From 06ef52cd2545b15e3bfed2588129cb64717a255c Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Mon, 22 Aug 2022 18:53:51 -0400 Subject: [PATCH] [decompiler] support for jak 2 (#1781) * [decompiler] suppport jak 2 * cleanpu * remove brief from gtest options * fix test --- common/type_system/TypeFieldLookup.cpp | 27 +- decompiler/CMakeLists.txt | 3 + decompiler/Function/Warnings.h | 1 - decompiler/IR2/AtomicOp.cpp | 51 +- decompiler/IR2/AtomicOp.h | 89 +- decompiler/IR2/AtomicOpTypeAnalysis.cpp | 1 + decompiler/IR2/Env.cpp | 124 +- decompiler/IR2/Env.h | 1 + decompiler/IR2/ExpressionHelpers.cpp | 31 +- decompiler/IR2/Form.cpp | 3 + decompiler/IR2/Form.h | 12 +- decompiler/IR2/FormExpressionAnalysis.cpp | 70 +- decompiler/IR2/IR2_common.h | 1 + decompiler/ObjectFile/LinkedObjectFile.h | 4 +- .../ObjectFile/LinkedObjectFileCreation.cpp | 2 +- decompiler/ObjectFile/ObjectFileDB.cpp | 2 +- decompiler/ObjectFile/ObjectFileDB.h | 1 + decompiler/ObjectFile/ObjectFileDB_IR2.cpp | 30 +- .../analysis/analyze_inspect_method.cpp | 9 +- decompiler/analysis/atomic_op_builder.cpp | 88 +- decompiler/analysis/insert_lets.cpp | 39 +- decompiler/config/jak2/all-types.gc | 9414 +++++++++-------- .../jak2/anonymous_function_types.jsonc | 30 + decompiler/config/jak2/hacks.jsonc | 38 +- decompiler/config/jak2/label_types.jsonc | 67 +- decompiler/config/jak2/stack_structures.jsonc | 159 +- decompiler/config/jak2/type_casts.jsonc | 365 +- decompiler/config/jak2/var_names.jsonc | 45 +- decompiler/config/jak2_ntsc_v1.jsonc | 2 +- decompiler/level_extractor/fr3_to_gltf.cpp | 4 +- decompiler/types2/ForwardProp.cpp | 2455 +++++ decompiler/types2/types2.cpp | 760 ++ decompiler/types2/types2.h | 248 + decompiler/util/DecompilerTypeSystem.cpp | 4 +- decompiler/util/data_decompile.cpp | 27 +- decompiler/util/goal_constants.h | 3 + goal_src/jak2/kernel-defs.gc | 2 +- goalc/build_level/collide_bvh.cpp | 62 +- test.sh | 2 +- test/decompiler/FormRegressionTest.h | 2 +- .../reference/jak1/engine/anim/joint_REF.gc | 2 +- .../jak1/engine/draw/drawable_REF.gc | 2 +- .../reference/jak1/engine/gfx/sky/sky_REF.gc | 2 +- .../reference/jak1/engine/math/vector_REF.gc | 22 +- .../reference/jak1/engine/util/glist_REF.gc | 4 +- .../jak1/levels/rolling/rolling-obs_REF.gc | 2 +- .../reference/jak2/decompiler-macros.gc | 141 + .../reference/jak2/kernel/gstate_REF.gc | 2 +- test/decompiler/test_InstructionDecode.cpp | 8 +- test/offline/config/jak2/config.jsonc | 21 +- test/offline/offline_test_main.cpp | 5 +- 51 files changed, 9934 insertions(+), 4555 deletions(-) create mode 100644 decompiler/types2/ForwardProp.cpp create mode 100644 decompiler/types2/types2.cpp create mode 100644 decompiler/types2/types2.h diff --git a/common/type_system/TypeFieldLookup.cpp b/common/type_system/TypeFieldLookup.cpp index cc013e71ec..5b690d75de 100644 --- a/common/type_system/TypeFieldLookup.cpp +++ b/common/type_system/TypeFieldLookup.cpp @@ -482,20 +482,6 @@ FieldReverseLookupOutput TypeSystem::reverse_field_lookup( // just use the multi-lookup set to 1 and grab the first result. auto multi_result = reverse_field_multi_lookup(input, 100); - for (auto& result : multi_result.results) { - // compute the score. - result.total_score = 0; - for (auto& tok : result.tokens) { - result.total_score += tok.score(); - } - } - - // use stable sort to make sure we break ties by being first in the order. - std::stable_sort(multi_result.results.begin(), multi_result.results.end(), - [](const FieldReverseLookupOutput& a, const FieldReverseLookupOutput& b) { - return a.total_score > b.total_score; - }); - /* if (multi_result.results.size() > 1) { fmt::print("Multiple:\n"); @@ -532,6 +518,19 @@ FieldReverseMultiLookupOutput TypeSystem::reverse_field_multi_lookup( try_reverse_lookup(input, *this, nullptr, &result, max_count); if (!result.results.empty()) { result.success = true; + for (auto& r : result.results) { + // compute the score. + r.total_score = 0; + for (auto& tok : r.tokens) { + r.total_score += tok.score(); + } + } + + // use stable sort to make sure we break ties by being first in the order. + std::stable_sort(result.results.begin(), result.results.end(), + [](const FieldReverseLookupOutput& a, const FieldReverseLookupOutput& b) { + return a.total_score > b.total_score; + }); } return result; } diff --git a/decompiler/CMakeLists.txt b/decompiler/CMakeLists.txt index db9b96959a..0374470012 100644 --- a/decompiler/CMakeLists.txt +++ b/decompiler/CMakeLists.txt @@ -69,6 +69,9 @@ add_library( ObjectFile/ObjectFileDB.cpp ObjectFile/ObjectFileDB_IR2.cpp + types2/ForwardProp.cpp + types2/types2.cpp + util/config_parsers.cpp util/data_decompile.cpp util/DataParser.cpp diff --git a/decompiler/Function/Warnings.h b/decompiler/Function/Warnings.h index ad1a7bc4f1..92426b73d1 100644 --- a/decompiler/Function/Warnings.h +++ b/decompiler/Function/Warnings.h @@ -104,6 +104,5 @@ class DecompWarnings { } std::vector m_warnings; - bool m_used_lq_sq = false; }; } // namespace decompiler diff --git a/decompiler/IR2/AtomicOp.cpp b/decompiler/IR2/AtomicOp.cpp index 72f19106df..d5d4b9a17e 100644 --- a/decompiler/IR2/AtomicOp.cpp +++ b/decompiler/IR2/AtomicOp.cpp @@ -142,16 +142,55 @@ SimpleAtom SimpleAtom::make_static_address(int static_label_id) { return result; } +/*! + * Mark this atom as a float. It will be printed as a float. + * This can only be applied to an "integer" atom. + * This should be used carefully, as this doesn't handle casts/types - it just changes the + * representation, which will do the wrong thing unless the type system is aware of this + * too. + */ +void SimpleAtom::mark_as_float() { + ASSERT(is_int()); + m_display_int_as_float = true; +} + +bool SimpleAtom::is_integer_promoted_to_float() const { + return m_kind == Kind::INTEGER_CONSTANT && m_display_int_as_float; +} + +float SimpleAtom::get_integer_promoted_to_float() const { + ASSERT(is_integer_promoted_to_float()); + s32 as_s32 = get_int(); + ASSERT(get_int() == (s64)as_s32); + float result; + memcpy(&result, &as_s32, 4); + return result; +} + goos::Object SimpleAtom::to_form(const std::vector& labels, const Env& env) const { switch (m_kind) { case Kind::VARIABLE: return m_variable.to_form(env); case Kind::INTEGER_CONSTANT: { - if (std::abs(m_int) > INT32_MAX) { - u64 v = m_int; - return pretty_print::to_symbol(fmt::format("#x{:x}", v)); + if (m_display_int_as_float) { + float f; + s32 as_s32 = m_int; + ASSERT(((s64)as_s32) == m_int); // float should always be a sign extended 32-bit value. + memcpy(&f, &as_s32, 4); + if (f == f) { + return goos::Object::make_float(f); + } else { + // nan or weird + ASSERT(false); // let's abort on this for now, can remove if it actually comes up. + return pretty_print::to_symbol(fmt::format("(the-as float #x{:x})", m_int)); + } } else { - return goos::Object::make_integer(m_int); + if (std::abs(m_int) > INT32_MAX) { + u64 v = m_int; + return pretty_print::to_symbol(fmt::format("#x{:x}", v)); + } else { + return goos::Object::make_integer(m_int); + } } } @@ -311,6 +350,8 @@ std::string get_simple_expression_op_name(SimpleExpression::Kind kind) { return "vec3dot"; case SimpleExpression::Kind::VECTOR_4_DOT: return "vec4dot"; + case SimpleExpression::Kind::VECTOR_LENGTH: + return "veclength"; case SimpleExpression::Kind::SET_ON_LESS_THAN: case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM: return "set-on-less-than"; @@ -378,6 +419,8 @@ int get_simple_expression_arg_count(SimpleExpression::Kind kind) { case SimpleExpression::Kind::SET_ON_LESS_THAN: case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM: return 2; + case SimpleExpression::Kind::VECTOR_LENGTH: + return 1; default: ASSERT(false); return -1; diff --git a/decompiler/IR2/AtomicOp.h b/decompiler/IR2/AtomicOp.h index 7b84193768..1cecc2e497 100644 --- a/decompiler/IR2/AtomicOp.h +++ b/decompiler/IR2/AtomicOp.h @@ -19,6 +19,11 @@ class FormElement; class ConditionElement; class FormPool; class DecompilerTypeSystem; +namespace types2 { +struct Instruction; +struct TypeState; +struct TypePropExtras; +} // namespace types2 /*! * An atomic operation represents a single operation from the point of view of the IR2 system. @@ -78,6 +83,12 @@ class AtomicOp { TypeState propagate_types(const TypeState& input, const Env& env, DecompilerTypeSystem& dts); + virtual void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) = 0; + int op_id() const { return m_my_idx; } const std::vector& read_regs() const { return m_read_regs; } const std::vector& write_regs() const { return m_write_regs; } @@ -176,12 +187,16 @@ class SimpleAtom { ASSERT(is_sym_ptr() || is_sym_val()); return m_string; } + void mark_as_float(); + bool is_integer_promoted_to_float() const; + float get_integer_promoted_to_float() const; private: Kind m_kind = Kind::INVALID; std::string m_string; // for symbol ptr and symbol val s64 m_int = -1; // for integer constant and static address label id RegisterAccess m_variable; + bool m_display_int_as_float = false; }; /*! @@ -240,6 +255,7 @@ class SimpleExpression { SUBU_L32_S7, // use SUBU X, src0, s7 to check if lower 32-bits are s7. VECTOR_3_DOT, VECTOR_4_DOT, + VECTOR_LENGTH, // jak 2 only. SET_ON_LESS_THAN, SET_ON_LESS_THAN_IMM }; @@ -250,6 +266,11 @@ class SimpleExpression { ASSERT(idx < args()); return m_args[idx]; } + + SimpleAtom& get_arg(int idx) { + ASSERT(idx < args()); + return m_args[idx]; + } Kind kind() const { return m_kind; } SimpleExpression() = default; SimpleExpression(Kind kind, const SimpleAtom& arg0); @@ -304,6 +325,11 @@ class SetVarOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; const RegisterAccess& dst() const { return m_dst; } const SimpleExpression& src() const { return m_src; } @@ -334,6 +360,11 @@ class AsmOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; const Instruction& instruction() const { return m_instr; } const std::optional dst() const { return m_dst; } @@ -437,6 +468,11 @@ class SetVarConditionOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; private: @@ -463,6 +499,11 @@ class StoreOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; const SimpleExpression& addr() const { return m_addr; } const SimpleAtom& value() const { return m_value; } @@ -492,9 +533,13 @@ class LoadVarOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; TP_Type get_src_type(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) const; void collect_vars(RegAccessSet& vars) const override; - const SimpleExpression& src() const { return m_src; } Kind kind() const { return m_kind; } int size() const { return m_size; } @@ -580,6 +625,11 @@ class BranchOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; const IR2_BranchDelay& branch_delay() const { return m_branch_delay; } const IR2_Condition& condition() const { return m_condition; } @@ -616,6 +666,11 @@ class AsmBranchOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; bool is_likely() const { return m_likely; } const IR2_Condition& condition() const { return m_condition; } @@ -653,6 +708,11 @@ class SpecialOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; Kind kind() const { return m_kind; } @@ -676,6 +736,11 @@ class CallOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; const std::vector& arg_vars() const { return m_arg_vars; } RegisterAccess function_var() const { return m_function_var; } @@ -717,6 +782,11 @@ class ConditionalMoveFalseOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; private: @@ -748,6 +818,11 @@ class FunctionEndOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; void mark_function_as_no_return_value(); const RegisterAccess& return_var() const { @@ -775,7 +850,13 @@ class StackSpillStoreOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; + int offset() const { return m_offset; } private: SimpleAtom m_value; @@ -798,7 +879,13 @@ class StackSpillLoadOp : public AtomicOp { TypeState propagate_types_internal(const TypeState& input, const Env& env, DecompilerTypeSystem& dts) override; + void propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) override; void collect_vars(RegAccessSet& vars) const override; + int offset() const { return m_offset; } private: RegisterAccess m_dst; diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 327e8ada80..c843bfbdee 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -243,6 +243,7 @@ TP_Type SimpleExpression::get_type(const TypeState& input, return TP_Type::make_from_ts("int"); case Kind::VECTOR_3_DOT: case Kind::VECTOR_4_DOT: + case Kind::VECTOR_LENGTH: return TP_Type::make_from_ts("float"); default: throw std::runtime_error("Simple expression cannot get_type: " + diff --git a/decompiler/IR2/Env.cpp b/decompiler/IR2/Env.cpp index b520dbc952..011fccd69e 100644 --- a/decompiler/IR2/Env.cpp +++ b/decompiler/IR2/Env.cpp @@ -507,69 +507,73 @@ void Env::disable_use(const RegisterAccess& access) { */ void Env::set_stack_structure_hints(const std::vector& hints) { for (auto& hint : hints) { - StackStructureEntry entry; - entry.hint = hint; - - switch (hint.container_type) { - case StackStructureHint::ContainerType::NONE: { - // parse the type spec. - TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); - auto type_info = dts->ts.lookup_type(base_typespec); - // just a plain object on the stack. - if (!type_info->is_reference()) { - throw std::runtime_error( - fmt::format("Stack variable type {} is not a reference and cannot be stored directly " - "on the stack. Use an array instead.", - base_typespec.print())); - } - entry.ref_type = base_typespec; - entry.size = type_info->get_size_in_memory(); - // sanity check the alignment - if (align(entry.hint.stack_offset, type_info->get_in_memory_alignment()) != - entry.hint.stack_offset) { - lg::error("Misaligned stack variable of type {} offset {} required align {}\n", - entry.ref_type.print(), entry.hint.stack_offset, - type_info->get_in_memory_alignment()); - } - } break; - - case StackStructureHint::ContainerType::INLINE_ARRAY: { - TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); - auto type_info = dts->ts.lookup_type(base_typespec); - if (!type_info->is_reference()) { - throw std::runtime_error( - fmt::format("Stack inline-array element type {} is not a reference and cannot be " - "stored in an inline-array. Use an array instead.", - base_typespec.print())); - } - - entry.ref_type = TypeSpec("inline-array", {TypeSpec(base_typespec)}); - entry.size = 1; // we assume that there is no constant propagation into this array and - // make this only trigger in get_stack_type if we hit exactly. - // sanity check the alignment - if (align(entry.hint.stack_offset, type_info->get_in_memory_alignment()) != - entry.hint.stack_offset) { - lg::error("Misaligned stack variable of type {} offset {} required align {}\n", - entry.ref_type.print(), entry.hint.stack_offset, - type_info->get_in_memory_alignment()); - } - } break; - - case StackStructureHint::ContainerType::ARRAY: { - TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); - entry.ref_type = TypeSpec("pointer", {TypeSpec(base_typespec)}); - entry.size = 1; // we assume that there is no constant propagation into this array and - // make this only trigger in get_stack_type if we hit exactly. - break; - } - default: - ASSERT(false); - } - - m_stack_structures.push_back(entry); + add_stack_structure_hint(hint); } } +void Env::add_stack_structure_hint(const StackStructureHint& hint) { + StackStructureEntry entry; + entry.hint = hint; + + switch (hint.container_type) { + case StackStructureHint::ContainerType::NONE: { + // parse the type spec. + TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); + auto type_info = dts->ts.lookup_type(base_typespec); + // just a plain object on the stack. + if (!type_info->is_reference()) { + throw std::runtime_error( + fmt::format("Stack variable type {} is not a reference and cannot be stored directly " + "on the stack. Use an array instead.", + base_typespec.print())); + } + entry.ref_type = base_typespec; + entry.size = type_info->get_size_in_memory(); + // sanity check the alignment + if (align(entry.hint.stack_offset, type_info->get_in_memory_alignment()) != + entry.hint.stack_offset) { + lg::error("Misaligned stack variable of type {} offset {} required align {}\n", + entry.ref_type.print(), entry.hint.stack_offset, + type_info->get_in_memory_alignment()); + } + } break; + + case StackStructureHint::ContainerType::INLINE_ARRAY: { + TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); + auto type_info = dts->ts.lookup_type(base_typespec); + if (!type_info->is_reference()) { + throw std::runtime_error( + fmt::format("Stack inline-array element type {} is not a reference and cannot be " + "stored in an inline-array. Use an array instead.", + base_typespec.print())); + } + + entry.ref_type = TypeSpec("inline-array", {TypeSpec(base_typespec)}); + entry.size = 1; // we assume that there is no constant propagation into this array and + // make this only trigger in get_stack_type if we hit exactly. + // sanity check the alignment + if (align(entry.hint.stack_offset, type_info->get_in_memory_alignment()) != + entry.hint.stack_offset) { + lg::error("Misaligned stack variable of type {} offset {} required align {}\n", + entry.ref_type.print(), entry.hint.stack_offset, + type_info->get_in_memory_alignment()); + } + } break; + + case StackStructureHint::ContainerType::ARRAY: { + TypeSpec base_typespec = dts->parse_type_spec(hint.element_type); + entry.ref_type = TypeSpec("pointer", {TypeSpec(base_typespec)}); + entry.size = 1; // we assume that there is no constant propagation into this array and + // make this only trigger in get_stack_type if we hit exactly. + break; + } + default: + ASSERT(false); + } + + m_stack_structures.push_back(entry); +} + std::optional Env::get_art_elt_name(int idx) const { ASSERT(dts); auto it = dts->art_group_info.find(art_group()); diff --git a/decompiler/IR2/Env.h b/decompiler/IR2/Env.h index c577d44d06..6c5a6ef894 100644 --- a/decompiler/IR2/Env.h +++ b/decompiler/IR2/Env.h @@ -174,6 +174,7 @@ class Env { } void set_stack_structure_hints(const std::vector& hints); + void add_stack_structure_hint(const StackStructureHint& hint); const std::vector& stack_structure_hints() const { return m_stack_structures; } diff --git a/decompiler/IR2/ExpressionHelpers.cpp b/decompiler/IR2/ExpressionHelpers.cpp index abbee45fca..b231cf114c 100644 --- a/decompiler/IR2/ExpressionHelpers.cpp +++ b/decompiler/IR2/ExpressionHelpers.cpp @@ -9,6 +9,20 @@ namespace decompiler { +// needed for jak 2. +std::optional try_get_const_float(const Form* form) { + auto* as_cfe = form->try_as_element(); + if (as_cfe) { + return as_cfe->value(); + } + + auto atom = form_as_atom(form); + if (atom && atom->is_integer_promoted_to_float()) { + return atom->get_integer_promoted_to_float(); + } + return {}; +} + FormElement* handle_get_property_value_float(const std::vector& forms, FormPool& pool, const Env& env) { @@ -35,8 +49,8 @@ FormElement* handle_get_property_value_float(const std::vector& forms, } // get the time. It must be DEFAULT_RES_TIME - auto lookup_time = forms.at(3)->try_as_element(); - if (!lookup_time || lookup_time->value() != DEFAULT_RES_TIME) { + auto lookup_time = try_get_const_float(forms.at(3)); + if (!lookup_time || *lookup_time != DEFAULT_RES_TIME) { fmt::print("fail: bad time {}\n", forms.at(3)->to_string(env)); return nullptr; } @@ -44,8 +58,8 @@ FormElement* handle_get_property_value_float(const std::vector& forms, // get the default value. It can be anything... Form* default_value = forms.at(4); // but let's see if it's 0, because that's the default in the macro - auto default_value_float = default_value->try_as_element(); - if (default_value_float && default_value_float->value() == 0) { + auto default_value_float = try_get_const_float(default_value); + if (default_value_float && *default_value_float == 0) { default_value = nullptr; } @@ -111,8 +125,8 @@ FormElement* handle_get_property_data_or_structure(const std::vector& for // get the time. It can be anything, but there's a default. auto time = forms.at(3); - auto lookup_time = time->try_as_element(); - if (lookup_time && lookup_time->value() == DEFAULT_RES_TIME) { + auto lookup_time = try_get_const_float(time); + if (lookup_time && *lookup_time == DEFAULT_RES_TIME) { time = nullptr; } @@ -153,8 +167,9 @@ FormElement* handle_get_property_data(const std::vector& forms, FormElement* handle_get_property_struct(const std::vector& forms, FormPool& pool, const Env& env) { - return handle_get_property_data_or_structure(forms, pool, env, ResLumpMacroElement::Kind::STRUCT, - "#f", TypeSpec("structure")); + return handle_get_property_data_or_structure( + forms, pool, env, ResLumpMacroElement::Kind::STRUCT, + env.version == GameVersion::Jak2 ? "(the-as structure #f)" : "#f", TypeSpec("structure")); } FormElement* handle_get_property_value(const std::vector& forms, diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index 11ae58520c..d312987516 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -1862,6 +1862,8 @@ std::string fixed_operator_to_string(FixedOperatorKind kind) { return "cpad-pressed?"; case FixedOperatorKind::CPAD_HOLD_P: return "cpad-hold?"; + case FixedOperatorKind::VECTOR_LENGTH: + return "vector-length"; default: ASSERT(false); return ""; @@ -3193,6 +3195,7 @@ goos::Object DefpartElement::to_form_internal(const Env& env) const { // sp-end break; } + ASSERT(env.version == GameVersion::Jak1); // need to update enums item_forms.push_back(decompile_sparticle_field_init(e, env.dts->ts)); } if (!item_forms.empty()) { diff --git a/decompiler/IR2/Form.h b/decompiler/IR2/Form.h index 6eab5e872f..d7fd877143 100644 --- a/decompiler/IR2/Form.h +++ b/decompiler/IR2/Form.h @@ -228,12 +228,12 @@ class SimpleExpressionElement : public FormElement { FormStack& stack, std::vector* result, bool allow_side_effects); - void update_from_stack_vector_dot(FixedOperatorKind kind, - const Env& env, - FormPool& pool, - FormStack& stack, - std::vector* result, - bool allow_side_effects); + void update_from_stack_vectors_in_common(FixedOperatorKind kind, + const Env& env, + FormPool& pool, + FormStack& stack, + std::vector* result, + bool allow_side_effects); const SimpleExpression& expr() const { return m_expr; } diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 17ce439e74..ebd10e5d3e 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1504,24 +1504,28 @@ void SimpleExpressionElement::update_from_stack_vector_float_product( result->push_back(new_form); } -void SimpleExpressionElement::update_from_stack_vector_dot(FixedOperatorKind kind, - const Env& env, - FormPool& pool, - FormStack& stack, - std::vector* result, - bool allow_side_effects) { - std::vector popped_args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, - env, pool, stack, allow_side_effects); +void SimpleExpressionElement::update_from_stack_vectors_in_common(FixedOperatorKind kind, + const Env& env, + FormPool& pool, + FormStack& stack, + std::vector* result, + bool allow_side_effects) { + std::vector register_acccesses; + for (int arg_idx = 0; arg_idx < m_expr.args(); arg_idx++) { + register_acccesses.push_back(m_expr.get_arg(arg_idx).var()); + } + std::vector popped_args = + pop_to_forms(register_acccesses, env, pool, stack, allow_side_effects); - for (int i = 0; i < 2; i++) { + for (int i = 0; i < m_expr.args(); i++) { auto arg_type = env.get_types_before_op(m_my_idx).get(m_expr.get_arg(i).var().reg()); if (arg_type.typespec() != TypeSpec("vector")) { popped_args.at(i) = cast_form(popped_args.at(i), TypeSpec("vector"), pool, env); } } - auto new_form = pool.alloc_element( - GenericOperator::make_fixed(kind), std::vector{popped_args.at(0), popped_args.at(1)}); + auto new_form = + pool.alloc_element(GenericOperator::make_fixed(kind), popped_args); result->push_back(new_form); } @@ -1606,7 +1610,14 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper( FormStack& stack, bool allow_side_effects) { // grab the normal variable type - auto arg0_type = env.get_variable_type(m_expr.get_arg(0).var(), true); + TypeSpec arg0_type; + if (m_expr.get_arg(0).is_var()) { + arg0_type = env.get_variable_type(m_expr.get_arg(0).var(), true); + } else if (m_expr.get_arg(0).is_int(0)) { + arg0_type = TypeSpec("int"); // ?? + } else { + ASSERT(false); + } // and try to get it as a bitfield auto type_info = env.dts->ts.lookup_type(arg0_type); @@ -1614,7 +1625,7 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper( bool had_pcpyud = false; TypeSpec bitfield_type = arg0_type; - if (!bitfield_info) { + if (!bitfield_info && m_expr.get_arg(0).is_var()) { // the above won't work if we're already done a pcpyud to grab the upper 64 bits. // we need to grab the type in the register (a TP_type) and check const auto& arg0_reg_type = @@ -1672,15 +1683,25 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper( } else { // and, two forms auto arg1_type = env.get_variable_type(m_expr.get_arg(1).var(), true); - auto arg0_i = is_int_type(env, m_my_idx, m_expr.get_arg(0).var()); - auto arg0_u = is_uint_type(env, m_my_idx, m_expr.get_arg(0).var()); + auto arg0_i = + m_expr.get_arg(0).is_var() ? is_int_type(env, m_my_idx, m_expr.get_arg(0).var()) : true; + auto arg0_u = + m_expr.get_arg(0).is_var() ? is_uint_type(env, m_my_idx, m_expr.get_arg(0).var()) : false; auto arg1_i = is_int_type(env, m_my_idx, m_expr.get_arg(1).var()); auto arg1_u = is_uint_type(env, m_my_idx, m_expr.get_arg(1).var()); auto arg0_n = arg0_i || arg0_u; auto arg1_n = arg1_i || arg1_u; - auto args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, env, pool, stack, - allow_side_effects); + std::vector args; + + if (m_expr.get_arg(0).is_var()) { + args = pop_to_forms({m_expr.get_arg(0).var(), m_expr.get_arg(1).var()}, env, pool, stack, + allow_side_effects); + } else { + args = pop_to_forms({m_expr.get_arg(1).var()}, env, pool, stack, allow_side_effects); + args.insert(args.begin(), pool.form( + SimpleAtom::make_int_constant(m_expr.get_arg(0).get_int()))); + } if (bitfield_info) { // either the immediate didn't fit in the 16-bit imm or it's with a variable @@ -2318,12 +2339,16 @@ void SimpleExpressionElement::update_from_stack(const Env& env, update_from_stack_subu_l32_s7(env, pool, stack, result, allow_side_effects); break; case SimpleExpression::Kind::VECTOR_3_DOT: - update_from_stack_vector_dot(FixedOperatorKind::VECTOR_3_DOT, env, pool, stack, result, - allow_side_effects); + update_from_stack_vectors_in_common(FixedOperatorKind::VECTOR_3_DOT, env, pool, stack, result, + allow_side_effects); break; case SimpleExpression::Kind::VECTOR_4_DOT: - update_from_stack_vector_dot(FixedOperatorKind::VECTOR_4_DOT, env, pool, stack, result, - allow_side_effects); + update_from_stack_vectors_in_common(FixedOperatorKind::VECTOR_4_DOT, env, pool, stack, result, + allow_side_effects); + break; + case SimpleExpression::Kind::VECTOR_LENGTH: + update_from_stack_vectors_in_common(FixedOperatorKind::VECTOR_LENGTH, env, pool, stack, + result, allow_side_effects); break; default: throw std::runtime_error( @@ -2701,7 +2726,8 @@ bool try_to_rewrite_matrix_inline_ctor(const Env& env, FormPool& pool, FormStack } else { matcher = Matcher::set( Matcher::deref(Matcher::any_reg(0), false, - {DerefTokenMatcher::string("quad"), DerefTokenMatcher::integer(i)}), + {DerefTokenMatcher::string("vector"), DerefTokenMatcher::integer(i), + DerefTokenMatcher::string("quad")}), Matcher::cast("uint128", Matcher::integer(0))); } diff --git a/decompiler/IR2/IR2_common.h b/decompiler/IR2/IR2_common.h index 0f1e4f387c..cb6dfca92e 100644 --- a/decompiler/IR2/IR2_common.h +++ b/decompiler/IR2/IR2_common.h @@ -169,6 +169,7 @@ enum class FixedOperatorKind { PROCESS_TO_HANDLE, PPOINTER_TO_PROCESS, VECTOR_4_DOT, + VECTOR_LENGTH, SEND_EVENT, CPAD_PRESSED_P, CPAD_HOLD_P, diff --git a/decompiler/ObjectFile/LinkedObjectFile.h b/decompiler/ObjectFile/LinkedObjectFile.h index d33b30f4e3..f592892a03 100644 --- a/decompiler/ObjectFile/LinkedObjectFile.h +++ b/decompiler/ObjectFile/LinkedObjectFile.h @@ -25,7 +25,7 @@ namespace decompiler { */ class LinkedObjectFile { public: - LinkedObjectFile() = default; + LinkedObjectFile(GameVersion version) : version(version){}; void set_segment_count(int n_segs); void push_back_word_to_segment(uint32_t word, int segment); int get_label_id_for(int seg, int offset); @@ -137,6 +137,8 @@ class LinkedObjectFile { std::unique_ptr label_db; + GameVersion version; + private: goos::Object to_form_script(int seg, int word_idx, std::vector& seen); goos::Object to_form_script_object(int seg, int byte_idx, std::vector& seen); diff --git a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp index f95d717482..51db88689e 100644 --- a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp +++ b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp @@ -816,7 +816,7 @@ LinkedObjectFile to_linked_object_file(const std::vector& data, const std::string& name, DecompilerTypeSystem& dts, GameVersion game_version) { - LinkedObjectFile result; + LinkedObjectFile result(game_version); const auto* header = (const LinkHeaderCommon*)&data.at(0); // use appropriate linker diff --git a/decompiler/ObjectFile/ObjectFileDB.cpp b/decompiler/ObjectFile/ObjectFileDB.cpp index cbf7a570af..4f1adf3563 100644 --- a/decompiler/ObjectFile/ObjectFileDB.cpp +++ b/decompiler/ObjectFile/ObjectFileDB.cpp @@ -359,7 +359,7 @@ void ObjectFileDB::add_obj_from_dgo(const std::string& obj_name, } // nope, have to add a new one. - ObjectFileData data; + ObjectFileData data(config.game_version); data.data.resize(obj_size); memcpy(data.data.data(), obj_data, obj_size); data.record.hash = hash; diff --git a/decompiler/ObjectFile/ObjectFileDB.h b/decompiler/ObjectFile/ObjectFileDB.h index 1db8ad242c..37f072874a 100644 --- a/decompiler/ObjectFile/ObjectFileDB.h +++ b/decompiler/ObjectFile/ObjectFileDB.h @@ -37,6 +37,7 @@ struct ObjectFileRecord { * All of the data for a single object file */ struct ObjectFileData { + ObjectFileData(GameVersion version) : linked_data(version) {} std::vector data; // raw bytes LinkedObjectFile linked_data; // data including linking annotations ObjectFileRecord record; // name diff --git a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp index 3d11c4e462..70563bbec8 100644 --- a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp +++ b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp @@ -29,6 +29,7 @@ #include "decompiler/analysis/symbol_def_map.h" #include "decompiler/analysis/type_analysis.h" #include "decompiler/analysis/variable_naming.h" +#include "decompiler/types2/types2.h" namespace decompiler { @@ -538,14 +539,33 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF func.ir2.env.set_art_group(obj_name + "-ag"); } - if (run_type_analysis_ir2(ts, dts, func)) { - func.ir2.env.types_succeeded = true; + constexpr bool kForceNewTypes = false; + if (config.game_version == GameVersion::Jak2 || kForceNewTypes) { + // use new types for jak 2 always + types2::Input in; + types2::Output out; + in.func = &func; + in.function_type = ts; + in.dts = &dts; + try { + types2::run(out, in); + func.ir2.env.set_types(out.block_init_types, out.op_end_types, *func.ir2.atomic_ops, + ts); + } catch (const std::exception& e) { + func.warnings.warning("Type analysis failed: {}", e.what()); + } + func.ir2.env.types_succeeded = out.succeeded; } else { - func.warnings.error("Type Propagation failed: Type analysis failed"); + // old type pass + if (run_type_analysis_ir2(ts, dts, func)) { + func.ir2.env.types_succeeded = true; + } else { + func.warnings.warning("Type analysis failed"); + } } } else { lg::warn("Function {} didn't know its type", func.name()); - func.warnings.error("Function {} has unknown type", func.name()); + func.warnings.warning("Function {} has unknown type", func.name()); } } }); @@ -872,9 +892,11 @@ std::string ObjectFileDB::ir2_function_to_string(ObjectFileData& data, Function& result += ";; Warnings:\n" + func.warnings.get_warning_text(true) + "\n"; } + /* if (func.ir2.env.has_local_vars()) { result += func.ir2.env.print_local_var_types(func.ir2.top_form); } + */ bool print_atomics = func.ir2.atomic_ops_succeeded; // print each instruction in the function. diff --git a/decompiler/analysis/analyze_inspect_method.cpp b/decompiler/analysis/analyze_inspect_method.cpp index 3c26986434..a42dcd3872 100644 --- a/decompiler/analysis/analyze_inspect_method.cpp +++ b/decompiler/analysis/analyze_inspect_method.cpp @@ -1157,7 +1157,7 @@ bool allow_guess(const Field& field) { std::string TypeInspectorResult::print_as_deftype( StructureType* old_game_type, std::unordered_map& previous_results, - DecompilerTypeSystem& previous_game_ts, + DecompilerTypeSystem& /*previous_game_ts*/, ObjectFileDB::PerObjectAllTypeInfo& object_file_meta) { std::string result; @@ -1408,8 +1408,8 @@ std::string get_label_type_name(LinkedObjectFile& file, std::string label_name) void inspect_top_level_for_metadata(Function& top_level, LinkedObjectFile& file, - DecompilerTypeSystem& dts, - DecompilerTypeSystem& previous_game_ts, + DecompilerTypeSystem& /*dts*/, + DecompilerTypeSystem& /*previous_game_ts*/, ObjectFileDB::PerObjectAllTypeInfo& objectFile) { // State as a method: /* @@ -1434,7 +1434,7 @@ void inspect_top_level_for_metadata(Function& top_level, // Check for non-method states std::string last_seen_label = ""; // TODO - safely increment op number - for (int i = 0; i < top_level.ir2.atomic_ops->ops.size(); i++) { + for (int i = 0; i < (int)top_level.ir2.atomic_ops->ops.size(); i++) { const auto& aop = top_level.ir2.atomic_ops->ops.at(i); const std::string as_str = aop.get()->to_string(top_level.ir2.env); @@ -1488,7 +1488,6 @@ void inspect_top_level_for_metadata(Function& top_level, // Check for types // if there's no inspect method, we can use just use the call to the type's new method // to find the type - const auto& env = top_level.ir2.env; for (int i = 0; i < ((int)top_level.ir2.atomic_ops->ops.size()) - 5; i++) { // lw v1, type(s7) ;; [ 20] (set! v1-10 type) [] -> [v1: ] const auto& aop_0 = top_level.ir2.atomic_ops->ops.at(i); diff --git a/decompiler/analysis/atomic_op_builder.cpp b/decompiler/analysis/atomic_op_builder.cpp index b633c56e3c..35ff7bdb5c 100644 --- a/decompiler/analysis/atomic_op_builder.cpp +++ b/decompiler/analysis/atomic_op_builder.cpp @@ -3,10 +3,10 @@ #include "atomic_op_builder.h" #include "common/log/log.h" #include "common/symbols.h" +#include "decompiler/Disasm/DecompilerLabel.h" #include "decompiler/Disasm/InstructionMatching.h" #include "decompiler/Function/Function.h" #include "decompiler/Function/Warnings.h" -#include "decompiler/util/TP_Type.h" namespace decompiler { @@ -1944,6 +1944,87 @@ std::unique_ptr convert_vector3_dot(const Instruction* instrs, int idx idx); } +std::unique_ptr convert_vector_length(const Instruction* instrs, int idx) { + // 0: lqc2 vf1, 0(a1) + if (instrs[0].kind != InstructionKind::LQC2 || instrs[0].get_dst(0).get_reg() != make_vf(1) || + !instrs[0].get_src(0).is_imm(0)) { + return nullptr; + } + Register vec_src = instrs[0].get_src(1).get_reg(); + + auto vf0 = make_vf(0); + auto vf1 = make_vf(1); + + // 1: vmul.xyzw vf1, vf1, vf1 + std::vector labels; + if (instrs[1].kind != InstructionKind::VMUL || instrs[1].get_dst(0).get_reg() != vf1 || + instrs[1].get_src(0).get_reg() != vf1 || instrs[1].get_src(1).get_reg() != vf1 || + instrs[1].cop2_dest != 0b1111) { + return nullptr; + } + + // 2: vmulax.w acc, vf0, vf1 + if (instrs[2].kind != InstructionKind::VMULA_BC || instrs[2].get_src(0).get_reg() != vf0 || + instrs[2].get_src(1).get_reg() != vf1 || instrs[2].cop2_dest != 0b0001 || + instrs[2].cop2_bc != 0) { + return nullptr; + } + + // 3: vmadday.w acc, vf0, vf1 + if (instrs[3].kind != InstructionKind::VMADDA_BC || instrs[3].get_src(0).get_reg() != vf0 || + instrs[3].get_src(1).get_reg() != vf1 || instrs[3].cop2_dest != 0b0001 || + instrs[3].cop2_bc != 1) { + return nullptr; + } + + // 4: vmaddz.w vf1, vf0, vf1 + if (instrs[4].kind != InstructionKind::VMADD_BC || instrs[4].get_dst(0).get_reg() != vf1 || + instrs[4].get_src(0).get_reg() != vf0 || instrs[4].get_src(1).get_reg() != vf1 || + instrs[4].cop2_dest != 0b0001 || instrs[4].cop2_bc != 2) { + return nullptr; + } + + // 5: vsqrt Q, vf1.w + if (instrs[5].kind != InstructionKind::VSQRT || instrs[5].get_src(0).get_reg() != vf1) { + return nullptr; + } + + // 6: vaddw.x vf1, vf0, vf0 + if (instrs[6].kind != InstructionKind::VADD_BC || instrs[6].get_dst(0).get_reg() != vf1 || + instrs[6].get_src(0).get_reg() != vf0 || instrs[6].get_src(1).get_reg() != vf0 || + instrs[6].cop2_dest != 0b1000 || instrs[6].cop2_bc != 3) { + return nullptr; + } + + // 7: vwaitq + if (instrs[7].kind != InstructionKind::VWAITQ) { + return nullptr; + } + + // 8: vmulq.x vf1, vf1, Q + if (instrs[8].kind != InstructionKind::VMULQ || instrs[8].get_dst(0).get_reg() != vf1 || + instrs[8].get_src(0).get_reg() != vf1 || instrs[8].cop2_dest != 0b1000) { + return nullptr; + } + + // 9: vnop + if (instrs[9].kind != InstructionKind::VNOP) { + return nullptr; + } + // 10: vnop + if (instrs[10].kind != InstructionKind::VNOP) { + return nullptr; + } + // 11: qmfc2.i a1, vf1 + if (instrs[11].kind != InstructionKind::QMFC2 || instrs[11].src->get_reg() != vf1) { + return nullptr; + } + auto dst = instrs[11].get_dst(0).get_reg(); + return std::make_unique( + make_dst_var(dst, idx), + SimpleExpression(SimpleExpression::Kind::VECTOR_LENGTH, make_src_atom(vec_src, idx)), idx); +} + // 12 instructions std::unique_ptr convert_vector4_dot(const Instruction* instrs, int idx) { // lwc1 f0, 0(a0) @@ -2061,6 +2142,11 @@ std::unique_ptr convert_12(const Instruction* instrs, int idx) { if (as_vector4_dot) { return as_vector4_dot; } + + auto as_vector_length = convert_vector_length(instrs, idx); + if (as_vector_length) { + return as_vector_length; + } return nullptr; } diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index e3ae2ac3c4..8ea37652e9 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -340,19 +340,46 @@ FormElement* rewrite_as_send_event(LetElement* in, //////////////////////////////////////////////////////// // (set! (-> block-var from) ) bool not_proc = false; - Matcher set_from_matcher = Matcher::set( - Matcher::deref(Matcher::reg(block_var_reg), false, {DerefTokenMatcher::string("from")}), - Matcher::any_reg(1)); + Matcher set_from_matcher; + switch (env.version) { + case GameVersion::Jak1: + set_from_matcher = Matcher::set( + Matcher::deref(Matcher::reg(block_var_reg), false, {DerefTokenMatcher::string("from")}), + Matcher::any_reg(1)); + break; + case GameVersion::Jak2: + // in jak 2, the event message block holds a ppointer instead. + set_from_matcher = Matcher::set( + Matcher::deref(Matcher::reg(block_var_reg), false, {DerefTokenMatcher::string("from")}), + Matcher::op_fixed(FixedOperatorKind::PROCESS_TO_PPOINTER, {Matcher::any_reg(1)})); + break; + default: + ASSERT(false); + } auto from_mr = match(set_from_matcher, body->at(0)); if (!from_mr.matched) { // initial matcher failed. try more advanced "from" matcher now. - Matcher set_from_form_matcher = Matcher::set( - Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("from")}), - Matcher::any(1)); + Matcher set_from_form_matcher; + switch (env.version) { + case GameVersion::Jak1: + set_from_form_matcher = Matcher::set( + Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("from")}), + Matcher::any(1)); + break; + case GameVersion::Jak2: + set_from_form_matcher = Matcher::set( + Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("from")}), + Matcher::op_fixed(FixedOperatorKind::PROCESS_TO_PPOINTER, {Matcher::any(1)})); + break; + default: + ASSERT(false); + } + from_mr = match(set_from_form_matcher, body->at(0)); if (!from_mr.matched) { return nullptr; } + fmt::print("case 1: {}\n", from_mr.maps.forms.at(1)->to_string(env)); not_proc = true; } diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index ace5237645..a5690714dd 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -12,16 +12,20 @@ (define-extern binteger type) (define-extern number type) (define-extern integer type) +(define-extern uinteger type) (define-extern float type) (define-extern boolean type) ;; not actually added as a runtime type in jak2, but valid? supports it. (define-extern uint16 type) (define-extern uint32 type) +(define-extern int32 type) (define-extern int64 type) +(define-extern uint8 type) (define-extern uint64 type) (define-extern process-tree type) (define-extern process type) (define-extern stack-frame type) (define-extern global kheap) +(define-extern kheap type) @@ -61,24 +65,46 @@ (define-extern scf-get-territory (function int)) ;; not actually a scf function... (define-extern mouse-get-data (function mouse-info none)) (define-extern file-stream-read (function file-stream pointer int int)) -(define-extern file-stream-open (function file-stream basic symbol file-stream)) +(define-extern file-stream-open (function file-stream string symbol file-stream)) (define-extern file-stream-length (function file-stream int)) +(define-extern reset-path (function none)) +(define-extern flush-cache (function int none)) +(define-extern gs-store-image (function object object object)) +(define-extern sync-path (function int int int)) +(define-extern file-stream-write (function file-stream pointer uint uint)) +(define-extern file-stream-close (function file-stream file-stream)) +(define-extern new-dynamic-structure (function symbol type int structure)) +(define-extern kernel-shutdown (function none)) +(define-extern scf-get-timeout (function int)) +(define-extern scf-get-inactive-timeout (function int)) +(define-extern syncv (function int int)) +(define-extern string->symbol (function string symbol)) +(define-extern link-begin (function pointer (pointer uint8) int kheap link-flag int)) +(define-extern link-resume (function int)) +(define-extern link-reset (function none)) + +(define-extern loading-level kheap) + + + +(defenum kmalloc-flags + :bitfield #t + (align-16 4) + (align-64 6) + (align-256 8) + (memset 12) + (top 13) + ) + +(define-extern kmalloc (function kheap int kmalloc-flags string pointer)) + (define-extern *kernel-boot-message* symbol) +(define-extern *kernel-boot-art-group* string) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gcommon ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype array (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. - ) -|# - (deftype vec4s (uint128) ((x float :offset 0) (y float :offset 32) @@ -895,6 +921,7 @@ (w uint8 :offset 3) (clr uint32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -908,6 +935,7 @@ (w int8 :offset 3) (clr int32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -919,6 +947,7 @@ (y uint8 :offset 1) (clr uint16 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 @@ -940,6 +969,7 @@ (x int16 :offset 0) (y int16 :offset 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -951,6 +981,7 @@ (y uint16 :offset 2) (val uint32 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -1000,7 +1031,7 @@ ) (deftype vector4w (structure) - ((data uint32 4 :offset-assert 0) + ((data uint32 4 :offset-assert 0 :score -1) (x int32 :offset 0) (y int32 :offset 4) (z int32 :offset 8) @@ -1087,6 +1118,7 @@ (w int16 :offset 6) (long uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 @@ -1121,7 +1153,7 @@ ) (deftype vector-array (inline-array-class) - ((data vector :inline :dynamic :offset-assert 16) + ((data vector :inline :dynamic :offset-assert 16 :score 10) ) :method-count-assert 9 :size-assert #x10 @@ -1236,7 +1268,7 @@ (word uint32 4 :offset 0) (dword uint64 2 :offset 0) (quad uint128 :offset 0) - (vector vector :inline :offset 0) + (vector vector :inline :offset 0 :score -100) (vector4w vector4w :inline :offset 0) ) :method-count-assert 9 @@ -1297,7 +1329,7 @@ (intersects-line-segment? (_type_ vector vector) symbol 12) (set-from-point-offset! (_type_ vector vector) none 13) (set-from-point-offset-pad! (_type_ vector vector float) int 14) - (set-to-point! (_type_ vector vector float) none 15) + (set-to-point! (_type_ vector) none 15) (set-from-sphere! (_type_ sphere) none 16) (set-from-spheres! (_type_ (inline-array sphere) int) int 17) (get-bounding-sphere (_type_ vector) vector 18) @@ -1344,10 +1376,10 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftype matrix (structure) - ((data float 16 :offset-assert 0) - (vector vector 4 :offset 0) - (quad uint128 4 :offset 0) - (trans vector :inline :offset 48) + ((data float 16 :offset-assert 0) + (vector vector 4 :inline :offset 0) + (quad uint128 4 :offset 0) + (trans vector :inline :offset 48) ) :method-count-assert 10 :size-assert #x40 @@ -1359,7 +1391,7 @@ (deftype matrix3 (structure) ((data float 12 :offset-assert 0) - (vector vector 3 :offset 0) + (vector vector 3 :inline :offset 0) (quad uint128 3 :offset 0) ) :method-count-assert 9 @@ -1368,9 +1400,9 @@ ) (deftype matrix4h (structure) - ((data int16 16 :offset-assert 0) - (vector4h vector4h 4 :offset 0) - (long int64 4 :offset 0) + ((data int16 16 :offset-assert 0) + (vector4h vector4h 4 :inline :offset 0) + (long int64 4 :offset 0) ) :method-count-assert 9 :size-assert #x20 @@ -1384,7 +1416,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftype quaternion (structure) - ((data float 4 :offset-assert 0) + ((data float 4 :offset-assert 0 :score -1) (x float :offset 0) (y float :offset 4) (z float :offset 8) @@ -1432,6 +1464,9 @@ (rot vector :inline :offset-assert 32) (scale vector :inline :offset-assert 48) ) + (:methods + (new (symbol type) _type_ 0) + ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 @@ -1480,7 +1515,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftype transformq (transform) - ((quat quaternion :inline :offset 16) + ((quat quaternion :inline :offset 16 :score 1) ) :method-count-assert 9 :size-assert #x30 @@ -1488,7 +1523,7 @@ ) (deftype trsq (trs) - ((quat quaternion :inline :offset 32) + ((quat quaternion :inline :offset 32 :score 1) ) :method-count-assert 9 :size-assert #x40 @@ -1509,25 +1544,25 @@ :size-assert #x8c :flag-assert #x1c0000008c (:methods - (trsqv-method-9 () none 9) ;; (seek-toward-heading-vec! (_type_ vector float time-frame) quaternion 9) - (trsqv-method-10 () none 10) ;; (set-heading-vec! (_type_ vector) quaternion 10) - (trsqv-method-11 () none 11) ;; (seek-to-point-toward-point! (_type_ vector float time-frame) quaternion 11) - (trsqv-method-12 () none 12) ;; (point-toward-point! (_type_ vector) quaternion 12) - (trsqv-method-13 () none 13) ;; (seek-toward-yaw-angle! (_type_ float float time-frame) quaternion 13) - (trsqv-method-14 () none 14) ;; (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14) - (trsqv-method-15 () none 15) ;; (set-roll-to-grav! (_type_ float) quaternion 15) - (trsqv-method-16 () none 16) ;; (set-roll-to-grav-2! (_type_ float) quaternion 16) - (trsqv-method-17 () none 17) ;; (rotate-toward-orientation! (_type_ quaternion float float) quaternion 17) - (trsqv-method-18 () none 18) ;; (set-quaternion! (_type_ quaternion) quaternion 18) - (trsqv-method-19 () none 19) ;; (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19) - (trsqv-method-20 () none 20) ;; (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20) - (trsqv-method-21 () none 21) ;; (rot->dir-targ! (_type_) quaternion 21) + (seek-toward-heading-vec! (_type_ vector float time-frame) quaternion 9) + (set-heading-vec! (_type_ vector) quaternion 10) + (seek-to-point-toward-point! (_type_ vector float time-frame) quaternion 11) + (point-toward-point! (_type_ vector) quaternion 12) + (seek-toward-yaw-angle! (_type_ float float time-frame) quaternion 13) + (set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion 14) + (set-roll-to-grav! (_type_ float) quaternion 15) + (set-roll-to-grav-2! (_type_ float) quaternion 16) + (rotate-toward-orientation! (_type_ quaternion float float) quaternion 17) + (set-quaternion! (_type_ quaternion) quaternion 18) + (set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion 19) + (point-toward-point-clear-roll-pitch! (_type_ vector) quaternion 20) + (rot->dir-targ! (_type_) quaternion 21) (y-angle (_type_) float 22) (global-y-angle-to-point (_type_ vector) float 23) (relative-y-angle-to-point (_type_ vector) float 24) - (trsqv-method-25 () none 25) ;; (roll-relative-to-gravity (_type_) float 25) - (trsqv-method-26 () none 26) ;; (set-and-limit-velocity (_type_ int vector float) trsqv 26) - (trsqv-method-27 () none 27) ;; (get-quaternion (_type_) quaternion 27) + (roll-relative-to-gravity (_type_) float 25) + (set-and-limit-velocity (_type_ int vector float) trsqv 26) + (get-quaternion (_type_) quaternion 27) ) ) @@ -1621,7 +1656,7 @@ (define-extern quaternion-axis-angle! (function quaternion float float float float quaternion)) (define-extern quaternion-vector-angle! (function quaternion vector float quaternion)) (define-extern vector-angle<-quaternion! (function vector quaternion vector)) -(define-extern quaternion-look-at! (function vector vector vector quaternion)) +(define-extern quaternion-look-at! (function quaternion vector vector quaternion)) (define-extern quaternion-zero! (function quaternion quaternion)) (define-extern quaternion-identity! (function quaternion quaternion)) (define-extern quaternion-i! (function quaternion quaternion)) @@ -1772,9 +1807,17 @@ (defenum sound-group :bitfield #t :type uint8 - ; (sfx) - ; (music) - ; (dialog) + (sfx) + (sog1) + (sog2) + (sog3) + (sog4) + (sog5) + (sog6) + (sog7) + + ; (music) 1 + ; (dialog) 2 ; (sog3) ; (ambient) ; (sog5) @@ -1782,18 +1825,19 @@ ; (sog7) ) +;; not 100% sure on these (defenum sound-mask :bitfield #t :type uint16 - ; (volume) - ; (pitch) - ; (bend) - ; (unused) - ; (time) - ; (trans) - ; (fo-min) - ; (fo-max) - ; (fo-curve) + (volume) + (pitch) + (bend) + (unused) + (time) + (trans) + (fo-min) + (fo-max) + (fo-curve) ) @@ -2107,7 +2151,7 @@ (group sound-group :offset-assert 12) (reg uint8 3 :offset-assert 13) (sound-name-char uint8 16 :offset-assert 16) - (sound-name sound-name :offset 16) + (sound-name sound-name :offset 16 :score 1) (trans int32 4 :offset-assert 32) (volume int32 :offset-assert 48) (pitch-mod int32 :offset-assert 52) @@ -2904,7 +2948,7 @@ (bucket-322 322) (bucket-323 323) (bucket-324 324) - (debug 325) + (debug-no-zbuf 325) ) (defenum vu1-renderer-mask @@ -2947,11 +2991,25 @@ (rn34) ) +(defenum tpage-category + :type int8 + (tfrag 0) + (pris 1) + (shrub 2) + (alpha 3) + (water 4) + (warp 5) + (pris2 6) + (sprite 7) + (map 8) + (sky 9) + ) + (deftype dma-foreground-sink (basic) - ((bucket bucket-id :offset-assert 4) - (foreground-texture-page int8 :offset-assert 8) - (foreground-texture-level int8 :offset-assert 9) - (foreground-output-bucket int8 :offset-assert 10) + ((bucket bucket-id :offset-assert 4) + (foreground-texture-page tpage-category :offset-assert 8) + (foreground-texture-level int8 :offset-assert 9) + (foreground-output-bucket int8 :offset-assert 10) ) :method-count-assert 9 :size-assert #xb @@ -2981,13 +3039,13 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftype profile-segment (structure) - ((name basic :offset-assert 0) + ((name symbol :offset-assert 0) (start-time int16 :offset-assert 4) (end-time int16 :offset-assert 6) (count uint8 :offset-assert 8) (vu-count uint8 :offset-assert 9) (depth uint16 :offset-assert 10) - (color uint32 :offset-assert 12) + (color rgba :offset-assert 12) (code-time uint16 :offset 4) (vu-time uint16 :offset 6) ) @@ -3013,7 +3071,7 @@ (depth int8 :offset-assert 6) (max-depth int8 :offset-assert 7) (base-time int16 :offset-assert 8) - (segment basic 9 :offset-assert 12) ;; todo + (segment profile-segment 9 :offset-assert 12) ;; todo (data profile-segment 512 :inline :offset-assert 48) ) :method-count-assert 13 @@ -3021,13 +3079,13 @@ :flag-assert #xd00002030 (:methods (get-total-time (_type_) int 9) - (profile-segment-array-method-10 () none 10) - (profile-segment-array-method-11 () none 11) - (profile-segment-array-method-12 () none 12) + (start-frame! (_type_) none 10) + (start-segment! (_type_ symbol rgba) none 11) + (end-segment! (_type_) none 12) ) ) - +(declare-type dma-buffer structure) (deftype profile-array (structure) ((data profile-segment-array 2 :offset-assert 0) ;; guess @@ -3036,9 +3094,9 @@ :size-assert #x8 :flag-assert #xc00000008 (:methods - (profile-array-method-9 () none 9) - (profile-array-method-10 () none 10) - (profile-array-method-11 () none 11) + (setup-categories! (_type_) none 9) + (draw-bars! (_type_ dma-buffer int) none 10) + (draw-text! (_type_) none 11) ) ) @@ -3141,6 +3199,9 @@ (deftype dma-gif-packet (structure) ((dma-vif dma-packet :inline :offset-assert 0) (gif uint64 2 :offset-assert 16) + ;; added these two + (gif0 uint64 :offset 16) + (gif1 uint64 :offset 24) (quad uint128 2 :offset 0) ) :method-count-assert 9 @@ -3154,6 +3215,7 @@ (base pointer :offset-assert 8) (end pointer :offset-assert 12) (data uint64 1 :offset-assert 16) + (data-buffer uint8 :dynamic :offset 16) ;; added ) (:methods (new (symbol type int) _type_ 0) @@ -3288,7 +3350,7 @@ :flag-assert #xa00000090 (:methods (new (symbol type int) _type_ 0) - (cpad-info-method-9 () none 9) + (invert-analog-if-needed (_type_) none 9) ) ) @@ -4036,6 +4098,21 @@ :flag-assert #x900000010 ) + +; (deftype dma-gif-packet (structure) +; ((dma-vif dma-packet :inline :offset-assert 0) +; (gif uint64 2 :offset-assert 16) +; ;; added these two +; (gif0 gif-tag64 :offset 16 :score 1) +; (gif1 gif-tag-regs :offset 24 :score 1) +; (quad uint128 2 :offset 0) +; ) +; :method-count-assert 9 +; :size-assert #x20 +; :flag-assert #x900000020 +; ) + + (deftype gif-packet (basic) ((reg-count int32 :offset-assert 4) @@ -4194,7 +4271,7 @@ :flag-assert #xa0000009c (:methods (new (symbol type int int int int int) _type_ 0) - (display-method-9 () none 9) ;; (set-time-ratios (_type_ float) float 9) + (set-time-ratios (_type_ float) float 9) ) ) @@ -4521,9 +4598,9 @@ :size-assert #xd0 :flag-assert #x10000000d0 (:methods - ;; (new (symbol type) _type_ 0) - (external-art-control-method-9 () none 9) ;; (update (_type_ symbol) int 9) - (external-art-control-method-10 () none 10) ;; (clear-rec (_type_) int 10) + (new (symbol type) _type_ 0) + (update (_type_ symbol) int 9) + (clear-rec (_type_) int 10) (external-art-control-method-11 () none 11) ;; (spool-push (_type_ string int process float) int 11) (external-art-control-method-12 () none 12) ;; (file-status (_type_ string int) symbol 12) (external-art-control-method-13 () none 13) ;; (reserve-alloc (_type_) kheap 13) @@ -4593,8 +4670,8 @@ (segment-common texture-pool-segment :inline :offset 28) (common-page texture-page 32 :offset-assert 52) ;; guessed by decompiler (common-page-mask int32 :offset-assert 180) - (update-sprites-flag basic :offset-assert 184) - (update-flag basic :offset-assert 188) + (update-sprites-flag symbol :offset-assert 184) + (update-flag symbol :offset-assert 188) (texture-enable-user uint64 :offset-assert 192) (texture-enable-user-menu uint64 :offset-assert 200) (ids uint32 128 :offset-assert 208) ;; guessed by decompiler @@ -4603,24 +4680,24 @@ :size-assert #x2d0 :flag-assert #x1a000002d0 (:methods - ;; (new (symbol type) _type_ 0) - (texture-pool-method-9 () none 9) ;; (initialize! (_type_) _type_ 9) + (new (symbol type) _type_ 0) + (initialize! (_type_) _type_ 9) (texture-pool-method-10 () none 10) ;; (print-usage (_type_) _type_ 10) (texture-pool-method-11 () none 11) ;; (setup-font-texture! (_type_) none 11) - (texture-pool-method-12 () none 12) ;; (allocate-defaults! (_type_) none 12) - (texture-pool-method-13 () none 13) ;; (login-level-textures (_type_ level int (pointer texture-id)) none 13) + (allocate-defaults! (_type_) none 12) + (login-level-textures (_type_ level int (pointer texture-id)) none 13) (texture-pool-method-14 () none 14) ;; (add-tex-to-dma! (_type_ level int) none 14) - (texture-pool-method-15 () none 15) ;; (allocate-vram-words! (_type_ int) int 15) - (texture-pool-method-16 () none 16) ;; (allocate-segment! (_type_ texture-pool-segment int) texture-pool-segment 16) + (allocate-vram-words! (_type_ int) int 15) + (allocate-segment! (_type_ texture-pool-segment int) texture-pool-segment 16) (texture-pool-method-17 () none 17) ;; (unused-17 () none 17) - (texture-pool-method-18 () none 18) ;; (unused-18 () none 18) - (texture-pool-method-19 () none 19) ;; (unused-19 () none 19) - (texture-pool-method-20 () none 20) ;; (unload! (_type_ texture-page) int 20) - (texture-pool-method-21 () none 21) ;; (upload-one-common! (_type_ level) symbol 21) - (texture-pool-method-22 () none 22) ;; (lookup-boot-common-id (_type_ int) int 22) - (texture-pool-method-23 () none 23) - (texture-pool-method-24 () none 24) - (texture-pool-method-25 () none 25) + (texture-pool-method-18 (_type_ int) int 18) ;; (unused-18 () none 18) + (update-warp-and-hud (_type_) none 19) ;; (unused-19 () none 19) + (update-sprites (_type_) none 20) ;; (unload! (_type_ texture-page) int 20) + (flag-update-and-sprite (_type_) none 21) ;; (upload-one-common! (_type_ level) symbol 21) + (relocate-sprite-dests! (_type_) none 22) ;; (lookup-boot-common-id (_type_ int) int 22) + (relocate-hud-dests! (_type_) none 23) + (relocate-warp-dests! (_type_) none 24) + (clear-ids (_type_) none 25) ) ) @@ -4701,11 +4778,11 @@ :size-assert #x80 :flag-assert #xe00000080 (:methods - (texture-page-method-9 () none 9) ;; (remove-from-heap (_type_ kheap) _type_ 9) - (texture-page-method-10 () none 10) ;; (get-leftover-block-count (_type_ int int) int 10) - (texture-page-method-11 () none 11) ;; (unused-11 () none 11) - (texture-page-method-12 () none 12) ;; (relocate-dests! (_type_ int int) none 12) - (texture-page-method-13 () none 13) ;; (add-to-dma-buffer (_type_ dma-buffer int) int 13) + (remove-from-heap (_type_ kheap) _type_ 9) + (get-leftover-block-count (_type_ int int) int 10) + (relocate-dests! (_type_ int int) none 11) ;; (unused-11 () none 11) + (texture-page-method-12 () none 12) ;; + (upload-now! (_type_ int) none 13) ;; (add-to-dma-buffer (_type_ dma-buffer int) int 13) ) ) @@ -4759,8 +4836,8 @@ (deftype adgif-shader (structure) - ((quad qword 5 :offset-assert 0) - (prims gs-reg64 10 :offset 0) + ((quad qword 5 :inline :offset-assert 0 :score -100) + (prims gs-reg64 10 :offset 0 :score -100) (reg-0 uint8 :offset 8) (reg-1 uint8 :offset 24) (reg-2 uint8 :offset 40) @@ -5051,7 +5128,7 @@ ) (deftype light-sphere (structure) - ((name basic :offset-assert 0) + ((name string :offset-assert 0) (bsphere vector :inline :offset-assert 16) (direction vector :inline :offset-assert 32) (color vector :inline :offset-assert 48) @@ -5080,13 +5157,13 @@ ((num-lights uint16 :offset-assert 4) (num-indices uint16 :offset-assert 6) (num-buckets uint16 :offset-assert 8) - (bucket-step uint16 2 :offset-assert 10) + (bucket-step uint8 2 :offset-assert 10) (base-trans vector :inline :offset-assert 16) (axis-scale vector :inline :offset-assert 32) (dimension-array vector4w :inline :offset-assert 48) - (bucket-array uint32 :offset-assert 64) - (index-array uint32 :offset-assert 68) - (light-sphere-array uint32 :offset-assert 72) + (bucket-array pointer :offset-assert 64) + (index-array pointer :offset-assert 68) + (light-sphere-array (inline-array light-sphere) :offset-assert 72) ) :method-count-assert 9 :size-assert #x4c @@ -5106,13 +5183,14 @@ (dir1 light :inline :offset-assert 48) (dir2 light :inline :offset-assert 96) (ambi light :inline :offset-assert 144) + (lights light 4 :inline :offset 0) ;; added ) :method-count-assert 9 :size-assert #xc0 :flag-assert #x9000000c0 ) -(define-extern *light-hash* light-hash-work) +(define-extern *light-hash* light-hash) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mood-h ;; @@ -5445,57 +5523,58 @@ ) (deftype level-load-info (basic) - ((name-list string 6 :offset-assert 4) + ((name-list symbol 6 :offset-assert 4 :score -1) (index int16 :offset-assert 28) (task-level uint8 :offset-assert 30) - (name string :offset 4) - (visname string :offset 8) - (nickname string :offset 12) - (dbname string :offset 16) - (taskname string :offset 20) + (name symbol :offset 4) + (visname symbol :offset 8) + (nickname symbol :offset 12) + (dbname symbol :offset 16) + (taskname symbol :offset 20) + (other-name-1 symbol :offset 24) (packages pair :offset-assert 32) ;; guess on type (memory-mode uint32 :offset-assert 36) (music-bank basic :offset-assert 40) (ambient-sounds basic :offset-assert 44) (sound-reverb float :offset-assert 48) - (mood-func basic :offset-assert 52) - (mood-init basic :offset-assert 56) + (mood-func symbol :offset-assert 52) + (mood-init symbol :offset-assert 56) (ocean basic :offset-assert 60) (sky basic :offset-assert 64) (use-camera-other basic :offset-assert 68) (part-engine-max int32 :offset-assert 72) (city-map-bits uint64 :offset-assert 80) - (continues basic :offset-assert 88) - (tasks basic :offset-assert 92) + (continues pair :offset-assert 88) + (tasks pair :offset-assert 92) (priority int32 :offset-assert 96) - (load-commands basic :offset-assert 100) - (alt-load-commands basic :offset-assert 104) + (load-commands pair :offset-assert 100) + (alt-load-commands pair :offset-assert 104) (bsp-mask uint64 :offset-assert 112) (buzzer int32 :offset-assert 120) (buttom-height meters :offset-assert 124) - (run-packages basic :offset-assert 128) + (run-packages pair :offset-assert 128) (prev-level basic :offset-assert 132) (next-level basic :offset-assert 136) (wait-for-load symbol :offset-assert 140) - (login-func basic :offset-assert 144) - (activate-func basic :offset-assert 148) - (deactivate-func basic :offset-assert 152) - (kill-func basic :offset-assert 156) + (login-func symbol :offset-assert 144) + (activate-func symbol :offset-assert 148) + (deactivate-func symbol :offset-assert 152) + (kill-func symbol :offset-assert 156) (borrow-size uint16 2 :offset-assert 160) (borrow-level symbol 2 :offset-assert 164) (borrow-display? basic 2 :offset-assert 172) (base-task-mask task-mask :offset-assert 180) - (texture-anim basic 10 :offset-assert 184) - (texture-anim-tfrag basic :offset 184) - (texture-anim-pris basic :offset 188) - (texture-anim-shrub basic :offset 192) - (texture-anim-alpha basic :offset 196) - (texture-anim-water basic :offset 200) - (texture-anim-twarp basic :offset 204) - (texture-anim-pris2 basic :offset 208) - (texture-anim-sprite basic :offset 212) - (texture-anim-map basic :offset 216) - (texture-anim-sky basic :offset 220) + (texture-anim symbol 10 :offset-assert 184 :score -1) + (texture-anim-tfrag symbol :offset 184) + (texture-anim-pris symbol :offset 188) + (texture-anim-shrub symbol :offset 192) + (texture-anim-alpha symbol :offset 196) + (texture-anim-water symbol :offset 200) + (texture-anim-twarp symbol :offset 204) + (texture-anim-pris2 symbol :offset 208) + (texture-anim-sprite symbol :offset 212) + (texture-anim-map symbol :offset 216) + (texture-anim-sky symbol :offset 220) (draw-priority float :offset-assert 224) (level-flags uint32 :offset-assert 228) (fog-height float :offset-assert 232) @@ -5506,15 +5585,15 @@ (max-rain float :offset-assert 272) (fog-mult float :offset-assert 276) (ocean-alpha float :offset-assert 280) - (extra-sound-bank basic :offset-assert 284) + (extra-sound-bank pair :offset-assert 284) ) :method-count-assert 9 :size-assert #x120 :flag-assert #x900000120 ;; Failed to read fields. ) - (declare-type drawable basic) + (deftype login-state (basic) ((state int32 :offset-assert 4) (pos uint32 :offset-assert 8) @@ -5525,6 +5604,18 @@ :size-assert #x50 :flag-assert #x900000050 ) +(declare-type entity-links-array inline-array-class) +(declare-type game-text-info basic) + +(defenum load-buffer-mode + :type uint32 + (small-edge 0) + (small-center 1) + (medium 2) + (large 3) + (borrow 4) + (ten 10) + ) (deftype level (basic) ((name symbol :offset-assert 4) @@ -5537,13 +5628,14 @@ (heap kheap :inline :offset-assert 48) (borrow-heap kheap 2 :inline :offset-assert 64) (bsp bsp-header :offset-assert 96) - (art-group basic :offset-assert 100) - (info basic :offset-assert 104) + (art-group load-dir-art-group :offset-assert 100) + (info level-load-info :offset-assert 104) (texture-page texture-page 18 :offset-assert 108) (loaded-texture-page texture-page 16 :offset-assert 180) (loaded-texture-page-count int32 :offset-assert 244) - (entity basic :offset-assert 248) + (entity entity-links-array :offset-assert 248) (closest-object float :offset-assert 252) + (closest-object-array float 18 :offset 252) ;; ???? (upload-size int32 18 :offset 324) (inside-boxes symbol :offset-assert 396) @@ -5553,7 +5645,7 @@ (force-inside? symbol :offset-assert 412) (mood-context mood-context :inline :offset-assert 416) (mood-func basic :offset-assert 2384) - (mood-init basic :offset-assert 2388) + (mood-init (function mood-context none) :offset-assert 2388) (vis-bits pointer :offset-assert 2392) (all-visible? symbol :offset-assert 2396) (force-all-visible? symbol :offset-assert 2400) @@ -5568,10 +5660,10 @@ (code-memory-end pointer :offset-assert 4508) (load-start-time time-frame :offset-assert 4512) (load-stop-time time-frame :offset-assert 4520) - (load-buffer basic 2 :offset-assert 4528) + (load-buffer uint32 2 :offset-assert 4528) (load-buffer-size uint32 :offset-assert 4536) (load-buffer-last uint32 :offset-assert 4540) - (load-buffer-mode uint32 :offset-assert 4544) + (load-buffer-mode load-buffer-mode :offset-assert 4544) (display-start-time time-frame :offset-assert 4552) (memory-mask uint32 :offset-assert 4560) (task-mask task-mask :offset-assert 4564) @@ -5595,7 +5687,7 @@ (part-engine basic :offset-assert 5148) (user-object basic 4 :offset-assert 5152) (loaded-text-info-count int32 :offset-assert 5168) - (loaded-text-info object 8 :offset-assert 5172) + (loaded-text-info game-text-info 8 :offset-assert 5172) (level-type basic :offset-assert 5204) (load-order int64 :offset-assert 5208) @@ -5607,27 +5699,27 @@ :flag-assert #x1e0000146c ;; Failed to read fields. (:methods - (level-method-9 () none 9) ;; (deactivate (_type_) _type_ 9) + (deactivate (_type_) _type_ 9) (level-method-10 () none 10) ;; (is-object-visible? (_type_ int) symbol 10) (level-method-11 () none 11) ;; (add-irq-to-tex-buckets! (_type_) none 11) - (level-method-12 () none 12) ;; (unload! (_type_) _type_ 12) - (level-method-13 () none 13) ;; (bsp-name (_type_) symbol 13) - (level-method-14 () none 14) ;; (compute-memory-usage (_type_ object) memory-usage-block 14) - (level-method-15 () none 15) ;; (point-in-boxes? (_type_ vector) symbol 15) + (unload! (_type_) _type_ 12) + (bsp-name (_type_) symbol 13) + (compute-memory-usage (_type_ object) memory-usage-block 14) + (point-in-boxes? (_type_ vector) symbol 15) (level-method-16 () none 16) ;; (update-vis! (_type_ level-vis-info uint uint) symbol 16) - (level-method-17 () none 17) ;; (load-continue (_type_) _type_ 17) - (level-method-18 () none 18) ;; (load-begin (_type_) _type_ 18) - (level-method-19 () none 19) ;; (login-begin (_type_) _type_ 19) - (level-method-20 () none 20) ;; (vis-load (_type_) uint 20) - (level-method-21 () none 21) ;; (unused-21 (_type_) none 21) + (load-continue (_type_) _type_ 17) + (load-begin (_type_) _type_ 18) + (login-begin (_type_) _type_ 19) + (debug-print-region-splitbox (_type_ vector object) none 20) ;; (vis-load (_type_) uint 20) + (get-art-group-by-name (_type_ string) art-group 21) ;; (unused-21 (_type_) none 21) (level-method-22 () none 22) ;; (birth (_type_) _type_ 22) (level-method-23 () none 23) ;; (level-status-set! (_type_ symbol) _type_ 23) - (level-method-24 () none 24) ;; (load-required-packages (_type_) _type_ 24) - (level-method-25 () none 25) ;; (init-vis (_type_) int 25) - (level-method-26 () none 26) ;; (vis-clear (_type_) int 26) - (level-method-27 () none 27) ;; (debug-print-splitbox (_type_ vector string) none 27) - (level-method-28 () none 28) ;; (art-group-get-by-name (_type_ string) art-group 28) - (level-method-29 () none 29) + (level-method-24 () none 24) + (birth (_type_) _type_ 25) ;; (init-vis (_type_) int 25) + (level-status-update! (_type_ symbol) _type_ 26) + (load-required-packages (_type_) _type_ 27) ;; (debug-print-splitbox (_type_ vector string) none 27) + (init-vis-from-bsp (_type_) none 28) + (vis-clear (_type_) none 29) ) ) @@ -5676,28 +5768,28 @@ :flag-assert #x1f00009014 ;; Failed to read fields. (:methods - (level-group-method-9 () none 9) ;; (level-get (_type_ symbol) level 9) - (level-group-method-10 () none 10) ;; (level-get-with-status (_type_ symbol) level 10) - (level-group-method-11 () none 11) ;; (level-get-for-use (_type_ symbol symbol) level 11) - (level-group-method-12 () none 12) ;; (activate-levels! (_type_) int 12) - (level-group-method-13 () none 13) ;; (debug-print-entities (_type_ symbol type) none 13) + (level-get (_type_ symbol) level 9) + (level-get-with-status (_type_ symbol) level 10) + (get-level-by-heap-ptr-and-status (_type_ pointer uint) level 11) ;; + (level-get-for-use (_type_ symbol symbol) level 12) + (activate-levels! (_type_) int 13) ;; (debug-print-entities (_type_ symbol type) none 13) (level-group-method-14 () none 14) ;; (debug-draw-actors (_type_ symbol) none 14) (level-group-method-15 () none 15) ;; (actors-update (_type_) object 15) - (level-group-method-16 () none 16) ;; (level-update (_type_) int 16) + (assign-draw-indices (_type_) none 16) ;; (level-update (_type_) int 16) (level-group-method-17 () none 17) ;; (level-get-target-inside (_type_) level 17) (level-group-method-18 () none 18) ;; (alloc-levels! (_type_ symbol) int 18) - (level-group-method-19 () none 19) ;; (load-commands-set! (_type_ pair) pair 19) - (level-group-method-20 () none 20) ;; (art-group-get-by-name (_type_ string) art-group 20) - (level-group-method-21 () none 21) ;; (load-command-get-index (_type_ symbol int) pair 21) - (level-group-method-22 () none 22) ;; (update-vis-volumes (_type_) none 22) + (level-update (_type_) none 19) ;; + (level-get-target-inside (_type_) level 20) ;; (art-group-get-by-name (_type_ string) art-group 20) + (alloc-levels-if-needed (_type_ symbol) none 21) + (load-commands-set! (_type_ pair) pair 22) ;; (update-vis-volumes (_type_) none 22) (level-group-method-23 () none 23) ;; (update-vis-volumes-from-nav-mesh (_type_) none 23) - (level-group-method-24 () none 24) ;; (print-volume-sizes (_type_) none 24) + (load-command-get-index (_type_ symbol int) pair 24) ;; (print-volume-sizes (_type_) none 24) (level-group-method-25 () none 25) ;; (level-status (_type_ symbol) symbol 25) - (level-group-method-26 () none 26) ;; (level-get-most-disposable (_type_) level 26) + (level-group-method-26 () none 26) (level-group-method-27 () none 27) - (level-group-method-28 () none 28) - (level-group-method-29 () none 29) - (level-group-method-30 () none 30) + (level-status (_type_ symbol) symbol 28) + (load-in-progress? (_type_) symbol 29) + (level-get-most-disposable (_type_) level 30) ) ) @@ -5843,6 +5935,7 @@ (mirror-normal vector :inline :offset-assert 1568) (fov-correction-factor float :offset-assert 1584) ) + (:methods (new (symbol type) _type_ 0)) :method-count-assert 9 :size-assert #x634 :flag-assert #x900000634 @@ -5898,11 +5991,21 @@ (defenum font-color :type uint32 + (zero 0) + (one 1) + (orange-red 3) ) (defenum font-flags :type uint32 :bitfield #t + (shadow 0) + (kerning 1) + (middle 2) + (left 3) + (right 4) + (large 5) + (pc-hack 6) ) (deftype font-context (basic) @@ -5922,7 +6025,7 @@ :size-assert #x54 :flag-assert #x1500000054 (:methods - (new (symbol type matrix int int int font-color font-flags) _type_ 0) + (new (symbol type matrix int int float font-color font-flags) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -5994,14 +6097,14 @@ (define-extern *font-default-matrix* matrix) (define-extern *font-work* font-work) -;; (define-extern font-set-tex0 function) ;; (function (pointer gs-tex0) texture uint uint uint none) -;; (define-extern set-font-color function) +(define-extern font-set-tex0 (function (pointer gs-tex0) texture uint uint uint none)) +(define-extern set-font-color (function int int int int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; decomp-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype decomp-work (structure) ((buffer0 uint8 2048 :offset-assert 0) ;; guessed by decompiler (buffer1 uint8 2048 :offset-assert 2048) ;; guessed by decompiler @@ -6012,7 +6115,6 @@ :size-assert #x3000 :flag-assert #x900003000 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -6036,40 +6138,43 @@ (define-extern *profile-w* int) (define-extern *profile-h* int) (define-extern *profile-ticks* symbol) -;; (define-extern profile-texture-test function) -;; (define-extern profile-tfrag-test function) -;; (define-extern profile-tie-test function) -;; (define-extern profile-merc-test function) -;; (define-extern profile-emerc-test function) -;; (define-extern profile-mercneric-test function) +(define-extern profile-texture-test (function bucket-id symbol)) +(define-extern profile-tfrag-test (function bucket-id symbol)) +(define-extern profile-tie-test (function bucket-id symbol)) +(define-extern profile-merc-test (function bucket-id symbol)) +(define-extern profile-emerc-test (function bucket-id symbol)) +(define-extern profile-mercneric-test (function bucket-id symbol)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; display ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern get-current-time (function time-frame)) -(define-extern get-integral-current-time (function time-frame)) -(define-extern set-display (function display int int int int int display)) -;; (define-extern allocate-dma-buffers function) ;; (function display display) -;; (define-extern *font-context* object) ;; font-context -;; (define-extern draw-sprite2d-xy function) ;; (function dma-buffer int int int int rgba none) -;; (define-extern draw-sprite2d-xy-absolute function) -;; (define-extern draw-quad2d function) ;; (function dma-buffer draw-context none) -;; (define-extern screen-gradient function) ;; (function dma-buffer rgba rgba rgba rgba none) -;; (define-extern vif1-handler-debug function) ;; (function none) -;; (define-extern vif1-handler function) ;; (function none) -;; (define-extern vblank-handler function) ;; (function int) -;; (define-extern set-display-gs-state function) ;; (function dma-buffer int int int int int dma-buffer) -;; (define-extern set-display-gs-state-offset function) ;; (function dma-buffer int int int int int int int dma-buffer) -;; (define-extern reset-display-gs-state function) ;; (function display dma-buffer int display) -;; (define-extern *vu0-dma-list* object) ;; dma-buffer +(define-extern get-integral-current-time (function uint)) +(define-extern set-display (function display display)) +(define-extern allocate-dma-buffers (function display display)) +(define-extern *font-context* font-context) +(define-extern draw-sprite2d-xy (function dma-buffer int int int int rgba none)) +(define-extern draw-sprite2d-xy-absolute (function dma-buffer int int int int rgba none)) +(define-extern draw-quad2d (function dma-buffer draw-context none)) +(define-extern screen-gradient (function dma-buffer rgba rgba rgba rgba none)) +(define-extern vif1-handler-debug (function none)) +(define-extern vif1-handler (function none)) +(define-extern vblank-handler (function int)) +(define-extern set-display-gs-state (function dma-buffer int int int int int dma-buffer)) +(define-extern set-display-gs-state-offset (function dma-buffer int int int int int int int dma-buffer)) +(define-extern reset-display-gs-state (function display dma-buffer int display)) +(define-extern *vu0-dma-list* dma-buffer) (define-extern *display* display) +(define-extern install-handler (function int function int)) ;; GOAL thinks it returns something. + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; connect ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype connectable (structure) ((next0 connectable :offset-assert 0) (prev0 connectable :offset-assert 4) @@ -6080,119 +6185,145 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + +(declare-type engine basic) + (deftype connection (connectable) ((param0 basic :offset-assert 16) (param1 int32 :offset-assert 20) ;; guessed by decompiler (param2 int32 :offset-assert 24) ;; guessed by decompiler (param3 int32 :offset-assert 28) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 ;; field param1 uses ~A with a signed load field param2 uses ~A with a signed load field param3 uses ~A with a signed load (:methods - (connection-method-9 () none 9) ;; (get-engine (connection) engine 9) - (connection-method-10 () none 10) ;; (get-process (connection) process 10) - (connection-method-11 () none 11) ;; (belongs-to-engine? (connection engine) symbol 11) - (connection-method-12 () none 12) ;; (belongs-to-process? (connection process) symbol 12) - (connection-method-13 () none 13) ;; (move-to-dead (connection) connection 13) + (get-engine (connection) engine 9) + (get-process (connection) process 10) + (belongs-to-engine? (connection engine) symbol 11) + (belongs-to-process? (connection process) symbol 12) + (move-to-dead (connection) connection 13) ) ) -|# -#| + + (deftype engine (basic) - () + ((name symbol :offset-assert 4) + (engine-time time-frame :offset 16) + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) + (alive-list connectable :inline :offset-assert 32) + (alive-list-end connectable :inline :offset-assert 48) + (dead-list connectable :inline :offset-assert 64) + (dead-list-end connectable :inline :offset-assert 80) + ;; storage for nodes. this is dynamically sized. + (data connection :dynamic :inline :offset-assert 96) + ) :method-count-assert 26 :size-assert #x60 :flag-assert #x1a00000060 ;; Failed to read fields. (:methods - ;; (new (symbol type basic int) _type_ 0) - (engine-method-9 () none 9) ;; (inspect-all-connections (engine) engine 9) - (engine-method-10 () none 10) ;; (apply-to-connections (engine (function connectable none)) int 10) - (engine-method-11 () none 11) ;; (apply-to-connections-reverse (engine (function connectable none)) int 11) - (engine-method-12 () none 12) ;; (execute-connections (engine object) int 12) - (engine-method-13 () none 13) ;; (execute-connections-and-move-to-dead (engine object) int 13) - (engine-method-14 () none 14) ;; (execute-connections-if-needed (engine object) int 14) - (engine-method-15 () none 15) ;; (add-connection (engine process object object object object) connection 15) - (engine-method-16 () none 16) ;; (remove-from-process (engine process) int 16) - (engine-method-17 () none 17) ;; (remove-matching (engine (function connection engine symbol)) int 17) - (engine-method-18 () none 18) ;; (remove-all (engine) int 18) - (engine-method-19 () none 19) ;; (remove-by-param1 (engine object) int 19) - (engine-method-20 () none 20) ;; (remove-by-param2 (engine int) int 20) - (engine-method-21 () none 21) ;; (get-first-connectable (engine) connectable 21) - (engine-method-22 () none 22) ;; (get-last-connectable (engine) connectable 22) - (engine-method-23 () none 23) ;; (unknown-1 (engine (pointer uint32)) uint 23) - (engine-method-24 () none 24) - (engine-method-25 () none 25) + (new (symbol type symbol int type) _type_ 0) + (inspect-all-connections (engine) engine 9) + (apply-to-connections (engine (function connectable none)) int 10) + (apply-to-connections-reverse (engine (function connectable none)) int 11) + (execute-connections (engine object) int 12) + (execute-connections-and-move-to-dead (engine object) int 13) + (execute-connections-if-needed (engine object) int 14) + (add-connection (engine process object object object object) connection 15) + (remove-from-process (engine process) int 16) + (remove-matching (engine (function connection engine symbol)) int 17) + (remove-all (engine) int 18) + (remove-by-param0 (engine object) int 19) + (remove-by-param1 (engine int) int 20) + (remove-by-param2 (engine int) int 21) + (get-first-connectable (engine) connectable 22) + (get-last-connectable (engine) connectable 23) + (get-next-connectable (_type_ connectable) connectable 24) + (get-prev-connectable (_type_ connectable) connectable 25) ) ) -|# -#| + (deftype connection-pers (structure) - () + ((next connection-pers :offset-assert 0) + (key object :offset-assert 4) + (update-time time-frame :offset-assert 8) + (param object 4 :offset 16) + (param-int32 int32 4 :offset 16) + (param-int64 int64 2 :offset 16) + (param-float float 4 :offset 16) + (param-quat int128 :offset 16) + ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ;; Failed to read fields. ) -|# -#| (deftype engine-pers (basic) - ((name basic :offset-assert 4) + ((name symbol :offset-assert 4) (length int16 :offset-assert 8) (allocated-length int16 :offset-assert 10) - (element-type basic :offset-assert 12) + (element-type type :offset-assert 12) (execute-time time-frame :offset-assert 16) (alive-list connection-pers :offset-assert 24) (dead-list connection-pers :offset-assert 28) - (data UNKNOWN :dynamic :offset-assert 32) + (data connection-pers :inline :dynamic :offset-assert 32) ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (engine-pers-method-9 () none 9) - (engine-pers-method-10 () none 10) - (engine-pers-method-11 () none 11) - (engine-pers-method-12 () none 12) - (engine-pers-method-13 () none 13) - (engine-pers-method-14 () none 14) + (new (symbol type symbol int type) _type_ 0) + (schedule-callback (_type_ object time-frame) connection-pers 9) + (kill-callback (_type_) none 10) + (kill-by-key (_type_ object) none 11) + (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none 12) + (update-callback (_type_) none 13) + (run-pending-updates! (_type_ time-frame) none 14) ) ) -|# -;; (define-extern connection-process-apply function) ;; (function process (function object none) symbol) +(define-extern connection-process-apply (function process (function object none) symbol)) (define-extern process-disconnect (function process int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; text-id-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defenum game-text-id + :type uint32 + :bitfield #f +;; GAME-TEXT-ID ENUM BEGINS + (pause 257) +;; GAME-TEXT-ID ENUM ENDS +) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; text-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype game-text (structure) ((id game-text-id :offset-assert 0) ;; guessed by decompiler (text string :offset-assert 4) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| + + (deftype game-text-info (basic) ((length int32 :offset-assert 4) (language-id int32 :offset-assert 8) @@ -6203,39 +6334,38 @@ :size-assert #x10 :flag-assert #xa00000010 (:methods - (game-text-info-method-9 () none 9) ;; (lookup-text! (_type_ game-text-id symbol) string 9) + (lookup-text! (_type_ game-text-id symbol) string 9) ) ) -|# -;; (define-extern *text-group-names* array) ;; (array string) -;; (define-extern *common-text-heap* object) ;; kheap -;; (define-extern *common-text* object) ;; game-text-info + +(define-extern *text-group-names* (array string)) +(define-extern *common-text-heap* kheap) +(define-extern *common-text* game-text-info) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; camera-defs-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype camera-bank (basic) ((collide-move-rad float :offset-assert 4) (joypad uint32 :offset-assert 8) (min-detectable-velocity float :offset-assert 12) - (attack-timeout uint64 :offset-assert 16) ;; time-frame + (attack-timeout time-frame :offset-assert 16) ;; time-frame (default-string-max-y meters :offset-assert 24) (default-string-min-y meters :offset-assert 28) (default-string-max-z meters :offset-assert 32) (default-string-min-z meters :offset-assert 36) (default-string-push-z meters :offset-assert 40) - (default-tilt-adjust deg :offset-assert 44) ;; degrees + (default-tilt-adjust degrees :offset-assert 44) ;; degrees ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| + (deftype camera-master-bank (basic) ((onscreen-head-height meters :offset-assert 4) (onscreen-foot-height meters :offset-assert 8) @@ -6250,16 +6380,15 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -;; (define-extern *CAMERA-bank* camera-bank) ;; camera-bank -;; (define-extern *CAMERA_MASTER-bank* camera-master-bank) ;; camera-master-bank + +(define-extern *CAMERA-bank* camera-bank) +(define-extern *CAMERA_MASTER-bank* camera-master-bank) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; trail-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype trail-node (structure) ((next-id int16 :offset-assert 0) (prev-id int16 :offset-assert 2) @@ -6281,9 +6410,7 @@ (trail-node-method-11 () none 11) ) ) -|# -#| (deftype trail-visgroup (structure) ((first-node uint16 :offset-assert 0) (node-count uint8 :offset-assert 2) @@ -6293,9 +6420,8 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| + (deftype trail-conn (structure) ((head-id uint16 :offset-assert 0) (tail-id uint16 :offset-assert 2) @@ -6310,9 +6436,7 @@ (trail-conn-method-9 () none 9) ) ) -|# -#| (deftype trail-conn-hash-cell (structure) ((first-conn uint16 :offset-assert 0) (conn-count uint8 :offset-assert 2) @@ -6322,9 +6446,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype trail-conn-search (structure) ((best-conn-id int32 :offset-assert 0) (best-dist float :offset-assert 4) @@ -6333,18 +6455,17 @@ (debug-cells-searched int32 :offset-assert 16) (debug-conns-searched int32 :offset-assert 20) (bounds bounding-box4w :inline :offset-assert 32) - (cell-quads UNKNOWN 2 :offset-assert 64) - (conn-quads UNKNOWN 7 :offset-assert 96) - (cell-bits UNKNOWN 2 :offset-assert 64) - (conn-bits UNKNOWN 2 :offset-assert 96) + (cell-quads qword 2 :inline :offset-assert 64) + (conn-quads qword 7 :inline :offset-assert 96) + (cell-bits vector16ub 2 :inline :offset 64) + ;; (conn-bits UNKNOWN 2 :offset-assert 96) ?? ) :method-count-assert 9 :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| + (deftype trail-conn-hash (basic) ((cell-width meters :offset-assert 4) (origin vector :inline :offset-assert 16) @@ -6355,9 +6476,8 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| + (deftype trail-cached-search-info (structure) ((goal-conn-id int16 :offset-assert 0) (orig-goal-pos vector :inline :offset-assert 16) @@ -6367,9 +6487,8 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| + (deftype trail-graph (basic) ((mode uint8 :offset-assert 4) (search-id uint32 :offset-assert 8) @@ -6389,10 +6508,10 @@ (orig-goal-pos vector :inline :offset-assert 64) (conn-start-pos vector :inline :offset-assert 80) (conn-goal-pos vector :inline :offset-assert 96) - (open-quads UNKNOWN 6 :offset-assert 112) - (closed-quads UNKNOWN 6 :offset-assert 208) - (open-bits UNKNOWN 2 :offset-assert 112) - (closed-bits UNKNOWN 2 :offset-assert 208) + (open-quads qword 6 :inline :offset-assert 112) + (closed-quads qword 6 :inline :offset-assert 208) + ; (open-bits UNKNOWN 2 :offset-assert 112) + ; (closed-bits UNKNOWN 2 :offset-assert 208) ) :method-count-assert 29 :size-assert #x130 @@ -6420,38 +6539,149 @@ (trail-graph-method-28 () none 28) ) ) -|# -;; (define-extern *trail-graph* object) +(define-extern *trail-graph* trail-graph) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; minimap-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum minimap-flag + :bitfield #t + :type uint16 + (active 0) ;; 1 + (fade-in 1) ;; 2 + (fade-out 2) ;; 4 + (clamp 3) ;; 8 + (trail 4) ;; 16 + (task-graph 5) ;; 32 + (flash 6) ;; 64 + (minimap 7) ;; 128 + (background 8) ;; 256 + (task 9) ;; 512 + (enemy 10) ;; 1024 + (frustum 11) ;; 2048 + (racer 12) ;; 4096 + (bigmap 13) ;; 8192 + (goal 14) ;; 16384 + (city-only 15) ;; 32768 + ) + +(defenum minimap-class + :type uint16 + :bitfield #f + (none 0) + (onintent 1) + (ruins 2) + (vinroom 3) + (mountain 4) + (hideout 5) + (sewer 6) + (atoll 7) + (hiphog 8) + (fortress 9) + (gungame 10) + (gun-yellow 11) + (garage 12) + (palace-cable 13) + (guard 14) + (goal 15) + (goal-no-trail 16) + (parking-spot 17) + (forest 18) + (kiosk 19) + (dig 20) + (canyon 21) + (tomb 22) + (tanker 23) + (kid 24) + (consite 25) + (palace 26) + (castle 27) + (underport 28) + (stadium 29) + (port-turret 30) + (oracle 31) + (guard-frustum 32) + (burning-bush 33) + (gun-dark 34) + (slumc-seal 35) + (racer 36) + (racer-target 37) + (racer-errol 38) + (flag 39) + (bbush-gena 40) + (bbush-gena-2 41) + (bbush-genb 42) + (bbush-genb-2 43) + (bbush-genc 44) + (bbush-genc-2 45) + (bbush-sluma 46) + (bbush-slumb 47) + (bbush-slumb-2 48) + (bbush-slumc 49) + (bbush-port-3 50) + (bbush-port-2 51) + (bbush-port 52) + (bbush-farma 53) + (bbush-farmb 54) + (bbush-inda 55) + (bbush-indb 56) + (bbush-marka 57) + (bbush-markb 58) + (bbush-markb-2 59) + (bbush-pal 60) + (bbush-pal-2 61) + (bbush-stadium 62) + (atoll-valve 63) + (atoll-ashelin 64) + (mountain-lens 65) + (mountain-shard 66) + (mountain-gear 67) + (ruins-hut 68) + (forest-samos 69) + (metalhead 70) + + ) + (deftype minimap-class-node (structure) - () + ((default-position vector :inline :offset-assert 0) + (flags minimap-flag :offset-assert 16) + (class minimap-class :offset-assert 18) + (name basic :offset-assert 20) + (icon-xy vector2ub :inline :offset-assert 24) + (scale float :offset-assert 28) + (color rgba :offset-assert 32) + ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ;; Failed to read fields. ) -|# -#| + (deftype connection-minimap (connection-pers) - () + ((handle handle :offset 8) + (position vector :offset 16) + (alpha float :offset 20) + (class minimap-class-node :offset 24) + (flags minimap-flag :offset 28) + (node uint16 :offset 30) + (edge-ry float :offset-assert 32) + (last-world-pos vector :inline :offset-assert 48) + (last-relative-pos vector :inline :offset-assert 64) + ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ;; Failed to read fields. ) -|# -#| + + (deftype engine-minimap (engine-pers) - ((alive-list connection-minimap :offset-assert 24) - (dead-list connection-minimap :offset-assert 28) + ((alive-list-override connection-minimap :offset 24) + (dead-list-override connection-minimap :offset 28) ) :method-count-assert 15 :size-assert #x20 @@ -6459,9 +6689,7 @@ (:methods ) ) -|# -#| (deftype minimap-trail (structure) ((used-by connection-minimap :offset-assert 0) (search-id uint32 :offset-assert 4) @@ -6470,7 +6698,7 @@ (node-path-dist float :offset-assert 16) (last-updated uint64 :offset-assert 24) (cached-info trail-cached-search-info :inline :offset-assert 32) - (node-id UNKNOWN 64 :offset-assert 80) + (node-id uint16 64 :offset-assert 80) ) :method-count-assert 11 :size-assert #xd0 @@ -6480,23 +6708,23 @@ (minimap-trail-method-10 () none 10) ) ) -|# -#| + + (deftype minimap-draw-work (structure) ((buf basic :offset-assert 0) (justify-right basic :offset-assert 4) (draw-pos vector4w :inline :offset-assert 16) (mat matrix :inline :offset-assert 32) - (corner UNKNOWN 4 :offset-assert 96) + (corner vector4w 4 :inline :offset-assert 96) ) :method-count-assert 9 :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| + + (deftype minimap (structure) ((draw-tmpl dma-gif-packet :inline :offset-assert 0) (draw2-tmpl dma-gif-packet :inline :offset-assert 32) @@ -6513,11 +6741,11 @@ (map-bits uint64 :offset-assert 256) (level basic :offset-assert 264) (ctywide basic :offset-assert 268) - (inv-scale float :offset-assert 212) - (fade float :offset-assert 220) + (inv-scale float :offset 212) + (fade float :offset 220) (engine basic :offset-assert 272) (engine-key uint32 :offset-assert 276) - (trail UNKNOWN 6 :offset-assert 288) + (trail minimap-trail 6 :inline :offset-assert 288) (race-tex basic :offset-assert 1536) (race-scale float :offset-assert 1540) (race-level basic :offset-assert 1544) @@ -6551,118 +6779,104 @@ (minimap-method-27 () none 27) ) ) -|# + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bigmap-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype bigmap-bit-mask (structure) - ((data UNKNOWN 6656 :offset-assert 0) + ((data uint8 6656 :offset-assert 0) ) :method-count-assert 9 :size-assert #x1a00 :flag-assert #x900001a00 ) -|# -#| + (deftype bigmap-layer-mask (structure) - ((data UNKNOWN 26624 :offset-assert 0) + ((data uint8 26624 :offset-assert 0) ) :method-count-assert 9 :size-assert #x6800 :flag-assert #x900006800 ) -|# -#| (deftype bigmap-image (structure) ((clut-offset uint32 :offset-assert 0) (image-offset uint32 :offset-assert 4) - (pad UNKNOWN 2 :offset-assert 8) - (data UNKNOWN 1 :offset-assert 16) + (pad uint32 2 :offset-assert 8) + (data uint8 1 :offset-assert 16) ) :method-count-assert 9 :size-assert #x11 :flag-assert #x900000011 ) -|# -#| + (deftype bigmap-info (vector) - ((data UNKNOWN 4 :offset-assert 0) - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (w float :offset-assert 12) - (quad uint128 :offset-assert 0) - (scale float :offset-assert 8) - (inv-scale float :offset-assert 12) + ((scale float :offset 8 :score 1) + (inv-scale float :offset 12 :score 1) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + (deftype bigmap-info-array (structure) - ((data UNKNOWN 21 :offset-assert 0) + ((data bigmap-info 21 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x150 :flag-assert #x900000150 ) -|# -#| (deftype bigmap-compressed-layers (structure) - ((data UNKNOWN 20 :offset-assert 0) - (layer0 uint32 :offset-assert 0) - (layer1 uint32 :offset-assert 4) - (layer2 uint32 :offset-assert 8) - (layer3 uint32 :offset-assert 12) - (layer4 uint32 :offset-assert 16) - (layer5 uint32 :offset-assert 20) - (layer6 uint32 :offset-assert 24) - (layer7 uint32 :offset-assert 28) - (layer8 uint32 :offset-assert 32) - (layer9 uint32 :offset-assert 36) - (layer10 uint32 :offset-assert 40) - (layer11 uint32 :offset-assert 44) - (layer12 uint32 :offset-assert 48) - (layer13 uint32 :offset-assert 52) - (layer14 uint32 :offset-assert 56) - (layer15 uint32 :offset-assert 60) - (layer16 uint32 :offset-assert 64) - (layer17 uint32 :offset-assert 68) - (layer18 uint32 :offset-assert 72) - (layer19 uint32 :offset-assert 76) + ((data uint32 20 :offset-assert 0 :score -1) + (layer0 uint32 :offset 0) + (layer1 uint32 :offset 4) + (layer2 uint32 :offset 8) + (layer3 uint32 :offset 12) + (layer4 uint32 :offset 16) + (layer5 uint32 :offset 20) + (layer6 uint32 :offset 24) + (layer7 uint32 :offset 28) + (layer8 uint32 :offset 32) + (layer9 uint32 :offset 36) + (layer10 uint32 :offset 40) + (layer11 uint32 :offset 44) + (layer12 uint32 :offset 48) + (layer13 uint32 :offset 52) + (layer14 uint32 :offset 56) + (layer15 uint32 :offset 60) + (layer16 uint32 :offset 64) + (layer17 uint32 :offset 68) + (layer18 uint32 :offset 72) + (layer19 uint32 :offset 76) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| + (deftype bigmap (basic) - ((drawing-flag basic :offset-assert 4) - (loading-flag basic :offset-assert 8) - (recording-flag basic :offset-assert 12) - (fill-flag basic :offset-assert 16) + ((drawing-flag symbol :offset-assert 4) + (loading-flag symbol :offset-assert 8) + (recording-flag symbol :offset-assert 12) + (fill-flag symbol :offset-assert 16) (bigmap-index uint32 :offset-assert 20) - (bigmap-image basic :offset-assert 24) + (bigmap-image external-art-buffer :offset-assert 24) (tpage basic :offset-assert 28) (progress-minimap basic :offset-assert 32) (mask-index uint32 :offset-assert 36) (bit-mask bigmap-bit-mask :offset-assert 40) (compressed-next-index uint32 :offset-assert 44) (max-next-index uint32 :offset-assert 48) - (compressed-masks UNKNOWN 20 :offset-assert 52) + (compressed-masks uint32 20 :offset-assert 52) ;; just a guess... (compressed-data uint32 :offset-assert 132) (layer-index uint32 :offset-assert 136) (layer-mask bigmap-layer-mask :offset-assert 140) @@ -6679,23 +6893,24 @@ (draw-tmpl dma-gif-packet :inline :offset-assert 224) (adgif-tmpl dma-gif-packet :inline :offset-assert 256) (offset vector :inline :offset-assert 288) - (size float :offset-assert 296) - (scale float :offset-assert 300) + (size float :offset 296) + (scale float :offset 300) (draw-offset vector :inline :offset-assert 304) - (draw-size float :offset-assert 312) - (draw-scale float :offset-assert 316) + (draw-size float :offset 312) + (draw-scale float :offset 316) (scroll vector :inline :offset-assert 320) (pos vector4w :inline :offset-assert 336) (color vector4w :inline :offset-assert 352) - (corner UNKNOWN 4 :offset-assert 368) + (corner vector4w 4 :inline :offset-assert 368) (auto-save-icon-flag basic :offset-assert 432) ) :method-count-assert 28 :size-assert #x1b4 :flag-assert #x1c000001b4 (:methods - (bigmap-method-9 () none 9) - (bigmap-method-10 () none 10) + (new (symbol type) _type_ 0) + (initialize (_type_) none 9) ;; some sort of init? + (update (_type_) none 10) (bigmap-method-11 () none 11) (bigmap-method-12 () none 12) (bigmap-method-13 () none 13) @@ -6715,9 +6930,8 @@ (bigmap-method-27 () none 27) ) ) -|# -;; (define-extern *bigmap-info-array* object) +(define-extern *bigmap-info-array* bigmap-info-array) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; settings-h ;; @@ -6961,7 +7175,7 @@ :size-assert #xfb0 :flag-assert #x1300000fb0 (:methods - ;; (new (symbol type int) _type_ 0) + (new (symbol type int) _type_ 0) (setting-control-method-9 () none 9) ;; (add-setting (_type_ process symbol object object object) none 9) (setting-control-method-10 () none 10) ;; (set-setting (_type_ process symbol object object object) none 10) (setting-control-method-11 () none 11) ;; (remove-setting (_type_ process symbol) none 11) @@ -6971,7 +7185,7 @@ (setting-control-method-15 () none 15) (setting-control-method-16 () none 16) (setting-control-method-17 () none 17) - (setting-control-method-18 () none 18) + (update (_type_) none 18) ) ) @@ -6980,14 +7194,21 @@ ;; capture ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern gs-set-default-store-image function) ;; (function gs-store-image-packet int int int int int int int int) -;; (define-extern store-image function) ;; (function int int) - +(define-extern gs-set-default-store-image (function gs-store-image-packet int int int int int int int int)) +(define-extern store-image (function screen-shot-work int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; memory-usage-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum mem-usage-id + :type uint32 + (bsp-leaf-vis-self 62) + (bsp-leaf-vis-adj 63) + + (level-code 65) + (entity-links 66) + ) + (deftype memory-usage-info (structure) ((name string :offset-assert 0) ;; guessed by decompiler (count int32 :offset-assert 4) @@ -6998,13 +7219,11 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype memory-usage-block (basic) ((work-bsp basic :offset-assert 4) (length int32 :offset-assert 8) - (data memory-usage-info 112 :offset-assert 16) ;; guessed by decompiler + (data memory-usage-info 112 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 12 :size-assert #x710 @@ -7015,17 +7234,16 @@ (memory-usage-block-method-11 () none 11) ;; (print-mem-usage (_type_ level object) none 11) ) ) -|# -;; (define-extern *mem-usage* object) ;; memory-usage-block -;; (define-extern *dma-mem-usage* object) ;; memory-usage-block -;; (define-extern *temp-mem-usage* object) ;; memory-usage-block +(define-extern *mem-usage* memory-usage-block) +(define-extern *dma-mem-usage* memory-usage-block) +(define-extern *temp-mem-usage* memory-usage-block) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; blit-displays-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype blit-displays-work (structure) ((adgif-tmpl dma-gif-packet :inline :offset-assert 0) (sprite-tmpl dma-gif-packet :inline :offset-assert 32) @@ -7034,7 +7252,7 @@ (scan-tmpl dma-gif-packet :inline :offset-assert 128) (color vector4w :inline :offset-assert 160) (line-color uint64 :offset-assert 176) - (scan-colors UNKNOWN 15 :offset-assert 192) + (scan-colors vector4w 15 :inline :offset-assert 192) ;; guesss (menu-mode basic :offset-assert 432) (screen-copied basic :offset-assert 436) (vu1-enable-user-menu uint64 :offset-assert 440) @@ -7051,13 +7269,15 @@ :size-assert #x1e0 :flag-assert #x9000001e0 ) -|# + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; texture ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; TODO skip + #| (deftype texture-page-dir (basic) () @@ -7071,53 +7291,53 @@ ) |# -;; (define-extern texture-bpp function) ;; (function gs-psm int) -;; (define-extern texture-qwc function) ;; (function int int gs-psm int) -;; (define-extern physical-address function) ;; (function pointer pointer) -;; (define-extern dma-buffer-add-ref-texture function) ;; (function dma-buffer pointer int int gs-psm none) -;; (define-extern gs-find-block function) ;; (function int int gs-psm int) -;; (define-extern gs-page-width function) ;; (function gs-psm int) -;; (define-extern gs-page-height function) ;; (function gs-psm int) -;; (define-extern gs-block-width function) ;; (function gs-psm int) -;; (define-extern gs-block-height function) ;; (function gs-psm int) -;; (define-extern gs-largest-block function) ;; (function int int gs-psm int) -;; (define-extern gs-blocks-used function) ;; (function int int gs-psm int) -;; (define-extern texture-page-default-allocate function) ;; (function texture-pool texture-page kheap int texture-page) -;; (define-extern texture-page-common-allocate function) ;; (function texture-pool texture-page kheap int texture-page) -;; (define-extern texture-page-font-allocate function) -;; (define-extern texture-page-common-boot-allocate function) ;; (function texture-pool texture-page kheap int texture-page) -;; (define-extern upload-vram-data function) ;; (function dma-buffer int pointer int none) -;; (define-extern upload-vram-pages function) ;; (function texture-pool texture-pool-segment texture-page int bucket-id int) -;; (define-extern update-vram-pages function) ;; (function texture-pool texture-pool-segment texture-page int int) -;; (define-extern upload-vram-pages-pris function) ;; (function texture-pool texture-pool-segment texture-page bucket-id int int) -;; (define-extern texture-page-level-allocate function) ;; (function texture-pool texture-page kheap int texture-page) +(define-extern texture-bpp (function gs-psm int)) +(define-extern texture-qwc (function int int gs-psm int)) +(define-extern physical-address (function pointer pointer)) +(define-extern dma-buffer-add-ref-texture (function dma-buffer pointer int int gs-psm none)) +(define-extern gs-find-block (function int int gs-psm int)) +(define-extern gs-page-width (function gs-psm int)) +(define-extern gs-page-height (function gs-psm int)) +(define-extern gs-block-width (function gs-psm int)) +(define-extern gs-block-height (function gs-psm int)) +(define-extern gs-largest-block (function int int gs-psm int)) +(define-extern gs-blocks-used (function int int gs-psm int)) +(define-extern texture-page-default-allocate (function texture-pool texture-page kheap int texture-page)) +(define-extern texture-page-common-allocate (function texture-pool texture-page kheap int texture-page)) +(define-extern texture-page-font-allocate (function texture-pool texture-page kheap int texture-page)) +(define-extern texture-page-common-boot-allocate (function texture-pool texture-page kheap int texture-page)) +(define-extern upload-vram-data (function dma-buffer int pointer int int none)) +(define-extern upload-vram-pages (function texture-pool texture-pool-segment texture-page int bucket-id int)) +(define-extern update-vram-pages (function texture-pool texture-pool-segment texture-page int int)) +(define-extern upload-vram-pages-pris (function texture-pool texture-pool-segment texture-page bucket-id int int)) +(define-extern texture-page-level-allocate (function texture-pool texture-page kheap int texture-page)) ;; (define-extern texture-page-size-check function) ;; (function texture-pool level symbol int) ;; (define-extern set-skull-gem-masks function) ;; (define-extern upload-textures function) -;; (define-extern *txt-dma-list* object) ;; dma-buffer +(define-extern *txt-dma-list* dma-buffer) ;; (define-extern texture-relocate function) ;; (function dma-buffer texture int gs-psm int dma-buffer) -;; (define-extern relocate-later function) ;; (function symbol) +(define-extern relocate-later (function symbol)) ;; (define-extern texture-page-login function) ;; (function texture-id (function texture-pool texture-page kheap int texture-page) kheap texture-page-dir-entry) ;; (define-extern lookup-texture-by-id function) ;; (function texture-id texture) ;; (define-extern lookup-texture-by-id-fast function) ;; (define-extern lookup-texture-by-name function) ;; (define-extern lookup-texture-id-by-name function) ;; (define-extern lookup-level-texture-by-name function) -;; (define-extern *shader-list* object) ;; pair -;; (define-extern *edit-shader* object) ;; texture-id +(define-extern *shader-list* pair) +(define-extern *edit-shader* texture-id) ;; (define-extern link-texture-by-id function) ;; (function texture-id adgif-shader texture-page-dir-entry) ;; (define-extern adgif-shader<-texture! function) ;; (function adgif-shader texture adgif-shader) ;; (define-extern adgif-shader-update! function) ;; (function adgif-shader texture none) ;; (define-extern adgif-shader<-texture-with-update! function) ;; (function adgif-shader texture adgif-shader) ;; (define-extern hack-texture function) ;; (define-extern adgif-shader-login function) ;; (function adgif-shader texture) -;; (define-extern adgif-shader-login-no-remap function) ;; (function adgif-shader texture) +(define-extern adgif-shader-login-no-remap (function adgif-shader texture)) ;; (define-extern adgif-shader-login-fast function) ;; (function adgif-shader texture) ;; (define-extern adgif-shader-login-no-remap-fast function) ;; (function adgif-shader texture) ;; (define-extern adgif-shader<-texture-simple! function) ;; (function adgif-shader texture adgif-shader) ;; (define-extern set-dirty-mask! function) ;; (define-extern texture-page-dir-inspect function) ;; (function texture-page-dir symbol none) -;; (define-extern *texture-pool* object) ;; texture-pool +(define-extern *texture-pool* texture-pool) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main-h ;; @@ -7133,8 +7353,8 @@ ) (deftype screen-filter (basic) - ((draw? basic :offset-assert 4) - (bucket int32 :offset-assert 8) + ((draw? symbol :offset-assert 4) + (bucket bucket-id :offset-assert 8) (color vector :inline :offset-assert 16) (color-src vector :inline :offset-assert 32) (color-dest vector :inline :offset-assert 48) @@ -7146,9 +7366,9 @@ :size-assert #x50 :flag-assert #xc00000050 (:methods - (screen-filter-method-9 () none 9) ;; (draw (_type_) none 9) - (screen-filter-method-10 () none 10) - (screen-filter-method-11 () none 11) + (draw (_type_) none 9) + (setup (_type_ vector vector float bucket-id) none 10) + (disable (_type_) none 11) ) ) @@ -7289,11 +7509,11 @@ (define-extern *col-rend* col-rend) (define-extern debug-actor? (function object symbol)) +(define-extern *time-of-day* (pointer process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mspace-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype joint (basic) ((name basic :offset-assert 4) (number int32 :offset-assert 8) @@ -7304,9 +7524,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype bone-cache (structure) ((bone-matrix uint32 :offset-assert 0) (parent-matrix uint32 :offset-assert 4) @@ -7317,33 +7535,24 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype bone (structure) ((transform matrix :inline :offset-assert 0) - (position vector :inline :offset-assert 48) + (position vector :inline :offset 48) (scale vector :inline :offset-assert 64) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype skeleton (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) - ) + ((bones bone :inline :dynamic)) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype cspace (structure) ((parent cspace :offset-assert 0) (joint joint :offset-assert 4) ;; guessed by decompiler @@ -7363,26 +7572,21 @@ (cspace-method-9 () none 9) ;; (reset-and-assign-geo! (_type_ basic) _type_ 9) ) ) -|# -#| (deftype cspace-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data cspace :dynamic :offset-assert 16) ;; guessed by decompiler + ((data cspace :inline :dynamic :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype drawable (basic) ((id int16 :offset-assert 4) (bsphere vector :inline :offset-assert 16) @@ -7391,19 +7595,19 @@ :size-assert #x20 :flag-assert #x1100000020 (:methods - (drawable-method-9 () none 9) ;; (login (_type_) _type_ 9) - (drawable-method-10 () none 10) ;; (draw (_type_ _type_ display-frame) none 10) + (login (_type_) _type_ 9) + (draw (_type_ _type_ display-frame) none 10) (drawable-method-11 () none 11) ;; (collide-with-box (_type_ int collide-list) none 11) (drawable-method-12 () none 12) ;; (collide-y-probe (_type_ int collide-list) none 12) (drawable-method-13 () none 13) ;; (collide-ray (_type_ int collide-list) none 13) - (drawable-method-14 () none 14) ;; (collect-stats (_type_) none 14) - (drawable-method-15 () none 15) ;; (debug-draw (_type_ drawable display-frame) none 15) - (drawable-method-16 () none 16) ;; (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8) 16) + (debug-draw (_type_ drawable display-frame) none 14) ;; (collect-stats (_type_) none 14) + (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8) 15) ;; + (drawable-method-16 () none 16) ;; ) ) -|# -#| + + (deftype drawable-error (drawable) ((name string :offset-assert 32) ;; guessed by decompiler ) @@ -7413,16 +7617,17 @@ (:methods ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-group-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype drawable-group (drawable) - () + ((length int16 :offset 6) + (data drawable :dynamic :offset-assert 32) + ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 @@ -7431,16 +7636,14 @@ ;; (new (symbol type int) _type_ 0) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-inline-array-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype drawable-inline-array (drawable) - ((length int16 :offset-assert 6) + ((length int16 :offset 6) ) :method-count-assert 17 :size-assert #x20 @@ -7448,19 +7651,17 @@ (:methods ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; draw-node-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype draw-node (drawable) - ((child-count uint8 :offset-assert 6) - (flags uint8 :offset-assert 7) - (child drawable :offset-assert 8) ;; guessed by decompiler - (distance float :offset-assert 12) + ((child-count uint8 :offset 6) + (flags uint8 :offset 7) + (child drawable :offset 8) ;; guessed by decompiler + (distance float :offset 12) ) :method-count-assert 17 :size-assert #x20 @@ -7469,11 +7670,12 @@ (:methods ) ) -|# -#| + (deftype drawable-inline-array-node (drawable-inline-array) - () + ((data draw-node 1 :inline) + (pad uint32) + ) :method-count-assert 17 :size-assert #x44 :flag-assert #x1100000044 @@ -7481,42 +7683,39 @@ (:methods ) ) -|# -#| + (deftype draw-node-dma (structure) - ((banka draw-node 32 :offset-assert 4) ;; guessed by decompiler - (bankb draw-node 32 :offset-assert 1028) ;; guessed by decompiler + ((banka draw-node 32 :inline :offset-assert 0) + (bankb draw-node 32 :inline :offset-assert 1024) ) :method-count-assert 9 :size-assert #x800 :flag-assert #x900000800 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-tree-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype drawable-tree (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree (drawable-group) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-array (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-array (drawable-group) + ((trees drawable-tree :dynamic :offset 32 :score 100)) + :flag-assert #x1100000020 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-actor-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype drawable-actor (drawable) - ((actor entity-actor :offset-assert 8) ;; guessed by decompiler + ((actor entity-actor :offset 8) ;; guessed by decompiler ) :method-count-assert 17 :size-assert #x20 @@ -7524,24 +7723,25 @@ (:methods ) ) -|# -;; (deftype drawable-tree-actor (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) -;; (deftype drawable-inline-array-actor (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype drawable-tree-actor (drawable-tree) + () + :flag-assert #x1100000020 + ) + +(deftype drawable-inline-array-actor (drawable-inline-array) + ((data drawable-actor 1 :inline) + (pad uint8 4)) + :flag-assert #x1100000044 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; region-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype region (structure) ((id uint32 :offset-assert 0) (on-enter basic :offset-assert 4) @@ -7556,23 +7756,19 @@ (region-method-9 () none 9) ) ) -|# -#| + (deftype region-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) + ((data region :inline :dynamic :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + (deftype drawable-region-prim (drawable) - ((region region :offset-assert 8) + ((region region :offset 8) ) :method-count-assert 20 :size-assert #x20 @@ -7583,28 +7779,29 @@ (drawable-region-prim-method-19 () none 19) ) ) -|# -#| + (deftype drawable-tree-region-prim (drawable-tree) - () + ((name basic :offset 8) + (data2 drawable-inline-array :dynamic :offset 32 :score 1)) :method-count-assert 19 :size-assert #x20 :flag-assert #x1300000020 ;; Failed to read fields. (:methods (drawable-tree-region-prim-method-17 () none 17) - (drawable-tree-region-prim-method-18 () none 18) + (debug-print (_type_ vector object) none 18) ) ) -|# -;; (deftype drawable-inline-array-region-prim (drawable-inline-array) -;; () -;; :flag-assert #x1100000044 -;; ) -#| +(deftype drawable-inline-array-region-prim (drawable-inline-array) + ((data drawable-region-prim 1 :inline) + (pad uint8 4)) + :flag-assert #x1100000044 + ) + + (deftype drawable-region-sphere (drawable-region-prim) () :method-count-assert 20 @@ -7613,24 +7810,20 @@ (:methods ) ) -|# -#| (deftype region-face-data (structure) ((normal vector :inline :offset-assert 0) - (normal-offset float :offset-assert 12) + (normal-offset float :offset 12) (num-points uint32 :offset-assert 16) - (points UNKNOWN :dynamic :offset-assert 32) + (points vector :inline :dynamic :offset-assert 32) ;; guess ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype drawable-region-face (drawable-region-prim) - ((data region-face-data :offset-assert 12) + ((data region-face-data :offset 12) ) :method-count-assert 20 :size-assert #x20 @@ -7638,23 +7831,17 @@ (:methods ) ) -|# -#| (deftype region-face-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 20) + ((data region-face-data :dynamic :offset 20) ;; not sure what's going on here. ) :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype drawable-region-volume (drawable-region-prim) - ((faces basic :offset-assert 12) + ((faces region-face-array :offset 12) ) :method-count-assert 20 :size-assert #x20 @@ -7662,25 +7849,21 @@ (:methods ) ) -|# -#| (deftype region-prim-list (structure) ((num-items int32 :offset-assert 0) - (items UNKNOWN 320 :offset-assert 4) + (items drawable-region-prim 320 :offset-assert 4) ) :method-count-assert 9 :size-assert #x504 :flag-assert #x900000504 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; traffic-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype traffic-danger-info (structure) ((sphere sphere :inline :offset-assert 0) (velocity vector :inline :offset-assert 16) @@ -7695,9 +7878,7 @@ :size-assert #x36 :flag-assert #x900000036 ) -|# -#| (deftype traffic-suppression-params (structure) ((bbox bounding-box :inline :offset-assert 0) (duration uint64 :offset-assert 32) @@ -7709,13 +7890,11 @@ (:methods (traffic-suppression-params-method-9 () none 9) (traffic-suppression-params-method-10 () none 10) - (traffic-suppression-params-method-11 () none 11) + (has-valid-id? (_type_) none 11) (traffic-suppression-params-method-12 () none 12) ) ) -|# -#| (deftype traffic-object-spawn-params (structure) ((object-type uint8 :offset-assert 0) (behavior uint64 :offset-assert 8) @@ -7735,12 +7914,11 @@ :size-assert #x68 :flag-assert #x900000068 ) -|# -;; (define-extern *traffic-manager* object) -;; (define-extern *ctywide-entity* object) -;; (define-extern *lwide-entity* object) -;; (define-extern *race-vehicle-entity* object) +(define-extern *traffic-manager* process) +(define-extern *ctywide-entity* object) +(define-extern *lwide-entity* object) +(define-extern *race-vehicle-entity* object) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-task-h ;; @@ -7748,34 +7926,361 @@ (defenum game-task :type uint8 + :bitfield #f + (none 0) + (complete 1) + (dummy0 2) + (eco-blue-button 3) + (eco-yellow-button 4) + (eco-red-button 5) + (fortress-escape 6) + (city-help-kid 7) + (city-vehicle-training 8) + (ruins-tower 9) + (atoll-water 10) + (fortress-dump 11) + (city-krew-delivery 12) + (city-red-gun-training 13) + (atoll-sig 14) + (sewer-enemy 15) + (strip-rescue 16) + (atoll-battle 17) + (mountain-lens 18) + (mountain-gear 19) + (mountain-shard 20) + (mountain-collection 21) + (city-keira-delivery 22) + (stadium-board1 23) + (city-krew-collection 24) + (city-yellow-gun-training 25) + (drill-eggs 26) + (city-power 27) + (palace-cable 28) + (palace-boss 29) + (city-shuttle 30) + (ruins-enemy 31) + (city-blue-gun-training 32) + (forest-scouts 33) + (city-escort-kid 34) + (dig-knock-down 35) + (strip-grenade 36) + (drill-ship 37) + (city-port-run 38) + (city-meet-brutter 39) + (sewer-board 40) + (forest-hunt 41) + (city-intercept-tanker 42) + (stadium-race-class3 43) + (city-protect-water-slums 44) + (dig-find-totem 45) + (city-destroy-guard-vehicles 46) + (city-play-onin-game 47) + (canyon-insert-items 48) + (tomb-poles 49) + (tomb-water 50) + (tomb-boss 51) + (fortress-save-friends 52) + (sewer-escort 53) + (city-dark-gun-training 54) + (stadium-race-class2 55) + (city-stop-bomb-bots 56) + (city-errol-challenge 57) + (strip-drop 58) + (ruins-mech 59) + (forest-protect 60) + (drill-mech 61) + (city-save-lurkers 62) + (stadium-race-class 63) + (palace-sneak-in 64) + (castle-break-in 65) + (castle-boss 66) + (city-whack 67) + (under-mech 68) + (under-sig 69) + (city-defend-stadium 70) + (consite-find-baron 71) + (nest-get-to-gun 72) + (nest-enter 73) + (nest-boss 74) + (city-win 75) + (city-oracle 76) + (city-burning-bush-ring-1 77) + (city-burning-bush-get-to-1 78) + (city-burning-bush-get-to-2 79) + (city-burning-bush-get-to-3 80) + (city-burning-bush-get-to-4 81) + (city-burning-bush-collection-1 82) + (city-burning-bush-racepoint-1 83) + (city-burning-bush-ring-2 84) + (city-burning-bush-get-to-5 85) + (city-burning-bush-get-to-6 86) + (city-burning-bush-shuttle-1 87) + (city-burning-bush-get-to-7 88) + (city-burning-bush-get-to-8 89) + (city-burning-bush-get-to-9 90) + (city-burning-bush-collection-2 91) + (city-burning-bush-get-to-10 92) + (city-burning-bush-get-to-11 93) + (city-burning-bush-ring-3 94) + (city-burning-bush-get-to-12 95) + (city-burning-bush-bombbot-1 96) + (city-burning-bush-get-to-13 97) + (city-burning-bush-get-to-14 98) + (city-burning-bush-get-to-15 99) + (city-burning-bush-collection-3 100) + (city-burning-bush-race-errol 101) + (city-burning-bush-race-port 102) + (stadium-burning-bush-race-board 103) + (stadium-burning-bush-race-class3 104) + (stadium-burning-bush-race-class2 105) + (stadium-burning-bush-race-class1 106) + (stadium-burning-bush-race-class3-r 107) + (stadium-burning-bush-race-class2-r 108) + (stadium-burning-bush-race-class1-r 109) + (max 110) ) +(defenum game-task-actor + :bitfield #f + :type uint8 + (none 0) + (minimap 1) + (torn-hideout 2) + (torn-alley 3) + (kor-alley 4) + (kor-vinroom 5) + (kor-tomb 6) + (krew-hiphog 7) + (sig-hiphog 8) + (sig-atoll 9) + (keira-garage 10) + (vin-vinroom 11) + (ashelin-atoll 12) + (ashelin-market 13) + (onin-onintent 14) + (pecker-onintent 15) + (baron-palace 16) + (baron-tomb 17) + (youngsamos-hideout 18) + (youngsamos-tomb 19) + (brutter-kiosk 20) + (kid-tomb 21) + (youngsamos-alley 22) + (kid-alley 23) + (crocadog-alley 24) + (crocadog-tomb 25) + (youngsamos-forest 26) + (ashelin-throne 27) + (baron-castle 28) + (tess-alley 29) + (youngsamos-onintent 30) + (samos-hideout 31) + (burning-bush-slumb 32) + (burning-bush-gena 33) + (burning-bush-genc 34) + (tess-hiphog 35) + (keira-stadium 36) + (kor-consite 37) + (kor-onintent 38) + (oracle-oracle 39) + (daxter-tomb 40) + (burning-bush-marka 41) + (burning-bush-sluma 42) + (burning-bush-slumb-2 43) + (burning-bush-slumc 44) + (burning-bush-farma 45) + (burning-bush-farmb 46) + (burning-bush-markb 47) + (burning-bush-markb-2 48) + (burning-bush-gena-2 49) + (burning-bush-genb 50) + (burning-bush-genc-2 51) + (burning-bush-inda 52) + (burning-bush-indb 53) + (burning-bush-port 54) + (burning-bush-port-2 55) + (burning-bush-port-3 56) + (burning-bush-pal 57) + (burning-bush-stadium 58) + (burning-bush-pal-2 59) + (burning-bush-genb-2 60) + (kor-hideout 61) + (kid-hideout 62) + (kid-vinroom 63) + (crocadog-vinroom 64) + (samos-garage 65) + (baron-consite 66) + (whack-a-metal-hiphog 67) + ) + +(defenum game-task-action + :bitfield #f + :type uint8 + (hide 0) + (idle 1) + (say 2) + (talk 3) + (show 4) + (shade 5) + (play 6) + (menu 7) + ) + +(defenum game-task-flags + :type uint8 + ) + +(defenum game-task-icon + :type uint16 + ) + +(defenum task-manager-mask + :type uint32 + :bitfield #t + (intro-scene 0) ;; 1 + (resolution-scene 1) ;; 2 + (begin-sphere 2) ;; 4 + (end-sphere 3) ;; 8 + (fail-message 4) ;; 16 + (retry-message 5) ;; 32 + ) + +(defenum game-task-node-flag + :type uint32 ;; guess + :bitfield #t + + (closed 0) ;; 1 + (auto-close 1) ;; 2 + (data 2) ;; 4 + (close-task 3) ;; 8 + (save-on-life 4) ;; 16 + (save-on-try 5) ;; 32 + (abs-task-mask 6) ;; 64 + (set-task-mask 7) ;; 128 + (clear-task-mask 8) ;; 256 + (task-retry 9) ;; 512 + (exclusive 10) ;; 1024 + (intro-wait 11) ;; 2048 + (city-wait 12) ;; 4096 + (reset-on-try 13) ;; 8192 + (task-manager 14) ;; 16384 + (no-fail-on-death 15) ;; 32768 + (no-restart 16) ;; 1 + (no-audio 17) ;; 2 + (no-slow-down 18) ;; #4 high + (utility-node 19) ;; #x8 high + ) + +(defenum game-task-node-command + :type uint8 ;; guess + :bitfield #f + (none 0) + (add-sidekick 1) + (sub-sidekick 2) + (add-board 3) + (sub-board 4) + (add-gun-red 5) + (add-gun-yellow 6) + (add-gun-blue 7) + (add-gun-dark 8) + (add-gun-up-1 9) + (add-gun-up-2 10) + (add-gun-up-3 11) + (add-gun-up-4 12) + (add-pass-red 13) + (add-pass-green 14) + (add-pass-yellow 15) + (add-pass-blue 16) + (add-darkjak 17) + (add-darkjak-0 18) + (add-darkjak-1 19) + (add-darkjak-2 20) + (add-darkjak-3 21) + (add-board-training 22) + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; task-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| -(deftype task-manager-info (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. +(deftype game-task-event (basic) + ((actor game-task-actor :offset-assert 4) + (action game-task-action :offset-assert 5) + (icon game-task-icon :offset 6) + (flags game-task-flags :offset 7) + (scene basic :offset 8) + (distance meters :offset-assert 12) ) -|# - -#| -(deftype game-task-node-info (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. + :flag-assert #x900000010 ) -|# -#| -(deftype game-task-info (UNKNOWN) + +(deftype task-manager-info (structure) + ((mask task-manager-mask) + (level basic) + (manager handle) + (fail-message uint32) + (retry-message uint32) + (intro-scene basic) + (resolution-scene basic) + (resolution-scene-continue basic) + (retry-continue basic) + (fail-continue basic) + (init-hook basic) + (cleanup-hook basic) + (update-hook basic) + (code-hook basic) + (complete-hook basic) + (fail-hook basic) + (event-hook basic) + (final-node uint16) + (time-limit int32) + (sphere-count int8) + (index int8) + (intro-delay uint16) + (sphere-array uint32) ;; pointers... + (on-complete basic) + (on-fail basic) + (begin-sphere sphere :inline) + (end-sphere sphere :inline) + ) + :flag-assert #x900000080 + ) + + + +(deftype game-task-node-info (basic) + ((level basic) + (task game-task) + (name basic) + (when-open basic) + (flags game-task-node-flag) + (parent-node uint16 4) + (task-mask task-mask) + (on-open basic) + (info task-manager-info) + (borrow basic) + (open? symbol) + (on-close basic) + (close-time time-frame) + (death-count uint16) + (gem-count uint16) + (skill-count uint16) + (suck-death-count uint8) + (add game-task-node-command) + (description uint32) + ) + :flag-assert #xe0000004c + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + (dummy-12 () none 12) + (dummy-13 () none 13) + ) + ) + + +(deftype game-task-info (basic) ((name basic :offset-assert 4) (text-name uint32 :offset-assert 8) (pre-play-node uint16 :offset-assert 12) @@ -7785,67 +8290,116 @@ (play-continue basic :offset-assert 24) (kiosk-play-continue basic :offset-assert 28) ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 + :flag-assert #x900000020 ) -|# -#| -(deftype task-manager (UNKNOWN) - () - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ;; Failed to read fields. +(deftype game-task-control (basic) + ((counter uint32) + (actor game-task-actor) + (current-node uint16) + (current-event uint32) + ) + :flag-assert #xa00000010 + (:methods + (dummy-9 () none 9) + ) ) -|# -#| -(deftype ambient-control (UNKNOWN) + +(deftype task-manager (process) + ( + (node-info basic) + (info task-manager-info) + (lev-name basic) + (fail-on-death? symbol) + (fail-now basic) + (retry-now basic) + (allow-fail basic) + (state-time time-frame) + (count int16) + (max-count int16) + (sub-state uint32 :offset-assert 172) + (slave uint64 32) ;; ? + (arrow uint64 :offset-assert 432) + (link uint32) + (start-time time-frame) + (total-time time-frame) + (beep-time time-frame) + (time-limit time-frame) + (begin-pos vector :inline :offset-assert 480) + (end-pos vector :inline) + (data-int8 int8 32) + (data-int32 int32 32) + (data-float float 32) + (data-vector vector 32 :inline :offset-assert 800) + (actor-group uint32 4 :offset-assert 1312) + (minimap uint32 8 :offset-assert 1328) + (hud uint64 4 :offset-assert 1360) + (hud-timer time-frame :offset 1360) + (hud-counter int64 :offset 1368) + (sound-id uint32 4 :offset-assert 1392) + (intro-time time-frame :offset-assert 1408) + ) + :flag-assert #x1705100588 + (:methods + (dummy-14 () none 14) + (dummy-15 () none 15) + (dummy-16 () none 16) + (dummy-17 () none 17) + (dummy-18 () none 18) + (dummy-19 () none 19) + (dummy-20 () none 20) + (dummy-21 () none 21) + (dummy-22 () none 22) + + ) + ) + + +(deftype ambient-control (structure) ((last-ambient-time time-frame :offset-assert 0) ;; time-frame (last-ambient string :offset-assert 8) ;; guessed by decompiler (last-ambient-id sound-id :offset-assert 12) ;; guessed by decompiler ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 + :flag-assert #xc00000010 + (:methods + (dummy-9 () none 9) + (dummy-10 () none 10) + (dummy-11 () none 11) + ) ) -|# -;; (define-extern game-task->string function) ;; (function game-task string) -;; (define-extern c-string->game-task function) -;; (define-extern game-task-actor->string function) -;; (define-extern game-task-action->string function) -;; (define-extern game-task-node-flag->string function) -;; (define-extern game-task-node-command->string function) -;; (define-extern *traffic-engine* object) +(define-extern game-task->string (function game-task string)) +(define-extern c-string->game-task (function string game-task)) +(define-extern game-task-actor->string (function game-task-actor string)) +(define-extern game-task-action->string (function game-task-action string)) +(define-extern game-task-node-flag->string (function game-task-node-flag none)) +(define-extern game-task-node-command->string (function game-task-node-command string)) +(define-extern *traffic-engine* object) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gsf-vertex (structure) - ((data uint32 8 :offset-assert 0) ;; guessed by decompiler - (byte uint8 32 :offset-assert 0) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler - (vt qword :inline :offset-assert 0) - (pos vector3s :inline :offset-assert 0) - (tex vector2uh :inline :offset-assert 12) - (nrm vector3s :inline :offset-assert 16) - (nc qword :inline :offset-assert 16) - (clr vector4ub :inline :offset-assert 28) - (dtex vector2uh :inline :offset-assert 16) - (dclr vector4ub :inline :offset-assert 20) + ((data uint32 8 :offset-assert 0) + (byte uint8 32 :offset 0) + (quad uint128 2 :offset 0) + (vt qword :inline :offset 0) + (pos vector3s :inline :offset 0) + (tex vector2uh :inline :offset 12) + (nrm vector3s :inline :offset 16) + (nc qword :inline :offset 16) + (clr vector4ub :inline :offset 28) + (dtex vector2uh :inline :offset 16) + (dclr vector4ub :inline :offset 20) ) + :pack-me :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype gsf-fx-vertex (structure) ((clr vector4ub :inline :offset-assert 0) (tex vector2uh :inline :offset-assert 4) @@ -7854,9 +8408,8 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| + (deftype gsf-header (structure) ((num-strips uint8 :offset-assert 0) (num-new-vtxs uint8 :offset-assert 1) @@ -7868,9 +8421,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gsf-ik (structure) ((index uint8 :offset-assert 0) (no-kick uint8 :offset-assert 1) @@ -7879,9 +8430,7 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype gsf-info (structure) ((ptr-iks uint32 :offset-assert 0) (ptr-verts uint32 :offset-assert 4) @@ -7892,22 +8441,18 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gsf-buffer (structure) ((data uint8 8192 :offset-assert 0) ;; guessed by decompiler - (info gsf-info :inline :offset-assert 0) - (header gsf-header :inline :offset-assert 16) - (work-area uint8 :dynamic :offset-assert 32) ;; guessed by decompiler + (info gsf-info :inline :offset 0) + (header gsf-header :inline :offset 16) + (work-area uint8 :dynamic :offset 32) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2000 :flag-assert #x900002000 ) -|# -#| (deftype generic-frag (structure) ((start-pos uint16 :offset-assert 0) (end-pos uint16 :offset-assert 2) @@ -7916,9 +8461,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-strip (structure) ((pos uint16 :offset-assert 0) (len uint16 :offset-assert 2) @@ -7927,9 +8470,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-envmap-saves (structure) ((index-mask vector4w :inline :offset-assert 0) (verts uint128 12 :offset-assert 16) ;; guessed by decompiler @@ -7939,9 +8480,7 @@ :size-assert #x110 :flag-assert #x900000110 ) -|# -#| (deftype generic-interp-job (structure) ((job-type uint16 :offset-assert 0) (num uint16 :offset-assert 2) @@ -7951,13 +8490,12 @@ (morph-z uint16 :offset-assert 12) (morph-w uint16 :offset-assert 14) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-saves (structure) ((ptr-dma uint32 :offset-assert 0) (ptr-vtxs uint32 :offset-assert 4) @@ -7990,24 +8528,20 @@ :size-assert #x170 :flag-assert #x900000170 ) -|# -#| (deftype generic-gif-tag (structure) ((data uint32 4 :offset-assert 0) ;; guessed by decompiler - (qword qword :inline :offset-assert 0) - (fan-prim uint32 :offset-assert 0) - (str-prim uint32 :offset-assert 4) - (regs uint32 :offset-assert 8) - (num-strips uint32 :offset-assert 12) + (qword qword :inline :offset 0) + (fan-prim uint32 :offset 0) + (str-prim uint32 :offset 4) + (regs uint32 :offset 8) + (num-strips uint32 :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-envmap-consts (structure) ((consts vector :inline :offset-assert 0) (strgif generic-gif-tag :inline :offset-assert 16) @@ -8018,9 +8552,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-consts (structure) ((dma-header dma-packet :inline :offset-assert 0) (vif-header uint32 4 :offset-assert 16) ;; guessed by decompiler @@ -8033,7 +8565,7 @@ (ztest-normal gs-adcmd :inline :offset-assert 176) ;; ad-cmd :inline (ztest-opaque gs-adcmd :inline :offset-assert 192) ;; ad-cmd :inline (adcmd-offsets uint8 16 :offset-assert 208) ;; guessed by decompiler - (adcmds ad-cmd 4 :offset-assert 144) ;; guessed by decompiler + ;(adcmds gs-adcmd 4 :offset-assert 144) ;; guessed by decompiler (stcycle-tag uint32 :offset-assert 224) (unpack-vtx-tag uint32 :offset-assert 228) (unpack-clr-tag uint32 :offset-assert 232) @@ -8051,9 +8583,7 @@ :size-assert #x1b0 :flag-assert #x9000001b0 ) -|# -#| (deftype generic-storage (structure) ((data uint128 16 :offset-assert 0) ;; guessed by decompiler ) @@ -8061,7 +8591,6 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# #| (deftype gsf-vertex-array (UNKNOWN) @@ -8083,13 +8612,28 @@ ) |# -;; (define-extern *gsf-buffer* object) ;; gsf-buffer +(deftype gsf-vertex-array (structure) + ((vtx gsf-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) + +(deftype gsf-fx-vertex-array (structure) + ((data gsf-fx-vertex :dynamic :offset-assert 0) + ) + :method-count-assert 9 + :size-assert #x0 + :flag-assert #x900000000 + ) + +(define-extern *gsf-buffer* gsf-buffer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sky-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sky-color-hour (structure) ((snapshot1 int32 :offset-assert 0) (snapshot2 int32 :offset-assert 4) @@ -8100,51 +8644,43 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype sky-color-day (structure) - ((hour sky-color-hour 24 :offset-assert 0) ;; guessed by decompiler + ((hour sky-color-hour 24 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype sky-sun-data (structure) ((data uint128 4 :offset-assert 0) ;; guessed by decompiler - (pos vector :inline :offset-assert 0) - (r-sun float :offset-assert 16) - (r-halo float :offset-assert 20) - (r-aurora float :offset-assert 24) - (c-sun-start rgba :offset-assert 32) ;; guessed by decompiler - (c-sun-end rgba :offset-assert 48) ;; guessed by decompiler - (c-halo-start rgba :offset-assert 36) ;; guessed by decompiler - (c-halo-end rgba :offset-assert 52) ;; guessed by decompiler - (c-aurora-start rgba :offset-assert 40) ;; guessed by decompiler - (c-aurora-end rgba :offset-assert 56) ;; guessed by decompiler + (pos vector :inline :offset 0) + (r-sun float :offset 16) + (r-halo float :offset 20) + (r-aurora float :offset 24) + (c-sun-start rgba :offset 32) ;; guessed by decompiler + (c-sun-end rgba :offset 48) ;; guessed by decompiler + (c-halo-start rgba :offset 36) ;; guessed by decompiler + (c-halo-end rgba :offset 52) ;; guessed by decompiler + (c-aurora-start rgba :offset 40) ;; guessed by decompiler + (c-aurora-end rgba :offset 56) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sky-moon-data (structure) ((data uint128 2 :offset-assert 0) ;; guessed by decompiler - (pos vector :inline :offset-assert 0) - (scale vector :inline :offset-assert 16) + (pos vector :inline :offset 0) + (scale vector :inline :offset 16) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sky-orbit (structure) ((high-noon float :offset-assert 0) (tilt float :offset-assert 4) @@ -8153,25 +8689,22 @@ (min-halo float :offset-assert 16) (max-halo float :offset-assert 20) ) + :allow-misaligned :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype sky-upload-data (structure) ((data uint128 10 :offset-assert 0) ;; guessed by decompiler - (sun sky-sun-data 2 :offset-assert 0) ;; guessed by decompiler - (moon sky-moon-data :inline :offset-assert 128) + (sun sky-sun-data 2 :inline :offset 0) ;; guessed by decompiler + (moon sky-moon-data :inline :offset 128) ) :method-count-assert 9 :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| (deftype sky-vertex (structure) ((pos vector :inline :offset-assert 0) (stq vector :inline :offset-assert 16) @@ -8181,19 +8714,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| -(deftype sky-vertex (structure) - () - :method-count-assert 9 - :size-assert #x30 - :flag-assert #x900000030 - ;; Failed to read fields. - ) -|# - -#| (deftype cloud-vertex (structure) ((pos vector :inline :offset-assert 0) (stq vector :inline :offset-assert 16) @@ -8207,19 +8728,15 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype cloud-vert-array (structure) - ((data UNKNOWN 100 :offset-assert 0) + ((data cloud-vertex 100 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x2bc0 :flag-assert #x900002bc0 ) -|# -#| (deftype haze-vertex (structure) ((pos vector :inline :offset-assert 0) (nrm vector :inline :offset-assert 16) @@ -8229,19 +8746,15 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype haze-vert-array (structure) - ((data UNKNOWN 36 :offset-assert 0) + ((data haze-vertex 36 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x6c0 :flag-assert #x9000006c0 ) -|# -#| (deftype cloud-lights (structure) ((sun0-normal vector :inline :offset-assert 0) (sun1-normal vector :inline :offset-assert 16) @@ -8260,9 +8773,7 @@ :size-assert #x9c :flag-assert #x90000009c ) -|# -#| (deftype haze-lights (structure) ((sun0-normal vector :inline :offset-assert 0) (sun1-normal vector :inline :offset-assert 16) @@ -8279,9 +8790,7 @@ :size-assert #x7c :flag-assert #x90000007c ) -|# -#| (deftype sky-work (structure) ((adgif-tmpl dma-gif-packet :inline :offset-assert 0) (draw-tmpl dma-gif-packet :inline :offset-assert 32) @@ -8290,28 +8799,28 @@ (blend-tmpl dma-gif-packet :inline :offset-assert 128) (sprite-tmpl dma-gif-packet :inline :offset-assert 160) (sprite-tmpl2 dma-gif-packet :inline :offset-assert 192) - (sun-coords UNKNOWN 2 :offset-assert 224) - (green-coords UNKNOWN 2 :offset-assert 256) - (moon0-coords UNKNOWN 2 :offset-assert 288) - (moon1-coords UNKNOWN 2 :offset-assert 320) - (moon2-coords UNKNOWN 2 :offset-assert 352) - (star-coords UNKNOWN 2 :offset-assert 384) - (sun-colors UNKNOWN 2 :offset-assert 416) - (green-colors UNKNOWN 2 :offset-assert 448) - (moon-colors UNKNOWN 3 :offset-assert 480) - (star-colors UNKNOWN 16 :offset-assert 528) - (st-coords UNKNOWN 2 :offset-assert 784) - (random UNKNOWN 8 :offset-assert 816) + (sun-coords vector 2 :inline :offset-assert 224) + (green-coords vector 2 :inline :offset-assert 256) + (moon0-coords vector 2 :inline :offset-assert 288) + (moon1-coords vector 2 :inline :offset-assert 320) + (moon2-coords vector 2 :inline :offset-assert 352) + (star-coords vector 2 :inline :offset-assert 384) + (sun-colors vector 2 :inline :offset-assert 416) + (green-colors vector 2 :inline :offset-assert 448) + (moon-colors vector 3 :inline :offset-assert 480) + (star-colors vector 16 :inline :offset-assert 528) + (st-coords vector 2 :inline :offset-assert 784) + (random vector 8 :inline :offset-assert 816) (giftag-base dma-gif :inline :offset-assert 944) (giftag-haze dma-gif :inline :offset-assert 960) (giftag-roof dma-gif :inline :offset-assert 976) (giftag-ocean dma-gif :inline :offset-assert 992) (fog vector :inline :offset-assert 1008) - (sky UNKNOWN 8 :offset-assert 1024) + (sky float 8 :offset-assert 1024) (time float :offset-assert 1056) (off-s uint16 :offset-assert 1060) (off-t uint16 :offset-assert 1062) - (orbit UNKNOWN 3 :offset-assert 1064) + (orbit sky-orbit 3 :inline :offset-assert 1064) (upload-data sky-upload-data :inline :offset-assert 1168) (ambi-color vector :inline :offset-assert 1328) (ambi-color-lower vector :inline :offset-assert 1344) @@ -8327,7 +8836,7 @@ (haze-lights haze-lights :inline :offset-assert 1744) (buf basic :offset-assert 1868) (draw-vortex basic :offset-assert 1872) - (stars UNKNOWN 512 :offset-assert 1888) + (stars vector 512 :inline :offset-assert 1888) ) :method-count-assert 37 :size-assert #x2760 @@ -8363,14 +8872,12 @@ (sky-work-method-36 () none 36) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ocean-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ocean-corner (structure) ((bsphere sphere :inline :offset-assert 0) (start-corner vector :inline :offset-assert 16) @@ -8382,9 +8889,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype ocean-wave-info (structure) ((frequency float :offset-assert 0) (amplitude float :offset-assert 4) @@ -8399,9 +8904,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ocean-vertex (structure) ((pos vector :inline :offset-assert 0) (stq vector :inline :offset-assert 16) @@ -8411,19 +8914,15 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype ocean-spheres (structure) - ((spheres sphere 36 :offset-assert 0) ;; guessed by decompiler + ((spheres sphere 36 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype ocean-colors (structure) ((colors rgba 2548 :offset-assert 0) ;; guessed by decompiler ) @@ -8431,30 +8930,25 @@ :size-assert #x27d0 :flag-assert #x9000027d0 ) -|# -#| (deftype ocean-colors-float (structure) - ((colors UNKNOWN 2548 :offset-assert 0) + ((colors vector 2548 :inline :offset-assert 0) ;; guess ) :method-count-assert 9 :size-assert #x9f40 :flag-assert #x900009f40 ) -|# -#| (deftype ocean-mid-mask (structure) ((mask uint8 8 :offset-assert 0) ;; guessed by decompiler - (dword uint64 :offset-assert 0) + (dword uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-mid-indices (basic) ((data uint16 36 :offset-assert 4) ;; guessed by decompiler ) @@ -8462,9 +8956,7 @@ :size-assert #x4c :flag-assert #x90000004c ) -|# -#| (deftype ocean-mid-masks (basic) ((data (inline-array ocean-mid-mask) :offset-assert 4) ;; guessed by decompiler ) @@ -8472,41 +8964,34 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-trans-mask (structure) ((mask uint8 4 :offset-assert 0) ;; guessed by decompiler - (word int32 :offset-assert 0) ;; uint64 + (word int32 :offset 0) ;; uint64 ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype ocean-trans-index (structure) ((parent int16 :offset-assert 0) (child int16 :offset-assert 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype ocean-trans-indices (basic) - ((data ocean-trans-index 2304 :offset-assert 4) ;; guessed by decompiler + ((data ocean-trans-index 2304 :inline :offset-assert 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2404 :flag-assert #x900002404 ) -|# -#| (deftype ocean-near-index (structure) ((data uint16 16 :offset-assert 0) ;; guessed by decompiler ) @@ -8514,9 +8999,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype ocean-near-indices (basic) ((data (inline-array ocean-near-index) :offset-assert 4) ;; guessed by decompiler ) @@ -8524,9 +9007,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype ocean-near-colors (structure) ((color0 vector :inline :offset-assert 0) (color1 vector :inline :offset-assert 16) @@ -8537,9 +9018,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype ocean-trans-strip (structure) ((verts uint128 10 :offset-assert 0) ;; guessed by decompiler ) @@ -8547,19 +9026,15 @@ :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| (deftype ocean-trans-strip-array (structure) - ((data ocean-trans-strip 4 :offset-assert 0) ;; guessed by decompiler + ((data ocean-trans-strip 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x280 :flag-assert #x900000280 ) -|# -#| (deftype ocean-wave-data (structure) ((data uint8 1024 :offset-assert 0) ;; guessed by decompiler ) @@ -8567,22 +9042,18 @@ :size-assert #x400 :flag-assert #x900000400 ) -|# -#| (deftype ocean-wave-frames (structure) - ((frame ocean-wave-data 64 :offset-assert 0) ;; guessed by decompiler + ((frame ocean-wave-data 64 :inline :offset-assert 0) ;; guessed by decompiler ) + ;; overflow 16-bit int size bug :method-count-assert 9 - :size-assert #x0 - :heap-base #x1 - :flag-assert #x900010000 + :size-assert #x10000 + ;:flag-assert #x900010000 ) -|# -#| (deftype ocean-texture-constants (structure) - ((giftag qword :inline :offset-assert 0) ;; gs-gif-tag :inline + ((giftag gs-gif-tag :inline :offset-assert 0) ;; was qword (buffers vector4w :inline :offset-assert 16) (dests vector4w :inline :offset-assert 32) (start vector :inline :offset-assert 48) @@ -8594,9 +9065,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype ocean-mid-vertex (structure) ((stq vector :inline :offset-assert 0) (col vector :inline :offset-assert 16) @@ -8606,9 +9075,8 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| + (deftype ocean-mid-constants (structure) ((hmge-scale vector :inline :offset-assert 0) (inv-hmge-scale vector :inline :offset-assert 16) @@ -8616,17 +9084,17 @@ (fog vector :inline :offset-assert 48) (constants vector :inline :offset-assert 64) (constants2 vector :inline :offset-assert 80) - (drw-fan qword :inline :offset-assert 96) ;; gs-gif-tag :inline - (env-fan qword :inline :offset-assert 112) ;; gs-gif-tag :inline - (drw-adgif qword :inline :offset-assert 128) ;; gs-gif-tag :inline + (drw-fan gs-gif-tag :inline :offset-assert 96) ;; gs-gif-tag :inline + (env-fan gs-gif-tag :inline :offset-assert 112) ;; gs-gif-tag :inline + (drw-adgif gs-gif-tag :inline :offset-assert 128) ;; gs-gif-tag :inline (drw-texture adgif-shader :inline :offset-assert 144) - (drw-strip-0 qword :inline :offset-assert 224) ;; gs-gif-tag :inline - (drw-strip-1 qword :inline :offset-assert 240) ;; gs-gif-tag :inline - (env-adgif qword :inline :offset-assert 256) ;; gs-gif-tag :inline + (drw-strip-0 gs-gif-tag :inline :offset-assert 224) ;; gs-gif-tag :inline + (drw-strip-1 gs-gif-tag :inline :offset-assert 240) ;; gs-gif-tag :inline + (env-adgif gs-gif-tag :inline :offset-assert 256) ;; gs-gif-tag :inline (env-texture adgif-shader :inline :offset-assert 272) - (env-strip qword :inline :offset-assert 352) ;; gs-gif-tag :inline + (env-strip gs-gif-tag :inline :offset-assert 352) ;; gs-gif-tag :inline (env-color vector :inline :offset-assert 368) - (index-table vector4w 8 :offset-assert 384) ;; guessed by decompiler + (index-table vector4w 8 :inline :offset-assert 384) ;; guessed by decompiler (pos0 vector :inline :offset-assert 512) (pos1 vector :inline :offset-assert 528) (pos2 vector :inline :offset-assert 544) @@ -8636,9 +9104,8 @@ :size-assert #x240 :flag-assert #x900000240 ) -|# -#| + (deftype ocean-mid-upload (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -8649,9 +9116,7 @@ :size-assert #x760 :flag-assert #x900000760 ) -|# -#| (deftype ocean-mid-upload2 (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -8670,9 +9135,7 @@ :size-assert #x230 :flag-assert #x900000230 ) -|# -#| (deftype ocean-mid-work (structure) ((env0 vector :inline :offset-assert 0) (env1 vector :inline :offset-assert 16) @@ -8686,9 +9149,7 @@ :size-assert #x160 :flag-assert #x900000160 ) -|# -#| (deftype ocean-near-constants (structure) ((hmge-scale vector :inline :offset-assert 0) (inv-hmge-scale vector :inline :offset-assert 16) @@ -8699,31 +9160,29 @@ (constants3 vector :inline :offset-assert 96) (constants4 vector :inline :offset-assert 112) (constants5 vector :inline :offset-assert 128) - (drw-fan qword :inline :offset-assert 144) ;; gs-gif-tag :inline - (drw2-fan qword :inline :offset-assert 160) ;; gs-gif-tag :inline - (env-fan qword :inline :offset-assert 176) ;; gs-gif-tag :inline - (drw-adgif qword :inline :offset-assert 192) ;; gs-gif-tag :inline + (drw-fan gs-gif-tag :inline :offset-assert 144) ;; gs-gif-tag :inline + (drw2-fan gs-gif-tag :inline :offset-assert 160) ;; gs-gif-tag :inline + (env-fan gs-gif-tag :inline :offset-assert 176) ;; gs-gif-tag :inline + (drw-adgif gs-gif-tag :inline :offset-assert 192) ;; gs-gif-tag :inline (drw-texture adgif-shader :inline :offset-assert 208) - (drw-strip qword :inline :offset-assert 288) ;; gs-gif-tag :inline - (env-adgif qword :inline :offset-assert 304) ;; gs-gif-tag :inline + (drw-strip gs-gif-tag :inline :offset-assert 288) ;; gs-gif-tag :inline + (env-adgif gs-gif-tag :inline :offset-assert 304) ;; gs-gif-tag :inline (env-texture adgif-shader :inline :offset-assert 320) - (env-strip qword :inline :offset-assert 400) ;; gs-gif-tag :inline + (env-strip gs-gif-tag :inline :offset-assert 400) ;; gs-gif-tag :inline (env-color vector :inline :offset-assert 416) - (drw2-adgif qword :inline :offset-assert 432) ;; gs-gif-tag :inline + (drw2-adgif gs-gif-tag :inline :offset-assert 432) ;; gs-gif-tag :inline (drw2-tex0 qword :inline :offset-assert 448) (drw2-frame qword :inline :offset-assert 464) - (drw2-strip qword :inline :offset-assert 480) ;; gs-gif-tag :inline - (drw3-adgif qword :inline :offset-assert 496) ;; gs-gif-tag :inline + (drw2-strip gs-gif-tag :inline :offset-assert 480) ;; gs-gif-tag :inline + (drw3-adgif gs-gif-tag :inline :offset-assert 496) ;; gs-gif-tag :inline (drw3-frame qword :inline :offset-assert 512) - (index-table vector4w 4 :offset-assert 528) ;; guessed by decompiler + (index-table vector4w 4 :inline :offset-assert 528) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x250 :flag-assert #x900000250 ) -|# -#| (deftype ocean-near-upload (structure) ((rot matrix :inline :offset-assert 0) (matrix matrix :inline :offset-assert 64) @@ -8736,9 +9195,7 @@ :size-assert #x100 :flag-assert #x900000100 ) -|# -#| (deftype ocean-near-vertex (structure) ((stq vector :inline :offset-assert 0) (clr vector :inline :offset-assert 16) @@ -8748,9 +9205,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype ocean-near-work (structure) ((verts-ptr vector :inline :offset-assert 0) (indices uint128 16 :offset-assert 16) ;; guessed by decompiler @@ -8759,29 +9214,23 @@ :size-assert #x110 :flag-assert #x900000110 ) -|# -#| (deftype ocean-height-array (structure) - ((data UNKNOWN 1024 :offset-assert 0) + ((data float 1024 :offset-assert 0) ;; guess ) :method-count-assert 9 :size-assert #x1000 :flag-assert #x900001000 ) -|# -#| (deftype ocean-vert-array (structure) - ((data UNKNOWN 2048 :offset-assert 0) + ((data vector 2048 :inline :offset-assert 0);; guess ) :method-count-assert 9 :size-assert #x8000 :flag-assert #x900008000 ) -|# -#| (deftype ocean-map (structure) ((start-corner vector :inline :offset-assert 0) (far-color vector :inline :offset-assert 16) @@ -8800,9 +9249,7 @@ (ocean-map-method-10 () none 10) ) ) -|# -#| (deftype ocean (ocean-map) ((off basic :offset-assert 56) (near-off basic :offset-assert 60) @@ -8817,14 +9264,14 @@ (map-min vector :inline :offset-assert 112) (map-max vector :inline :offset-assert 128) (interp vector :inline :offset-assert 144) - (corner-array UNKNOWN 25 :offset-assert 160) + (corner-array ocean-corner 25 :inline :offset-assert 160) (corner-count int32 :offset-assert 2160) - (temp-vecs UNKNOWN 4 :offset-assert 2176) - (mid-mask-ptrs UNKNOWN 36 :offset-assert 2240) - (mid-camera-masks UNKNOWN 36 :offset-assert 2384) - (trans-mask-ptrs UNKNOWN 64 :offset-assert 2672) - (trans-camera-masks UNKNOWN 16 :offset-assert 2928) - (trans-temp-masks UNKNOWN 16 :offset-assert 2992) + (temp-vecs vector 4 :inline :offset-assert 2176) + (mid-mask-ptrs pointer 36 :offset-assert 2240) + (mid-camera-masks uint64 36 :offset-assert 2384) + (trans-mask-ptrs pointer 64 :offset-assert 2672) + (trans-camera-masks uint32 16 :offset-assert 2928) + (trans-temp-masks uint32 16 :offset-assert 2992) (sprite-tmpl dma-gif-packet :inline :offset-assert 3056) (sprite-tmpl2 dma-gif-packet :inline :offset-assert 3088) (sprite-tmpl3 dma-gif-packet :inline :offset-assert 3120) @@ -8839,13 +9286,13 @@ (haze-lights haze-lights :inline :offset-assert 3536) (constant vector :inline :offset-assert 3664) (sky-color vector :inline :offset-assert 3680) - (haze-verts UNKNOWN 32 :offset-assert 3696) - (cloud-verts UNKNOWN 36 :offset-assert 4208) - (cloud-nrms UNKNOWN 36 :offset-assert 4784) - (cloud-col0 UNKNOWN 36 :offset-assert 5360) - (cloud-col1 UNKNOWN 36 :offset-assert 5936) - (cloud-st0 UNKNOWN 36 :offset-assert 6512) - (cloud-st1 UNKNOWN 36 :offset-assert 7088) + (haze-verts vector4w 32 :inline :offset-assert 3696) + (cloud-verts vector4w 36 :inline :offset-assert 4208) + (cloud-nrms vector 36 :inline :offset-assert 4784) + (cloud-col0 vector 36 :inline :offset-assert 5360) + (cloud-col1 vector 36 :inline :offset-assert 5936) + (cloud-st0 vector 36 :inline :offset-assert 6512) + (cloud-st1 vector 36 :inline :offset-assert 7088) (color80808080 vector4w :inline :offset-assert 7664) (color80808040 vector4w :inline :offset-assert 7680) (color80808000 vector4w :inline :offset-assert 7696) @@ -8865,8 +9312,8 @@ (xy2020 vector4w :inline :offset-assert 7920) (xy4040 vector4w :inline :offset-assert 7936) (xy8080 vector4w :inline :offset-assert 7952) - (cloud-alpha UNKNOWN 36 :offset-assert 7968) - (near-mask-indices UNKNOWN 16 :offset-assert 8004) + (cloud-alpha uint8 36 :offset-assert 7968) + (near-mask-indices uint16 16 :offset-assert 8004) (mid-minx uint8 :offset-assert 8036) (mid-maxx uint8 :offset-assert 8037) (mid-minz uint8 :offset-assert 8038) @@ -8889,7 +9336,7 @@ (frame-speed float :offset-assert 8084) (frame-num2 float :offset-assert 8088) (frame-speed2 float :offset-assert 8092) - (cloud-interp float :offset-assert 3676) + (cloud-interp float :offset 3676) (scales vector :inline :offset-assert 8096) (mask-hi vector4w :inline :offset-assert 8112) (mask-lo vector4w :inline :offset-assert 8128) @@ -8986,58 +9433,56 @@ (ocean-method-91 () none 91) ) ) -|# -;; (define-extern *ocean-map* object) ;; ocean-map -;; (define-extern *ocean* object) +(define-extern *ocean-map* ocean-map) +(define-extern *ocean* ocean) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ocean-trans-tables ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *ocean-left-table* object) ;; (pointer float) -;; (define-extern *ocean-right-table* object) ;; (pointer float) -;; (define-extern *ocean-up-table* object) ;; (pointer float) -;; (define-extern *ocean-down-table* object) ;; (pointer float) -;; (define-extern *ocean-down-left-table* object) ;; (pointer float) -;; (define-extern *ocean-down-right-table* object) ;; (pointer float) -;; (define-extern *ocean-up-right-table* object) ;; (pointer float) -;; (define-extern *ocean-up-left-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-left-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-right-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-up-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-down-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-down-left-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-down-right-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-up-right-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-up-left-table* object) ;; (pointer float) -;; (define-extern *ocean-trans-corner-table* object) ;; (inline-array vector4w-2) -;; (define-extern *ocean-trans-strip-array* object) ;; (pointer float) -;; (define-extern *ocean-trans-st-table* object) ;; (inline-array vector) +(define-extern *ocean-left-table* (pointer float)) +(define-extern *ocean-right-table* (pointer float)) +(define-extern *ocean-up-table* (pointer float)) +(define-extern *ocean-down-table* (pointer float)) +(define-extern *ocean-down-left-table* (pointer float)) +(define-extern *ocean-down-right-table* (pointer float)) +(define-extern *ocean-up-right-table* (pointer float)) +(define-extern *ocean-up-left-table* (pointer float)) +(define-extern *ocean-trans-left-table* (pointer float)) +(define-extern *ocean-trans-right-table* (pointer float)) +(define-extern *ocean-trans-up-table* (pointer float)) +(define-extern *ocean-trans-down-table* (pointer float)) +(define-extern *ocean-trans-down-left-table* (pointer float)) +(define-extern *ocean-trans-down-right-table* (pointer float)) +(define-extern *ocean-trans-up-right-table* (pointer float)) +(define-extern *ocean-trans-up-left-table* (pointer float)) +(define-extern *ocean-trans-corner-table* (inline-array vector4w-2)) +(define-extern *ocean-trans-strip-array* (pointer float)) +(define-extern *ocean-trans-st-table* (inline-array vector)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ocean-tables ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *ocean-spheres-city* object) -;; (define-extern *ocean-colors-city* object) -;; (define-extern *ocean-near-indices-city* ocean-near-indices) -;; (define-extern *ocean-trans-indices-city* ocean-trans-indices) -;; (define-extern *ocean-mid-indices-city* ocean-mid-indices) -;; (define-extern *ocean-mid-masks-city* ocean-mid-masks) -;; (define-extern *ocean-map-city* object) +(define-extern *ocean-spheres-city* ocean-spheres) +(define-extern *ocean-colors-city* ocean-colors) +(define-extern *ocean-near-indices-city* ocean-near-indices) +(define-extern *ocean-trans-indices-city* ocean-trans-indices) +(define-extern *ocean-mid-indices-city* ocean-mid-indices) +(define-extern *ocean-mid-masks-city* ocean-mid-masks) +(define-extern *ocean-map-city* ocean-map) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ocean-frames ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *ocean-wave-frames* object) ;; (pointer uint32) +(define-extern *ocean-wave-frames* (pointer uint32)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; time-of-day-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype palette-fade-control (structure) ((trans vector :inline :offset-assert 0) (fade float :offset-assert 16) @@ -9047,11 +9492,9 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype palette-fade-controls (basic) - ((control palette-fade-control 8 :offset-assert 16) ;; guessed by decompiler + ((control palette-fade-control 8 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x110 @@ -9061,41 +9504,31 @@ (palette-fade-controls-method-10 () none 10) ;; (set-fade! (_type_ int float float vector) object 10) ) ) -|# -#| +(declare-type sparticle-launch-control inline-array-class) (deftype time-of-day-proc (process) - ((hours int32 :offset-assert 124) - (minutes int32 :offset-assert 128) - (seconds int32 :offset-assert 132) - (old-frame uint64 :offset-assert 140) - (current-frame uint64 :offset-assert 148) - (frames uint64 :offset-assert 156) - (time-of-day float :offset-assert 164) - (time-ratio float :offset-assert 168) - (dest-time-ratio float :offset-assert 172) - (dest-time-delta float :offset-assert 176) - (sun-count int32 :offset-assert 180) - (sun sparticle-launch-control :offset-assert 184) ;; guessed by decompiler - (green-sun-count int32 :offset-assert 188) - (green-sun sparticle-launch-control :offset-assert 192) ;; guessed by decompiler - (moon-count int32 :offset-assert 196) - (moon sparticle-launch-control :offset-assert 200) ;; guessed by decompiler + ((hours int32 :offset-assert 128) + (minutes int32 :offset-assert 132) + (seconds int32 :offset-assert 136) + (old-frame uint64 :offset-assert 144) + (current-frame uint64 :offset-assert 152) + (frames uint64 :offset-assert 160) + (time-of-day float :offset-assert 168) + (time-ratio float :offset-assert 172) + (dest-time-ratio float :offset-assert 176) + (dest-time-delta float :offset-assert 180) + (sun-count int32 :offset-assert 184) + (sun sparticle-launch-control :offset-assert 188) ;; guessed by decompiler + (green-sun-count int32 :offset-assert 192) + (green-sun sparticle-launch-control :offset-assert 196) ;; guessed by decompiler + (moon-count int32 :offset-assert 200) + (moon sparticle-launch-control :offset-assert 204) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #xd0 :flag-assert #xe005000d0 - (:methods - (time-of-day-proc-method-9 () none 9) - (time-of-day-proc-method-10 () none 10) - (time-of-day-proc-method-11 () none 11) - (time-of-day-proc-method-12 () none 12) - (time-of-day-proc-method-13 () none 13) - ) ) -|# -#| (deftype time-of-day-palette (basic) ((width int32 :offset-assert 4) (height int32 :offset-assert 8) @@ -9106,9 +9539,8 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| + (deftype time-of-day-context (basic) ((interp float 6 :offset-assert 4) ;; guessed by decompiler (current-fog mood-fog :inline :offset-assert 32) @@ -9116,9 +9548,9 @@ (current-env-color vector :inline :offset-assert 96) (current-prt-color vector :inline :offset-assert 112) (current-shadow-color vector :inline :offset-assert 128) - (light-group light-group 8 :offset-assert 144) ;; guessed by decompiler + (light-group light-group 8 :inline :offset-assert 144) ;; guessed by decompiler (current-clouds mood-clouds :inline :offset-assert 1680) - (times UNKNOWN 8 :offset-assert 1696) + (times vector 8 :inline :offset-assert 1696) ;; might be vector4w? (title-light-group light-group :inline :offset-assert 1824) (filter vector :inline :offset-assert 2016) (filter-color vector :inline :offset-assert 2032) @@ -9140,9 +9572,8 @@ :size-assert #x834 :flag-assert #x900000834 ) -|# -#| + (deftype time-of-day-dma (structure) ((outa uint32 256 :offset-assert 0) ;; guessed by decompiler (outb uint32 256 :offset-assert 1024) ;; guessed by decompiler @@ -9153,16 +9584,14 @@ :size-assert #x1000 :flag-assert #x900001000 ) -|# -;; (define-extern *palette-fade-controls* object) ;; palette-fade-controls -;; (define-extern *time-of-day-context* time-of-day-context) ;; time-of-day-context +(define-extern *palette-fade-controls* palette-fade-controls) ;; palette-fade-controls +(define-extern *time-of-day-context* time-of-day-context) ;; time-of-day-context ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; art-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype joint-anim (basic) ((name string :offset-assert 4) ;; guessed by decompiler (number int16 :offset-assert 8) @@ -9172,24 +9601,20 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -;; (deftype joint-anim-matrix (joint-anim) -;; () -;; :flag-assert #x900000010 -;; ) +(deftype joint-anim-matrix (joint-anim) + ((data matrix :inline :dynamic :offset 16)) + :flag-assert #x900000010 + ) -#| (deftype joint-anim-transformq (joint-anim) - () + ((data transformq :inline :dynamic :offset 16) + ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 - ;; Failed to read fields. ) -|# -#| (deftype joint-anim-drawable (joint-anim) ((data drawable :dynamic :offset-assert 12) ;; guessed by decompiler ) @@ -9197,20 +9622,19 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype joint-anim-frame (structure) - ((matrices matrix 2 :offset-assert 0) ;; guessed by decompiler - (data matrix :dynamic :offset-assert 128) ;; guessed by decompiler + ((matrices matrix 2 :inline :offset-assert 0) ;; guessed by decompiler + (data matrix :dynamic :offset-assert 128) ;; guessed by decompiler ) + (:methods + (new (symbol type int) _type_ 0) + ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype joint-anim-compressed-hdr (structure) ((control-bits uint32 14 :offset-assert 0) ;; guessed by decompiler (num-joints uint32 :offset-assert 56) @@ -9220,38 +9644,32 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype joint-anim-compressed-fixed (structure) ((hdr joint-anim-compressed-hdr :inline :offset-assert 0) (offset-64 uint32 :offset-assert 64) (offset-32 uint32 :offset-assert 68) (offset-16 uint32 :offset-assert 72) (reserved uint32 :offset-assert 76) - (data vector 133 :offset-assert 80) ;; guessed by decompiler + (data vector 133 :inline :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8a0 :flag-assert #x9000008a0 ) -|# -#| (deftype joint-anim-compressed-frame (structure) ((offset-64 uint32 :offset-assert 0) (offset-32 uint32 :offset-assert 4) (offset-16 uint32 :offset-assert 8) (reserved uint32 :offset-assert 12) - (data vector 133 :offset-assert 16) ;; guessed by decompiler + (data vector 133 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x860 :flag-assert #x900000860 ) -|# -#| (deftype joint-anim-compressed-control (structure) ((num-frames uint16 :offset-assert 0) ;; uint32 (flags uint16 :offset-assert 2) @@ -9264,11 +9682,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype art (basic) - ((name string :offset-assert 8) ;; guessed by decompiler + ((name string :offset 8) ;; guessed by decompiler (length int32 :offset-assert 12) (extra res-lump :offset-assert 16) ;; guessed by decompiler ) @@ -9282,30 +9698,26 @@ (art-method-12 () none 12) ;; (needs-link? (_type_) symbol 12) ) ) -|# -#| + (deftype art-element (art) - () + ((pad uint8 12)) :method-count-assert 13 :size-assert #x20 :flag-assert #xd00000020 - (:methods - ) ) -|# -;; (deftype art-mesh-anim (art-element) -;; () -;; :flag-assert #xd00000020 -;; ) -#| +(deftype art-mesh-anim (art-element) + () + :flag-assert #xd00000020 + ) + (deftype art-joint-anim (art-element) - ((speed float :offset-assert 20) - (artist-base float :offset-assert 24) - (artist-step float :offset-assert 28) - (eye-anim basic :offset-assert 4) + ((speed float :offset 20) + (artist-base float :offset 24) + (artist-step float :offset 28) + (eye-anim basic :offset 4) (master-art-group-name string :offset-assert 32) ;; guessed by decompiler (master-art-group-index int32 :offset-assert 36) (blend-shape-anim basic :offset-assert 40) @@ -9318,11 +9730,11 @@ (:methods ) ) -|# -#| (deftype art-group (art) - () + ((info file-info :offset 4) + (data art-element :dynamic :offset 32) ;; might just be art? + ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 @@ -9332,19 +9744,17 @@ (art-group-method-14 () none 14) ;; (unlink-art! (_type_) int 14) ) ) -|# -;; (deftype art-mesh-geo (art-element) -;; () -;; :flag-assert #xd00000020 -;; ) +(deftype art-mesh-geo (art-element) + () + :flag-assert #xd00000020 + ) -;; (deftype art-joint-geo (art-element) -;; () -;; :flag-assert #xd00000020 -;; ) +(deftype art-joint-geo (art-element) + () + :flag-assert #xd00000020 + ) -#| (deftype art-joint-anim-manager-slot (structure) ((anim basic :offset-assert 0) (comp-data uint32 :offset-assert 4) @@ -9354,37 +9764,33 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + (deftype art-joint-anim-manager (basic) - () + ((kheap kheap :inline) + (free-index int32) + (slot art-joint-anim-manager-slot 64 :inline) + ) :method-count-assert 14 :size-assert #x430 :flag-assert #xe00000430 ;; Failed to read fields. (:methods + (new (symbol type int) _type_ 0) (art-joint-anim-manager-method-9 () none 9) (art-joint-anim-manager-method-10 () none 10) - (art-joint-anim-manager-method-11 () none 11) + (unload-from-slot (_type_ int) none 11) (art-joint-anim-manager-method-12 () none 12) - (art-joint-anim-manager-method-13 () none 13) + (unload-from-level (_type_ level) none 13) ) ) -|# -#| (deftype skeleton-group (art-group) - ((name basic :offset-assert 8) - (length int32 :offset-assert 12) - (extra basic :offset-assert 16) - (info basic :offset-assert 4) - (data UNKNOWN :dynamic :offset-assert 32) - (art-group-name string :offset-assert 32) ;; guessed by decompiler + ((art-group-name string :offset-assert 32) ;; guessed by decompiler (jgeo int32 :offset-assert 36) (janim int32 :offset-assert 40) (bounds vector :inline :offset-assert 48) - (radius meters :offset-assert 60) + (radius meters :offset 60) (mgeo int16 6 :offset-assert 64) ;; guessed by decompiler (max-lod int32 :offset-assert 76) (lod-dist float 6 :offset-assert 80) ;; guessed by decompiler @@ -9396,6 +9802,7 @@ (origin-joint-index int8 :offset-assert 112) (shadow-joint-index int8 :offset-assert 113) (light-index uint8 :offset-assert 114) + (pad uint8) ;; ? ) :method-count-assert 16 :size-assert #x74 @@ -9404,22 +9811,20 @@ (skeleton-group-method-15 () none 15) ) ) -|# -#| +(declare-type merc-ctrl art-element) (deftype lod-group (structure) ((geo merc-ctrl :offset-assert 0) ;; guessed by decompiler (dist meters :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype lod-set (structure) - ((lod lod-group 6 :offset-assert 0) ;; guessed by decompiler + ((lod lod-group 6 :inline :offset-assert 0) ;; guessed by decompiler (max-lod int8 :offset-assert 48) ) :method-count-assert 10 @@ -9429,18 +9834,95 @@ (lod-set-method-9 () none 9) ;; (setup-lods! (_type_ skeleton-group art-group entity) _type_ 9) ) ) -|# -#| +(defenum draw-control-status + :type uint16 + :bitfield #t + (close-to-screen 0) ;; 1 + (no-draw 1) ;; 2 + (no-draw-temp 2) ;; 4 + (on-screen 3) ;; 8 + (uninited 4) ;; 16 + (no-draw-bounds 5) ;; 32 + (no-closest-distance 6) ;; 64 + (math-skel 7) ;; 128 + (force-vu1 8) ;; 256 + (no-draw-bounds2 9) ;; 512 + (force-fade 10) ;; 1024 + (warp-cross-fade 11) ;; 2048 + (lod-set 12) ;; 4096 + (disable-fog 13) ;; 8192 + (hud 14) ;; 16384 + ) + +(defenum draw-control-data-format + :type uint8 + :bitfield #f + (pris 0) + (merc 1) + ) + +(defenum draw-control-global-effect + :type uint8 + :bitfield #t + (bit-0 0) + (bit-1 1) ;; 2 + (title-light 2) ;; 4 + (disable-envmap 3) ;; 8 + ) + +(declare-type ripple-control basic) +(declare-type shadow-control basic) + (deftype draw-control (basic) - () + ((process process :offset-assert 4) + (status draw-control-status) + (data-format draw-control-data-format) + (global-effect draw-control-global-effect) + (art-group art-group :offset-assert 12) + (jgeo art-joint-geo) + (mgeo merc-ctrl) + (dma-add-func function) ;; (function process-drawable draw-control symbol object none) + (skeleton skeleton) + (lod-set lod-set :inline) + (max-lod int8 :offset 80) + (force-lod int8) + (cur-lod int8) + (desired-lod int8) + (ripple ripple-control) + (longest-edge meters :offset-assert 88) + (longest-edge? uint32 :offset 88) + (light-index uint8) + (shadow-mask uint8) + (level-index uint8) + (death-draw-overlap uint8 :offset-assert 95) + (death-timer uint8) + (death-timer-org uint8) + (death-vertex-skip uint16) + (death-effect uint32) + (shadow uint32) + (shadow-ctrl shadow-control :offset-assert 108) + (distance meters) + (origin vector :inline) + (bounds vector :inline) + (radius meters :offset 156) + (color-mult rgbaf :inline) + (color-emissive rgbaf :inline) + (effect-mask uint64) + (seg-mask uint64) + (origin-joint-index uint8) + (shadow-joint-index uint8) + (force-fade uint8) + (default-texture-page uint8) + (shadow-values uint32) + ) :method-count-assert 15 :size-assert #xd8 :flag-assert #xf000000d8 ;; Failed to read fields. (:methods ;; (new (symbol type process art-joint-geo) _type_ 0) - (draw-control-method-9 () none 9) ;; (get-skeleton-origin (_type_) vector 9) + (get-skeleton-origin (_type_) vector 9) (draw-control-method-10 () none 10) ;; (lod-set! (_type_ int) none 10) (draw-control-method-11 () none 11) ;; (lods-assign! (_type_ lod-set) none 11) (draw-control-method-12 () none 12) @@ -9448,28 +9930,24 @@ (draw-control-method-14 () none 14) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-vu1-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype pris-mtx (structure) ((data float 32 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (t-mtx matrix :inline :offset-assert 0) - (n-mtx matrix3 :inline :offset-assert 64) - (scale vector :inline :offset-assert 112) + (vector vector 8 :offset 0) ;; guessed by decompiler + (t-mtx matrix :inline :offset 0) + (n-mtx matrix3 :inline :offset 64) + (scale vector :inline :offset 112) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-pris-mtx-save (structure) ((loc-mtx pris-mtx :inline :offset-assert 0) (par-mtx pris-mtx :inline :offset-assert 128) @@ -9479,12 +9957,10 @@ :size-assert #x180 :flag-assert #x900000180 ) -|# -#| (deftype generic-constants (structure) ((fog vector :inline :offset-assert 0) - (adgif qword :inline :offset-assert 16) ;; gs-gif-tag :inline + (adgif gs-gif-tag :inline :offset-assert 16) ;; was qword (hvdf-offset vector :inline :offset-assert 32) (hmge-scale vector :inline :offset-assert 48) (invh-scale vector :inline :offset-assert 64) @@ -9496,9 +9972,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-shrub-constants (structure) ((shrub-giftag generic-gif-tag :inline :offset-assert 0) (shrub-adnop qword :inline :offset-assert 16) @@ -9507,38 +9981,32 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype gcf-shader (structure) - ((adgif UNKNOWN 5 :offset-assert 0) - (shader adgif-shader :inline :offset-assert 0) - (pos uint32 :offset-assert 12) - (num uint32 :offset-assert 28) + ((adgif uint128 5 :offset-assert 0) ;; guess + (shader adgif-shader :inline :offset 0) + (pos uint32 :offset 12) + (num uint32 :offset 28) ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype gcf-control (structure) ((matrix matrix :inline :offset-assert 0) (giftag generic-gif-tag :inline :offset-assert 64) - (adnops UNKNOWN 2 :offset-assert 80) - (num-strips uint32 :offset-assert 76) - (num-dps uint32 :offset-assert 92) - (kick-offset uint32 :offset-assert 108) - (shader UNKNOWN :dynamic :offset-assert 112) + (adnops uint32 2 :offset-assert 80) ;; guess + (num-strips uint32 :offset 76) + (num-dps uint32 :offset 92) + (kick-offset uint32 :offset 108) + (shader gcf-shader :inline :dynamic :offset-assert 112) ;; guess ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype gcf-vertex (structure) ((tex vector4w :inline :offset-assert 0) (clr gs-packed-rgba :inline :offset-assert 16) @@ -9548,30 +10016,23 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; merc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype ripple-merc-query (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (start-vertex int32 :offset-assert 16) + ((start-vertex int32 :offset-assert 16) (vertex-skip int32 :offset-assert 20) (vertex-count int32 :offset-assert 24) (current-loc int32 :offset-assert 28) - (data vector :dynamic :offset-assert 32) ;; guessed by decompiler + (data vector :inline :dynamic :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype merc-byte-header (structure) ((srcdest-off uint8 :offset-assert 0) (rgba-off uint8 :offset-assert 1) @@ -9592,9 +10053,7 @@ :size-assert #x17 :flag-assert #x900000017 ) -|# -#| (deftype merc-fragment (structure) ((header merc-byte-header :inline :offset-assert 0) (rest uint8 1 :offset-assert 23) ;; guessed by decompiler @@ -9603,12 +10062,10 @@ :size-assert #x18 :flag-assert #xa00000018 (:methods - (merc-fragment-method-9 () none 9) ;; (login-adgifs (_type_) none 9) + (login-adgifs (_type_) none 9) ) ) -|# -#| (deftype merc-vtx (structure) ((mat-0 uint8 :offset-assert 0) (mat-1 uint8 :offset-assert 1) @@ -9627,9 +10084,7 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype merc-fp-header (structure) ((x-add float :offset-assert 0) (y-add float :offset-assert 4) @@ -9643,44 +10098,34 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-mat-dest (structure) ((matrix-number uint8 :offset-assert 0) (matrix-dest uint8 :offset-assert 1) ) + :pack-me :method-count-assert 9 :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype merc-fragment-control (structure) ((unsigned-four-count uint8 :offset-assert 0) (lump-four-count uint8 :offset-assert 1) (fp-qwc uint8 :offset-assert 2) (mat-xfer-count uint8 :offset-assert 3) - (mat-dest-data merc-mat-dest :dynamic :offset-assert 4) ;; guessed by decompiler + (mat-dest-data merc-mat-dest :inline :dynamic :offset-assert 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| -(deftype merc-blend-data (UNKNOWN) - ((int8-data int8 :dynamic :offset-assert 0) ;; guessed by decompiler +(deftype merc-blend-data (structure) ;; was unknown! + ((int8-data int8 :dynamic :offset-assert 0) ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 ) -|# -#| (deftype merc-blend-ctrl (structure) ((blend-vtx-count uint8 :offset-assert 0) (nonzero-index-count uint8 :offset-assert 1) @@ -9690,9 +10135,7 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| (deftype mei-envmap-tint (structure) ((fade0 float :offset-assert 0) (fade1 float :offset-assert 4) @@ -9703,9 +10146,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype mei-texture-scroll (structure) ((max-dist float :offset-assert 0) (st-int-scale uint8 :offset-assert 4) @@ -9719,9 +10160,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype mei-ripple (structure) ((x-base float :offset-assert 0) (z-base float :offset-assert 4) @@ -9732,9 +10171,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-extra-info (structure) ((envmap-tint-offset uint8 :offset-assert 0) (shader-offset uint8 :offset-assert 1) @@ -9746,9 +10183,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-effect (structure) ((frag-geo merc-fragment :offset-assert 0) (frag-ctrl merc-fragment-control :offset-assert 4) @@ -9768,68 +10203,59 @@ :size-assert #x20 :flag-assert #xa00000020 (:methods - (merc-effect-method-9 () none 9) ;; (login-adgifs (_type_) none 9) + (login-adgifs (_type_) none 9) ) ) -|# -#| (deftype merc-eye-ctrl (structure) ((eye-slot int8 :offset-assert 0) (shader-offset int8 :offset-assert 1) (shader-count int8 :offset-assert 2) - (shader adgif-shader 6 :offset-assert 16) ;; guessed by decompiler - (left-iris-shader adgif-shader :inline :offset-assert 16) - (left-pupil-shader adgif-shader :inline :offset-assert 96) - (left-lid-shader adgif-shader :inline :offset-assert 176) - (right-iris-shader adgif-shader :inline :offset-assert 256) - (right-pupil-shader adgif-shader :inline :offset-assert 336) - (right-lid-shader adgif-shader :inline :offset-assert 416) + (shader adgif-shader 6 :inline :offset-assert 16 :score -1) ;; guessed by decompiler + (left-iris-shader adgif-shader :inline :offset 16) + (left-pupil-shader adgif-shader :inline :offset 96) + (left-lid-shader adgif-shader :inline :offset 176) + (right-iris-shader adgif-shader :inline :offset 256) + (right-pupil-shader adgif-shader :inline :offset 336) + (right-lid-shader adgif-shader :inline :offset 416) ) :method-count-assert 9 :size-assert #x1f0 :flag-assert #x9000001f0 ) -|# -#| (deftype merc-eye-anim-frame (structure) ((pupil-trans-x int8 :offset-assert 0) (pupil-trans-y int8 :offset-assert 1) (blink int8 :offset-assert 2) - (iris-scale int8 :offset-assert 4) - (pupil-scale int8 :offset-assert 5) - (lid-scale int8 :offset-assert 6) - (dword uint64 :offset-assert 0) + (iris-scale int8 :offset 4) + (pupil-scale int8 :offset 5) + (lid-scale int8 :offset 6) + (dword uint64 :offset 0) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype merc-eye-anim-block (structure) ((max-frame int16 :offset-assert 0) - (data merc-eye-anim-frame :dynamic :offset-assert 8) ;; guessed by decompiler + (data merc-eye-anim-frame :inline :dynamic :offset-assert 8) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype texture-usage-group (structure) - ((data UNKNOWN 7 :offset-assert 0) + ((data texture-masks 7 :inline :offset-assert 0) ;; total guess here ) :method-count-assert 9 :size-assert #x150 :flag-assert #x900000150 ) -|# -#| (deftype merc-ctrl-header (structure) ((xyz-scale float :offset-assert 0) (st-magic uint32 :offset-assert 4) @@ -9858,40 +10284,38 @@ (num-verts uint16 :offset-assert 58) (longest-edge float :offset-assert 60) (eye-ctrl merc-eye-ctrl :offset-assert 64) - (pad UNKNOWN 3 :offset-assert 68) + (pad uint32 3 :offset-assert 68) (masks-padding texture-masks :inline :offset-assert 80) - (texture-usage-group texture-usage-group :offset-assert 80) - (dummy-bytes uint8 :dynamic :offset-assert 32) ;; guessed by decompiler - (envmap-tint uint32 :offset-assert 32) - (query basic :offset-assert 36) - (needs-clip uint8 :offset-assert 40) - (use-isometric uint8 :offset-assert 41) - (use-attached-shader uint8 :offset-assert 42) - (display-triangles uint8 :offset-assert 43) - (death-vertex-skip uint16 :offset-assert 44) - (death-start-vertex uint16 :offset-assert 46) - (death-effect uint32 :offset-assert 48) - (use-translucent uint8 :offset-assert 52) - (display-this-fragment uint8 :offset-assert 53) - (use-warp uint8 :offset-assert 54) - (ignore-alpha uint8 :offset-assert 55) - (force-fade uint8 :offset-assert 56) - (disable-fog uint8 :offset-assert 57) - (disable-envmap uint8 :offset-assert 58) + (texture-usage-group texture-usage-group :offset 80) + (dummy-bytes uint8 :dynamic :offset 32) ;; guessed by decompiler + (envmap-tint uint32 :offset 32) + (query basic :offset 36) + (needs-clip uint8 :offset 40) + (use-isometric uint8 :offset 41) + (use-attached-shader uint8 :offset 42) + (display-triangles uint8 :offset 43) + (death-vertex-skip uint16 :offset 44) + (death-start-vertex uint16 :offset 46) + (death-effect uint32 :offset 48) + (use-translucent uint8 :offset 52) + (display-this-fragment uint8 :offset 53) + (use-warp uint8 :offset 54) + (ignore-alpha uint8 :offset 55) + (force-fade uint8 :offset 56) + (disable-fog uint8 :offset 57) + (disable-envmap uint8 :offset 58) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ;; field xyz-scale is a float printed as hex? ) -|# -#| (deftype merc-ctrl (art-element) - ((num-joints int32 :offset-assert 20) - (seg-table basic :offset-assert 24) + ((num-joints int32 :offset 20) + (seg-table basic :offset 24) (header merc-ctrl-header :inline :offset-assert 32) - (effect merc-effect :dynamic :offset-assert 160) ;; guessed by decompiler + (effect merc-effect :inline :dynamic :offset-assert 160) ;; guessed by decompiler ) :method-count-assert 13 :size-assert #xa0 @@ -9899,12 +10323,10 @@ (:methods ) ) -|# -#| (deftype merc-vu1-low-mem (structure) - ((tri-strip-gif qword :inline :offset-assert 0) ;; gs-gif-tag :inline - (ad-gif qword :inline :offset-assert 16) ;; gs-gif-tag :inline + ((tri-strip-gif gs-gif-tag :inline :offset-assert 0) ;; was qword + (ad-gif gs-gif-tag :inline :offset-assert 16) ;; was qword (hvdf-offset vector :inline :offset-assert 32) (perspective uint128 4 :offset-assert 48) ;; guessed by decompiler (fog vector :inline :offset-assert 112) @@ -9913,24 +10335,20 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype emerc-vu1-low-mem (structure) - ((tri-strip-gif qword :inline :offset-assert 0) - (ad-gif qword :inline :offset-assert 16) - (hvdf-offset vector :inline :offset-assert 32) - (perspective UNKNOWN 4 :offset-assert 48) - (fog vector :inline :offset-assert 112) - (unperspect vector :inline :offset-assert 128) + ((tri-strip-gif qword :inline :offset-assert 0) + (ad-gif qword :inline :offset-assert 16) + (hvdf-offset vector :inline :offset-assert 32) + (perspective vector 4 :inline :offset-assert 48) + (fog vector :inline :offset-assert 112) + (unperspect vector :inline :offset-assert 128) ) :method-count-assert 9 :size-assert #x90 :flag-assert #x900000090 ) -|# -#| (deftype ripple-wave (structure) ((scale float :offset-assert 0) (offs float :offset-assert 4) @@ -9941,27 +10359,24 @@ (zmul float :offset-assert 20) (delta float :offset-assert 24) ) + :pack-me :method-count-assert 9 :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype ripple-wave-set (basic) ((count int32 :offset-assert 4) (converted basic :offset-assert 8) (normal-scale float :offset-assert 12) - (wave ripple-wave 4 :offset-assert 16) ;; guessed by decompiler + (wave ripple-wave 4 :inline :offset-assert 16) ;; guessed by decompiler (frame-save uint64 :offset-assert 128) ;; uint32 ) :method-count-assert 9 :size-assert #x88 :flag-assert #x900000088 ) -|# -#| (deftype ripple-control (basic) ((global-scale float :offset-assert 4) (last-frame-scale float :offset-assert 8) @@ -9973,52 +10388,39 @@ (send-query symbol :offset-assert 32) ;; guessed by decompiler (query ripple-merc-query :offset-assert 36) ;; guessed by decompiler ) + (:methods + (new (symbol type) _type_ 0) + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ) -|# -#| -(deftype merc-blend-data (UNKNOWN) - ((int8-data int8 :dynamic :offset-assert 0) ;; guessed by decompiler - ) - :method-count-assert 0 - :size-assert #x0 - :flag-assert #x0 - ) -|# - -;; (define-extern merc-fragment-fp-data function) ;; (function merc-fragment merc-fp-header) +(define-extern merc-fragment-fp-data (function merc-fragment merc-fp-header)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-merc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype merc-matrix (structure) ((quad uint128 8 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (tag uint64 :offset-assert 0) + (vector vector 8 :offset 0) ;; guessed by decompiler + (tag uint64 :offset 0) ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-merc-tag (dma-packet) - ((next-ptr uint32 :offset-assert 12) - (size uint32 :offset-assert 8) + ((next-ptr uint32 :offset 12) + (size uint32 :offset 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-merc-ctrl (structure) ((tag generic-merc-tag :inline :offset-assert 0) (lights vu-lights :inline :offset-assert 16) @@ -10029,9 +10431,7 @@ :size-assert #x120 :flag-assert #x900000120 ) -|# -#| (deftype generic-merc-ctrl-with-sfx (generic-merc-ctrl) ((sfx-data uint128 11 :offset-assert 288) ;; guessed by decompiler ) @@ -10039,14 +10439,12 @@ :size-assert #x1d0 :flag-assert #x9000001d0 ) -|# -#| (deftype generic-merc-input (structure) ((geo-tag generic-merc-tag :inline :offset-assert 0) (geo-block uint8 1296 :offset-assert 16) ;; guessed by decompiler - (byte-header merc-byte-header :inline :offset-assert 16) - (matrix merc-matrix 9 :offset-assert 1312) ;; guessed by decompiler + (byte-header merc-byte-header :inline :offset 16) + (matrix merc-matrix 9 :inline :offset-assert 1312) ;; guessed by decompiler (control generic-merc-ctrl-with-sfx :inline :offset-assert 2464) (end-tag generic-merc-tag :inline :offset-assert 2928) (shader adgif-shader :inline :offset-assert 2944) @@ -10055,24 +10453,20 @@ :size-assert #xbd0 :flag-assert #x900000bd0 ) -|# -#| (deftype generic-merc-output (structure) ((info gsf-info :inline :offset-assert 0) (header gsf-header :inline :offset-assert 16) (index-kick-table uint16 80 :offset-assert 32) ;; guessed by decompiler - (index-table uint8 160 :offset-assert 32) ;; guessed by decompiler + (index-table uint8 160 :offset 32) ;; guessed by decompiler (inverse-table uint8 256 :offset-assert 192) ;; guessed by decompiler - (vertex-table gsf-vertex 72 :offset-assert 448) ;; guessed by decompiler + (vertex-table gsf-vertex 72 :inline :offset-assert 448) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xac0 :flag-assert #x900000ac0 ) -|# -#| (deftype generic-merc-dcache (structure) ((output-a generic-merc-output :inline :offset-assert 0) (output-b generic-merc-output :inline :offset-assert 2752) @@ -10085,9 +10479,7 @@ :size-assert #x2000 :flag-assert #x900002000 ) -|# -#| (deftype gm-shadow (structure) ((perspective matrix :inline :offset-assert 0) (isometric matrix :inline :offset-assert 64) @@ -10121,9 +10513,7 @@ :size-assert #x190 :flag-assert #x900000190 ) -|# -#| (deftype generic-merc-work (structure) ((input-a generic-merc-input :inline :offset-assert 0) (input-b generic-merc-input :inline :offset-assert 3024) @@ -10135,17 +10525,15 @@ :size-assert #x1c00 :flag-assert #x900001c00 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-tie-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype generic-tie-instance (structure) ((matrix-tag dma-packet :inline :offset-assert 0) - (matrix-data vector 6 :offset-assert 16) ;; guessed by decompiler + (matrix-data vector 6 :inline :offset-assert 16) ;; guessed by decompiler (index-tag dma-packet :inline :offset-assert 112) (indices uint8 224 :offset-assert 128) ;; guessed by decompiler (end-tag dma-packet :inline :offset-assert 352) @@ -10154,16 +10542,14 @@ :size-assert #x170 :flag-assert #x900000170 ) -|# -#| (deftype generic-tie-input (structure) ((palette-tag dma-packet :inline :offset-assert 0) (palette rgba 128 :offset-assert 16) ;; guessed by decompiler (model-tag dma-packet :inline :offset-assert 528) - (model vector 146 :offset-assert 544) ;; guessed by decompiler + (model vector 146 :inline :offset-assert 544) ;; guessed by decompiler (matrix-tag dma-packet :inline :offset-assert 2880) - (matrix-data vector 6 :offset-assert 2896) ;; guessed by decompiler + (matrix-data vector 6 :inline :offset-assert 2896) ;; guessed by decompiler (index-tag dma-packet :inline :offset-assert 2992) (indices uint8 224 :offset-assert 3008) ;; guessed by decompiler (end-tag dma-packet :inline :offset-assert 3232) @@ -10172,9 +10558,7 @@ :size-assert #xcb0 :flag-assert #x900000cb0 ) -|# -#| (deftype generic-tie-run-control (structure) ((skip-bp2 uint8 :offset-assert 0) (skip-ips uint8 :offset-assert 1) @@ -10193,76 +10577,67 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype generic-tie-base-point (structure) ((data uint16 8 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) - (d0 int16 :offset-assert 6) - (vtx uint64 :offset-assert 0) - (u int16 :offset-assert 8) - (v int16 :offset-assert 10) - (tex uint32 :offset-assert 8) - (w int16 :offset-assert 12) - (d1 int16 :offset-assert 14) + (quad uint128 :offset 0) + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) + (d0 int16 :offset 6) + (vtx uint64 :offset 0) + (u int16 :offset 8) + (v int16 :offset 10) + (tex uint32 :offset 8) + (w int16 :offset 12) + (d1 int16 :offset 14) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-tie-bps (structure) - ((bp generic-tie-base-point 4 :offset-assert 0) ;; guessed by decompiler + ((bp generic-tie-base-point 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype generic-tie-interp-point (structure) ((data uint16 12 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (x int16 :offset-assert 0) - (y int16 :offset-assert 2) - (z int16 :offset-assert 4) - (d0 int16 :offset-assert 6) - (vtx0 uint64 :offset-assert 0) - (dx int16 :offset-assert 8) - (dy int16 :offset-assert 10) - (dz int16 :offset-assert 12) - (unused int16 :offset-assert 14) - (vtx1 uint64 :offset-assert 8) - (u int16 :offset-assert 16) - (v int16 :offset-assert 18) - (tex uint32 :offset-assert 16) - (w int16 :offset-assert 20) - (d1 int16 :offset-assert 22) + ;(quad uint128 :offset 0) ;; misaligned?? + (x int16 :offset 0) + (y int16 :offset 2) + (z int16 :offset 4) + (d0 int16 :offset 6) + (vtx0 uint64 :offset 0) + (dx int16 :offset 8) + (dy int16 :offset 10) + (dz int16 :offset 12) + (unused int16 :offset 14) + (vtx1 uint64 :offset 8) + (u int16 :offset 16) + (v int16 :offset 18) + (tex uint32 :offset 16) + (w int16 :offset 20) + (d1 int16 :offset 22) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype generic-tie-ips (structure) - ((ip generic-tie-interp-point 2 :offset-assert 0) ;; guessed by decompiler + ((ip generic-tie-interp-point 2 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype generic-tie-header (structure) ((effect uint8 :offset-assert 0) (interp-table-size uint8 :offset-assert 1) @@ -10279,9 +10654,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype generic-tie-matrix (structure) ((matrix matrix :inline :offset-assert 0) (morph vector :inline :offset-assert 64) @@ -10291,9 +10664,7 @@ :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype generic-tie-normal (structure) ((x int8 :offset-assert 0) (y int8 :offset-assert 1) @@ -10304,9 +10675,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype generic-tie-control (structure) ((ptr-palette uint32 :offset-assert 0) (ptr-shaders uint32 :offset-assert 4) @@ -10328,9 +10697,7 @@ :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype generic-tie-stats (structure) ((num-bps uint32 :offset-assert 0) (num-ips uint32 :offset-assert 4) @@ -10346,22 +10713,19 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype generic-tie-calls (structure) ((generic-prepare-dma-double basic :offset-assert 0) (generic-envmap-dproc basic :offset-assert 4) (generic-interp-dproc basic :offset-assert 8) (generic-no-light-dproc basic :offset-assert 12) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype generic-tie-shadow (structure) ((out-buf gsf-buffer :offset-assert 0) (cur-buf uint32 :offset-assert 4) @@ -10373,13 +10737,12 @@ (write-limit uint32 :offset-assert 28) (calls generic-tie-calls :inline :offset-assert 32) ) + :pack-me :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype generic-tie-work (structure) ((control generic-tie-control :inline :offset-assert 0) (interp-job generic-interp-job :inline :offset-assert 60) @@ -10393,26 +10756,22 @@ :size-assert #x1d50 :flag-assert #x900001d50 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-work-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype generic-input-buffer (structure) ((data uint128 473 :offset-assert 0) ;; guessed by decompiler - (merc generic-merc-work :inline :offset-assert 0) - (tie generic-tie-work :inline :offset-assert 0) + (merc generic-merc-work :inline :offset 0) + (tie generic-tie-work :inline :offset 0) ) :method-count-assert 9 :size-assert #x1d90 :flag-assert #x900001d90 ) -|# -#| (deftype generic-debug (structure) ((locks uint32 4 :offset-assert 0) ;; guessed by decompiler (timer uint32 32 :offset-assert 16) ;; guessed by decompiler @@ -10426,26 +10785,22 @@ :size-assert #x19c :flag-assert #x90000019c ) -|# -#| (deftype generic-vu1-header (structure) ((matrix matrix :inline :offset-assert 0) (strgif generic-gif-tag :inline :offset-assert 64) - (adcmds ad-cmd 2 :offset-assert 80) ;; guessed by decompiler - (adnop1 gs-adcmd :inline :offset-assert 80) ;; ad-cmd :inline - (adnop2 gs-adcmd :inline :offset-assert 96) ;; ad-cmd :inline - (dps uint16 :offset-assert 92) - (kickoff uint16 :offset-assert 108) - (strips uint16 :offset-assert 76) + (adcmds gs-adcmd 2 :inline :offset-assert 80) ;; guessed by decompiler + (adnop1 gs-adcmd :inline :offset 80) ;; ad-cmd :inline + (adnop2 gs-adcmd :inline :offset 96) ;; ad-cmd :inline + (dps uint16 :offset 92) + (kickoff uint16 :offset 108) + (strips uint16 :offset 76) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype generic-vu1-texbuf (structure) ((header generic-vu1-header :inline :offset-assert 0) (shader uint32 :dynamic :offset-assert 112) ;; guessed by decompiler @@ -10454,9 +10809,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype generic-texbuf (structure) ((tag dma-packet :inline :offset-assert 0) (header generic-vu1-header :inline :offset-assert 16) @@ -10466,9 +10819,7 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype generic-effect-work (structure) ((consts generic-consts :inline :offset-assert 0) (storage generic-storage :inline :offset-assert 432) @@ -10479,9 +10830,7 @@ :size-assert #x420 :flag-assert #x900000420 ) -|# -#| (deftype generic-effect-buffer (structure) ((outbuf-0 uint8 3552 :offset-assert 0) ;; guessed by decompiler (work generic-effect-work :inline :offset-assert 3552) @@ -10491,9 +10840,7 @@ :size-assert #x1fe0 :flag-assert #x900001fe0 ) -|# -#| (deftype generic-work (structure) ((saves generic-saves :inline :offset-assert 0) (storage generic-storage :inline :offset-assert 368) @@ -10504,20 +10851,29 @@ :size-assert #x3fe0 :flag-assert #x900003fe0 ) -|# -;; (define-extern *generic-debug* object) ;; generic-debug +(define-extern *generic-debug* generic-debug) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-cpu-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum shadow-flags + :bitfield #t + :type int32 + (shdf00) ;; unused + (disable-fade) + (shdf02) ;; only set, never used. + (shdf03) + (shdf04) ;; unused + (disable-draw) + ) + (deftype shadow-settings (structure) - ((center vector :inline :offset-assert 0) - (flags int32 :offset-assert 12) ;; shadow-flags + ((center vector :inline :offset-assert 0 :score -1) + (flags shadow-flags :offset 12) ;; shadow-flags (shadow-dir vector :inline :offset-assert 16) - (dist-to-locus float :offset-assert 28) + (dist-to-locus float :offset 28) (bot-plane plane :inline :offset-assert 32) (top-plane plane :inline :offset-assert 48) (fade-dist float :offset-assert 64) @@ -10529,9 +10885,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype shadow-control (basic) ((settings shadow-settings :inline :offset-assert 16) ) @@ -10539,21 +10893,19 @@ :size-assert #x60 :flag-assert #xf00000060 (:methods - ;; (new (symbol type float float float float float) _type_ 0) - (shadow-control-method-9 () none 9) ;; (clear-offset-bit (shadow-control) int 9) - (shadow-control-method-10 () none 10) ;; (set-offset-bit (shadow-control) int 10) - (shadow-control-method-11 () none 11) ;; (set-top-plane-offset (shadow-control float) int 11) - (shadow-control-method-12 () none 12) ;; (set-bottom-plane-offset (shadow-control float) int 12) + (new (symbol type float float float float float) _type_ 0) + (clear-offset-bit (shadow-control) int 9) + (set-offset-bit (shadow-control) int 10) + (set-top-plane-offset (shadow-control float) int 11) + (set-bottom-plane-offset (shadow-control float) int 12) (shadow-control-method-13 () none 13) ;; (unused-13 (_type_) none 13) (shadow-control-method-14 () none 14) ;; (update-direction-from-time-of-day (_type_) none 14) ) ) -|# -#| (deftype shadow-data (structure) ((dma-unpack-template dma-packet :inline :offset-assert 0) - (dma-cnt uint64 :offset-assert 16) ;; dma-tag + (dma-cnt dma-tag :offset-assert 16) ;; was u64 (vif-nop vif-tag :offset-assert 24) ;; guessed by decompiler (vif-unpack-v4-8 vif-tag :offset-assert 28) ;; guessed by decompiler (pdc basic :offset-assert 32) @@ -10565,9 +10917,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype shadow-work (structure) ((shadow-data shadow-data :inline :offset-assert 0) (inbuf uint128 600 :offset-assert 48) ;; guessed by decompiler @@ -10576,9 +10926,7 @@ :size-assert #x25b0 :flag-assert #x9000025b0 ) -|# -#| (deftype shadow-bucket (structure) ((first uint32 :offset-assert 0) (next uint32 :offset-assert 4) @@ -10586,25 +10934,22 @@ (shadow-color uint32 :offset-assert 12) (constants basic :offset-assert 16) ) + :allow-misaligned :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype shadow-globals (structure) ((num-buckets uint32 :offset-assert 0) (cur-bucket uint32 :offset-assert 4) - (bucket UNKNOWN 2 :offset-assert 8) + (bucket shadow-bucket 2 :inline :offset-assert 8) ) :method-count-assert 9 :size-assert #x48 :flag-assert #x900000048 ) -|# -#| (deftype shadow-vertex (structure) ((x float :offset-assert 0) (y float :offset-assert 4) @@ -10615,9 +10960,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype shadow-matrix-ref (structure) ((joint-0 uint8 :offset-assert 0) (joint-1 uint8 :offset-assert 1) @@ -10626,22 +10969,18 @@ :size-assert #x2 :flag-assert #x900000002 ) -|# -#| -(deftype shadow-edge (structure) - ((ind-0 uint16 :offset-assert 0) - (ind-1 uint16 :offset-assert 2) - (tri-0 uint16 :offset-assert 4) - (tri-1 uint16 :offset-assert 6) - ) - :method-count-assert 9 - :size-assert #x4 - :flag-assert #x900000004 - ) -|# +; (deftype shadow-edge (structure) +; ((ind-0 uint16 :offset-assert 0) +; (ind-1 uint16 :offset-assert 2) +; (tri-0 uint16 :offset-assert 4) +; (tri-1 uint16 :offset-assert 6) +; ) +; :method-count-assert 9 +; :size-assert #x4 +; :flag-assert #x900000004 +; ) -#| (deftype shadow-tri (structure) ((ind-0 uint8 :offset-assert 0) (ind-1 uint8 :offset-assert 1) @@ -10652,9 +10991,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype shadow-edge (structure) ((ind-0 uint8 :offset-assert 0) (ind-1 uint8 :offset-assert 1) @@ -10665,9 +11002,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype shadow-frag-header (structure) ((qwc-data uint32 :offset-assert 0) (num-joints uint32 :offset-assert 4) @@ -10688,25 +11023,22 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype shadow-frag-ref (structure) ((header shadow-frag-header :offset-assert 0) (qwc uint32 :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype shadow-geo-old (art-element) - ((version uint32 :offset-assert 20) + ((version uint32 :offset 20) (header shadow-frag-header :inline :offset-assert 32) - (total-qwc uint32 :offset-assert 32) - (rest UNKNOWN :dynamic :offset-assert 80) + (total-qwc uint32 :offset 32) + (rest uint64 :dynamic :offset-assert 80) ) :method-count-assert 13 :size-assert #x50 @@ -10714,15 +11046,13 @@ (:methods ) ) -|# -#| (deftype shadow-geo (art-element) - ((version uint32 :offset-assert 20) + ((version uint32 :offset 20) (total-qwc uint32 :offset-assert 32) (num-joints uint32 :offset-assert 36) (num-fragments uint32 :offset-assert 40) - (frags UNKNOWN :dynamic :offset-assert 44) + (frags shadow-frag-ref :inline :dynamic :offset-assert 44) ;; guess ) :method-count-assert 13 :size-assert #x2c @@ -10730,13 +11060,12 @@ (:methods ) ) -|# -;; (define-extern *shadow-globals* object) -;; (define-extern *shadow* object) ;; symbol -;; (define-extern *shadow-object* object) ;; symbol -;; (define-extern *shadow-debug* object) ;; symbol -;; (define-extern *shadow-dma-buf* object) +(define-extern *shadow-globals* shadow-globals) +(define-extern *shadow* object) ;; symbol +(define-extern *shadow-object* object) +(define-extern *shadow-debug* object) +(define-extern *shadow-dma-buf* dma-buffer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1-h ;; @@ -10747,38 +11076,36 @@ ;; memcard-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype mc-handle (int32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype mc-handle (int32) + () + :flag-assert #x900000004 + ) -#| (deftype mc-file-info (structure) ((present int32 :offset-assert 0) - (blind-data float 16 :offset-assert 4) ;; guessed by decompiler - (blind-data-int8 int8 64 :offset-assert 4) ;; guessed by decompiler - (level-index int32 :offset-assert 4) - (gem-count float :offset-assert 8) - (skill-count float :offset-assert 12) - (completion-percentage float :offset-assert 16) - (minute uint8 :offset-assert 24) - (hour uint8 :offset-assert 25) - (week uint8 :offset-assert 26) - (day uint8 :offset-assert 27) - (month uint8 :offset-assert 28) - (year uint8 :offset-assert 29) - (game-time0 uint32 :offset-assert 36) - (game-time1 uint32 :offset-assert 40) - (secrets uint32 :offset-assert 44) - (features uint32 :offset-assert 48) + (blind-data float 16 :offset 4) ;; guessed by decompiler + (blind-data-int8 int8 64 :offset 4) ;; guessed by decompiler + (level-index int32 :offset 4) + (gem-count float :offset 8) + (skill-count float :offset 12) + (completion-percentage float :offset 16) + (minute uint8 :offset 24) + (hour uint8 :offset 25) + (week uint8 :offset 26) + (day uint8 :offset 27) + (month uint8 :offset 28) + (year uint8 :offset 29) + (game-time0 uint32 :offset 36) + (game-time1 uint32 :offset 40) + (secrets uint32 :offset 44) + (features uint32 :offset 48) ) + :pack-me :method-count-assert 9 :size-assert #x44 :flag-assert #x900000044 ) -|# -#| (deftype mc-slot-info (structure) ((handle int32 :offset-assert 0) (known int32 :offset-assert 4) @@ -10787,16 +11114,20 @@ (last-file int32 :offset-assert 16) (mem-required int32 :offset-assert 20) (mem-actual int32 :offset-assert 24) - (file mc-file-info 4 :offset-assert 28) ;; guessed by decompiler + (file mc-file-info 4 :inline :offset-assert 28) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x12c :flag-assert #x90000012c ) -|# -;; (define-extern mc-sync function) ;; (function int) -;; (define-extern show-mc-info function) ;; (function dma-buffer none) +(define-extern mc-sync (function int)) +(define-extern show-mc-info (function dma-buffer none)) + +(define-extern mc-run (function none)) +(define-extern mc-check-result (function int)) +(define-extern mc-get-slot-info (function int mc-slot-info none)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-info-h ;; @@ -10842,26 +11173,33 @@ (force-vis? symbol :offset-assert 8) ;; guessed by decompiler (force-inside? symbol :offset-assert 12) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -#| + (deftype load-state (basic) - () + ((want level-buffer-state 6 :inline) + (want-sound symbol 3) + (vis-nick symbol :offset-assert 112) + (command-list pair) + (object-name string 256) + (object-status basic 256) + ) :method-count-assert 22 :size-assert #x878 :flag-assert #x1600000878 ;; Failed to read fields. (:methods - ;; (new (symbol type) _type_ 0) - (load-state-method-9 () none 9) ;; (reset! (_type_) _type_ 9) - (load-state-method-10 () none 10) ;; (update! (_type_) int 10) - (load-state-method-11 () none 11) ;; (want-levels (_type_ symbol symbol) int 11) + (new (symbol type) _type_ 0) + (reset! (_type_) _type_ 9) + (update! (_type_) int 10) + (want-levels (_type_ (pointer symbol)) int 11) (load-state-method-12 () none 12) ;; (want-display-level (_type_ symbol symbol) int 12) - (load-state-method-13 () none 13) ;; (want-vis (_type_ symbol) int 13) - (load-state-method-14 () none 14) ;; (want-force-vis (_type_ symbol symbol) int 14) + (want-display-level (_type_ symbol symbol) int 13) + (want-vis-level (_type_ symbol) none 14) ;; (want-force-vis (_type_ symbol symbol) int 14) (load-state-method-15 () none 15) ;; (execute-command (_type_ pair) none 15) (load-state-method-16 () none 16) ;; (execute-commands-up-to (_type_ float) int 16) (load-state-method-17 () none 17) ;; (backup-load-state-and-set-cmds (_type_ pair) int 17) @@ -10871,11 +11209,57 @@ (load-state-method-21 () none 21) ) ) -|# -#| + +(defenum continue-flags + :type uint32 + :bitfield #t + (cf0 0) + (cf1 1) + (cf2 2) + (cf3 3) + (cf4 4) + (cf5 5) + (cf6 6) + (cf7 7) + (cf8 8) + (cf9 9) + (cf10 10) + (cf11 11) + (cf12 12) + (cf13 13) + (cf14 14) + (cf15 15) + (cf16 16) + (cf17 17) + (cf18 18) + (cf19 19) + (cf20 20) + (cf21 21) + (cf22 22) + (cf23 23) + (cf24 24) + (cf25 25) + (cf26 26) + (cf27 27) + (cf28 28) + (cf29 29) + (cf30 30) + ) + (deftype continue-point (basic) - () + ((name string) ;; ? + (level symbol) ;; ? + (flags continue-flags) + (trans vector :inline) + (quat vector :inline) + (camera-trans vector :inline) + (camera-rot float 9) + (on-goto pair) + (vis-nick symbol) + (want level-buffer-state 6 :inline) + (want-sound symbol 3) + ) :method-count-assert 12 :size-assert #xd8 :flag-assert #xc000000d8 @@ -10886,9 +11270,33 @@ (continue-point-method-11 () none 11) ) ) -|# -#| +(defenum mc-status-code + :type uint32 + ; (busy 0) + ; (ok 1) + ; (bad-handle 2) + ; (format-failed 3) + ; (internal-error 4) + ; (write-error 5) + ; (read-error 6) + ; (new-game 7) + ; (no-memory 8) + ; (no-card 9) + ; (no-last 10) + ; (no-format 11) + ; (no-file 12) + ; (no-save 13) + ; (no-space 14) + ; (bad-version 15) + ; (no-process 16) + ; (no-auto-save 17) + ) + +(declare-type entity-perm-array inline-array-class) +(declare-type continue-point basic) +(declare-type game-save basic) + (deftype game-info (basic) ((mode symbol :offset-assert 4) ;; guessed by decompiler (save-name basic :offset-assert 8) @@ -10910,9 +11318,11 @@ (features uint64 :offset-assert 128) (debug-features uint64 :offset-assert 136) (secrets uint32 :offset-assert 144) + (unknown-pad1 uint32) (purchase-secrets uint32 :offset-assert 152) + (unknown-pad2 uint32) (gun-type int32 :offset-assert 160) - (gun-ammo UNKNOWN 4 :offset-assert 164) + (gun-ammo uint32 4 :offset-assert 164) ;; ?? (shield float :offset-assert 180) (score float :offset-assert 184) (score-owner uint64 :offset-assert 192) @@ -10926,7 +11336,9 @@ (task-perm-list entity-perm-array :offset-assert 236) ;; guessed by decompiler (current-continue continue-point :offset-assert 240) ;; guessed by decompiler (last-continue basic :offset-assert 244) + (unknown-pad3 uint32 3) (task-counter uint32 :offset-assert 260) + (unknown-pad4 uint32) (level-opened uint8 32 :offset-assert 268) ;; guessed by decompiler (total-deaths int32 :offset-assert 300) (continue-deaths int32 :offset-assert 304) @@ -10937,7 +11349,10 @@ (death-time time-frame :offset-assert 336) ;; time-frame (hit-time time-frame :offset-assert 344) ;; time-frame (task-pickup-time time-frame :offset-assert 352) - (death-pos vector-array :offset-assert 372) ;; guessed by decompiler + (unknown-array1 (array uint64)) + (unknown-array2 (array uint64)) + (unknown-array3 (array uint64)) + (death-pos vector-array :offset 372) ;; guessed by decompiler ?? (stop-watch-start uint64 :offset-assert 376) (stop-watch-stop uint64 :offset-assert 384) (blackout-time time-frame :offset-assert 392) ;; time-frame @@ -10947,20 +11362,20 @@ (display-text-handle uint64 :offset-assert 424) ;; handle (death-movie-tick int32 :offset-assert 432) (want-auto-save symbol :offset-assert 436) ;; guessed by decompiler - (auto-save-proc uint64 :offset-assert 440) ;; handle + (auto-save-proc handle :offset-assert 440) ;; handle (auto-save-status mc-status-code :offset-assert 448) ;; guessed by decompiler (auto-save-card int32 :offset-assert 452) (auto-save-which int32 :offset-assert 456) (auto-save-count int32 :offset-assert 460) (pov-camera-handle uint64 :offset-assert 464) ;; handle (other-camera-handle uint64 :offset-assert 472) ;; handle - (controller UNKNOWN 2 :offset-assert 480) + (controller uint64 2 :offset-assert 480) ;; ?? (race-timer uint64 :offset-assert 496) (race-current-lap-count int32 :offset-assert 504) (race-total-lap-count int32 :offset-assert 508) (race-position int32 :offset-assert 512) (race-number-turbos int32 :offset-assert 516) - (bot-health UNKNOWN 3 :offset-assert 520) + (bot-health uint32 3 :offset-assert 520) ;; ?? (demo-state uint32 :offset-assert 532) (wanted-flash basic :offset-assert 536) (distance float :offset-assert 540) @@ -10970,6 +11385,7 @@ (goal float :offset-assert 564) (miss float :offset-assert 568) (miss-max float :offset-assert 572) + (unknown-array4 (array uint64)) ;; ?? (live-eco-pill-count int32 :offset-assert 580) (live-gem-count int32 :offset-assert 584) (air-supply float :offset-assert 588) @@ -10981,42 +11397,122 @@ :size-assert #x25c :flag-assert #x1f0000025c (:methods - (game-info-method-9 () none 9) ;; (initialize! (_type_ symbol game-save string) _type_ 9) + (initialize! (_type_ symbol game-save string) _type_ 9) (game-info-method-10 () none 10) ;; (adjust (_type_ symbol float handle) float 10) (game-info-method-11 () none 11) ;; (task-complete? (_type_ game-task) symbol 11) (game-info-method-12 () none 12) ;; (lookup-entity-perm-by-aid (_type_ actor-id) entity-perm 12) (game-info-method-13 () none 13) ;; (get-entity-task-perm (_type_ game-task) entity-perm 13) - (game-info-method-14 () none 14) ;; (copy-perms-from-level! (_type_ level) none 14) - (game-info-method-15 () none 15) ;; (copy-perms-to-level! (_type_ level) none 15) - (game-info-method-16 () none 16) ;; (debug-print (_type_ symbol) _type_ 16) - (game-info-method-17 () none 17) ;; (get-or-create-continue! (_type_) continue-point 17) + (game-info-method-14 () none 14) ;; 14) + (game-info-method-15 () none 15) + (copy-perms-from-level! (_type_ level) none 16) ;; (debug-print (_type_ symbol) _type_ 16) + (copy-perms-to-level! (_type_ level) none 17) ;; (get-or-create-continue! (_type_) continue-point 17) (game-info-method-18 () none 18) ;; (get-continue-by-name (_type_ string) continue-point 18) (game-info-method-19 () none 19) ;; (set-continue! (_type_ basic) continue-point 19) (game-info-method-20 () none 20) ;; (buzzer-count (_type_ game-task) int 20) - (game-info-method-21 () none 21) ;; (seen-text? (_type_ game-text-id) symbol 21) + (set-continue! (_type_ basic) continue-point 21) ;; (seen-text? (_type_ game-text-id) symbol 21) (game-info-method-22 () none 22) ;; (mark-text-as-seen (_type_ game-text-id) none 22) (game-info-method-23 () none 23) ;; (got-buzzer? (_type_ game-task int) symbol 23) (game-info-method-24 () none 24) ;; (save-game! (_type_ game-save string) none 24) (game-info-method-25 () none 25) ;; (load-game! (_type_ game-save) game-save 25) (game-info-method-26 () none 26) ;; (clear-text-seen! (_type_ game-text-id) none 26) - (game-info-method-27 () none 27) ;; (get-death-count (_type_ symbol) int 27) + (get-next-attack-id (_type_) uint 27) ;; (get-death-count (_type_ symbol) int 27) (game-info-method-28 () none 28) ;; (get-health-percent-lost (_type_ symbol) float 28) (game-info-method-29 () none 29) (game-info-method-30 () none 30) ) ) -|# -;; (define-extern *GAME-bank* game-bank) ;; game-bank -;; (define-extern *game-info* object) ;; game-info + +(define-extern *GAME-bank* game-bank) +(define-extern *game-info* game-info) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gui-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + +(defenum gui-action + :type uint8 + :bitfield #f + (none 0) + (queue 1) + (play 2) + (playing 3) + (stop 4) + (stopping 5) + (abort 6) + (hide 7) + (hidden 8) + (fade 9) + ) + +(defenum gui-channel + :type uint8 + :bitfield #f + (none 0) + (art-load 16) + (art-load-next 17) + (background 18) + (jak 19) + (daxter 20) + (sig 21) + (ashelin 22) + (mog 23) + (jinx 24) + (grim 25) + (kid 26) + (kor 27) + (hal 28) + (voicebox 29) + (guard 30) + (crocadog 31) + (alert 32) + (citizen 33) + (bbush 34) + (krew 35) + (voice 47) + (movie 64) + (blackout 65) + (query 66) + (message 67) + (notice 68) + (subtitle 69) + (supertitle 70) + (notice-low 71) + (screen 79) + (hud-upper-right 80) + (hud-upper-left 81) + (hud-lower-right 82) + (hud-lower-left 83) + (hud-lower-left-1 84) + (hud-lower-left-2 85) + (hud-center-right 86) + (hud-center-left 87) + (hud-middle-right 88) + (hud-middle-left 89) + (hud-upper-center 90) + (hud-upper-center-2 91) + (hud 95) + (max 96) + ) + (deftype gui-connection (connection) - () + ((priority float :offset 16 :score 1) + (action gui-action :offset 20) + (channel gui-channel :offset 21) + (anim-part uint8 :offset 22) + (flags uint8 :offset 23) + (name object :offset 24) + (id uint32 :offset 28) + (handle handle :offset 0) + (time-stamp time-frame :offset 8) + (hold-time time-frame :offset-assert 32) + (fo-min int16) + (fo-max int16) + (fo-curve int8) + (fade uint8) + (pad uint8 2) + ) :method-count-assert 14 :size-assert #x30 :flag-assert #xe00000030 @@ -11024,11 +11520,13 @@ (:methods ) ) -|# -#| + + (deftype gui-control (basic) - () + ((engine engine) + (data uint8 3272) + ) :method-count-assert 25 :size-assert #xcd0 :flag-assert #x1900000cd0 @@ -11038,7 +11536,7 @@ (gui-control-method-10 () none 10) (gui-control-method-11 () none 11) (gui-control-method-12 () none 12) - (gui-control-method-13 () none 13) + (update (_type_ symbol) none 13) (gui-control-method-14 () none 14) (gui-control-method-15 () none 15) (gui-control-method-16 () none 16) @@ -11052,16 +11550,13 @@ (gui-control-method-24 () none 24) ) ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ambient-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype talker-speech-class (structure) - ((name basic :offset-assert 0) + ((name string :offset-assert 0) (channel uint8 :offset-assert 4) (flags uint8 :offset-assert 5) (speech uint16 :offset-assert 6) @@ -11072,6 +11567,7 @@ (neg uint16 :offset-assert 18) (on-close basic :offset-assert 20) ) + :pack-me :method-count-assert 14 :size-assert #x18 :flag-assert #xe00000018 @@ -11084,72 +11580,92 @@ (talker-speech-class-method-13 () none 13) ) ) -|# -#| (deftype talker (process) - ((trans vector :inline :offset-assert 124) - (message talker-speech-class :offset-assert 140) - (total-time time-frame :offset-assert 148) - (total-off-time time-frame :offset-assert 156) - (start-time time-frame :offset-assert 164) - (state-time time-frame :offset-assert 172) - (voicebox uint64 :offset-assert 180) - (voice-id uint32 :offset-assert 188) - (message-id uint32 :offset-assert 192) - (region region :offset-assert 196) - (interp float :offset-assert 200) - (save? basic :offset-assert 204) + ((trans vector :inline :offset-assert 128) + (message talker-speech-class :offset-assert 144) + (total-time time-frame :offset-assert 152) + (total-off-time time-frame :offset-assert 160) + (start-time time-frame :offset-assert 168) + (state-time time-frame :offset-assert 176) + (voicebox uint64 :offset-assert 184) + (voice-id uint32 :offset-assert 192) + (message-id uint32 :offset-assert 196) + (region region :offset-assert 200) + (interp float :offset-assert 204) + (save? basic :offset-assert 208) ) :method-count-assert 18 :size-assert #xd4 :flag-assert #x12006000d4 (:methods - (talker-method-9 () none 9) - (talker-method-10 () none 10) - (talker-method-11 () none 11) - (talker-method-12 () none 12) - (talker-method-13 () none 13) (talker-method-14 () none 14) (talker-method-15 () none 15) (talker-method-16 () none 16) (talker-method-17 () none 17) ) ) -|# -;; (define-extern *talker-speech* object) +(define-extern *talker-speech* talker-speech-class) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; speech-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum speech-type-flag + :type uint8 + :bitfield #t + (random-order 0) + ) + (deftype speech-type-info (structure) - () + ((channel uint8) + (flags speech-type-flag) + (priority int8) + (request-timeout uint16) + (min-delay uint16) + (max-delay uint16) + (delay uint16) + (play-index int16) + (list basic) + ) :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ;; Failed to read fields. ) -|# -#| (deftype speech-request (structure) ((handle uint64 :offset-assert 0) (time time-frame :offset-assert 8) (priority float :offset-assert 16) (speech-type int8 :offset-assert 20) ) + :pack-me :method-count-assert 9 :size-assert #x15 :flag-assert #x900000015 ) -|# -#| +(defenum speech-channel-flag + :type uint8 + :bitfield #t + (disable 0) + ) + (deftype speech-channel (structure) - () + ((flags speech-channel-flag) + (gui-channel gui-channel) + (delay uint16) + (id uint32) + (update-time time-frame :offset-assert 8) + (start-time time-frame) + (end-time time-frame) + (request speech-request :inline) + (last-request speech-request :inline) + (target-pos vector :inline) + (speech-table uint32) + ) :method-count-assert 14 :size-assert #x64 :flag-assert #xe00000064 @@ -11162,12 +11678,11 @@ (speech-channel-method-13 () none 13) ) ) -|# -#| + (deftype speech-control (structure) - ((channel-array UNKNOWN 2 :offset-assert 0) - (speech-table UNKNOWN 57 :offset-assert 224) + ((channel-array speech-channel 2 :inline :offset-assert 0) + (speech-table uint32 57 :offset-assert 224) ;; guess ) :method-count-assert 17 :size-assert #x1c4 @@ -11183,31 +11698,28 @@ (speech-control-method-16 () none 16) ) ) -|# + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; wind-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype wind-vector (structure) ((wind-pos vector4w :inline :offset-assert 0) ;; vector2w :inline (wind-vel vector4w :inline :offset-assert 16) ;; vector2w :inline - (stiffness float :offset-assert 28) + (stiffness float :offset 28) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype wind-work (basic) - ((wind-array vector 64 :offset-assert 16) ;; guessed by decompiler + ((wind-array vector 64 :inline :offset-assert 16) ;; guessed by decompiler (wind-normal vector :inline :offset-assert 1040) (wind-temp vector :inline :offset-assert 1056) - (wind-force float 64 :offset-assert 1072) ;; guessed by decompiler + (wind-force float 64 :offset-assert 1072) ;; guessed by decompiler (wind-const vector :inline :offset-assert 1328) (wind-time uint32 :offset-assert 1344) (wait-to-vu0 uint32 :offset-assert 1348) @@ -11223,33 +11735,29 @@ (last-mem uint32 :offset-assert 1388) (next-spr uint32 :offset-assert 1392) (last-spr uint32 :offset-assert 1396) - (to-ptrs UNKNOWN 3 :offset-assert 1400) + (to-ptrs uint32 3 :offset-assert 1400) ) :method-count-assert 9 :size-assert #x584 :flag-assert #x900000584 ) -|# -#| (deftype wind-dma (structure) - ((buffer0 UNKNOWN 128 :offset-assert 0) - (buffer1 UNKNOWN 128 :offset-assert 4096) - (buffer2 UNKNOWN 128 :offset-assert 8192) + ((buffer0 wind-vector 128 :inline :offset-assert 0) + (buffer1 wind-vector 128 :inline :offset-assert 4096) + (buffer2 wind-vector 128 :inline :offset-assert 8192) ) :method-count-assert 9 :size-assert #x3000 :flag-assert #x900003000 ) -|# -;; (define-extern *wind-scales* array) ;; (array uint8) +(define-extern *wind-scales* (array uint8)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; prototype-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype prototype-bucket (basic) ((name string :offset-assert 4) ;; guessed by decompiler (flags uint16 :offset-assert 8) ;; uint32 @@ -11259,41 +11767,38 @@ (geometry drawable 4 :offset-assert 16) ;; guessed by decompiler (dists vector :inline :offset-assert 32) (rdists vector :inline :offset-assert 48) - (near-plane meters :offset-assert 32) - (near-stiff meters :offset-assert 36) - (mid-plane meters :offset-assert 40) - (far-plane meters :offset-assert 44) - (rlength-near float :offset-assert 48) - (rlength-stiff float :offset-assert 52) - (rlength-mid float :offset-assert 56) - (stiffness float :offset-assert 60) + (near-plane meters :offset 32) + (near-stiff meters :offset 36) + (mid-plane meters :offset 40) + (far-plane meters :offset 44) + (rlength-near float :offset 48) + (rlength-stiff float :offset 52) + (rlength-mid float :offset 56) + (stiffness float :offset 60) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype prototype-bucket-shrub (prototype-bucket) ((next uint32 4 :offset-assert 64) ;; guessed by decompiler (count uint16 4 :offset-assert 80) ;; guessed by decompiler (mod-count uint16 4 :offset-assert 88) ;; guessed by decompiler (last dma-packet 4 :offset-assert 96) ;; guessed by decompiler - (next-clear uint128 :offset-assert 64) - (count-clear uint64 :offset-assert 80) - (last-clear uint128 :offset-assert 96) + (next-clear uint128 :offset 64) + (count-clear uint64 :offset 80) + (last-clear uint128 :offset 96) ) :method-count-assert 9 :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype prototype-inline-array-shrub (drawable) - ((length int16 :offset-assert 6) - (data prototype-bucket-shrub 1 :offset-assert 36) ;; guessed by decompiler + ((length int16 :offset 6) + (data prototype-bucket-shrub 1 :inline :offset 32) ;; guessed by decompiler + (_pad uint32) ) :method-count-assert 17 :size-assert #x94 @@ -11301,9 +11806,7 @@ (:methods ) ) -|# -#| (deftype prototype-array-shrub-info (basic) ((prototype-inline-array-shrub prototype-inline-array-shrub :offset-assert 4) ;; guessed by decompiler (wind-vectors uint32 :offset-assert 8) @@ -11313,9 +11816,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(declare-type prototype-tie drawable) + (deftype prototype-bucket-tie (prototype-bucket) ((next uint32 12 :offset-assert 64) ;; guessed by decompiler (count uint16 12 :offset-assert 112) ;; guessed by decompiler @@ -11332,94 +11835,89 @@ (tie-colors time-of-day-palette :offset-assert 180) ;; guessed by decompiler (data uint32 :dynamic :offset-assert 184) ;; guessed by decompiler (color-index-qwc uint32 :dynamic :offset-assert 184) ;; guessed by decompiler - (scissor-frag-count uint8 :offset-assert 136) - (near-frag-count uint8 :offset-assert 137) - (mid-frag-count uint8 :offset-assert 138) - (far-frag-count uint8 :offset-assert 139) - (scissor-index-start uint8 :offset-assert 140) - (near-index-start uint8 :offset-assert 141) - (mid-index-start uint8 :offset-assert 142) - (far-index-start uint8 :offset-assert 143) - (scissor-base-qw uint16 :offset-assert 144) - (near-base-qw uint16 :offset-assert 146) - (mid-base-qw uint16 :offset-assert 148) - (far-base-qw uint16 :offset-assert 150) - (tie-next UNKNOWN 4 :offset-assert 64) - (tie-scissor-next uint32 :offset-assert 64) - (tie-near-next uint32 :offset-assert 68) - (tie-mid-next uint32 :offset-assert 72) - (tie-far-next uint32 :offset-assert 76) - (trans-next UNKNOWN 4 :offset-assert 64) - (trans-scissor-next UNKNOWN 4 :offset-assert 64) - (trans-near-next uint32 :offset-assert 68) - (trans-mid-next uint32 :offset-assert 72) - (trans-far-next uint32 :offset-assert 76) - (water-next UNKNOWN 4 :offset-assert 64) - (water-scissor-next UNKNOWN 4 :offset-assert 64) - (water-near-next uint32 :offset-assert 68) - (water-mid-next uint32 :offset-assert 72) - (water-far-next uint32 :offset-assert 76) - (envmap-next UNKNOWN 4 :offset-assert 80) - (envmap-scissor-next UNKNOWN 4 :offset-assert 80) - (envmap-near-next uint32 :offset-assert 84) - (envmap-mid-next uint32 :offset-assert 88) - (envmap-far-next uint32 :offset-assert 92) - (generic-next uint32 3 :offset-assert 96) ;; guessed by decompiler - (generic-near-next uint32 :offset-assert 96) - (generic-mid-next uint32 :offset-assert 100) - (generic-far-next uint32 :offset-assert 104) - (vanish-next uint32 :offset-assert 108) - (tie-count UNKNOWN 4 :offset-assert 112) - (tie-scissor-count uint16 :offset-assert 112) - (tie-near-count uint16 :offset-assert 114) - (tie-mid-count uint16 :offset-assert 116) - (tie-far-count uint16 :offset-assert 118) - (trans-count UNKNOWN 4 :offset-assert 112) - (trans-scissor-count uint16 :offset-assert 112) - (trans-near-count uint16 :offset-assert 114) - (trans-mid-count uint16 :offset-assert 116) - (trans-far-count uint16 :offset-assert 118) - (water-count UNKNOWN 4 :offset-assert 112) - (water-scissor-count uint16 :offset-assert 112) - (water-near-count uint16 :offset-assert 114) - (water-mid-count uint16 :offset-assert 116) - (water-far-count uint16 :offset-assert 118) - (envmap-count UNKNOWN 4 :offset-assert 120) - (envmap-scissor-count uint16 :offset-assert 120) - (envmap-near-count uint16 :offset-assert 122) - (envmap-mid-count uint16 :offset-assert 124) - (envmap-far-count uint16 :offset-assert 126) - (generic-count uint16 3 :offset-assert 128) ;; guessed by decompiler - (generic-near-count uint16 :offset-assert 128) - (generic-mid-count uint16 :offset-assert 130) - (generic-far-count uint16 :offset-assert 132) - (vanish-count uint16 :offset-assert 134) - (next-clear uint128 3 :offset-assert 64) ;; guessed by decompiler - (count-clear uint64 3 :offset-assert 112) ;; guessed by decompiler + (scissor-frag-count uint8 :offset 136) + (near-frag-count uint8 :offset 137) + (mid-frag-count uint8 :offset 138) + (far-frag-count uint8 :offset 139) + (scissor-index-start uint8 :offset 140) + (near-index-start uint8 :offset 141) + (mid-index-start uint8 :offset 142) + (far-index-start uint8 :offset 143) + (scissor-base-qw uint16 :offset 144) + (near-base-qw uint16 :offset 146) + (mid-base-qw uint16 :offset 148) + (far-base-qw uint16 :offset 150) + (tie-next uint32 4 :offset 64) + (tie-scissor-next uint32 :offset 64) + (tie-near-next uint32 :offset 68) + (tie-mid-next uint32 :offset 72) + (tie-far-next uint32 :offset 76) + (trans-next uint32 4 :offset 64) + (trans-scissor-next uint32 4 :offset 64) + (trans-near-next uint32 :offset 68) + (trans-mid-next uint32 :offset 72) + (trans-far-next uint32 :offset 76) + (water-next uint32 4 :offset 64) + (water-scissor-next uint32 4 :offset 64) + (water-near-next uint32 :offset 68) + (water-mid-next uint32 :offset 72) + (water-far-next uint32 :offset 76) + (envmap-next uint32 4 :offset 80) + (envmap-scissor-next uint32 4 :offset 80) + (envmap-near-next uint32 :offset 84) + (envmap-mid-next uint32 :offset 88) + (envmap-far-next uint32 :offset 92) + (generic-next uint32 3 :offset 96) ;; guessed by decompiler + (generic-near-next uint32 :offset 96) + (generic-mid-next uint32 :offset 100) + (generic-far-next uint32 :offset 104) + (vanish-next uint32 :offset 108) + (tie-count uint16 4 :offset 112) + (tie-scissor-count uint16 :offset 112) + (tie-near-count uint16 :offset 114) + (tie-mid-count uint16 :offset 116) + (tie-far-count uint16 :offset 118) + (trans-count uint16 4 :offset 112) + (trans-scissor-count uint16 :offset 112) + (trans-near-count uint16 :offset 114) + (trans-mid-count uint16 :offset 116) + (trans-far-count uint16 :offset 118) + (water-count uint16 4 :offset 112) + (water-scissor-count uint16 :offset 112) + (water-near-count uint16 :offset 114) + (water-mid-count uint16 :offset 116) + (water-far-count uint16 :offset 118) + (envmap-count uint16 4 :offset 120) + (envmap-scissor-count uint16 :offset 120) + (envmap-near-count uint16 :offset 122) + (envmap-mid-count uint16 :offset 124) + (envmap-far-count uint16 :offset 126) + (generic-count uint16 3 :offset 128) ;; guessed by decompiler + (generic-near-count uint16 :offset 128) + (generic-mid-count uint16 :offset 130) + (generic-far-count uint16 :offset 132) + (vanish-count uint16 :offset 134) + (next-clear uint128 3 :offset 64) ;; guessed by decompiler + (count-clear uint64 3 :offset 112) ;; guessed by decompiler + ;; added + (tie-geom prototype-tie 4 :offset 16 :score 1) ) :method-count-assert 9 :size-assert #xb8 :flag-assert #x9000000b8 ) -|# -#| (deftype prototype-array-tie (array) - ((type type :offset-assert 0) ;; guessed by decompiler - (length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (content-type type :offset-assert 12) ;; guessed by decompiler + ((array-data prototype-bucket-tie :dynamic :offset 16) ;; NOTE - field added, not 100% positive on the type ) :method-count-assert 10 :size-assert #x10 :flag-assert #xa00000010 (:methods - (prototype-array-tie-method-9 () none 9) ;; (login (_type_) none 9) + (login (_type_) none 9) ) ) -|# -#| (deftype proxy-prototype-array-tie (basic) ((prototype-array-tie prototype-array-tie :offset-assert 4) ;; guessed by decompiler (wind-vectors uint32 :offset-assert 8) @@ -11430,14 +11928,12 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype instance (drawable) - ((bucket-index uint16 :offset-assert 6) + ((bucket-index uint16 :offset 6) (origin matrix4h :inline :offset-assert 32) - (flags uint16 :offset-assert 46) - (wind-index uint16 :offset-assert 62) + (flags uint16 :offset 46) + (wind-index uint16 :offset 62) ) :method-count-assert 17 :size-assert #x40 @@ -11445,27 +11941,49 @@ (:methods ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; joint-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum joint-control-command + :type int64 + (push 1) + (blend 2) + (eight 8) + (push1 19) + (stack 36) + (float 42) + (stack1 52) + ) + +(declare-type joint-control basic) (deftype joint-control-channel (structure) - () + ((parent joint-control :offset-assert 0) + (frame-group art-joint-anim :offset-assert 4) + (frame-num float :offset-assert 8) + (dist meters :offset-assert 12) + (num-func (function joint-control-channel float float float)) + (param float 3) + (frame-interp float 2) + (inspector-amount uint8) + (command joint-control-command) + (group-sub-index int8 :offset-assert 56) + (grou-size int8) + (eval-time uint32) + ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ;; Failed to read fields. ) -|# -#| + + (deftype top-anim-joint-control (basic) ((process uint32 :offset-assert 4) - (interp-select UNKNOWN 2 :offset-assert 8) + (interp-select uint64 2 :offset-assert 8) (base-anim basic :offset-assert 24) (base-anim-speed float :offset-assert 28) (base-anim-blend float :offset-assert 32) @@ -11494,11 +12012,40 @@ (top-anim-joint-control-method-12 () none 12) ) ) -|# -#| + +(defenum joint-control-status + :type uint16 + :bitfield #t + + (sync-math 0) ;; 1 + (spooling 1) ;; 2 + (spooling-not-last-block 2) ;; 4 + (blend-shape 3) ;; 8 + (math-when-off-screen 4) ;; 16 + (valid-spooled-frame 5) ;; 32 + (blend-shape-valid 6) ;; 64 + (eye-anim-valid 7) ;; 128 + (eye-anim 8) ;; 256 + ) + (deftype joint-control (basic) - () + ((status joint-control-status) + (allocated-length uint8) + (active-channels uint8) + (root-channel uint32 :offset 16) + (blend-index uint8) + (active-frame-interp uint8) + (float-channels uint8) + (generate-frame-function function) + (prebind-function function) + (postbind-function function) + (effect basic) + (interp-select int64 2) + (top-anim basic) + (override basic) + (channel joint-control-channel :inline :dynamic) + ) :method-count-assert 12 :size-assert #x40 :flag-assert #xc00000040 @@ -11510,20 +12057,16 @@ (joint-control-method-11 () none 11) ) ) -|# -#| (deftype matrix-stack (structure) ((top matrix :offset-assert 0) - (data matrix 24 :offset-assert 16) ;; guessed by decompiler + (data matrix 24 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x610 :flag-assert #x900000610 ) -|# -#| (deftype channel-upload-info (structure) ((fixed joint-anim-compressed-fixed :offset-assert 0) (fixed-qwc int32 :offset-assert 4) @@ -11532,67 +12075,62 @@ (amount float :offset-assert 16) (interp float :offset-assert 20) ) + :pack-me :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype joint-work (structure) ((temp-mtx matrix :inline :offset-assert 0) (joint-stack matrix-stack :inline :offset-assert 64) (fix-jmp-table (function none) 16 :offset-assert 1616) ;; guessed by decompiler (frm-jmp-table (function none) 16 :offset-assert 1680) ;; guessed by decompiler (pair-jmp-table (function none) 16 :offset-assert 1744) ;; guessed by decompiler - (uploads channel-upload-info 24 :offset-assert 1808) ;; guessed by decompiler + (uploads channel-upload-info 24 :inline :offset-assert 1808) ;; guessed by decompiler (num-uploads int32 :offset-assert 2384) - (mtx-acc matrix 2 :offset-assert 2400) ;; guessed by decompiler - (tq-acc transformq 100 :offset-assert 2528) ;; guessed by decompiler + (mtx-acc matrix 2 :inline :offset-assert 2400) ;; guessed by decompiler + (tq-acc transformq 100 :inline :offset-assert 2528) ;; guessed by decompiler (jacp-hdr joint-anim-compressed-hdr :inline :offset-assert 7328) (fixed-data joint-anim-compressed-fixed :inline :offset-assert 7392) - (frame-data joint-anim-compressed-frame 2 :offset-assert 9600) ;; guessed by decompiler - (flatten-array float 576 :offset-assert 2400) ;; guessed by decompiler - (flattened vector 24 :offset-assert 2400) ;; guessed by decompiler + (frame-data joint-anim-compressed-frame 2 :inline :offset-assert 9600) ;; guessed by decompiler + (flatten-array float 576 :offset 2400) ;; guessed by decompiler + (flattened vector 24 :offset 2400) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x3640 :flag-assert #x900003640 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bones-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + (deftype bone-buffer (structure) - ((joint joint-anim-compressed-hdr 16 :offset-assert 0) ;; guessed by decompiler - (bone bone 16 :offset-assert 1024) ;; guessed by decompiler - (output UNKNOWN 16 :offset-assert 2304) + ((joint joint-anim-compressed-hdr 16 :inline :offset-assert 0) ;; guessed by decompiler + (bone bone 16 :inline :offset-assert 1024) ;; guessed by decompiler + ;; (output UNKNOWN 16 :offset-assert 2304) + (_pad uint8 #x800) ) :method-count-assert 9 :size-assert #x1100 :flag-assert #x900001100 ) -|# -#| (deftype bone-layout (structure) ((data uint16 8 :offset-assert 0) ;; guessed by decompiler - (joint joint 2 :offset-assert 0) ;; guessed by decompiler - (bone bone 2 :offset-assert 8) ;; guessed by decompiler - (output uint32 2 :offset-assert 16) ;; guessed by decompiler - (unused UNKNOWN 2 :offset-assert 24) + (joint joint 2 :offset 0) ;; guessed by decompiler + (bone bone 2 :offset 8) ;; guessed by decompiler + (output uint32 2 :offset 16) ;; guessed by decompiler + (unused uint32 2 :offset 24) ;; was "cache" in jak 1, but they removed this. ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype bone-regs (structure) ((dma-buf basic :offset-assert 0) (wait-count uint32 :offset-assert 4) @@ -11608,9 +12146,7 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype bone-work (structure) ((layout bone-layout :inline :offset-assert 0) (regs bone-regs :inline :offset-assert 32) @@ -11619,9 +12155,7 @@ :size-assert #x44 :flag-assert #x900000044 ) -|# -#| (deftype bone-debug (structure) ((time-ctr uint32 :offset-assert 0) (timing uint32 360 :offset-assert 4) ;; guessed by decompiler @@ -11630,22 +12164,40 @@ :size-assert #x5a4 :flag-assert #x9000005a4 ) -|# -#| (deftype bone-memory (structure) ((work bone-work :inline :offset-assert 0) - (buffer bone-buffer 2 :offset-assert 80) ;; guessed by decompiler + (buffer bone-buffer 2 :inline :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2250 :flag-assert #x900002250 ) -|# -#| +(defenum bone-calc-flags + :type uint16 + :bitfield #t + (bncfl00 0) + (bncfl01 1) ;; use identity matrix in bone matrix calc instead of cam rot (effectively screen-space bones?) + (bncfl02 2) + (bncfl03 3) + (bncfl04 4) + (bncfl05 5) + (bncfl06 6) + (bncfl07 7) + (bncfl08 8) + (bncfl09 9) + (bncfl10 10) + (bncfl11 11) + (bncfl12 12) + (bncfl13 13) + (bncfl14 14) + (bncfl15 15) + ) + + (deftype bone-calculation (structure) - ((flags uint16 :offset-assert 0) ;; bone-calc-flags + ((flags bone-calc-flags :offset-assert 0) ;; bone-calc-flags (num-bones uint16 :offset-assert 2) (matrix-area (inline-array matrix) :offset-assert 4) ;; guessed by decompiler (joints (inline-array joint) :offset-assert 8) ;; guessed by decompiler @@ -11663,39 +12215,35 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; foreground-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype mercneric-chain (structure) ((first uint32 :offset-assert 0) (next uint32 :offset-assert 4) (state generic-bucket-state :inline :offset-assert 8) (vu1-bucket int32 :offset-assert 16) ) + :pack-me :method-count-assert 9 :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype merc-chain (structure) ((first dma-packet :offset-assert 0) (patch dma-packet :offset-assert 4) (vu1-bucket int32 :offset-assert 8) ) + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype foreground-bucket (structure) ((merc merc-chain :inline :offset-assert 0) (emerc merc-chain :inline :offset-assert 12) @@ -11705,30 +12253,25 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype foreground-level-buckets (structure) - ((data UNKNOWN 7 :offset-assert 0) + ((data foreground-bucket 7 :inline :offset-assert 0) ) :method-count-assert 9 :size-assert #x150 :flag-assert #x900000150 ) -|# -#| + (deftype foreground-bucket-grid (structure) - ((level-buckets UNKNOWN 7 :offset-assert 0) + ((level-buckets foreground-level-buckets 7 :inline :offset-assert 0) (warp-chain mercneric-chain :inline :offset-assert 2352) ) :method-count-assert 9 :size-assert #x944 :flag-assert #x900000944 ) -|# -#| (deftype foreground-regs (structure) ((dist float :offset-assert 0) (merc-used uint32 :offset-assert 4) @@ -11749,12 +12292,10 @@ :size-assert #x38 :flag-assert #x900000038 ) -|# -#| (deftype foreground-work (structure) ((regs foreground-regs :inline :offset-assert 0) - (draw-index-map UNKNOWN 7 :offset-assert 64) + (draw-index-map uint16 7 :offset 64) ;; ???? (grid foreground-bucket-grid :inline :offset-assert 80) (bounds sphere :inline :offset-assert 2464) (lights vu-lights :inline :offset-assert 2480) @@ -11765,9 +12306,7 @@ :size-assert #xa40 :flag-assert #x900000a40 ) -|# -#| (deftype texscroll-globals (structure) ((requests int32 :offset-assert 0) (effects merc-effect 32 :offset-assert 4) ;; guessed by decompiler @@ -11776,9 +12315,7 @@ :size-assert #x84 :flag-assert #x900000084 ) -|# -#| (deftype merc-effect-bucket-info (structure) ((color-fade rgba :offset-assert 0) ;; guessed by decompiler (merc-path uint8 :offset-assert 4) @@ -11786,27 +12323,24 @@ (disable-draw uint8 :offset-assert 6) (disable-envmap uint8 :offset-assert 7) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype merc-bucket-info (structure) ((light vu-lights :inline :offset-assert 0) (needs-clip int32 :offset-assert 112) (need-mercprime-if-merc int32 :offset-assert 116) (must-use-mercneric-for-clip int32 :offset-assert 120) - (effect merc-effect-bucket-info 64 :offset-assert 124) ;; guessed by decompiler + (effect merc-effect-bucket-info 64 :inline :offset-assert 124) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x27c :flag-assert #x90000027c ) -|# -#| (deftype foreground-globals (structure) ((foreground-grid foreground-bucket-grid :inline :offset-assert 0) (merc-bucket-info merc-bucket-info :inline :offset-assert 2384) @@ -11816,9 +12350,7 @@ :size-assert #xc54 :flag-assert #x900000c54 ) -|# -#| (deftype shadow-dma-packet (structure) ((tag generic-merc-tag :inline :offset-assert 0) (settings shadow-settings :inline :offset-assert 16) @@ -11830,33 +12362,41 @@ :size-assert #x90 :flag-assert #x900000090 ) -|# -;; (define-extern invalidate-cache-line function) ;; (function pointer int) -;; (define-extern *foreground* object) +(define-extern invalidate-cache-line (function pointer int)) +(define-extern *foreground* foreground-globals) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; engines ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *background-draw-engine* object) ;; engine -;; (define-extern *matrix-engine* object) ;; (array handle) -;; (define-extern *part-engine* object) -;; (define-extern *camera-engine* object) ;; engine -;; (define-extern *debug-engine* object) ;; engine -;; (define-extern *pad-engine* object) -;; (define-extern *lightning-engine* object) -;; (define-extern *hud-engine* object) -;; (define-extern *task-manager-engine* object) +(define-extern *background-draw-engine* engine) +(define-extern *matrix-engine* (array handle)) +(define-extern *part-engine* engine) +(define-extern *camera-engine* engine) ;; engine +(define-extern *debug-engine* engine) ;; engine +(define-extern *pad-engine* engine) +(define-extern *lightning-engine* engine) +(define-extern *hud-engine* engine) +(define-extern *task-manager-engine* engine) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lightning-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum lightning-spec-flags + :type uint16 + :bitfield #t + (lsf0 0) + (lsf1 1) + (lsf2 2) + (lsf3 3) + (size-from-adjust-dist 4) + ) + (deftype lightning-spec (basic) - ((name basic :offset-assert 4) - (flags uint16 :offset-assert 8) + ((name string :offset-assert 4) + (flags lightning-spec-flags :offset-assert 8) (rand-func uint8 :offset-assert 10) (adjust-distance uint8 :offset-assert 11) (start-color uint32 :offset-assert 12) @@ -11881,18 +12421,24 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| +(defenum lightning-mode + :type uint8 + (lm0 0) + (lm1 1) + (lm2 2) + (lm3 3) + ) + (deftype lightning-state (structure) - ((mode uint8 :offset-assert 0) + ((mode lightning-mode :offset-assert 0) (counter float :offset-assert 4) (points-to-draw int32 :offset-assert 8) (box-size float :offset-assert 12) (gcf-control gcf-control :inline :offset-assert 16) - (line basic :offset-assert 128) - (meet basic :offset-assert 132) - (path basic :offset-assert 136) + (line vector-array :offset-assert 128) + (meet vector-array :offset-assert 132) + (path vector-array :offset-assert 136) (start-color uint32 :offset-assert 140) (end-color uint32 :offset-assert 144) ) @@ -11900,45 +12446,41 @@ :size-assert #x94 :flag-assert #x900000094 ) -|# -#| (deftype lightning-control (basic) - ((spec basic :offset-assert 4) - (process uint32 :offset-assert 8) + ((spec lightning-spec :offset-assert 4) + (process process :offset-assert 8) (state lightning-state :inline :offset-assert 16) ) :method-count-assert 14 :size-assert #xa4 :flag-assert #xe000000a4 (:methods - (lightning-control-method-9 () none 9) - (lightning-control-method-10 () none 10) - (lightning-control-method-11 () none 11) - (lightning-control-method-12 () none 12) - (lightning-control-method-13 () none 13) + (new (symbol type lightning-spec process float) _type_) + (change-mode (_type_ lightning-mode) lightning-mode 9) + (get-mode (_type_) lightning-mode 10) + (set-point (_type_ int vector) none 11) + (set-first-meet-point (_type_ vector) none 12) + (set-last-meet-point (_type_ vector) none 13) ) ) -|# -#| (deftype lightning-probe-vars (basic) ((src-joint-index uint32 :offset-assert 4) (next-spawn-time time-frame :offset-assert 8) (last-valid-time time-frame :offset-assert 16) - (point UNKNOWN 2 :offset-assert 32) - (start-pos vector :inline :offset-assert 32) - (end-pos vector :inline :offset-assert 48) - (probe-dirs uint32 :offset-assert 64) + (point vector 2 :inline :offset-assert 32) + (start-pos vector :inline :offset 32) + (end-pos vector :inline :offset 48) + (probe-dirs (inline-array vector) :offset-assert 64) ) :method-count-assert 9 :size-assert #x44 :flag-assert #x900000044 ) -|# -;; (define-extern lookup-lightning-spec-by-name function) -;; (define-extern *lightning-probe-vars* lightning-probe-vars) +(define-extern lookup-lightning-spec-by-name (function string lightning-spec)) +(define-extern *lightning-probe-vars* lightning-probe-vars) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; res-h ;; @@ -11958,6 +12500,22 @@ (declare-type entity-links structure) + + + +(define-extern *res-key-string* string) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; res ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(deftype res-tag-pair (uint64) + ((lo int32 :offset 0) + (hi int32 :offset 32) + ) + ;; made-up type + ) + (deftype res-lump (basic) ((length int32 :offset-assert 4) (allocated-length int32 :offset-assert 8) @@ -11972,84 +12530,53 @@ :flag-assert #x1600000020 ;; field extra uses ~A with a signed load (:methods - ;; (new (symbol type int int) _type_ 0) - (res-lump-method-9 () none 9) ;; (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer 9) - (res-lump-method-10 () none 10) ;; (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure 10) - (res-lump-method-11 () none 11) ;; (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 11) - (res-lump-method-12 () none 12) ;; (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float 12) - (res-lump-method-13 () none 13) ;; (get-tag-index-data (_type_ int) pointer 13) - (res-lump-method-14 () none 14) ;; (get-tag-data (_type_ res-tag) pointer 14) - (res-lump-method-15 () none 15) ;; (allocate-data-memory-for-tag! (_type_ res-tag) res-tag 15) - (res-lump-method-16 () none 16) ;; (sort! (_type_) _type_ 16) - (res-lump-method-17 () none 17) ;; (add-data! (_type_ res-tag pointer) res-lump 17) - (res-lump-method-18 () none 18) ;; (add-32bit-data! (_type_ res-tag object) res-lump 18) - (res-lump-method-19 () none 19) ;; (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair 19) - (res-lump-method-20 () none 20) ;; (make-property-data (_type_ float res-tag-pair pointer) pointer 20) - (res-lump-method-21 () none 21) ;; (get-curve-data! (_type_ curve symbol symbol float) symbol 21) + (new (symbol type int int) _type_ 0) + (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer :no-virtual 9) + (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure :no-virtual 10) + (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 :no-virtual 11) + (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float :no-virtual 12) + (get-tag-index-data (_type_ int) pointer 13) + (get-tag-data (_type_ res-tag) pointer 14) + (allocate-data-memory-for-tag! (_type_ res-tag) res-tag 15) + (sort! (_type_) _type_ 16) + (add-data! (_type_ res-tag pointer) res-lump 17) + (add-32bit-data! (_type_ res-tag object) res-lump 18) + (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair :no-virtual 19) + (make-property-data (_type_ float res-tag-pair pointer) pointer 20) + (get-curve-data! (_type_ curve symbol symbol float) symbol 21) ) ) - -;; (define-extern *res-key-string* object) ;; string - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; res ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -#| -(deftype res-lump (basic) - () - :method-count-assert 22 - :size-assert #x20 - :flag-assert #x1600000020 - ;; Failed to read fields. - (:methods - ;; (new (symbol type int int) _type_ 0) - (res-lump-method-9 () none 9) ;; (get-property-data (_type_ symbol symbol float pointer (pointer res-tag) pointer) pointer 9) - (res-lump-method-10 () none 10) ;; (get-property-struct (_type_ symbol symbol float structure (pointer res-tag) pointer) structure 10) - (res-lump-method-11 () none 11) ;; (get-property-value (_type_ symbol symbol float uint128 (pointer res-tag) pointer) uint128 11) - (res-lump-method-12 () none 12) ;; (get-property-value-float (_type_ symbol symbol float float (pointer res-tag) pointer) float 12) - (res-lump-method-13 () none 13) ;; (get-tag-index-data (_type_ int) pointer 13) - (res-lump-method-14 () none 14) ;; (get-tag-data (_type_ res-tag) pointer 14) - (res-lump-method-15 () none 15) ;; (allocate-data-memory-for-tag! (_type_ res-tag) res-tag 15) - (res-lump-method-16 () none 16) ;; (sort! (_type_) _type_ 16) - (res-lump-method-17 () none 17) ;; (add-data! (_type_ res-tag pointer) res-lump 17) - (res-lump-method-18 () none 18) ;; (add-32bit-data! (_type_ res-tag object) res-lump 18) - (res-lump-method-19 () none 19) ;; (lookup-tag-idx (_type_ symbol symbol float) res-tag-pair 19) - (res-lump-method-20 () none 20) ;; (make-property-data (_type_ float res-tag-pair pointer) pointer 20) - (res-lump-method-21 () none 21) ;; (get-curve-data! (_type_ curve symbol symbol float) symbol 21) - ) - ) -|# - -;; (define-extern *res-static-buf* object) ;; pointer +(define-extern *res-static-buf* pointer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lights ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *light-hash-work* object) -;; (define-extern light-slerp function) ;; (function light light light float light) -;; (define-extern light-group-slerp function) ;; (function light-group light-group light-group float light-group) -;; (define-extern light-group-process! function) ;; (function vu-lights light-group vector vector none) -;; (define-extern *default-lights* object) ;; vu-lights -;; (define-extern vu-lights-default! function) ;; (function vu-lights vu-lights) -;; (define-extern init-light-hash function) -;; (define-extern light-hash-count-items function) +;; TODO skipped +;; some asm stuff, maybe needs mips2c. + +(define-extern *light-hash-work* light-hash-work) +(define-extern light-slerp (function light light light float light)) +(define-extern light-group-slerp (function light-group light-group light-group float light-group)) +(define-extern light-group-process! (function vu-lights light-group vector vector none)) +(define-extern *default-lights* vu-lights) +(define-extern vu-lights-default! (function vu-lights vu-lights)) +(define-extern init-light-hash (function none)) +(define-extern light-hash-count-items (function light-hash none)) ;; (define-extern light-hash-add-items function) -;; (define-extern reset-light-hash function) -;; (define-extern update-light-hash function) -;; (define-extern lookup-light-sphere-by-name function) -;; (define-extern light-hash-get-bucket-index function) +(define-extern reset-light-hash (function none)) +(define-extern update-light-hash (function light-hash none)) +(define-extern lookup-light-sphere-by-name (function string light-hash light-sphere)) +(define-extern light-hash-get-bucket-index (function light-hash vector int)) ;; (define-extern add-light-sphere-to-light-group function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dynamics-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dynamics (basic) - ((name basic :offset-assert 4) + ((name symbol :offset-assert 4) (gravity-max meters :offset-assert 8) (gravity-length meters :offset-assert 12) (gravity vector :inline :offset-assert 16) @@ -12061,87 +12588,248 @@ :size-assert #x38 :flag-assert #xa00000038 (:methods - (dynamics-method-9 () none 9) + (set-gravity-length (_type_ float) none 9) ) ) -|# -;; (define-extern time-to-apex function) ;; (function float float int) -;; (define-extern time-to-ground function) ;; (function float float float int) -;; (define-extern *standard-dynamics* dynamics) ;; dynamics +(define-extern time-to-apex (function float float int)) +(define-extern time-to-ground (function float float float int)) +(define-extern *standard-dynamics* dynamics) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; surface-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum surface-flag + :bitfield #t + :type uint32 + + (look-around 0) ;; 1 + (xz-local 1) ;; 2 + (smooth-collision 2) ;; 4 + (no-turn-around 3) ;; 8 + (turn-to-pad 4) ;; 16 + (turn-to-vel 5) ;; 32 + (no-jump 6) ;; 64 + (no-attack 7) ;; 128 + (no-hands 8) ;; 256 + (no-feet 9) ;; 512 + (check-edge 10) ;; 1024 + (air 11) ;; 2048 + (attack 12) ;; 4096 + (duck 13) ;; 8192 + (momentum 14) ;; 16384 + (turn-when-centered 15) ;; 32768 + + (turn-to-alt 16) ;; hi 1 + (spin 17) ;; hi 2 + (super 18) ;; hi 4 + (gun-inactive 19) ;; hi 8 + (gun-hide 20) ;; hi 16 + (gun-off 21) ;; hi 32 + (gun-fast-exit 22) ;; hi 64 + (gun-direct 23) ;; hi 128 + (gun-strafe 24) ;; hi 256 + (gun-no-twist 25) ;; hi 512 + (laser-hide 26) ;; hi 1024 + (no-board 27) ;; hi 2048 + (gun-turn-fast 28) ;; hi 4096 + ) + (deftype surface (basic) - () + ((name symbol) + ;(data float 30 :score -1) + (turnv float :offset-assert 8) + (turnvv float :offset-assert 12) + (tiltv float :offset-assert 16) + (tiltvv float :offset-assert 20) + + (transv-max float :offset-assert 24) + (target-speed float :offset-assert 28) + (seek0 float :offset-assert 32) + (seek90 float :offset-assert 36) + (seek180 float :offset-assert 40) + (fric float :offset-assert 44) + (nonlin-fric-dist float :offset-assert 48) + (slip-factor float :offset-assert 52) + (slide-factor float :offset-assert 56) + (slope-up-factor float :offset-assert 60) + (slope-down-factor float :offset-assert 64) + (slope-slip-angle float :offset-assert 68) + (impact-fric float :offset-assert 72) + (bend-factor float :offset-assert 76) + (bend-speed float :offset-assert 80) + (alignv float :offset-assert 84) + (slope-up-traction float :offset-assert 88) + (align-speed float :offset-assert 92) + + (slope-change-preserve float) + + (turnvf float :offset-assert 100) + (turnvvf float :offset-assert 104) + (tiltvf float :offset-assert 108) + (tiltvvf float :offset-assert 112) + (vel-turn float :offset-assert 116) + + ;; hook + (active-hook (function none) :offset 128) + (touch-hook (function none)) + (impact-hook function) + (mult-hook (function surface surface surface int none)) + (exit-hook function) + + ;; dataw + (mode symbol :offset-assert 148) + (flags surface-flag) + + (data float 30 :offset 8) + (hook function 4 :offset 128) + (dataw uint32 2 :offset 148) + + ) :method-count-assert 9 :size-assert #x9c :flag-assert #x90000009c ;; Failed to read fields. ) -|# -;; (define-extern calc-terminal-vel function) ;; (function float float float float) -;; (define-extern calc-terminal2-vel function) ;; (function float float float float float) -;; (define-extern calc-terminal4-vel function) ;; (function float float float float) -;; (define-extern surface-interp! function) ;; (function surface surface surface float surface) -;; (define-extern surface-mult! function) ;; (function surface surface surface surface) -;; (define-extern surface-clamp-speed function) ;; (function surface surface surface int none) -;; (define-extern *walk-mods* surface) ;; surface -;; (define-extern *walk-no-turn-mods* surface) ;; surface -;; (define-extern *turn-around-mods* surface) ;; surface -;; (define-extern *jump-mods* surface) ;; surface -;; (define-extern *double-jump-mods* surface) ;; surface -;; (define-extern *smack-jump-mods* surface) ;; surface -;; (define-extern *high-jump-mods* surface) ;; surface -;; (define-extern *launch-jump-mods* surface) ;; surface -;; (define-extern *forward-high-jump-mods* surface) ;; surface -;; (define-extern *flip-jump-mods* surface) ;; surface -;; (define-extern *forward-jump-mods* surface) ;; surface -;; (define-extern *forward-pole-jump-mods* surface) ;; surface -;; (define-extern *dark-jump-mods* object) -;; (define-extern *roll-mods* surface) -;; (define-extern *roll-flip-mods* surface) -;; (define-extern *flop-mods* surface) ;; surface -;; (define-extern *flop-land-mods* object) ;; surface -;; (define-extern *wade-mods* surface) ;; surface -;; (define-extern *swim-mods* surface) ;; surface -;; (define-extern *dive-mods* surface) ;; surface -;; (define-extern *dive-bottom-mods* surface) ;; surface -;; (define-extern *pole-mods* object) ;; surface -;; (define-extern *grab-mods* object) ;; surface -;; (define-extern *edge-grab-mods* object) ;; surface -;; (define-extern *empty-mods* surface) ;; surface -;; (define-extern *neutral-mods* surface) ;; surface -;; (define-extern *stone-surface* surface) ;; surface -;; (define-extern *gravel-surface* surface) -;; (define-extern *edge-surface* surface) ;; surface -;; (define-extern *wade-surface* surface) ;; surface -;; (define-extern *quicksand-surface* surface) ;; surface -;; (define-extern *tar-surface* surface) ;; surface -;; (define-extern *ice-surface* surface) ;; surface -;; (define-extern *rail-surface* surface) -;; (define-extern *standard-ground-surface* object) ;; surface -;; (define-extern *swim-surface* object) ;; surface +(define-extern calc-terminal-vel (function float float float float)) +(define-extern calc-terminal2-vel (function float float float float float)) +(define-extern calc-terminal4-vel (function float float float float)) +(define-extern surface-interp! (function surface surface surface float surface)) +(define-extern surface-mult! (function surface surface surface surface)) +(define-extern surface-clamp-speed (function surface surface surface int none)) +(define-extern *walk-mods* surface) +(define-extern *walk-no-turn-mods* surface) +(define-extern *turn-around-mods* surface) +(define-extern *jump-mods* surface) +(define-extern *double-jump-mods* surface) +(define-extern *smack-jump-mods* surface) +(define-extern *high-jump-mods* surface) +(define-extern *launch-jump-mods* surface) +(define-extern *forward-high-jump-mods* surface) +(define-extern *flip-jump-mods* surface) +(define-extern *forward-jump-mods* surface) +(define-extern *forward-pole-jump-mods* surface) +(define-extern *dark-jump-mods* surface) +(define-extern *roll-mods* surface) +(define-extern *roll-flip-mods* surface) +(define-extern *flop-mods* surface) +(define-extern *flop-land-mods* surface) +(define-extern *wade-mods* surface) +(define-extern *swim-mods* surface) +(define-extern *dive-mods* surface) +(define-extern *dive-bottom-mods* surface) +(define-extern *pole-mods* surface) +(define-extern *grab-mods* surface) +(define-extern *edge-grab-mods* surface) +(define-extern *empty-mods* surface) +(define-extern *neutral-mods* surface) +(define-extern *stone-surface* surface) +(define-extern *gravel-surface* surface) +(define-extern *edge-surface* surface) +(define-extern *wade-surface* surface) +(define-extern *quicksand-surface* surface) +(define-extern *tar-surface* surface) +(define-extern *ice-surface* surface) +(define-extern *rail-surface* surface) +(define-extern *standard-ground-surface* surface) +(define-extern *swim-surface* surface) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; pat-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum pat-mode + :type uint8 + (ground 0) + (wall 1) + (obstacle 2) + (halfpipe 3) + ) + +(defenum pat-material + :type uint8 + (unknown 0) + (ice 1) + (quicksand 2) + (waterbottom 3) + (tar 4) + (sand 5) + (wood 6) + (grass 7) + (pcmetal 8) + (snow 9) + (deepsnow 10) + (hotcoals 11) + (lava 12) + (crwood 13) + (gravel 14) + (dirt 15) + (metal 16) + (straw 17) + (tube 18) + (swamp 19) + (stopproj 20) + (rotate 21) + (neutral 22) + (stone 23) + (crmetal 24) + (carpet 25) + (grmetal 26) + (shmetal 27) + (hdwood 28) + ) + +(defenum pat-event + :type uint8 + (none 0) + (deadly 1) + (endlessfall 2) + (burn 3) + (deadlup 4) + (burnup 5) + (melt 6) + (slide 7) + (lip 8) + (lipramp 9) + (shock 10) + (shockup 11) + (hide 12) + (rail 13) + (slippery 14) + ) + (deftype pat-surface (uint32) - () + ((skip uint8 :offset 0 :size 7 :do-not-decompile) + (mode pat-mode :offset 7 :size 3) + (material pat-material :offset 10 :size 6) + (camera uint8 :offset 16 :size 1 :do-not-decompile) ;; sz = 2?? + (event pat-event :offset 18 :size 6) + (skip2 uint8 :offset 24 :size 5 :do-not-decompile) + + (noentity uint8 :offset 0 :size 1) + (nocamera uint8 :offset 1 :size 1) + (noedge uint8 :offset 2 :size 1) + (nogrind uint8 :offset 3 :size 1) + (nojak uint8 :offset 4 :size 1) + (noboard uint8 :offset 5 :size 1) + (nopilot uint8 :offset 6 :size 1) + + (probe uint8 :offset 24 :size 1) + (nomech uint8 :offset 25 :size 1) + (noproj uint8 :offset 26 :size 1) + (noendlessfall uint8 :offset 27 :size 1) + (noprobe uint8 :offset 28 :size 1) + + (nolineofsight uint8 :offset 16 :size 1) + ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ;; Failed to read some fields. ) -|# -#| (deftype pat-mode-info (structure) ((name string :offset-assert 0) ;; guessed by decompiler (wall-angle float :offset-assert 4) @@ -12152,18 +12840,56 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern pat-material->string function) ;; (function pat-surface string) -;; (define-extern pat-mode->string function) ;; (function pat-surface string) -;; (define-extern pat-event->string function) ;; (function pat-surface string) -;; (define-extern *pat-mode-info* object) ;; (inline-array pat-mode-info) + +(define-extern pat-material->string (function pat-surface string)) +(define-extern pat-mode->string (function pat-surface string)) +(define-extern pat-event->string (function pat-surface string)) +(define-extern *pat-mode-info* (inline-array pat-mode-info)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; fact-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum pickup-type + :bitfield #f + :type int32 + (none 0) + (eco-yellow 1) + (eco-red 2) + (eco-blue 3) + (eco-dark 4) + (eco-green 5) + (eco-pill-green 6) + (eco-pill-dark 7) + (eco-pill-random 8) + (money 9) + (fuel-cell 10) + (buzzer 11) + (darkjak 12) + (ammo-yellow 13) + (ammo-red 14) + (ammo-blue 15) + (ammo-dark 16) + (shield 17) + (health 18) + (trick-point 19) + (trick-judge 20) + (gem 21) + (skill 22) + (karma 23) + (gun-red 24) + (gun-yellow 25) + (gun-blue 26) + (gun-dark 27) + (board 28) + (pass-red 29) + (pass-green 30) + (pass-yellow 31) + (pass-blue 32) + (ammo-random 33) + ) + (deftype fact-bank (basic) ((eco-level-max float :offset-assert 4) (eco-single-inc float :offset-assert 8) @@ -12204,27 +12930,98 @@ :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| +(defenum actor-option + :bitfield #t + :type uint64 + + (blocked 0) ;; 1 + (spawns-fuel-cell 1) ;; 2 + (draw-blocker 2) ;; 4 + (loop 3) ;; 8 + (reflect 4) ;; 16 + (wait-for-cue 5) ;; 32 + (auto-pickup 6) ;; 64 + (fuel-cell-no-jump 7) ;; 128 + (suck-in 8) ;; 256 + (fade-out 9) ;; 512 + (big-collision 10) ;; 1024 + (racer-only 11) ;; 2048 + (no-reaction 12) ;; 4096 + (no-shadow 13) ;; 8192 + (wait-for-task-complete 14) ;; 16384 + (respawn-delay 15) ;; 32768 + + (no-amb-sound 16) ;; hi 1 + (user17 17) ;; hi 2 + (user18 18) ;; hi 4 + (user19 19) ;; hi 8 + (user20 20) ;; hi 16 + (cond-hide 21) ;; hi 32 + (cond-respawn 22) ;; hi 64 + (fall 23) ;; hi 128 + (mirror 24) ;; hi 256 + (cond-low-ammo 25) ;; hi 512 + (no-distance-check-fadeout 26) ;; 1024 + (no-track 27) ;; hi 2048 + ) + (deftype fact-info (basic) - () + ((process process :offset-assert 4) + (pickup-type pickup-type :offset-assert 8) + (pickup-amount float :offset-assert 12) + (pickup-spawn-amount float :offset-assert 16) + (options actor-option :offset-assert 24) + (fade-time time-frame :offset-assert 32) + ) :method-count-assert 12 :size-assert #x28 :flag-assert #xc00000028 ;; Failed to read fields. (:methods - ;; (new (symbol type process-drawable pickup-type float) _type_ 0) + (new (symbol type process pickup-type float) _type_ 0) (fact-info-method-9 () none 9) ;; (drop-pickup (_type_ symbol process-tree fact-info int) (pointer process) 9) - (fact-info-method-10 () none 10) ;; (reset! (_type_ symbol) none 10) - (fact-info-method-11 () none 11) ;; (pickup-collectable! (_type_ pickup-type float handle) float 11) + (reset! (_type_ symbol) none 10) + (pickup-collectable! (_type_ pickup-type float handle) float 11) ) ) -|# -#| (deftype fact-info-target (fact-info) - () + ((eco-type int32) + (eco-level float) + (eco-pickup-time time-frame) + (eco-timeout time-frame) + (eco-source uint64) + (eco-source-time time-frame) + (health float) + (health-max float) + (health-pickup-time time-frame) + (buzzer float) + (buzzer-max float) + (eco-pill-green float) + (eco-pill-green-max float) + (eco-pill-green-pickup-time time-frame) + (eco-pill-dark-pickup-time time-frame) + (money-pickup-time time-frame) + (buzzer-pickup-time time-frame) + (task-pickup-time time-frame) + (stop-time-timeout time-frame) + (darkjak-start-time time-frame) + (darkjak-effect-time time-frame) + (ammo-pickup-time time-frame) + (shield-pickup-time time-frame) + (shield-start-time time-frame) + (shield-use-time time-frame) + (shield-level float) + (shield-attack-id uint32) + (trick-point float) + (trick-point-pickup-time time-frame) + (trick-point-start-time time-frame) + (trick-point-duration time-frame) + (gem-pickup-time time-frame) + (skill-pickup-time time-frame) + (karma-pickup-time time-frame) + ) :method-count-assert 13 :size-assert #x110 :flag-assert #xd00000110 @@ -12234,25 +13031,65 @@ (fact-info-target-method-12 () none 12) ) ) -|# -#| +(defenum enemy-option + :bitfield #t + :type uint32 + (user0 0) ;; 1 + (user1 1) ;; 2 + (user2 2) ;; 4 + (user3 3) ;; 8 + (user4 4) ;; 16 + (user5 5) ;; 32 + (user6 6) ;; 64 + (user7 7) ;; 128 + (user8 8) ;; 256 + (user9 9) ;; 512 + (user10 10) ;; 1024 + (user11 11) ;; 2048 + (user12 12) ;; 4096 + (user13 13) ;; 8192 + (user14 14) ;; 16k + (user15 15) + + (dormant 16) ;; hi 1 + (dormant-aware 17) ;; hi 2 + (ambush 18) ;; hi 4 + (spawner 19) ;; hi 8 + (prespawned 20) ;; hi 16 + (multi-focus 21) ;; hi 32 + (has-trigger 22) + (idle-til-trigger 23) ;; hi 128 + (knocked-into-water 24) ;; hi 256 + (water 25) ;; hi 512 + ) + (deftype fact-info-enemy (fact-info) - () + ((speed float) + (idle-distance meters) + (notice-top meters) + (notice-bottom meters) + (cam-horz meters) + (cam-vert meters) + (cam-notice-dist meters) + (enemy-options enemy-option) + (trig-dist meters) + (trig-actor-group uint32) + (trig-mask-count int8) + (trig-mask uint8 2) + ) :method-count-assert 13 :size-assert #x53 :flag-assert #xd00000053 ;; Failed to read fields. (:methods - ;; (new (symbol type process-drawable pickup-type float) _type_ 0) - (fact-info-enemy-method-12 () none 12) + (new (symbol type process (pointer float) pickup-type float) _type_ 0) + (clear-mask-bits (_type_ int) none 12) ) ) -|# -#| (deftype fact-info-crate (fact-info) - () + ((suck-count int32)) :method-count-assert 12 :size-assert #x2c :flag-assert #xc0000002c @@ -12260,9 +13097,7 @@ (:methods ) ) -|# -#| (deftype fact-info-enemy-defaults (basic) ((idle-distance meters :offset-assert 4) ) @@ -12270,33 +13105,57 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern *FACT-bank* fact-bank) ;; fact-bank -;; (define-extern pickup-type->string function) ;; (function pickup-type string) -;; (define-extern *fact-info-enemy-defaults* fact-info-enemy-defaults) +(define-extern *FACT-bank* fact-bank) +(define-extern pickup-type->string (function pickup-type string)) +(define-extern *fact-info-enemy-defaults* fact-info-enemy-defaults) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; aligner-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type process-drawable process) + +(defenum align-flags + :bitfield #t + :type uint32 + (disabled) ;; keep object velocity + ) + +(defenum align-opts + :bitfield #t + :type uint32 + (adjust-x-vel) + (adjust-y-vel) + (adjust-xz-vel) + (keep-other-velocities) + (adjust-quat) ;; 16 + (alop0) + (alop1) + (alop2) + (alop3) + (alop4) + (alop5) + (no-gravity) + (ignore-y-if-zero) + ) + (deftype align-control (basic) ((flags align-flags :offset-assert 4) ;; guessed by decompiler (process process-drawable :offset-assert 8) ;; guessed by decompiler (frame-group art-joint-anim :offset-assert 12) ;; guessed by decompiler (frame-num float :offset-assert 16) - (matrix matrix 2 :offset-assert 32) ;; guessed by decompiler - (transform transform 2 :offset-assert 160) ;; guessed by decompiler + (matrix matrix 2 :inline :offset-assert 32) ;; guessed by decompiler + (transform transform 2 :inline :offset-assert 160) ;; guessed by decompiler (delta transformq :inline :offset-assert 256) (last-speed meters :offset-assert 304) - (align transformq :inline :offset-assert 160) + (align transformq :inline :offset 160) ) :method-count-assert 14 :size-assert #x134 :flag-assert #xe00000134 (:methods - ;; (new (symbol type process) _type_ 0) + (new (symbol type process) _type_ 0) (align-control-method-9 () none 9) ;; (compute-alignment! (_type_) transformq 9) (align-control-method-10 () none 10) ;; (align! (_type_ align-opts float float float) trsqv 10) (align-control-method-11 () none 11) ;; (align-vel-and-quat-only! (_type_ align-opts vector int float float) trsqv 11) @@ -12304,49 +13163,91 @@ (align-control-method-13 () none 13) ;; (snd-transform (_type_) transform 13) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; penetrate-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern penetrate-using->damage function) -;; (define-extern penetrated-by-all&hit-points->penetrated-by function) +(defenum penetrate + :bitfield #t + :type uint64 + (touch 0) ;; 1 + (generic-attack 1) ;; 2 + (lunge 2) ;; 4 + (flop 3) ;; 8 + (punch 4) ;; 16 + (spin 5) ;; 32 + (roll 6) ;; 64 + (uppercut 7) ;; 128 + (bonk 8) ;; 256 + (tube 9) ;; 512 + (vehicle 10) ;; 1024 + (flut-attack 11) ;; 2048 + (board 12) ;; 4096 + (mech 13) ;; 8192 + (mech-punch 14) ;; 16384 + (mech-bonk 15) ;; 32768 + (dark-skin 16) ;; hi 1 + (dark-punch 17) ;; hi 2 + (dark-bomb 18) ;; hi 4 + (dark-giant 19) ;; hi 8 + (shield 20) ;; hi 16 + (explode 21) ;; hi 32 + (jak-yellow-shot 22) ;; hi 64 + (jak-red-shot 23) ;; hi 128 + (jak-blue-shot 24) ;; hi 256 + (jak-dark-shot 25) ;; hi 512 + (enemy-yellow-shot 26) ;; hi 1024 + (enemy-dark-shot 27) ;; hi 2048 + (eco-yellow 28) ;; hi 4096 + (eco-red 29) ;; hi 8192 + (eco-blue 30) ;; hi 16384 + (eco-green 31) ;; hi 32768 + (knocked 32) ;; hihi 1 + ) + +(define-extern penetrate-using->damage (function penetrate int)) +(define-extern penetrated-by-all&hit-points->penetrated-by (function penetrate int penetrate)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type nav-control structure) +(declare-type path-control basic) +(declare-type vol-control basic) +(declare-type actor-link-info basic) +(declare-type water-control basic) + +(defenum state-flags + :bitfield #t + :type uint32 + ) + (deftype process-drawable (process) - ((root trsqv :offset-assert 124) ;; guessed by decompiler - (node-list cspace-array :offset-assert 128) ;; guessed by decompiler - (draw draw-control :offset-assert 132) ;; guessed by decompiler - (skel joint-control :offset-assert 136) ;; guessed by decompiler - (nav nav-control :offset-assert 140) ;; guessed by decompiler - (align align-control :offset-assert 144) ;; guessed by decompiler - (path path-control :offset-assert 148) ;; guessed by decompiler - (vol vol-control :offset-assert 152) ;; guessed by decompiler - (fact fact-info :offset-assert 156) ;; guessed by decompiler - (link actor-link-info :offset-assert 160) ;; guessed by decompiler - (part sparticle-launch-control :offset-assert 164) ;; guessed by decompiler - (water water-control :offset-assert 168) ;; guessed by decompiler - (sound ambient-sound :offset-assert 172) ;; guessed by decompiler - (carry basic :offset-assert 176) - (rbody basic :offset-assert 180) - (state-flags state-flags :offset-assert 184) ;; guessed by decompiler - (state-time time-frame :offset-assert 188) ;; time-frame + ((root trsqv :offset-assert 128) ;; guessed by decompiler + (node-list cspace-array :offset-assert 132) ;; guessed by decompiler + (draw draw-control :offset-assert 136) ;; guessed by decompiler + (skel joint-control :offset-assert 140) ;; guessed by decompiler + (nav nav-control :offset-assert 144) ;; guessed by decompiler + (align align-control :offset-assert 148) ;; guessed by decompiler + (path path-control :offset-assert 152) ;; guessed by decompiler + (vol vol-control :offset-assert 156) ;; guessed by decompiler + (fact fact-info :offset-assert 160) ;; guessed by decompiler + (link actor-link-info :offset-assert 164) ;; guessed by decompiler + (part sparticle-launch-control :offset-assert 168) ;; guessed by decompiler + (water water-control :offset-assert 172) ;; guessed by decompiler + (sound ambient-sound :offset-assert 176) ;; guessed by decompiler + (carry basic :offset-assert 180) + (rbody basic :offset-assert 184) + (state-flags state-flags :offset-assert 188) ;; guessed by decompiler + (state-time time-frame :offset-assert 192) ;; time-frame ) :method-count-assert 20 :size-assert #xc8 :flag-assert #x14005000c8 (:methods - (process-drawable-method-9 () none 9) - (process-drawable-method-10 () none 10) - (process-drawable-method-11 () none 11) - (process-drawable-method-12 () none 12) - (process-drawable-method-13 () none 13) (process-drawable-method-14 () none 14) ;; (initialize-skeleton (_type_ skeleton-group pair) none 14) (process-drawable-method-15 () none 15) ;; (initialize-skeleton-by-name (_type_ string object) _type_ 15) (process-drawable-method-16 () none 16) ;; (apply-alignment (_type_ align-opts transformq vector) collide-shape 16) @@ -12355,9 +13256,7 @@ (process-drawable-method-19 () none 19) ;; (evaluate-joint-control (_type_) none 19) ) ) -|# -#| (deftype process-drawable-reserved (process-drawable) () :method-count-assert 178 @@ -12524,9 +13423,7 @@ (process-drawable-reserved-method-177 () none 177) ) ) -|# -#| (deftype attack-dir-info (structure) ((dir vector :inline :offset-assert 0) (xz-dir vector :inline :offset-assert 16) @@ -12537,11 +13434,61 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| +(defenum attack-info-mask + :bitfield #t + :type uint32 + (trans 0) ;; 1 + (vector 1) ;; 2 + (intersection 2) ;; 4 + (attacker 3) ;; 8 + (attack-time 4) ;; 16 + (invinc-time 5) ;; 32 + (mode 6) ;; 64 + (shove-back 7) ;; 128 + (shove-up 8) ;; 256 + (speed 9) ;; 512 + (dist 10) ;; 1024 + (control 11) ;; 2048 + (angle 12) ;; 4096 + (rotate-to 13) ;; 8192 + (prev-state 14) ;; 16384 + (id 15) ;; 32768 + (count 16) ;; hi 1 + (penetrate-using 17) ;; hi 2 + (attacker-velocity 18);; hi 4 + (damage 19) ;; hi 8 + (shield-damage 20) ;; hi16 + (knock 21) ;; hi 32 + (test 22) ;; hi 64 + ) + (deftype attack-info (structure) - () + ((trans vector :inline) + (vector vector :inline) + (attacker-velocity vector :inline) + (intersection vector :inline) + (attacker handle) + (attack-time time-frame) + (invinc-time time-frame) + (mask attack-info-mask) + (mode symbol) + (shove-back meters) + (shove-up meters) + (speed meters) + (dist meters) + (control float) + (angle symbol) + (rotate-to degrees) + (prev-state state) + (id uint32) + (count uint32) + (penetrate-using uint64) + (damage float) + (shield-damage float) + (knock uint8) + (test uint32) + ) :method-count-assert 12 :size-assert #xa0 :flag-assert #xc000000a0 @@ -12552,9 +13499,7 @@ (attack-info-method-11 () none 11) ) ) -|# -#| (deftype ground-tween-info (structure) ((chan uint8 3 :offset-assert 0) ;; guessed by decompiler (blend float 3 :offset-assert 4) ;; guessed by decompiler @@ -12564,14 +13509,12 @@ :size-assert #x24 :flag-assert #x900000024 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; script-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype script-form (structure) ((name basic :offset-assert 0) (spec basic :offset-assert 4) @@ -12584,29 +13527,36 @@ (script-form-method-9 () none 9) ) ) -|# -#| (deftype script-context (structure) - () + ((load-state load-state) + (key basic) + (process process) + (trans vector) + (side-effect? symbol) + (got-error? symbol) + (expr basic) + (param-count int32) + (param object 16) + (param-type object 16) + ) :method-count-assert 12 :size-assert #xa0 :flag-assert #xc000000a0 ;; Failed to read fields. (:methods + (new (symbol type basic process vector) _type_ 0) (script-context-method-9 () none 9) (script-context-method-10 () none 10) (script-context-method-11 () none 11) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; scene-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype scene-actor (basic) ((name basic :offset-assert 4) (level basic :offset-assert 8) @@ -12633,16 +13583,9 @@ (scene-actor-method-9 () none 9) ) ) -|# -#| (deftype scene (art-group) - ((name basic :offset-assert 8) - (length int32 :offset-assert 12) - (extra basic :offset-assert 16) - (info basic :offset-assert 4) - (data UNKNOWN :dynamic :offset-assert 32) - (mask-to-clear uint32 :offset-assert 32) + ((mask-to-clear uint32 :offset-assert 32) (entity basic :offset-assert 36) (art-group basic :offset-assert 40) (anim basic :offset-assert 44) @@ -12675,32 +13618,30 @@ (scene-method-16 () none 16) ) ) -|# -#| (deftype scene-player (process-drawable) - ((scene-list basic :offset-assert 196) - (scene basic :offset-assert 200) - (scene-index int32 :offset-assert 204) - (anim basic :offset-assert 208) - (next-anim basic :offset-assert 212) - (camera uint64 :offset-assert 220) - (main-entity basic :offset-assert 228) - (wait basic :offset-assert 232) - (old-target-pos transformq :inline :offset-assert 236) - (pre-cut-frame basic :offset-assert 284) - (preload-continue basic :offset-assert 288) - (dma-max uint32 :offset-assert 292) - (gui-id uint32 :offset-assert 296) - (aborted? basic :offset-assert 300) - (scene-start-time time-frame :offset-assert 308) - (targ-speed float :offset-assert 316) - (cur-speed float :offset-assert 320) - (speed-change-time time-frame :offset-assert 324) - (speed-press-time time-frame :offset-assert 332) - (speed-change-speed float :offset-assert 340) - (subtitle-change-time time-frame :offset-assert 348) - (user-sound UNKNOWN 4 :offset-assert 356) + ((scene-list basic :offset-assert 200) + (scene basic :offset-assert 204) + (scene-index int32 :offset-assert 208) + (anim basic :offset-assert 212) + (next-anim basic :offset-assert 216) + (camera uint64 :offset-assert 224) + (main-entity basic :offset-assert 232) + (wait basic :offset-assert 236) + (old-target-pos transformq :inline :offset-assert 240) + (pre-cut-frame basic :offset-assert 288) + (preload-continue basic :offset-assert 292) + (dma-max uint32 :offset-assert 296) + (gui-id uint32 :offset-assert 300) + (aborted? basic :offset-assert 304) + (scene-start-time time-frame :offset-assert 312) + (targ-speed float :offset-assert 320) + (cur-speed float :offset-assert 324) + (speed-change-time time-frame :offset-assert 328) + (speed-press-time time-frame :offset-assert 336) + (speed-change-speed float :offset-assert 344) + (subtitle-change-time time-frame :offset-assert 352) + (user-sound uint32 4 :offset-assert 360) ;; guess ) :method-count-assert 26 :size-assert #x178 @@ -12714,18 +13655,21 @@ (scene-player-method-25 () none 25) ) ) -|# -;; (define-extern *scene-player* object) +(define-extern *scene-player* scene-player) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sync-info-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum sync-flags + :type uint64 + :bitfield #t + ) + (deftype sync-info-params (structure) ((sync-type basic :offset-assert 0) - (sync-flags uint64 :offset-assert 8) + (sync-flags sync-flags :offset-assert 8) (entity basic :offset-assert 16) (period uint32 :offset-assert 20) (percent float :offset-assert 24) @@ -12738,11 +13682,9 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype sync-info (structure) - ((sync-flags uint64 :offset-assert 0) + ((sync-flags sync-flags :offset-assert 0) (offset float :offset-assert 8) (period uint32 :offset-assert 12) ) @@ -12759,9 +13701,7 @@ (sync-info-method-15 () none 15) ;; (load-params! (_type_ process uint float float float) symbol 15) ) ) -|# -#| (deftype sync-linear (sync-info) () :method-count-assert 16 @@ -12770,9 +13710,7 @@ (:methods ) ) -|# -#| (deftype sync-eased (sync-info) ((tlo float :offset-assert 16) (thi float :offset-assert 20) @@ -12788,9 +13726,7 @@ (:methods ) ) -|# -#| (deftype sync-paused (sync-info) ((pause-in float :offset-assert 16) (pause-out float :offset-assert 20) @@ -12801,9 +13737,7 @@ (:methods ) ) -|# -#| (deftype delayed-rand-float (structure) ((min-time int32 :offset-assert 0) (max-time int32 :offset-assert 4) @@ -12822,9 +13756,7 @@ (delayed-rand-float-method-12 () none 12) ) ) -|# -#| (deftype oscillating-float (structure) ((value float :offset-assert 0) (target float :offset-assert 4) @@ -12841,9 +13773,7 @@ (oscillating-float-method-10 () none 10) ;; (update! (_type_ float) float 10) ) ) -|# -#| (deftype bouncing-float (structure) ((osc oscillating-float :inline :offset-assert 0) (max-value float :offset-assert 24) @@ -12861,9 +13791,7 @@ (bouncing-float-method-12 () none 12) ;; (at-max? (_type_) symbol 12) ) ) -|# -#| (deftype delayed-rand-vector (structure) ((min-time int32 :offset-assert 0) (max-time int32 :offset-assert 4) @@ -12883,9 +13811,7 @@ (delayed-rand-vector-method-12 () none 12) ;; (update-with-delay-or-reset! (_type_) vector 12) ) ) -|# -#| (deftype oscillating-vector (structure) ((value vector :inline :offset-assert 0) (target vector :inline :offset-assert 16) @@ -12902,23 +13828,29 @@ (oscillating-vector-method-10 () none 10) ;; (update! (_type_ vector) vector 10) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; pov-camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum pov-camera-flag + :bitfield #t + :type int32 + (notify-of-abort 0) + (allow-abort 1) + (inherit-orientation 2) + ) + (deftype pov-camera (process-drawable) - ((flags int32 :offset-assert 196) ;; pov-camera-flag - (debounce-start-time time-frame :offset-assert 204) ;; time-frame - (notify-handle uint64 :offset-assert 212) ;; handle - (anim-name string :offset-assert 220) ;; guessed by decompiler - (command-list pair :offset-assert 224) ;; guessed by decompiler - (mask-to-clear process-mask :offset-assert 228) ;; guessed by decompiler - (music-volume-movie float :offset-assert 232) - (sfx-volume-movie float :offset-assert 236) + ((flags pov-camera-flag :offset-assert 200) ;; pov-camera-flag + (debounce-start-time time-frame :offset-assert 208) ;; time-frame + (notify-handle uint64 :offset-assert 216) ;; handle + (anim-name string :offset-assert 224) ;; guessed by decompiler + (command-list pair :offset-assert 228) ;; guessed by decompiler + (mask-to-clear process-mask :offset-assert 232) ;; guessed by decompiler + (music-volume-movie float :offset-assert 236) + (sfx-volume-movie float :offset-assert 240) ) :method-count-assert 30 :size-assert #xf4 @@ -12936,14 +13868,12 @@ (pov-camera-method-29 () none 29) ;; (set-stack-size! (_type_) none 29) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; smush-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype smush-control (structure) ((start-time time-frame :offset-assert 0) ;; time-frame (period float :offset-assert 8) @@ -12957,22 +13887,20 @@ :size-assert #x20 :flag-assert #xf00000020 (:methods - (smush-control-method-9 () none 9) ;; (set-zero! (_type_) _type_ 9) - (smush-control-method-10 () none 10) ;; (update! (_type_) float 10) - (smush-control-method-11 () none 11) ;; (get-no-update (_type_) float 11) - (smush-control-method-12 () none 12) ;; (activate! (_type_ float int int float float) _type_ 12) - (smush-control-method-13 () none 13) ;; (nonzero-amplitude? (_type_) symbol 13) - (smush-control-method-14 () none 14) ;; (die-on-next-update! (_type_) _type_ 14) + (set-zero! (_type_) _type_ 9) + (update! (_type_) float 10) + (get-no-update (_type_) float 11) + (activate! (_type_ float int int float float clock) _type_ 12) + (nonzero-amplitude? (_type_) symbol 13) + (die-on-next-update! (_type_) _type_ 14) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; debug-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype pos-history (structure) ((points (inline-array vector) :offset-assert 0) ;; guessed by decompiler (num-points int32 :offset-assert 4) @@ -12983,9 +13911,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype debug-vertex (structure) ((trans vector4w :inline :offset-assert 0) (normal vector3h :inline :offset-assert 16) @@ -12996,50 +13922,102 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype debug-vertex-stats (basic) ((length int32 :offset-assert 4) (pos-count int32 :offset-assert 8) - (vertex debug-vertex 600 :offset-assert 16) ;; guessed by decompiler + (vertex debug-vertex 600 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4b10 :flag-assert #x900004b10 ) -|# -;; (define-extern *color-black* object) ;; rgba -;; (define-extern *color-white* object) ;; rgba -;; (define-extern *color-gray* object) ;; rgba -;; (define-extern *color-red* object) ;; rgba -;; (define-extern *color-green* object) ;; rgba -;; (define-extern *color-blue* object) ;; rgba -;; (define-extern *color-cyan* object) ;; rgba -;; (define-extern *color-magenta* object) ;; rgba -;; (define-extern *color-yellow* object) ;; rgba -;; (define-extern *color-light-red* object) ;; rgba -;; (define-extern *color-light-green* object) ;; rgba -;; (define-extern *color-light-blue* object) ;; rgba -;; (define-extern *color-light-cyan* object) ;; rgba -;; (define-extern *color-light-magenta* object) ;; rgba -;; (define-extern *color-light-yellow* object) ;; rgba -;; (define-extern *color-dark-red* object) ;; rgba -;; (define-extern *color-dark-green* object) ;; rgba -;; (define-extern *color-dark-blue* object) ;; rgba -;; (define-extern *color-dark-cyan* object) ;; rgba -;; (define-extern *color-dark-magenta* object) ;; rgba -;; (define-extern *color-dark-yellow* object) ;; rgba -;; (define-extern *color-orange* object) ;; rgba +(define-extern *color-black* rgba) +(define-extern *color-white* rgba) +(define-extern *color-gray* rgba) +(define-extern *color-red* rgba) +(define-extern *color-green* rgba) +(define-extern *color-blue* rgba) +(define-extern *color-cyan* rgba) +(define-extern *color-magenta* rgba) +(define-extern *color-yellow* 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) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; joint-mod-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum joint-mod-mode + :bitfield #f + :type uint32 + + ) + +(defenum track-mode + :bitfield #t + :type uint16 + (track-on 0) ;; 1 + (track-x 1) ;; 2 + (track-y 2) ;; 4 + (lock-on 3) ;; 8 + (no-trans 4) ;; 16 + (no-rotate 5) ;; 32 + (no-scale 6) ;; 64 + ) + (deftype joint-mod (basic) - () + ((mode joint-mod-mode) + (process process) + (joint cspace) + (target vector :inline :offset 16) + (twist vector :inline :offset 32) + ;;(twist-max vector :inline) + (twist-max float 4) + (extra-twist degrees :offset 40) + (track-mode track-mode :offset 44) + (loock-at-count uint16 :offset 46) + (twist-range-x meters :offset 56) + (twist-range-y meters :offset 60) + (twist-speed-x float :offset 64) + (twist-speed-y float :offset 68) + (twist-min-x float :offset 72) + (twist-min-y float :offset 76) + (trans vector :inline :offset-assert 80) + (shmushy-old float :offset 80) + (smushy-off float :offset 84) + (smushyv float :offset 88) + (quat quaternion :inline :offset-assert 96) + (scale vector :inline) + (notice-time time-frame) + (flex-blend float) + (blend float) + (max-dist meters) + (ignore-angle degrees) + (up uint8) + (nose uint8) + (ear uint8) + (base-joint uint8) + (base-nose uint8) + (shutting-down? symbol) + (parented-scale? symbol) + (polar-internal-tilt-max float) + (polar-internal-radius float) + (polar-external-tilt-max float) + (polar-external-radius float) + ) :method-count-assert 16 :size-assert #xb8 :flag-assert #x10000000b8 @@ -13049,15 +14027,13 @@ (joint-mod-method-9 () none 9) ;; (set-mode! (_type_ joint-mod-handler-mode) _type_ 9) (joint-mod-method-10 () none 10) ;; (set-target! (_type_ vector) none 10) (joint-mod-method-11 () none 11) ;; (look-at-enemy! (_type_ vector symbol process) none 11) - (joint-mod-method-12 () none 12) ;; (reset-blend! (_type_) _type_ 12) + (reset-blend! (_type_) _type_ 12) (joint-mod-method-13 () none 13) ;; (set-twist! (_type_ float float float) vector 13) (joint-mod-method-14 () none 14) ;; (set-trs! (_type_ vector quaternion vector) none 14) (joint-mod-method-15 () none 15) ;; (shut-down! (_type_) float 15) ) ) -|# -#| (deftype try-to-look-at-info (basic) ((who uint64 :offset-assert 8) ;; handle (horz float :offset-assert 16) @@ -13067,9 +14043,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype joint-mod-wheel (basic) ((last-position vector :inline :offset-assert 16) (angle float :offset-assert 32) @@ -13077,106 +14051,114 @@ (wheel-radius float :offset-assert 40) (wheel-axis int8 :offset-assert 44) ) + (:methods + (new (symbol type process-drawable int float int) _type_) + ) :method-count-assert 9 :size-assert #x2d :flag-assert #x90000002d ) -|# -#| (deftype joint-mod-set-local (basic) ((transform transformq :inline :offset-assert 16) - (set-rotation basic :offset-assert 64) - (set-scale basic :offset-assert 68) - (set-translation basic :offset-assert 72) - (enable basic :offset-assert 76) + (set-rotation symbol :offset-assert 64) + (set-scale symbol :offset-assert 68) + (set-translation symbol :offset-assert 72) + (enable symbol :offset-assert 76) ) + (:methods + (new (symbol type process-drawable int symbol symbol symbol) _type_) + ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype joint-mod-add-local (basic) ((transform transformq :inline :offset-assert 16) - (add-rotation basic :offset-assert 64) - (add-scale basic :offset-assert 68) - (add-translation basic :offset-assert 72) - (enable basic :offset-assert 76) + (add-rotation symbol :offset-assert 64) + (add-scale symbol :offset-assert 68) + (add-translation symbol :offset-assert 72) + (enable symbol :offset-assert 76) ) + (:methods + (new (symbol type process-drawable int symbol symbol symbol) _type_) + ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype joint-mod-set-world (basic) ((transform transformq :inline :offset-assert 16) (node-index int32 :offset-assert 64) - (enable basic :offset-assert 68) + (enable symbol :offset-assert 68) ) + (:methods + (new (symbol type process-drawable int symbol) _type_) + ) :method-count-assert 9 :size-assert #x48 :flag-assert #x900000048 ) -|# -#| (deftype joint-mod-blend-local (basic) ((transform transformq :inline :offset-assert 16) (blend-transform transformq :inline :offset-assert 64) (node-index int32 :offset-assert 112) (blend float :offset-assert 116) - (enable basic :offset-assert 120) + (enable symbol :offset-assert 120) ) + (:methods + (new (symbol type process-drawable int symbol) _type_) + ) :method-count-assert 9 :size-assert #x7c :flag-assert #x90000007c ) -|# -#| (deftype joint-mod-spinner (basic) ((spin-axis vector :inline :offset-assert 16) (angle float :offset-assert 32) (spin-rate float :offset-assert 36) - (enable basic :offset-assert 40) + (enable symbol :offset-assert 40) ) + (:methods + (new (symbol type process-drawable int vector float) _type_) + ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype joint-mod-blend-world (basic) ((transform transformq :inline :offset-assert 16) (blend-transform transformq :inline :offset-assert 64) (blend-flags uint32 :offset-assert 112) (node-index int32 :offset-assert 116) (blend float :offset-assert 120) - (enable basic :offset-assert 124) + (enable symbol :offset-assert 124) ) + (:methods + (new (symbol type process-drawable int symbol float) _type_) + ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype joint-mod-rotate-local (basic) - ((enable basic :offset-assert 4) + ((enable symbol :offset-assert 4) (rotation quaternion :inline :offset-assert 16) ) + (:methods + (new (symbol type process-drawable int symbol) _type_) + ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype joint-mod-ik (basic) ((flags uint32 :offset-assert 4) (process basic :offset-assert 8) @@ -13202,18 +14184,17 @@ (joint-mod-ik-method-10 () none 10) ) ) -|# -;; (define-extern joint-mod-debug-draw function) ;; (function joint-mod none) -;; (define-extern *joint-axis-vectors* object) ;; (inline-array vector) -;; (define-extern joint-mod-wheel-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-set-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-add-local-callback function) -;; (define-extern joint-mod-set-world-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-blend-local-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-spinner-callback function) ;; (function cspace transformq none) -;; (define-extern joint-mod-blend-world-callback function) -;; (define-extern joint-mod-rotate-local-callback function) +(define-extern joint-mod-debug-draw (function joint-mod none)) +(define-extern *joint-axis-vectors* (inline-array vector)) +(define-extern joint-mod-wheel-callback (function cspace transformq none)) +(define-extern joint-mod-set-local-callback (function cspace transformq none)) +(define-extern joint-mod-add-local-callback (function cspace transformq none)) +(define-extern joint-mod-set-world-callback (function cspace transformq none)) +(define-extern joint-mod-blend-local-callback (function cspace transformq none)) +(define-extern joint-mod-spinner-callback (function cspace transformq none)) +(define-extern joint-mod-blend-world-callback (function cspace transformq none)) +(define-extern joint-mod-rotate-local-callback (function cspace transformq none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-func-h ;; @@ -13224,9 +14205,8 @@ ;; collide-mesh-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-tri-result (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (intersect vector :inline :offset-assert 48) (normal vector :inline :offset-assert 64) (pat pat-surface :offset-assert 80) ;; guessed by decompiler @@ -13236,27 +14216,24 @@ :size-assert #x58 :flag-assert #x900000058 ) -|# -#| (deftype collide-mesh-tri (structure) ((vertex-index uint8 3 :offset-assert 0) ;; guessed by decompiler (unused uint8 :offset-assert 3) (pat pat-surface :offset-assert 4) ;; guessed by decompiler ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype collide-mesh (basic) ((joint-id int32 :offset-assert 4) (num-tris uint32 :offset-assert 8) (num-verts uint32 :offset-assert 12) (vertex-data (inline-array vector) :offset-assert 16) ;; guessed by decompiler - (tris collide-mesh-tri 1 :offset-assert 32) ;; guessed by decompiler + (tris collide-mesh-tri 1 :inline :offset 32) ;; guessed by decompiler ) :method-count-assert 16 :size-assert #x28 @@ -13271,37 +14248,31 @@ (collide-mesh-method-15 () none 15) ;; (collide-mesh-math-2 (_type_ object object object) none 15) ) ) -|# -#| (deftype collide-mesh-cache-tri (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler (normal vector :inline :offset-assert 48) (bbox4w bounding-box4w :inline :offset-assert 64) - (pat pat-surface :offset-assert 60) ;; guessed by decompiler + (pat pat-surface :offset 60) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype collide-mesh-cache-entry (structure) ((mat matrix :inline :offset-assert 0) - (tris UNKNOWN :dynamic :offset-assert 64) + (tris collide-mesh-cache-tri :dynamic :inline :offset-assert 64) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype collide-mesh-cache (basic) ((used-size uint32 :offset-assert 4) (max-size uint32 :offset-assert 8) - (id uint64 :offset-assert 12) ;; guessed by decompiler + (id uint32 :offset-assert 12) ;; guessed by decompiler (data uint8 48000 :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 13 @@ -13309,20 +14280,78 @@ :flag-assert #xd0000bb90 (:methods (collide-mesh-cache-method-9 () none 9) ;; (allocate! (_type_ int) int 9) - (collide-mesh-cache-method-10 () none 10) ;; (is-id? (_type_ int) symbol 10) - (collide-mesh-cache-method-11 () none 11) ;; (next-id! (_type_) uint 11) + (is-id? (_type_ int) symbol 10) ;; (is-id? (_type_ int) symbol 10) + (next-id! (_type_) uint 11) ;; (next-id! (_type_) uint 11) (collide-mesh-cache-method-12 () none 12) ) ) -|# -;; (define-extern *collide-mesh-cache* object) ;; collide-mesh-cache +(define-extern *collide-mesh-cache* collide-mesh-cache) ;; collide-mesh-cache ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-shape-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type collide-shape trsqv) +(declare-type collide-shape-moving collide-shape) +(declare-type touching-list structure) + +(defenum collide-spec + :bitfield #t + :type uint32 + + (backgnd 0) ;; 1 + (jak 1) ;; 2 + (bot 2) ;; 4 + (crate 3) ;; 8 + (civilian 4) ;; 16 + (enemy 5) ;; 32 + (obstacle 6) ;; 64 + (vehicle-sphere 7) ;; 128 + (hit-by-player-list 8) ;; 256 + (hit-by-others-list 9) ;; 512 + (player-list 10) ;; 1024 + (water 11) ;; 2048 + (collectable 12) ;; 4096 + (blocking-plane 13) ;; 8192 + (projectile 14) ;; 16384 + (jak-vulnerable 15) ;; 32768 + (camera-blocker 16) ;; hi 1 + (notice-blue-eco-powerup 17) ;; hi 2 + (tobot 18) ;; hi 4 + (pusher 19) ;; hi 8 + (vehicle-mesh 20) ;; hi 16 + (bot-targetable 21) ;; hi 32 + (jak-vehicle 22) ;; hi 64 + (special-obstacle 23) ;; hi 128 + (mech-punch 24) ;; hi 256 + (obstacle-for-jak 25) ;; hi 512 + (vehicle-mesh-probeable 26) ;; hi 1024 + ) + +(defenum collide-action + :bitfield #t + :type uint32 + + (solid 0) ;; 1 + (semi-solid 1) ;; 2 + (rideable 2) ;; 4 + (can-ride 3) ;; 8 + (dont-push-away 4) ;; 16 + (pull-rider-can-collide 5) ;; 32 + (deadly 6) ;; 64 + (persistent-attack 7) ;; 128 + (no-smack 8) ;; 256 + (no-standon 9) ;; 512 + (block-turn-around 10) ;; 1024 + (check-edge 11) ;; 2048 + (check-stuck 12) ;; 4096 + (stuck-wall-escape 13) ;; 8192 + (no-normal-reset 14) ;; 163884 + (edge-grabbed 15) ;; 32768 + (nav-sphere 16) ;; hi 1 + ) + (deftype collide-rider (structure) ((rider-handle uint64 :offset-assert 0) (sticky-prim basic :offset-assert 8) @@ -13333,24 +14362,20 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-rider-pool (basic) ((alloc-count int32 :offset-assert 4) - (riders UNKNOWN 20 :offset-assert 16) + (riders collide-rider 20 :inline :offset-assert 16) ) :method-count-assert 11 :size-assert #x290 :flag-assert #xb00000290 (:methods (collide-rider-pool-method-9 () none 9) - (collide-rider-pool-method-10 () none 10) + (prepare (_type_) none 10) ) ) -|# -#| (deftype pull-rider-info (structure) ((rider collide-rider :offset-assert 0) ;; collide-sticky-rider (rider-cshape collide-shape-moving :offset-assert 4) ;; guessed by decompiler @@ -13361,26 +14386,27 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| +(defenum overlaps-others-options + :type uint32 + :bitfield #t + ) + (deftype overlaps-others-params (structure) - ((options uint32 :offset-assert 0) - (collide-with-filter uint32 :offset-assert 4) + ((options overlaps-others-options :offset-assert 0) + (collide-with-filter collide-spec :offset-assert 4) (tlist touching-list :offset-assert 8) ;; guessed by decompiler - (filtered-root-collide-with uint32 :offset-assert 12) - (filtered-child-collide-with uint32 :offset-assert 16) - (filtered-other-collide-as uint32 :offset-assert 20) + (filtered-root-collide-with collide-spec :offset-assert 12) + (filtered-child-collide-with collide-spec :offset-assert 16) + (filtered-other-collide-as collide-spec :offset-assert 20) ) :method-count-assert 9 :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype move-above-ground-params (structure) - ((gnd-collide-with uint32 :offset-assert 0) + ((gnd-collide-with collide-spec :offset-assert 0) (popup float :offset-assert 4) (dont-move-if-overlaps? basic :offset-assert 8) (hover-if-no-ground? basic :offset-assert 12) @@ -13388,7 +14414,7 @@ (new-pos vector :inline :offset-assert 48) (old-gspot-pos vector :inline :offset-assert 64) (old-gspot-normal vector :inline :offset-assert 80) - (pat uint32 :offset-assert 96) + (pat pat-surface :offset-assert 96) ;; was u32 (on-ground? basic :offset-assert 100) (do-move? basic :offset-assert 104) ) @@ -13396,33 +14422,52 @@ :size-assert #x6c :flag-assert #x90000006c ) -|# -#| +(defenum prim-type + :type int8 + (prim -2) + (sphere -1) + (group 0) + (mesh 1) + (fake-prim 2) + ) + (deftype collide-prim-core (structure) ((world-sphere vector :inline :offset-assert 0) - (collide-as collide-kind :offset-assert 16) ;; guessed by decompiler + (collide-as collide-spec :offset-assert 16) ;; guessed by decompiler (collide-with uint32 :offset-assert 20) (action collide-action :offset-assert 24) ;; guessed by decompiler - (prim-type int8 :offset-assert 28) - (unused1 UNKNOWN 3 :offset-assert 29) - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (prim-type prim-type :offset-assert 28) + (unused1 uint8 3 :offset-assert 29) + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-shape-prim (basic) - () + ((cshape collide-shape :offset-assert 4) + (prim-id uint32 :offset-assert 8) + (transform-index int8 :offset-assert 12) + (unused2 int8 3) + (prim-core collide-prim-core :inline :offset-assert 16) + (local-sphere vector :inline :offset-assert 48) + ;; specifc + (world-sphere vector :inline :offset 16) + (collide-as collide-spec :offset 32) + (collide-with collide-spec :offset 36) + (action collide-action :offset 40) + (prim-type int8 :offset 44) + (radius float :offset 60) + (specific uint8 16 :score -1) + ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 ;; Failed to read fields. (:methods - ;; (new (symbol type collide-shape uint int) _type_ 0) + (new (symbol type collide-shape uint int) _type_ 0) (collide-shape-prim-method-9 () none 9) ;; (move-by-vector! (_type_ vector) none 9) (collide-shape-prim-method-10 () none 10) ;; (find-prim-by-id (_type_ uint) collide-shape-prim 10) (collide-shape-prim-method-11 () none 11) ;; (debug-draw-world-sphere (_type_) symbol 11) @@ -13436,56 +14481,84 @@ (collide-shape-prim-method-19 () none 19) ;; (collide-with-collide-cache-prim-sphere (_type_ collide-shape-intersect collide-cache-prim) none 19) ) ) -|# -#| + (deftype collide-shape-prim-sphere (collide-shape-prim) - () + ((pat pat-surface :offset 64) + (nav-radius float :offset 68) + ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 ;; Failed to read fields. (:methods - ;; (new (symbol type collide-shape uint) _type_ 0) + (new (symbol type collide-shape uint) _type_ 0) ) ) -|# -#| + (deftype collide-shape-prim-mesh (collide-shape-prim) - () + ((mesh collide-mesh :offset 64) + (mesh-id int32 :offset 68) + (mesh-cache-id uint32 :offset 72) + (mesh-cache-entry collide-mesh-cache-entry :offset 76) + ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 ;; Failed to read fields. (:methods - ;; (new (symbol type collide-shape uint uint) _type_ 0) + (new (symbol type collide-shape uint uint) _type_ 0) ) ) -|# -#| (deftype collide-shape-prim-group (collide-shape-prim) - () + ((num-children uint8 :offset 64) + (num-alloc-children uint8 :offset 65) + (child (inline-array collide-shape) :offset 68) ;; total guess.. + ) :method-count-assert 20 :size-assert #x50 :flag-assert #x1400000050 ;; Failed to read fields. (:methods - ;; (new (symbol type collide-shape uint int) _type_ 0) + (new (symbol type collide-shape uint int) _type_ 0) ) ) -|# -#| +(defenum collide-list-enum + (hit-by-player) + (usually-hit-by-player) + (hit-by-others) + (player) + ) + + (deftype collide-shape (trsqv) - () + ((actor-hash-index int16 :offset 12) + (process process :offset-assert 140) + (max-iteration-count uint8) + (nav-flags uint8) + (total-prims uint8) + (num-riders uint8) + (pat-ignore-mask pat-surface) + (event-self symbol) + (event-other symbol) + (root-prim collide-shape-prim) + (riders pointer) ;; no + (penetrate-using penetrate) + (penetrated-by penetrate) + (backup-collide-as collide-spec) + (backup-collde-with collide-spec) + (event-priority uint8) + (rider-max-momentum float) + ) :method-count-assert 55 :size-assert #xc8 :flag-assert #x37000000c8 ;; Failed to read fields. (:methods - ;; (new (symbol type process-drawable collide-list-enum) _type_ 0) + (new (symbol type process-drawable collide-list-enum) _type_ 0) (collide-shape-method-28 () none 28) ;; (move-by-vector! (_type_ vector) none 28) (collide-shape-method-29 () none 29) ;; (alloc-riders (_type_ int) none 29) (collide-shape-method-30 () none 30) ;; (move-to-point! (_type_ vector) none 30) @@ -13515,11 +14588,107 @@ (collide-shape-method-54 () none 54) ;; (set-collide-offense (_type_ int collide-offense) none 54) ) ) -|# -#| +(defenum cshape-moving-flags + :bitfield #t + :type uint64 + (csmf00) + (csmf01) + (csmf02) + (csmf03) + (csmf04) + (csmf05) + (csmf06) + (csmf07) + (csmf08) + (csmf09) + (csmf10) + (csmf11) + (csmf12) + (csmf13) + (csmf14) + (csmf15) + (csmf16) + (csmf17) + (csmf18) + (csmf19) + (csmf20) + (csmf21) + (csmf22) + (csmf23) + (csmf24) + (csmf25) + (csmf26) + (csmf27) + (csmf28) + (csmf29) + ) + +(defenum cshape-reaction-flags + :bitfield #t + :type uint32 + (csrf00) + (csrf01) + (csrf02) + (csrf03) + (csrf04) + (csrf05) + (csrf06) + (csrf07) + (csrf08) + (csrf09) + (csrf10) + (csrf11) + (csrf12) + (csrf13) + (csrf14) + (csrf15) + (csrf16) + (csrf17) + (csrf18) + (csrf19) + (csrf20) + (csrf21) + (csrf22) + (csrf23) + (csrf24) + (csrf25) + (csrf26) + (csrf27) + (csrf28) + (csrf29) + (csrf30) + (csrf31) + ) + (deftype collide-shape-moving (collide-shape) - () + ((rider-time time-frame :offset-assert 200) + (rider-last-move vector :inline) + (trans-old vector :inline) + (poly-pat pat-surface :offset 272) + (cur-pat pat-surface) + (ground-pat pat-surface) + (status cshape-moving-flags) + (old-status cshape-moving-flags) + (prev-status cshape-moving-flags :offset-assert 304) + (reaction-flag cshape-reaction-flags) + (reaction function) ;; function types... + (no-reaction function) + (local-normal vector :inline) + (surface-normal vector :inline) + (poly-normal vector :inline) + (ground-poly-normal vector :inline) + (gspot-pos vector :inline) + (gspot-normal vector :inline) + (grount-touch-point vector :inline) + (ground-impact-vel meters) + (surface-angle float) + (poly-angle float) + (touch-angle float) + (coverage float) + (dynam dynamics) + (surf surface) + ) :method-count-assert 68 :size-assert #x1dc :flag-assert #x44000001dc @@ -13540,127 +14709,133 @@ (collide-shape-moving-method-67 () none 67) ) ) -|# -;; (define-extern *collide-hit-by-player-list* object) ;; engine -;; (define-extern *collide-hit-by-others-list* object) ;; engine -;; (define-extern *collide-player-list* object) ;; engine -;; (define-extern *collide-shape-prim-backgnd* collide-shape-prim-mesh) ;; collide-shape-prim-mesh -;; (define-extern *collide-shape-prim-water* collide-shape-prim-mesh) ;; collide-shape-prim-mesh -;; (define-extern *collide-rider-pool* object) +(define-extern *collide-hit-by-player-list* engine) ;; engine +(define-extern *collide-hit-by-others-list* engine) ;; engine +(define-extern *collide-player-list* engine) ;; engine +(define-extern *collide-shape-prim-backgnd* collide-shape-prim-mesh) ;; collide-shape-prim-mesh +(define-extern *collide-shape-prim-water* collide-shape-prim-mesh) ;; collide-shape-prim-mesh +(define-extern *collide-rider-pool* collide-rider-pool) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-obs-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype manipy (process-drawable) -;; () -;; :flag-assert #x1501000174 -;; ) +(defenum manipy-options + :bitfield #t + :type uint32 + ) + +(deftype manipy (process-drawable) + ((new-trans-hook (function none) :offset-assert 200) + (cur-trans-hook (function none) :offset-assert 204) + (cur-event-hook (function none) :offset-assert 208) + (new-joint-anim art-joint-anim :offset-assert 212) + (new-joint-anim-blend uint64 :offset-assert 216) + (anim-mode symbol :offset-assert 224) + (cur-grab-handle handle :offset-assert 232) + (cur-target-handle handle :offset-assert 240) + (old-grab-pos vector :inline :offset-assert 256) + (joint joint-mod 4 :offset-assert 272) + (new-post-hook (function none) :offset-assert 288) + (cur-post-hook (function none) :offset-assert 292) + (clone-copy-trans symbol :offset-assert 296) + (shadow-backup basic :offset-assert 300) + (draw? symbol :offset-assert 304) + (userdata uint64 :offset-assert 312) + (prefix basic :offset-assert 320) + (shadow-volume-joint int32 :offset-assert 324) + (speed float :offset-assert 328) + (user-uint64 uint64 4 :offset-assert 336) + (options manipy-options :offset-assert 368) + ) + :flag-assert #x1501000174 + (:methods + (manipy-method-20 () none 20) + ) + ) -#| (deftype part-spawner (process) - ((root trsqv :offset-assert 124) ;; guessed by decompiler - (part sparticle-launch-control :offset-assert 128) ;; guessed by decompiler - (sound ambient-sound :offset-assert 132) ;; guessed by decompiler - (mode (pointer sparticle-launch-group) :offset-assert 136) ;; guessed by decompiler - (enable symbol :offset-assert 140) ;; guessed by decompiler - (radius meters :offset-assert 144) - (world-sphere sphere :inline :offset-assert 156) + ((root trsqv :offset-assert 128) ;; guessed by decompiler + (part sparticle-launch-control :offset-assert 132) ;; guessed by decompiler + (sound ambient-sound :offset-assert 136) ;; guessed by decompiler + (mode (pointer sparticle-launch-group) :offset-assert 140) ;; guessed by decompiler + (enable symbol :offset-assert 144) ;; guessed by decompiler + (radius meters :offset-assert 148) + (world-sphere sphere :inline :offset-assert 160) ) :method-count-assert 16 :size-assert #xb0 :flag-assert #x10003000b0 (:methods - (part-spawner-method-9 () none 9) - (part-spawner-method-10 () none 10) - (part-spawner-method-11 () none 11) - (part-spawner-method-12 () none 12) - (part-spawner-method-13 () none 13) (part-spawner-method-14 () none 14) (part-spawner-method-15 () none 15) ) ) -|# -#| (deftype part-tracker (process) - ((root trsqv :offset-assert 124) ;; guessed by decompiler - (mat matrix :inline :offset-assert 140) - (part sparticle-launch-control :offset-assert 204) ;; guessed by decompiler - (callback (function part-tracker vector) :offset-assert 208) ;; guessed by decompiler - (linger-callback (function part-tracker vector) :offset-assert 212) ;; guessed by decompiler - (duration uint64 :offset-assert 220) ;; time-frame - (linger-duration uint64 :offset-assert 228) ;; time-frame - (start-time time-frame :offset-assert 236) ;; time-frame - (target uint64 :offset-assert 244) ;; handle - (target-joint int32 :offset-assert 252) - (offset vector :inline :offset-assert 268) - (userdata uint64 :offset-assert 284) - (user-time time-frame 2 :offset-assert 292) ;; guessed by decompiler - (user-vector vector :inline :offset-assert 316) - (user-handle uint32 2 :offset-assert 348) ;; guessed by decompiler + ((root trsqv :offset-assert 128) ;; guessed by decompiler + (mat matrix :inline :offset-assert 144) + (part sparticle-launch-control :offset-assert 208) ;; guessed by decompiler + (callback (function part-tracker vector) :offset-assert 212) ;; guessed by decompiler + (linger-callback (function part-tracker vector) :offset-assert 216) ;; guessed by decompiler + (duration uint64 :offset-assert 224) ;; time-frame + (linger-duration uint64 :offset-assert 232) ;; time-frame + (start-time time-frame :offset-assert 240) ;; time-frame + (target uint64 :offset-assert 248) ;; handle + (target-joint int32 :offset-assert 256) + (offset vector :inline :offset-assert 272) + (userdata uint64 :offset-assert 288) + (user-time time-frame 2 :offset-assert 296) ;; guessed by decompiler + (user-vector vector :inline :offset-assert 320) ;; two of these in jak1, seems like there's still space. + (user-handle uint32 2 :offset 352) ;; guessed by decompiler ) :method-count-assert 16 :size-assert #x168 :flag-assert #x1000f00168 ;; field userdata uses ~A with a 64-bit load (:methods - (part-tracker-method-9 () none 9) - (part-tracker-method-10 () none 10) - (part-tracker-method-11 () none 11) - (part-tracker-method-12 () none 12) - (part-tracker-method-13 () none 13) (part-tracker-method-14 () none 14) (part-tracker-method-15 () none 15) ) ) -|# -#| (deftype lightning-tracker (process) - ((root basic :offset-assert 124) - (lightning basic :offset-assert 128) - (callback basic :offset-assert 132) - (duration uint64 :offset-assert 140) - (start-time time-frame :offset-assert 148) - (offset0 vector :inline :offset-assert 156) - (offset1 vector :inline :offset-assert 172) - (target0 uint64 :offset-assert 188) - (target1 uint64 :offset-assert 196) - (target-joint0 int32 :offset-assert 204) - (target-joint1 int32 :offset-assert 208) - (sound uint32 :offset-assert 212) - (userdata uint64 :offset-assert 220) - (user-time UNKNOWN 2 :offset-assert 228) - (user-vector vector :inline :offset-assert 252) - (user-handle UNKNOWN 2 :offset-assert 284) + ((root basic :offset-assert 128) + (lightning basic :offset-assert 132) + (callback basic :offset-assert 136) + (duration uint64 :offset-assert 144) + (start-time time-frame :offset-assert 152) + (offset0 vector :inline :offset-assert 160) + (offset1 vector :inline :offset-assert 176) + (target0 uint64 :offset-assert 192) + (target1 uint64 :offset-assert 200) + (target-joint0 int32 :offset-assert 208) + (target-joint1 int32 :offset-assert 212) + (sound uint32 :offset-assert 216) + (userdata uint64 :offset-assert 224) + (user-time time-frame 2 :offset-assert 232) + (user-vector vector :inline :offset-assert 256) + (user-handle handle 2 :offset 288) ) :method-count-assert 17 :size-assert #x130 :flag-assert #x1100b00130 ;; field userdata uses ~A with a 64-bit load (:methods - (lightning-tracker-method-9 () none 9) - (lightning-tracker-method-10 () none 10) - (lightning-tracker-method-11 () none 11) - (lightning-tracker-method-12 () none 12) - (lightning-tracker-method-13 () none 13) (lightning-tracker-method-14 () none 14) (lightning-tracker-method-15 () none 15) (lightning-tracker-method-16 () none 16) ) ) -|# -#| (deftype touch-tracker (process-drawable) - ((duration uint64 :offset-assert 196) ;; time-frame - (target uint64 :offset-assert 204) ;; handle - (event symbol :offset-assert 212) ;; guessed by decompiler - (run-function (function object) :offset-assert 216) ;; guessed by decompiler - (callback (function touch-tracker none) :offset-assert 220) ;; guessed by decompiler - (event-mode basic :offset-assert 224) + ((duration time-frame :offset-assert 200) + (target handle :offset-assert 208) + (event symbol :offset-assert 216) ;; guessed by decompiler + (run-function (function object) :offset-assert 220) ;; guessed by decompiler + (callback (function touch-tracker none) :offset-assert 224) ;; guessed by decompiler + (event-mode basic :offset-assert 228) ) :method-count-assert 21 :size-assert #xe8 @@ -13669,16 +14844,14 @@ (touch-tracker-method-20 () none 20) ) ) -|# -#| (deftype swingpole (process-drawable) - ((edge-length meters :offset-assert 196) - (path-pos float :offset-assert 200) - (joint-track int32 :offset-assert 204) - (speed meters :offset-assert 208) - (dir vector :inline :offset-assert 220) - (sync sync-eased :inline :offset-assert 236) + ((edge-length meters :offset-assert 200) + (path-pos float :offset-assert 204) + (joint-track int32 :offset-assert 208) + (speed meters :offset-assert 212) + (dir vector :inline :offset-assert 224) + (sync sync-eased :inline :offset-assert 240) ) :method-count-assert 23 :size-assert #x11c @@ -13689,9 +14862,7 @@ (swingpole-method-22 () none 22) ) ) -|# -#| (deftype gui-query (structure) ((x-position int32 :offset-assert 0) (y-position int32 :offset-assert 4) @@ -13709,42 +14880,31 @@ (gui-query-method-10 () none 10) ;; (get-response (_type_) symbol 10) ) ) -|# -#| (deftype othercam (process) - ((hand uint64 :offset-assert 124) ;; handle - (old-global-mask process-mask :offset-assert 132) ;; guessed by decompiler - (mask-to-clear process-mask :offset-assert 136) ;; guessed by decompiler - (cam-joint-index int32 :offset-assert 140) - (old-pos vector :inline :offset-assert 156) - (old-mat-z vector :inline :offset-assert 172) - (had-valid-frame basic :offset-assert 188) - (border-value basic :offset-assert 192) - (die? symbol :offset-assert 196) ;; guessed by decompiler - (survive-anim-end? symbol :offset-assert 200) ;; guessed by decompiler - (spooling? symbol :offset-assert 204) ;; guessed by decompiler - (fov float :offset-assert 208) + ((hand handle :offset-assert 128) + (old-global-mask process-mask :offset-assert 136) ;; guessed by decompiler + (mask-to-clear process-mask :offset-assert 140) ;; guessed by decompiler + (cam-joint-index int32 :offset-assert 144) + (old-pos vector :inline :offset-assert 160) + (old-mat-z vector :inline :offset-assert 176) + (had-valid-frame basic :offset-assert 192) + (border-value basic :offset-assert 196) + (die? symbol :offset-assert 200) ;; guessed by decompiler + (survive-anim-end? symbol :offset-assert 204) ;; guessed by decompiler + (spooling? symbol :offset-assert 208) ;; guessed by decompiler + (fov float :offset-assert 212) ) :method-count-assert 14 :size-assert #xd8 :flag-assert #xe006000d8 - (:methods - (othercam-method-9 () none 9) - (othercam-method-10 () none 10) - (othercam-method-11 () none 11) - (othercam-method-12 () none 12) - (othercam-method-13 () none 13) - ) ) -|# -#| (deftype explosion (process-drawable) - ((start-time time-frame :offset-assert 196) - (duration uint32 :offset-assert 204) - (linger-duration uint32 :offset-assert 208) - (attack-id uint32 :offset-assert 212) + ((start-time time-frame :offset-assert 200) + (duration uint32 :offset-assert 208) + (linger-duration uint32 :offset-assert 212) + (attack-id uint32 :offset-assert 216) ) :method-count-assert 23 :size-assert #xdc @@ -13755,24 +14915,20 @@ (explosion-method-22 () none 22) ) ) -|# -#| (deftype explosion-init-params (structure) ((spawn-point vector :inline :offset-assert 0) (spawn-quat quaternion :inline :offset-assert 16) (radius float :offset-assert 32) (group basic :offset-assert 36) - (collide-with uint32 :offset-assert 40) - (penetrate-using uint64 :offset-assert 48) + (collide-with collide-spec :offset-assert 40) + (penetrate-using penetrate :offset-assert 48) ) :method-count-assert 9 :size-assert #x38 :flag-assert #x900000038 ) -|# -#| (deftype process-hidden (process) () :method-count-assert 15 @@ -13780,22 +14936,15 @@ :flag-assert #xf00000080 ;; Failed to read fields. (:methods - (process-hidden-method-9 () none 9) - (process-hidden-method-10 () none 10) - (process-hidden-method-11 () none 11) - (process-hidden-method-12 () none 12) - (process-hidden-method-13 () none 13) (process-hidden-method-14 () none 14) ;; (die () _type_ :state 14) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; trajectory-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype trajectory (structure) ((initial-position vector :inline :offset-assert 0) (initial-velocity vector :inline :offset-assert 16) @@ -13806,52 +14955,57 @@ :size-assert #x28 :flag-assert #x1200000028 (:methods - (trajectory-method-9 () none 9) ;; (eval-position! (_type_ float vector) vector 9) - (trajectory-method-10 () none 10) ;; (eval-velocity! (_type_ float vector) vector 10) - (trajectory-method-11 () none 11) ;; (setup-from-to-duration! (_type_ vector vector float float) none 11) - (trajectory-method-12 () none 12) ;; (setup-from-to-xz-vel! (_type_ vector vector float float) none 12) - (trajectory-method-13 () none 13) ;; (setup-from-to-y-vel! (_type_ vector vector float float) none 13) - (trajectory-method-14 () none 14) ;; (setup-from-to-height! (_type_ vector vector float float) none 14) - (trajectory-method-15 () none 15) ;; (debug-draw! (_type_) none 15) - (trajectory-method-16 () none 16) - (trajectory-method-17 () none 17) + (compute-trans-at-time (_type_ float vector) vector 9) + (compute-transv-at-time (_type_ float vector) vector 10) + (compute-time-until-apex (_type_) float 11) + (setup-from-to-duration! (_type_ vector vector float float) none 12) + (setup-from-to-xz-vel! (_type_ vector vector float float) none 13) + (setup-from-to-y-vel! (_type_ vector vector float float) none 14) + (setup-from-to-height! (_type_ vector vector float float) none 15) + (setup-from-to-duration-and-height! (_type_ vector vector float float) none 16) + (debug-draw (_type_) none 17) ) ) -|# -#| (deftype impact-control (structure) - () + ((process (pointer process-drawable) :offset-assert 0) + (radius float :offset-assert 4) + (joint int32 :offset-assert 8) + (collide-with collide-spec :offset-assert 12) + (start-time time-frame :offset-assert 16) + (trans vector 2 :inline :offset-assert 32) + (dir vector :inline :offset-assert 64) + ) :method-count-assert 12 :size-assert #x50 :flag-assert #xc00000050 ;; Failed to read fields. (:methods - (impact-control-method-9 () none 9) - (impact-control-method-10 () none 10) + (new (symbol type process-drawable int float collide-spec) _type_ 0) + (initialize (_type_ process-drawable int float collide-spec) impact-control :behavior process 9) + (update-from-cspace (_type_) none 10) (impact-control-method-11 () none 11) ) ) -|# -#| (deftype point-tracker (structure) - () + ((trans vector 2 :inline :offset-assert 0)) :method-count-assert 12 :size-assert #x20 :flag-assert #xc00000020 ;; Failed to read fields. (:methods - (point-tracker-method-9 () none 9) + (new (symbol type vector vector) _type_ 0) + (initialize (_type_ vector vector) point-tracker 9) (point-tracker-method-10 () none 10) (point-tracker-method-11 () none 11) ) ) -|# -#| (deftype combo-tracker (point-tracker) - () + ((target handle :offset-assert 32) + (move-start-time time-frame :offset-assert 40) + ) :method-count-assert 14 :size-assert #x30 :flag-assert #xe00000030 @@ -13861,9 +15015,7 @@ (combo-tracker-method-13 () none 13) ) ) -|# -#| (deftype traj2d-params (structure) ((x float :offset-assert 0) (y float :offset-assert 4) @@ -13876,9 +15028,7 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype traj3d-params (structure) ((gravity float :offset-assert 0) (initial-tilt float :offset-assert 4) @@ -13893,9 +15043,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype cubic-curve (structure) ((mat matrix :inline :offset-assert 0) ) @@ -13910,24 +15058,23 @@ (cubic-curve-method-13 () none 13) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-target-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype control-info (collide-shape-moving) -;; () -;; :flag-assert #x4400001910 -;; ) +(deftype control-info (collide-shape-moving) + ((pad uint8 :offset #x190f) + ) + :flag-assert #x4400001910 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-touch-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype touching-prim (structure) ((cprim collide-shape-prim :offset-assert 0) ;; guessed by decompiler (has-tri? symbol :offset-assert 4) ;; guessed by decompiler @@ -13937,9 +15084,7 @@ :size-assert #x68 :flag-assert #x900000068 ) -|# -#| (deftype touching-prims-entry (structure) ((next touching-prims-entry :offset-assert 0) (prev touching-prims-entry :offset-assert 4) @@ -13957,12 +15102,10 @@ (touching-prims-entry-method-11 () none 11) ;; (get-middle-of-bsphere-overlap (_type_ vector) vector 11) ) ) -|# -#| (deftype touching-prims-entry-pool (structure) ((head touching-prims-entry :offset-assert 0) - (nodes touching-prims-entry 64 :offset-assert 16) ;; guessed by decompiler + (nodes touching-prims-entry 64 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 13 :size-assert #x3c10 @@ -13971,13 +15114,11 @@ ;; (new (symbol type) _type_ 0) (touching-prims-entry-pool-method-9 () none 9) ;; (alloc-node (_type_) touching-prims-entry 9) (touching-prims-entry-pool-method-10 () none 10) ;; (get-free-node-count (_type_) int 10) - (touching-prims-entry-pool-method-11 () none 11) ;; (init-list! (_type_) none 11) + (init-list! (_type_) none 11) (touching-prims-entry-pool-method-12 () none 12) ;; (free-node (_type_ touching-prims-entry) touching-prims-entry 12) ) ) -|# -#| (deftype touching-shapes-entry (structure) ((cshape1 collide-shape :offset-assert 0) ;; guessed by decompiler (cshape2 collide-shape :offset-assert 4) ;; guessed by decompiler @@ -13986,25 +15127,24 @@ (handle1 uint64 :offset-assert 16) (handle2 uint64 :offset-assert 24) ) + :pack-me :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (touching-shapes-entry-method-9 () none 9) ;; (dummy-9 (_type_) none 9) - (touching-shapes-entry-method-10 () none 10) ;; (get-touched-shape (_type_ collide-shape) collide-shape 10) + (get-head (_type_) touching-prims-entry 9) ;; (dummy-9 (_type_) none 9) + (get-next (_type_ touching-shapes-entry) touching-prims-entry 10) ;; (get-touched-shape (_type_ collide-shape) collide-shape 10) (touching-shapes-entry-method-11 () none 11) ;; (dummy-11 () none 11) (touching-shapes-entry-method-12 () none 12) ;; (prims-touching? (_type_ collide-shape-moving uint) touching-prims-entry 12) (touching-shapes-entry-method-13 () none 13) ;; (prims-touching-action? (_type_ collide-shape collide-action collide-action) touching-prims-entry 13) (touching-shapes-entry-method-14 () none 14) ;; (dummy-14 () none 14) ) ) -|# -#| (deftype touching-list (structure) ((num-touching-shapes int32 :offset-assert 0) (resolve-u int8 :offset-assert 4) - (touching-shapes touching-shapes-entry 32 :offset-assert 8) ;; guessed by decompiler + (touching-shapes touching-shapes-entry 32 :inline :offset-assert 8) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x408 @@ -14018,46 +15158,42 @@ (touching-list-method-13 () none 13) ;; (get-shapes-entry (_type_ collide-shape collide-shape) touching-shapes-entry 13) ) ) -|# -;; (define-extern *touching-prims-entry-pool* object) ;; touching-prims-entry-pool -;; (define-extern *touching-list* object) ;; touching-list +(define-extern *touching-prims-entry-pool* touching-prims-entry-pool) +(define-extern *touching-list* touching-list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-edge-grab-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype pilot-edge-grab-info (structure) ((local-pos vector :inline :offset-assert 0) (local-dir vector :inline :offset-assert 16) - (handle uint64 :offset-assert 32) + (handle handle :offset-assert 32) ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ) -|# -#| (deftype edge-grab-info (structure) - ((world-vertex vector 8 :offset-assert 0) ;; guessed by decompiler - (local-vertex vector 8 :offset-assert 128) ;; guessed by decompiler + ((world-vertex vector 8 :inline :offset-assert 0) ;; guessed by decompiler + (local-vertex vector 8 :inline :offset-assert 128) ;; guessed by decompiler (status uint64 :offset-assert 256) (actor-cshape-prim-offset int32 :offset-assert 264) (actor-handle uint64 :offset-assert 272) ;; handle (hanging-matrix matrix :inline :offset-assert 288) - (edge-vertex vector 2 :offset-assert 0) ;; guessed by decompiler - (center-hold vector :inline :offset-assert 32) - (tri-vertex vector 3 :offset-assert 48) ;; guessed by decompiler - (adjacent-edge-left-vertex vector :inline :offset-assert 96) - (adjacent-edge-right-vertex vector :inline :offset-assert 112) + (edge-vertex vector 2 :inline :offset 0) ;; guessed by decompiler + (center-hold vector :inline :offset 32) + (tri-vertex vector 3 :inline :offset 48) ;; guessed by decompiler + (adjacent-edge-left-vertex vector :inline :offset 96) + (adjacent-edge-right-vertex vector :inline :offset 112) (left-hand-hold vector :inline :offset-assert 352) (right-hand-hold vector :inline :offset-assert 368) (center-hold-old vector :inline :offset-assert 384) (edge-tri-pat uint32 :offset-assert 400) - (found-edge? basic :offset-assert 404) - (pilot-edge-grab? basic :offset-assert 408) + (found-edge? symbol :offset-assert 404) + (pilot-edge-grab? symbol :offset-assert 408) (pilot-edge-grab pilot-edge-grab-info :inline :offset-assert 416) (pilot-start-grab-pos vector :inline :offset-assert 464) (pilot-grab-interp float :offset-assert 480) @@ -14070,9 +15206,8 @@ (edge-grab-info-method-10 () none 10) ;; (debug-draw (_type_) symbol 10) ) ) -|# -#| +(declare-type collide-cache-tri structure) (deftype collide-edge-tri (structure) ((ctri collide-cache-tri :offset-assert 0) ;; guessed by decompiler (normal vector :inline :offset-assert 16) @@ -14081,9 +15216,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-edge-edge (structure) ((ignore basic :offset-assert 0) (etri collide-edge-tri :offset-assert 4) @@ -14098,9 +15231,7 @@ (collide-edge-edge-method-9 () none 9) ) ) -|# -#| (deftype collide-edge-hold-item (structure) ((next collide-edge-hold-item :offset-assert 0) (rating float :offset-assert 4) @@ -14113,15 +15244,13 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype collide-edge-hold-list (structure) ((num-allocs uint32 :offset-assert 0) (num-attempts uint32 :offset-assert 4) (head collide-edge-hold-item :offset-assert 8) - (items collide-edge-hold-item 32 :offset-assert 16) ;; guessed by decompiler - (attempts qword 32 :offset-assert 1552) ;; guessed by decompiler + (items collide-edge-hold-item 32 :inline :offset-assert 16) ;; guessed by decompiler + (attempts qword 32 :inline :offset-assert 1552) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x810 @@ -14131,31 +15260,29 @@ (collide-edge-hold-list-method-10 () none 10) ;; (add-to-list! (_type_ collide-edge-hold-item) none 10) ) ) -|# -#| (deftype collide-edge-spec (structure) - ((split-dists UNKNOWN 2 :offset-assert 0) + ((split-dists float 2 :offset-assert 0) (outward-offset vector :inline :offset-assert 16) (flags uint64 :offset-assert 32) - (ignore-pat uint32 :offset-assert 40) + (ignore-pat pat-surface :offset-assert 40) (max-dist-sqrd-to-outward-pt float :offset-assert 44) (max-dir-cosa-delta float :offset-assert 48) (max-dir-cosa-player float :offset-assert 52) - (touching-segment uint32 :offset-assert 56) + (touching-segment symbol :offset-assert 56) (local-cache-fill-box bounding-box :inline :offset-assert 64) (local-within-reach-box bounding-box :inline :offset-assert 96) - (local-player-spheres UNKNOWN 12 :offset-assert 128) - (local-player-hanging-spheres UNKNOWN 6 :offset-assert 128) - (local-player-leap-up-spheres UNKNOWN 6 :offset-assert 224) + (local-player-spheres sphere 12 :inline :offset 128) + (local-player-hanging-spheres sphere 6 :inline :offset 128) + (local-player-leap-up-spheres sphere 6 :inline :offset 224) ) :method-count-assert 9 :size-assert #x140 :flag-assert #x900000140 ) -|# -#| +(declare-type collide-cache basic) + (deftype collide-edge-work (structure) ((ccache collide-cache :offset-assert 0) ;; guessed by decompiler (cshape collide-shape :offset-assert 4) ;; guessed by decompiler @@ -14167,14 +15294,14 @@ (within-reach-box4w bounding-box4w :inline :offset-assert 96) (search-pt vector :inline :offset-assert 128) (search-dir-vec vector :inline :offset-assert 144) - (world-player-spheres sphere 12 :offset-assert 160) ;; guessed by decompiler - (world-player-hanging-spheres sphere 6 :offset-assert 160) ;; guessed by decompiler - (world-player-leap-up-spheres sphere 6 :offset-assert 256) ;; guessed by decompiler + (world-player-spheres sphere 12 :inline :offset-assert 160) ;; guessed by decompiler + (world-player-hanging-spheres sphere 6 :inline :offset 160) ;; guessed by decompiler + (world-player-leap-up-spheres sphere 6 :inline :offset 256) ;; guessed by decompiler (spec collide-edge-spec :inline :offset-assert 352) (process uint32 :offset-assert 672) - (verts vector 64 :offset-assert 688) ;; guessed by decompiler - (edges collide-edge-edge 96 :offset-assert 1712) ;; guessed by decompiler - (tris collide-edge-tri 48 :offset-assert 6320) ;; guessed by decompiler + (verts vector 64 :inline :offset-assert 688) ;; guessed by decompiler + (edges collide-edge-edge 96 :inline :offset-assert 1712) ;; guessed by decompiler + (tris collide-edge-tri 48 :inline :offset-assert 6320) ;; guessed by decompiler (hold-list collide-edge-hold-list :inline :offset-assert 7856) ) :method-count-assert 21 @@ -14195,75 +15322,79 @@ (collide-edge-work-method-20 () none 20) ) ) -|# -;; (define-extern *collide-edge-spec* object) -;; (define-extern *collide-edge-work* object) ;; collide-edge-work -;; (define-extern *edge-grab-info* object) ;; edge-grab-info +(define-extern *collide-edge-spec* collide-edge-spec) +(define-extern *collide-edge-work* collide-edge-work) +(define-extern *edge-grab-info* edge-grab-info) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-drawable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cspace-by-name-no-fail function) ;; (function process-drawable string cspace) -;; (define-extern cspace-index-by-name-no-fail function) ;; (function process-drawable string int) -;; (define-extern num-func-none function) ;; (function joint-control-channel float float float) -;; (define-extern num-func-+! function) ;; (function joint-control-channel float float float) -;; (define-extern num-func--! function) ;; (function joint-control-channel float float float) -;; (define-extern num-func-loop! function) ;; (function joint-control-channel float float float) -;; (define-extern num-func-loop-speedless! function) -;; (define-extern num-func-seek! function) ;; (function joint-control-channel float float float) -;; (define-extern num-func-blend-in! function) ;; (function joint-control-channel float float float) -;; (define-extern joint-channel-float-delete! function) -;; (define-extern num-func-interp-play! function) -;; (define-extern num-func-interp1-play! function) -;; (define-extern num-func-chan function) ;; (function joint-control-channel float float float) -;; (define-extern num-func-identity function) ;; (function joint-control-channel float float float) +(define-extern cspace-by-name-no-fail (function process-drawable string cspace)) +(define-extern cspace-index-by-name-no-fail (function process-drawable string int)) +(define-extern num-func-none (function joint-control-channel float float float)) +(define-extern num-func-+! (function joint-control-channel float float float)) +(define-extern num-func--! (function joint-control-channel float float float)) +(define-extern num-func-loop! (function joint-control-channel float float float)) +(define-extern num-func-loop-speedless! (function joint-control-channel float float float)) +(define-extern num-func-seek! (function joint-control-channel float float float)) +(define-extern num-func-blend-in! (function joint-control-channel float float float)) +(define-extern joint-channel-float-delete! (function joint-control-channel none)) +(define-extern num-func-interp-play! (function joint-control-channel float float float float)) +(define-extern num-func-interp1-play! (function joint-control-channel float float float float)) +(define-extern num-func-chan (function joint-control-channel float float float)) +(define-extern num-func-identity (function joint-control-channel float float float)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-focusable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum focus-status + :bitfield #t + :type uint32 + (fs0 0) ;; if set, all collide checks fail + (fs1 1) ;; if set, all collide checks fail + (fs2 2) + ) + (deftype process-focusable (process-drawable) - ((focus-status uint32 :offset-assert 196) + ((focus-status focus-status :offset-assert 200) ) :method-count-assert 27 :size-assert #xcc :flag-assert #x1b005000cc (:methods - (process-focusable-method-20 () none 20) - (process-focusable-method-21 () none 21) - (process-focusable-method-22 () none 22) - (process-focusable-method-23 () none 23) - (process-focusable-method-24 () none 24) - (process-focusable-method-25 () none 25) - (process-focusable-method-26 () none 26) + (get-trans (_type_ int) vector 20) + (get-quat (_type_) quaternion 21) + (get-transv (_type_) vector 22) + (process-focusable-method-23 (_type_) none 23) + (process-focusable-method-24 (_type_) none 24) + (process-focusable-method-25 (_type_) none 25) + (process-focusable-method-26 (_type_) none 26) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; process-taskable-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype process-taskable (process-focusable) - ((task basic :offset-assert 200) - (ambient ambient-control :inline :offset-assert 204) - (neck-joint-index int32 :offset-assert 220) - (talk-message game-text-id :offset-assert 224) ;; guessed by decompiler - (bounce-away symbol :offset-assert 228) ;; guessed by decompiler - (will-talk symbol :offset-assert 232) ;; guessed by decompiler - (look-at-me basic :offset-assert 236) - (hide-during-movie basic :offset-assert 240) - (talk-distance meters :offset-assert 244) - (talk-height meters :offset-assert 248) - (last-talk uint64 :offset-assert 252) ;; time-frame - (want-to-say uint64 :offset-assert 260) - (birth-time time-frame :offset-assert 268) - (slave uint64 :offset-assert 276) + ((task basic :offset-assert 204) + (ambient ambient-control :inline :offset-assert 208) + (neck-joint-index int32 :offset-assert 224) + (talk-message game-text-id :offset-assert 228) ;; guessed by decompiler + (bounce-away symbol :offset-assert 232) ;; guessed by decompiler + (will-talk symbol :offset-assert 236) ;; guessed by decompiler + (look-at-me symbol :offset-assert 240) + (hide-during-movie symbol :offset-assert 244) + (talk-distance meters :offset-assert 248) + (talk-height meters :offset-assert 252) + (last-talk time-frame :offset-assert 256) ;; time-frame + (want-to-say uint64 :offset-assert 264) + (birth-time time-frame :offset-assert 272) + (slave handle :offset-assert 280) ) :method-count-assert 38 :size-assert #x120 @@ -14282,103 +15413,95 @@ (process-taskable-method-37 () none 37) ;; (push-reject-anim (_type_) none 37) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; focus ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; skipped : handle creation is different, want to grab more. +;; otherwise looks good + (deftype focus (structure) - ((handle uint64 :offset-assert 0) - (collide-with uint32 :offset-assert 8) + ((handle handle :offset-assert 0) + (collide-with collide-spec :offset-assert 8) ) :method-count-assert 13 :size-assert #xc :flag-assert #xd0000000c (:methods - (focus-method-9 () none 9) - (focus-method-10 () none 10) - (focus-method-11 () none 11) - (focus-method-12 () none 12) + (clear-focused (_type_) none 9) + (collide-check? (_type_ process-focusable) object 10) + (reset-to-collide-spec (_type_ collide-spec) none 11) + (try-update-focus (_type_ process-focusable) symbol 12) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; effect-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum effect-control-flag + :type uint32 + :bitfield #t + ) + (deftype effect-control (basic) - ((process process-drawable :offset-assert 4) ;; guessed by decompiler - (flags uint32 :offset-assert 8) - (last-frame-group art-joint-anim :offset-assert 12) ;; guessed by decompiler - (last-frame-num float :offset-assert 16) - (channel-offset int32 :offset-assert 20) - (res res-lump :offset-assert 24) ;; guessed by decompiler - (name (pointer res-tag) :offset-assert 28) ;; guessed by decompiler - (param uint32 :offset-assert 32) + ((process process-drawable :offset-assert 4) ;; guessed by decompiler + (flags effect-control-flag :offset-assert 8) + (last-frame-group art-joint-anim :offset-assert 12) ;; guessed by decompiler + (last-frame-num float :offset-assert 16) + (channel-offset int32 :offset-assert 20) + (res res-lump :offset-assert 24) ;; guessed by decompiler + (name (pointer res-tag) :offset-assert 28) ;; guessed by decompiler + (param uint32 :offset-assert 32) ) :method-count-assert 15 :size-assert #x24 :flag-assert #xf00000024 (:methods - ;; (new (symbol type process-drawable) _type_ 0) + (new (symbol type process-drawable) _type_ 0) (effect-control-method-9 () none 9) ;; (TODO-RENAME-9 (_type_) none 9) (effect-control-method-10 () none 10) ;; (dummy-10 (_type_ symbol float int) object 10) (effect-control-method-11 () none 11) ;; (dummy-11 (_type_ symbol float int basic pat-surface) none 11) (effect-control-method-12 () none 12) ;; (dummy-12 (_type_ symbol float int basic sound-name) int 12) - (effect-control-method-13 () none 13) ;; (set-channel-offset! (_type_ int) none 13) + (set-channel-offset! (_type_ int) none 13) (effect-control-method-14 () none 14) ;; (TODO-RENAME-14 (_type_ float float float) none 14) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-frag-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-frag-vertex (vector) - ((data float 4 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (w float :offset-assert 12) - (quad uint128 :offset-assert 0) - ) + () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype collide-frag-mesh (basic) ((packed-data uint32 :offset-assert 4) (pat-array uint32 :offset-assert 8) (strip-data-len uint16 :offset-assert 12) (poly-count uint16 :offset-assert 14) (base-trans vector4w :inline :offset-assert 16) ;; vector :inline - (vertex-count uint8 :offset-assert 28) - (vertex-data-qwc uint8 :offset-assert 29) - (total-qwc uint8 :offset-assert 30) - (unused uint8 :offset-assert 31) + (vertex-count uint8 :offset 28) + (vertex-data-qwc uint8 :offset 29) + (total-qwc uint8 :offset 30) + (unused uint8 :offset 31) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype collide-fragment (drawable) - ((mesh collide-frag-mesh :offset-assert 8) ;; guessed by decompiler - (collide-new basic :offset-assert 12) + ((mesh collide-frag-mesh :offset 8) ;; guessed by decompiler + (collide-new basic :offset 12) ) :method-count-assert 17 :size-assert #x20 @@ -14386,11 +15509,10 @@ (:methods ) ) -|# -#| (deftype drawable-inline-array-collide-fragment (drawable-inline-array) - ((data collide-fragment 1 :offset-assert 36) ;; guessed by decompiler + ((data collide-fragment 1 :inline :offset-assert 32) ;; guessed by decompiler + (pad uint32) ) :method-count-assert 17 :size-assert #x44 @@ -14398,32 +15520,28 @@ (:methods ) ) -|# -;; (deftype drawable-tree-collide-fragment (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-collide-fragment (drawable-tree) + () + :flag-assert #x1100000020 + ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-hash-scratch (structure) - ((collidable-bits UNKNOWN 128 :offset-assert 0) - (poly-bits UNKNOWN 2 :offset-assert 0) - (id-bits UNKNOWN 512 :offset-assert 0) + ((collidable-bits uint128 128 :offset-assert 0) + (poly-bits uint64 2 :offset 0) + (id-bits uint32 512 :offset 0) (tris uint32 :offset-assert 2048) ) :method-count-assert 9 :size-assert #x804 :flag-assert #x900000804 ) -|# -#| (deftype collide-hash-bucket (structure) ((index int16 :offset-assert 0) (count int16 :offset-assert 2) @@ -14432,9 +15550,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-item (structure) ((id uint32 :offset-assert 0) (collidable basic :offset-assert 4) @@ -14443,54 +15559,49 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype collide-hash-poly (structure) - ((data UNKNOWN 4 :offset-assert 0) - (vert-index0 uint8 :offset-assert 0) - (vert-index1 uint8 :offset-assert 1) - (vert-index2 uint8 :offset-assert 2) - (pat-index uint8 :offset-assert 3) - (word uint32 :offset-assert 0) + ((data uint8 4 :offset-assert 0 :score -1) + (vert-index0 uint8 :offset 0) + (vert-index1 uint8 :offset 1) + (vert-index2 uint8 :offset 2) + (pat-index uint8 :offset 3) + (word uint32 :offset 0) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-fragment-stats (structure) ((num-verts uint16 :offset-assert 0) (num-polys uint8 :offset-assert 2) (poly-count uint8 :offset-assert 3) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype collide-hash-fragment (drawable) - ((num-buckets uint16 :offset-assert 4) - (num-indices uint16 :offset-assert 6) - (pat-array uint32 :offset-assert 8) - (bucket-array uint32 :offset-assert 12) + ((num-buckets uint16 :offset 4) + (num-indices uint16 :offset 6) + (pat-array uint32 :offset 8) + (bucket-array uint32 :offset 12) (grid-step vector :inline :offset-assert 32) (bbox bounding-box :inline :offset-assert 48) (bbox4w bounding-box4w :inline :offset-assert 80) - (axis-scale vector :inline :offset-assert 64) - (avg-extents vector :inline :offset-assert 80) - (dimension-array UNKNOWN 4 :offset-assert 44) - (stats collide-hash-fragment-stats :inline :offset-assert 60) - (num-verts uint16 :offset-assert 60) - (num-polys uint8 :offset-assert 62) - (poly-count uint8 :offset-assert 63) - (poly-array uint32 :offset-assert 76) - (vert-array uint32 :offset-assert 92) - (index-array uint32 :offset-assert 108) + (axis-scale vector :inline :offset 64) + (avg-extents vector :inline :offset 80) + (dimension-array uint32 4 :offset 44) ;; ? + (stats collide-hash-fragment-stats :inline :offset 60) + (num-verts uint16 :offset 60) + (num-polys uint8 :offset 62) + (poly-count uint8 :offset 63) + (poly-array uint32 :offset 76) + (vert-array uint32 :offset 92) + (index-array uint32 :offset 108) ) :method-count-assert 17 :size-assert #x70 @@ -14498,36 +15609,28 @@ (:methods ) ) -|# -#| (deftype collide-hash-fragment-array (array) - ((type basic :offset-assert 0) - (length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (content-type basic :offset-assert 12) - ) + () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype collide-hash (drawable) - ((num-ids uint16 :offset-assert 4) - (id-count uint16 :offset-assert 6) - (num-buckets uint32 :offset-assert 8) - (qwc-id-bits uint32 :offset-assert 12) - (grid-step vector :inline :offset-assert 16) + ((num-ids uint16 :offset 4) + (id-count uint16 :offset 6) + (num-buckets uint32 :offset 8) + (qwc-id-bits uint32 :offset 12) + (grid-step vector :inline :offset 16) (bbox bounding-box :inline :offset-assert 32) (bbox4w bounding-box4w :inline :offset-assert 64) - (axis-scale vector :inline :offset-assert 48) - (avg-extents vector :inline :offset-assert 64) - (bucket-array uint32 :offset-assert 44) - (item-array uint32 :offset-assert 60) - (dimension-array UNKNOWN 3 :offset-assert 76) - (num-items uint32 :offset-assert 92) + (axis-scale vector :inline :offset 48) + (avg-extents vector :inline :offset 64) + (bucket-array uint32 :offset 44) + (item-array uint32 :offset 60) + (dimension-array uint32 3 :offset 76) ;; ? + (num-items uint32 :offset 92) ) :method-count-assert 17 :size-assert #x60 @@ -14535,19 +15638,17 @@ (:methods ) ) -|# -;; (define-extern *collide-list-boxes* object) -;; (define-extern *collide-hash-fragments* object) -;; (define-extern *collide-hash-fragments-tfrag* object) -;; (define-extern *collide-hash-fragments-instance* object) -;; (define-extern *already-printed-exeeded-max-cache-tris* object) ;; symbol +(define-extern *collide-list-boxes* object) +(define-extern *collide-hash-fragments* object) +(define-extern *collide-hash-fragments-tfrag* object) +(define-extern *collide-hash-fragments-instance* object) +(define-extern *already-printed-exeeded-max-cache-tris* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; chain-physics-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype chain-physics-setup (structure) ((joint-index int32 :offset-assert 0) ) @@ -14555,9 +15656,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype chain-physics-joint (structure) ((position vector :inline :offset-assert 0) (velocity vector :inline :offset-assert 16) @@ -14568,11 +15667,9 @@ :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype chain-physics (basic) - ((chain-joints UNKNOWN 20 :offset-assert 16) + ((chain-joints chain-physics-joint 20 :inline :offset-assert 16) (num-joints uint8 :offset-assert 1296) (root-joint-index uint8 :offset-assert 1297) (joint-length float :offset-assert 1300) @@ -14603,43 +15700,46 @@ (chain-physics-method-17 () none 17) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; projectile-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum projectile-options + :type uint64 + :bitfield #t + ) + (deftype projectile (process-drawable) - ((starting-pos vector :inline :offset-assert 204) - (starting-dir vector :inline :offset-assert 220) - (target-pos vector :inline :offset-assert 236) - (base-target-pos vector :inline :offset-assert 252) - (pre-move-transv vector :inline :offset-assert 268) - (timeout uint64 :offset-assert 284) ;; time-frame - (spawn-time time-frame :offset-assert 292) - (options uint64 :offset-assert 300) - (last-target uint64 :offset-assert 308) ;; handle - (notify-handle uint64 :offset-assert 316) ;; handle - (owner-handle uint64 :offset-assert 324) - (ignore-handle uint64 :offset-assert 332) - (update-velocity (function projectile none) :offset-assert 340) ;; guessed by decompiler - (move basic :offset-assert 344) - (pick-target basic :offset-assert 348) - (max-speed float :offset-assert 352) - (old-dist float 16 :offset-assert 356) ;; guessed by decompiler - (old-dist-count int32 :offset-assert 420) - (hits int32 :offset-assert 424) - (max-hits int32 :offset-assert 428) - (tween float :offset-assert 432) - (attack-mode symbol :offset-assert 436) ;; guessed by decompiler - (attack-id uint32 :offset-assert 440) - (damage float :offset-assert 444) - (charge-level float :offset-assert 448) - (sound-id sound-id :offset-assert 452) ;; guessed by decompiler - (stop-speed meters :offset-assert 456) - (invinc-time time-frame :offset-assert 460) + ((starting-pos vector :inline :offset-assert 208) + (starting-dir vector :inline :offset-assert 224) + (target-pos vector :inline :offset-assert 240) + (base-target-pos vector :inline :offset-assert 256) + (pre-move-transv vector :inline :offset-assert 272) + (timeout time-frame :offset-assert 288) + (spawn-time time-frame :offset-assert 296) + (options projectile-options :offset-assert 304) + (last-target handle :offset-assert 312) + (notify-handle handle :offset-assert 320) + (owner-handle handle :offset-assert 328) + (ignore-handle handle :offset-assert 336) + (update-velocity (function projectile none) :offset-assert 344) ;; guessed by decompiler + (move basic :offset-assert 348) + (pick-target basic :offset-assert 352) + (max-speed float :offset-assert 356) + (old-dist float 16 :offset-assert 360) ;; guessed by decompiler + (old-dist-count int32 :offset-assert 424) + (hits int32 :offset-assert 428) + (max-hits int32 :offset-assert 432) + (tween float :offset-assert 436) + (attack-mode symbol :offset-assert 440) ;; guessed by decompiler + (attack-id uint32 :offset-assert 444) + (damage float :offset-assert 448) + (charge-level float :offset-assert 452) + (sound-id sound-id :offset-assert 456) ;; guessed by decompiler + (stop-speed meters :offset-assert 460) + (invinc-time time-frame :offset-assert 464) ) :method-count-assert 40 :size-assert #x1d8 @@ -14667,31 +15767,27 @@ (projectile-method-39 () none 39) ) ) -|# -#| (deftype projectile-init-by-other-params (structure) ((ent basic :offset-assert 0) (charge float :offset-assert 4) (attack-id uint32 :offset-assert 8) - (options uint64 :offset-assert 16) - (notify-handle uint64 :offset-assert 24) - (owner-handle uint64 :offset-assert 32) - (ignore-handle uint64 :offset-assert 40) + (options projectile-options :offset-assert 16) + (notify-handle handle :offset-assert 24) + (owner-handle handle :offset-assert 32) + (ignore-handle handle :offset-assert 40) (pos vector :inline :offset-assert 48) (vel vector :inline :offset-assert 64) - (timeout uint64 :offset-assert 80) + (timeout handle :offset-assert 80) ) :method-count-assert 9 :size-assert #x58 :flag-assert #x900000058 ) -|# -#| (deftype projectile-bounce (projectile) - ((played-bounce-time time-frame :offset-assert 468) - (tumble-quat quaternion :inline :offset-assert 476) + ((played-bounce-time time-frame :offset-assert 472) + (tumble-quat quaternion :inline :offset-assert 480) ) :method-count-assert 42 :size-assert #x1f0 @@ -14701,85 +15797,92 @@ (projectile-bounce-method-41 () none 41) ) ) -|# -;; (define-extern spawn-projectile function) +(define-extern spawn-projectile (function type projectile-init-by-other-params process-tree dead-pool (pointer process))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; find-nearest-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; empty! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; target-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; missing ref test - there's a useless array defintion with a list of not-yet-defined types +;; and this doesn't work in goalc. + +(declare-type sidekick basic) +(declare-type racer-info basic) +(declare-type tube-info basic) +(declare-type flut-info basic) + (deftype target (process-focusable) - ((control control-info :offset-assert 124) ;; guessed by decompiler - (skel2 basic :offset-assert 200) - (shadow-backup basic :offset-assert 204) - (target-flags uint32 :offset-assert 184) - (game game-info :offset-assert 208) ;; guessed by decompiler - (neck joint-mod :offset-assert 212) ;; guessed by decompiler - (head basic :offset-assert 216) - (upper-body basic :offset-assert 220) - (horns basic :offset-assert 224) - (hair UNKNOWN 2 :offset-assert 228) - (darkjak-interp float :offset-assert 236) - (darkjak-giant-interp float :offset-assert 240) - (arm-ik UNKNOWN 2 :offset-assert 244) - (leg-ik UNKNOWN 2 :offset-assert 252) - (foot UNKNOWN 2 :offset-assert 260) - (init-time time-frame :offset-assert 268) - (teleport-time time-frame :offset-assert 276) - (state-hook-time time-frame :offset-assert 284) ;; time-frame - (state-hook (function none :behavior target) :offset-assert 292) ;; guessed by decompiler - (cam-user-mode symbol :offset-assert 296) ;; guessed by decompiler - (sidekick (pointer sidekick) :offset-assert 300) ;; guessed by decompiler - (manipy (pointer manipy) :offset-assert 304) ;; guessed by decompiler - (mirror uint32 :offset-assert 308) - (attack-info attack-info :inline :offset-assert 316) - (attack-info-rec attack-info :inline :offset-assert 476) - (attack-info-old UNKNOWN 8 :offset-assert 636) - (anim-seed uint64 :offset-assert 1916) - (alt-cam-pos vector :inline :offset-assert 1932) - (current-level level :offset-assert 1948) ;; guessed by decompiler - (saved-pos transformq :inline :offset-assert 1964) - (saved-owner uint64 :offset-assert 2012) - (alt-neck-pos vector :inline :offset-assert 2028) - (focus-search basic :offset-assert 2044) - (excitement float :offset-assert 2048) - (shock-effect-time time-frame :offset-assert 2052) - (beard? basic :offset-assert 2060) - (spool-anim basic :offset-assert 2064) - (ambient-time time-frame :offset-assert 2068) - (fp-hud uint64 :offset-assert 2076) ;; handle - (no-load-wait uint64 :offset-assert 2084) ;; time-frame - (no-look-around-wait uint64 :offset-assert 2092) ;; time-frame - (burn-proc uint64 :offset-assert 2100) ;; handle - (pre-joint-hook basic :offset-assert 2108) - (notify uint64 :offset-assert 2116) - (mode-cache basic :offset-assert 2124) - (mode-param1 uint64 :offset-assert 2132) - (mode-param2 uint64 :offset-assert 2140) - (mode-param3 uint64 :offset-assert 2148) - (tobot-state basic :offset-assert 2156) - (tobot? basic :offset-assert 2160) - (tobot-recorder basic :offset-assert 2164) - (color-effect basic :offset-assert 2168) - (color-effect-start-time time-frame :offset-assert 2172) - (color-effect-duration uint64 :offset-assert 2180) - (racer racer-info :offset-assert 2188) ;; guessed by decompiler - (tube tube-info :offset-assert 2192) ;; guessed by decompiler - (flut flut-info :offset-assert 2196) ;; guessed by decompiler - (board basic :offset-assert 2200) - (pilot basic :offset-assert 2204) - (gun basic :offset-assert 2208) - (mech basic :offset-assert 2212) - (turret basic :offset-assert 2216) - (darkjak basic :offset-assert 2220) - (indax basic :offset-assert 2224) + ((control control-info :offset 128) ;; guessed by decompiler + (skel2 basic :offset-assert 204) + (shadow-backup basic :offset-assert 208) + (target-flags uint32 :offset 188) + (game game-info :offset-assert 212) ;; guessed by decompiler + (neck joint-mod :offset-assert 216) ;; guessed by decompiler + (head basic :offset-assert 220) + (upper-body basic :offset-assert 224) + (horns basic :offset-assert 228) + (hair basic 2 :offset-assert 232) + (darkjak-interp float :offset-assert 240) + (darkjak-giant-interp float :offset-assert 244) + (arm-ik basic 2 :offset-assert 248) + (leg-ik basic 2 :offset-assert 256) + (foot basic 2 :offset-assert 264) + (init-time time-frame :offset-assert 272) + (teleport-time time-frame :offset-assert 280) + (state-hook-time time-frame :offset-assert 288) ;; time-frame + (state-hook (function none :behavior target) :offset-assert 296) ;; guessed by decompiler + (cam-user-mode symbol :offset-assert 300) ;; guessed by decompiler + (sidekick (pointer sidekick) :offset-assert 304) ;; guessed by decompiler + (manipy (pointer manipy) :offset-assert 308) ;; guessed by decompiler + (mirror uint32 :offset-assert 312) + (attack-info attack-info :inline :offset-assert 320) + (attack-info-rec attack-info :inline :offset-assert 480) + (attack-info-old attack-info 8 :inline :offset-assert 640) + (anim-seed uint64 :offset-assert 1920) + (alt-cam-pos vector :inline :offset-assert 1936) + (current-level level :offset-assert 1952) ;; guessed by decompiler + (saved-pos transformq :inline :offset-assert 1968) + (saved-owner uint64 :offset-assert 2016) + (alt-neck-pos vector :inline :offset-assert 2032) + (focus-search basic :offset-assert 2048) + (excitement float :offset-assert 2052) + (shock-effect-time time-frame :offset-assert 2056) + (beard? basic :offset-assert 2064) + (spool-anim basic :offset-assert 2068) + (ambient-time time-frame :offset-assert 2072) + (fp-hud uint64 :offset-assert 2080) ;; handle + (no-load-wait uint64 :offset-assert 2088) ;; time-frame + (no-look-around-wait uint64 :offset-assert 2096) ;; time-frame + (burn-proc uint64 :offset-assert 2104) ;; handle + (pre-joint-hook basic :offset-assert 2112) + (notify uint64 :offset-assert 2120) + (mode-cache basic :offset-assert 2128) + (mode-param1 uint64 :offset-assert 2136) + (mode-param2 uint64 :offset-assert 2144) + (mode-param3 uint64 :offset-assert 2152) + (tobot-state basic :offset-assert 2160) + (tobot? basic :offset-assert 2164) + (tobot-recorder basic :offset-assert 2168) + (color-effect basic :offset-assert 2172) + (color-effect-start-time time-frame :offset-assert 2176) + (color-effect-duration uint64 :offset-assert 2184) + (racer racer-info :offset-assert 2192) ;; guessed by decompiler + (tube tube-info :offset-assert 2196) ;; guessed by decompiler + (flut flut-info :offset-assert 2200) ;; guessed by decompiler + (board basic :offset-assert 2204) + (pilot basic :offset-assert 2208) + (gun basic :offset-assert 2212) + (mech basic :offset-assert 2216) + (turret basic :offset-assert 2220) + (darkjak basic :offset-assert 2224) + (indax basic :offset-assert 2228) ) :method-count-assert 29 :size-assert #x8b8 @@ -14790,18 +15893,16 @@ (target-method-28 () none 28) ) ) -|# -#| (deftype sidekick (process-drawable) - ((control control-info :offset-assert 124) ;; guessed by decompiler - (anim-seed uint64 :offset-assert 204) - (shadow-in-movie? symbol :offset-assert 212) ;; guessed by decompiler - (special-anim-time time-frame :offset-assert 220) - (special-anim-interp float :offset-assert 228) - (special-anim-frame float :offset-assert 232) - (offset transformq :inline :offset-assert 236) - (mirror uint32 :offset-assert 284) + ((control control-info :offset 128) ;; guessed by decompiler + (anim-seed uint64 :offset 208) ;; ?? + (shadow-in-movie? symbol :offset-assert 216) ;; guessed by decompiler + (special-anim-time time-frame :offset-assert 224) + (special-anim-interp float :offset-assert 232) + (special-anim-frame float :offset-assert 236) + (offset transformq :inline :offset-assert 240) + (mirror uint32 :offset-assert 288) ) :method-count-assert 20 :size-assert #x124 @@ -14809,16 +15910,14 @@ (:methods ) ) -|# -;; (define-extern *target* object) ;; target -;; (define-extern *sidekick* object) ;; sidekick +(define-extern *target* target) +(define-extern *sidekick* sidekick) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; stats-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tr-stat (structure) ((groups uint16 :offset-assert 0) (fragments uint16 :offset-assert 2) @@ -14831,9 +15930,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype merc-global-stats (structure) ((merc tr-stat :inline :offset-assert 0) (emerc tr-stat :inline :offset-assert 16) @@ -14843,9 +15940,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype perf-stat (structure) ((frame-number uint32 :offset-assert 0) (count uint32 :offset-assert 4) @@ -14866,33 +15961,83 @@ :flag-assert #xe00000034 (:methods (perf-stat-method-9 () none 9) ;; (dummy-9 (_type_) none 9) - (perf-stat-method-10 () none 10) ;; (print-to-stream (_type_ string basic) none 10) - (perf-stat-method-11 () none 11) ;; (reset! (_type_) none 11) - (perf-stat-method-12 () none 12) ;; (read! (_type_) none 12) - (perf-stat-method-13 () none 13) ;; (update-wait-stats (_type_ uint uint uint) none 13) + (print-to-stream (_type_ string basic) none 10) + (reset! (_type_) none 11) + (read! (_type_) none 12) + (update-wait-stats (_type_ uint uint uint) none 13) ) ) -|# -#| (deftype perf-stat-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data perf-stat :dynamic :offset-assert 16) ;; guessed by decompiler + ((data perf-stat :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern perf-stat-bucket->string function) ;; (function perf-stat-bucket string) +(defenum perf-stat-bucket + :type uint32 ;; guess + + (all-code 0) + (spatial-hash-build 1) + (spatial-hash-search 2) + (collide 3) + (collide-list 4) + (collide-fill 5) + (actor-hash 6) + (nav 7) + (nav-dma-all 8) + (nav-dma-read 9) + (nav-dma-write 10) + (nav-dma-work 11) + (nav-part1 12) + (nav-part2 13) + (nav-part3 14) + (nav-part4 15) + (nav-part5 16) + (nav-part6 17) + (nav-part7 18) + (nav-part8 19) + (nav-part9 20) + (nav-part10 21) + (add-to-translation 22) + (update-current-poly 23) + (clamp-vector-to-mesh 24) + (ray-step 25) + (update-spheres 26) + (travel-around-spheres 27) + (avoid-spheres 28) + (check-vector-collision-with-nav-spheres 29) + (find-nearest-poly 30) + (find-containing-poly 31) + (generate-velocity 32) + (apply-rotation 33) + (apply-velocity 34) + (travel-post 35) + (common-post 36) + (misc 37) + (mercneric 38) + (tie-generic 39) + (background 40) + (drawable 41) + (tfrag 42) + (tfrag-scissor 43) + (inst-shrub 44) + (proto-shrub 45) + (inst-tie 46) + (proto-tie 47) + (bones 48) + (camera 49) + (foreground 50) + ) + +(define-extern perf-stat-bucket->string (function perf-stat-bucket string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bsp-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype bsp-node (structure) ((front int16 :offset-assert 0) ;; int32 (back int16 :offset-assert 2) ;; int32 @@ -14905,9 +16050,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype game-level (basic) ((master-bsp basic :offset-assert 4) ) @@ -14915,9 +16058,7 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype view-frustum (structure) ((hither-top-left vector :inline :offset-assert 0) (hither-top-right vector :inline :offset-assert 16) @@ -14932,23 +16073,77 @@ :size-assert #x80 :flag-assert #x900000080 ) -|# -#| +(declare-type entity-camera entity) +(declare-type entity-race-mesh entity) +(declare-type entity-nav-mesh entity) +(declare-type actor-group basic) + (deftype bsp-header (drawable) - () + ( + (info file-info :offset 4) + (all-visible-list (pointer uint16) :offset-assert 32) + (visible-list-length int16 :offset-assert 36) + (drawable-trees drawable-tree-array :offset-assert 40) + (pat pointer :offset-assert 44) + (pat-length int32 :offset-assert 48) + + ; ;; some sort of texture remapping info (seems to be same in jak2) + ; (texture-remap-table (pointer uint64) :offset-assert 52) + ; (texture-remap-table-len int32 :offset-assert 56) + + (texture-ids (pointer texture-id) :offset 60) + (texture-page-count int32 :offset 64) + + ; (unk-zero-0 basic :offset-assert 68) + + (name symbol :offset 72) + (nickname symbol :offset-assert 76) + (vis-info level-vis-info 8 :offset 80) + (actors drawable-inline-array-actor :offset-assert 112) + (cameras (array entity-camera) :offset-assert 116) + (nodes (inline-array bsp-node) :offset 120) + (level level :offset-assert 124) + ; (current-leaf-idx uint16 :offset-assert 128) + (unk-data-2 uint16 9 :offset 130) + + ; (boxes box8s-array :offset-assert 148) + ; (current-bsp-back-flags uint32 :offset-assert 152) + (unk-byte uint8 :offset 152) + ; (ambients drawable-inline-array-ambient :offset-assert 156) ;; now just #t? + (unk-data-4 float :offset 160) + (unk-data-5 float :offset-assert 164) + ; (adgifs adgif-shader-array :offset-assert 168) + (race-meshes (array entity-race-mesh) :offset 168) + ;; 172 is something + (light-hash light-hash :offset 176) + (nav-meshes (array entity-nav-mesh) :offset 180) + (actor-groups (array actor-group) :offset 184) + + (collide-hash collide-hash :offset 196) + ;; 200 is some array + ;; 204 is maybe that array's length + ;; 216 is a vector array + + (region-tree drawable-tree-region-prim :offset 252) + + ; (actor-birth-order (pointer uint32) :offset-assert 172) + ; (split-box-indices (pointer uint16) :offset-assert 176) + (unk-data-8 uint32 55 :offset 180) + ) :method-count-assert 19 :size-assert #x190 :flag-assert #x1300000190 ;; Failed to read fields. (:methods - (bsp-header-method-17 () none 17) - (bsp-header-method-18 () none 18) ;; (birth (_type_) none 18) + (birth (_type_) none 17) + (deactivate-entities (_type_) none 18) ) ) -|# -#| +;; something very strange happened here and these stopwatches are +;; totally broken + (deftype collide-stats (structure) ((calls uint32 :offset-assert 0) (spheres uint32 :offset-assert 4) @@ -14956,24 +16151,24 @@ (frags uint32 :offset-assert 12) (tris uint32 :offset-assert 16) (output uint32 :offset-assert 20) - (total-target stopwatch :inline :offset-assert 28) - (target-cache-fill stopwatch :inline :offset-assert 60) - (target-ray-poly stopwatch :inline :offset-assert 92) + (pad0 uint32 2) + (total-target uint32 8 :offset-assert 32) + (target-cache-fill uint32 8 :offset-assert 64) + (target-ray-poly uint32 6 :offset-assert 96) + ;(pad uint8 :offset 119) ) :method-count-assert 9 :size-assert #x78 :flag-assert #x900000078 ) -|# -;; (define-extern inspect-bsp-tree function) ;; (function bsp-header bsp-node none) -;; (define-extern map-bsp-tree function) ;; (function (function bsp-node none) bsp-header bsp-node none) +(define-extern inspect-bsp-tree (function bsp-header bsp-node none)) +(define-extern map-bsp-tree (function (function bsp-node none) bsp-header bsp-node none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-cache-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-puss-sphere (structure) ((bsphere sphere :inline :offset-assert 0) (bbox4w bounding-box4w :inline :offset-assert 16) @@ -14982,15 +16177,13 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype collide-puss-work (structure) ((closest-pt vector :inline :offset-assert 0) (tri-normal vector :inline :offset-assert 16) (tri-bbox4w bounding-box4w :inline :offset-assert 32) (spheres-bbox4w bounding-box4w :inline :offset-assert 64) - (spheres collide-puss-sphere 64 :offset-assert 96) ;; guessed by decompiler + (spheres collide-puss-sphere 64 :inline :offset-assert 96) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #xc60 @@ -15000,37 +16193,33 @@ (collide-puss-work-method-10 () none 10) ;; (dummy-10 (_type_ object object) symbol 10) ) ) -|# -#| (deftype collide-cache-tri (structure) - ((vertex vector 3 :offset-assert 0) ;; guessed by decompiler - (extra-quad uint128 16 :offset-assert 48) ;; guessed by decompiler - (pat pat-surface :offset-assert 48) ;; guessed by decompiler - (collide-ptr basic :offset-assert 52) - (prim-index uint16 :offset-assert 56) - (user16 uint16 :offset-assert 58) - (user32 uint32 :offset-assert 60) + ((vertex vector 3 :inline :offset-assert 0) ;; guessed by decompiler + (extra-quad uint8 16 :offset-assert 48) ;; guessed by decompiler + (pat pat-surface :offset 48) ;; guessed by decompiler + (collide-ptr basic :offset 52) + (prim-index uint16 :offset 56) + (user16 uint16 :offset 58) + (user32 uint32 :offset 60) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype collide-cache-prim (structure) ((prim-core collide-prim-core :inline :offset-assert 0) - (extra-quad uint128 16 :offset-assert 32) ;; guessed by decompiler - (ccache collide-cache :offset-assert 32) ;; guessed by decompiler - (prim collide-shape-prim :offset-assert 36) ;; guessed by decompiler - (first-tri uint16 :offset-assert 40) - (num-tris uint16 :offset-assert 42) - (unused uint8 4 :offset-assert 44) ;; guessed by decompiler - (world-sphere vector :inline :offset-assert 0) - (collide-as collide-kind :offset-assert 16) ;; guessed by decompiler - (action collide-action :offset-assert 24) ;; guessed by decompiler - (prim-type int8 :offset-assert 28) + (extra-quad uint8 16 :offset-assert 32) ;; guessed by decompiler + (ccache collide-cache :offset 32) ;; guessed by decompiler + (prim collide-shape-prim :offset 36) ;; guessed by decompiler + (first-tri uint16 :offset 40) + (num-tris uint16 :offset 42) + (unused uint8 4 :offset 44) ;; guessed by decompiler + (world-sphere vector :inline :offset 0) + (collide-as collide-spec :offset 16) ;; guessed by decompiler + (action collide-action :offset 24) ;; guessed by decompiler + (prim-type prim-type :offset 28) ) :method-count-assert 11 :size-assert #x30 @@ -15040,20 +16229,18 @@ (collide-cache-prim-method-10 () none 10) ;; (resolve-moving-sphere-sphere (_type_ collide-tri-result collide-prim-core vector float collide-action) float 10) ) ) -|# -#| (deftype collide-cache (basic) ((num-tris int32 :offset-assert 4) (num-prims int32 :offset-assert 8) (ignore-mask pat-surface :offset-assert 12) ;; guessed by decompiler - (ignore-processes UNKNOWN 2 :offset-assert 16) + (ignore-processes process 2 :offset-assert 16) (collide-box bounding-box :inline :offset-assert 32) (collide-box4w bounding-box4w :inline :offset-assert 64) - (collide-with collide-kind :offset-assert 96) ;; guessed by decompiler + (collide-with collide-spec :offset-assert 96) ;; guessed by decompiler (unused uint32 :offset-assert 100) - (prims collide-cache-prim 100 :offset-assert 112) ;; guessed by decompiler - (tris collide-cache-tri 461 :offset-assert 4912) ;; guessed by decompiler + (prims collide-cache-prim 100 :inline :offset-assert 112) ;; guessed by decompiler + (tris collide-cache-tri 461 :inline :offset-assert 4912) ;; guessed by decompiler ) :method-count-assert 26 :size-assert #x8670 @@ -15078,64 +16265,59 @@ (collide-cache-method-25 () none 25) ;; (fill-from-water (_type_ water-control) none 25) ) ) -|# -#| (deftype collide-list-item (structure) ((mesh collide-frag-mesh :offset-assert 0) ;; guessed by decompiler (inst basic :offset-assert 4) ) + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype collide-list (structure) ((num-items int32 :offset-assert 0) - (items collide-list-item 256 :offset-assert 16) ;; guessed by decompiler + (items collide-list-item 256 :inline :offset 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x810 :flag-assert #x900000810 ) -|# -;; (define-extern *collide-cache* object) ;; collide-cache -;; (define-extern *collide-list* object) ;; collide-list +(define-extern *collide-cache* collide-cache) +(define-extern *collide-list* collide-list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype collide-query (structure) ((best-other-tri collide-tri-result :inline :offset-assert 0) - (best-my-tri collide-tri-result :inline :offset-assert 0) - (ignore-processes UNKNOWN 2 :offset-assert 88) - (ignore-process0 basic :offset-assert 88) - (ignore-process1 basic :offset-assert 92) - (ignore-pat uint32 :offset-assert 96) - (collide-with uint32 :offset-assert 100) - (overlay-params UNKNOWN 3 :offset-assert 112) + (best-my-tri collide-tri-result :inline :offset 0) + (ignore-processes process 2 :offset-assert 88) + (ignore-process0 process :offset 88) + (ignore-process1 process :offset 92) + (ignore-pat pat-surface :offset-assert 96) + (collide-with collide-spec :offset-assert 100) + (overlay-params uint32 3 :offset 112) ;; ? (bbox bounding-box :inline :offset-assert 128) (bbox4w bounding-box4w :inline :offset-assert 160) (bsphere sphere :inline :offset-assert 192) (start-pos vector :inline :offset-assert 208) (move-dist vector :inline :offset-assert 224) (rlength vector :inline :offset-assert 240) - (exit-planes UNKNOWN 2 :offset-assert 256) - (radius float :offset-assert 268) - (inv-mat matrix :inline :offset-assert 288) - (spheres uint32 :offset-assert 112) - (num-spheres uint32 :offset-assert 116) - (solid-only basic :offset-assert 120) - (best-dist float :offset-assert 112) - (best-other-prim basic :offset-assert 116) - (best-my-prim basic :offset-assert 120) - (move-vec vector :inline :offset-assert 224) - (best-u float :offset-assert 112) + (exit-planes plane 2 :offset-assert 256) ;; ? + (radius float :offset 268) + (inv-mat matrix :inline :offset 288) + (spheres uint32 :offset 112) + (num-spheres uint32 :offset 116) + (solid-only basic :offset 120) + (best-dist float :offset 112 :score 1) + (best-other-prim basic :offset 116) + (best-my-prim basic :offset 120) + (move-vec vector :inline :offset 224) + (best-u float :offset 112) (action-mask uint32 :offset-assert 352) (local-box4w bounding-box4w :inline :offset-assert 368) (search-box bounding-box4w :inline :offset-assert 400) @@ -15153,15 +16335,13 @@ :size-assert #x21c :flag-assert #x90000021c ) -|# -;; (define-extern *collide-test-flag* object) ;; symbol +(define-extern *collide-test-flag* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shrubbery-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype billboard (drawable) ((flat adgif-shader :inline :offset-assert 32) ) @@ -15171,41 +16351,45 @@ (:methods ) ) -|# -#| (deftype shrub-view-data (structure) ((data uint128 3 :offset-assert 0) ;; guessed by decompiler - (texture-giftag qword :inline :offset-assert 0) ;; gs-gif-tag :inline - (consts vector :inline :offset-assert 16) - (fog-clamp vector :inline :offset-assert 32) - (tex-start-ptr int32 :offset-assert 16) - (gifbufsum float :offset-assert 16) - (mtx-buf-ptr int32 :offset-assert 20) - (exp23 float :offset-assert 20) - (fog-0 float :offset-assert 24) - (fog-1 float :offset-assert 28) - (fog-min float :offset-assert 32) - (fog-max float :offset-assert 36) + (texture-giftag gs-gif-tag :inline :offset 0) ;; was qword + (consts vector :inline :offset 16) + (fog-clamp vector :inline :offset 32) + (tex-start-ptr int32 :offset 16) + (gifbufsum float :offset 16) + (mtx-buf-ptr int32 :offset 20) + (exp23 float :offset 20) + (fog-0 float :offset 24) + (fog-1 float :offset 28) + (fog-min float :offset 32) + (fog-max float :offset 36) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype shrubbery (drawable) - ((textures (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (header qword :offset-assert 8) - (obj-qwc uint8 :offset-assert 12) - (vtx-qwc uint8 :offset-assert 13) - (col-qwc uint8 :offset-assert 14) - (stq-qwc uint8 :offset-assert 15) - (obj uint32 :offset-assert 16) - (vtx uint32 :offset-assert 20) - (col uint32 :offset-assert 24) - (stq uint32 :offset-assert 28) + ((textures (inline-array adgif-shader) :offset 4) + ;; header breakdown: + ;; [0] - number of textures / 2 + ;; [1] - number of vertices + ;; [2] - number of triangle strips + ;; [3] - ?? + ;; + ;; Number of Triangles in the Shrub = header[2] - 2 * header[1] + (header qword :offset 8 :score -1) + (obj-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + ;; start of static dma-chain + (obj uint32 :score 999 :offset 16) + (vtx uint32 :score 999 :offset 20) + (col uint32 :score 999 :offset 24) + (stq uint32 :score 999 :offset 28) ) :method-count-assert 17 :size-assert #x20 @@ -15213,13 +16397,11 @@ (:methods ) ) -|# -#| (deftype instance-shrubbery (instance) ((flat-normal vector :inline :offset-assert 64) - (flat-hwidth float :offset-assert 76) - (color uint32 :offset-assert 8) + (flat-hwidth float :offset 76) + (color uint32 :offset 8) ) :method-count-assert 17 :size-assert #x50 @@ -15227,30 +16409,32 @@ (:methods ) ) -|# -;; (deftype drawable-inline-array-instance-shrub (drawable-inline-array) -;; () -;; :flag-assert #x1100000074 -;; ) +(deftype drawable-inline-array-instance-shrub (drawable-inline-array) + ((data instance-shrubbery 1 :inline :offset-assert 32) + (pad uint32) + ) + :flag-assert #x1100000074 + ) -;; (deftype drawable-tree-instance-shrub (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-instance-shrub (drawable-tree) + ((info prototype-array-shrub-info :offset 8) + (colors-added time-of-day-palette :offset 12) ;; added + ) + :flag-assert #x1100000020 + ) -#| (deftype generic-shrub-fragment (drawable) - ((textures (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (vtx-cnt uint32 :offset-assert 8) - (cnt-qwc uint8 :offset-assert 12) - (vtx-qwc uint8 :offset-assert 13) - (col-qwc uint8 :offset-assert 14) - (stq-qwc uint8 :offset-assert 15) - (cnt uint32 :offset-assert 16) - (vtx uint32 :offset-assert 20) - (col uint32 :offset-assert 24) - (stq uint32 :offset-assert 28) + ((textures (inline-array adgif-shader) :offset 4) ;; guessed by decompiler + (vtx-cnt uint32 :offset 8) + (cnt-qwc uint8 :offset 12) + (vtx-qwc uint8 :offset 13) + (col-qwc uint8 :offset 14) + (stq-qwc uint8 :offset 15) + (cnt uint32 :offset 16) + (vtx uint32 :offset 20) + (col uint32 :offset 24) + (stq uint32 :offset 28) ) :method-count-assert 17 :size-assert #x20 @@ -15258,11 +16442,12 @@ (:methods ) ) -|# -#| + (deftype prototype-shrubbery (drawable-inline-array) - () + ((data shrubbery 1 :inline :offset-assert 32) + (pad uint32) + ) :method-count-assert 17 :size-assert #x44 :flag-assert #x1100000044 @@ -15270,19 +16455,17 @@ (:methods ) ) -|# -;; (deftype prototype-trans-shrubbery (prototype-shrubbery) -;; () -;; :flag-assert #x1100000044 -;; ) +(deftype prototype-trans-shrubbery (prototype-shrubbery) + () + :flag-assert #x1100000044 + ) -;; (deftype prototype-generic-shrub (drawable-group) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype prototype-generic-shrub (drawable-group) + () + :flag-assert #x1100000020 + ) -#| (deftype shrubbery-matrix (structure) ((mat matrix :inline :offset-assert 0) (color qword :inline :offset-assert 64) @@ -15291,9 +16474,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype shrub-near-packet (structure) ((matrix-tmpl dma-packet :inline :offset-assert 0) (header-tmpl dma-packet :inline :offset-assert 16) @@ -15308,22 +16489,20 @@ :size-assert #x90 :flag-assert #x900000090 ) -|# -#| (deftype instance-shrub-work (structure) - ((dummy qword 3 :offset-assert 0) ;; guessed by decompiler - (chaina qword 8 :offset-assert 48) ;; guessed by decompiler - (chainb qword 8 :offset-assert 176) ;; guessed by decompiler + ((dummy qword 3 :inline :offset-assert 0) ;; guessed by decompiler + (chaina qword 8 :inline :offset-assert 48) ;; guessed by decompiler + (chainb qword 8 :inline :offset-assert 176) ;; guessed by decompiler (colors rgba 1024 :offset-assert 304) ;; guessed by decompiler - (matrix-tmpl qword 20 :offset-assert 4400) ;; guessed by decompiler - (count-tmpl vector4w 20 :offset-assert 4720) ;; guessed by decompiler + (matrix-tmpl qword 20 :inline :offset-assert 4400) ;; guessed by decompiler + (count-tmpl vector4w 20 :inline :offset-assert 4720) ;; guessed by decompiler (mscalf-tmpl dma-packet :inline :offset-assert 5040) (mscalf-ret-tmpl dma-packet :inline :offset-assert 5056) (adgif-tmpl dma-gif-packet :inline :offset-assert 5072) (billboard-tmpl dma-gif-packet :inline :offset-assert 5104) (billboard-const vector :inline :offset-assert 5136) - (shrub-near-packets shrub-near-packet 6 :offset-assert 5152) ;; guessed by decompiler + (shrub-near-packets shrub-near-packet 6 :inline :offset-assert 5152) ;; guessed by decompiler (dma-ref dma-packet :inline :offset-assert 6016) (dma-end dma-packet :inline :offset-assert 6032) (wind-const vector :inline :offset-assert 6048) @@ -15336,8 +16515,8 @@ (bb-color vector :inline :offset-assert 6160) (min-dist vector :inline :offset-assert 6176) (temp-vec vector :inline :offset-assert 6192) - (guard-plane plane 4 :offset-assert 6208) ;; guessed by decompiler - (plane plane 4 :offset-assert 6272) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 6208) ;; guessed by decompiler + (plane plane 4 :inline :offset-assert 6272) ;; guessed by decompiler (last uint32 4 :offset-assert 6336) ;; guessed by decompiler (next uint32 4 :offset-assert 6352) ;; guessed by decompiler (count uint16 4 :offset-assert 6368) ;; guessed by decompiler @@ -15352,18 +16531,21 @@ (to-spr uint32 :offset-assert 6412) (from-spr uint32 :offset-assert 6416) (shrub-count uint32 :offset-assert 6420) - (stack-ptr uint32 :offset-assert 6400) + ;(stack-ptr uint32 :offset-assert 6400) + (pad uint32) (node uint32 6 :offset-assert 6428) ;; guessed by decompiler (length uint32 6 :offset-assert 6452) ;; guessed by decompiler (prototypes uint32 :offset-assert 6476) - (bucket-ptr uint32 :offset-assert 6404) + ;(bucket-ptr uint32 :offset-assert 6404) + (pad2 uint32) (start-bank uint8 20 :offset-assert 6484) ;; guessed by decompiler (buffer-index uint32 :offset-assert 6504) (current-spr uint32 :offset-assert 6508) (current-mem uint32 :offset-assert 6512) (current-shrub-near-packet uint32 :offset-assert 6516) (current-shrub-near-trans-packet uint32 :offset-assert 6520) - (to-spr uint32 :offset-assert 6412) + ;(to-spr uint32 :offset-assert 6412) + (pad3 uint32) (dma-buffer basic :offset-assert 6528) (near-last uint32 :offset-assert 6532) (near-next uint32 :offset-assert 6536) @@ -15384,9 +16566,7 @@ :size-assert #x19bc :flag-assert #x9000019bc ) -|# -#| (deftype instance-shrub-dma (structure) ((instancea uint128 325 :offset-assert 0) ;; guessed by decompiler (instanceb uint128 325 :offset-assert 5200) ;; guessed by decompiler @@ -15397,44 +16577,40 @@ :size-assert #x38a0 :flag-assert #x9000038a0 ) -|# -;; (define-extern shrubbery-login-post-texture function) ;; (function shrubbery none) -;; (define-extern *shrub-state* object) ;; int +(define-extern shrubbery-login-post-texture (function shrubbery none)) +(define-extern *shrub-state* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tie-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tie-fragment-debug (structure) ((num-tris uint16 :offset-assert 0) (num-dverts uint16 :offset-assert 2) - (debug-lines basic :offset-assert 4) + (debug-lines (array vector-array) :offset-assert 4) ) :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype tie-fragment (drawable) - ((gif-ref (inline-array adgif-shader) :offset-assert 4) ;; guessed by decompiler - (point-ref uint32 :offset-assert 8) - (color-index uint16 :offset-assert 12) - (base-colors uint8 :offset-assert 14) - (tex-count uint16 :offset-assert 32) - (gif-count uint16 :offset-assert 34) - (vertex-count uint16 :offset-assert 36) - (color-count uint16 :offset-assert 38) - (dp-ref uint32 :offset-assert 40) - (dp-qwc uint32 :offset-assert 44) - (generic-ref uint32 :offset-assert 48) - (generic-count uint16 :offset-assert 52) ;; uint32 - (normal-count uint16 :offset-assert 54) - (normal-ref uint32 :offset-assert 56) - (debug tie-fragment-debug :offset-assert 60) + ((gif-ref (inline-array adgif-shader) :offset 4) ;; guessed by decompiler + (point-ref uint32 :offset 8) + (color-index uint16 :offset 12) + (base-colors uint8 :offset 14) + (tex-count uint16 :offset 32) + (gif-count uint16 :offset 34) + (vertex-count uint16 :offset 36) + (color-count uint16 :offset 38) + (dp-ref uint32 :offset 40) + (dp-qwc uint32 :offset 44) + (generic-ref uint32 :offset 48) + (generic-count uint16 :offset 52) ;; uint32 + (normal-count uint16 :offset 54) + (normal-ref uint32 :offset 56) + (debug tie-fragment-debug :offset 60) ) :method-count-assert 17 :size-assert #x40 @@ -15442,14 +16618,12 @@ (:methods ) ) -|# -#| (deftype instance-tie (instance) - ((color-indices uint32 :offset-assert 8) - (bucket-ptr prototype-bucket-tie :offset-assert 12) ;; guessed by decompiler - (max-scale uint16 :offset-assert 38) - (rmin-scale uint16 :offset-assert 54) + ((color-indices uint32 :offset 8) + (bucket-ptr prototype-bucket-tie :offset 12) ;; guessed by decompiler + (max-scale uint16 :offset 38) + (rmin-scale uint16 :offset 54) ) :method-count-assert 17 :size-assert #x40 @@ -15457,11 +16631,11 @@ (:methods ) ) -|# -#| (deftype drawable-inline-array-instance-tie (drawable-inline-array) - () + ((data instance-tie 1 :inline :offset-assert 32) ;; not sure on type here + (pad uint32) + ) :method-count-assert 17 :size-assert #x64 :flag-assert #x1100000064 @@ -15469,11 +16643,10 @@ (:methods ) ) -|# -#| (deftype drawable-tree-instance-tie (drawable-tree) - () + ((prototypes proxy-prototype-array-tie :offset 8) + ) :method-count-assert 17 :size-assert #x20 :flag-assert #x1100000020 @@ -15481,11 +16654,11 @@ (:methods ) ) -|# -#| (deftype prototype-tie (drawable-inline-array) - () + ((data tie-fragment 1 :inline :offset-assert 32) + (pad uint32) + ) :method-count-assert 17 :size-assert #x64 :flag-assert #x1100000064 @@ -15493,27 +16666,23 @@ (:methods ) ) -|# -#| (deftype tie-matrix (structure) ((mat matrix :inline :offset-assert 0) (morph qword :inline :offset-assert 64) (fog qword :inline :offset-assert 80) - (envmap-flag uint32 :offset-assert 80) - (guard-flag uint32 :offset-assert 84) - (vertex-alpha float :offset-assert 88) - (fog-value float :offset-assert 92) - (fixed-alpha float :offset-assert 68) + (envmap-flag uint32 :offset 80) + (guard-flag uint32 :offset 84) + (vertex-alpha float :offset 88) + (fog-value float :offset 92) + (fixed-alpha float :offset 68) ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype instance-tie-work (structure) ((wind-const vector :inline :offset-assert 0) (hmge-d vector :inline :offset-assert 16) @@ -15523,7 +16692,7 @@ (far-morph vector :inline :offset-assert 80) (dist-test vector :inline :offset-assert 96) (min-dist vector :inline :offset-assert 112) - (guard-plane plane 4 :offset-assert 128) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 128) ;; guessed by decompiler (upload-color-0 dma-packet :inline :offset-assert 192) (upload-color-1 dma-packet :inline :offset-assert 208) (upload-color-2 dma-packet :inline :offset-assert 224) @@ -15566,23 +16735,20 @@ :size-assert #x22c :flag-assert #x90000022c ) -|# -#| (deftype instance-tie-dma (structure) - ((banka instance-tie 32 :offset-assert 4) ;; guessed by decompiler - (bankb instance-tie 32 :offset-assert 2052) ;; guessed by decompiler - (outa uint128 256 :offset-assert 4096) ;; guessed by decompiler - (outb uint128 256 :offset-assert 8192) ;; guessed by decompiler - (work instance-tie-work :offset-assert 12288) + ((banka instance-tie 32 :inline :offset-assert 0) + (bankb instance-tie 32 :inline :offset-assert 2048) + (outa uint128 256 :offset-assert 4096) + (outb uint128 256 :offset-assert 8192) + ;; this is outside the type???? + (work instance-tie-work :dynamic :offset-assert 12288) ) :method-count-assert 9 :size-assert #x3000 :flag-assert #x900003000 ) -|# -#| (deftype prototype-tie-work (structure) ((upload-flushe dma-packet :inline :offset-assert 0) (upload-palette dma-packet :inline :offset-assert 16) @@ -15613,155 +16779,151 @@ (wait-from-spr uint32 :offset-assert 396) (wait-to-spr uint32 :offset-assert 400) (mood mood-context :offset-assert 404) - (last UNKNOWN 16 :offset-assert 416) - (next UNKNOWN 16 :offset-assert 480) - (count UNKNOWN 16 :offset-assert 544) - (tie-last uint32 :offset-assert 416) - (tie-next uint32 :offset-assert 480) - (tie-count uint16 :offset-assert 544) - (trans-last uint32 :offset-assert 420) - (trans-next uint32 :offset-assert 484) - (trans-count uint16 :offset-assert 546) - (water-last uint32 :offset-assert 424) - (water-next uint32 :offset-assert 488) - (water-count uint16 :offset-assert 548) - (scissor-last uint32 :offset-assert 428) - (scissor-next uint32 :offset-assert 492) - (scissor-count uint16 :offset-assert 550) - (scissor-trans-last uint32 :offset-assert 432) - (scissor-trans-next uint32 :offset-assert 496) - (scissor-trans-count uint16 :offset-assert 552) - (scissor-water-last uint32 :offset-assert 436) - (scissor-water-next uint32 :offset-assert 500) - (scissor-water-count uint16 :offset-assert 554) - (envmap-last uint32 :offset-assert 440) - (envmap-next uint32 :offset-assert 504) - (envmap-count uint16 :offset-assert 556) - (envmap-trans-last uint32 :offset-assert 444) - (envmap-trans-next uint32 :offset-assert 508) - (envmap-trans-count uint16 :offset-assert 558) - (envmap-water-last uint32 :offset-assert 448) - (envmap-water-next uint32 :offset-assert 512) - (envmap-water-count uint16 :offset-assert 560) - (envmap-scissor-last uint32 :offset-assert 452) - (envmap-scissor-next uint32 :offset-assert 516) - (envmap-scissor-count uint16 :offset-assert 562) - (envmap-scissor-trans-last uint32 :offset-assert 456) - (envmap-scissor-trans-next uint32 :offset-assert 520) - (envmap-scissor-trans-count uint16 :offset-assert 564) - (envmap-scissor-water-last uint32 :offset-assert 460) - (envmap-scissor-water-next uint32 :offset-assert 524) - (envmap-scissor-water-count uint16 :offset-assert 566) - (generic-last uint32 :offset-assert 464) - (generic-next uint32 :offset-assert 528) - (generic-count uint16 :offset-assert 568) - (generic-trans-last uint32 :offset-assert 468) - (generic-trans-next uint32 :offset-assert 532) - (generic-trans-count uint16 :offset-assert 570) - (generic-water-last uint32 :offset-assert 472) - (generic-water-next uint32 :offset-assert 536) - (generic-water-count uint16 :offset-assert 572) - (vanish-last uint32 :offset-assert 476) - (vanish-next uint32 :offset-assert 540) - (vanish-count uint16 :offset-assert 574) + (last uint32 16 :offset 416) + (next uint32 16 :offset-assert 480) + (count uint16 16 :offset-assert 544) + (tie-last uint32 :offset 416) + (tie-next uint32 :offset 480) + (tie-count uint16 :offset 544) + (trans-last uint32 :offset 420) + (trans-next uint32 :offset 484) + (trans-count uint16 :offset 546) + (water-last uint32 :offset 424) + (water-next uint32 :offset 488) + (water-count uint16 :offset 548) + (scissor-last uint32 :offset 428) + (scissor-next uint32 :offset 492) + (scissor-count uint16 :offset 550) + (scissor-trans-last uint32 :offset 432) + (scissor-trans-next uint32 :offset 496) + (scissor-trans-count uint16 :offset 552) + (scissor-water-last uint32 :offset 436) + (scissor-water-next uint32 :offset 500) + (scissor-water-count uint16 :offset 554) + (envmap-last uint32 :offset 440) + (envmap-next uint32 :offset 504) + (envmap-count uint16 :offset 556) + (envmap-trans-last uint32 :offset 444) + (envmap-trans-next uint32 :offset 508) + (envmap-trans-count uint16 :offset 558) + (envmap-water-last uint32 :offset 448) + (envmap-water-next uint32 :offset 512) + (envmap-water-count uint16 :offset 560) + (envmap-scissor-last uint32 :offset 452) + (envmap-scissor-next uint32 :offset 516) + (envmap-scissor-count uint16 :offset 562) + (envmap-scissor-trans-last uint32 :offset 456) + (envmap-scissor-trans-next uint32 :offset 520) + (envmap-scissor-trans-count uint16 :offset 564) + (envmap-scissor-water-last uint32 :offset 460) + (envmap-scissor-water-next uint32 :offset 524) + (envmap-scissor-water-count uint16 :offset 566) + (generic-last uint32 :offset 464) + (generic-next uint32 :offset 528) + (generic-count uint16 :offset 568) + (generic-trans-last uint32 :offset 468) + (generic-trans-next uint32 :offset 532) + (generic-trans-count uint16 :offset 570) + (generic-water-last uint32 :offset 472) + (generic-water-next uint32 :offset 536) + (generic-water-count uint16 :offset 572) + (vanish-last uint32 :offset 476) + (vanish-next uint32 :offset 540) + (vanish-count uint16 :offset 574) ) :method-count-assert 9 :size-assert #x240 :flag-assert #x900000240 ) -|# -#| (deftype prototype-tie-dma (structure) ((colora rgba 256 :offset-assert 0) ;; guessed by decompiler (colorb rgba 256 :offset-assert 1024) ;; guessed by decompiler (outa uint128 256 :offset-assert 2048) ;; guessed by decompiler (outb uint128 256 :offset-assert 6144) ;; guessed by decompiler (geometry uint32 4 :offset-assert 10240) ;; guessed by decompiler - (next uint32 12 :offset-assert 10256) ;; guessed by decompiler - (count UNKNOWN 12 :offset-assert 10304) - (counts UNKNOWN 4 :offset-assert 10328) - (palette-ptr uint32 :offset-assert 10336) - (model-ptr uint32 :offset-assert 10340) - (ret-ptr uint32 :offset-assert 10344) - (length uint32 :offset-assert 10348) - (flags uint32 :offset-assert 10352) - (dma-buffer basic :offset-assert 10356) - (this-frag-count uint32 :offset-assert 10360) - (frag-count uint8 4 :offset-assert 10364) ;; guessed by decompiler - (from-spr uint32 :offset-assert 10368) - (to-spr uint32 :offset-assert 10372) - (spr-out uint32 :offset-assert 10376) - (this-count uint32 :offset-assert 10380) - (scissor-geometry uint32 :offset-assert 10240) - (near-geometry uint32 :offset-assert 10244) - (mid-geometry uint32 :offset-assert 10248) - (far-geometry uint32 :offset-assert 10252) - (scissor-frag-count uint8 :offset-assert 10364) - (near-frag-count uint8 :offset-assert 10365) - (mid-frag-count uint8 :offset-assert 10366) - (far-frag-count uint8 :offset-assert 10367) - (tie-scissor-next uint32 :offset-assert 10256) - (tie-near-next uint32 :offset-assert 10260) - (tie-mid-next uint32 :offset-assert 10264) - (tie-far-next uint32 :offset-assert 10268) - (trans-scissor-next UNKNOWN 4 :offset-assert 10256) - (trans-near-next uint32 :offset-assert 10260) - (trans-mid-next uint32 :offset-assert 10264) - (trans-far-next uint32 :offset-assert 10268) - (water-scissor-next UNKNOWN 4 :offset-assert 10256) - (water-near-next uint32 :offset-assert 10260) - (water-mid-next uint32 :offset-assert 10264) - (water-far-next uint32 :offset-assert 10268) - (envmap-scissor-next UNKNOWN 4 :offset-assert 10272) - (envmap-near-next uint32 :offset-assert 10276) - (envmap-mid-next uint32 :offset-assert 10280) - (envmap-far-next uint32 :offset-assert 10284) - (generic-near-next uint32 :offset-assert 10288) - (generic-mid-next uint32 :offset-assert 10292) - (generic-far-next uint32 :offset-assert 10296) - (vanish-next uint32 :offset-assert 10300) - (tie-count uint16 :offset-assert 10304) - (tie-scissor-count uint16 :offset-assert 10304) - (tie-near-count uint16 :offset-assert 10306) - (tie-mid-count uint16 :offset-assert 10308) - (tie-far-count uint16 :offset-assert 10310) - (trans-count uint16 :offset-assert 10304) - (trans-scissor-count uint16 :offset-assert 10304) - (trans-near-count uint16 :offset-assert 10306) - (trans-mid-count uint16 :offset-assert 10308) - (trans-far-count uint16 :offset-assert 10310) - (water-count uint16 :offset-assert 10304) - (water-scissor-count uint16 :offset-assert 10304) - (water-near-count uint16 :offset-assert 10306) - (water-mid-count uint16 :offset-assert 10308) - (water-far-count uint16 :offset-assert 10310) - (envmap-count uint16 :offset-assert 10312) - (envmap-scissor-count uint16 :offset-assert 10312) - (envmap-near-count uint16 :offset-assert 10314) - (envmap-mid-count uint16 :offset-assert 10316) - (envmap-far-count uint16 :offset-assert 10318) - (generic-count uint16 :offset-assert 10320) - (generic-near-count uint16 :offset-assert 10320) - (generic-mid-count uint16 :offset-assert 10322) - (generic-far-count uint16 :offset-assert 10324) - (vanish-count uint16 :offset-assert 10326) - (next-clear UNKNOWN 3 :offset-assert 10256) - (count-clear UNKNOWN 3 :offset-assert 10304) + (next uint32 12 :offset 10256) ;; guessed by decompiler + (count uint16 12 :offset 10304) + (counts uint32 4 :offset 10328) + (palette-ptr uint32 :offset 10336) + (model-ptr uint32 :offset 10340) + (ret-ptr uint32 :offset 10344) + (length uint32 :offset 10348) + (flags uint32 :offset 10352) + (dma-buffer basic :offset 10356) + (this-frag-count uint32 :offset 10360) + (frag-count uint8 4 :offset 10364) ;; guessed by decompiler + (from-spr uint32 :offset 10368) + (to-spr uint32 :offset 10372) + (spr-out uint32 :offset 10376) + (this-count uint32 :offset 10380) + (scissor-geometry uint32 :offset 10240) + (near-geometry uint32 :offset 10244) + (mid-geometry uint32 :offset 10248) + (far-geometry uint32 :offset 10252) + (scissor-frag-count uint8 :offset 10364) + (near-frag-count uint8 :offset 10365) + (mid-frag-count uint8 :offset 10366) + (far-frag-count uint8 :offset 10367) + (tie-scissor-next uint32 :offset 10256) + (tie-near-next uint32 :offset 10260) + (tie-mid-next uint32 :offset 10264) + (tie-far-next uint32 :offset 10268) + (trans-scissor-next uint32 4 :offset 10256) + (trans-near-next uint32 :offset 10260) + (trans-mid-next uint32 :offset 10264) + (trans-far-next uint32 :offset 10268) + (water-scissor-next uint32 4 :offset 10256) + (water-near-next uint32 :offset 10260) + (water-mid-next uint32 :offset 10264) + (water-far-next uint32 :offset 10268) + (envmap-scissor-next uint32 4 :offset 10272) + (envmap-near-next uint32 :offset 10276) + (envmap-mid-next uint32 :offset 10280) + (envmap-far-next uint32 :offset 10284) + (generic-near-next uint32 :offset 10288) + (generic-mid-next uint32 :offset 10292) + (generic-far-next uint32 :offset 10296) + (vanish-next uint32 :offset 10300) + (tie-count uint16 :offset 10304) + (tie-scissor-count uint16 :offset 10304) + (tie-near-count uint16 :offset 10306) + (tie-mid-count uint16 :offset 10308) + (tie-far-count uint16 :offset 10310) + (trans-count uint16 :offset 10304) + (trans-scissor-count uint16 :offset 10304) + (trans-near-count uint16 :offset 10306) + (trans-mid-count uint16 :offset 10308) + (trans-far-count uint16 :offset 10310) + (water-count uint16 :offset 10304) + (water-scissor-count uint16 :offset 10304) + (water-near-count uint16 :offset 10306) + (water-mid-count uint16 :offset 10308) + (water-far-count uint16 :offset 10310) + (envmap-count uint16 :offset 10312) + (envmap-scissor-count uint16 :offset 10312) + (envmap-near-count uint16 :offset 10314) + (envmap-mid-count uint16 :offset 10316) + (envmap-far-count uint16 :offset 10318) + (generic-count uint16 :offset 10320) + (generic-near-count uint16 :offset 10320) + (generic-mid-count uint16 :offset 10322) + (generic-far-count uint16 :offset 10324) + (vanish-count uint16 :offset 10326) + (next-clear uint32 3 :offset 10256) + (count-clear uint16 3 :offset 10304) ) :method-count-assert 9 :size-assert #x2890 :flag-assert #x900002890 ) -|# -;; (define-extern *instance-tie-work-copy* object) ;; instance-tie-work +(define-extern *instance-tie-work-copy* instance-tie-work) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tfrag-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype tfragment-stats (structure) ((num-tris uint16 4 :offset-assert 0) ;; guessed by decompiler (num-dverts uint16 4 :offset-assert 8) ;; guessed by decompiler @@ -15770,9 +16932,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype tfragment-debug-data (structure) ((stats tfragment-stats :inline :offset-assert 0) (debug-lines (array vector-array) :offset-assert 16) ;; guessed by decompiler @@ -15781,9 +16941,7 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype generic-tfragment (structure) ((dummy int32 :offset-assert 0) ) @@ -15791,29 +16949,27 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype tfragment (drawable) - ((color-index uint16 :offset-assert 6) - (debug-data tfragment-debug-data :offset-assert 8) - (color-indices uint32 :offset-assert 12) - (colors uint32 :offset-assert 12) - (dma-chain uint32 3 :offset-assert 32) ;; guessed by decompiler - (dma-common uint32 :offset-assert 32) - (dma-level-0 uint32 :offset-assert 32) - (dma-base uint32 :offset-assert 36) - (dma-level-1 uint32 :offset-assert 40) - (dma-qwc uint8 4 :offset-assert 44) ;; guessed by decompiler - (shader (inline-array adgif-shader) :offset-assert 48) ;; guessed by decompiler - (num-shaders uint8 :offset-assert 52) - (num-base-colors uint8 :offset-assert 53) - (num-level0-colors uint8 :offset-assert 54) - (num-level1-colors uint8 :offset-assert 55) - (color-offset uint8 :offset-assert 56) - (color-count uint8 :offset-assert 57) - (texture-masks-index uint16 :offset-assert 58) - (generic generic-tfragment :offset-assert 60) + ((color-index uint16 :offset 6) + (debug-data tfragment-debug-data :offset 8) + (color-indices uint32 :offset 12) + (colors uint32 :offset 12) + (dma-chain uint32 3 :offset 32) ;; guessed by decompiler + (dma-common uint32 :offset 32) + (dma-level-0 uint32 :offset 32) + (dma-base uint32 :offset 36) + (dma-level-1 uint32 :offset 40) + (dma-qwc uint8 4 :offset 44) ;; guessed by decompiler + (shader (inline-array adgif-shader) :offset 48) ;; guessed by decompiler + (num-shaders uint8 :offset 52) + (num-base-colors uint8 :offset 53) + (num-level0-colors uint8 :offset 54) + (num-level1-colors uint8 :offset 55) + (color-offset uint8 :offset 56) + (color-count uint8 :offset 57) + (texture-masks-index uint16 :offset 58) + (generic generic-tfragment :offset 60) ) :method-count-assert 17 :size-assert #x40 @@ -15821,11 +16977,10 @@ (:methods ) ) -|# -#| (deftype drawable-inline-array-tfrag (drawable-inline-array) - () + ((data tfragment 1 :inline :offset-assert 32) + (pad uint32)) :method-count-assert 17 :size-assert #x64 :flag-assert #x1100000064 @@ -15833,71 +16988,73 @@ (:methods ) ) -|# -;; (deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) -;; () -;; :flag-assert #x11000000b4 -;; ) +(deftype drawable-inline-array-tfrag-trans (drawable-inline-array-tfrag) + ;; same bug here as jak 1 + ((data2 tfragment 1 :inline :offset-assert 112) + (pad2 uint32)) + :flag-assert #x11000000b4 + ) -;; (deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) -;; () -;; :flag-assert #x11000000b4 -;; ) +(deftype drawable-inline-array-tfrag-water (drawable-inline-array-tfrag) + ;; same bug here as jak 1 + ((data2 tfragment 1 :inline :offset-assert 112) + (pad2 uint32)) + :flag-assert #x11000000b4 + ) -;; (deftype drawable-tree-tfrag (drawable-tree) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag (drawable-tree) + ((time-of-day-pal time-of-day-palette :offset 12) + (arrays drawable-inline-array :dynamic :offset 32 :score 100) ;; either drawable-inline-array-node or drawable-inline-array-tfrag + ) + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) -;; () -;; :flag-assert #x1100000020 -;; ) +(deftype drawable-tree-tfrag-trans (drawable-tree-tfrag) + () + :flag-assert #x1100000020 + ) + +(deftype drawable-tree-tfrag-water (drawable-tree-tfrag-trans) + () + :flag-assert #x1100000020 + ) -;; (deftype drawable-tree-tfrag-water (drawable-tree-tfrag-trans) -;; () -;; :flag-assert #x1100000020 -;; ) -#| (deftype tfrag-dists (structure) - ((data uint32 16 :offset-assert 0) ;; guessed by decompiler - (vector vector 4 :offset-assert 0) ;; guessed by decompiler - (k0s vector 2 :offset-assert 0) ;; guessed by decompiler - (k1s vector 2 :offset-assert 32) ;; guessed by decompiler + ((data uint32 16 :offset-assert 0 :score -1) + (vector vector 4 :inline :offset 0 :score -1) + (k0s vector 2 :inline :offset 0) + (k1s vector 2 :inline :offset 32) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| + (deftype tfrag-data (structure) - ((data uint32 56 :offset-assert 0) ;; guessed by decompiler - (vector vector 14 :offset-assert 0) ;; guessed by decompiler - (fog vector :inline :offset-assert 0) - (val vector :inline :offset-assert 16) - (strgif qword :inline :offset-assert 32) ;; gs-gif-tag :inline - (fangif qword :inline :offset-assert 48) ;; gs-gif-tag :inline - (adgif qword :inline :offset-assert 64) ;; gs-gif-tag :inline - (hvdf-offset vector :inline :offset-assert 80) - (hmge-scale vector :inline :offset-assert 96) - (invh-scale vector :inline :offset-assert 112) - (ambient vector :inline :offset-assert 128) - (guard vector :inline :offset-assert 144) - (dists tfrag-dists :inline :offset-assert 160) - (k0s uint128 2 :offset-assert 160) ;; guessed by decompiler - (k1s uint128 2 :offset-assert 192) ;; guessed by decompiler + ((data uint32 56 :offset 0 :score -1) + (vector vector 14 :inline :offset 0 :score -1) + (fog vector :inline :offset 0) + (val vector :inline :offset 16) + (strgif gs-gif-tag :inline :offset 32) ;; was qword + (fangif gs-gif-tag :inline :offset 48) ;; was qword + (adgif gs-gif-tag :inline :offset 64) ;; was qword + (hvdf-offset vector :inline :offset 80) + (hmge-scale vector :inline :offset 96) + (invh-scale vector :inline :offset 112) + (ambient vector :inline :offset 128) + (guard vector :inline :offset 144) + (dists tfrag-dists :inline :offset 160) + (k0s uint128 2 :offset 160) ;; guessed by decompiler + (k1s uint128 2 :offset 192) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xe0 :flag-assert #x9000000e0 ) -|# -#| (deftype tfrag-control (structure) ((num-base-points uint32 :offset-assert 0) (num-shared-base-points uint32 :offset-assert 4) @@ -15924,9 +17081,7 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype tfrag-stats (structure) ((from int32 :offset-assert 0) (to int32 :offset-assert 4) @@ -15949,9 +17104,7 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype tfrag-packet (structure) ((tag uint128 2 :offset-assert 0) ;; guessed by decompiler ) @@ -15959,9 +17112,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype tfrag-work (structure) ((base-tmpl dma-packet :inline :offset-assert 0) (level-0-tmpl dma-packet :inline :offset-assert 16) @@ -15993,38 +17144,34 @@ :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -#| (deftype tfrag-dma (structure) - ((banka tfragment 16 :offset-assert 4) ;; guessed by decompiler - (bankb tfragment 16 :offset-assert 1028) ;; guessed by decompiler - (outa uint128 128 :offset-assert 2048) ;; guessed by decompiler - (outb uint128 128 :offset-assert 4096) ;; guessed by decompiler - (colors rgba 2048 :offset-assert 6144) ;; guessed by decompiler + ((banka tfragment 16 :inline :offset-assert 0) + (bankb tfragment 16 :inline :offset-assert 1024) + (outa uint128 128 :offset-assert 2048) + (outb uint128 128 :offset-assert 4096) + (colors rgba 2047 :offset-assert 6144) ;; why is this one short!!! ) :method-count-assert 9 :size-assert #x37fc :flag-assert #x9000037fc ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; background-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype background-work (basic) ((tfrag-tree-count int32 :offset-assert 4) (tfrag-trees drawable-tree-tfrag 8 :offset-assert 8) ;; guessed by decompiler (tfrag-levels level 8 :offset-assert 40) ;; guessed by decompiler (tfrag-trans-tree-count int32 :offset-assert 72) - (tfrag-trans-trees UNKNOWN 8 :offset-assert 76) - (tfrag-trans-levels UNKNOWN 8 :offset-assert 108) + (tfrag-trans-trees drawable-tree-tfrag-trans 8 :offset-assert 76) + (tfrag-trans-levels level 8 :offset-assert 108) (tfrag-water-tree-count int32 :offset-assert 140) - (tfrag-water-trees UNKNOWN 8 :offset-assert 144) - (tfrag-water-levels UNKNOWN 8 :offset-assert 176) + (tfrag-water-trees drawable-tree-tfrag-water 8 :offset-assert 144) + (tfrag-water-levels level 8 :offset-assert 176) (shrub-tree-count int32 :offset-assert 208) (shrub-trees drawable-tree-instance-shrub 8 :offset-assert 212) ;; guessed by decompiler (shrub-levels level 8 :offset-assert 244) ;; guessed by decompiler @@ -16032,47 +17179,43 @@ (tie-trees drawable-tree-instance-tie 8 :offset-assert 280) ;; guessed by decompiler (tie-levels level 8 :offset-assert 312) ;; guessed by decompiler (tie-generic basic 8 :offset-assert 344) ;; guessed by decompiler - (tie-generic-trans UNKNOWN 8 :offset-assert 376) + (tie-generic-trans basic 8 :offset-assert 376) (wait-to-vu0 uint32 :offset-assert 408) ) :method-count-assert 9 :size-assert #x19c :flag-assert #x90000019c ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; subdivide-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype subdivide-settings (basic) ((dist float 5 :offset-assert 4) ;; guessed by decompiler (meters float 5 :offset-assert 24) ;; guessed by decompiler (close float 8 :offset-assert 44) ;; guessed by decompiler (far float 8 :offset-assert 76) ;; guessed by decompiler ) + (:methods + (new (symbol type meters meters) _type_) + ) :method-count-assert 9 :size-assert #x6c :flag-assert #x90000006c ) -|# -#| (deftype subdivide-dists (structure) ((data uint32 32 :offset-assert 0) ;; guessed by decompiler - (vector vector 8 :offset-assert 0) ;; guessed by decompiler - (k0s uint128 4 :offset-assert 0) ;; guessed by decompiler - (k1s uint128 4 :offset-assert 64) ;; guessed by decompiler + (vector vector 8 :inline :offset 0) ;; guessed by decompiler + (k0s uint128 4 :offset 0) ;; guessed by decompiler + (k1s uint128 4 :offset 64) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x80 :flag-assert #x900000080 ) -|# -#| (deftype terrain-stats (structure) ((pris tr-stat :inline :offset-assert 0) (tie-generic tr-stat :inline :offset-assert 16) @@ -16109,27 +17252,23 @@ :size-assert #x1e0 :flag-assert #x9000001e0 ) -|# -#| (deftype dma-area (structure) - ((instance-shrub-dma instance-shrub-dma :inline :offset-assert 0) - (draw-node-dma draw-node-dma :inline :offset-assert 0) - (tfrag-dma tfrag-dma :inline :offset-assert 0) - (instance-tie-dma instance-tie-dma :inline :offset-assert 0) - (prototype-tie-dma prototype-tie-dma :inline :offset-assert 0) - (wind-dma wind-dma :inline :offset-assert 0) - (time-of-day-dma time-of-day-dma :inline :offset-assert 0) - (decomp-work decomp-work :inline :offset-assert 0) - (ocean-vertex ocean-vertex 4 :offset-assert 0) ;; guessed by decompiler + ((instance-shrub-dma instance-shrub-dma :inline :offset 0) + (draw-node-dma draw-node-dma :inline :offset 0) + (tfrag-dma tfrag-dma :inline :offset 0) + (instance-tie-dma instance-tie-dma :inline :offset 0) + (prototype-tie-dma prototype-tie-dma :inline :offset 0) + (wind-dma wind-dma :inline :offset 0) + (time-of-day-dma time-of-day-dma :inline :offset 0) + (decomp-work decomp-work :inline :offset 0) + (ocean-vertex ocean-vertex 4 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x38a0 :flag-assert #x9000038a0 ) -|# -#| (deftype background-area (structure) ((dma-area dma-area :inline :offset-assert 0) (vis-list uint8 2048 :offset-assert 14496) ;; guessed by decompiler @@ -16138,39 +17277,35 @@ :size-assert #x40a0 :flag-assert #x9000040a0 ) -|# -#| (deftype foreground-area (structure) ((generic-work generic-work :inline :offset-assert 0) - (foreground-work foreground-work :inline :offset-assert 0) - (joint-work joint-work :inline :offset-assert 0) - (bone-mem bone-memory :inline :offset-assert 0) - (shadow-work shadow-work :inline :offset-assert 0) + (foreground-work foreground-work :inline :offset 0) + (joint-work joint-work :inline :offset 0) + (bone-mem bone-memory :inline :offset 0) + (shadow-work shadow-work :inline :offset 0) ) :method-count-assert 9 :size-assert #x3fe0 :flag-assert #x900003fe0 ) -|# -#| (deftype region-prim-area (structure) ((region-prim-list region-prim-list :inline :offset-assert 0) (pos vector :inline :offset-assert 1296) - (ray vector :inline :offset-assert 1328) - (region-enter-count int32 :offset-assert 1360) - (region-enter-list UNKNOWN 320 :offset-assert 1364) - (region-enter-prim-list UNKNOWN 320 :offset-assert 2644) + (ray vector :inline :offset 1328) + (region-enter-count int32 :offset 1360) + (region-enter-list uint32 320 :offset-assert 1364) + (region-enter-prim-list uint32 320 :offset-assert 2644) (region-exit-count int32 :offset-assert 3924) - (region-exit-list UNKNOWN 320 :offset-assert 3928) - (region-exit-prim-list UNKNOWN 320 :offset-assert 5208) + (region-exit-list uint32 320 :offset-assert 3928) + (region-exit-prim-list uint32 320 :offset-assert 5208) (region-inside-count int32 :offset-assert 6488) - (region-inside-list UNKNOWN 320 :offset-assert 6492) - (region-inside-prim-list UNKNOWN 320 :offset-assert 7772) + (region-inside-list uint32 320 :offset-assert 6492) + (region-inside-prim-list uint32 320 :offset-assert 7772) (region-start-count int32 :offset-assert 9052) - (region-start-list UNKNOWN 320 :offset-assert 9056) - (region-start-prim-list UNKNOWN 320 :offset-assert 10336) + (region-start-list uint32 320 :offset-assert 9056) + (region-start-prim-list uint32 320 :offset-assert 10336) ) :method-count-assert 13 :size-assert #x2d60 @@ -16182,33 +17317,27 @@ (region-prim-area-method-12 () none 12) ) ) -|# -#| (deftype sprite-area (structure) - ((clock-data UNKNOWN 13 :offset-assert 0) - (buffer UNKNOWN :dynamic :offset-assert 208) + ((clock-data vector 13 :inline :offset-assert 0) + (buffer uint8 :dynamic :offset-assert 208) ) :method-count-assert 9 :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype work-area (structure) ((background background-area :inline :offset-assert 0) - (foreground foreground-area :inline :offset-assert 0) - (region-prim region-prim-area :inline :offset-assert 0) - (sprite sprite-area :inline :offset-assert 0) + (foreground foreground-area :inline :offset 0) + (region-prim region-prim-area :inline :offset 0) + (sprite sprite-area :inline :offset 0) ) :method-count-assert 9 :size-assert #x40a0 :flag-assert #x9000040a0 ) -|# -#| (deftype terrain-context (structure) ((work work-area :inline :offset-assert 0) ) @@ -16216,15 +17345,30 @@ :size-assert #x40a0 :flag-assert #x9000040a0 ) -|# -;; (define-extern *terrain-stats* object) ;; terrain-stats -;; (define-extern *collide-stats* object) ;; collide-stats +(define-extern *terrain-stats* terrain-stats) +(define-extern *collide-stats* collide-stats) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defenum entity-perm-status + :bitfield #t + :type uint16 + (bit-0 0) + (bit-1 1) + (dead 2) + (bit-3 3) + (bit-4 4) + (bit-5 5) + (subtask-complete 6) + (bit-7 7) + (bit-8 8) + (bit-9 9) + (bit-10 10) + ) + (deftype entity-perm (structure) ((user-object object 2 :offset-assert 0) ;; guessed by decompiler (user-uint64 uint64 :offset 0) @@ -16235,7 +17379,7 @@ (user-uint16 uint16 4 :offset 0) ;; guessed by decompiler (user-int8 int8 8 :offset 0) ;; guessed by decompiler (user-uint8 uint8 8 :offset 0) ;; guessed by decompiler - (status uint16 :offset 8) ;; entity-perm-status + (status entity-perm-status :offset 8) ;; entity-perm-status (dummy uint8 1 :offset 10) ;; guessed by decompiler (task uint8 :offset 11) ;; game-task (aid actor-id :offset 12) ;; guessed by decompiler @@ -16274,33 +17418,27 @@ ) ) - -#| (deftype entity-perm-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data entity-perm :dynamic :offset-assert 16) ;; guessed by decompiler + ((data entity-perm :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| + (deftype entity-links-array (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data entity-links :dynamic :offset-assert 16) ;; guessed by decompiler + ((data entity-links :dynamic :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# (deftype entity (res-lump) - ((pad uint32 5)) + ((trans vector :inline :offset-assert 32) + (aid uint32 :offset-assert 48) + ) :method-count-assert 27 :size-assert #x34 :flag-assert #x1b00000034 @@ -16314,14 +17452,14 @@ ) ) -;; (deftype entity-camera (entity) -;; () -;; :flag-assert #x1b00000050 -;; ) +(deftype entity-camera (entity) + ((connect connectable :inline :offset-assert 64)) ;; guess from jak 1 + :flag-assert #x1b00000050 + ) -#| +(declare-type nav-mesh basic) (deftype entity-nav-mesh (entity) - () + ((nav-mesh nav-mesh)) :method-count-assert 29 :size-assert #x38 :flag-assert #x1d00000038 @@ -16331,33 +17469,40 @@ (entity-nav-mesh-method-28 () none 28) ) ) -|# -;; (deftype entity-race-mesh (entity) -;; () -;; :flag-assert #x1d00000038 -;; ) +(declare-type race-mesh basic) +(deftype entity-race-mesh (entity) + ((race-mesh race-mesh) + ) + :flag-assert #x1d00000038 + (:methods + (entity-race-mesh-method-27 () none 27) + (entity-race-mesh-method-28 () none 28) + ) + ) -(declare-type entity-actor entity) -#| +(define-extern entity-actor type) (deftype entity-actor (entity) - () + ((etype type :offset 56) + (task game-task :offset-assert 60) + (kill-mask task-mask :offset 52) + (vis-id int16 :offset-assert 62) + (quat quaternion :inline :offset-assert 64) + ) :method-count-assert 33 :size-assert #x50 :flag-assert #x2100000050 ;; Failed to read fields. (:methods - (entity-actor-method-27 () none 27) ;; (next-actor (_type_) entity-actor 27) - (entity-actor-method-28 () none 28) ;; (prev-actor (_type_) entity-actor 28) + (next-actor (_type_) entity-actor 27) + (prev-actor (_type_) entity-actor 28) (entity-actor-method-29 () none 29) ;; (debug-print (_type_ symbol type) none 29) (entity-actor-method-30 () none 30) ;; (dummy-30 (_type_ entity-perm-status symbol) none 30) (entity-actor-method-31 () none 31) (entity-actor-method-32 () none 32) ) ) -|# -#| (deftype actor-reference (structure) ((actor basic :offset-assert 0) (id uint32 :offset-assert 4) @@ -16366,21 +17511,15 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype actor-group (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (data UNKNOWN :dynamic :offset-assert 16) + ((data actor-reference :dynamic :inline :offset-assert 16) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype entity-info (basic) ((ptype type :offset-assert 4) ;; guessed by decompiler (package basic :offset-assert 8) @@ -16392,59 +17531,53 @@ :size-assert #x18 :flag-assert #x900000018 ) -|# -#| (deftype actor-bank (basic) - ((pause-dist float :offset-assert 4) - (birth-dist float :offset-assert 8) + ((pause-dist meters :offset-assert 4) + (birth-dist meters :offset-assert 8) (birth-max int32 :offset-assert 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *generate-actor-vis* object) ;; symbol -;; (define-extern *generate-actor-vis-start* object) ;; symbol -;; (define-extern *generate-actor-vis-output* object) ;; symbol -;; (define-extern *ACTOR-bank* actor-bank) ;; actor-bank +(define-extern *generate-actor-vis* symbol) +(define-extern *generate-actor-vis-start* symbol) +(define-extern *generate-actor-vis-output* symbol) +(define-extern *ACTOR-bank* actor-bank) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sprite-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sprite-vec-data-2d (structure) ((x-y-z-sx vector :inline :offset-assert 0) (flag-rot-sy vector :inline :offset-assert 16) (r-g-b-a vector :inline :offset-assert 32) - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (sx float :offset-assert 12) - (sy float :offset-assert 28) - (rot float :offset-assert 24) - (flag int32 :offset-assert 16) - (matrix int32 :offset-assert 20) - (warp-turns int32 :offset-assert 16) - (r float :offset-assert 32) - (g float :offset-assert 36) - (b float :offset-assert 40) - (a float :offset-assert 44) - (trans vector3s :inline :offset-assert 0) - (color rgbaf :inline :offset-assert 32) - (data uint128 1 :offset-assert 0) ;; guessed by decompiler - (data64 uint64 6 :offset-assert 0) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (sx float :offset 12) + (sy float :offset 28) + (rot float :offset 24) + (flag int32 :offset 16) + (matrix int32 :offset 20) + (warp-turns int32 :offset 16) + (r float :offset 32) + (g float :offset 36) + (b float :offset 40) + (a float :offset 44) + (trans vector3s :inline :offset 0) + (color rgbaf :inline :offset 32) + (data uint128 1 :offset 0) ;; guessed by decompiler + (data64 uint64 6 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype sprite-array-2d (basic) ((num-sprites int32 2 :offset-assert 4) ;; guessed by decompiler (num-valid int32 2 :offset-assert 12) ;; guessed by decompiler @@ -16457,37 +17590,33 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype sprite-vec-data-3d (structure) ((x-y-z-sx vector :inline :offset-assert 0) (qx-qy-qz-sy vector :inline :offset-assert 16) (r-g-b-a vector :inline :offset-assert 32) - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (sx float :offset-assert 12) - (sy float :offset-assert 28) - (qx float :offset-assert 16) - (qy float :offset-assert 20) - (qz float :offset-assert 24) - (r float :offset-assert 32) - (g float :offset-assert 36) - (b float :offset-assert 40) - (a float :offset-assert 44) - (trans vector3s :inline :offset-assert 0) - (rot vector3s :inline :offset-assert 16) - (color rgbaf :inline :offset-assert 32) - (data uint128 1 :offset-assert 0) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (z float :offset 8) + (sx float :offset 12) + (sy float :offset 28) + (qx float :offset 16) + (qy float :offset 20) + (qz float :offset 24) + (r float :offset 32) + (g float :offset 36) + (b float :offset 40) + (a float :offset 44) + (trans vector3s :inline :offset 0) + (rot vector3s :inline :offset 16) + (color rgbaf :inline :offset 32) + (data uint128 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype sprite-array-3d (basic) ((num-sprites int32 2 :offset-assert 4) ;; guessed by decompiler (num-valid int32 2 :offset-assert 12) ;; guessed by decompiler @@ -16499,17 +17628,15 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; simple-sprite-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype sprite-glow-data (structure) ((position vector :inline :offset-assert 0) - (size-x float :offset-assert 12) + (size-x float :offset 12) (size-probe float :offset-assert 16) (z-offset float :offset-assert 20) (rot-angle float :offset-assert 24) @@ -16524,12 +17651,10 @@ :size-assert #x40 :flag-assert #xa00000040 (:methods - (sprite-glow-data-method-9 () none 9) + (set-trans (_type_ vector) none 9) ) ) -|# -#| (deftype simple-sprite-system (structure) ((count int16 :offset-assert 0) (max-count int16 :offset-assert 2) @@ -16544,33 +17669,29 @@ (simple-sprite-system-method-11 () none 11) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; eye-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype eye (structure) - ((data vector 2 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (lid float :offset-assert 8) - (iris-scale float :offset-assert 16) - (pupil-scale float :offset-assert 20) - (lid-scale float :offset-assert 24) + ((data vector 2 :inline :offset-assert 0) ;; guessed by decompiler + (x float :offset 0) + (y float :offset 4) + (lid float :offset 8) + (iris-scale float :offset 16) + (pupil-scale float :offset 20) + (lid-scale float :offset 24) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype eye-control (structure) - ((process uint64 :offset-assert 0) ;; handle - (draw-flag basic :offset-assert 8) + ((process handle :offset-assert 0) + (draw-flag symbol :offset-assert 8) (different-eyes basic :offset-assert 12) (random-time uint16 :offset-assert 16) (bucket uint16 :offset-assert 18) @@ -16583,29 +17704,24 @@ :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype eye-control-array (basic) - ((data eye-control 16 :offset-assert 16) ;; guessed by decompiler + ((data eye-control 16 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x610 :flag-assert #x900000610 ) -|# -#| (deftype eye-control-arrays (basic) - ((data UNKNOWN 6 :offset-assert 20) + ((data eye-control-array 6 :inline :offset-assert 16) + (pad uint32) ) :method-count-assert 9 :size-assert #x2474 :flag-assert #x900002474 ) -|# -#| (deftype eye-work (structure) ((sprite-tmpl dma-gif-packet :inline :offset-assert 0) (sprite-tmpl2 dma-gif-packet :inline :offset-assert 32) @@ -16616,15 +17732,137 @@ :size-assert #x88 :flag-assert #x900000088 ) -|# -;; (define-extern *eye-control-arrays* eye-control-arrays) +(define-extern *eye-control-arrays* eye-control-arrays) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparticle-launcher-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +;; note: changed from jak 1, slightly. +(defenum sp-field-id + :type uint16 + + (misc-fields-start 0) + (spt-texture 1) + (spt-anim 2) + (spt-anim-speed 3) + (spt-birth-func 4) + (spt-joint/refpoint 5) + (spt-num 6) + (spt-sound 7) + (misc-fields-end 8) + + (sprite-fields-start 9) + (spt-x 10) + (spt-y 11) + (spt-z 12) + (spt-scale-x 13) + (spt-rot-x 14) + (spt-rot-y 15) + (spt-rot-z 16) + (spt-scale-y 17) + (spt-r 18) + (spt-g 19) + (spt-b 20) + (spt-a 21) + (sprite-fields-end 22) + + (cpu-fields-start 23) + (spt-omega 24) + (spt-vel-x 25) + (spt-vel-y 26) + (spt-vel-z 27) + (spt-scalevel-x 28) + (spt-rotvel-x 29) + (spt-rotvel-y 30) + (spt-rotvel-z 31) + (spt-scalevel-y 32) + (spt-fade-r 33) + (spt-fade-g 34) + (spt-fade-b 35) + (spt-fade-a 36) + (spt-accel-x 37) + (spt-accel-y 38) + (spt-accel-z 39) + (spt-dummy 40) + (spt-quat-x 41) + (spt-quat-y 42) + (spt-quat-z 43) + (spt-quad-w 44) + (spt-friction 45) + (spt-timer 46) + (spt-flags 47) + (spt-userdata 48) + (spt-func 49) + (spt-next-time 50) + (spt-next-launcher 51) + (cpu-fields-end 52) + + (launch-fields-start 53) + (spt-launchrot-x 54) + (spt-launchrot-y 55) + (spt-launchrot-z 56) + (spt-launchrot-w 57) + (spt-conerot-x 58) + (spt-conerot-y 59) + (spt-conerot-z 60) + (spt-conerot-w 61) + (spt-rotate-x 62) + (spt-rotate-y 63) + (spt-rotate-z 64) + + (spt-conerot-radius 65) + (spt-mat-scale-x 66) + (spt-mat-scale-y 67) + (spt-mat-scale-z 68) + (launch-fields-end 69) + + (spt-scale 70) + (spt-scalevel 71) + (spt-end 72) + ) + +;; appears the same as jak 1 +(defenum sp-flag + :type uint16 + (plain-v1 0) ;; just a plain signed integer. No random crap. + (float-with-rand 1) + (int-with-rand 2) + (copy-from-other-field 3) + (plain-v2 4) + (from-pointer 5) + (part-by-id 6) + ) + +(defenum sp-group-item-flag + :bitfield #t + :type uint16 + (is-3d 0) + (bit1 1) + (start-dead 2) + (launch-asap 3) + (bit6 6) + ) + +(defenum sp-launch-state-flags + :bitfield #t + :type uint16 + (launcher-active 0) ;; active + (particles-active 1) ;; wants to launch + (bit2 2) + ) + +(defenum sp-group-flag + :bitfield #t + :type uint16 + (use-local-clock 0) + (always-draw 1) + (screen-space 2) + (unknown-bit-01 3) ;; beach-part + ) + + (deftype sparticle-birthinfo (structure) ((sprite uint32 :offset-assert 0) (anim int32 :offset-assert 4) @@ -16633,40 +17871,36 @@ (joint-ppoint int32 :offset-assert 16) (num-to-birth float :offset-assert 20) (sound basic :offset-assert 24) - (dataf float 1 :offset-assert 0) ;; guessed by decompiler - (data uint32 1 :offset-assert 0) ;; guessed by decompiler + (dataf float 1 :offset 0) ;; guessed by decompiler + (data uint32 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x1c :flag-assert #x90000001c ) -|# -#| (deftype sp-field-init-spec (structure) - ((field uint16 :offset-assert 0) ;; sp-field-id - (flags uint16 :offset-assert 2) ;; sp-flag + ((field sp-field-id :offset-assert 0) + (flags sp-flag :offset-assert 2) (initial-valuef float :offset-assert 4) (random-rangef float :offset-assert 8) (random-multf float :offset-assert 12) - (initial-value int32 :offset-assert 4) - (random-range int32 :offset-assert 8) - (random-mult int32 :offset-assert 12) - (func symbol :offset-assert 4) ;; guessed by decompiler - (tex texture-id :offset-assert 4) ;; guessed by decompiler - (pntr pointer :offset-assert 4) ;; guessed by decompiler - (object basic :offset-assert 4) - (sym symbol :offset-assert 4) ;; guessed by decompiler - (sound sound-spec :offset-assert 4) ;; guessed by decompiler + (initial-value int32 :offset 4) + (random-range int32 :offset 8) + (random-mult int32 :offset 12) + (func symbol :offset 4) ;; guessed by decompiler + (tex texture-id :offset 4) ;; guessed by decompiler + (pntr pointer :offset 4) ;; guessed by decompiler + (object basic :offset 4) + (sym symbol :offset 4) ;; guessed by decompiler + (sound sound-spec :offset 4) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ;; field object uses ~A with a signed load ) -|# -#| (deftype sparticle-launcher (basic) ((birthaccum float :offset-assert 4) (soundaccum float :offset-assert 8) @@ -16680,14 +17914,12 @@ (sparticle-launcher-method-10 () none 10) ) ) -|# -#| (deftype sparticle-group-item (structure) ((launcher uint32 :offset-assert 0) (fade-after meters :offset-assert 4) (falloff-to meters :offset-assert 8) - (flags uint16 :offset-assert 12) ;; sp-group-item-flag + (flags sp-group-item-flag :offset-assert 12) (period uint16 :offset-assert 14) (length uint16 :offset-assert 16) (offset int16 :offset-assert 18) ;; uint16 @@ -16698,12 +17930,12 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| +(declare-type sparticle-cpuinfo structure) + (deftype sparticle-launch-state (structure) ((group-item sparticle-group-item :offset-assert 0) - (flags uint16 :offset-assert 4) ;; sp-launch-state-flags + (flags sp-launch-state-flags :offset-assert 4) (randomize uint16 :offset-assert 6) (center vector :offset-assert 8) (sprite3d sprite-vec-data-3d :offset-assert 12) @@ -16712,29 +17944,27 @@ (accum float :offset-assert 24) (spawn-time uint32 :offset-assert 28) (control basic :offset-assert 32) - (swarm basic :offset-assert 20) - (seed uint32 :offset-assert 24) - (time uint32 :offset-assert 28) - (spec basic :offset-assert 16) - (id uint32 :offset-assert 12) + (swarm basic :offset 20) + (seed uint32 :offset 24) + (time uint32 :offset 28) + (spec basic :offset 16) + (id uint32 :offset 12) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype sparticle-launch-group (basic) ((length int16 :offset-assert 4) (duration uint16 :offset-assert 6) (linger-duration uint16 :offset-assert 8) - (flags uint16 :offset-assert 10) ;; sp-group-flag + (flags sp-group-flag :offset-assert 10) (name string :offset-assert 12) ;; guessed by decompiler (launcher (inline-array sparticle-group-item) :offset-assert 16) ;; guessed by decompiler - (rotate-x deg :offset-assert 20) - (rotate-y deg :offset-assert 24) - (rotate-z deg :offset-assert 28) + (rotate-x degrees :offset-assert 20) + (rotate-y degrees :offset-assert 24) + (rotate-z degrees :offset-assert 28) (scale-x float :offset-assert 32) (scale-y float :offset-assert 36) (scale-z float :offset-assert 40) @@ -16747,24 +17977,20 @@ (sparticle-launch-group-method-9 () none 9) ;; (create-launch-control (_type_ process) sparticle-launch-control 9) ) ) -|# -#| (deftype sparticle-launch-control (inline-array-class) - ((length int32 :offset-assert 4) - (allocated-length int32 :offset-assert 8) - (group sparticle-launch-group :offset-assert 16) ;; guessed by decompiler + ((group sparticle-launch-group :offset-assert 16) ;; guessed by decompiler (proc process :offset-assert 20) ;; guessed by decompiler (local-clock int32 :offset-assert 24) (fade float :offset-assert 28) (matrix int8 :offset-assert 32) ;; int32 - (state-mode UNKNOWN 3 :offset-assert 33) + (state-mode uint8 3 :offset-assert 33) (state-counter uint32 :offset-assert 36) (last-spawn-frame int32 :offset-assert 40) (last-spawn-time int32 :offset-assert 44) (origin matrix :inline :offset-assert 48) - (center vector :inline :offset-assert 96) - (data sparticle-launch-state :dynamic :offset-assert 112) ;; guessed by decompiler + (center vector :inline :offset 96) + (data sparticle-launch-state :dynamic :inline :offset-assert 112) ;; guessed by decompiler ) :method-count-assert 16 :size-assert #x70 @@ -16779,15 +18005,37 @@ (sparticle-launch-control-method-15 () none 15) ) ) -|# -;; (define-extern *launch-matrix* object) +(define-extern *launch-matrix* matrix) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sparticle-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum sp-cpuinfo-flag + :bitfield #t + :type uint32 + (bit0 0) + (bit1 1) + (bit2 2) ;; cleared after an aux has its func set to add-to-sprite-aux-lst + (bit3 3) + (bit4 4) + (ready-to-launch 6) ;; maybe just just death? + (bit7 7) + (aux-list 8) ;; prevents relaunch, adds to aux + (bit9 9) + (level0 10) + (level1 11) + (bit12 12) ;; required to relaunch + (bit13 13) + (bit14 14) + (use-global-acc 16) + (launch-along-z 17) + (left-multiply-quat 18) + (right-multiply-quat 19) + (set-conerot 20) + ) + (deftype sparticle-cpuinfo (structure) ((sprite sprite-vec-data-2d :offset-assert 0) (adgif adgif-shader :offset-assert 4) @@ -16798,19 +18046,19 @@ (fade rgbaf :inline :offset-assert 48) (acc vector :inline :offset-assert 64) (rotvel3d quaternion :inline :offset-assert 80) - (vel vector3s :inline :offset-assert 16) - (accel vector3s :inline :offset-assert 64) - (scalevelx float :offset-assert 28) - (scalevely float :offset-assert 44) + (vel vector3s :inline :offset 16) + (accel vector3s :inline :offset 64) + (scalevelx float :offset 28) + (scalevely float :offset 44) (friction float :offset-assert 96) (timer int32 :offset-assert 100) (flags sp-cpuinfo-flag :offset-assert 104) ;; guessed by decompiler (user-int32 int32 :offset-assert 108) - (user-uint32 uint32 :offset-assert 108) - (user-float float :offset-assert 108) - (user-pntr uint32 :offset-assert 108) - (user-object basic :offset-assert 108) - (user-sprite sprite-vec-data-2d :offset-assert 108) + (user-uint32 uint32 :offset 108) + (user-float float :offset 108 :score 1) + (user-pntr uint32 :offset 108) + (user-object basic :offset 108) + (user-sprite sprite-vec-data-2d :offset 108) (sp-func basic :offset-assert 112) (next-time uint32 :offset-assert 116) (next-launcher basic :offset-assert 120) @@ -16820,19 +18068,17 @@ (user1-int16 uint16 :offset-assert 130) (key sparticle-launch-control :offset-assert 132) ;; guessed by decompiler (binding sparticle-launch-state :offset-assert 136) - (data uint32 1 :offset-assert 12) ;; guessed by decompiler - (datab UNKNOWN 4 :offset-assert 12) - (dataf float 1 :offset-assert 12) ;; guessed by decompiler - (datac uint8 1 :offset-assert 12) ;; guessed by decompiler + (data uint32 1 :offset 12) ;; guessed by decompiler + (datab uint8 4 :offset 12) + (dataf float 1 :offset 12) ;; guessed by decompiler + (datac uint8 1 :offset 12) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x8c :flag-assert #x90000008c ;; field user-object uses ~A with a signed load field key uses ~A with a signed load ) -|# -#| (deftype sparticle-launchinfo (structure) ((launchrot vector :inline :offset-assert 0) (conerot vector :inline :offset-assert 16) @@ -16840,21 +18086,19 @@ (rotate-y float :offset-assert 36) (rotate-z float :offset-assert 40) (coneradius float :offset-assert 44) - (rotate vector :inline :offset-assert 32) - (scale-x float :offset-assert 48) - (scale-y float :offset-assert 52) - (scale-z float :offset-assert 56) - (dummy float :offset-assert 60) - (scale vector :inline :offset-assert 48) - (data uint8 1 :offset-assert 0) ;; guessed by decompiler + (rotate vector :inline :offset 32) + (scale-x float :offset 48) + (scale-y float :offset 52) + (scale-z float :offset 56) + (dummy float :offset 60) + (scale vector :inline :offset 48) + (data uint8 1 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype sparticle-system (basic) ((blocks int32 2 :offset-assert 4) ;; guessed by decompiler (length int32 2 :offset-assert 12) ;; guessed by decompiler @@ -16870,15 +18114,13 @@ :size-assert #x34 :flag-assert #x900000034 ) -|# -;; (define-extern *sp-60-hz* object) ;; symbol +(define-extern *sp-60-hz* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; actor-link-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype actor-link-info (basic) ((process process :offset-assert 4) ;; guessed by decompiler (next entity-actor :offset-assert 8) ;; guessed by decompiler @@ -16888,43 +18130,57 @@ :size-assert #x10 :flag-assert #x1a00000010 (:methods - ;; (new (symbol type process) _type_ 0) - (actor-link-info-method-9 () none 9) ;; (get-matching-actor-type-mask (_type_ type) int 9) - (actor-link-info-method-10 () none 10) ;; (actor-count-before (_type_) int 10) - (actor-link-info-method-11 () none 11) ;; (link-to-next-and-prev-actor (_type_) entity-actor 11) - (actor-link-info-method-12 () none 12) ;; (get-next (_type_) entity-actor 12) - (actor-link-info-method-13 () none 13) ;; (get-prev (_type_) entity-actor 13) - (actor-link-info-method-14 () none 14) ;; (get-next-process (_type_) process 14) - (actor-link-info-method-15 () none 15) ;; (get-prev-process (_type_) process 15) - (actor-link-info-method-16 () none 16) ;; (apply-function-forward (_type_ (function entity-actor object object) object) int 16) - (actor-link-info-method-17 () none 17) ;; (apply-function-reverse (_type_ (function entity-actor object object) object) int 17) - (actor-link-info-method-18 () none 18) ;; (apply-all (_type_ (function entity-actor object object) object) int 18) - (actor-link-info-method-19 () none 19) ;; (send-to-all (_type_ symbol) none 19) - (actor-link-info-method-20 () none 20) ;; (send-to-all-after (_type_ symbol) object 20) - (actor-link-info-method-21 () none 21) ;; (send-to-all-before (_type_ symbol) object 21) - (actor-link-info-method-22 () none 22) ;; (send-to-next-and-prev (_type_ symbol) none 22) - (actor-link-info-method-23 () none 23) ;; (send-to-next (_type_ symbol) none 23) - (actor-link-info-method-24 () none 24) ;; (send-to-prev (_type_ symbol) none 24) - (actor-link-info-method-25 () none 25) ;; (actor-count (_type_) int 25) + (new (symbol type process symbol) _type_ 0) + (get-matching-actor-type-mask (_type_ type) int 9) + (actor-count-before (_type_) int 10) + (link-to-next-and-prev-actor (_type_) actor-link-info 11) + (get-next (_type_) entity-actor 12) + (get-prev (_type_) entity-actor 13) + (get-next-process (_type_) process 14) + (get-prev-process (_type_) process 15) + (apply-function-forward (_type_ (function entity-actor object object) object) int 16) + (apply-function-reverse (_type_ (function entity-actor object object) object) int 17) + (apply-all (_type_ (function entity-actor object object) object) int 18) + (send-to-all (_type_ symbol) none 19) + (send-to-all-after (_type_ symbol) object 20) + (send-to-all-before (_type_ symbol) object 21) + (send-to-next-and-prev (_type_ symbol) none 22) + (send-to-next (_type_ symbol) none 23) + (send-to-prev (_type_ symbol) none 24) + (actor-count (_type_) int 25) ) ) -|# -;; (define-extern entity-actor-lookup function) ;; (function res-lump symbol int entity-actor) -;; (define-extern entity-actor-count function) ;; (function res-lump symbol int) -;; (define-extern actor-link-subtask-complete-hook function) ;; (function entity-actor (pointer symbol) symbol) -;; (define-extern actor-link-subtask-incomplete-count-hook function) -;; (define-extern actor-link-dead-hook function) ;; (function entity-actor (pointer symbol) symbol) -;; (define-extern alt-actor-list-subtask-incomplete-count function) ;; (function process-drawable int) +(define-extern entity-actor-lookup (function res-lump symbol int entity-actor)) +(define-extern entity-actor-count (function res-lump symbol int)) +(define-extern actor-link-subtask-complete-hook (function entity-actor (pointer symbol) symbol)) +(define-extern actor-link-subtask-incomplete-count-hook (function entity-actor (pointer uint64) symbol)) +(define-extern actor-link-dead-hook (function entity-actor (pointer symbol) symbol)) +(define-extern alt-actor-list-subtask-incomplete-count (function process-drawable int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| + +(defenum cam-index-options + :type uint32 + :bitfield #t + (RADIAL) + (SPHERICAL) + ) + +(defenum slave-los-state + :type uint32 + (none 0) + (cw 1) + (ccw 2) + (between 3) + ) + (deftype cam-index (structure) ((flags cam-index-options :offset-assert 0) ;; guessed by decompiler - (vec vector 2 :offset-assert 16) ;; guessed by decompiler + (vec vector 2 :inline :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 11 :size-assert #x30 @@ -16934,9 +18190,7 @@ (cam-index-method-10 () none 10) ;; (dummy-10 (_type_ vector) float 10) ) ) -|# -#| (deftype tracking-point (structure) ((position vector :inline :offset-assert 0) (direction vector :inline :offset-assert 16) @@ -16948,9 +18202,7 @@ :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype tracking-spline-sampler (structure) ((cur-pt int32 :offset-assert 0) (partial-pt float :offset-assert 4) @@ -16959,11 +18211,9 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype tracking-spline (structure) - ((point tracking-point 32 :offset-assert 0) ;; guessed by decompiler + ((point tracking-point 32 :inline :offset-assert 0) ;; guessed by decompiler (summed-len float :offset-assert 1536) (free-point int32 :offset-assert 1540) (used-point int32 :offset-assert 1544) @@ -16999,9 +18249,7 @@ (tracking-spline-method-23 () none 23) ;; (TODO-RENAME-23 (_type_) none 23) ) ) -|# -#| (deftype cam-float-seeker (structure) ((target float :offset-assert 0) (value float :offset-assert 4) @@ -17010,19 +18258,18 @@ (max-vel float :offset-assert 16) (max-partial float :offset-assert 20) ) + :pack-me :method-count-assert 13 :size-assert #x18 :flag-assert #xd00000018 (:methods - (cam-float-seeker-method-9 () none 9) ;; (init-cam-float-seeker (_type_ float float float float) none 9) - (cam-float-seeker-method-10 () none 10) ;; (copy-cam-float-seeker (_type_ _type_) none 10) - (cam-float-seeker-method-11 () none 11) ;; (update! (_type_ float) none 11) - (cam-float-seeker-method-12 () none 12) ;; (jump-to-target! (_type_ float) float 12) + (init (_type_ float float float float) none 9) + (copy-to (_type_ _type_) none 10) + (update! (_type_ float) none 11) + (jump-to-target! (_type_ float) float 12) ) ) -|# -#| (deftype cam-vector-seeker (structure) ((target vector :inline :offset-assert 0) (value vector :inline :offset-assert 16) @@ -17035,13 +18282,11 @@ :size-assert #x3c :flag-assert #xb0000003c (:methods - (cam-vector-seeker-method-9 () none 9) ;; (init! (_type_ vector float float float) none 9) - (cam-vector-seeker-method-10 () none 10) ;; (update! (_type_ vector) none 10) + (init (_type_ vector float float float) none 9) + (update! (_type_ vector) none 10) ) ) -|# -#| (deftype cam-rotation-tracker (structure) ((inv-mat matrix :inline :offset-assert 0) (no-follow basic :offset-assert 64) @@ -17060,223 +18305,200 @@ :size-assert #x108 :flag-assert #x900000108 ) -|# -#| (deftype camera-combiner (process) - ((trans vector :inline :offset-assert 124) - (inv-camera-rot matrix :inline :offset-assert 140) - (fov float :offset-assert 204) - (interp-val float :offset-assert 208) - (interp-step float :offset-assert 212) - (dist-from-src float :offset-assert 216) - (dist-from-dest float :offset-assert 220) - (flip-control-axis vector :inline :offset-assert 236) - (velocity vector :inline :offset-assert 252) - (tracking-status uint64 :offset-assert 268) - (tracking-options int32 :offset-assert 276) - (tracking cam-rotation-tracker :inline :offset-assert 284) - (fast-rot basic :offset-assert 548) + ((trans vector :inline :offset-assert 128) + (inv-camera-rot matrix :inline :offset-assert 144) + (fov float :offset-assert 208) + (interp-val float :offset-assert 212) + (interp-step float :offset-assert 216) + (dist-from-src float :offset-assert 220) + (dist-from-dest float :offset-assert 224) + (flip-control-axis vector :inline :offset-assert 240) + (velocity vector :inline :offset-assert 256) + (tracking-status uint64 :offset-assert 272) + (tracking-options int32 :offset-assert 280) + (tracking cam-rotation-tracker :inline :offset-assert 288) + (fast-rot basic :offset-assert 552) ) :method-count-assert 14 :size-assert #x22c :flag-assert #xe01b0022c - (:methods - (camera-combiner-method-9 () none 9) - (camera-combiner-method-10 () none 10) - (camera-combiner-method-11 () none 11) - (camera-combiner-method-12 () none 12) - (camera-combiner-method-13 () none 13) - ) ) -|# -#| (deftype camera-slave (process) - ((trans vector :inline :offset-assert 124) - (fov float :offset-assert 140) - (fov0 float :offset-assert 144) - (fov1 float :offset-assert 148) - (fov-index cam-index :inline :offset-assert 156) - (tracking cam-rotation-tracker :inline :offset-assert 204) - (view-off-param float :offset-assert 468) - (view-off vector :inline :offset-assert 476) - (joystick-saved-view-off vector :inline :offset-assert 492) - (min-z-override float :offset-assert 508) - (view-flat vector :inline :offset-assert 524) - (string-vel-dir uint32 :offset-assert 540) - (string-trans vector :inline :offset-assert 556) - (position-spline tracking-spline :inline :offset-assert 572) - (pivot-pt vector :inline :offset-assert 2220) - (pivot-rad float :offset-assert 2236) - (circular-follow vector :inline :offset-assert 2252) - (max-angle-offset float :offset-assert 2268) - (max-angle-curr float :offset-assert 2272) - (options uint32 :offset-assert 2276) - (cam-entity entity :offset-assert 2280) ;; guessed by decompiler - (butt-timer uint64 :offset-assert 2284) - (butt-seek basic :offset-assert 2292) - (butt-vector vector :inline :offset-assert 2300) - (velocity vector :inline :offset-assert 2316) - (desired-pos vector :inline :offset-assert 2332) - (time-dist-too-far uint32 :offset-assert 2348) - (los-state slave-los-state :offset-assert 2352) ;; guessed by decompiler - (good-point vector :inline :offset-assert 2364) - (los-tgt-spline-pt int32 :offset-assert 2380) - (los-tgt-spline-pt-incarnation int32 :offset-assert 2384) - (los-last-pos vector :inline :offset-assert 2396) - (intro-curve curve :inline :offset-assert 2412) - (intro-offset vector :inline :offset-assert 2444) - (intro-t float :offset-assert 2460) - (intro-t-step float :offset-assert 2464) - (outro-exit-value float :offset-assert 2468) - (spline-exists basic :offset-assert 2472) - (spline-curve curve :inline :offset-assert 2476) - (spline-offset vector :inline :offset-assert 2508) - (index cam-index :inline :offset-assert 2524) - (saved-pt vector :inline :offset-assert 2572) - (spline-tt float :offset-assert 2588) - (spline-follow-dist float :offset-assert 2592) - (enter-has-run symbol :offset-assert 2596) ;; guessed by decompiler - (blend-from-type uint64 :offset-assert 2604) - (blend-to-type uint64 :offset-assert 2612) - (have-phony-joystick basic :offset-assert 2620) - (phony-joystick-x float :offset-assert 2624) - (phony-joystick-y float :offset-assert 2628) - (string-min-val vector :inline :offset-assert 2636) - (string-max-val vector :inline :offset-assert 2652) - (string-val-locked basic :offset-assert 2668) - (relative-position vector :inline :offset-assert 2684) - (string-relative basic :offset-assert 2700) + ((trans vector :inline :offset-assert 128) + (fov float :offset-assert 144) + (fov0 float :offset-assert 148) + (fov1 float :offset-assert 152) + (fov-index cam-index :inline :offset-assert 160) + (tracking cam-rotation-tracker :inline :offset-assert 208) + (view-off-param float :offset-assert 472) + (view-off vector :inline :offset-assert 480) + (joystick-saved-view-off vector :inline :offset-assert 496) + (min-z-override float :offset-assert 512) + (view-flat vector :inline :offset-assert 528) + (string-vel-dir uint32 :offset-assert 544) + (string-trans vector :inline :offset-assert 560) + (position-spline tracking-spline :inline :offset-assert 576) + (pivot-pt vector :inline :offset-assert 2224) + (pivot-rad float :offset-assert 2240) + (circular-follow vector :inline :offset-assert 2256) + (max-angle-offset float :offset-assert 2272) + (max-angle-curr float :offset-assert 2276) + (options uint32 :offset-assert 2280) + (cam-entity entity :offset-assert 2284) ;; guessed by decompiler + (butt-timer uint64 :offset-assert 2288) + (butt-seek basic :offset-assert 2296) + (butt-vector vector :inline :offset-assert 2304) + (velocity vector :inline :offset-assert 2320) + (desired-pos vector :inline :offset-assert 2336) + (time-dist-too-far uint32 :offset-assert 2352) + (los-state slave-los-state :offset-assert 2356) ;; guessed by decompiler + (good-point vector :inline :offset-assert 2368) + (los-tgt-spline-pt int32 :offset-assert 2384) + (los-tgt-spline-pt-incarnation int32 :offset-assert 2388) + (los-last-pos vector :inline :offset-assert 2400) + (intro-curve curve :inline :offset-assert 2416) + (intro-offset vector :inline :offset-assert 2448) + (intro-t float :offset-assert 2464) + (intro-t-step float :offset-assert 2468) + (outro-exit-value float :offset-assert 2472) + (spline-exists basic :offset-assert 2476) + (spline-curve curve :inline :offset-assert 2480) + (spline-offset vector :inline :offset-assert 2512) + (index cam-index :inline :offset-assert 2528) + (saved-pt vector :inline :offset-assert 2576) + (spline-tt float :offset-assert 2592) + (spline-follow-dist float :offset-assert 2596) + (enter-has-run symbol :offset-assert 2600) ;; guessed by decompiler + (blend-from-type uint64 :offset-assert 2608) + (blend-to-type uint64 :offset-assert 2616) + (have-phony-joystick basic :offset-assert 2624) + (phony-joystick-x float :offset-assert 2628) + (phony-joystick-y float :offset-assert 2632) + (string-min-val vector :inline :offset-assert 2640) + (string-max-val vector :inline :offset-assert 2656) + (string-val-locked basic :offset-assert 2672) + (relative-position vector :inline :offset-assert 2688) + (string-relative basic :offset-assert 2704) ) :method-count-assert 14 :size-assert #xa94 :flag-assert #xe0a200a94 - (:methods - (camera-slave-method-9 () none 9) - (camera-slave-method-10 () none 10) - (camera-slave-method-11 () none 11) - (camera-slave-method-12 () none 12) - (camera-slave-method-13 () none 13) - ) ) -|# -#| (deftype camera-master (process) - ((master-options uint32 :offset-assert 124) - (settings cam-setting-data :offset-assert 128) - (slave (pointer camera-slave) :offset-assert 132) ;; guessed by decompiler - (decel uint32 :offset-assert 136) - (slave-options uint32 :offset-assert 140) - (view-off-param-save float :offset-assert 144) - (changer uint32 :offset-assert 148) - (string-min cam-vector-seeker :inline :offset-assert 156) - (string-max cam-vector-seeker :inline :offset-assert 220) - (string-push-z float :offset-assert 280) - (local-down vector :inline :offset-assert 284) - (focus focus :inline :offset-assert 300) - (being-attacked symbol :offset-assert 312) ;; guessed by decompiler - (attack-start uint64 :offset-assert 316) ;; time-frame - (on-ground symbol :offset-assert 324) ;; guessed by decompiler - (under-water int32 :offset-assert 328) - (on-pole symbol :offset-assert 332) ;; guessed by decompiler - (tgt-rot-mat matrix :inline :offset-assert 348) - (tgt-face-mat matrix :inline :offset-assert 412) - (tpos-old vector :inline :offset-assert 476) - (tpos-curr vector :inline :offset-assert 492) - (tpos-old-adj vector :inline :offset-assert 508) - (tpos-curr-adj vector :inline :offset-assert 524) - (tpos-tgt vector :inline :offset-assert 540) - (upspeed float :offset-assert 556) - (pitch-off vector :inline :offset-assert 572) - (target-spline tracking-spline :inline :offset-assert 588) - (ease-from vector :inline :offset-assert 2236) - (ease-t float :offset-assert 2252) - (ease-step float :offset-assert 2256) - (ease-to vector :inline :offset-assert 2268) - (outro-curve curve :inline :offset-assert 2284) - (outro-t float :offset-assert 2304) - (outro-t-step float :offset-assert 2308) - (outro-exit-value float :offset-assert 2312) - (water-drip-time time-frame :offset-assert 2316) ;; time-frame - (water-drip sparticle-launch-control :offset-assert 2324) ;; guessed by decompiler - (water-drip-mult float :offset-assert 2328) - (water-drip-speed float :offset-assert 2332) + ((master-options uint32 :offset-assert 128) + (settings cam-setting-data :offset-assert 132) + (slave (pointer camera-slave) :offset-assert 136) ;; guessed by decompiler + (decel uint32 :offset-assert 140) + (slave-options uint32 :offset-assert 144) + (view-off-param-save float :offset-assert 148) + (changer uint32 :offset-assert 152) + (string-min cam-vector-seeker :inline :offset-assert 160) + (string-max cam-vector-seeker :inline :offset-assert 224) + (string-push-z float :offset-assert 284) + (local-down vector :inline :offset-assert 288) + (focus focus :inline :offset-assert 304) + (being-attacked symbol :offset-assert 316) ;; guessed by decompiler + (attack-start time-frame :offset-assert 320) ;; time-frame + (on-ground symbol :offset-assert 328) ;; guessed by decompiler + (under-water int32 :offset-assert 332) + (on-pole symbol :offset-assert 336) ;; guessed by decompiler + (tgt-rot-mat matrix :inline :offset-assert 352) + (tgt-face-mat matrix :inline :offset-assert 416) + (tpos-old vector :inline :offset-assert 480) + (tpos-curr vector :inline :offset-assert 496) + (tpos-old-adj vector :inline :offset-assert 512) + (tpos-curr-adj vector :inline :offset-assert 528) + (tpos-tgt vector :inline :offset-assert 544) + (upspeed float :offset-assert 560) + (pitch-off vector :inline :offset-assert 576) + (target-spline tracking-spline :inline :offset-assert 592) + (ease-from vector :inline :offset-assert 2240) + (ease-t float :offset-assert 2256) + (ease-step float :offset-assert 2260) + (ease-to vector :inline :offset-assert 2272) + (outro-curve curve :inline :offset-assert 2288) + (outro-t float :offset-assert 2308) + (outro-t-step float :offset-assert 2312) + (outro-exit-value float :offset-assert 2316) + (water-drip-time time-frame :offset-assert 2320) ;; time-frame + (water-drip sparticle-launch-control :offset-assert 2328) ;; guessed by decompiler + (water-drip-mult float :offset-assert 2332) + (water-drip-speed float :offset-assert 2336) ) :method-count-assert 17 :size-assert #x924 :flag-assert #x1108b00924 (:methods - (camera-master-method-9 () none 9) - (camera-master-method-10 () none 10) - (camera-master-method-11 () none 11) - (camera-master-method-12 () none 12) - (camera-master-method-13 () none 13) (camera-master-method-14 () none 14) (camera-master-method-15 () none 15) (camera-master-method-16 () none 16) ) ) -|# - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-debug-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *redline-table* object) ;; (pointer float) -;; (define-extern *redline-index* object) ;; int -;; (define-extern float-save-redline function) ;; (function float none) -;; (define-extern float-lookup-redline function) ;; (function float float) -;; (define-extern *blueline-table* object) ;; (pointer float) -;; (define-extern *blueline-index* object) ;; int -;; (define-extern float-save-blueline function) ;; (function float none) -;; (define-extern float-lookup-blueline function) ;; (function float float) -;; (define-extern *greenline-table* object) ;; (pointer float) -;; (define-extern *greenline-index* object) ;; int -;; (define-extern float-save-greenline function) ;; (function float none) -;; (define-extern float-lookup-greenline function) ;; (function float float) -;; (define-extern *yellowline-table* object) ;; (pointer float) -;; (define-extern *yellowline-index* object) ;; int -;; (define-extern float-save-yellowline function) ;; (function float none) -;; (define-extern float-lookup-yellowline function) ;; (function float float) -;; (define-extern *timeplot-table* object) ;; (pointer float) -;; (define-extern *timeplot-index* object) ;; int -;; (define-extern float-save-timeplot function) ;; (function float none) -;; (define-extern float-lookup-timeplot function) ;; (function float float) -;; (define-extern *cam-layout* object) ;; symbol +(define-extern *redline-table* (pointer float)) +(define-extern *redline-index* int) +(define-extern float-save-redline (function float none)) +(define-extern float-lookup-redline (function float float)) +(define-extern *blueline-table* (pointer float)) +(define-extern *blueline-index* int) +(define-extern float-save-blueline (function float none)) +(define-extern float-lookup-blueline (function float float)) +(define-extern *greenline-table* (pointer float)) +(define-extern *greenline-index* int) +(define-extern float-save-greenline (function float none)) +(define-extern float-lookup-greenline (function float float)) +(define-extern *yellowline-table* (pointer float)) +(define-extern *yellowline-index* int) +(define-extern float-save-yellowline (function float none)) +(define-extern float-lookup-yellowline (function float float)) +(define-extern *timeplot-table* (pointer float)) +(define-extern *timeplot-index* int) +(define-extern float-save-timeplot (function float none)) +(define-extern float-lookup-timeplot (function float float)) +(define-extern *cam-layout* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-interface-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *camera-init-mat* object) ;; matrix -;; (define-extern *camera* object) ;; camera-master -;; (define-extern *camera-combiner* object) ;; camera-combiner +(define-extern *camera-init-mat* matrix) +(define-extern *camera* camera-master) +(define-extern *camera-combiner* camera-combiner) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-update-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *external-cam-options* object) ;; external-cam-option -;; (define-extern *external-cam-mode* object) ;; symbol -;; (define-extern *camera-look-through-other* object) ;; int -;; (define-extern *camera-other-fov* bfloat) ;; bfloat -;; (define-extern *camera-other-trans* object) ;; vector -;; (define-extern *camera-other-matrix* object) ;; matrix -;; (define-extern *camera-smush-control* object) ;; smush-control -;; (define-extern *camera-other-root* object) ;; vector -;; (define-extern *fix-visible-level-mask* object) -;; (define-extern *manual-sample-point* object) +(defenum external-cam-option + :bitfield #t + (allow-z 0) + ) + +(define-extern *external-cam-options* external-cam-option) +(define-extern *external-cam-mode* symbol) +(define-extern *camera-look-through-other* int) +(define-extern *camera-other-fov* bfloat) +(define-extern *camera-other-trans* vector) +(define-extern *camera-other-matrix* matrix) +(define-extern *camera-smush-control* smush-control) +(define-extern *camera-other-root* vector) +(define-extern *fix-visible-level-mask* int) +(define-extern *manual-sample-point* symbol) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hud-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype hud-string (basic) - ((text basic :offset-assert 4) + ((text string :offset-assert 4) (scale float :offset-assert 8) (color uint32 :offset-assert 12) (flags uint32 :offset-assert 16) @@ -17286,9 +18508,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype hud-sprite (structure) ((pos vector4w :inline :offset-assert 0) (color vector4w :inline :offset-assert 16) @@ -17306,9 +18526,7 @@ (hud-sprite-method-10 () none 10) ) ) -|# -#| (deftype hud-box (structure) ((min vector2 :inline :offset-assert 0) (max vector2 :inline :offset-assert 8) @@ -17327,9 +18545,7 @@ (hud-box-method-15 () none 15) ) ) -|# -#| (deftype hud-icon (basic) ((icon (pointer manipy) :offset-assert 4) ;; guessed by decompiler (pos vector4w :inline :offset-assert 16) @@ -17340,42 +18556,38 @@ :size-assert #x28 :flag-assert #x900000028 ) -|# -#| (deftype hud-value (basic) ((current int32 :offset-assert 4) (target int32 :offset-assert 8) (flags uint16 :offset-assert 12) (counter uint16 :offset-assert 14) ) + :pack-me :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(defenum hud-flags + :type uint32 + :bitfield #t + ) (deftype hud (process) - ((trigger-time time-frame :offset-assert 124) ;; time-frame - (last-hide-time time-frame :offset-assert 132) ;; time-frame - (offset float :offset-assert 140) ;; int32 - (flags uint32 :offset-assert 144) - (values UNKNOWN 8 :offset-assert 148) - (strings UNKNOWN 14 :offset-assert 284) - (sprites UNKNOWN 30 :offset-assert 956) - (icons hud-icon 2 :offset-assert 2876) ;; guessed by decompiler - (gui-id uint32 :offset-assert 2972) + ((trigger-time time-frame :offset-assert 128) ;; time-frame + (last-hide-time time-frame :offset-assert 136) ;; time-frame + (offset float :offset-assert 144) ;; int32 + (flags hud-flags :offset-assert 148) + (values hud-value 8 :inline :offset-assert 152) + (strings hud-string 14 :inline :offset-assert 288) + (sprites hud-sprite 30 :inline :offset-assert 960) + (icons hud-icon 2 :inline :offset-assert 2880) ;; guessed by decompiler + (gui-id uint32 :offset-assert 2976) ) :method-count-assert 27 :size-assert #xba4 :flag-assert #x1b0b300ba4 (:methods - (hud-method-9 () none 9) - (hud-method-10 () none 10) - (hud-method-11 () none 11) - (hud-method-12 () none 12) - (hud-method-13 () none 13) (hud-method-14 () none 14) ;; (hidden? (_type_) symbol 14) (hud-method-15 () none 15) ;; (draw-hud (_type_) none 15) (hud-method-16 () none 16) ;; (tally-value (_type_ int int) none 16) @@ -17391,9 +18603,7 @@ (hud-method-26 () none 26) ;; (get-icon-scale-y (_type_) float 26) ) ) -|# -#| (deftype hud-ashelin (hud) () :method-count-assert 27 @@ -17402,9 +18612,7 @@ (:methods ) ) -|# -#| (deftype hud-cargo (hud) () :method-count-assert 27 @@ -17413,9 +18621,7 @@ (:methods ) ) -|# -#| (deftype hud-citizen (hud) () :method-count-assert 27 @@ -17424,9 +18630,7 @@ (:methods ) ) -|# -#| (deftype hud-cpanel (hud) () :method-count-assert 27 @@ -17435,9 +18639,7 @@ (:methods ) ) -|# -#| (deftype hud-dig-clasp (hud) () :method-count-assert 27 @@ -17446,9 +18648,7 @@ (:methods ) ) -|# -#| (deftype hud-gun (hud) () :method-count-assert 27 @@ -17457,9 +18657,7 @@ (:methods ) ) -|# -#| (deftype hud-health (hud) () :method-count-assert 27 @@ -17468,9 +18666,7 @@ (:methods ) ) -|# -#| (deftype hud-dark-eco-symbol (hud) () :method-count-assert 27 @@ -17479,9 +18675,7 @@ (:methods ) ) -|# -#| (deftype hud-helldog (hud) () :method-count-assert 27 @@ -17490,9 +18684,7 @@ (:methods ) ) -|# -#| (deftype hud-lurker (hud) () :method-count-assert 27 @@ -17501,9 +18693,7 @@ (:methods ) ) -|# -#| (deftype hud-map (hud) () :method-count-assert 27 @@ -17512,9 +18702,7 @@ (:methods ) ) -|# -#| (deftype hud-moneybag (hud) () :method-count-assert 27 @@ -17523,9 +18711,7 @@ (:methods ) ) -|# -#| (deftype hud-pegasus (hud) () :method-count-assert 27 @@ -17534,9 +18720,7 @@ (:methods ) ) -|# -#| (deftype hud-plasmite (hud) () :method-count-assert 27 @@ -17545,9 +18729,7 @@ (:methods ) ) -|# -#| (deftype hud-dig-button (hud) () :method-count-assert 27 @@ -17556,9 +18738,7 @@ (:methods ) ) -|# -#| (deftype hud-predator (hud) () :method-count-assert 27 @@ -17567,9 +18747,7 @@ (:methods ) ) -|# -#| (deftype hud-heatmeter (hud) () :method-count-assert 27 @@ -17578,9 +18756,7 @@ (:methods ) ) -|# -#| (deftype hud-progress (hud) () :method-count-assert 27 @@ -17589,9 +18765,7 @@ (:methods ) ) -|# -#| (deftype hud-rocketsensor (hud) () :method-count-assert 27 @@ -17600,9 +18774,7 @@ (:methods ) ) -|# -#| (deftype hud-ruffians (hud) () :method-count-assert 27 @@ -17611,9 +18783,7 @@ (:methods ) ) -|# -#| (deftype hud-score (hud) () :method-count-assert 27 @@ -17622,9 +18792,7 @@ (:methods ) ) -|# -#| (deftype hud-sig (hud) () :method-count-assert 27 @@ -17633,9 +18801,7 @@ (:methods ) ) -|# -#| (deftype hud-skill (hud) () :method-count-assert 27 @@ -17644,9 +18810,7 @@ (:methods ) ) -|# -#| (deftype hud-skullgem (hud) () :method-count-assert 27 @@ -17655,9 +18819,7 @@ (:methods ) ) -|# -#| (deftype hud-timer (hud) () :method-count-assert 27 @@ -17666,9 +18828,7 @@ (:methods ) ) -|# -#| (deftype hud-turret (hud) () :method-count-assert 27 @@ -17677,9 +18837,7 @@ (:methods ) ) -|# -#| (deftype hud-squid (hud) () :method-count-assert 27 @@ -17688,9 +18846,7 @@ (:methods ) ) -|# -#| (deftype hud-gunturret (hud) () :method-count-assert 27 @@ -17699,9 +18855,7 @@ (:methods ) ) -|# -#| (deftype hud-gruntegg (hud) () :method-count-assert 27 @@ -17710,9 +18864,7 @@ (:methods ) ) -|# -#| (deftype hud-crimsonhover (hud) () :method-count-assert 27 @@ -17721,9 +18873,7 @@ (:methods ) ) -|# -#| (deftype hud-metalkor (hud) () :method-count-assert 27 @@ -17732,9 +18882,7 @@ (:methods ) ) -|# -#| (deftype hud-big-score (hud) () :method-count-assert 27 @@ -17743,9 +18891,7 @@ (:methods ) ) -|# -#| (deftype hud-goal (hud) () :method-count-assert 27 @@ -17754,9 +18900,7 @@ (:methods ) ) -|# -#| (deftype hud-miss (hud) () :method-count-assert 27 @@ -17765,9 +18909,7 @@ (:methods ) ) -|# -#| (deftype hud-race-timer (hud) () :method-count-assert 27 @@ -17776,9 +18918,7 @@ (:methods ) ) -|# -#| (deftype hud-race-lap-counter (hud) () :method-count-assert 27 @@ -17787,9 +18927,7 @@ (:methods ) ) -|# -#| (deftype hud-race-turbo-counter (hud) () :method-count-assert 27 @@ -17798,9 +18936,7 @@ (:methods ) ) -|# -#| (deftype hud-race-position (hud) () :method-count-assert 27 @@ -17809,9 +18945,7 @@ (:methods ) ) -|# -#| (deftype hud-race-map (hud) () :method-count-assert 27 @@ -17820,9 +18954,7 @@ (:methods ) ) -|# -#| (deftype hud-samos-old (hud) () :method-count-assert 27 @@ -17831,9 +18963,7 @@ (:methods ) ) -|# -#| (deftype hud-samos-young (hud) () :method-count-assert 27 @@ -17842,9 +18972,7 @@ (:methods ) ) -|# -#| (deftype hud-lurker-button (hud) () :method-count-assert 27 @@ -17853,9 +18981,7 @@ (:methods ) ) -|# -#| (deftype hud-widow (hud) () :method-count-assert 27 @@ -17864,9 +18990,7 @@ (:methods ) ) -|# -#| (deftype hud-race-final-stats (hud) () :method-count-assert 27 @@ -17875,9 +18999,7 @@ (:methods ) ) -|# -#| (deftype hud-mech-air-tank (hud) () :method-count-assert 27 @@ -17886,9 +19008,7 @@ (:methods ) ) -|# -#| (deftype hud-homing-beacon (hud) () :method-count-assert 27 @@ -17897,9 +19017,7 @@ (:methods ) ) -|# -#| (deftype hud-dark-eco-pickup (hud) () :method-count-assert 27 @@ -17908,9 +19026,7 @@ (:methods ) ) -|# -#| (deftype hud-green-eco-pickup (hud) () :method-count-assert 27 @@ -17919,40 +19035,38 @@ (:methods ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; progress-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype progress (process-drawable) - ((current-options basic :offset-assert 196) - (menu-transition float :offset-assert 200) - (option-index int32 :offset-assert 204) - (want-option-index int32 :offset-assert 208) - (next-option-index int32 :offset-assert 212) - (graphic-index int32 :offset-assert 216) - (selected-option basic :offset-assert 220) - (current basic :offset-assert 224) - (next basic :offset-assert 228) - (ring-angle float :offset-assert 232) - (ring-want-angle float :offset-assert 236) - (init-quat quaternion :inline :offset-assert 252) - (pos-transition float :offset-assert 268) - (anim-frame float :offset-assert 272) - (swing float :offset-assert 276) - (main-menu basic :offset-assert 280) - (state-stack UNKNOWN 5 :offset-assert 284) - (option-index-stack int32 5 :offset-assert 304) ;; guessed by decompiler - (state-pos int32 :offset-assert 324) - (secret-buying basic :offset-assert 328) - (secret-buy-choice basic :offset-assert 332) - (sliding float :offset-assert 336) - (sliding-off float :offset-assert 340) - (scanlines-alpha float :offset-assert 344) - (sliding-height float :offset-assert 348) + ((current-options basic :offset-assert 200) + (menu-transition float :offset-assert 204) + (option-index int32 :offset-assert 208) + (want-option-index int32 :offset-assert 212) + (next-option-index int32 :offset-assert 216) + (graphic-index int32 :offset-assert 220) + (selected-option basic :offset-assert 224) + (current basic :offset-assert 228) + (next basic :offset-assert 232) + (ring-angle float :offset-assert 236) + (ring-want-angle float :offset-assert 240) + (init-quat quaternion :inline :offset-assert 256) + (pos-transition float :offset-assert 272) + (anim-frame float :offset-assert 276) + (swing float :offset-assert 280) + (main-menu basic :offset-assert 284) + (state-stack int32 5 :offset-assert 288) + (option-index-stack int32 5 :offset-assert 308) ;; guessed by decompiler + (state-pos int32 :offset-assert 328) + (secret-buying basic :offset-assert 332) + (secret-buy-choice basic :offset-assert 336) + (sliding float :offset-assert 340) + (sliding-off float :offset-assert 344) + (scanlines-alpha float :offset-assert 348) + (sliding-height float :offset-assert 352) ) :method-count-assert 33 :size-assert #x164 @@ -17973,13 +19087,11 @@ (progress-method-32 () none 32) ;; (can-go-back? (_type_) symbol 32) ) ) -|# -#| (deftype menu-option (basic) ((name uint32 :offset-assert 4) (scale basic :offset-assert 8) - (box UNKNOWN 1 :offset-assert 16) + (box bounding-box 1 :inline :offset-assert 16) ;; no idea ) :method-count-assert 12 :size-assert #x30 @@ -17990,9 +19102,7 @@ (menu-option-method-11 () none 11) ) ) -|# -#| (deftype menu-on-off-option (menu-option) ((value-to-modify uint32 :offset-assert 48) ) @@ -18002,9 +19112,7 @@ (:methods ) ) -|# -#| (deftype menu-yes-no-option (menu-option) ((value-to-modify uint32 :offset-assert 48) ) @@ -18014,9 +19122,7 @@ (:methods ) ) -|# -#| (deftype menu-language-option (menu-option) ((language-selection uint64 :offset-assert 48) (language-direction basic :offset-assert 56) @@ -18029,9 +19135,7 @@ (:methods ) ) -|# -#| (deftype menu-quit-option (menu-option) () :method-count-assert 12 @@ -18040,12 +19144,10 @@ (:methods ) ) -|# -#| (deftype menu-slider-option (menu-option) ((value-to-modify uint32 :offset-assert 48) - (sprites UNKNOWN 5 :offset-assert 64) + (sprites hud-sprite 5 :inline :offset-assert 64) ;; guess ) :method-count-assert 12 :size-assert #x180 @@ -18053,11 +19155,10 @@ (:methods ) ) -|# -#| (deftype menu-sub-menu-option (menu-option) ((next-state basic :offset-assert 48) + (pad uint8 44) ) :method-count-assert 12 :size-assert #x60 @@ -18065,9 +19166,7 @@ (:methods ) ) -|# -#| (deftype menu-sub-menu-sound-option (menu-option) ((next-state basic :offset-assert 48) ) @@ -18077,9 +19176,7 @@ (:methods ) ) -|# -#| (deftype menu-stereo-mode-sound-option (menu-option) () :method-count-assert 12 @@ -18088,9 +19185,7 @@ (:methods ) ) -|# -#| (deftype menu-sub-menu-graphic-option (menu-option) ((next-state basic :offset-assert 48) ) @@ -18100,9 +19195,7 @@ (:methods ) ) -|# -#| (deftype menu-unlocked-menu-option (menu-sub-menu-option) () :method-count-assert 12 @@ -18111,9 +19204,7 @@ (:methods ) ) -|# -#| (deftype menu-main-menu-option (menu-option) ((next-state basic :offset-assert 48) ) @@ -18123,11 +19214,10 @@ (:methods ) ) -|# -#| (deftype menu-memcard-slot-option (menu-option) - ((sprites UNKNOWN 5 :offset-assert 48) + ((sprites hud-sprite 5 :inline :offset-assert 48) ;; total guess + (pad uint8 32) ) :method-count-assert 12 :size-assert #x190 @@ -18135,9 +19225,7 @@ (:methods ) ) -|# -#| (deftype menu-loading-option (menu-option) () :method-count-assert 12 @@ -18146,9 +19234,7 @@ (:methods ) ) -|# -#| (deftype menu-insufficient-space-option (menu-option) ((last-move uint64 :offset-assert 48) ) @@ -18158,9 +19244,7 @@ (:methods ) ) -|# -#| (deftype menu-secrets-insufficient-space-option (menu-option) () :method-count-assert 12 @@ -18169,9 +19253,7 @@ (:methods ) ) -|# -#| (deftype menu-insert-card-option (menu-option) () :method-count-assert 12 @@ -18180,9 +19262,7 @@ (:methods ) ) -|# -#| (deftype menu-error-loading-option (menu-option) () :method-count-assert 12 @@ -18191,9 +19271,7 @@ (:methods ) ) -|# -#| (deftype menu-error-auto-saving-option (menu-option) () :method-count-assert 12 @@ -18202,9 +19280,7 @@ (:methods ) ) -|# -#| (deftype menu-card-removed-option (menu-option) () :method-count-assert 12 @@ -18213,9 +19289,7 @@ (:methods ) ) -|# -#| (deftype menu-error-disc-removed-option (menu-option) () :method-count-assert 12 @@ -18224,9 +19298,7 @@ (:methods ) ) -|# -#| (deftype menu-error-reading-option (menu-option) () :method-count-assert 12 @@ -18235,11 +19307,9 @@ (:methods ) ) -|# -#| (deftype menu-icon-info-option (menu-option) - ((sprites UNKNOWN 2 :offset-assert 48) + ((sprites hud-sprite 2 :inline :offset-assert 48) ) :method-count-assert 12 :size-assert #xb0 @@ -18247,9 +19317,7 @@ (:methods ) ) -|# -#| (deftype menu-format-card-option (menu-option) () :method-count-assert 12 @@ -18258,9 +19326,7 @@ (:methods ) ) -|# -#| (deftype menu-already-exists-option (menu-option) () :method-count-assert 12 @@ -18269,9 +19335,7 @@ (:methods ) ) -|# -#| (deftype menu-create-game-option (menu-option) () :method-count-assert 12 @@ -18280,9 +19344,7 @@ (:methods ) ) -|# -#| (deftype menu-video-mode-warning-option (menu-option) () :method-count-assert 12 @@ -18291,9 +19353,7 @@ (:methods ) ) -|# -#| (deftype menu-video-mode-ok-option (menu-option) () :method-count-assert 12 @@ -18302,9 +19362,7 @@ (:methods ) ) -|# -#| (deftype menu-progressive-mode-warning-option (menu-option) () :method-count-assert 12 @@ -18313,9 +19371,7 @@ (:methods ) ) -|# -#| (deftype menu-progressive-mode-ok-option (menu-option) () :method-count-assert 12 @@ -18324,9 +19380,7 @@ (:methods ) ) -|# -#| (deftype menu-select-start-option (menu-option) ((task-index int32 :offset-assert 48) (real-task-index int32 :offset-assert 52) @@ -18338,9 +19392,7 @@ (:methods ) ) -|# -#| (deftype menu-select-scene-option (menu-option) ((task-index int32 :offset-assert 48) (last-move uint64 :offset-assert 56) @@ -18351,9 +19403,7 @@ (:methods ) ) -|# -#| (deftype menu-bigmap-option (menu-option) () :method-count-assert 12 @@ -18362,9 +19412,7 @@ (:methods ) ) -|# -#| (deftype paged-menu-option (menu-option) ((page-index int32 :offset-assert 48) (prev-page-index int32 :offset-assert 52) @@ -18377,9 +19425,7 @@ (:methods ) ) -|# -#| (deftype menu-missions-option (paged-menu-option) ((task-line-index int32 :offset-assert 64) (last-move uint64 :offset-assert 72) @@ -18390,12 +19436,10 @@ (:methods ) ) -|# -#| (deftype menu-highscores-option (paged-menu-option) ((last-move uint64 :offset-assert 64) - (sprites UNKNOWN 2 :offset-assert 80) + (sprites hud-sprite 2 :inline :offset-assert 80) ) :method-count-assert 12 :size-assert #xd0 @@ -18403,9 +19447,7 @@ (:methods ) ) -|# -#| (deftype secret-item-option (menu-option) ((cost int32 :offset-assert 48) (can-toggle basic :offset-assert 52) @@ -18418,9 +19460,7 @@ (:methods ) ) -|# -#| (deftype menu-secret-option (menu-option) ((item-index int32 :offset-assert 48) (prev-item-index int32 :offset-assert 52) @@ -18428,7 +19468,7 @@ (num-hero-items int32 :offset-assert 60) (secret-items basic :offset-assert 64) (last-move uint64 :offset-assert 72) - (sprites UNKNOWN 2 :offset-assert 80) + (sprites hud-sprite 2 :inline :offset-assert 80) ) :method-count-assert 12 :size-assert #xd0 @@ -18436,9 +19476,7 @@ (:methods ) ) -|# -#| (deftype menu-option-list (basic) ((y-center int32 :offset-assert 4) (y-space int32 :offset-assert 8) @@ -18449,12 +19487,10 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype menu-qr-option (menu-option) ((last-move uint64 :offset-assert 48) - (value-to-modify uint32 :offset-assert 60) + (value-to-modify uint32 :offset 60) ) :method-count-assert 12 :size-assert #x40 @@ -18462,9 +19498,7 @@ (:methods ) ) -|# -#| (deftype menu-restart-mission-qr-option (menu-qr-option) ((next-state basic :offset-assert 64) ) @@ -18474,9 +19508,7 @@ (:methods ) ) -|# -#| (deftype menu-quit-qr-option (menu-qr-option) ((next-state basic :offset-assert 64) ) @@ -18486,9 +19518,7 @@ (:methods ) ) -|# -#| (deftype menu-sub-menu-qr-option (menu-qr-option) ((next-state basic :offset-assert 64) ) @@ -18498,12 +19528,10 @@ (:methods ) ) -|# -#| (deftype menu-graphic-option (menu-option) ((last-move uint64 :offset-assert 48) - (value-to-modify uint32 :offset-assert 60) + (value-to-modify uint32 :offset 60) ) :method-count-assert 12 :size-assert #x40 @@ -18511,9 +19539,7 @@ (:methods ) ) -|# -#| (deftype menu-on-off-progressive-scan-graphic-option (menu-graphic-option) () :method-count-assert 12 @@ -18522,9 +19548,7 @@ (:methods ) ) -|# -#| (deftype menu-aspect-ratio-option (menu-graphic-option) () :method-count-assert 12 @@ -18533,9 +19557,7 @@ (:methods ) ) -|# -#| (deftype menu-center-screen-graphic-option (menu-graphic-option) ((next-state basic :offset-assert 64) ) @@ -18545,9 +19567,7 @@ (:methods ) ) -|# -#| (deftype menu-video-mode-option (menu-graphic-option) () :method-count-assert 12 @@ -18556,12 +19576,10 @@ (:methods ) ) -|# -#| (deftype menu-game-option (menu-option) ((last-move uint64 :offset-assert 48) - (value-to-modify uint32 :offset-assert 60) + (value-to-modify uint32 :offset 60) ) :method-count-assert 12 :size-assert #x40 @@ -18569,9 +19587,7 @@ (:methods ) ) -|# -#| (deftype menu-on-off-game-vibrations-option (menu-game-option) () :method-count-assert 12 @@ -18580,9 +19596,7 @@ (:methods ) ) -|# -#| (deftype menu-on-off-game-subtitles-option (menu-game-option) () :method-count-assert 12 @@ -18591,9 +19605,7 @@ (:methods ) ) -|# -#| (deftype menu-sub-menu-game-option (menu-game-option) ((next-state basic :offset-assert 64) ) @@ -18603,9 +19615,7 @@ (:methods ) ) -|# -#| (deftype menu-language-game-option (menu-game-option) ((language-selection uint64 :offset-assert 64) (language-direction basic :offset-assert 72) @@ -18618,9 +19628,7 @@ (:methods ) ) -|# -#| (deftype menu-subtitle-language-game-option (menu-game-option) ((language-selection uint64 :offset-assert 64) (language-direction basic :offset-assert 72) @@ -18633,29 +19641,31 @@ (:methods ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; rpc-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(define-extern rpc-busy? (function int uint)) +(define-extern rpc-call (function int uint uint uint int uint int uint)) + (deftype rpc-buffer (basic) ((elt-size uint32 :offset-assert 4) (elt-count uint32 :offset-assert 8) (elt-used uint32 :offset-assert 12) (busy basic :offset-assert 16) (base pointer :offset-assert 20) ;; guessed by decompiler - (data uint8 :dynamic :offset-assert 32) ;; guessed by decompiler + (data uint8 :dynamic :offset 32) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 + (:methods + (new (symbol type uint uint) rpc-buffer 0) + ) ) -|# -#| (deftype rpc-buffer-pair (basic) ((buffer rpc-buffer 2 :offset-assert 4) ;; guessed by decompiler (current rpc-buffer :offset-assert 12) ;; guessed by decompiler @@ -18666,36 +19676,44 @@ :size-assert #x18 :flag-assert #xf00000018 (:methods - ;; (new (symbol type uint uint int) rpc-buffer-pair 0) - (rpc-buffer-pair-method-9 () none 9) ;; (call (rpc-buffer-pair uint pointer uint) int 9) - (rpc-buffer-pair-method-10 () none 10) ;; (add-element (rpc-buffer-pair) pointer 10) - (rpc-buffer-pair-method-11 () none 11) ;; (decrement-elt-used (rpc-buffer-pair) int 11) - (rpc-buffer-pair-method-12 () none 12) ;; (sync (rpc-buffer-pair symbol) int 12) - (rpc-buffer-pair-method-13 () none 13) ;; (check-busy (rpc-buffer-pair) symbol 13) - (rpc-buffer-pair-method-14 () none 14) ;; (pop-last-received (rpc-buffer-pair) pointer 14) + (new (symbol type uint uint int) rpc-buffer-pair 0) + (call (rpc-buffer-pair uint pointer uint) int 9) + (add-element (rpc-buffer-pair) pointer 10) + (decrement-elt-used (rpc-buffer-pair) int 11) + (sync (rpc-buffer-pair symbol) int 12) + (check-busy (rpc-buffer-pair) symbol 13) + (pop-last-received (rpc-buffer-pair) pointer 14) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; path-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum path-control-flag + :bitfield #t + :type uint32 + (display 0) + (draw-line 1) ;; TODO - only seen it used to control debug drawing so far + (draw-point 2) ;; TODO - only seen it used to control debug drawing so far + (draw-text 3) ;; TODO - only seen it used to control debug drawing so far + (not-found 4) + ) + (deftype path-control (basic) ((flags path-control-flag :offset-assert 4) ;; guessed by decompiler (name symbol :offset-assert 8) ;; guessed by decompiler (process process-drawable :offset-assert 12) ;; guessed by decompiler (curve curve :inline :offset-assert 16) - (num-cverts int32 :offset-assert 20) - (cverts (inline-array vector) :offset-assert 16) ;; guessed by decompiler + (num-cverts int32 :offset 20) + (cverts (inline-array vector) :offset 16) ;; guessed by decompiler ) :method-count-assert 27 :size-assert #x24 :flag-assert #x1b00000024 (:methods - ;; (new (symbol type process symbol float) _type_ 0) + (new (symbol type process symbol float entity symbol) _type_ 0) (path-control-method-9 () none 9) ;; (dummy-9 (_type_) none 9) (path-control-method-10 () none 10) ;; (eval-path-curve-div! (_type_ vector float symbol) vector 10) (path-control-method-11 () none 11) ;; (get-random-point (_type_ vector) vector 11) @@ -18704,70 +19722,64 @@ (path-control-method-14 () none 14) ;; (TODO-RENAME-14 (_type_ vector float) vector 14) (path-control-method-15 () none 15) ;; (length-as-float (_type_) float 15) (path-control-method-16 () none 16) ;; (path-distance (_type_) float 16) - (path-control-method-17 () none 17) ;; (get-num-verts (_type_) int 17) + (get-num-segments (_type_) float 17) (path-control-method-18 () none 18) ;; (should-display? (_type_) symbol 18) - (path-control-method-19 () none 19) ;; (TODO-RENAME-19 (_type_) float 19) - (path-control-method-20 () none 20) ;; (TODO-RENAME-20 (_type_) float 20) - (path-control-method-21 () none 21) + (get-num-verts (_type_) int 19) ;; (TODO-RENAME-19 (_type_) float 19) + (path-distance-equal-spacing (_type_ float) float 20) ;; (TODO-RENAME-20 (_type_) float 20) + (average-segment-length (_type_ float) float 21) (path-control-method-22 () none 22) (path-control-method-23 () none 23) (path-control-method-24 () none 24) - (path-control-method-25 () none 25) + (should-display-marks? (_type_) symbol 25) (path-control-method-26 () none 26) ) ) -|# -#| (deftype curve-control (path-control) () :method-count-assert 27 :size-assert #x24 :flag-assert #x1b00000024 (:methods - ;; (new (symbol type process symbol float) _type_ 0) + (new (symbol type process symbol float) _type_ 0) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nav-mesh-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype nav-mesh-work-debug (structure) - ((debug-vec1 vector :inline :offset-assert 0) - (debug-vec2 vector :inline :offset-assert 16) - (debug-vec3 vector :inline :offset-assert 32) - (debug-vec4 vector :inline :offset-assert 48) - (debug-vec5 vector :inline :offset-assert 64) - (debug-vec6 vector :inline :offset-assert 80) - (debug-vec7 vector :inline :offset-assert 96) - (debug-vec8 vector :inline :offset-assert 112) - (debug-vec9 vector :inline :offset-assert 128) - (debug-vec10 vector :inline :offset-assert 144) - (debug-vec11 vector :inline :offset-assert 160) - (debug-vec12 vector :inline :offset-assert 176) - (sphere-array UNKNOWN 16 :offset-assert 192) + ((debug-vec1 vector :inline :offset-assert 0) + (debug-vec2 vector :inline :offset-assert 16) + (debug-vec3 vector :inline :offset-assert 32) + (debug-vec4 vector :inline :offset-assert 48) + (debug-vec5 vector :inline :offset-assert 64) + (debug-vec6 vector :inline :offset-assert 80) + (debug-vec7 vector :inline :offset-assert 96) + (debug-vec8 vector :inline :offset-assert 112) + (debug-vec9 vector :inline :offset-assert 128) + (debug-vec10 vector :inline :offset-assert 144) + (debug-vec11 vector :inline :offset-assert 160) + (debug-vec12 vector :inline :offset-assert 176) + (sphere-array sphere 16 :inline :offset-assert 192) ) :method-count-assert 9 :size-assert #x1c0 :flag-assert #x9000001c0 ) -|# -#| (deftype nav-mesh-work (structure) - ((vert0-table UNKNOWN 4 :offset-assert 0) - (vert1-table UNKNOWN 4 :offset-assert 4) - (edge-mask-table UNKNOWN 3 :offset-assert 8) + ((vert0-table int8 4 :offset-assert 0) + (vert1-table int8 4 :offset-assert 4) + (edge-mask-table uint8 3 :offset-assert 8) (pad0 uint32 :offset-assert 12) (deg-to-rad float :offset-assert 16) (rad-to-deg float :offset-assert 20) (nav-poly-min-dist float :offset-assert 24) (nav-poly-epsilon float :offset-assert 28) - (sphere-array UNKNOWN 16 :offset-assert 32) + (sphere-array sphere 16 :inline :offset-assert 32) (debug nav-mesh-work-debug :offset-assert 288) (work-struct-in-scratch int8 :offset-assert 292) (mesh-struct-in-scratch int8 :offset-assert 293) @@ -18782,9 +19794,7 @@ :size-assert #x13c :flag-assert #x90000013c ) -|# -#| (deftype nav-mesh-link (structure) ((id uint32 :offset-assert 0) (dest-mesh-id uint32 :offset-assert 4) @@ -18798,50 +19808,38 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype nav-poly (structure) - ((data UNKNOWN 64 :offset-assert 0) - (vertex uint8 4 :offset-assert 0) ;; guessed by decompiler - (vertex0 vector :inline :offset-assert 0) - (vertex1 vector :inline :offset-assert 16) - (vertex2 vector :inline :offset-assert 32) - (vertex3 vector :inline :offset-assert 48) - (id uint8 :offset-assert 12) - (pat uint8 :offset-assert 13) - (vertex-count uint8 :offset-assert 14) - (link uint8 :offset-assert 15) - (adj-poly uint8 4 :offset-assert 28) ;; guessed by decompiler - (adj-poly0 uint8 :offset-assert 28) - (adj-poly1 uint8 :offset-assert 29) - (adj-poly2 uint8 :offset-assert 30) - (adj-poly3 uint8 :offset-assert 31) - (min-y float :offset-assert 44) - (max-y float :offset-assert 60) + ((data uint8 64 :offset-assert 0 :score -1) + (vertex vector 4 :inline :offset 0) ;; changed to vector from uint8 in jak 1 + (vertex0 vector :inline :offset 0) + (vertex1 vector :inline :offset 16) + (vertex2 vector :inline :offset 32) + (vertex3 vector :inline :offset 48) + (id uint8 :offset 12) + (pat uint8 :offset 13) + (vertex-count uint8 :offset 14) + (link uint8 :offset 15) + (adj-poly uint8 4 :offset 28) ;; guessed by decompiler + (adj-poly0 uint8 :offset 28) + (adj-poly1 uint8 :offset 29) + (adj-poly2 uint8 :offset 30) + (adj-poly3 uint8 :offset 31) + (min-y float :offset 44) + (max-y float :offset 60) ) :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype nav-vertex (vector) - ((data float 4 :offset-assert 0) ;; guessed by decompiler - (x float :offset-assert 0) - (y float :offset-assert 4) - (z float :offset-assert 8) - (w float :offset-assert 12) - (quad uint128 :offset-assert 0) - ) + () :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype nav-sphere (structure) ((trans sphere :inline :offset-assert 0) ) @@ -18849,9 +19847,7 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype nav-ray (structure) ((current-pos vector :inline :offset-assert 0) (dir vector :inline :offset-assert 16) @@ -18870,11 +19866,9 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype nav-route-portal (structure) - ((vertex nav-vertex 2 :offset-assert 0) ;; guessed by decompiler + ((vertex nav-vertex 2 :inline :offset-assert 0) ;; guessed by decompiler (next-poly nav-poly :offset-assert 32) (edge-index int8 :offset-assert 36) ) @@ -18882,24 +19876,20 @@ :size-assert #x25 :flag-assert #x900000025 ) -|# -#| (deftype nav-find-poly-parms (structure) ((point vector :inline :offset-assert 0) (y-threshold float :offset-assert 16) (ignore uint8 :offset-assert 20) (poly nav-poly :offset-assert 24) (dist float :offset-assert 28) - (point-inside? basic :offset-assert 32) + (point-inside? symbol :offset-assert 32) ) :method-count-assert 9 :size-assert #x24 :flag-assert #x900000024 ) -|# -#| (deftype clamp-travel-vector-to-mesh-return-info (structure) ((found-boundary basic :offset-assert 0) (intersection vector :inline :offset-assert 16) @@ -18919,11 +19909,41 @@ :size-assert #xa0 :flag-assert #x9000000a0 ) -|# -#| +(define-extern nav-mesh type) ;; remove once we have this. + +(defenum nav-mesh-flag + :type uint8 + :bitfield #t + (dummy 0) + ) + (deftype nav-mesh (basic) - () + ((work nav-mesh-work :offset-assert 4) + (poly-array (inline-array nav-poly)) + (static-sphere-count uint8) + (poly-count uint8) + (nav-control-count uint8) + (max-nav-control-count uint8) + (route uint32) + (poly-hash basic) + (nav-control-array uint32) + (sphere-hash basic) + (static-sphere uint32 :offset-assert 32) + (user-list basic) + (next-nav-mesh basic) + (prev-nav-mesh basic) + (bounds sphere :inline :offset-assert 48) + (origin vector :inline :offset 48) + (entity entity) + (link-array uint32) + (link-count uint8) + (flags nav-mesh-flag) + (pad1 uint8 2) + (nearest-y-threshold meters :offset-assert 76) + (water-max-height meters) + (pad2 uint32 7) + ) :method-count-assert 47 :size-assert #x70 :flag-assert #x2f00000070 @@ -18936,7 +19956,7 @@ (nav-mesh-method-13 () none 13) ;; (initialize-mesh! (_type_) none 13) (nav-mesh-method-14 () none 14) ;; (move-along-nav-ray! (_type_ nav-ray) none 14) (nav-mesh-method-15 () none 15) ;; (try-move-along-ray (_type_ nav-poly vector vector float) meters 15) - (nav-mesh-method-16 () none 16) ;; (TODO-RENAME-16 (_type_ vector nav-poly vector symbol float clip-travel-vector-to-mesh-return-info) none 16) + (move-along-nav-ray! (_type_ nav-ray) none 16) ;; (TODO-RENAME-16 (_type_ vector nav-poly vector symbol float clip-travel-vector-to-mesh-return-info) none 16) (nav-mesh-method-17 () none 17) ;; (update-route-table (_type_) none 17) (nav-mesh-method-18 () none 18) ;; (dummy-18 (_type_ int vector int (pointer int8) int) none 18) (nav-mesh-method-19 () none 19) ;; (compute-bounding-box (_type_ vector vector) none 19) @@ -18957,11 +19977,11 @@ (nav-mesh-method-34 () none 34) (nav-mesh-method-35 () none 35) (nav-mesh-method-36 () none 36) - (nav-mesh-method-37 () none 37) + (point-in-poly? (_type_ nav-poly vector) symbol 37) (nav-mesh-method-38 () none 38) - (nav-mesh-method-39 () none 39) + (closest-point-on-boundary (_type_ nav-poly vector vector) none 39) (nav-mesh-method-40 () none 40) - (nav-mesh-method-41 () none 41) + (project-point-into-poly-2d (_type_ nav-poly vector vector) none 41) (nav-mesh-method-42 () none 42) (nav-mesh-method-43 () none 43) (nav-mesh-method-44 () none 44) @@ -18969,20 +19989,19 @@ (nav-mesh-method-46 () none 46) ) ) -|# -;; (define-extern vector-normalize-unity! function) -;; (define-extern vector-normalize-unity-copy! function) -;; (define-extern debug-validate-current-poly function) -;; (define-extern init-ray function) ;; (function nav-ray symbol) -;; (define-extern point-poly-intersection? function) -;; (define-extern nav-sphere-from-cam function) ;; (function none) + +(define-extern vector-normalize-unity! (function vector vector)) +(define-extern vector-normalize-unity-copy! (function vector vector vector)) +(define-extern debug-validate-current-poly (function symbol)) +(define-extern init-ray (function nav-ray none)) +(define-extern point-poly-intersection? (function nav-mesh vector int (inline-array vector) symbol)) +(define-extern nav-sphere-from-cam (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; nav-control-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype check-vector-collision-with-nav-spheres-info (structure) ((u float :offset-assert 0) (intersect vector :inline :offset-assert 16) @@ -18992,9 +20011,7 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype nav-gap-info (structure) ((dest vector :inline :offset-assert 0) (poly nav-poly :offset-assert 16) @@ -19003,14 +20020,12 @@ :size-assert #x14 :flag-assert #x900000014 ) -|# -#| (deftype nav-avoid-spheres-params (structure) ((current-pos vector :inline :offset-assert 0) (travel vector :inline :offset-assert 16) (pref-dir vector :inline :offset-assert 32) - (out-travel UNKNOWN 2 :offset-assert 48) + (out-travel vector 2 :inline :offset-assert 48) (closest-sphere-dist2 float :offset-assert 80) (avoiding-sphere? basic :offset-assert 84) ) @@ -19018,22 +20033,60 @@ :size-assert #x58 :flag-assert #x900000058 ) -|# -#| (deftype nav-callback-info (structure) ((callback-count int32 :offset-assert 0) - (callback-array UNKNOWN 10 :offset-assert 4) + (callback-array uint32 10 :offset-assert 4) ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c ) -|# -#| +(defenum nav-state-flag + :type uint32 + :bitfield #t + + (display-marks 0) ;; 1 + (recovery-mode 1) ;; 2 + (initialized 2) ;; 4 + (debug 3) ;; 8 + (directional-mode 4) ;; 16 + (trapped-by-sphere 5) ;; 32 + (target-poly-dirty 6) ;; 64 + (blocked 7) ;; 128 + (in-target-poly 8) ;; 256 + (at-target 9) ;; 512 + (target-inside 10) ;; 1024 + (in-mesh 11) ;; 2048 + (avoiding-sphere 12) ;; 4096 + (touching-sphere 13) ;; 8192 + (at-gap 14) ;; 16384 + ) + (deftype nav-state (structure) - () + ((flags nav-state-flag) + (nav basic) ;; ?? + (user-poly nav-poly) + (mesh nav-mesh) + (current-poly nav-poly) + (virtual-current-poly nav-poly) + (next-poly nav-poly) + (target-poly nav-poly) + (rotation-rate float :offset-assert 32) + (speed meters) + (prev-speed meters) + (pad0 uint32 1) + (travel vector :inline :offset-assert 48) + (target-post vector :inline) + (current-pos vector :inline) + (current-pos-local vector :inline) + (virtual-current-pos-local vector :inline) + (velocity vector :inline :offset-assert 128) + (heading vector :inline) + (target-dir vector :inline :offset-assert 160) + (accel vector :inline :offset 160) + ) :method-count-assert 55 :size-assert #xb0 :flag-assert #x37000000b0 @@ -19087,11 +20140,45 @@ (nav-state-method-54 () none 54) ) ) -|# -#| +(defenum nav-control-flag + :type uint32 + :bitfield #t + (display-marks 0) ;; 1 + (debug 1) ;; 2 + (no-redirect-in-clamp 2) ;; 4 + (limit-rotation-rate 3) ;; 8 + (update-heading-from-facing 4) ;; 16 + (use-momentum 5) ;; 32 + (momentum-ignore-heading 6) ;; 64 + (output-sphere-hash 7) ;; 128 + (kernel-run 8) ;; 256 + ) + (deftype nav-control (structure) - () + ((flags nav-control-flag) + (callback-info nav-callback-info) + (process process) + (pad0 uint32) + (shape basic) + (nearest-y-threshold meters) + (nav-cull-radius meters) + (sec-per-frame float) + (target-speed meters) + (acceleration meters) + (turning-acceleration meters) + (max-rotation-rate float) + (speed-scale float) + (sphere-count int32) + (sphere-array (inline-array sphere)) ;; guess + (root-sphere-id uint8) + (sphere-mask uint8) + (pad1 uint8 2) + (sphere-id-array uint8 16) + (extra-nav-sphere vector :inline) + (root-nav-sphere vector :inline) + (state nav-state :inline) + ) :method-count-assert 47 :size-assert #x120 :flag-assert #x2f00000120 @@ -19138,40 +20225,37 @@ (nav-control-method-46 () none 46) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; spatial-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype grid-hash-word (uint8) -;; () -;; :flag-assert #x900000001 -;; ) +(deftype grid-hash-word (uint8) + () + :flag-assert #x900000001 + ) -#| (deftype grid-hash-box (structure) - ((min UNKNOWN 3 :offset-assert 0) - (max UNKNOWN 3 :offset-assert 3) + ((min uint8 3 :offset-assert 0) + (max uint8 3 :offset-assert 3) ) + :pack-me :method-count-assert 9 :size-assert #x6 :flag-assert #x900000006 ) -|# -#| (deftype grid-hash (basic) ((work basic :offset-assert 4) (search-box grid-hash-box :inline :offset-assert 8) (bucket-size int16 :offset-assert 14) - (axis-scale UNKNOWN 3 :offset-assert 16) - (dimension-array UNKNOWN 3 :offset-assert 28) + (axis-scale uint32 3 :offset-assert 16) + (dimension-array uint8 3 :offset-assert 28) (vertical-cell-count int8 :offset-assert 31) (bucket-array uint32 :offset-assert 32) - (box-min UNKNOWN 3 :offset-assert 36) - (box-max UNKNOWN 3 :offset-assert 48) + (box-min uint32 3 :offset-assert 36) + (box-max uint32 3 :offset-assert 48) (object-count int16 :offset-assert 60) (bucket-count int16 :offset-assert 62) (min-cell-size float :offset-assert 64) @@ -19203,9 +20287,7 @@ (grid-hash-method-24 () none 24) ) ) -|# -#| (deftype find-nav-sphere-ids-params (structure) ((bsphere sphere :inline :offset-assert 0) (y-threshold float :offset-assert 16) @@ -19218,9 +20300,7 @@ :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype sphere-hash (grid-hash) ((sphere-array uint32 :offset-assert 88) (max-object-count int16 :offset-assert 92) @@ -19243,9 +20323,7 @@ (sphere-hash-method-33 () none 33) ) ) -|# -#| (deftype hash-object-info (structure) ((object basic :offset-assert 0) ) @@ -19253,9 +20331,7 @@ :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype spatial-hash (sphere-hash) ((object-array uint32 :offset-assert 104) (mem-object-array uint32 :offset-assert 108) @@ -19274,69 +20350,71 @@ (spatial-hash-method-40 () none 40) ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; actor-hash-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *actor-list* object) -;; (define-extern *actor-list-length* object) +(define-extern *actor-list* pointer) ;; some array of something. +(define-extern *actor-list-length* int) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; load-dgo ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum load-msg-result + :type uint16 + :bitfield #f + (done 0) + (error 1) + (more 2) + (aborted 3) + (invalid 666) + ) + (deftype load-dgo-msg (structure) ((rsvd uint16 :offset-assert 0) - (result uint16 :offset-assert 2) ;; load-msg-result + (result load-msg-result :offset-assert 2) (b1 pointer :offset-assert 4) ;; guessed by decompiler (b2 pointer :offset-assert 8) ;; guessed by decompiler (bt pointer :offset-assert 12) ;; guessed by decompiler (name uint128 :offset-assert 16) - (address uint32 :offset-assert 4) + (address uint32 :offset 4) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# -#| (deftype load-chunk-msg (structure) ((rsvd uint16 :offset-assert 0) - (result uint16 :offset-assert 2) ;; load-msg-result + (result load-msg-result :offset-assert 2) (address pointer :offset-assert 4) ;; guessed by decompiler (section uint32 :offset-assert 8) (maxlen uint32 :offset-assert 12) - (dummy UNKNOWN 4 :offset-assert 16) + (dummy uint32 4 :offset-assert 16) (basename sound-stream-name :inline :offset-assert 32) ;; uint8 48 ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype play-chunk-msg (structure) ((rsvd uint16 :offset-assert 0) (result uint16 :offset-assert 2) - (address uint32 :offset-assert 4) + (address pointer :offset-assert 4) (section uint32 :offset-assert 8) (maxlen uint32 :offset-assert 12) - (id UNKNOWN 4 :offset-assert 16) - (basename UNKNOWN 4 :offset-assert 32) + (id uint32 4 :offset-assert 16) + (basename sound-stream-name 4 :inline :offset-assert 32) ) :method-count-assert 9 :size-assert #xe0 :flag-assert #x9000000e0 ) -|# -#| (deftype dgo-header (structure) ((length uint32 :offset-assert 0) (rootname uint8 60 :offset-assert 4) ;; guessed by decompiler @@ -19345,31 +20423,30 @@ :size-assert #x40 :flag-assert #x900000040 ) -|# -;; (define-extern *load-dgo-rpc* object) ;; rpc-buffer-pair -;; (define-extern *load-str-rpc* object) ;; rpc-buffer-pair -;; (define-extern *play-str-rpc* object) ;; rpc-buffer-pair -;; (define-extern *load-str-lock* object) ;; symbol -;; (define-extern *que-str-lock* object) ;; symbol -;; (define-extern *dgo-name* object) ;; string -;; (define-extern str-load function) ;; (function string int pointer int symbol) -;; (define-extern str-load-status function) ;; (function (pointer int32) symbol) -;; (define-extern str-load-cancel function) ;; (function none) -;; (define-extern str-play-async function) ;; (function string sound-id none) -;; (define-extern str-play-stop function) ;; (function string none) -;; (define-extern str-play-queue function) ;; (function string none) -;; (define-extern str-ambient-play function) ;; (function string none) -;; (define-extern str-ambient-stop function) ;; (function string none) -;; (define-extern str-play-kick function) ;; (function none) -;; (define-extern *dgo-time* object) ;; time-frame -;; (define-extern dgo-load-begin function) ;; (function string pointer pointer pointer load-dgo-msg) -;; (define-extern dgo-load-get-next function) ;; (function (pointer symbol) pointer) -;; (define-extern dgo-load-continue function) ;; (function pointer int) -;; (define-extern dgo-load-cancel function) ;; (function none) -;; (define-extern find-temp-buffer function) ;; (function int pointer) -;; (define-extern dgo-load-link function) ;; (function dgo-header kheap symbol symbol symbol) -;; (define-extern destroy-mem function) ;; (function (pointer uint32) (pointer uint32) none) +(define-extern *load-dgo-rpc* rpc-buffer-pair) +(define-extern *load-str-rpc* rpc-buffer-pair) +(define-extern *play-str-rpc* rpc-buffer-pair) +(define-extern *load-str-lock* symbol) +(define-extern *que-str-lock* symbol) +(define-extern *dgo-name* string) +(define-extern str-load (function string int pointer int symbol)) +(define-extern str-load-status (function (pointer int32) symbol)) +(define-extern str-load-cancel (function none)) +(define-extern str-play-async (function string sound-id none)) +(define-extern str-play-stop (function string sound-id none)) +(define-extern str-play-queue (function string string string string (pointer uint32) pointer none)) +(define-extern str-ambient-play (function string none)) +(define-extern str-ambient-stop (function string none)) +(define-extern str-play-kick (function none)) ;; +(define-extern *dgo-time* time-frame) +(define-extern dgo-load-begin (function string pointer pointer pointer load-dgo-msg)) +(define-extern dgo-load-get-next (function (pointer symbol) pointer)) +(define-extern dgo-load-continue (function pointer pointer pointer load-dgo-msg)) +(define-extern dgo-load-cancel (function none)) +(define-extern find-temp-buffer (function int pointer)) +(define-extern dgo-load-link (function dgo-header kheap uint symbol symbol symbol)) +(define-extern destroy-mem (function (pointer uint32) (pointer uint32) none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ramdisk ;; @@ -19455,7 +20532,7 @@ ;; (define-extern current-str-pos function) ;; (function sound-id int) ;; (define-extern is-ramdisk-loaded? function) ;; (define-extern is-cd-in? function) ;; (function symbol) -;; (define-extern new-sound-id function) ;; (function sound-id) +(define-extern new-sound-id (function sound-id)) ;; (define-extern check-irx-version function) ;; (function int) ;; (define-extern sound-bank-iop-store function) ;; (define-extern sound-bank-iop-free function) @@ -19471,32 +20548,32 @@ ;; (define-extern sound-command->string function) ;; (function sound-command string) ;; (define-extern sound-buffer-dump function) ;; (function int) ;; (define-extern *sound-player-enable* object) ;; symbol -;; (define-extern swap-sound-buffers function) ;; (function vector vector float int) +(define-extern swap-sound-buffers (function vector vector float int)) ;; (define-extern get-sound-buffer-entry function) ;; (function pointer) ;; (define-extern free-last-sound-buffer-entry function) ;; (function int) ;; (define-extern sound-basic-cb function) ;; (function int (pointer int32) none) ;; (define-extern sound-trans-convert function) ;; (function vector3w vector int) ;; (define-extern sound-angle-convert function) ;; (function float int) -;; (define-extern string->sound-name function) ;; (function string sound-name) +(define-extern string->sound-name (function string sound-name)) ;; (define-extern sound-set-volume function) ;; (function sound-group float int) ;; (define-extern sound-set-reverb function) ;; (function int float float uint int) ;; (define-extern sound-set-ear-trans function) ;; (function vector vector float int) ;; (define-extern sound-play-by-name function) ;; (function sound-name sound-id int int int sound-group symbol sound-id) -;; (define-extern sound-play-by-spec function) ;; (function sound-spec sound-id vector sound-id) +(define-extern sound-play-by-spec (function sound-spec sound-id vector sound-id)) ;; (define-extern sound-pause function) ;; (function sound-id int) ;; (define-extern sound-stop function) ;; (function sound-id int) ;; (define-extern sound-continue function) ;; (function sound-id int) -;; (define-extern sound-group-pause function) ;; (function sound-group int) +(define-extern sound-group-pause (function sound-group int)) ;; (define-extern sound-group-stop function) ;; (function sound-group int) -;; (define-extern sound-group-continue function) ;; (function sound-group int) +(define-extern sound-group-continue (function sound-group int)) ;; (define-extern sound-set-flava function) ;; (function uint int) ;; (define-extern sound-set-midi-reg function) ;; (define-extern sound-set-fps function) ;; (function int int) ;; (define-extern sound-volume-off function) ;; (function int) ;; (define-extern *ambient-spec* sound-spec) ;; sound-spec -;; (define-extern show-iop-info function) ;; (function dma-buffer int) -;; (define-extern show-iop-memory function) ;; (function dma-buffer int) -;; (define-extern ear-trans function) ;; (function vector) +(define-extern show-iop-info (function dma-buffer int)) +(define-extern show-iop-memory (function dma-buffer int)) +(define-extern ear-trans (function vector)) ;; (define-extern make-sqrt-table function) ;; (function int) ;; (define-extern loader-test-command function) ;; (define-extern doppler-pitch-shift function) @@ -19507,11 +20584,11 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern transformq-copy! function) ;; (function transformq transformq transformq) -;; (define-extern matrix<-transformq! function) ;; (function matrix transformq matrix) +(define-extern matrix<-transformq! (function matrix transformq matrix)) ;; (define-extern matrix<-no-trans-transformq! function) ;; (function matrix transformq matrix) ;; (define-extern matrix<-transformq+trans! function) ;; (function matrix transformq vector matrix) ;; (define-extern matrix<-transformq+world-trans! function) ;; (function matrix transformq vector matrix) -;; (define-extern matrix<-parented-transformq! function) ;; (function matrix transformq vector matrix) +(define-extern matrix<-parented-transformq! (function matrix transformq vector matrix)) ;; (define-extern matrix<-transformq+rot-offset! function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -19553,7 +20630,7 @@ ;; (define-extern cspace<-parent-joint! function) ;; (define-extern cspace<-rot-yxy! function) ;; (function cspace transform matrix) ;; (define-extern cspace<-transform-yxy! function) ;; (function cspace transform matrix) -;; (define-extern cspace<-transformq! function) ;; (function cspace transformq matrix) +(define-extern cspace<-transformq! (function cspace transformq matrix)) ;; (define-extern cspace<-transformq+trans! function) ;; (function cspace transformq vector matrix) ;; (define-extern cspace<-transformq+world-trans! function) ;; (function cspace transformq vector matrix) ;; (define-extern cspace<-transformq+rot-offset! function) @@ -19564,7 +20641,7 @@ ;; (define-extern cspace<-parented-matrix-mirror! function) ;; (define-extern cspace<-parented-matrix-joint-flip-z! function) ;; (define-extern cspace<-matrix-joint-flip-z! function) -;; (define-extern cspace<-parented-transformq-joint! function) ;; (function cspace transformq none) +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) ;; (define-extern cspace<-parented-transformq-joint-flip-z! function) ;; (define-extern clear-frame-accumulator function) ;; (function (inline-array vector) none) ;; (define-extern normalize-frame-quaternions function) ;; function @@ -19575,7 +20652,7 @@ ;; (define-extern calc-animation-from-spr function) ;; (function (inline-array vector) int none) ;; (define-extern create-interpolated-joint-animation-frame function) ;; (function (inline-array vector) int process-drawable int) ;; (define-extern create-interpolated2-joint-animation-frame function) -;; (define-extern *anim-manager* object) +(define-extern *anim-manager* art-joint-anim-manager) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; joint-mod ;; @@ -19633,13 +20710,13 @@ ;; wind-work ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *wind-work* wind-work) ;; wind-work +(define-extern *wind-work* wind-work) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; wind ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern update-wind function) ;; (function wind-work (array uint8) none) +(define-extern update-wind (function wind-work (array uint8) none)) ;; (define-extern wind-get-hashed-index function) ;; (function vector int) ;; (define-extern level-update-wind function) @@ -19650,9 +20727,9 @@ ;; (define-extern mem-usage-bsp-tree function) ;; (function bsp-header bsp-node memory-usage-block int none) ;; (define-extern *test-shrub* object) ;; int ;; (define-extern bsp-camera-asm function) ;; (function bsp-header vector none) -;; (define-extern print-collide-stats function) ;; (function none) +(define-extern print-collide-stats (function none)) ;; (define-extern level-remap-texture function) ;; (function texture-id texture-id) -;; (define-extern build-masks function) +(define-extern build-masks (function bsp-header none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; subdivide ;; @@ -19664,9 +20741,9 @@ ;; (define-extern *stat-string-tfrag-scissor* object) ;; (define-extern *stat-string-total* object) ;; string ;; (define-extern print-tr-stat function) ;; (function tr-stat string string none) -;; (define-extern print-terrain-stats function) ;; (function none) +(define-extern print-terrain-stats (function none)) ;; (define-extern update-subdivide-settings! function) ;; (function subdivide-settings math-camera int none) -;; (define-extern *subdivide-settings* object) ;; subdivide-settings +(define-extern *subdivide-settings* subdivide-settings) ;; (define-extern set-tfrag-dists! function) ;; (function tfrag-dists none) ;; (define-extern *terrain-context* object) ;; terrain-context ;; (define-extern GSH_ENABLE object) ;; symbol @@ -19674,11 +20751,11 @@ ;; (define-extern GSH_WHICH_STAT object) ;; int ;; (define-extern GSH_MAX_DISPLAY object) ;; basic ;; (define-extern GSH_TIME object) ;; int -;; (define-extern *perf-stats* object) ;; perf-stat-array +(define-extern *perf-stats* perf-stat-array) ;; (define-extern *gomi-stats-hack* object) ;; (inline-array perf-stat) -;; (define-extern start-perf-stat-collection function) ;; (function none) -;; (define-extern end-perf-stat-collection function) ;; (function none) -;; (define-extern print-perf-stats function) ;; (function none) +(define-extern start-perf-stat-collection (function none)) +(define-extern end-perf-stat-collection (function none)) +(define-extern print-perf-stats (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sprite ;; @@ -19807,7 +20884,7 @@ ;; (define-extern sprite-add-2d-all function) ;; (function sprite-array-2d dma-buffer int none) ;; (define-extern sprite-add-3d-chunk function) ;; (function sprite-array-3d int int dma-buffer none) ;; (define-extern sprite-add-3d-all function) ;; (function sprite-array-3d dma-buffer int none) -;; (define-extern sprite-draw function) ;; (function display none) +(define-extern sprite-draw (function display none)) ;; (define-extern sprite-allocate-user-hvdf function) ;; (function int) ;; (define-extern sprite-release-user-hvdf function) ;; (function int none) ;; (define-extern sprite-get-user-hvdf function) ;; (function int vector) @@ -20056,22 +21133,22 @@ ;; (define-extern get-debug-line function) ;; (function debug-line) ;; (define-extern get-debug-text-3d function) ;; (function debug-text-3d) ;; (define-extern debug-reset-buffers function) ;; (function symbol) -;; (define-extern debug-draw-buffers function) ;; (function symbol) -;; (define-extern add-debug-line function) ;; (function symbol bucket-id vector vector rgba symbol rgba symbol) +(define-extern debug-draw-buffers (function symbol)) +(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol)) ;; (define-extern add-debug-line2d function) ;; (function symbol bucket-id vector vector vector symbol) ;; (define-extern add-debug-box function) ;; (function symbol bucket-id vector vector rgba symbol) ;; (define-extern add-debug-box-with-transform function) ;; (define-extern add-debug-x function) ;; (function symbol bucket-id vector rgba symbol) ;; (define-extern add-debug-cross function) -;; (define-extern add-debug-text-3d function) ;; (function symbol bucket-id string vector font-color vector2h symbol) +(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol)) ;; (define-extern add-debug-sphere-with-transform function) ;; (function symbol bucket-id vector meters matrix rgba symbol) -;; (define-extern add-debug-sphere function) ;; (function symbol bucket-id vector float rgba symbol) +(define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol)) ;; (define-extern add-debug-text-sphere function) ;; (function symbol bucket-id vector float string rgba symbol) ;; (define-extern add-debug-spheres function) ;; (function symbol bucket-id (inline-array vector) int rgba symbol) ;; (define-extern add-debug-line-sphere function) ;; (define-extern add-debug-circle function) ;; (function symbol bucket-id vector float rgba matrix symbol) ;; (define-extern add-debug-vector function) ;; (function symbol bucket-id vector vector meters rgba symbol) -;; (define-extern add-debug-matrix function) ;; (function symbol bucket-id matrix matrix) +(define-extern add-debug-matrix (function symbol bucket-id matrix float matrix)) ;; (define-extern add-debug-rot-matrix function) ;; (function symbol bucket-id matrix vector matrix) ;; (define-extern add-debug-quaternion function) ;; (define-extern add-debug-cspace function) @@ -20088,7 +21165,7 @@ ;; (define-extern history-init function) ;; (function pos-history int pos-history) ;; (define-extern history-draw-and-update function) ;; (function pos-history int vector symbol) ;; (define-extern dma-timeout-cam function) ;; (function vector) -;; (define-extern display-file-info function) ;; (function int) +(define-extern display-file-info (function int)) (define-extern add-debug-cursor (function symbol bucket-id int int int none)) ;; (define-extern *boundary-polygon* object) ;; (inline-array lbvtx) ;; (define-extern init-boundary-regs function) ;; (function none) @@ -20253,11 +21330,11 @@ ;; (define-extern *stats-blerc* object) ;; symbol ;; (define-extern *blerc-globals* object) ;; blerc-globals ;; (define-extern blerc-stats-init function) ;; (function none) -;; (define-extern blerc-init function) ;; (function none) +(define-extern blerc-init (function none)) ;; ;; (define-extern blerc-a-fragment function) ;; function ;; (define-extern dma-from-spr function) ;; function ;; (define-extern merc-dma-chain-to-spr function) ;; function -;; (define-extern blerc-execute function) ;; (function none) +(define-extern blerc-execute (function none)) ;; (define-extern merc-blend-shape function) ;; (function process-drawable object) ;; (define-extern setup-blerc-chains-for-one-fragment function) ;; (function object object object object object object object) ;; (define-extern setup-blerc-chains function) ;; (function merc-ctrl (pointer int16) dma-buffer none) @@ -20353,7 +21430,7 @@ ;; (define-extern ripple-execute-init function) ;; (function none) ;; (define-extern ripple-create-wave-table function) ;; (function ripple-wave-set int) ;; (define-extern ripple-apply-wave-table function) ;; (function merc-effect symbol) -;; (define-extern ripple-execute function) ;; (function none) +(define-extern ripple-execute (function none)) ;; (define-extern ripple-matrix-scale function) ;; function ;; (define-extern ripple-add-debug-sphere function) ;; (function process-drawable vector float float none) ;; (define-extern ripple-slow-add-sine-waves function) ;; (function ripple-wave-set float float float) @@ -20379,9 +21456,9 @@ ;; (define-extern bones-vu0-block object) ;; vu-function ;; (define-extern bones-set-sqwc function) ;; (function none) ;; (define-extern bones-reset-sqwc function) ;; (function none) -;; (define-extern bones-init function) ;; (function dma-buffer dma-foreground-sink-group none) +(define-extern bones-init (function dma-buffer none)) ;; (define-extern bones-mtx-calc function) ;; (function int pointer pointer int object none) -;; (define-extern bones-mtx-calc-execute function) ;; (function none) +(define-extern bones-mtx-calc-execute (function none)) ;; (define-extern dump-qword function) ;; (function qword none) ;; (define-extern dump-mem function) ;; (function pointer int none) ;; (define-extern bones-debug function) ;; (function none) @@ -20406,12 +21483,12 @@ ;; (define-extern vu1-bucket-map function) ;; (define-extern generic-bucket-state-init function) ;; (define-extern mercneric-chain-init function) -;; (define-extern foreground-init function) +(define-extern foreground-init (function none)) ;; (define-extern texscroll-make-request function) ;; (function merc-effect none) -;; (define-extern texscroll-execute function) ;; (function none) -;; (define-extern vu-lights<-light-group! function) ;; (function vu-lights light-group none) +(define-extern texscroll-execute (function none)) +(define-extern vu-lights<-light-group! (function vu-lights light-group none)) ;; (define-extern foreground-add-mtx-calc function) -;; (define-extern foreground-wrapup function) +(define-extern foreground-wrapup (function none)) ;; (define-extern *default-shadow-settings* object) ;; shadow-settings ;; (define-extern foreground-shadow function) ;; (define-extern foreground-generic-merc-death function) @@ -20423,7 +21500,7 @@ ;; (define-extern foreground-ripple function) ;; (define-extern foreground-draw function) ;; (define-extern foreground-draw-hud function) -;; (define-extern *foreground-draw-engine* object) +(define-extern *foreground-draw-engine* engine) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-vu0 ;; @@ -20512,7 +21589,7 @@ ;; (define-extern generic-merc-death function) ;; (define-extern generic-merc-execute-asm function) ;; (function none) ;; (define-extern generic-merc-do-chain function) -;; (define-extern generic-merc-execute-all function) ;; (function dma-buffer none) +(define-extern generic-merc-execute-all (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; generic-tie ;; @@ -20613,7 +21690,7 @@ ;; (define-extern debug-draw-settings function) ;; (define-extern shadow-execute function) ;; (function shadow-dma-packet pointer pointer) ;; (define-extern shadow-vu0-upload function) ;; (function none) -;; (define-extern shadow-execute-all function) ;; (function dma-buffer shadow-queue none) +(define-extern shadow-execute-all (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; shadow-vu1 ;; @@ -20727,15 +21804,15 @@ ;; texture-anim-tables ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *sky-texture-anim-array* texture-anim-array) +(define-extern *sky-texture-anim-array* texture-anim-array) ;; (define-extern set-fog-height! function) ;; (define-extern set-cloud-minmax! function) -;; (define-extern *darkjak-texture-anim-array* texture-anim-array) +(define-extern *darkjak-texture-anim-array* texture-anim-array) ;; (define-extern set-darkjak-texture-morph! function) -;; (define-extern *skull-gem-texture-anim-array* texture-anim-array) -;; (define-extern *waterfall-texture-anim-array* texture-anim-array) -;; (define-extern *waterfall-b-texture-anim-array* texture-anim-array) -;; (define-extern *bomb-texture-anim-array* texture-anim-array) +(define-extern *skull-gem-texture-anim-array* texture-anim-array) +(define-extern *waterfall-texture-anim-array* texture-anim-array) +(define-extern *waterfall-b-texture-anim-array* texture-anim-array) +(define-extern *bomb-texture-anim-array* texture-anim-array) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; blit-displays ;; @@ -20746,8 +21823,8 @@ ;; (define-extern blur-disp function) ;; (define-extern filter-disp function) ;; (define-extern hflip-disp function) -;; (define-extern blit-displays function) -;; (define-extern draw-color-bars function) +(define-extern blit-displays (function none)) +(define-extern draw-color-bars (function none)) ;; (define-extern draw-raw-image function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -20765,7 +21842,7 @@ ;; (define-extern draw-string-asm function) ;; (define-extern draw-string function) ;; (function string dma-buffer font-context float) ;; (define-extern get-string-length function) ;; (function string font-context float) -;; (define-extern draw-string-xy function) ;; (function string dma-buffer int int font-color font-flags float) +(define-extern draw-string-xy (function string dma-buffer int int font-color font-flags float)) ;; (define-extern draw-string-adv function) ;; (function string dma-buffer font-context none) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -20792,15 +21869,15 @@ ;; background ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *background-work* object) ;; background-work +(define-extern *background-work* background-work) ;; (define-extern background-vu0-block object) ;; vu-function ;; (define-extern background-upload-vu0 function) ;; (function none) -;; (define-extern init-background function) ;; (function none) +(define-extern init-background (function none)) ;; (define-extern upload-vis-bits function) ;; (function level level bsp-header none) ;; (define-extern set-background-regs! function) ;; (define-extern set-tie-quard-planes! function) ;; (define-extern set-shrub-quard-planes! function) -;; (define-extern finish-background function) ;; (function none) +(define-extern finish-background (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; draw-node ;; @@ -21280,7 +22357,7 @@ ;; (define-extern *sp-temp* object) ;; (define-extern lookup-part-group-by-name function) ;; (function string basic) ;; (define-extern lookup-part-group-pointer-by-name function) ;; (function string (pointer sparticle-launch-group)) -;; (define-extern part-group-pointer? function) ;; (function pointer symbol) +(define-extern part-group-pointer? (function pointer symbol)) ;; (define-extern unlink-part-group-by-heap function) ;; (function kheap int) ;; (define-extern sp-init-fields! function) ;; (function object (inline-array sp-field-init-spec) sp-field-id sp-field-id symbol object) ;; (define-extern *sp-launcher-lock* object) ;; symbol @@ -21302,7 +22379,7 @@ ;; (define-extern sp-relaunch-setup-fields function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) ;; (define-extern sp-relaunch-particle-2d function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) ;; (define-extern sp-relaunch-particle-3d function) ;; (function object sparticle-launcher sparticle-cpuinfo sprite-vec-data-3d none) -;; (define-extern execute-part-engine function) +(define-extern execute-part-engine (function none)) ;; (define-extern sparticle-track-root function) ;; (function object sparticle-cpuinfo vector none) ;; (define-extern sparticle-track-root-prim function) ;; (function object sparticle-cpuinfo vector none) ;; (define-extern sparticle-track-joint function) @@ -21367,13 +22444,12 @@ ;; (define-extern kill-all-particles-with-key function) ;; (function sparticle-launch-control none) ;; (define-extern forall-particles-runner function) ;; (function (function sparticle-system sparticle-cpuinfo pointer none) sparticle-system none) ;; (define-extern forall-particles function) ;; (function function symbol symbol none) -;; (define-extern kill-all-particles-in-level function) ;; (function level int) +(define-extern kill-all-particles-in-level (function level int)) ;; (define-extern all-particles-50-to-60 function) ;; (function none) ;; (define-extern all-particles-60-to-50 function) ;; (function none) ;; (define-extern remap-particle function) ;; (define-extern remap-all-particles function) -;; (define-extern process-particles function) ;; (function none) - +(define-extern process-particles (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; entity-table ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -21430,8 +22506,8 @@ ;; (define-extern *preload-spool-anims* object) ;; symbol ;; (define-extern ja-play-spooled-anim function) ;; (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) int :behavior process-drawable) ;; (define-extern ja-abort-spooled-anim function) ;; (function spool-anim art-joint-anim int int :behavior process-drawable) -;; (define-extern *gui-control* object) -;; (define-extern *art-control* object) ;; external-art-control +(define-extern *gui-control* gui-control) +(define-extern *art-control* external-art-control) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; game-info ;; @@ -21441,7 +22517,7 @@ ;; (define-extern task-level->string function) ;; (define-extern level-name->task-level function) ;; (define-extern trsq->continue-point function) ;; (function trsq none) -;; (define-extern position->stream function) +(define-extern position->stream (function string symbol symbol none)) ;; (define-extern bug-report-display function) ;; (define-extern print-continues function) ;; (define-extern *highscore-info-array* array) @@ -21572,15 +22648,15 @@ ;; (define-extern auto-save-post function) ;; (function none :behavior auto-save) ;; (define-extern auto-save-init-by-other function) ;; (function symbol process-tree int int none :behavior auto-save) ;; (define-extern auto-save-command function) ;; (function symbol int int process-tree none) -;; (define-extern auto-save-check function) ;; (function none) +(define-extern auto-save-check (function none)) ;; (define-extern auto-save-user function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; settings ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern get-current-language function) -;; (define-extern *setting-control* object) ;; setting-control +(define-extern get-current-language (function language-enum)) +(define-extern *setting-control* setting-control) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mood-tables ;; @@ -21617,7 +22693,7 @@ ;; (define-extern *mood-sky-table* object) ;; (define-extern *mood-interp-table* object) ;; (define-extern init-mood-control function) -;; (define-extern *mood-control* mood-control) +(define-extern *mood-control* mood-control) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mood-tables2 ;; @@ -21730,7 +22806,7 @@ ;; (define-extern update-mood-exterior function) ;; (define-extern copy-mood-exterior function) ;; (define-extern copy-mood-exterior-ambi function) -;; (define-extern clear-mood-context function) +(define-extern clear-mood-context (function int none)) ;; (define-extern update-mood-interior function) ;; (define-extern update-mood-flames function) ;; (function mood-context int int int float float float none) ;; (define-extern *flash0* array) ;; (array float) @@ -22690,18 +23766,18 @@ ;; (define-extern time-of-day-setup function) ;; (function symbol symbol) ;; (define-extern time-of-day-interp-colors function) ;; (function (pointer rgba) uint mood-context none) ;; (define-extern time-of-day-interp-colors-scratch function) ;; (function (pointer rgba) time-of-day-palette mood-context none) -;; (define-extern init-time-of-day-context function) ;; (function time-of-day-context none) +(define-extern init-time-of-day-context (function time-of-day-context none)) ;; (define-extern set-filter-color! function) ;; (define-extern tod-madd! function) ;; (define-extern update-environment-colors function) -;; (define-extern update-time-of-day function) ;; (function time-of-day-context none) +(define-extern update-time-of-day (function time-of-day-context none)) ;; (define-extern calc-fade-from-fog function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; sky-data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *sky-work* object) ;; sky-work +(define-extern *sky-work* sky-work) ;; (define-extern sky-base-polygons object) ;; (inline-array sky-vertex) ;; (define-extern sky-roof-polygons object) ;; (inline-array sky-vertex) ;; (define-extern *cloud-vert-array* object) @@ -22731,191 +23807,193 @@ ;; (define-extern *display-load-commands* object) ;; symbol ;; (define-extern *backup-load-state* object) ;; load-state -;; (define-extern *load-state* object) ;; load-state +(define-extern *load-state* load-state) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; level-info ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *task-level* array) -;; (define-extern default-level level-load-info) ;; level-load-info -;; (define-extern intro level-load-info) ;; level-load-info -;; (define-extern demo level-load-info) ;; level-load-info -;; (define-extern title level-load-info) ;; level-load-info -;; (define-extern vinroom level-load-info) -;; (define-extern drillmid level-load-info) -;; (define-extern drill level-load-info) -;; (define-extern drillb level-load-info) -;; (define-extern drillmtn level-load-info) -;; (define-extern sewer level-load-info) -;; (define-extern sewerb level-load-info) -;; (define-extern sewesc level-load-info) -;; (define-extern sewescb level-load-info) -;; (define-extern tomba level-load-info) -;; (define-extern tombb level-load-info) -;; (define-extern tombc level-load-info) -;; (define-extern tombd level-load-info) -;; (define-extern tombe level-load-info) -;; (define-extern tombext level-load-info) -;; (define-extern tombboss level-load-info) -;; (define-extern under level-load-info) -;; (define-extern underb level-load-info) -;; (define-extern palcab level-load-info) -;; (define-extern palshaft level-load-info) -;; (define-extern palboss level-load-info) -;; (define-extern palroof level-load-info) -;; (define-extern palout level-load-info) -;; (define-extern throne level-load-info) -;; (define-extern lbrnermk level-load-info) -;; (define-extern lashthrn level-load-info) -;; (define-extern lthrnout level-load-info) -;; (define-extern palent level-load-info) -;; (define-extern prison level-load-info) -;; (define-extern ldjakbrn level-load-info) -;; (define-extern lprsncst level-load-info) -;; (define-extern forexita level-load-info) -;; (define-extern forexitb level-load-info) -;; (define-extern forresca level-load-info) -;; (define-extern forrescb level-load-info) -;; (define-extern fordumpa level-load-info) -;; (define-extern fordumpb level-load-info) -;; (define-extern fordumpc level-load-info) -;; (define-extern fordumpd level-load-info) -;; (define-extern strip level-load-info) -;; (define-extern ruins level-load-info) -;; (define-extern sagehut level-load-info) -;; (define-extern atoll level-load-info) -;; (define-extern atollext level-load-info) -;; (define-extern mountain level-load-info) -;; (define-extern mtnext level-load-info) -;; (define-extern forest level-load-info) -;; (define-extern forestb level-load-info) -;; (define-extern mincan level-load-info) -;; (define-extern ctywide level-load-info) -;; (define-extern lwidea level-load-info) -;; (define-extern lwideb level-load-info) -;; (define-extern lwidec level-load-info) -;; (define-extern ctykora level-load-info) -;; (define-extern ctyasha level-load-info) -;; (define-extern ctygena level-load-info) -;; (define-extern ctygenb level-load-info) -;; (define-extern ctygenc level-load-info) -;; (define-extern ctysluma level-load-info) -;; (define-extern ctyslumb level-load-info) -;; (define-extern ctyslumc level-load-info) -;; (define-extern ctyport level-load-info) -;; (define-extern ljkdxash level-load-info) -;; (define-extern ctyfarma level-load-info) -;; (define-extern ctyfarmb level-load-info) -;; (define-extern ctyinda level-load-info) -;; (define-extern consite level-load-info) -;; (define-extern consiteb level-load-info) -;; (define-extern ctyindb level-load-info) -;; (define-extern ctymarka level-load-info) -;; (define-extern ctymarkb level-load-info) -;; (define-extern ctypal level-load-info) -;; (define-extern stadium level-load-info) -;; (define-extern stadiumb level-load-info) -;; (define-extern stadiumc level-load-info) -;; (define-extern stadiumd level-load-info) -;; (define-extern skatea level-load-info) -;; (define-extern garage level-load-info) -;; (define-extern stadblmp level-load-info) -;; (define-extern lwidesta level-load-info) -;; (define-extern lerrol level-load-info) -;; (define-extern lkeirift level-load-info) -;; (define-extern lracelit level-load-info) -;; (define-extern lracebb level-load-info) -;; (define-extern lracebf level-load-info) -;; (define-extern lracecb level-load-info) -;; (define-extern lracecf level-load-info) -;; (define-extern lracedb level-load-info) -;; (define-extern lracedf level-load-info) -;; (define-extern lgarcsta level-load-info) -;; (define-extern lsamergd level-load-info) -;; (define-extern lerbrngd level-load-info) -;; (define-extern lsmysbrt level-load-info) -;; (define-extern lashgrd level-load-info) -;; (define-extern onintent level-load-info) -;; (define-extern ltentout level-load-info) -;; (define-extern ltentob level-load-info) -;; (define-extern kiosk level-load-info) -;; (define-extern oracle level-load-info) ;; type -;; (define-extern hideout level-load-info) -;; (define-extern ltrntess level-load-info) -;; (define-extern ltrnkrkd level-load-info) -;; (define-extern ltrnysam level-load-info) -;; (define-extern lysamsam level-load-info) -;; (define-extern lyskdcd level-load-info) -;; (define-extern lkiddoge level-load-info) -;; (define-extern lhelldog level-load-info) -;; (define-extern lpackage level-load-info) -;; (define-extern lsack level-load-info) -;; (define-extern lportrun level-load-info) -;; (define-extern lshuttle level-load-info) -;; (define-extern lmeetbrt level-load-info) -;; (define-extern lpower level-load-info) -;; (define-extern lerlchal level-load-info) -;; (define-extern lprtrace level-load-info) -;; (define-extern lbombbot level-load-info) -;; (define-extern lbbush level-load-info) -;; (define-extern lprotect level-load-info) -;; (define-extern hiphog level-load-info) -;; (define-extern ltess level-load-info) -;; (define-extern lhipout level-load-info) -;; (define-extern lwhack level-load-info) -;; (define-extern lguard level-load-info) -;; (define-extern lcguard level-load-info) -;; (define-extern lerltess level-load-info) -;; (define-extern gungame level-load-info) -;; (define-extern dig1 level-load-info) -;; (define-extern dig3a level-load-info) -;; (define-extern dig3b level-load-info) -;; (define-extern caspad level-load-info) -;; (define-extern castle level-load-info) -;; (define-extern casboss level-load-info) -;; (define-extern casext level-load-info) -;; (define-extern cascity level-load-info) -;; (define-extern village1 level-load-info) ;; level-load-info -;; (define-extern introcst level-load-info) -;; (define-extern lcitylow level-load-info) -;; (define-extern lintcstb level-load-info) -;; (define-extern ljakdax level-load-info) -;; (define-extern nest level-load-info) -;; (define-extern nestb level-load-info) -;; (define-extern outrocst level-load-info) -;; (define-extern portwall level-load-info) -;; (define-extern loutcstb level-load-info) -;; (define-extern island1 level-load-info) -;; (define-extern city-start function) -;; (define-extern skatepark level-load-info) -;; (define-extern halfpipe level-load-info) ;; level-load-info -;; (define-extern vistest level-load-info) -;; (define-extern woodstest level-load-info) -;; (define-extern tobytest level-load-info) -;; (define-extern chartest level-load-info) -;; (define-extern dptest level-load-info) -;; (define-extern ctyfence level-load-info) -;; (define-extern *level-load-list* object) ;; pair +(define-extern *task-level* array) +(define-extern default-level level-load-info) ;; level-load-info +(define-extern intro level-load-info) ;; level-load-info +(define-extern demo level-load-info) ;; level-load-info +(define-extern title level-load-info) ;; level-load-info +(define-extern vinroom level-load-info) +(define-extern drillmid level-load-info) +(define-extern drill level-load-info) +(define-extern drillb level-load-info) +(define-extern drillmtn level-load-info) +(define-extern sewer level-load-info) +(define-extern sewerb level-load-info) +(define-extern sewesc level-load-info) +(define-extern sewescb level-load-info) +(define-extern tomba level-load-info) +(define-extern tombb level-load-info) +(define-extern tombc level-load-info) +(define-extern tombd level-load-info) +(define-extern tombe level-load-info) +(define-extern tombext level-load-info) +(define-extern tombboss level-load-info) +(define-extern under level-load-info) +(define-extern underb level-load-info) +(define-extern palcab level-load-info) +(define-extern palshaft level-load-info) +(define-extern palboss level-load-info) +(define-extern palroof level-load-info) +(define-extern palout level-load-info) +(define-extern throne level-load-info) +(define-extern lbrnermk level-load-info) +(define-extern lashthrn level-load-info) +(define-extern lthrnout level-load-info) +(define-extern palent level-load-info) +(define-extern prison level-load-info) +(define-extern ldjakbrn level-load-info) +(define-extern lprsncst level-load-info) +(define-extern forexita level-load-info) +(define-extern forexitb level-load-info) +(define-extern forresca level-load-info) +(define-extern forrescb level-load-info) +(define-extern fordumpa level-load-info) +(define-extern fordumpb level-load-info) +(define-extern fordumpc level-load-info) +(define-extern fordumpd level-load-info) +(define-extern strip level-load-info) +(define-extern ruins level-load-info) +(define-extern sagehut level-load-info) +(define-extern atoll level-load-info) +(define-extern atollext level-load-info) +(define-extern mountain level-load-info) +(define-extern mtnext level-load-info) +(define-extern forest level-load-info) +(define-extern forestb level-load-info) +(define-extern mincan level-load-info) +(define-extern ctywide level-load-info) +(define-extern lwidea level-load-info) +(define-extern lwideb level-load-info) +(define-extern lwidec level-load-info) +(define-extern ctykora level-load-info) +(define-extern ctyasha level-load-info) +(define-extern ctygena level-load-info) +(define-extern ctygenb level-load-info) +(define-extern ctygenc level-load-info) +(define-extern ctysluma level-load-info) +(define-extern ctyslumb level-load-info) +(define-extern ctyslumc level-load-info) +(define-extern ctyport level-load-info) +(define-extern ljkdxash level-load-info) +(define-extern ctyfarma level-load-info) +(define-extern ctyfarmb level-load-info) +(define-extern ctyinda level-load-info) +(define-extern consite level-load-info) +(define-extern consiteb level-load-info) +(define-extern ctyindb level-load-info) +(define-extern ctymarka level-load-info) +(define-extern ctymarkb level-load-info) +(define-extern ctypal level-load-info) +(define-extern stadium level-load-info) +(define-extern stadiumb level-load-info) +(define-extern stadiumc level-load-info) +(define-extern stadiumd level-load-info) +(define-extern skatea level-load-info) +(define-extern garage level-load-info) +(define-extern stadblmp level-load-info) +(define-extern lwidesta level-load-info) +(define-extern lerrol level-load-info) +(define-extern lkeirift level-load-info) +(define-extern lracelit level-load-info) +(define-extern lracebb level-load-info) +(define-extern lracebf level-load-info) +(define-extern lracecb level-load-info) +(define-extern lracecf level-load-info) +(define-extern lracedb level-load-info) +(define-extern lracedf level-load-info) +(define-extern lgarcsta level-load-info) +(define-extern lsamergd level-load-info) +(define-extern lerbrngd level-load-info) +(define-extern lsmysbrt level-load-info) +(define-extern lashgrd level-load-info) +(define-extern onintent level-load-info) +(define-extern ltentout level-load-info) +(define-extern ltentob level-load-info) +(define-extern kiosk level-load-info) +(define-extern oracle level-load-info) ;; type +(define-extern hideout level-load-info) +(define-extern ltrntess level-load-info) +(define-extern ltrnkrkd level-load-info) +(define-extern ltrnysam level-load-info) +(define-extern lysamsam level-load-info) +(define-extern lyskdcd level-load-info) +(define-extern lkiddoge level-load-info) +(define-extern lhelldog level-load-info) +(define-extern lpackage level-load-info) +(define-extern lsack level-load-info) +(define-extern lportrun level-load-info) +(define-extern lshuttle level-load-info) +(define-extern lmeetbrt level-load-info) +(define-extern lpower level-load-info) +(define-extern lerlchal level-load-info) +(define-extern lprtrace level-load-info) +(define-extern lbombbot level-load-info) +(define-extern lbbush level-load-info) +(define-extern lprotect level-load-info) +(define-extern hiphog level-load-info) +(define-extern ltess level-load-info) +(define-extern lhipout level-load-info) +(define-extern lwhack level-load-info) +(define-extern lguard level-load-info) +(define-extern lcguard level-load-info) +(define-extern lerltess level-load-info) +(define-extern gungame level-load-info) +(define-extern dig1 level-load-info) +(define-extern dig3a level-load-info) +(define-extern dig3b level-load-info) +(define-extern caspad level-load-info) +(define-extern castle level-load-info) +(define-extern casboss level-load-info) +(define-extern casext level-load-info) +(define-extern cascity level-load-info) +(define-extern village1 level-load-info) ;; level-load-info +(define-extern introcst level-load-info) +(define-extern lcitylow level-load-info) +(define-extern lintcstb level-load-info) +(define-extern ljakdax level-load-info) +(define-extern nest level-load-info) +(define-extern nestb level-load-info) +(define-extern outrocst level-load-info) +(define-extern portwall level-load-info) +(define-extern loutcstb level-load-info) +(define-extern island1 level-load-info) +(define-extern city-start (function none)) +(define-extern skatepark level-load-info) +(define-extern halfpipe level-load-info) ;; level-load-info +(define-extern vistest level-load-info) +(define-extern woodstest level-load-info) +(define-extern tobytest level-load-info) +(define-extern chartest level-load-info) +(define-extern dptest level-load-info) +(define-extern ctyfence level-load-info) +(define-extern *level-load-list* pair) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; level ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern lookup-level-info function) ;; (function symbol level-load-info) -;; (define-extern remap-level-name function) ;; (function level-load-info symbol) -;; (define-extern add-bsp-drawable function) ;; (function bsp-header level symbol display-frame none) -;; (define-extern *login-state* object) ;; login-state -;; (define-extern *print-login* object) ;; symbol -;; (define-extern load-buffer-resize function) -;; (define-extern level-update-after-load function) ;; (function level login-state level) +(define-extern lookup-level-info (function symbol level-load-info)) +(define-extern remap-level-name (function level-load-info symbol)) +(define-extern add-bsp-drawable (function bsp-header level symbol display-frame none)) +(define-extern *login-state* login-state) +(define-extern *print-login* symbol) +(define-extern load-buffer-resize (function level pointer none)) +(define-extern level-update-after-load (function level login-state level)) (define-extern bg (function symbol int)) (define-extern play (function symbol symbol int)) (define-extern play-boot (function none)) ;; (define-extern update-sound-banks function) ;; (function int) -;; (define-extern show-level function) ;; (function symbol int) +(define-extern show-level (function symbol int)) (define-extern *default-level* level) +(define-extern *level-type-list* type) ;; ?? + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; text ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -22942,7 +24020,7 @@ ;; (define-extern convert-korean-text function) ;; (define-extern text-is-loading object) ;; symbol ;; (define-extern load-game-text-info function) ;; (function string symbol kheap int) -;; (define-extern load-level-text-files function) ;; (function int none) +(define-extern load-level-text-files (function int none)) ;; (define-extern draw-debug-text-box function) ;; (function font-context none) ;; (define-extern print-game-text-scaled function) ;; (function string float font-context int none) ;; (define-extern print-game-text function) ;; (function string font-context symbol int int float) @@ -23113,7 +24191,7 @@ ;; (define-extern cshape-reaction-update-state function) ;; (define-extern cshape-reaction-default function) ;; (define-extern cshape-reaction-just-move function) -;; (define-extern collide-shape-draw-debug-marks function) ;; (function none) +(define-extern collide-shape-draw-debug-marks (function none)) ;; (define-extern *col-timer* object) ;; stopwatch ;; (define-extern *frame-timer* object) ;; stopwatch ;; (define-extern *col-timer-enable* object) ;; symbol @@ -23128,7 +24206,7 @@ ;; collide ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *collide-vif0-init* array) ;; (array uint32) +(define-extern *collide-vif0-init* (array uint32)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-planes ;; @@ -23216,7 +24294,7 @@ ;; (define-extern *actor-hash* object) ;; (define-extern *actor-hash-buckets* object) -;; (define-extern update-actor-hash function) +(define-extern update-actor-hash (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; merc-death ;; @@ -23391,12 +24469,12 @@ ;; (define-extern matrix-local->world function) ;; (function symbol symbol matrix) ;; (define-extern matrix-world->local function) ;; (function matrix) ;; (define-extern *camera-dummy-vector* object) ;; vector -;; (define-extern camera-pos function) ;; (function vector) +(define-extern camera-pos (function vector)) ;; ;; (define-extern math-camera-pos function) ;; (function vector) ;; (define-extern camera-matrix function) ;; (define-extern math-camera-matrix function) -;; (define-extern camera-angle function) ;; (function float) -;; (define-extern camera-teleport-to-entity function) ;; (function entity-actor none :behavior process) +(define-extern camera-angle (function float)) +(define-extern camera-teleport-to-entity (function entity-actor none :behavior process)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; cam-master ;; @@ -23626,11 +24704,11 @@ ;; (define-extern update-visible function) ;; (function math-camera symbol) ;; (define-extern *save-camera-inv-rot* object) ;; matrix ;; (define-extern move-camera-from-pad function) ;; (function math-camera math-camera) -;; (define-extern external-cam-reset! function) ;; (function none) +(define-extern external-cam-reset! (function none)) ;; (define-extern *start-timer* object) ;; int ;; (define-extern *timer-value* object) ;; int ;; (define-extern *start-pos* object) ;; vector -;; (define-extern update-camera function) ;; (function symbol) +(define-extern update-camera (function symbol)) ;; ;; (define-extern move-level-by-name function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -24000,9 +25078,9 @@ ;; (define-extern *camera-old-stat-string-tfrag* object) ;; string ;; (define-extern *camera-old-stat-string-tfrag-near* object) ;; string ;; (define-extern *camera-old-stat-string-total* object) ;; string -;; (define-extern cam-slave-options->string function) ;; (function cam-slave-options object string) -;; (define-extern cam-index-options->string function) ;; (function cam-index-options object string) -;; (define-extern slave-los-state->string function) ;; (function slave-los-state string) +(define-extern cam-slave-options->string (function cam-slave-options object string)) +(define-extern cam-index-options->string (function cam-index-options object string)) +(define-extern slave-los-state->string (function slave-los-state string)) ;; (define-extern cam-line-dma function) ;; (function pointer) ;; (define-extern camera-line2d function) ;; (function vector4w vector4w pointer) ;; (define-extern camera-plot-float-func function) ;; (function float float float float (function float float) vector4w none) @@ -24050,9 +25128,9 @@ ;; process-drawable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern cspace-by-name function) ;; (function process-drawable string cspace) -;; (define-extern cspace-index-by-name function) ;; (function process-drawable string int) -;; (define-extern vector<-cspace! function) ;; (function vector cspace vector) +(define-extern cspace-by-name (function process-drawable string cspace)) +(define-extern cspace-index-by-name (function process-drawable string int)) +(define-extern vector<-cspace! (function vector cspace vector)) ;; (define-extern vector<-matrix! function) ;; (define-extern vector<-cspace+vector! function) ;; (function vector cspace vector vector) ;; (define-extern cspace-children function) ;; (function process-drawable int pair) @@ -24061,7 +25139,7 @@ ;; (define-extern draw-joint-axes function) ;; (define-extern draw-root function) ;; (define-extern empty-state state) ;; (state process) -;; (define-extern process-drawable-art-error state) ;; (state string process-drawable) +(define-extern process-drawable-art-error (state string process-drawable)) ;; (define-extern process-drawable-idle state) ;; (state process-drawable) ;; (define-extern skeleton-group->draw-control function) ;; (define-extern ja-done? function) ;; (function int symbol :behavior process-drawable) @@ -24076,7 +25154,7 @@ ;; (define-extern ja-channel-set! function) ;; (function int int :behavior process-drawable) ;; (define-extern ja-channel-push! function) ;; (function int time-frame int :behavior process-drawable) ;; (define-extern ja-channel-float! function) -;; (define-extern joint-control-reset! function) ;; (function joint-control joint-control-channel none :behavior process-drawable) +(define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable)) ;; (define-extern ja-group-size function) ;; (function int :behavior process-drawable) ;; (define-extern ja-eval function) ;; (function int :behavior process-drawable) ;; (define-extern ja-blend-eval function) ;; (function int :behavior process-drawable) @@ -24118,7 +25196,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern region-tree-execute function) -;; (define-extern region-execute function) +(define-extern region-execute (function none)) ;; (define-extern region-prim-lookup-by-id function) ;; (define-extern region-lookup-by-id function) @@ -24182,6 +25260,8 @@ ) |# +(declare-type camera-start basic) +(define-extern camera-start type) #| (deftype camera-start (process-hidden) () @@ -24271,7 +25351,7 @@ ) |# -;; (define-extern *lightning-spec-id-table* object) +(define-extern *lightning-spec-id-table* (array lightning-spec)) ;; (define-extern *lightning-gcf* object) ;; (define-extern lightning-fractal-gen function) ;; (define-extern lightning-uniform-gen function) @@ -24285,7 +25365,7 @@ ;; (define-extern lightning-start function) ;; (define-extern *lightning-globals* object) ;; (define-extern *lightning* object) -;; (define-extern lightning-draw-all function) +(define-extern lightning-draw-all (function none)) ;; (define-extern unlink-lightning-spec-by-heap function) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -24647,7 +25727,7 @@ ;; (define-extern target-log-attack function) ;; (define-extern ground-tween-initialize function) ;; (function ground-tween-info uint uint uint uint uint uint ground-tween-info :behavior target) ;; (define-extern ground-tween-update function) ;; (function ground-tween-info float float none :behavior target) -;; (define-extern target-pos function) ;; (function int vector) +(define-extern target-pos (function int vector)) ;; (define-extern target-cam-pos function) ;; (function vector) ;; (define-extern target-rot function) ;; (function quaternion) @@ -24687,8 +25767,8 @@ ;; (define-extern target-collision-reaction function) ;; (function control-info collide-shape-intersect vector vector cshape-moving-flags) ;; (define-extern target-collision-no-reaction function) ;; (function control-info collide-shape-intersect vector vector none) ;; (define-extern *collide-edge-board-spec* object) -;; (define-extern rail-surface-touch function) -;; (define-extern gravel-surface-touch function) +(define-extern rail-surface-touch (function none)) +(define-extern gravel-surface-touch (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; logic-target ;; @@ -24741,7 +25821,7 @@ ;; (define-extern target-init function) ;; (define-extern tobot-init function) (define-extern stop (function symbol int)) -;; (define-extern start function) ;; (function symbol continue-point target) +(define-extern start (function symbol continue-point target)) ;; (define-extern tobot-start function) ;; (define-extern tobot-stop function) @@ -24920,7 +26000,7 @@ ;; (define-extern projectile-move-fill-line-sphere function) ;; (define-extern projectile-update-velocity-add-gravity function) ;; (define-extern projectile-update-velocity-space-wars function) ;; (function projectile none) -;; (define-extern projectile-init-by-other function) ;; (function entity-actor vector vector uint handle none :behavior projectile) +(define-extern projectile-init-by-other (function projectile-init-by-other-params projectile)) ;; (function entity-actor vector vector uint handle none :behavior projectile) ;; (define-extern projectile-bounce-update-velocity function) ;; (define-extern projectile-bounce-falling-post function) ;; (define-extern projectile-bounce-move function) @@ -25659,13 +26739,13 @@ ;; drawable ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern sphere-cull function) ;; (function vector symbol) -;; (define-extern guard-band-cull function) ;; (function vector symbol) -;; (define-extern sphere-in-view-frustum? function) ;; (function sphere symbol) +(define-extern sphere-cull (function vector symbol)) +(define-extern guard-band-cull (function vector symbol)) +(define-extern sphere-in-view-frustum? (function sphere symbol)) ;; (define-extern line-in-view-frustum? function) ;; (function vector vector symbol) -;; (define-extern vis-cull function) ;; (function int symbol) +(define-extern vis-cull (function int symbol)) ;; (define-extern vis-cull-debug function) -;; (define-extern error-sphere function) ;; (function drawable-error string none) +(define-extern error-sphere (function drawable-error string none)) ;; (define-extern *edit-instance* object) ;; string ;; (define-extern *instance-mem-usage* object) ;; memory-usage-block ;; (define-extern find-instance-by-name-level function) @@ -25683,25 +26763,25 @@ ;; (define-extern *hud-lights* object) ;; vu-lights ;; (define-extern dma-add-process-drawable-hud function) ;; (function process-drawable draw-control symbol dma-buffer none) ;; (define-extern add-process-drawable function) ;; (function process-drawable draw-control symbol dma-buffer none) -;; (define-extern foreground-engine-execute function) ;; (function engine display-frame int int none) +(define-extern foreground-engine-execute (function engine display-frame none)) ;; (define-extern main-debug-hook function) ;; (function none) ;; (define-extern *debug-hook* object) ;; (function none) -;; (define-extern *add-sphere* object) ;; symbol +(define-extern *add-sphere* symbol) ;; (define-extern *generic-effect-mode* object) ;; int -;; (define-extern foreground-initialize-engines function) -;; (define-extern foreground-execute-cpu-vu0-engines function) -;; (define-extern real-main-draw-hook function) ;; (function none) -;; (define-extern main-draw-hook function) ;; (function none) -;; (define-extern *draw-hook* object) ;; (function none) +(define-extern foreground-initialize-engines (function none)) +(define-extern foreground-execute-cpu-vu0-engines (function none)) +(define-extern real-main-draw-hook (function none)) +(define-extern main-draw-hook (function none)) +(define-extern *draw-hook* (function none)) ;; (define-extern default-init-buffer function) ;; (define-extern default-end-buffer function) ;; (define-extern screen-shot-scale function) ;; (define-extern screen-shot function) ;; (define-extern display-frame-start function) ;; (function display int int none) -;; (define-extern display-frame-finish function) ;; (function display display) +(define-extern display-frame-finish (function display display)) ;; (define-extern determine-pause-mode function) ;; (function int) -;; (define-extern display-sync function) ;; (function display none) -;; (define-extern swap-display function) ;; (function display none) +(define-extern display-sync (function display none)) +(define-extern swap-display (function display none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; drawable-group ;; @@ -25736,40 +26816,40 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (define-extern set-video-mode function) ;; (function symbol none) -;; (define-extern get-video-mode function) ;; (function symbol) +(define-extern get-video-mode (function symbol)) ;; (define-extern set-aspect-ratio function) ;; (function symbol none) ;; (define-extern get-aspect-ratio function) ;; (function symbol) ;; (define-extern set-progressive-scan function) ;; (define-extern get-progressive-scan function) ;; (define-extern *smode2* object) -;; (define-extern set-graphics-mode function) +(define-extern set-graphics-mode (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; main ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern set-letterbox-frames (function time-frame none)) -;; (define-extern letterbox function) ;; (function none) -;; (define-extern set-blackout-frames function) ;; (function time-frame none) -;; (define-extern blackout function) ;; (function none) -;; (define-extern paused? function) ;; (function symbol) -;; (define-extern movie? function) ;; (function symbol) -;; (define-extern demo? function) +(define-extern letterbox (function none)) +(define-extern set-blackout-frames (function time-frame none)) +(define-extern blackout (function none)) +(define-extern paused? (function symbol)) +(define-extern movie? (function symbol)) +(define-extern demo? (function symbol)) (define-extern *last-master-mode* symbol) -;; (define-extern set-master-mode function) ;; (function symbol none) -;; (define-extern pause-allowed? function) ;; (function symbol) -;; (define-extern toggle-pause function) ;; (function int) +(define-extern set-master-mode (function symbol none)) +(define-extern pause-allowed? (function symbol)) +(define-extern toggle-pause (function int)) (define-extern *screen-filter* screen-filter) (define-extern *cheat-temp* (pointer int32)) (define-extern *master-exit* symbol) (define-extern *progress-cheat* symbol) (define-extern *first-boot* symbol) -;; (define-extern main-cheats function) ;; (function int) -;; (define-extern end-display function) -;; (define-extern display-loop-main function) +(define-extern main-cheats (function int)) +(define-extern end-display (function display none)) +(define-extern display-loop-main (function display none)) (define-extern display-loop (function int :behavior process)) (define-extern on (function symbol process)) -;; (define-extern off function) ;; (function int) +(define-extern off (function int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; collide-cache ;; @@ -25879,9 +26959,9 @@ ;; (define-extern *spawn-actors* object) ;; symbol ;; (define-extern *compact-actors* object) ;; symbol ;; (define-extern *vis-actors* object) ;; symbol -;; (define-extern entity-by-name function) ;; (function string entity) +(define-extern entity-by-name (function string entity)) (define-extern entity-by-type (function type entity-actor)) -;; (define-extern entity-by-aid function) ;; (function uint entity) +(define-extern entity-by-aid (function uint entity)) ;; (define-extern entity-actor-from-level-name function) ;; (define-extern entity-nav-mesh-by-aid function) ;; (define-extern nav-mesh-from-res-tag function) @@ -25892,7 +26972,7 @@ ;; (define-extern entity-remap-names function) ;; (function pair none) ;; (define-extern process-status-bits function) ;; (function process symbol none) ;; (define-extern process-entity-set! function) -;; (define-extern process-task-mask function) +(define-extern process-task-mask (function process task-mask)) ;; (define-extern update-actor-vis-box function) ;; (function process-drawable vector vector none) ;; (define-extern expand-bounding-box function) ;; (define-extern expand-vis-box-with-point function) ;; (function entity vector none) @@ -26364,7 +27444,7 @@ ;; (define-extern *fail-mission-control* fail-mission-control) ;; (define-extern game-task-node->string function) -;; (define-extern update-task-masks function) +(define-extern update-task-masks (function symbol none)) ;; (define-extern play-clean function) ;; (define-extern play-task function) ;; (define-extern restart-mission function) @@ -26690,7 +27770,7 @@ |# ;; (define-extern *progress-stack* object) ;; (pointer uint8) -;; (define-extern *progress-process* object) ;; (pointer progress) +(define-extern *progress-process* (pointer progress)) ;; (define-extern *progress-state* progress-global-state) ;; progress-global-state ;; (define-extern *progress-save-info* object) ;; mc-slot-info ;; (define-extern min-max-wrap-around function) @@ -26698,10 +27778,10 @@ ;; (define-extern hud-ring-cell-init-by-other function) ;; (define-extern progress-init-by-other function) ;; (function none :behavior progress) ;; (define-extern set-ring-position function) -;; (define-extern activate-progress function) ;; (function process progress-screen none) +(define-extern activate-progress (function process symbol none)) ;; (define-extern deactivate-progress function) ;; (function none) -;; (define-extern hide-progress-screen function) ;; (function none) -;; (define-extern progress-allowed? function) ;; (function symbol) +(define-extern hide-progress-screen (function none)) +(define-extern progress-allowed? (function symbol)) ;; (define-extern menu-update-purchase-secrets function) ;; (define-extern progress-trans function) ;; (define-extern begin-scan function) @@ -26883,7 +27963,7 @@ ;; bigmap-data ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *bigmap-compressed-layers* object) +(define-extern *bigmap-compressed-layers* bigmap-compressed-layers) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bigmap ;; @@ -26893,7 +27973,7 @@ ;; (define-extern *circle-mask-2x2-meters* array) ;; (define-extern *image-mask-table* object) ;; (define-extern *map-save-ptr* object) -;; (define-extern *bigmap* object) +(define-extern *bigmap* bigmap) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; eye ;; @@ -27182,7 +28262,7 @@ ;; (define-extern anim-tester-add-newobj function) ;; (function anim-tester string art-group object) ;; (define-extern anim-tester-stop function) ;; (function symbol) ;; (define-extern anim-tester-start function) ;; (function symbol) -;; (define-extern anim-tester-add-object function) ;; (function string none) +(define-extern anim-tester-add-object (function string none)) ;; (define-extern anim-tester-set-name function) ;; (function string object) ;; (define-extern anim-tester-add-sequence function) ;; (function string none) @@ -27889,7 +28969,7 @@ ;; (define-extern debug-menu-context-make-default-menus function) ;; (function debug-menu-context debug-menu-context) ;; (define-extern *popup-menu-context* object) ;; debug-menu-context ;; (define-extern popup-menu-context-make-default-menus function) ;; (function debug-menu-context debug-menu-context) -;; (define-extern menu-respond-to-pause function) ;; (function symbol) +(define-extern menu-respond-to-pause (function symbol)) ;; (define-extern *menu-hook* function) ;; (function debug-menu-context) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -34910,7 +35990,7 @@ ;; (define-extern draw-large-polygon-vortex function) ;; (define-extern render-vortex-quad function) ;; (define-extern update-vortex-data function) -;; (define-extern draw-vortex function) +(define-extern draw-vortex (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ai-task-h ;; diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index 1f91f9c9f9..d594ac7895 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -12,5 +12,35 @@ ], "main": [ [3, "(function none :behavior process)"] + ], + "profile": [ + [9, "(function profile-segment-array profile-collapse none)"] + ], + "bigmap-h": [ + [1, "(function external-art-buffer none)"], + [2, "(function external-art-buffer none)"] + ], + "surface-h": [ + [0, "(function none)"], + [1, "(function none)"] + ], + + "main": [ + [10, "(function none)"], + [9, "(function none)"], + [8, "(function none)"], + [7, "(function time-frame none)"], + [3, "(function none)"] + ], + + "level-info": [ + [0, "(function none)"], + [1, "(function none)"], + [2, "(function none)"] + ], + + "level": [ + [5, "(function none)"], + [24, "(function level-group int symbol)"] ] } \ No newline at end of file diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 1d3d5f48ab..793cf0413f 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -16,13 +16,17 @@ // the second argument is the name of the first condition in the cond. Use print_cfg to find it out. // The third argument is the number of cases. If you set it too small it may fail to build the CFG. "cond_with_else_max_lengths": [ - + ["(method 20 res-lump)", "b0", 2], + ["(method 11 res-lump)", "b0", 1], + ["(method 12 res-lump)", "b0", 1] ], // if a cond with an else case is being used a value in a place where it looks wrong // you can add the function name to this list and it will more aggressively reject this rewrite. "aggressively_reject_cond_to_value_rewrite": [ - + "(method 10 res-lump)", + "(method 11 res-lump)", + "(method 12 res-lump)" ], // this provides a hint to the decompiler that these functions will have a lot of inline assembly. @@ -31,8 +35,8 @@ "asm_functions_by_name": [ // checking boxed type is different now - these make the cfg stuff sad - "name=", "(method 8 res-lump)", "joint-control-remap!", "(method 21 game-info)", "(method 12 level)", - "bg", "(anon-function 2 cam-combiner)", "cspace-inspect-tree", "command-get-process", "command-get-trans", "(method 10 script-context)", + "name=", "joint-control-remap!", "(method 21 game-info)", + "(anon-function 2 cam-combiner)", "cspace-inspect-tree", "command-get-process", "command-get-trans", "(method 10 script-context)", "(method 11 script-context)", "(method 9 script-context)", "(anon-function 64 script)", "(anon-function 61 script)", "(anon-function 60 script)", "(anon-function 54 script)", "(anon-function 52 script)", "(anon-function 49 script)", "(anon-function 33 script)", "debug-menu-func-decode", "scene-player-init", "(method 77 spyder)", "(method 77 flamer)", "(method 77 grenadier)", "(method 224 bot)", "(method 77 rapid-gunner)", @@ -47,7 +51,9 @@ // actual asm "quad-copy!", "return-from-thread", "return-from-thread-dead", "reset-and-call", "(method 10 cpu-thread)", "(method 11 cpu-thread)", "(method 0 catch-frame)", "throw-dispatch", "throw", "run-function-in-process", - "set-to-run-bootstrap", "return-from-exception", "exp", + "set-to-run-bootstrap", "return-from-exception", "exp", "(method 17 bounding-box)", "(method 9 bounding-box)", + "(method 9 matrix)", "quaternion->matrix-2", "sin-rad", "cos-rad", "atan-series-rad", "sign-float", "dma-count-until-done", + "(method 11 collide-mesh-cache)", "symlink2", "blerc-a-fragment", "blerc-execute", "foreground-check-longest-edge-asm", "generic-light-proc", "shadow-add-single-edges","shadow-add-facing-single-tris", "shadow-add-double-tris", "shadow-add-double-edges", @@ -83,7 +89,11 @@ "delete-car!", "insert-cons!", "sort", - "unload-package" + "unload-package", + "display-loop-main", + "lookup-level-info", + "(method 24 level-group)", + "(method 19 level-group)" ], // If format is used with the wrong number of arguments, @@ -91,7 +101,12 @@ // that they used the correct number. This will override the decompiler's // automatic detection. "bad_format_strings": { - + "~170h~5d~220h~5d~280h~5,,2f": 3, + "~338h~5d~388h~5d~448h~5,,2f": 3, + "~1k~%":0, + "~30Htf: ~8D~134Hpr: ~8D~252Hsh: ~8D~370Hhd: ~8D~%":4, + "~30Hal: ~8D~131Hwa: ~8D~252Hsp: ~8D~370Hwp: ~8D~%":4, + "~0Kload ~16S ~5S ~5DK ~5,,2fs ~5,,2fs~1K ~5,,0f k/s~%":6 }, "blocks_ending_in_asm_branch": { @@ -103,7 +118,14 @@ "find-knot-span": [0, 1, 2, 3, 5, 6, 7, 8, 9], - "curve-evaluate!": [0, 2, 5, 6, 7, 8, 9] + "curve-evaluate!": [0, 2, 5, 6, 7, 8, 9], + + "display-loop-main": [127, 130, 133, 136], + + "real-main-draw-hook": [114, 115, 116, 118], + + "(method 12 perf-stat)": [0], + "(method 11 perf-stat)": [0] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index fad2c11641..392de23831 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -8,33 +8,6 @@ ["L102", "(pointer float)", 32] ], - // possible for auto-labeling - "vector-h": [ - ["L36", "vector"], - ["L35", "vector"], - ["L34", "vector"], - ["L33", "vector"], - ["L32", "vector"], - ["L31", "vector"], - ["L30", "vector"] - ], - - "matrix": [ - ["L65", "matrix"] - ], - "quaternion-h": [ - ["L1", "quaternion"] - ], - "quaternion": [ - ["L85", "vector"], - ["L84", "vector"], - ["L83", "vector"], - ["L82", "vector"], - ["L81", "vector"], - ["L80", "vector"], - ["L79", "vector"], - ["L78", "vector"] - ], "trigonometry": [ ["L93", "vector"], ["L92", "vector"], @@ -63,5 +36,45 @@ "font-h": [ ["L20", "matrix"], ["L19", "font-work"] + ], + "capture": [ + ["L4", "gs-store-image-packet"]], + + "task-control-h": [ + ["L877", "uint64", true], + ["L878", "uint64", true], + ["L879", "uint64", true], + ["L880", "uint64", true], + ["L881", "uint64", true], + ["L882", "uint64", true], + ["L883", "uint64", true] + ], + + "ocean-trans-tables": [ + ["L1", "(inline-array vector)", 4], + ["L2", "(pointer float)", 160], + ["L3", "(pointer float)", 100], + ["L4", "(pointer float)", 72], + ["L5", "(pointer float)", 72], + ["L6", "(pointer float)", 72], + ["L7", "(pointer float)", 72], + ["L8", "(pointer float)", 44], + ["L9", "(pointer float)", 44], + ["L10", "(pointer float)", 44], + ["L11", "(pointer float)", 44], + ["L12", "(pointer float)", 40], + ["L13", "(pointer float)", 40], + ["L14", "(pointer float)", 40], + ["L15", "(pointer float)", 40], + ["L16", "(pointer float)", 28], + ["L17", "(pointer float)", 28], + ["L18", "(pointer float)", 28], + ["L19", "(pointer float)", 28] + ], + "ocean-frames": [["L1", "(pointer uint32)", 16384]], + "ambient-h": [["L1", "(inline-array talker-speech-class)", 188]], + "pat-h": [["L1", "(inline-array pat-mode-info)", 4]], + "joint-mod-h": [ + ["L43", "(inline-array vector)", 6] ] } \ No newline at end of file diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 188f8acd8e..487915f6d5 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1,114 +1,6 @@ { - // possible for automatic detection: - "(method 23 trsqv)": [[16, "vector"]], - "(method 24 trsqv)": [[16, "vector"]], - "(method 18 bounding-box)": [[16, "vector"], [32, "vector"]], - "(method 12 bounding-box)": [[16, "liang-barsky-line-clip-params"]], - "matrixp*!": [[16, "matrix"]], - "vector3s-matrix*!": [[16, "vector"]], - "vector3s-rotate*!": [[16, "vector"]], - - "matrix-rotate-zyx!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix-rotate-xyz!": [ - [16, "vector"], - [32, "vector"], - [80, "matrix"] - ], - "matrix-rotate-zxy!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix-rotate-yxz!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix-rotate-yzx!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix-rotate-yxy!": [ - [16, "vector"], - [32, "vector"], - [48, "vector"] - ], - "matrix-rotate-yx!": [[16, "matrix"]], - "transform-matrix-calc!": [ - [16, "matrix"], - [80, "matrix"] - ], - "transform-matrix-parent-calc!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix->quat": [ - [16, "matrix"] - ], - "matrix<-quat": [ - [16, "vector"], - [32, "matrix"] - ], - "matrix->transformq": [ - [16, "matrix"] - ], - "matrix-rotate-xyz-2!": [ - [16, "matrix"], - [80, "matrix"] - ], - "matrix-with-scale->quaternion": [[16, "matrix"]], "quaternion-exp!": [[16, "vector"]], - "quaternion-slerp!": [[16, "vector"]], - "quaternion-zxy!": [ - [16, "vector"], - [32, "vector"], - [48, "vector"] - ], - "vector-x-quaternion!": [[16, "matrix"]], - "vector-y-quaternion!": [[16, "matrix"]], - "vector-z-quaternion!": [[16, "matrix"]], - "quaternion-x-angle": [[16, "vector"]], - "quaternion-y-angle": [[16, "vector"]], - "quaternion-z-angle": [[16, "vector"]], - "quaternion-rotate-local-x!": [[16, "quaternion"]], - "quaternion-rotate-local-y!": [[16, "quaternion"]], - "quaternion-rotate-local-z!": [[16, "quaternion"]], - "quaternion-rotate-y!": [[16, "quaternion"]], - "quaternion-rotate-x!": [ - [16, "quaternion"], - [32, "vector"] - ], - "quaternion-rotate-z!": [ - [16, "quaternion"], - [32, "vector"] - ], - "quaternion-delta-y": [ - [16, "vector"], - [32, "vector"] - ], - "quaternion-rotate-y-to-vector!": [ - [16, "quaternion"], - [32, "vector"], - [48, "quaternion"] - ], - "quaternion-xz-angle": [ - [16, "matrix"], - [80, "vector"] - ], - "vector-rotate-x!": [ - [16, "quaternion"], - [32, "matrix"] - ], - "vector-rotate-y!": [ - [16, "quaternion"], - [32, "matrix"] - ], - "vector-rotate-z!": [ - [16, "quaternion"], - [32, "matrix"] - ], "quaternion-axis-angle!": [ [16, "vector"] ], @@ -118,16 +10,12 @@ "quaternion-look-at!": [ [16, "matrix"] ], - "quaternion-pseudo-seek": [ - [16, "quaternion"], - [32, "quaternion"] - ], "quaternion-smooth-seek!": [ [16, ["inline-array", "quaternion", 2]] ], + + // possible for automatic detection: "eul->matrix": [[16, "vector"]], - "eul->quat": [[16, "matrix"]], - "quat->eul": [[16, "matrix"]], "vector-sincos!": [[16, "vector"]], "vector-reflect-flat-gravity!": [[16, "vector"], [32, "vector"]], @@ -255,12 +143,53 @@ [32, "vector"], [48, "vector"] ], - "init-for-transform": [ + "init-for-transform": [ [16, "matrix"], [80, "matrix"], [144, "vector4s-3"], [192, "vector"], [208, "vector4s-3"] ], + "draw-sprite2d-xy": [ + [16, "draw-context"] + ], + "screen-gradient": [ + [16, "draw-context"] + ], + "play": [ + [16, "event-message-block"], + [96, ["array", "symbol", 10]] + ], + "store-image": [ + [16, "file-stream"] + ], + + "joint-mod-blend-world-callback": [ + [160, "vector"] + ], + "joint-mod-rotate-local-callback": [ + [16, "vector"] + ], + "light-hash-get-bucket-index": [ + [16, "vector4w"] + ], + "(method 10 cam-vector-seeker)": [ + [16, "vector"] + ], + + "(method 39 nav-mesh)" : [ + [16, "vector"], + [32, "vector"] + ], + + "(method 41 nav-mesh)": [ + [16, "vector"], + [32, "vector"] + ], + + "show-level": [ + [16, ["array", "symbol", 10]] + ], + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index cb89fad732..da2cafb741 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -1,4 +1,15 @@ { + + // auto find-parent-method possible + "(method 3 entity-actor)" : [ + [7, "t9", "(function entity entity)"] + ], + + "(method 3 entity)" : [ + [7, "t9", "(function entity entity)"] + ], + + // "(method 2 array)": [ [23, "gp", "(array int32)"], [43, "gp", "(array uint32)"], @@ -66,26 +77,30 @@ ], "send-event-function": [[[7, 15], "a0", "process"]], + // MATH "logf": [ [12, "f0", "float"], [12, "f1", "float"], [19, "f0", "float"], [19, "f1", "float"] ], - "log2f": [ [12, "f0", "float"], [12, "f1", "float"], [19, "f0", "float"], [19, "f1", "float"] ], - - "log2": [[3, "v1", "int"]], - "cube-root": [ - [[0,33], "f0", "float"], - [[0,33], "f1", "float"], - [[0,33], "f2", "float"] + [17, "f0", "float"], + [17, "f1", "float"], + [18, "f0", "float"], + [18, "f1", "float"], + [[23,32], "f0", "float"] + ], + + // Quaternion + "quaternion-look-at!": [ + [15, "v1", "vector"] ], "vector-x-quaternion!": [[10, "v1", "(pointer uint128)"]], @@ -177,5 +192,341 @@ [13, "s5", "(inline-array vector4)"], [14, "s4", "(inline-array vector4)"], [15, "gp", "(inline-array vector4)"]], + + "vector-segment-distance-point!": [ + [[21,30], "f1", "float"] + ], + + "(method 10 profile-array)": [ + [[6, 10], "a0", "dma-packet"], + [[16, 19], "a0", "gs-gif-tag"], + [24, "a0", "(pointer gs-alpha)"], + [26, "a0", "(pointer gs-reg64)"], + [28, "a0", "(pointer gs-zbuf)"], + [30, "a0", "(pointer gs-reg64)"], + [32, "a0", "(pointer gs-test)"], + [34, "a0", "(pointer gs-reg64)"], + [35, "a0", "(pointer uint64)"], + [37, "a0", "(pointer gs-reg64)"], + [39, "a0", "(pointer gs-clamp)"], + [41, "a0", "(pointer gs-reg64)"], + [43, "a0", "(pointer gs-tex1)"], + [45, "a0", "(pointer gs-reg64)"], + [48, "a0", "(pointer gs-texa)"], + [50, "a0", "(pointer gs-reg64)"], + [52, "a0", "(pointer gs-texclut)"], + [54, "a0", "(pointer gs-reg64)"], + [56, "a0", "(pointer uint64)"], + [58, "a0", "(pointer gs-reg64)"], + [[69, 73], "a0", "(pointer uint128)"], + [[73, 82], "a1", "vector4w"], + [[82, 89], "a1", "vector4w"], + [[90, 96], "a0", "vector4w"], + [[113, 117], "a1", "(pointer uint128)"], + [[117, 126], "a2", "vector4w"], + [[126, 136], "a2", "vector4w"], + [[137, 149], "a1", "vector4w"], + [[187, 191], "t2", "(pointer int128)"], + [[191, 225], "t4", "vector4w"], + [[225, 231], "a2", "vector4w"], + [[231, 237], "a2", "vector4w"] + ], + + "draw-sprite2d-xy": [ + [[35, 39], "t0", "dma-packet"], + [[45, 48], "t0", "gs-gif-tag"], + [53, "t0", "(pointer gs-prim)"], + [55, "t0", "(pointer gs-rgbaq)"], + [66, "t0", "(pointer gs-xyzf)"], + [87, "t0", "(pointer gs-xyzf)"], + [[96, 108], "v1", "(pointer uint64)"] + ], + + "draw-sprite2d-xy-absolute": [ + [[6, 10], "t3", "dma-packet"], + [[16, 19], "t3", "gs-gif-tag"], + [24, "t3", "(pointer gs-prim)"], + [25, "t3", "(pointer gs-rgbaq)"], + [36, "t3", "(pointer gs-xyzf)"], + [49, "t3", "(pointer gs-xyzf)"], + [[62, 69], "v1", "(pointer uint64)"] + ], + + "draw-quad2d": [ + [[18, 22], "t2", "dma-packet"], + [[28, 31], "t2", "gs-gif-tag"], + [36, "t2", "(pointer gs-prim)"], + [38, "t2", "(pointer gs-rgbaq)"], + [46, "t2", "(pointer gs-xyzf)"], + [48, "t2", "(pointer gs-rgbaq)"], + [61, "t2", "(pointer gs-xyzf)"], + [63, "t2", "(pointer gs-rgbaq)"], + [76, "t2", "(pointer gs-xyzf)"], + [78, "t2", "(pointer gs-rgbaq)"], + [96, "t2", "(pointer gs-xyzf)"], + [97, "t2", "(pointer uint64)"], + [[110, 117], "v1", "(pointer uint64)"] + ], + "set-display-gs-state": [ + [[3, 10], "t3", "dma-packet"], + [[13, 19], "t3", "gs-gif-tag"], + [30, "t3", "(pointer gs-scissor)"], + [32, "t3", "(pointer gs-reg64)"], + [33, "t3", "(pointer gs-xy-offset)"], + [35, "t3", "(pointer gs-reg64)"], + [46, "t3", "(pointer gs-frame)"], + [48, "t3", "(pointer gs-reg64)"], + [50, "t3", "(pointer gs-test)"], + [52, "t3", "(pointer gs-reg64)"], + [54, "t3", "(pointer gs-texa)"], + [56, "t3", "(pointer gs-reg64)"], + [58, "t3", "(pointer gs-zbuf)"], + [60, "t3", "(pointer gs-reg64)"], + [61, "t3", "(pointer uint64)"], + [63, "t3", "(pointer gs-reg64)"] + ], + "set-display-gs-state-offset": [ + [[3, 10], "t5", "dma-packet"], + [[13, 19], "t5", "gs-gif-tag"], + [30, "t5", "(pointer gs-scissor)"], + [32, "t5", "(pointer gs-reg64)"], + [40, "t5", "(pointer gs-xy-offset)"], + [42, "t5", "(pointer gs-reg64)"], + [53, "t5", "(pointer gs-frame)"], + [55, "t5", "(pointer gs-reg64)"], + [57, "t5", "(pointer gs-test)"], + [59, "t5", "(pointer gs-reg64)"], + [61, "t5", "(pointer gs-texa)"], + [63, "t5", "(pointer gs-reg64)"], + [65, "t5", "(pointer gs-zbuf)"], + [67, "t5", "(pointer gs-reg64)"], + [68, "t5", "(pointer uint64)"], + [70, "t5", "(pointer gs-reg64)"] + ], + "reset-display-gs-state": [ + [[3, 8], "a2", "dma-packet"], + [[14, 17], "a2", "gs-gif-tag"], + [22, "a1", "(pointer gs-scissor)"], + [24, "a1", "(pointer gs-reg64)"], + [26, "a1", "(pointer gs-xy-offset)"], + [28, "a1", "(pointer gs-reg64)"], + [30, "a1", "(pointer gs-frame)"], + [32, "a1", "(pointer gs-reg64)"], + [34, "a1", "(pointer gs-test)"], + [36, "a1", "(pointer gs-reg64)"], + [39, "a1", "(pointer gs-texa)"], + [41, "a1", "(pointer gs-reg64)"], + [43, "a1", "(pointer gs-zbuf)"], + [45, "a1", "(pointer gs-reg64)"], + [46, "a1", "(pointer uint64)"], + [48, "a1", "(pointer gs-reg64)"] + ], + + "(method 3 connection-pers)": [ + [97, "f0", "float"] + ], + + "(method 9 connection)": [[8, "a0", "pointer"]], + "(method 10 connection)": [[8, "a0", "pointer"]], + "(method 11 connection)": [[5, "a1", "pointer"]], + "(method 0 engine)": [[44, "v1", "pointer"], [47, "v1", "pointer"], [53, "v1", "connectable"], [65, "v1", "connectable"]], + "(method 12 engine)": [ + [[5, 18], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + + "(method 13 engine)": [ + [[5, 28], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + "(method 15 engine)": [[[0, 36], "v1", "connection"]], + "(method 19 engine)": [[8, "a0", "connection"]], + "(method 20 engine)": [[8, "a0", "connection"]], + "(method 21 engine)": [[8, "a0", "connection"]], + "(method 0 engine-pers)": [[32, "v1", "pointer"], [23, "v1", "pointer"], [26, "v1", "pointer"], [24, "v1", "(pointer pointer)"]], + "(method 3 connection-minimap)" : [[97, "f0", "float"]], + "dma-buffer-add-ref-texture": [ + [[25, 29], "a3", "dma-packet"], + [[32, 44], "a3", "gs-gif-tag"], + [[47, 62], "a2", "dma-packet"] + ], + "texture-page-default-allocate": [ + [51, "a3", "texture-page"] + ], + "texture-page-font-allocate": [ + [33, "a3", "texture-page"] + ], + "(method 24 texture-pool)": [ + [67, "a1", "shader-ptr"], + [[70, 91], "a1", "adgif-shader"], + [92, "a1", "adgif-shader"] + ], + + "(method 3 generic-tie-interp-point)":[ + [19, "gp", "(pointer uint128)"] + ], + "(method 19 res-lump)": [ + [46, "t2", "(pointer uint64)"], + [100, "t3", "(pointer uint64)"], + [184, "t5", "(pointer uint64)"], + [64, "t6", "(pointer uint64)"] + ], + "(method 20 res-lump)": [[331, "a3", "(inline-array vector)"]], + "(method 16 res-lump)": [ + [22, "t1", "(pointer uint64)"], + [29, "t2", "(pointer uint64)"] + ], + "(method 15 res-lump)": [[132, "s5", "res-tag-pair"]], + "(method 17 res-lump)": [[22, "s4", "(pointer pointer)"]], + + "(method 0 script-context)" : [[[8, 17], "v0", "script-context"]], + "joint-mod-wheel-callback": [[[2, 63], "s4", "joint-mod-wheel"]], + "joint-mod-set-local-callback": [[[0, 23], "v1", "joint-mod-set-local"]], + "joint-mod-add-local-callback": [[[2, 33], "s4", "joint-mod-add-local"]], + "joint-mod-set-world-callback": [[[0, 23], "v1", "joint-mod-set-world"]], + "joint-mod-blend-local-callback": [[[2, 63], "gp", "joint-mod-blend-local"]], + "joint-mod-spinner-callback": [[[2, 63], "gp", "joint-mod-spinner"]], + "joint-mod-blend-world-callback": [[[2, 148], "gp", "joint-mod-blend-world"]], + "joint-mod-rotate-local-callback": [[[2, 16], "v1", "joint-mod-rotate-local"]], + "(method 0 collide-shape-prim-sphere)": [[[3, 8], "v0", "collide-shape-prim-sphere"]], + "(method 0 collide-shape-prim-mesh)": [[[3, 11], "v0", "collide-shape-prim-mesh"]], + "(method 0 collide-shape-prim-group)": [[[3, 12], "v0", "collide-shape-prim-group"]], + "(method 0 collide-shape-moving)" : [[[2, 12], "v0", "collide-shape-moving"]], + "(method 11 touching-prims-entry-pool)": [ + [[0, 8], "v1", "touching-prims-entry"], + [8, "v1", "pointer"], + [[9, 11], "v1", "touching-prims-entry"], + [[1, 20], "a1", "touching-prims-entry"] + ], + "(method 0 touching-list)": [[[6, 9], "v0", "touching-list"]], + "display-loop-main": [[223, "t9", "(function none)"]], + "end-display": [[205, "f1", "float"], [205, "f0", "float"]], + + "(method 18 res-lump)": [["_stack_", 16, "object"]], + "(method 21 res-lump)": [ + ["_stack_", 16, "res-tag"], + ["_stack_", 32, "res-tag"] + ], + + "(method 8 res-lump)": [ + [258, "s0", "array"], + // [[0, 100], "s0", "basic"], + // [[102, 120], "s0", "basic"], + // [[147, 150], "s0", "collide-mesh"], + [[157, 239], "s0", "(array object)"] + // [235, "s0", "basic"] + ], + "(method 20 res-lump)": [ + [341, "t0", "(pointer uint128)"] + ], + + "(method 0 fact-info-enemy)": [ + [[0, 196], "gp", "fact-info-enemy"], + ["_stack_", 16, "res-tag"], + ["_stack_", 32, "res-tag"] + ], + + "(method 0 fact-info)": [ + [87, "v1", "(pointer int32)"] + ], + + "(method 0 fact-info-crate)": [ + [[0, 17], "gp", "fact-info-crate"] + ], + + + "(method 0 fact-info-target)": [ + [[0, 17], "gp", "fact-info-target"] + ], + + "joint-channel-float-delete!": [ + [7, "a0", "pointer"], + [7, "a1", "pointer"] + ], + + "num-func-chan": [ + [7, "v1", "joint-control-channel"] + ], + + "(method 20 process-focusable)": [ + [15, "gp", "collide-shape-moving"], + [31, "gp", "collide-shape"] + ], + + "(method 10 focus)": [ + [19, "v1", "collide-shape"] + ], + "shrubbery-login-post-texture": [ + [[13, 15], "a3", "qword"], + [16, "a3", "pointer"], + [24, "a3", "pointer"], + [[17, 23], "a3", "qword"], + [[13, 23], "a1", "qword"], + [14, "a2", "qword"], + [[27, 29], "a3", "qword"], + [[27, 29], "a1", "qword"], + [[35, 37], "a3", "qword"], + [[35, 37], "a2", "qword"] + ], + + "(top-level-login eye-h)": [ + [[69, 77], "a1", "eye-control"] + ], + + "entity-actor-lookup": [ + ["_stack_", 16, "res-tag"] + ], + + + "entity-actor-count": [ + ["_stack_", 16, "res-tag"] + ], + + "(method 0 path-control)": [["_stack_", 16, "res-tag"]], + +"(method 9 actor-link-info)": [[[0, 36], "s3", "entity-actor"]], +"(method 41 nav-mesh)": [["_stack_", 56, "float"]], +"(method 39 nav-mesh)": [["_stack_", 56, "float"]], + "str-load": [[[18, 44], "s2", "load-chunk-msg"]], + "str-load-status": [ + [[18, 22], "v1", "load-chunk-msg"], + [26, "v1", "load-chunk-msg"] + ], + "str-play-async": [[[7, 36], "s4", "play-chunk-msg"]], + "str-play-stop": [[[7, 36], "s4", "play-chunk-msg"]], + "str-play-queue": [[[7, 98], "s4", "play-chunk-msg"]], + "str-ambient-play": [[[7, 20], "s5", "load-chunk-msg"]], + "str-ambient-stop": [[[7, 20], "s5", "load-chunk-msg"]], + "dgo-load-begin": [[[19, 41], "s2", "load-dgo-msg"]], + "dgo-load-get-next": [[[14, 31], "v1", "load-dgo-msg"]], + "dgo-load-continue": [[[5, 23], "gp", "load-dgo-msg"]], + "dgo-load-link": [[7, "s4", "uint"], [17, "s4", "uint"], [55, "s4", "uint"], [27, "s4", "uint"], [37, "s4", "uint"]], + + "lookup-level-info": [[3, "a1", "symbol"], [[4, 24], "a1", "level-load-info"]], + "(method 30 level-group)": [[87, "v0", "level"]], + "(method 19 level-group)": [ + [223, "s3", "continue-point"], + [[177, 209], "s1", "continue-point"], + [[182, 224], "s3", "continue-point"], + [434, "v1", "symbol"]], + "(method 18 level)": [ + [[82, 89], "a1", "level"] + ], + "(method 19 level)": [ + [[45, 48], "a0", "texture-anim-array"] + ], + "level-update-after-load": [ + [[123, 152], "s0", "drawable-inline-array-tfrag"], + [[155, 158], "s0", "drawable-tree-instance-tie"], + [365, "a1", "(pointer int32)"], + [370, "a2", "(pointer int32)"] + ], + "(method 25 level)": [ + [97, "t9", "(function object none)"], + [169, "t9", "(function object symbol none)"] + ], + "(method 9 level)": [ + [54, "t9", "(function object none)"] + ], "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak2/var_names.jsonc b/decompiler/config/jak2/var_names.jsonc index 9e26dfeeb6..dbae062519 100644 --- a/decompiler/config/jak2/var_names.jsonc +++ b/decompiler/config/jak2/var_names.jsonc @@ -1 +1,44 @@ -{} \ No newline at end of file +{ + + "(method 15 res-lump)": { + "vars": { + "s5-0": ["tag-pair", "res-tag-pair"], + "s2-0": "existing-tag", + "s3-0": "data-size", + "v1-25": "resource-mem" + } + }, + + "(method 0 lightning-control)": { + "vars": { + "gp-0": ["obj", "lightning-control"] + } + }, + + "(method 0 align-control)": { + "vars": { + "v0-0": ["obj", "align-control"] + } + }, + + "(method 16 nav-mesh)": { + "args": ["obj", "ray"], + "vars": { + "sv-16": "next-poly-idx", + "sv-24": "work", + "sv-28": "current-poly", + "sv-32": "current-poly-vtx-count", + "sv-36": "v0-table", + "sv-40": "v1-table", + "v1-9": "i", + "sv-52": "adj-vtx-0", + "sv-56": "adj-vtx-1", + "sv-44": "delta-x", + "sv-48": "delta-z", + "sv-60": "adj-edge-dz", + "sv-64": "adj-edge-minus-dx", + "f0-10": "heading-dot" + + } + } +} \ No newline at end of file diff --git a/decompiler/config/jak2_ntsc_v1.jsonc b/decompiler/config/jak2_ntsc_v1.jsonc index d889a15401..308f636a5a 100644 --- a/decompiler/config/jak2_ntsc_v1.jsonc +++ b/decompiler/config/jak2_ntsc_v1.jsonc @@ -7,7 +7,7 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. - "allowed_objects": [], + "allowed_objects": ["math"], "banned_objects": ["effect-control"], //////////////////////////// diff --git a/decompiler/level_extractor/fr3_to_gltf.cpp b/decompiler/level_extractor/fr3_to_gltf.cpp index 51d35ea529..35de534b66 100644 --- a/decompiler/level_extractor/fr3_to_gltf.cpp +++ b/decompiler/level_extractor/fr3_to_gltf.cpp @@ -716,7 +716,7 @@ void save_level_background_as_gltf(const tfrag3::Level& level, const fs::path& g // a "scene" is a traditional scene graph, made up of Nodes. // sadly, attempting to nest stuff makes the blender importer unhappy, so we just dump // everything into the top level. - auto& scene = model.scenes.emplace_back(); + model.scenes.emplace_back(); // hack, add a default material. tinygltf::Material mat; @@ -755,7 +755,7 @@ void save_level_foreground_as_gltf(const tfrag3::Level& level, const fs::path& g // a "scene" is a traditional scene graph, made up of Nodes. // sadly, attempting to nest stuff makes the blender importer unhappy, so we just dump // everything into the top level. - auto& scene = model.scenes.emplace_back(); + model.scenes.emplace_back(); // hack, add a default material. tinygltf::Material mat; diff --git a/decompiler/types2/ForwardProp.cpp b/decompiler/types2/ForwardProp.cpp new file mode 100644 index 0000000000..7b1936d251 --- /dev/null +++ b/decompiler/types2/ForwardProp.cpp @@ -0,0 +1,2455 @@ +#include "common/util/BitUtils.h" + +#include "decompiler/IR2/AtomicOp.h" +#include "decompiler/IR2/bitfields.h" +#include "decompiler/ObjectFile/LinkedObjectFile.h" +#include "decompiler/types2/types2.h" +#include "decompiler/util/goal_constants.h" + +/*! + * This file contains implementations of forward type propagation. + */ + +namespace decompiler { + +bool tc(const DecompilerTypeSystem& dts, const TypeSpec& expected, const TP_Type& actual) { + return dts.ts.tc(expected, actual.typespec()); +} + +bool is_int_or_uint(const DecompilerTypeSystem& dts, const TP_Type& type) { + return tc(dts, TypeSpec("integer"), type) || tc(dts, TypeSpec("uint"), type); +} +bool is_signed(const DecompilerTypeSystem& dts, const TP_Type& type) { + return tc(dts, TypeSpec("int"), type) && !tc(dts, TypeSpec("uint"), type); +} + +/*! + * Set up an instruction which sets its result to an ambiguous deref. + * The possibilities are specified in FieldReverseMultiLookupOutput. + */ +void types2_from_ambiguous_deref(types2::Instruction& instr, + types2::Type& type, + const std::vector& out, + bool tag_lock) { + ASSERT(!out.empty()); + + // HACK - this is disabled for now. This probably works, but the expression pass needs + // a way to get the decisions. + type.type = TP_Type::make_from_ts(out.front().result_type); + return; + + // see if we've tagged this instruction in a previous iteration.. + if (instr.field_access_tag) { + // we did. we should see if the tag tells us which option to pick + auto& tag = instr.field_access_tag; + if (tag->selected_possibility >= 0) { + // it does! + // there's a chance that we are a different deref than last time, so do our best to + // find a matching type. + auto& desired_type = tag->possibilities.at(tag->selected_possibility).type; + for (auto& sel : out) { + if (sel.result_type == desired_type) { + // found one, take it. + type.type = TP_Type::make_from_ts(desired_type); + return; + } + } + // the previously selected type is gone... not sure what we can do here, but complain and + // use the first one (highest scored). + fmt::print("type2_from_ambiguous_deref: wanted type {}, but couldn't find it.\n", + desired_type.print()); + type.type = TP_Type::make_from_ts(out.front().result_type); + return; + } else { + // we've got a tag, but no info, just pick the first. + type.type = TP_Type::make_from_ts(out.front().result_type); + return; + } + } else { + // no tag, let's create one! + if (!tag_lock) { // but only if we're in the first pass. + instr.field_access_tag = std::make_unique(); + auto& tag = instr.field_access_tag; + for (auto& poss : out) { + auto& slot = tag->possibilities.emplace_back(); + slot.type = poss.result_type; + } + type.tag.kind = types2::Tag::FIELD_ACCESS; + type.tag.field_access = tag.get(); + } else { + // don't think this should be possible + lg::warn("Tag lock prevented the creation of a tag in types2_from_ambiguous_deref"); + } + type.type = TP_Type::make_from_ts(out.front().result_type); + return; + } +} + +// Note that there are "get_type" and "types2" functions that look somewhat similar. +// the difference is that "get_type" just tries to figure out a TP_Type, and the "types2" function +// will set up/resolve tags, and they are intended to be used to update the type state with their +// result. + +/*! + * Try to figure the type of a label. + * Note: for array labels, we just return a "label_addr" type. The purpose of this is to allow + * far label loads and array accesses to pass through. This might cause the backprop to work + * slightly worse on array labels, but I think we can add some extra info if that comes up. + */ +std::optional try_get_type_of_label(int label_idx, const Env& env) { + const auto& label_db_lookup = env.file->label_db->lookup(label_idx); + if (label_db_lookup.known) { + if (label_db_lookup.result_type.base_type() == "string") { + // strings have a special case to count format arguments, so calls to format can figure + // out their argument count. + return TP_Type::make_from_string(env.file->get_goal_string_by_label(label_idx)); + } + + if (label_db_lookup.is_value) { + // accessing a static array is handled later, and we just make this a placeholder. + // this is to help with far labels. + return TP_Type::make_label_addr(label_idx); + } else { + return TP_Type::make_from_ts(label_db_lookup.result_type); + } + } + + return {}; +} + +/*! + * Try to figure out the type of the value in a symbol with the given name. + */ +std::optional try_get_type_symbol_val(const std::string& name, + const DecompilerTypeSystem& dts, + const Env& env) { + if (name == "#f") { + // if we ever read the false symbol, it should contain the false symbol as its value. + return TP_Type::make_false(); + } else if (name == "__START-OF-TABLE__") { + // another annoying special case. We have a fake symbol called __START-OF-TABLE__ + // which actually means that you get the first address in the symbol table. + // it's not really a linked symbol, but the basic op builder represents it as one. + return TP_Type::make_from_ts(TypeSpec("pointer")); + } else if (name == "enter-state") { + return TP_Type::make_enter_state(); + } else if (name == "run-function-in-process") { + return TP_Type::make_run_function_in_process_function(); + } else if (name == "set-to-run" && env.func->name() != "enter-state") { + return TP_Type::make_set_to_run_function(); + } + + // look up the type of the symbol + auto type = dts.symbol_types.find(name); + if (type == dts.symbol_types.end()) { + // we don't know it, failed. + return {}; + } + + if (type->second == TypeSpec("type")) { + // if we get a type by symbol, we should remember which type we got it from. + return TP_Type::make_type_no_virtual_object(TypeSpec(name)); + } + + if (type->second == TypeSpec("function")) { + // warn if we're accessing a function, but we don't know a more specific type. + // 99% of the time, we're about to call the function, and this will give the user + // a more specific error message that contains the symbol the name. + lg::warn("Function {} has unknown type", name); + } + + // otherwise, just return a normal typespec + return TP_Type::make_from_ts(type->second); +} + +/*! + * Get the type of a symbol, throw if we don't know it. + */ +TP_Type get_type_symbol_val(const std::string& name, + const DecompilerTypeSystem& dts, + const Env& env) { + auto result = try_get_type_symbol_val(name, dts, env); + if (!result) { + throw std::runtime_error(fmt::format("Unknown symbol: {}", name)); + } else { + return *result; + } +} + +/*! + * Get the type of a symbol pointer. Always succeeds + */ +TP_Type get_type_symbol_ptr(const std::string& name) { + // usually just symbol, but we have a special case for #f + if (name == "#f") { + return TP_Type::make_false(); + } else { + return TP_Type::make_from_ts("symbol"); + } +} + +/*! + * Try to figure out the type of an atom. + */ +std::optional try_get_type_of_atom(const types2::TypeState& type_state, + const SimpleAtom& atom, + const Env& env, + const DecompilerTypeSystem& dts) { + switch (atom.get_kind()) { + case SimpleAtom::Kind::VARIABLE: { + return type_state[atom.var().reg()]->type; + } + case SimpleAtom::Kind::SYMBOL_VAL: + return try_get_type_symbol_val(atom.get_str(), dts, env); + case SimpleAtom::Kind::INTEGER_CONSTANT: { + return TP_Type::make_from_integer(atom.get_int()); + } break; + default: + ASSERT_MSG(false, + fmt::format("unknown kind in try_get_type_of_atom: {}", atom.to_string(env))); + } +} + +/*! + * Try to figure out the type of an expression. Can return 0, 1, or multiple. + * If there are multiple, the first one will be the "best". + */ +std::vector try_get_type_of_expr(const types2::TypeState& type_state, + const SimpleExpression& expr, + const Env& env, + const DecompilerTypeSystem& dts) { + switch (expr.kind()) { + case SimpleExpression::Kind::IDENTITY: { + auto atom_type = try_get_type_of_atom(type_state, expr.get_arg(0), env, dts); + if (atom_type) { + return {*atom_type}; + } else { + return {}; + } + } + case SimpleExpression::Kind::ADD: + return {}; // temp, todo something better here. + + default: + ASSERT_MSG(false, fmt::format("unknown kind in try_get_type_of_expr: {} {}", + expr.to_string(env), (int)expr.kind())); + } +} + +namespace types2 { +/*! + * Given a tagged type, and an expectation for what it should be, backprop constraints. + */ +bool backprop_tagged_type(const TP_Type& expected_type, + types2::Type& actual_type, + const DecompilerTypeSystem& dts) { + switch (actual_type.tag.kind) { + case types2::Tag::NONE: + return false; + case types2::Tag::INT_OR_FLOAT: { + auto type = expected_type.typespec(); + // only update if we're actually changing something. + if (type.base_type() == "float" && + (!actual_type.tag.int_or_float->is_float || + actual_type.tag.int_or_float->is_float.value() == false)) { + actual_type.tag.int_or_float->is_float = true; + actual_type.type = TP_Type::make_from_ts("float"); + return true; + } + return false; + } + + case types2::Tag::BLOCK_ENTRY: + // don't update if we're updating to exactly the same thing. + if (actual_type.tag.block_entry->selected_type && + actual_type.tag.block_entry->selected_type == expected_type) { + return false; + } + { + actual_type.tag.block_entry->updated = true; + actual_type.tag.block_entry->selected_type = expected_type; + return true; + } + + case types2::Tag::UNKNOWN_LABEL: + if (actual_type.tag.unknown_label->selected_type && + actual_type.tag.unknown_label->selected_type == expected_type.typespec()) { + return false; // no need to update + } else { + auto& tag = actual_type.tag.unknown_label; + actual_type.tag.unknown_label->selected_type = expected_type.typespec(); + fmt::print("Label Guess: {} is a {}\n", tag->label_name, + actual_type.tag.unknown_label->selected_type->print()); + return true; + } + + case types2::Tag::UNKNOWN_STACK_STRUCTURE: + if (actual_type.tag.unknown_stack_structure->selected_type && + actual_type.tag.unknown_stack_structure->selected_type == expected_type.typespec()) { + return false; // no need to update + } else { + auto& tag = actual_type.tag.unknown_stack_structure; + actual_type.tag.unknown_stack_structure->selected_type = expected_type.typespec(); + fmt::print("Stack Guess: {} is a {}\n", tag->stack_offset, + actual_type.tag.unknown_stack_structure->selected_type->print()); + return true; + } + + case types2::Tag::FIELD_ACCESS: { + ASSERT(false); // this code works, but the later stuff can't get use it yet. + auto* tag = actual_type.tag.field_access; + bool needs_redo = false; + auto expected_typespec = expected_type.typespec(); + if (tag->selected_possibility >= 0) { + if (!dts.ts.tc(expected_typespec, tag->possibilities.at(tag->selected_possibility).type)) { + // we picked something, but it no longer matches this constraint... + needs_redo = true; + } + } + if (tag->selected_possibility < 0) { + needs_redo = true; + } + if (needs_redo) { + int best_idx = 0; // if nothing else matches, use 0. + for (size_t ci = 0; ci < tag->possibilities.size(); ci++) { + if (dts.ts.tc(expected_typespec, tag->possibilities.at(ci).type)) { + // match! + best_idx = ci; // first is highest scored, so don't bother with the rest. + break; + } + } + + if (best_idx != tag->selected_possibility) { + tag->selected_possibility = best_idx; + return true; + } else { + // failed again, in the same way, no need to update (it'll become a cast...) + return false; + } + } else { + return false; // no need to update + } + + } break; + + default: + ASSERT_MSG(false, fmt::format("unhandled tag: {}\n", (int)actual_type.tag.kind)); + } +} +} // namespace types2 + +/*! + * Update a type state so the given type_out has the type for the specified label. + * If the label is unknown, this will set up a tag. But that's not implemented yet... + */ +void types2_for_label(types2::Type& type_out, + types2::Instruction& instr, + int label_idx, + const Env& env, + const types2::TypePropExtras& extras) { + // first, see if the label type is known (either through obvious auto-detect, or a cast) + + auto known_type = try_get_type_of_label(label_idx, env); + if (known_type) { + type_out.type = known_type; + return; + } else { + if (instr.unknown_label_tag) { + auto& tag = instr.unknown_label_tag; + if (tag->selected_type) { + // resolved tag, use that + type_out.type = TP_Type::make_from_ts(*tag->selected_type); + return; + } else { + // unresolved tag, do nothing and hope for the best. + type_out.type = {}; + return; + } + } else { + // no tag. + if (extras.tags_locked) { + // this really shouldn't happen. + throw std::runtime_error(fmt::format("Encountered unknown label {}, but tags were locked.", + env.file->labels.at(label_idx).name)); + } else { + auto& name = env.file->labels.at(label_idx).name; + fmt::print("Encountered unknown label: {}\n", name); + instr.unknown_label_tag = std::make_unique(); + instr.unknown_label_tag->label_idx = label_idx; + instr.unknown_label_tag->label_name = name; + type_out.tag.unknown_label = instr.unknown_label_tag.get(); + type_out.tag.kind = types2::Tag::UNKNOWN_LABEL; + type_out.type = {}; + return; + } + } + } +} + +bool common_int2_case(types2::Type& type_out, + const DecompilerTypeSystem& dts, + TP_Type& arg0_type, + TP_Type& arg1_type) { + if (arg0_type == arg1_type && is_int_or_uint(dts, arg0_type)) { + // both are the same type and both are int/uint, so we assume that we're doing integer math. + // we strip off any weird things like multiplication or integer constant. + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return true; + } + + if (is_int_or_uint(dts, arg0_type) && is_int_or_uint(dts, arg1_type)) { + // usually we would want to use arg0's type as the "winning" type. + // but we use arg1's if arg0 is an integer constant + // in either case, strip off weird stuff. + if (arg0_type.is_integer_constant() && !arg1_type.is_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return true; + } + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return true; + } + + return false; +} + +/*! + * Update a type state so the given type_out has the type for the result of a right shift. + */ +void types2_for_right_shift(types2::Type& type_out, + const SimpleExpression& expr, + bool is_unsigned, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + // bitfield access, with a single shift + + if (expr.get_arg(1).is_int()) { + auto bf = dynamic_cast(dts.ts.lookup_type(arg0_type.typespec())); + // skip time-frame: we're probably doing math and we know it has no fields in it. + // note: we could be a bit more robust with this detection... + if (bf && arg0_type.typespec() != TypeSpec("time-frame")) { + int shift_size = 64; + int size = shift_size - expr.get_arg(1).get_int(); + int start_bit = shift_size - size; + auto field = find_field(dts.ts, bf, start_bit, size, is_unsigned); + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(field.type())); + return; + } + } + + if (arg0_type.kind == TP_Type::Kind::LEFT_SHIFTED_BITFIELD && expr.get_arg(1).is_int()) { + // second op in left/right shift combo + int end_bit = 64 - arg0_type.get_left_shift(); + if (arg0_type.pcpyud()) { + end_bit += 64; + } + + int size = 64 - expr.get_arg(1).get_int(); + int start_bit = end_bit - size; + if (start_bit < 0) { + throw std::runtime_error("Bad bitfield start bit"); + } + + auto type = dts.ts.lookup_type(arg0_type.get_bitfield_type()); + auto as_bitfield = dynamic_cast(type); + ASSERT(as_bitfield); + auto field = find_field(dts.ts, as_bitfield, start_bit, size, is_unsigned); + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(field.type())); + return; + } + + if (is_signed(dts, arg0_type)) { + type_out.type = TP_Type::make_from_ts("int"); + } else { + type_out.type = TP_Type::make_from_ts("uint"); + } + + // common_int2_case(type_out, dts, arg0_type, arg1_type); +} + +void types2_for_left_shift(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type) { + // fail! + type_out.type = {}; + return; + } + + // multiplication by constant power of two, optimized to a shift. + if (expr.get_arg(1).is_int() && is_int_or_uint(dts, *arg0_type)) { + ASSERT(expr.get_arg(1).get_int() >= 0); + ASSERT(expr.get_arg(1).get_int() < 64); + // this could be a bitfield access or a multiply. + // we pick bitfield access if the parent is a bitfield. + if (dynamic_cast(dts.ts.lookup_type(arg0_type->typespec()))) { + type_out.type = TP_Type::make_from_left_shift_bitfield(arg0_type->typespec(), + expr.get_arg(1).get_int(), false); + return; + } else if (arg0_type->kind == TP_Type::Kind::PCPYUD_BITFIELD) { + type_out.type = TP_Type::make_from_left_shift_bitfield(arg0_type->get_bitfield_type(), + expr.get_arg(1).get_int(), true); + return; + } else { + type_out.type = + TP_Type::make_from_product(1ull << expr.get_arg(1).get_int(), is_signed(dts, *arg0_type)); + return; + } + } + + if (expr.get_arg(1).is_int() && dts.ts.tc(TypeSpec("pointer"), arg0_type->typespec())) { + // allow shifting a pointer to put it in a bitfield. + type_out.type = TP_Type::make_from_ts(TypeSpec("uint")); + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg1_type = *arg1_type_info; + + if (arg0_type == arg1_type && is_int_or_uint(dts, *arg0_type)) { + // both are the same type and both are int/uint, so we assume that we're doing integer math. + // we strip off any weird things like multiplication or integer constant. + type_out.type = TP_Type::make_from_ts(arg0_type->typespec()); + return; + } + + if (is_int_or_uint(dts, *arg0_type) && is_int_or_uint(dts, arg1_type)) { + // usually we would want to use arg0's type as the "winning" type. + // but we use arg1's if arg0 is an integer constant + // in either case, strip off weird stuff. + if (arg0_type->is_integer_constant() && !arg1_type.is_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return; + } + type_out.type = TP_Type::make_from_ts(arg0_type->typespec()); + return; + } + + // last fallback + type_out.type = TP_Type::make_from_ts("int"); +} + +void types2_for_int_constant(types2::Type& type_out, + types2::Instruction& output_instr, + SimpleAtom& atom, + bool tag_lock) { + if (output_instr.int_or_float) { + auto& tag = output_instr.int_or_float; + if (tag->is_float.has_value()) { + bool is_float = tag->is_float.value(); + if (is_float) { + atom.mark_as_float(); + type_out.type = TP_Type::make_from_ts("float"); + return; + } else { + type_out.type = TP_Type::make_from_integer(atom.get_int()); + return; + } + } else { + // don't know, just guess int + type_out.type = TP_Type::make_from_integer(atom.get_int()); + return; + } + } else { + // no tag, add one and guess int. + if (!tag_lock) { + output_instr.int_or_float = std::make_unique(); + auto& tag = output_instr.int_or_float; + + type_out.tag.kind = types2::Tag::INT_OR_FLOAT; + type_out.tag.int_or_float = tag.get(); + } else { + // this one really shouldn't be possible... + lg::warn("Tag lock prevented tag creation in types2_for_int_constant"); + } + + type_out.type = TP_Type::make_from_integer(atom.get_int()); + + return; + } +} + +void types2_for_atom(types2::Type& type_out, + types2::Instruction& output_instr, + types2::TypeState& input_types, + SimpleAtom& atom, + const Env& env, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + switch (atom.get_kind()) { + case SimpleAtom::Kind::STATIC_ADDRESS: + types2_for_label(type_out, output_instr, atom.label(), env, extras); + return; + case SimpleAtom::Kind::SYMBOL_VAL: { + auto type = get_type_symbol_val(atom.get_str(), dts, env); + type_out.type = type; + } break; + case SimpleAtom::Kind::SYMBOL_PTR: { + auto type = get_type_symbol_ptr(atom.get_str()); + type_out.type = type; + } break; + case SimpleAtom::Kind::INTEGER_CONSTANT: { + // auto type = TP_Type::make_from_integer(atom.get_int()); + // type_out.type = type; + types2_for_int_constant(type_out, output_instr, atom, extras.tags_locked); + } break; + case SimpleAtom::Kind::EMPTY_LIST: { + auto type = TP_Type::make_from_ts("pair"); + type_out.type = type; + } break; + case SimpleAtom::Kind::VARIABLE: { + auto& in = input_types[atom.var().reg()]; + type_out.type = in->type; + // not 100% sure how this should work... + type_out.tag = in->tag; + } break; + default: + ASSERT_MSG(false, fmt::format("Unhandled types2_for_atom: {}\n", atom.to_string(env))); + } +} + +void types2_for_fpr_to_gpr(types2::Type& type_out, + types2::Instruction& output_instr, + SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // for now, we'll just copy the type. + types2_for_atom(type_out, output_instr, input_types, expr.get_arg(0), env, dts, extras); +} + +void types2_for_gpr_to_fpr(types2::Type& type_out, + types2::Instruction& output_instr, + SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // for now, we'll just copy the type. + types2_for_atom(type_out, output_instr, input_types, expr.get_arg(0), env, dts, extras); +} + +void types2_for_integer_mul(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + bool is_unsigned) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (arg0_type.is_integer_constant() && is_int_or_uint(dts, arg1_type)) { + type_out.type = + TP_Type::make_from_product(arg0_type.get_integer_constant(), is_signed(dts, arg0_type)); + return; + } else if (is_int_or_uint(dts, arg0_type) && is_int_or_uint(dts, arg1_type)) { + // signed multiply will always return a signed number. + type_out.type = TP_Type::make_from_ts(is_unsigned ? "uint" : "int"); + return; + } + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } + + throw std::runtime_error( + fmt::format("Couldn't figure out integer multiplication: {} ({} and {})\n", + expr.to_string(env), arg0_type.print(), arg1_type.print())); +} + +void types2_for_logior(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (arg0_type.kind == TP_Type::Kind::PCPYUD_BITFIELD) { + // anding a bitfield should return the bitfield type. + type_out.type = TP_Type::make_from_pcpyud_bitfield(arg0_type.get_bitfield_type()); + return; + } + + if (arg0_type.typespec() == TypeSpec("float") && arg1_type.typespec() == TypeSpec("float")) { + env.func->warnings.warning("Using logior on floats"); + // returning int instead of uint because they like to use the float sign bit as an integer sign + // bit. + type_out.type = TP_Type::make_from_ts(TypeSpec("float")); + return; + } + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } + throw std::runtime_error(fmt::format("Couldn't figure out logior: {} ({} and {})\n", + expr.to_string(env), arg0_type.print(), arg1_type.print())); +} + +void types2_for_logand(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (arg0_type.kind == TP_Type::Kind::PCPYUD_BITFIELD) { + // anding a bitfield should return the bitfield type. + type_out.type = TP_Type::make_from_pcpyud_bitfield(arg0_type.get_bitfield_type()); + return; + } + + if (arg0_type == arg1_type && is_int_or_uint(dts, arg0_type)) { + // both are the same type and both are int/uint, so we assume that we're doing integer math. + // we strip off any weird things like multiplication or integer constant. + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (is_int_or_uint(dts, arg0_type) && is_int_or_uint(dts, arg1_type)) { + // usually we would want to use arg0's type as the "winning" type. + // but we use arg1's if arg0 is an integer constant + // in either case, strip off weird stuff. + if (arg0_type.is_integer_constant() && !arg1_type.is_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return; + } + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (arg0_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg1_type)) { + // pointer logand integer = pointer + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } else if (arg1_type.typespec().base_type() == "pointer" && + tc(dts, TypeSpec("integer"), arg0_type)) { + // integer logand pointer = pointer + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return; + } + // base case for and. Just get an integer. + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); +} + +void types2_for_normal_int2(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } +} + +void types2_for_div_mod_signed(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (is_int_or_uint(dts, arg0_type) && is_int_or_uint(dts, arg1_type)) { + // signed division will always return a signed number. + type_out.type = TP_Type::make_from_ts("int"); + return; + } + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } + + throw std::runtime_error(fmt::format("Couldn't figure out integer mod/divide: {} ({} and {})\n", + expr.to_string(env), arg0_type.print(), arg1_type.print())); +} + +void types2_for_pcpyld(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (arg0_type.kind == TP_Type::Kind::PCPYUD_BITFIELD) { + type_out.type = arg1_type; + return; + } + + type_out.type = TP_Type::make_from_ts("uint"); +} + +void types2_for_sub(types2::Type& type_out, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + + if (arg0_type == arg1_type && is_int_or_uint(dts, arg0_type)) { + // both are the same type and both are int/uint, so we assume that we're doing integer math. + // we strip off any weird things like multiplication or integer constant. + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (is_int_or_uint(dts, arg0_type) && is_int_or_uint(dts, arg1_type)) { + // usually we would want to use arg0's type as the "winning" type. + // but we use arg1's if arg0 is an integer constant + // in either case, strip off weird stuff. + if (arg0_type.is_integer_constant() && !arg1_type.is_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return; + } + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (arg0_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg1_type)) { + // plain pointer plus integer = plain pointer + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (arg1_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg0_type)) { + // plain pointer plus integer = plain pointer + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (tc(dts, TypeSpec("structure"), arg0_type) && arg1_type.is_integer_constant()) { + auto type_info = dts.ts.lookup_type(arg0_type.typespec()); + + // get next in memory, allow this as &+/&- + if ((s64)type_info->get_size_in_memory() == std::abs((s64)arg1_type.get_integer_constant())) { + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + // also allow it, if 16-byte aligned stride. + if ((u64)align16(type_info->get_size_in_memory()) == arg1_type.get_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + } + + if (tc(dts, TypeSpec("pointer"), arg0_type) && tc(dts, TypeSpec("pointer"), arg1_type)) { + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); + return; + } + + if (tc(dts, TypeSpec("structure"), arg1_type) && !expr.get_arg(0).is_int() && + is_int_or_uint(dts, arg0_type)) { + // byte access of offset array field trick. + // arg1 holds a structure. + // arg0 is an integer in a register. + type_out.type = TP_Type::make_object_plus_product(arg1_type.typespec(), 1, true); + return; + } + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } + throw std::runtime_error(fmt::format("Couldn't figure out integer subtract: {} ({} and {})\n", + expr.to_string(env), arg0_type.print(), arg1_type.print())); +} + +void types2_addr_on_stack(types2::Type& type_out, + types2::Instruction& instr, + int offset, + const Env& env, + const DecompilerTypeSystem& dts, + const types2::TypeState& types, + bool tag_lock) { + (void)dts; + + // first look for a stack structure + for (auto& structure : env.stack_structure_hints()) { + if (offset < structure.hint.stack_offset || + offset >= (structure.hint.stack_offset + structure.size)) { + continue; // reject, it isn't in this variable + } + + if (offset == structure.hint.stack_offset) { + // special case just getting the variable + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(structure.ref_type)); + return; + } + } + + // look for a stack variable + auto sss = types.try_find_stack_spill_slot(offset); + if (sss && sss->type) { + type_out.type = TP_Type::make_from_ts(TypeSpec("pointer", {sss->type->typespec()})); + return; + } + + // Neither matched... see if there's a tag. + if (instr.unknown_stack_structure_tag) { + auto& tag = instr.unknown_stack_structure_tag; + if (tag->selected_type) { + // use the resolved tag! + type_out.type = TP_Type::make_from_ts(*tag->selected_type); + return; + } else { + // unresolved tag, do nothing and hope for the best. + type_out.type = {}; + return; + } + } else { + // no tag. can we create one? + if (tag_lock) { + // nope. + throw std::runtime_error( + fmt::format("Failed to find a stack variable or structure at offset {}", offset)); + } else { + fmt::print("Encountered unknown stack address {} : {}\n", env.func->name(), offset); + instr.unknown_stack_structure_tag = std::make_unique(); + instr.unknown_stack_structure_tag->stack_offset = offset; + type_out.tag.unknown_stack_structure = instr.unknown_stack_structure_tag.get(); + type_out.tag.kind = types2::Tag::UNKNOWN_STACK_STRUCTURE; + type_out.type = {}; + return; + } + } +} + +void types2_for_add(types2::Type& type_out, + types2::Instruction& output_instr, + const SimpleExpression& expr, + const Env& env, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + auto arg0_type_info = try_get_type_of_atom(input_types, expr.get_arg(0), env, dts); + if (!arg0_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto arg1_type_info = try_get_type_of_atom(input_types, expr.get_arg(1), env, dts); + if (!arg1_type_info) { + // fail! + type_out.type = {}; + return; + } + + auto& arg0_type = *arg0_type_info; + auto& arg1_type = *arg1_type_info; + auto& arg0 = expr.get_arg(0); + auto& arg1 = expr.get_arg(1); + + // the approach here is just to try a bunch of things. + // this is a bit of a mess, but I don't know another way. Add is a very useful instruction. + + // access the stack - either a stack variable or structure. + if (arg0.is_var() && arg0.var().reg() == Register(Reg::GPR, Reg::SP) && arg1.is_int()) { + // get_stack_type_at_constant_offset(arg1.get_int(), env, dts, input); + types2_addr_on_stack(type_out, output_instr, arg1.get_int(), env, dts, input_types, + extras.tags_locked); + return; + } + + // if things go wrong, and we add a pointer to another address, just return int + // honestly not sure why I have this one... let's have it abort for now. + if (arg0_type.kind == TP_Type::Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT && + arg1_type.typespec().base_type() == "pointer") { + ASSERT(false); + // return TP_Type::make_from_ts(TypeSpec("int")); + } + + // special case: dynamic access to the method table, to look up a method by ID. + if (arg0_type.is_product_with(4) && tc(dts, TypeSpec("type"), arg1_type) && + env.func->name() != "overrides-parent-method?" // hack! + ) { + // dynamic access into the method array with shift, add, offset-load + // no need to track the type because we don't know the method index anyway. + type_out.type = TP_Type::make_partial_dyanmic_vtable_access(); + return; + } + + // propagate integer math: a * C1 + C2 + if (arg1_type.is_integer_constant() && arg0_type.kind == TP_Type::Kind::PRODUCT_WITH_CONSTANT) { + type_out.type = TP_Type::make_from_integer_constant_plus_product( + arg1_type.get_integer_constant(), arg0_type.typespec(), arg0_type.get_multiplier()); + return; + } + + // propagate integer math: a + C1 + if (arg1_type.is_integer_constant() && is_int_or_uint(dts, arg0_type)) { + type_out.type = TP_Type::make_from_integer_constant_plus_var(arg1_type.get_integer_constant(), + arg0_type.typespec()); + return; + } + + // get addr of field using obj + C1 + a * C2 + if (arg0_type.kind == TP_Type::Kind::INTEGER_CONSTANT_PLUS_VAR_MULT) { + FieldReverseLookupInput rd_in; + rd_in.offset = arg0_type.get_add_int_constant(); + rd_in.stride = arg0_type.get_mult_int_constant(); + rd_in.base_type = arg1_type.typespec(); + auto out = env.dts->ts.reverse_field_multi_lookup(rd_in); + if (out.success) { + if (out.results.size() == 1) { + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(out.results.front().result_type)); + return; + } else { + types2_from_ambiguous_deref(output_instr, type_out, out.results, extras.tags_locked); + return; + } + } + // flipped version of the above + } else if (arg1_type.kind == TP_Type::Kind::INTEGER_CONSTANT_PLUS_VAR_MULT) { + FieldReverseLookupInput rd_in; + rd_in.offset = arg1_type.get_add_int_constant(); + rd_in.stride = arg1_type.get_mult_int_constant(); + rd_in.base_type = arg0_type.typespec(); + auto out = env.dts->ts.reverse_field_multi_lookup(rd_in); + if (out.success) { + if (out.results.size() == 1) { + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(out.results.front().result_type)); + return; + } else { + types2_from_ambiguous_deref(output_instr, type_out, out.results, extras.tags_locked); + return; + } + } + } + + // get addr of field using obj + C1 + a (effectively a stride of 1) + if (arg0_type.kind == TP_Type::Kind::INTEGER_CONSTANT_PLUS_VAR) { + FieldReverseLookupInput rd_in; + rd_in.offset = arg0_type.get_integer_constant(); + rd_in.stride = 1; + rd_in.base_type = arg1_type.typespec(); + auto out = env.dts->ts.reverse_field_multi_lookup(rd_in); + if (out.success) { + if (out.results.size() == 1) { + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(out.results.front().result_type)); + return; + } else { + types2_from_ambiguous_deref(output_instr, type_out, out.results, extras.tags_locked); + return; + } + } + } + + if (common_int2_case(type_out, dts, arg0_type, arg1_type)) { + return; + } + + // get addr of field with a constant: obj + C1 + if (arg1.is_int() && arg0_type.kind == TP_Type::Kind::TYPESPEC) { + // access a field. + FieldReverseLookupInput rd_in; + rd_in.deref = std::nullopt; + rd_in.stride = 0; + rd_in.offset = arg1.get_int(); + rd_in.base_type = arg0_type.typespec(); + auto out = env.dts->ts.reverse_field_multi_lookup(rd_in); + if (out.success) { + if (out.results.size() == 1) { + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(out.results.front().result_type)); + return; + } else { + types2_from_ambiguous_deref(output_instr, type_out, out.results, extras.tags_locked); + return; + } + } + } + + // access with just product and no offset. + if (arg0_type.kind == TP_Type::Kind::TYPESPEC && + arg0_type.typespec().base_type() == "inline-array" && + arg1_type.kind == TP_Type::Kind::PRODUCT_WITH_CONSTANT) { + FieldReverseLookupInput rd_in; + rd_in.deref = std::nullopt; + rd_in.stride = arg1_type.get_multiplier(); + rd_in.offset = 0; + rd_in.base_type = arg0_type.typespec(); + auto rd = dts.ts.reverse_field_multi_lookup(rd_in); + + std::vector filtered_results; + for (auto& result : rd.results) { + if (result.has_variable_token()) { + filtered_results.push_back(result); + } + } + + if (filtered_results.size() == 1) { + type_out.type = + TP_Type::make_from_ts(coerce_to_reg_type(filtered_results.front().result_type)); + return; + } else { + types2_from_ambiguous_deref(output_instr, type_out, filtered_results, extras.tags_locked); + return; + } + } + + // flipped of above + if (arg1_type.kind == TP_Type::Kind::TYPESPEC && + arg1_type.typespec().base_type() == "inline-array" && + arg0_type.kind == TP_Type::Kind::PRODUCT_WITH_CONSTANT) { + FieldReverseLookupInput rd_in; + rd_in.deref = std::nullopt; + rd_in.stride = arg0_type.get_multiplier(); + rd_in.offset = 0; + rd_in.base_type = arg1_type.typespec(); + auto rd = dts.ts.reverse_field_multi_lookup(rd_in); + std::vector filtered_results; + for (auto& result : rd.results) { + if (result.has_variable_token()) { + filtered_results.push_back(result); + } + } + + if (filtered_results.size() == 1) { + type_out.type = + TP_Type::make_from_ts(coerce_to_reg_type(filtered_results.front().result_type)); + return; + } else { + ASSERT(false); + } + } + + if (arg0_type.is_product() && arg1_type.kind == TP_Type::Kind::TYPESPEC) { + type_out.type = + TP_Type::make_object_plus_product(arg1_type.typespec(), arg0_type.get_multiplier(), true); + return; + } + + if (arg1_type.is_product() && arg0_type.kind == TP_Type::Kind::TYPESPEC) { + type_out.type = + TP_Type::make_object_plus_product(arg0_type.typespec(), arg1_type.get_multiplier(), false); + return; + } + + if (arg0_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg1_type)) { + if (!arg1.is_int()) { + type_out.type = TP_Type::make_object_plus_product(arg0_type.typespec(), 1, false); + return; + } + // plain pointer plus integer = plain pointer + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + if (arg1_type.typespec().base_type() == "pointer" && tc(dts, TypeSpec("integer"), arg0_type)) { + // plain pointer plus integer = plain pointer + type_out.type = TP_Type::make_from_ts(arg1_type.typespec()); + return; + } + + if (tc(dts, TypeSpec("structure"), arg0_type) && arg1_type.is_integer_constant()) { + auto type_info = dts.ts.lookup_type(arg0_type.typespec()); + + // get next in memory, allow this as &+/&- + if ((s64)type_info->get_size_in_memory() == std::abs((s64)arg1_type.get_integer_constant())) { + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + + // also allow it, if 16-byte aligned stride. + if ((u64)align16(type_info->get_size_in_memory()) == arg1_type.get_integer_constant()) { + type_out.type = TP_Type::make_from_ts(arg0_type.typespec()); + return; + } + } + + if (tc(dts, TypeSpec("pointer"), arg0_type) && tc(dts, TypeSpec("pointer"), arg1_type)) { + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); + return; + } + + auto& name = env.func->guessed_name; + if (name.kind == FunctionName::FunctionKind::METHOD && name.method_id == 7 && + env.func->type.arg_count() == 3) { + if (arg1_type.typespec() == TypeSpec("int")) { + type_out.type = arg0_type; + return; + } + } + + if (tc(dts, TypeSpec("structure"), arg1_type) && !expr.get_arg(0).is_int() && + is_int_or_uint(dts, arg0_type)) { + if (arg1_type.typespec() == TypeSpec("symbol") && + arg0_type.is_integer_constant(DECOMP_SYM_INFO_OFFSET + POINTER_SIZE)) { + // symbol -> GOAL String + // NOTE - the offset doesn't fit in a s16, so it's loaded into a register first. + // so we expect the arg to be a variable, and the type propagation will figure out the + // integer constant. + type_out.type = TP_Type::make_from_ts(dts.ts.make_pointer_typespec("string")); + return; + } else { + // byte access of offset array field trick. + // arg1 holds a structure. + // arg0 is an integer in a register. + type_out.type = TP_Type::make_object_plus_product(arg1_type.typespec(), 1, true); + return; + } + } + + if (env.version == GameVersion::Jak2 && tc(dts, TypeSpec("symbol"), arg1_type) && + is_int_or_uint(dts, arg0_type)) { + if (arg0_type.is_integer_constant(jak2::SYM_TO_STRING_OFFSET)) { + // symbol -> GOAL String + // NOTE - the offset doesn't fit in a s16, so it's loaded into a register first. + // so we expect the arg to be a variable, and the type propagation will figure out the + // integer constant. + type_out.type = TP_Type::make_from_ts(dts.ts.make_pointer_typespec("string")); + return; + } + } + + fmt::print("checks: {} {} {}\n", tc(dts, TypeSpec("structure"), arg1_type), + !expr.get_arg(0).is_int(), is_int_or_uint(dts, arg0_type)); + + throw std::runtime_error( + fmt::format("add failed: {} {}\n", arg0_type.print(), arg1_type.print())); + // ASSERT_MSG(false, fmt::format("add failed: {} {}\n", arg0_type.print(), arg1_type.print())); +} + +void types2_for_normal_all_float(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop to make inputs floats + for (int i = 0; i < expr.args(); i++) { + auto& arg = expr.get_arg(i); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("float"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + } + + type_out.type = TP_Type::make_from_ts(TypeSpec("float")); +} + +void types2_for_vectors_in_float_out(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop to make inputs vector + for (int i = 0; i < expr.args(); i++) { + auto& arg = expr.get_arg(i); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("vector"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + } + + type_out.type = TP_Type::make_from_ts(TypeSpec("float")); +} + +void types2_for_vector_in_and_out(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop to make inputs vector + for (int i = 0; i < expr.args(); i++) { + auto& arg = expr.get_arg(i); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("vector"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + } + + type_out.type = TP_Type::make_from_ts(TypeSpec("vector")); +} + +void types2_for_vector_float_product(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop to make inputs vector + for (int i = 0; i < expr.args(); i++) { + auto& arg = expr.get_arg(i); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts(i == 0 ? "vector" : "float"), + *arg_type, dts)) { + extras.needs_rerun = true; + } + } + } + + type_out.type = TP_Type::make_from_ts(TypeSpec("vector")); +} + +void types2_for_float_to_int(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + auto& arg = expr.get_arg(0); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("float"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); +} + +void types2_for_int_to_float(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop here might be bad... + auto& arg = expr.get_arg(0); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("int"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + type_out.type = TP_Type::make_from_ts(TypeSpec("float")); +} + +void types2_for_normal_int1(types2::Type& type_out, + const SimpleExpression& expr, + types2::TypeState& input_types) { + type_out.type = {}; + auto& input_type = input_types[expr.get_arg(0).var().reg()]; + if (input_type->type) { + type_out.type = input_type->type; + } +} + +void types2_for_expr(types2::Type& type_out, + types2::Instruction& output_instr, + types2::TypeState& input_types, + SimpleExpression& expr, + const Env& env, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + switch (expr.kind()) { + case SimpleExpression::Kind::IDENTITY: + types2_for_atom(type_out, output_instr, input_types, expr.get_arg(0), env, dts, extras); + break; + case SimpleExpression::Kind::RIGHT_SHIFT_ARITH: + types2_for_right_shift(type_out, expr, false, env, input_types, dts); + break; + case SimpleExpression::Kind::RIGHT_SHIFT_LOGIC: + types2_for_right_shift(type_out, expr, true, env, input_types, dts); + break; + case SimpleExpression::Kind::LEFT_SHIFT: + types2_for_left_shift(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::FPR_TO_GPR: + types2_for_fpr_to_gpr(type_out, output_instr, expr, env, input_types, dts, extras); + break; + case SimpleExpression::Kind::ADD: + types2_for_add(type_out, output_instr, expr, env, input_types, dts, extras); + break; + case SimpleExpression::Kind::GPR_TO_FPR: + types2_for_gpr_to_fpr(type_out, output_instr, expr, env, input_types, dts, extras); + break; + case SimpleExpression::Kind::DIV_S: + case SimpleExpression::Kind::MIN_S: + case SimpleExpression::Kind::SUB_S: + case SimpleExpression::Kind::MAX_S: + case SimpleExpression::Kind::MUL_S: + case SimpleExpression::Kind::ADD_S: + case SimpleExpression::Kind::ABS_S: + case SimpleExpression::Kind::NEG_S: + case SimpleExpression::Kind::SQRT_S: + types2_for_normal_all_float(type_out, expr, input_types, dts, extras); + break; + case SimpleExpression::Kind::SUB: + types2_for_sub(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::MUL_SIGNED: + types2_for_integer_mul(type_out, expr, env, input_types, dts, false); + break; + case SimpleExpression::Kind::MUL_UNSIGNED: + types2_for_integer_mul(type_out, expr, env, input_types, dts, true); + break; + case SimpleExpression::Kind::DIV_SIGNED: + case SimpleExpression::Kind::MOD_SIGNED: + types2_for_div_mod_signed(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::NEG: + case SimpleExpression::Kind::MIN_SIGNED: + case SimpleExpression::Kind::MAX_SIGNED: + case SimpleExpression::Kind::SUBU_L32_S7: + type_out.type = TP_Type::make_from_ts("int"); // ? + break; + case SimpleExpression::Kind::OR: + types2_for_logior(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::AND: + types2_for_logand(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::NOR: + case SimpleExpression::Kind::XOR: + types2_for_normal_int2(type_out, expr, env, input_types, dts); + break; + case SimpleExpression::Kind::LOGNOT: + types2_for_normal_int1(type_out, expr, input_types); + break; + case SimpleExpression::Kind::FLOAT_TO_INT: + types2_for_float_to_int(type_out, expr, input_types, dts, extras); + break; + case SimpleExpression::Kind::INT_TO_FLOAT: + types2_for_int_to_float(type_out, expr, input_types, dts, extras); + break; + case SimpleExpression::Kind::VECTOR_3_DOT: + case SimpleExpression::Kind::VECTOR_4_DOT: + case SimpleExpression::Kind::VECTOR_LENGTH: + types2_for_vectors_in_float_out(type_out, expr, input_types, dts, extras); + break; + case SimpleExpression::Kind::VECTOR_CROSS: + case SimpleExpression::Kind::VECTOR_MINUS: + case SimpleExpression::Kind::VECTOR_PLUS: + types2_for_vector_in_and_out(type_out, expr, input_types, dts, extras); + break; + case SimpleExpression::Kind::VECTOR_FLOAT_PRODUCT: + types2_for_vector_float_product(type_out, expr, input_types, dts, extras); + case SimpleExpression::Kind::PCPYLD: + types2_for_pcpyld(type_out, expr, env, input_types, dts); + break; + default: + throw std::runtime_error( + fmt::format("Unhandled types2_for_expr: {} {}\n", expr.to_string(env), (int)expr.kind())); + } +} + +void SetVarOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // propagate types on the expression. Will also handle backprop of constraints, etc. + auto* type_out = instr.types[m_dst.reg()]; + types2_for_expr(*type_out, instr, input_types, m_src, env, dts, extras); + + // remember this. It's used later, to insert better looking casts. + if (type_out->type) { + m_source_type = type_out->type->typespec(); + } + + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } +} + +void AsmOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& /*extras*/) { + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + + auto& out = instr.types; + + if (m_instr.kind == InstructionKind::QMFC2) { + ASSERT(m_dst); + out[m_dst->reg()]->type = TP_Type::make_from_ts("float"); + // ASSERT(false); // hack... not sure float is right here... lets do more testing first. + return; + } + + // can be used for asm or bitfield. earlier passes mark it asm, we catch it in types, + // and set the tp_types. + if (m_instr.kind == InstructionKind::PCPYUD) { + if (m_src[1] && m_src[1]->reg() == Register(Reg::GPR, Reg::R0)) { + ASSERT(m_src[0]); + auto& in_type = input_types[m_src[0]->reg()]; + if (in_type->type) { + auto bf = dynamic_cast(dts.ts.lookup_type(in_type->type->typespec())); + if (bf) { + ASSERT(m_dst); + // just mark as pcpyud, it's part of a longer chain... + out[m_dst->reg()]->type = TP_Type::make_from_pcpyud_bitfield(in_type->type->typespec()); + return; + } + } + } + } + + // pextuw t0, r0, gp + if (m_instr.kind == InstructionKind::PEXTUW) { + if (m_src[0] && m_src[0]->reg() == Register(Reg::GPR, Reg::R0)) { + ASSERT(m_src[1]); + auto& in_type = input_types[m_src[1]->reg()]->type; + if (in_type) { + auto type = dts.ts.lookup_type(in_type->typespec()); + auto as_bitfield = dynamic_cast(type); + if (as_bitfield) { + auto field = find_field(dts.ts, as_bitfield, 64, 32, true); + ASSERT(m_dst); + out[m_dst->reg()]->type = TP_Type::make_from_ts(field.type()); + return; + } + } + } + } + + // sllv out, in, r0 + // this is recognized as asm (because it usually is) but it can be used in bitfields to extract + // the low 32-bits + if (m_instr.kind == InstructionKind::SLLV && + instruction().src[1].is_reg(Register(Reg::GPR, Reg::R0))) { + // check input: + auto& src_type = input_types[m_src[0]->reg()]; + if (src_type->type) { + auto type = dts.ts.lookup_type(src_type->type->typespec()); + // see if it's a bitfield type + auto as_bitfield = dynamic_cast(type); + if (as_bitfield) { + // see if we can find a field (throws if we can't) + auto field = find_field(dts.ts, as_bitfield, 0, 32, {}); + // this is a complete extraction, can set the type as the result. + out[m_dst->reg()]->type = TP_Type::make_from_ts(field.type()); + return; + } + } + } + + // srl out, bitfield, int + if (m_instr.kind == InstructionKind::SRL) { + auto& src_type = input_types[m_src[0]->reg()]; + if (src_type) { + auto type = dts.ts.lookup_type(src_type->type->typespec()); + auto as_bitfield = dynamic_cast(type); + if (as_bitfield) { + int sa = m_instr.src[1].get_imm(); + int offset = sa; + int size = 32 - offset; + auto field = find_field(dts.ts, as_bitfield, offset, size, {}); + out[m_dst->reg()]->type = TP_Type::make_from_ts(coerce_to_reg_type(field.type())); + return; + } + } + } + + // general case fallback: if we write a register we should at least set something... + if (m_dst.has_value()) { + auto kind = m_dst->reg().get_kind(); + if (kind == Reg::FPR) { + // if we set a fpr, just assume float + out[m_dst->reg()]->type = TP_Type::make_from_ts("float"); + } else if (kind == Reg::GPR) { + // if we're a gpr, and any + for (auto& x : m_src) { + if (x && x->reg().get_kind() == Reg::GPR) { + // if any sources are known to be 128-bit integers, use uint128 as the output + auto src_type = input_types[x->reg()]; + if (!src_type->type) { + continue; + } + auto src_ts = src_type->type->typespec(); + if (dts.ts.tc(TypeSpec("int128"), src_ts) || dts.ts.tc(TypeSpec("uint128"), src_ts)) { + out[m_dst->reg()]->type = TP_Type::make_from_ts("uint128"); + return; + } + } + // otherwise just use int... + out[m_dst->reg()]->type = TP_Type::make_from_ts("int"); + } + } + } +} + +void SetVarConditionOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& /*input_types*/, + DecompilerTypeSystem& /*dts*/, + types2::TypePropExtras& /*extras*/) { + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + instr.types[m_dst.reg()]->type = TP_Type::make_from_ts("symbol"); +} + +/*! + * Run type propagation on a store to memory (does not include stack spill stores) + * Normally, we don't have to do anything here, but there are 3 special cases: + * - if we're storing something in the current process next-state as part of a go, the type pass + * needs to track this, to determine the number of arguments for the updating go. + * - we can backprop type information on the value being stored + * - we can backprop type information on the location we're storing to. + */ +void StoreOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // backprop on the value being stored. + { + if (m_value.is_var()) { // only applicable if we're storing a var + auto reg = m_value.var().reg(); + if (reg.get_kind() != Reg::VF) { + const auto& value_type = input_types[m_value.var().reg()]; + if (value_type->tag.has_tag()) { // don't bother if we don't have a tag to resolve + if (m_kind == Kind::FLOAT) { + if (backprop_tagged_type(TP_Type::make_from_ts("float"), *value_type, dts)) { + extras.needs_rerun = true; + } + } else { + auto location_type = try_get_type_of_expr(input_types, m_addr, env, dts); + if (!location_type.empty()) { // need to know where we're storing + + // temp warning if we have multiple store types + if (location_type.size() > 1) { + fmt::print("StoreOp::propagate_types2: multiple possible store types: "); + for (auto& t : location_type) { + fmt::print("{} ", t.print()); + } + fmt::print("\n"); + } + + if (backprop_tagged_type(location_type.at(0), *value_type, dts)) { + extras.needs_rerun = true; + } + } + } + } + } + } + } + + // backprop on the store type + { + // TODO implement this. + // it's a little tricky if there's an offset, let's implement this as we find examples. + } + + // handle the next-state thing + // look for setting the next state of the current process + IR2_RegOffset ro; + if (get_as_reg_offset(m_addr, &ro)) { + if (ro.reg == Register(Reg::GPR, Reg::S6) && + ro.offset == OFFSET_OF_NEXT_STATE_STORE[env.version]) { + ASSERT(m_value.is_var()); + auto& store_type = input_types[m_value.var().reg()]->type; + if (store_type) { + instr.types.next_state_type->type = store_type; + } else { + instr.types.next_state_type->type = TP_Type::make_from_ts("state"); // idk + } + } + } + + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } +} + +RegClass get_reg_kind(const Register& r) { + switch (r.get_kind()) { + case Reg::GPR: + return RegClass::GPR_64; + case Reg::FPR: + return RegClass::FLOAT; + default: + ASSERT(false); + return RegClass::INVALID; + } +} + +bool load_var_op_determine_type(types2::Type& type_out, + types2::Instruction& output_instr, + types2::TypeState& input_types, + const LoadVarOp& op, + const Env& env, + const DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + if (op.src().is_identity()) { + auto& src = op.src().get_arg(0); + if (src.is_static_addr()) { + if (op.kind() == LoadVarOp::Kind::FLOAT) { + // assume anything loaded directly to floating point register is a float, and skip the + // rest. + type_out.type = TP_Type::make_from_ts("float"); + return true; + } + + auto label_name = env.file->labels.at(src.label()).name; + const auto& hint = env.file->label_db->lookup(label_name); + if (!hint.known) { + ASSERT(false); // todo + throw std::runtime_error( + fmt::format("Label {} was unknown in AtomicOpTypeAnalysis (type).", hint.name)); + } + + if (!hint.is_value) { + // this one seems fatal + throw std::runtime_error( + fmt::format("Label {} was used as a value, but wasn't marked as one", hint.name)); + } + + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(hint.result_type)); + return true; + } + } + + IR2_RegOffset ro; + if (get_as_reg_offset(op.src(), &ro)) { + auto& input_type_info = input_types[ro.reg]; + if (!input_type_info->type) { + // todo: could try some basic stuff to resolve float loads here... + // ASSERT(false); + return false; + } + auto& input_type = input_type_info->type.value(); + + // check loading a method of a known type. + // the TP_Type system will track individual types, both as a "most specific known at decompile + // time" (TYPE_OF_TYPE_OR_CHILD) or "exact" version (TYPE_OF_TYPE_NO_VIRTUAL) + if ((input_type.kind == TP_Type::Kind::TYPE_OF_TYPE_OR_CHILD || + input_type.kind == TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL) // is known type + && ro.offset >= 16 // is in the method table (16 is the offset of the first method) + && (ro.offset & 3) == 0 // is aligned + && op.size() == 4 // loading a pointer + && op.kind() == LoadVarOp::Kind::UNSIGNED // GOAL convention to load pointers as unsigned + ) { + // method get of fixed type + // here, we look up the actual type signature of the method, which depends on the type. + auto type_name = input_type.get_type_objects_typespec().base_type(); + auto method_id = (ro.offset - 16) / 4; + auto method_info = dts.ts.lookup_method(type_name, method_id); + auto method_type = method_info.type.substitute_for_method_call(type_name); + + // special case: the new method of "object" is the general heap allocation function, + // and is used in (new 'heap 'foo ... ) expressions. + // we'll use a special type for these. + if (type_name == "object" && method_id == GOAL_NEW_METHOD) { + type_out.type = TP_Type::make_object_new(method_type); + return true; + } + + // another special case: calling the new method is never done virtually. so just handle it + // without paying attention to virtual/non-virtual + if (method_id == GOAL_NEW_METHOD) { + type_out.type = TP_Type::make_from_ts(method_type); + return true; + } else if (input_type.kind == TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL) { + // normal non-virtual method access + type_out.type = + TP_Type::make_non_virtual_method(method_type, TypeSpec(type_name), method_id); + return true; + } else { + // normal virtual method access. + type_out.type = TP_Type::make_virtual_method(method_type, TypeSpec(type_name), method_id); + return true; + } + } + + // finally, we have a backup to allow some method access if we have no idea of the exact type. + // we can only do this safely for a few "built in" methods that always take the same arguments + // on all types. + if (input_type.kind == TP_Type::Kind::TYPESPEC // if we've fallen back to plain type + && input_type.typespec() == TypeSpec("type") // and we think it's a type + // and the usual load check + && ro.offset >= 16 && (ro.offset & 3) == 0 && op.size() == 4 && + op.kind() == LoadVarOp::Kind::UNSIGNED) { + // method get of an unknown type. We assume the most general "object" type because that + // will have the correct arguments for built-in methods + auto method_id = (ro.offset - 16) / 4; + // only allow up to MEMUSAGE, the last built-in method. + if (method_id <= (int)GOAL_MEMUSAGE_METHOD) { + auto method_info = dts.ts.lookup_method("object", method_id); + // also block new: you can override the arguments, and relocate: it has two uses: login and + // actual relocated, and it takes different arguments for these cases. + if (method_id != GOAL_NEW_METHOD && method_id != GOAL_RELOC_METHOD) { + // this can get us the wrong thing for `new` methods. And maybe relocate? + type_out.type = TP_Type::make_non_virtual_method( + method_info.type.substitute_for_method_call("object"), TypeSpec("object"), method_id); + return true; + } + } + } + + if (input_type.kind == TP_Type::Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT) { + FieldReverseLookupInput rd_in; + DerefKind dk; + dk.is_store = false; + dk.reg_kind = get_reg_kind(ro.reg); + dk.sign_extend = op.kind() == LoadVarOp::Kind::SIGNED; + dk.size = op.size(); + rd_in.deref = dk; + rd_in.base_type = input_type.get_obj_plus_const_mult_typespec(); + rd_in.stride = input_type.get_multiplier(); + rd_in.offset = ro.offset; + auto rd = dts.ts.reverse_field_multi_lookup(rd_in); + if (rd.success) { + if (rd.results.size() == 1) { + type_out.type = TP_Type::make_from_ts(coerce_to_reg_type(rd.results.front().result_type)); + return true; + } else { + types2_from_ambiguous_deref(output_instr, type_out, rd.results, extras.tags_locked); + return true; + } + } + } + + if (input_type.kind == TP_Type::Kind::TYPESPEC && ro.offset == -4 && + op.kind() == LoadVarOp::Kind::UNSIGNED && op.size() == 4 && ro.reg.get_kind() == Reg::GPR) { + // get type of basic likely, but misrecognized as an object. + + type_out.type = TP_Type::make_type_allow_virtual_object(input_type.typespec().base_type()); + return true; + } + + if (input_type.kind == TP_Type::Kind::DYNAMIC_METHOD_ACCESS && ro.offset == 16) { + // access method vtable. The input is type + (4 * method), and the 16 is the offset + // of method 0. + type_out.type = TP_Type::make_from_ts(TypeSpec("function")); + return true; + } + + // Assume we're accessing a field of an object. + // if we are a pair with sloppy typing, don't use this and instead use the case down below. + if (input_type.typespec() != TypeSpec("pair") || !env.allow_sloppy_pair_typing()) { + FieldReverseLookupInput rd_in; + DerefKind dk; + dk.is_store = false; + dk.reg_kind = get_reg_kind(ro.reg); + dk.sign_extend = op.kind() == LoadVarOp::Kind::SIGNED; + dk.size = op.size(); + rd_in.deref = dk; + rd_in.base_type = input_type.typespec(); + rd_in.stride = 0; + rd_in.offset = ro.offset; + auto rd = dts.ts.reverse_field_multi_lookup(rd_in); + + if (rd.success) { + if (rd.results.size() == 1) { + if (rd_in.base_type.base_type() == "state" && rd.results.front().tokens.size() == 1 && + rd.results.front().tokens.front().kind == + FieldReverseLookupOutput::Token::Kind::FIELD && + rd.results.front().tokens.front().name == "enter" && + rd_in.base_type.arg_count() > 0) { + // special case for accessing the enter field of state + type_out.type = + TP_Type::make_from_ts(state_to_go_function(rd_in.base_type, TypeSpec("none"))); + return true; + } else { + type_out.type = + TP_Type::make_from_ts(coerce_to_reg_type(rd.results.front().result_type)); + return true; + } + } else { + /* + fmt::print("ambiguous deref. Choices are:\n"); + for (auto& result : rd.results) { + fmt::print(" {} : ", result.result_type.print()); + for (auto& tok : result.tokens) { + fmt::print("{} ", tok.print()); + } + fmt::print("\n"); + } + */ + + types2_from_ambiguous_deref(output_instr, type_out, rd.results, extras.tags_locked); + return true; + } + } + } + + if (input_type.typespec() == TypeSpec("pointer") || + // this seems like a bit of a hack, but we did it in the old type pass... + input_type.kind == TP_Type::Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT) { + // we got a plain pointer. let's just assume we're loading an integer. + // perhaps we should disable this feature by default on 4-byte loads if we're getting + // lots of false positives for loading pointers from plain pointers. + + switch (op.kind()) { + case LoadVarOp::Kind::UNSIGNED: + switch (op.size()) { + case 1: + case 2: + case 4: + case 8: + type_out.type = TP_Type::make_from_ts(TypeSpec("uint")); + return true; + case 16: + type_out.type = TP_Type::make_from_ts(TypeSpec("uint128")); + return true; + default: + break; + } + break; + case LoadVarOp::Kind::SIGNED: + switch (op.size()) { + case 1: + case 2: + case 4: + case 8: + type_out.type = TP_Type::make_from_ts(TypeSpec("int")); + return true; + case 16: + type_out.type = TP_Type::make_from_ts(TypeSpec("int128")); + return true; + default: + break; + } + break; + case LoadVarOp::Kind::FLOAT: + type_out.type = TP_Type::make_from_ts(TypeSpec("float")); + return true; + default: + ASSERT(false); + } + } + + // rd failed, try as pair. + if (env.allow_sloppy_pair_typing()) { + // we are strict here - only permit pair-type loads from object or pair. + // object is permitted for stuff like association lists where the car is also a pair. + if (op.kind() == LoadVarOp::Kind::SIGNED && op.size() == 4 && + (input_type.typespec() == TypeSpec("object") || + input_type.typespec() == TypeSpec("pair"))) { + // these rules are of course not always correct or the most specific, but it's the best + // we can do. + if (ro.offset == 2) { + // cdr = another pair. + type_out.type = TP_Type::make_from_ts(TypeSpec("pair")); + return true; + } else if (ro.offset == -2) { + // car = some object. + type_out.type = TP_Type::make_from_ts(TypeSpec("object")); + return true; + } + } + } + + throw std::runtime_error(fmt::format("Could not figure out load: {}", op.to_string(env))); + } else { + throw std::runtime_error(fmt::format("Could not figure out load: {}", op.to_string(env))); + } +} + +void LoadVarOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + + if (m_dst.reg().get_kind() == Reg::VF) { + // ignore vf registers in type pass. + return; + } + + auto& type_out = instr.types[m_dst.reg()]; + load_var_op_determine_type(*type_out, instr, input_types, *this, env, dts, extras); + m_type = type_out->type ? type_out->type->typespec() : std::optional(); +} + +void branch_delay_types2(IR2_BranchDelay& delay, + types2::Instruction& instr, + types2::TypeState& input_types) { + switch (delay.kind()) { + case IR2_BranchDelay::Kind::NOP: + case IR2_BranchDelay::Kind::NO_DELAY: + break; + case IR2_BranchDelay::Kind::SET_REG_FALSE: + instr.types[delay.var(0).reg()]->type = TP_Type::make_false(); + break; + case IR2_BranchDelay::Kind::SET_REG_TRUE: + instr.types[delay.var(0).reg()]->type = TP_Type::make_from_ts("symbol"); + break; + case IR2_BranchDelay::Kind::SET_REG_REG: + instr.types[delay.var(0).reg()]->type = input_types[delay.var(1).reg()]->type; + break; + default: + ASSERT_MSG(false, fmt::format("propagate_types2 BranchOp unknown branch delay: {}", + (int)delay.kind())); + } +} + +void BranchOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + + switch (m_condition.kind()) { + case IR2_Condition::Kind::FLOAT_EQUAL: + case IR2_Condition::Kind::FLOAT_GEQ: + case IR2_Condition::Kind::FLOAT_GREATER_THAN: + case IR2_Condition::Kind::FLOAT_LEQ: + case IR2_Condition::Kind::FLOAT_LESS_THAN: + case IR2_Condition::Kind::FLOAT_NOT_EQUAL: + for (int i = 0; i < 2; i++) { + auto& arg = m_condition.src(i); + auto& arg_type = input_types[arg.var().reg()]; + if (arg_type->tag.has_tag()) { + if (types2::backprop_tagged_type(TP_Type::make_from_ts("float"), *arg_type, dts)) { + extras.needs_rerun = true; + } + } + } + break; + default: + break; + } + + branch_delay_types2(m_branch_delay, instr, input_types); +} + +void AsmBranchOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + if (m_branch_delay) { + m_branch_delay->propagate_types2(instr, env, input_types, dts, extras); + } + // for now, just make everything uint + for (auto x : m_write_regs) { + if (x.allowed_local_gpr()) { + instr.types[x]->type = TP_Type::make_from_ts("uint"); + } + } +} + +void SpecialOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& /*input_types*/, + DecompilerTypeSystem& /*dts*/, + types2::TypePropExtras& /*extras*/) { + // update clobbers. + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + switch (m_kind) { + case Kind::NOP: + case Kind::BREAK: + case Kind::CRASH: + case Kind::SUSPEND: + return; + default: + ASSERT(false); + } +} + +void CallOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& /*extras*/) { + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } + + const Reg::Gpr arg_regs[8] = {Reg::A0, Reg::A1, Reg::A2, Reg::A3, + Reg::T0, Reg::T1, Reg::T2, Reg::T3}; + auto& out_types = instr.types; + + // see what's in the function register + auto in_tp_info = input_types[Register(Reg::GPR, Reg::T9)]; + if (!in_tp_info->type) { + // no idea what's there, can't do anything... + out_types[Register(Reg::GPR, Reg::V0)]->type = {}; + return; + } + auto& in_tp = in_tp_info->type.value(); + + // special case: call object new method inside of a new method. + if (in_tp.kind == TP_Type::Kind::OBJECT_NEW_METHOD && + !dts.type_prop_settings.current_method_type.empty()) { + // calling object new method. Set the result to a new object of our type + out_types[Register(Reg::GPR, Reg::V0)]->type = + TP_Type::make_from_ts(dts.type_prop_settings.current_method_type); + // update the call type + m_call_type = in_tp.get_method_new_object_typespec(); + m_call_type.get_arg(m_call_type.arg_count() - 1) = + TypeSpec(dts.type_prop_settings.current_method_type); + m_call_type_set = true; + + // update function call info info + m_read_regs.clear(); + m_arg_vars.clear(); + m_read_regs.emplace_back(Reg::GPR, Reg::T9); + for (int i = 0; i < int(m_call_type.arg_count()) - 1; i++) { + m_read_regs.emplace_back(Reg::GPR, arg_regs[i]); + m_arg_vars.push_back(RegisterAccess(AccessMode::READ, m_read_regs.back(), m_my_idx)); + } + return; + } + + auto in_type = in_tp.typespec(); + + if (in_type.base_type() != "function") { + throw std::runtime_error("Called something that was not a function: " + in_type.print()); + } + + // backprop + bool can_backprop = true; + + // special case: go + // If we call enter-state, update our type. + if (in_tp.kind == TP_Type::Kind::ENTER_STATE_FUNCTION) { + can_backprop = false; // for now... can special case this later. + // this is a GO! + const auto& state_type = instr.types.next_state_type; + if (!state_type->type) { + throw std::runtime_error( + fmt::format("At op {}, called enter-state, but we have no idea what the type of the " + "next-states is. This can probably be fixed by providing some more casts, or " + "improving the decompiler to backtrack go's.", + m_my_idx)); + } + auto state_typespec = state_type->type->typespec(); + if (state_typespec.base_type() != "state") { + throw std::runtime_error( + fmt::format("At op {}, called enter-state, but the current next-state has type {}, which " + "is not a valid state.", + m_my_idx, state_typespec.print())); + } + + if (state_typespec.arg_count() == 0) { + throw std::runtime_error(fmt::format( + "At op {}, tried to enter-state, but the type of (-> s6 next-state) is just a plain " + "state. The decompiler must know the specific state type.", + m_my_idx)); + } + in_type = state_to_go_function(state_typespec, TypeSpec("object")); + } + + // special case: process initialization + if (in_tp.kind == TP_Type::Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION || + in_tp.kind == TP_Type::Kind::SET_TO_RUN_FUNCTION) { + can_backprop = false; // for now... can special case this later. + auto func_to_run_type = input_types[Register(Reg::GPR, arg_regs[1])]; + auto func_to_run_ts = + func_to_run_type->type ? func_to_run_type->type->typespec() : TypeSpec("object"); + if (func_to_run_ts.base_type() != "function" || func_to_run_ts.arg_count() == 0 || + func_to_run_ts.arg_count() > 7) { + throw std::runtime_error( + fmt::format("Call to run-function-in-process or set-to-run at op {} with an invalid " + "function type: {}", + m_my_idx, func_to_run_ts.print())); + } + + std::vector new_arg_types; + if (in_tp.kind == TP_Type::Kind::RUN_FUNCTION_IN_PROCESS_FUNCTION) { + new_arg_types.push_back(TypeSpec("process")); + } else { + new_arg_types.push_back(TypeSpec("thread")); + } + new_arg_types.push_back(TypeSpec("function")); + + for (size_t i = 0; i < func_to_run_ts.arg_count() - 1; i++) { + new_arg_types.push_back(func_to_run_ts.get_arg(i)); + } + new_arg_types.push_back(TypeSpec("none")); + in_type = TypeSpec("function", new_arg_types); + } + + if (in_type.arg_count() < 1) { + throw std::runtime_error("Called a function, but we do not know its type"); + } + + // special case: variable argument count + if (in_type.arg_count() == 2 && in_type.get_arg(0) == TypeSpec("_varargs_")) { + can_backprop = false; // for now... can special case this later. + // we're calling a varags function, which is format. We can determine the argument count + // by looking at the format string, if we can get it. + TP_Type arg_type = TP_Type::make_uninitialized(); + if (input_types[Register(Reg::GPR, Reg::A1)]->type) { + arg_type = *input_types[Register(Reg::GPR, Reg::A1)]->type; + } + + auto can_determine_argc = arg_type.can_be_format_string(); + auto dynamic_string = false; + if (!can_determine_argc && arg_type.typespec() == TypeSpec("string")) { + // dynamic string. use manual lookup table. + dynamic_string = true; + } + if (can_determine_argc || dynamic_string) { + int arg_count = -1; + + if (dynamic_string) { + arg_count = dts.get_dynamic_format_arg_count(env.func->name(), m_my_idx); + } else if (arg_type.is_constant_string()) { + auto& str = arg_type.get_string(); + arg_count = dts.get_format_arg_count(str); + } else { + // is format string. + arg_count = arg_type.get_format_string_arg_count(); + } + + if (arg_count + 2 > 8) { + throw std::runtime_error( + "Call to `format` pushed the arg-count beyond the acceptable arg limit (8), do you " + "need to add " + "a code to the ignore lists?"); + } + + TypeSpec format_call_type("function"); + format_call_type.add_arg(TypeSpec("object")); // destination + format_call_type.add_arg(TypeSpec("string")); // format string + for (int i = 0; i < arg_count; i++) { + format_call_type.add_arg(TypeSpec("object")); + } + format_call_type.add_arg(TypeSpec("object")); + arg_count += 2; // for destination and format string. + + m_call_type = format_call_type; + m_call_type_set = true; + + out_types[Register(Reg::GPR, Reg::V0)]->type = TP_Type::make_from_ts(in_type.last_arg()); + + // we can also update register usage here. + m_read_regs.clear(); + m_arg_vars.clear(); + m_read_regs.emplace_back(Reg::GPR, Reg::T9); + for (int i = 0; i < arg_count; i++) { + m_read_regs.emplace_back(Reg::GPR, arg_regs[i]); + m_arg_vars.push_back(RegisterAccess(AccessMode::READ, m_read_regs.back(), m_my_idx)); + } + + return; + } else { + throw std::runtime_error("Failed to get appropriate string for _varags_ call, got " + + arg_type.print()); + } + } + // set the call type! + m_call_type = in_type; + m_call_type_set = true; + + out_types[Register(Reg::GPR, Reg::V0)]->type = TP_Type::make_from_ts(in_type.last_arg()); + + // we can also update register usage here. + m_read_regs.clear(); + m_arg_vars.clear(); + m_read_regs.emplace_back(Reg::GPR, Reg::T9); + + for (uint32_t i = 0; i < in_type.arg_count() - 1; i++) { + m_read_regs.emplace_back(Reg::GPR, arg_regs[i]); + m_arg_vars.push_back(RegisterAccess(AccessMode::READ, m_read_regs.back(), m_my_idx)); + } + + // _always_ write the v0 register, even if the function returns none. + // GOAL seems to insert coloring moves even on functions returning none. + m_write_regs.clear(); + m_write_regs.emplace_back(Reg::GPR, Reg::V0); + + if (can_backprop) { + for (int i = 0; i < int(m_call_type.arg_count()) - 1; i++) { + auto& expected_type = m_call_type.get_arg(i); + auto& actual_type = input_types[Register(Reg::GPR, arg_regs[i])]; + if (actual_type->tag.has_tag()) { + types2::backprop_tagged_type(TP_Type::make_from_ts(expected_type), *actual_type, dts); + } + } + } +} + +void FunctionEndOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& /*input_types*/, + DecompilerTypeSystem& /*dts*/, + types2::TypePropExtras& /*extras*/) { + for (auto& clobber : m_clobber_regs) { + instr.types[clobber]->type = TP_Type::make_uninitialized(); + } +} + +void StackSpillStoreOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + auto& info = env.stack_spills().lookup(m_offset); + if (info.size != m_size) { + env.func->warnings.error("Stack slot store mismatch: defined as size {}, got size {}\n", + info.size, m_size); + } + + // auto stored_type = m_value.get_type(input, env, dts); + auto* type_out = instr.types.try_find_stack_spill_slot(m_offset); + ASSERT(type_out); + types2_for_atom(*type_out, instr, input_types, m_value, env, dts, extras); +} + +void StackSpillLoadOp::propagate_types2(types2::Instruction& instr, + const Env& env, + types2::TypeState& input_types, + DecompilerTypeSystem& dts, + types2::TypePropExtras& extras) { + // stack slot load + auto& info = env.stack_spills().lookup(m_offset); + if (info.size != m_size) { + env.func->warnings.error("Stack slot load at {} mismatch: defined as size {}, got size {}", + m_offset, info.size, m_size); + } + + if (info.is_signed != m_is_signed) { + env.func->warnings.warning("Stack slot offset {} signed mismatch", m_offset); + } + + auto* type_in = input_types.try_find_stack_spill_slot(m_offset); + ASSERT(type_in); + instr.types[m_dst.reg()]->type = type_in->type; +} + +void ConditionalMoveFalseOp::propagate_types2(types2::Instruction& instr, + const Env& /*env*/, + types2::TypeState& /*input_types*/, + DecompilerTypeSystem& /*dts*/, + types2::TypePropExtras& /*extras*/) { + auto& typ = instr.types[m_dst.reg()]->type; + if (typ) { + if (typ->typespec() != TypeSpec("symbol")) { + lg::warn("Conditional Moved #f into something of type {}", typ->typespec().print()); + // result.get(m_dst.reg()) = TP_Type::make_from_ts("symbol"); + } + } + typ = TP_Type::make_from_ts("symbol"); +} + +} // namespace decompiler diff --git a/decompiler/types2/types2.cpp b/decompiler/types2/types2.cpp new file mode 100644 index 0000000000..b360a7b741 --- /dev/null +++ b/decompiler/types2/types2.cpp @@ -0,0 +1,760 @@ +#include "types2.h" + +#include + +#include "decompiler/ObjectFile/LinkedObjectFile.h" +#include "decompiler/types2/types2.h" +#include "decompiler/util/goal_constants.h" + +namespace decompiler::types2 { + +/*! + * Construct a typestate from the types at the start of a block. + */ +TypeState make_typestate_from_block_types(BlockStartTypes& block_start_types) { + // create references to the gpr, fpr, and stack slot types of the start of the block. + TypeState result; + for (int i = 0; i < 32; i++) { + result.gpr_types[i] = &block_start_types.gpr_types[i]; + result.fpr_types[i] = &block_start_types.fpr_types[i]; + } + for (auto& s : block_start_types.stack_slot_types) { + result.stack_slot_types.push_back(&s); + } + result.next_state_type = &block_start_types.next_state_type; + return result; +} + +/*! + * Find all of the used stack spill slots in a function. + * They are represented as byte offsets. + */ +std::set find_stack_spill_slots(const Function& f) { + std::set result; + for (auto& op : f.ir2.atomic_ops->ops) { + auto as_stack_spill_store = dynamic_cast(op.get()); + if (as_stack_spill_store) { + result.insert(as_stack_spill_store->offset()); + } + + auto as_stack_spill_load = dynamic_cast(op.get()); + if (as_stack_spill_load) { + result.insert(as_stack_spill_load->offset()); + } + } + return result; +} + +/*! + * Set up types for the entry of a function. + */ +void construct_function_entry_types(BlockStartTypes& result, + const TypeSpec& f_ts, + const std::set& stack_slots) { + for (auto& x : result.gpr_types) { + x.type = TP_Type::make_uninitialized(); + } + for (auto& x : result.fpr_types) { + x.type = TP_Type::make_uninitialized(); + } + result.next_state_type.type = TP_Type::make_uninitialized(); + + for (auto x : stack_slots) { + auto slot = result.try_find_stack_spill_slot(x); + ASSERT(slot); + slot->slot = x; + slot->type.type = TP_Type::make_uninitialized(); + } + + int goal_args[] = {Reg::A0, Reg::A1, Reg::A2, Reg::A3, Reg::T0, Reg::T1, Reg::T2, Reg::T3}; + ASSERT(f_ts.base_type() == "function"); + ASSERT(f_ts.arg_count() >= 1); + ASSERT(f_ts.arg_count() <= 8 + 1); // 8 args + 1 return. + for (int i = 0; i < int(f_ts.arg_count()) - 1; i++) { + auto reg_id = goal_args[i]; + const auto& reg_type = f_ts.get_arg(i); + result[Register(Reg::GPR, reg_id)].type = TP_Type::make_from_ts(reg_type); + } + + result[Register(Reg::GPR, Reg::S6)].type = + TP_Type::make_from_ts(TypeSpec(f_ts.try_get_tag("behavior").value_or("process"))); + + // initialize stack slots as uninitialized (I think safe to skip) +} + +/*! + * Set up function cache data structure. + */ +void build_function(FunctionCache& function_cache, + Function& func, + const std::set& stack_slots) { + ASSERT(func.ir2.atomic_ops && func.ir2.atomic_ops_succeeded); + auto& aops = func.ir2.atomic_ops->ops; + + // set up the instruction and block structures + function_cache.blocks.resize(func.basic_blocks.size()); + function_cache.instructions.resize(aops.size()); + for (size_t i = 0; i < aops.size(); i++) { + function_cache.instructions[i].aop_idx = i; + } + for (size_t block_idx = 0; block_idx < function_cache.blocks.size(); block_idx++) { + for (int instr_idx = func.ir2.atomic_ops->block_id_to_first_atomic_op.at(block_idx); + instr_idx < func.ir2.atomic_ops->block_id_to_end_atomic_op.at(block_idx); instr_idx++) { + function_cache.blocks[block_idx].instructions.push_back( + &function_cache.instructions.at(instr_idx)); + } + } + + // figure out the order we'll visit all blocks + // todo: do something with unreachables? + function_cache.block_visit_order = func.bb_topo_sort().vist_order; + + // to save time, we store types at the entry of each block, then in the instructions inside + // each block, store types sparsely. This saves very slow copying around of types. + for (int block_idx : function_cache.block_visit_order) { + auto& block = function_cache.blocks.at(block_idx); + + // add placeholders for all stack slots. + for (auto slot_addr : stack_slots) { + auto& new_slot = block.start_types.stack_slot_types.emplace_back(); + new_slot.slot = slot_addr; + } + + // this will contain pointers to the most recent types for each register. + // it gets initialized to the types on block entry (we store a copy of these) + TypeState state = make_typestate_from_block_types(block.start_types); + block.start_type_state = state; // stash this here, just makes it easier for later. + ASSERT(block.start_type_state.fpr_types[0]); + + // loop through instructions, allocating new types for written registers. + for (auto instr : block.instructions) { + auto& aop = aops.at(instr->aop_idx); + + // allocate types that we'll write/clobber + for (auto& reg : aop->write_regs()) { + RegType rt; + rt.reg = reg; + instr->written_reg_types.push_back(rt); + } + for (auto& reg : aop->clobber_regs()) { + RegType rt; + rt.reg = reg; + instr->written_reg_types.push_back(rt); + } + + // now link the register types + for (auto& written_reg_type : instr->written_reg_types) { + auto reg_kind = written_reg_type.reg.get_kind(); + // ignore weird registers + if (reg_kind == Reg::GPR || reg_kind == Reg::FPR) { + state[written_reg_type.reg] = &written_reg_type.type; + } + } + + // do the same for stack spill types + auto as_stack_spill_store = dynamic_cast(aop.get()); + if (as_stack_spill_store) { + // make a written_stack_slot_type + StackSlotType ss; + ss.slot = as_stack_spill_store->offset(); + instr->written_stack_slot_type = ss; + + // and update state! + bool found = false; + for (auto& slot : state.stack_slot_types) { + if (slot->slot == ss.slot) { + ASSERT(!found); + slot = &instr->written_stack_slot_type.value(); + found = true; + } + } + ASSERT(found); + } + + // do the same for next state (maybe) + auto as_store_op = dynamic_cast(aop.get()); + if (as_store_op) { + IR2_RegOffset ro; + // note that this isn't 100% sure to actually be a next state. + // the implementation of StoreOp will have to notice these false positives and copy + // the next state type (not a big deal). + if (get_as_reg_offset(as_store_op->addr(), &ro)) { + if (ro.reg == Register(Reg::GPR, Reg::S6) && + ro.offset == OFFSET_OF_NEXT_STATE_STORE[func.ir2.env.version]) { + instr->written_next_state_type = types2::Type(); + state.next_state_type = &instr->written_next_state_type.value(); + } + } + } + + // now store the state: + instr->types = state; + } + } +} + +/*! + * Wrapper around a TypeState* that temporarily modifies types for a cast. + * When this is destroyed, the casts will be reverted. + */ +class TypeStateCasted { + public: + TypeStateCasted(TypeState* state) : m_state(state) {} + TypeStateCasted(TypeState* state, const Env& env, int aop_idx, DecompilerTypeSystem& dts) + : TypeStateCasted(state) { + const auto& reg_cast_it = env.casts().find(aop_idx); + if (reg_cast_it != env.casts().end()) { + // apply register casts! + for (auto& cast : reg_cast_it->second) { + push_reg_cast(cast.reg, dts.parse_type_spec(cast.type_name)); + } + } + + for (const auto& [offset, cast] : env.stack_casts()) { + push_stack_cast(offset, dts.parse_type_spec(cast.type_name), env.func); + } + } + TypeStateCasted(const TypeStateCasted&) = delete; + TypeStateCasted& operator=(const TypeStateCasted&) = delete; + + void push_reg_cast(Register reg, const TypeSpec& type) { + auto& cast = m_restores.emplace_back(); + cast.reg = reg; + cast.is_reg = true; + cast.previous = (*m_state)[reg]->type; + (*m_state)[reg]->type = TP_Type::make_from_ts(type); + } + + void push_stack_cast(int slot, const TypeSpec& type, const Function* func) { + auto& cast = m_restores.emplace_back(); + cast.stack_slot = slot; + cast.is_reg = false; + auto spill_slot = m_state->try_find_stack_spill_slot(slot); + ASSERT_MSG(spill_slot, fmt::format("Function {} has no stack slot at {}", func->name(), slot)); + cast.previous = spill_slot->type; + spill_slot->type = TP_Type::make_from_ts(type); + } + + ~TypeStateCasted() { + for (auto it = m_restores.rbegin(); it != m_restores.rend(); it++) { + if (it->is_reg) { + (*m_state)[it->reg]->type = it->previous; + } else { + m_state->try_find_stack_spill_slot(it->stack_slot)->type = it->previous; + } + } + } + + private: + struct Cast { + Register reg; + int stack_slot; + std::optional previous; + bool is_reg; + }; + std::vector m_restores; + TypeState* m_state; +}; + +void backprop_from_preds(FunctionCache& cache, + int block_idx, + Function& func, + TypeState* block_end_typestate, + DecompilerTypeSystem& dts) { + auto& cblock = cache.blocks.at(block_idx); + auto& block = func.basic_blocks.at(block_idx); + + // first, we'll see if we can get any information by looking at our successors. + // if not, we'll notify our successors to prepare information for us, and we'll get it next time. + + // loop over registers (both gpr and fpr) + for (auto reg_type : {Reg::GPR, Reg::FPR}) { + for (int i = 0; i < 32; i++) { + auto reg = Register(reg_type, i); + + // we're only interested in types with a "tag" that indicates they need more info. + if (block_end_typestate->operator[](reg)->tag.has_tag()) { + std::optional resolve_type; + + // loop over successors + for (auto& succ_idx : {block.succ_branch, block.succ_ft}) { + if (succ_idx >= 0) { + // the successor will use block entry tags to report back this info. + // we'll check for these, use them if they exist, and add them if they don't. + bool this_succ_has_tag = false; + auto& succ_cblock = cache.blocks.at(succ_idx); + + // loop over all block entry tags - these are used within the block to backpropagate + // constraints to the start of the block. + for (auto& succ_tag : succ_cblock.block_entry_tags) { + // see if it matches... + if (succ_tag->is_reg && succ_tag->reg == reg) { + // remember the tag exists so we don't add another. + this_succ_has_tag = true; + + // see if the tag has been resolved + if (succ_tag->selected_type) { + // it has, we can use this to update our guess of the type + if (resolve_type) { + // we already have 1 guess, lca of the guesses. + bool change; + resolve_type = dts.tp_lca(*resolve_type, *succ_tag->selected_type, &change); + } else { + // no existing guess, just use this one. + resolve_type = succ_tag->selected_type; + } + } + } + } + + // if we didn't find a tag, we should add one + if (!this_succ_has_tag) { + // allocate it in the block + succ_cblock.block_entry_tags.push_back(std::make_unique()); + auto* tag = succ_cblock.block_entry_tags.back().get(); + // set up for the register + tag->is_reg = true; + tag->reg = reg; + tag->type_to_clear = &cache.blocks.at(succ_idx).start_type_state[reg]->type; + // fmt::print("mark to clear {}\n", succ_idx); + // add the tag to the type. + auto& st = succ_cblock.start_types[reg]; + ASSERT(!st.tag.has_tag()); + st.tag.kind = Tag::BLOCK_ENTRY; + st.tag.block_entry = tag; + succ_cblock.needs_run = true; + } + } + } + + // we got info from the successor, pass it back into this block + if (resolve_type) { + if (backprop_tagged_type(*resolve_type, *(*block_end_typestate)[reg], dts)) { + // if we've changed things, mark this block to be re-ran. + cblock.needs_run = true; + } + } + } + } + } + + // if we updated somebody else's tags + bool tags_updated = false; + for (auto& my_tag : cblock.block_entry_tags) { + if (my_tag->updated) { + tags_updated = true; + my_tag->updated = false; + // fmt::print("clearing {}\n", block_idx); + cblock.needs_run = true; // maybe? + *my_tag->type_to_clear = {}; // meh.. + } + } + + if (tags_updated) { + for (auto& pred : block.pred) { + cache.blocks.at(pred).needs_run = true; + } + } +} + +std::optional tp_lca(const types2::Type& existing, + const types2::Type& add, + bool* changed, + DecompilerTypeSystem& dts) { + if (existing.type && add.type) { + return dts.tp_lca(*existing.type, *add.type, changed); + } else if (existing.type && !add.type) { + *changed = false; + return existing.type; + } else if (!existing.type && add.type) { + *changed = true; + return add.type; + } else { + // neither + *changed = false; + return {}; + } +} + +/*! + * Find the least common ancestor of an entire typestate. + */ +bool tp_lca(types2::TypeState* combined, const types2::TypeState& add, DecompilerTypeSystem& dts) { + bool result = false; + for (int i = 0; i < 32; i++) { + bool diff = false; + auto new_type = tp_lca(*combined->gpr_types[i], *add.gpr_types[i], &diff, dts); + if (diff) { + result = true; + combined->gpr_types[i]->type = new_type; + } + } + + for (int i = 0; i < 32; i++) { + bool diff = false; + auto new_type = tp_lca(*combined->fpr_types[i], *add.fpr_types[i], &diff, dts); + if (diff) { + result = true; + combined->fpr_types[i]->type = new_type; + } + } + + for (auto& x : add.stack_slot_types) { + bool diff = false; + auto comb = combined->try_find_stack_spill_slot(x->slot); + if (!comb) { + fmt::print("failed to find {}\n", x->slot); + for (auto& x : combined->stack_slot_types) { + fmt::print("x = {}\n", x->slot); + } + } + ASSERT(comb); + auto new_type = tp_lca(*comb, x->type, &diff, dts); + if (diff) { + result = true; + comb->type = new_type; + } + } + + bool diff = false; + auto new_type = tp_lca(*combined->next_state_type, *add.next_state_type, &diff, dts); + if (diff) { + result = true; + combined->next_state_type->type = new_type; + } + + return result; +} + +/*! + * Propagate types from the beginning of this block. + */ +bool propagate_block(FunctionCache& cache, + int block_idx, + Function& func, + DecompilerTypeSystem& dts, + bool tag_lock) { + bool debug = false; // func.name() == "string->float"; + auto& cblock = cache.blocks.at(block_idx); + auto& block = func.basic_blocks.at(block_idx); + // for now, assume we'll be done. something might change this later, we'll see + cblock.needs_run = false; + + // propagate through instructions + TypeState* previous_typestate = &cblock.start_type_state; + for (auto instr : cblock.instructions) { + { + TypeStateCasted casted(previous_typestate, func.ir2.env, instr->aop_idx, *func.ir2.env.dts); + auto& aop = func.ir2.atomic_ops->ops.at(instr->aop_idx); + TypePropExtras extras; + extras.tags_locked = tag_lock; + // fmt::print("run: {}\n", aop->to_string(func.ir2.env)); + + try { + aop->propagate_types2(*instr, func.ir2.env, *previous_typestate, *func.ir2.env.dts, extras); + } catch (const std::exception& e) { + auto error = fmt::format("failed type prop at {}: {}", instr->aop_idx, e.what()); + func.warnings.error(error); + lg::error("Function {} {}", func.name(), error); + return false; + } + if (extras.needs_rerun) { + cblock.needs_run = true; + } + // propagate forward + // TODO + // handle constraints + } + previous_typestate = &instr->types; + } + + // now that we've reached the end, handle backprop across blocks + if (!tag_lock) { + backprop_from_preds(cache, block_idx, func, previous_typestate, *func.ir2.env.dts); + } + + // deal with end crap + + // lca + + // set tags on succs/backprop from succs + + for (auto succ_block_id : {block.succ_ft, block.succ_branch}) { + if (succ_block_id != -1) { + // set types to LCA (current, new) + if (tp_lca(&cache.blocks.at(succ_block_id).start_type_state, *previous_typestate, dts)) { + // if something changed, run again! + cache.blocks.at(succ_block_id).needs_run = true; + } + } + } + return true; +} + +bool convert_to_old_format(TP_Type& out, const types2::Type* in, bool recovery_mode) { + if (!in->type) { + if (recovery_mode) { + out = TP_Type::make_uninitialized(); + return true; + } else { + return false; + } + } else { + out = *in->type; + return true; + } +} + +bool convert_to_old_format(::decompiler::TypeState& out, + const types2::TypeState& in, + std::string& error_string, + int my_idx, + const std::unordered_map>& casts, + const std::unordered_map& stack_casts, + const DecompilerTypeSystem& dts, + bool recovery_mode) { + for (int i = 0; i < 32; i++) { + ASSERT(in.fpr_types[i]); + if (!convert_to_old_format(out.fpr_types[i], in.fpr_types[i], recovery_mode)) { + error_string += fmt::format("Failed to convert FPR: {} ", i); + return false; + } + if (!convert_to_old_format(out.gpr_types[i], in.gpr_types[i], recovery_mode)) { + error_string += fmt::format("Failed to convert GPR: {} ", Register(Reg::GPR, i).to_string()); + return false; + } + } + + if (!convert_to_old_format(out.next_state_type, in.next_state_type, recovery_mode)) { + error_string += "Failed to convert next state "; + return false; + } + + const auto& reg_casts = casts.find(my_idx); + if (reg_casts != casts.end()) { + for (auto& cast : reg_casts->second) { + out.get(cast.reg) = TP_Type::make_from_ts(dts.parse_type_spec(cast.type_name)); + } + } + + for (auto& x : in.stack_slot_types) { + TP_Type temp; + if (!convert_to_old_format(temp, &x->type, recovery_mode)) { + error_string += fmt::format("Failed to convert stack slot: {} ", x->slot); + return false; + } + out.spill_slots[x->slot] = temp; + } + + for (auto& [offset, type] : stack_casts) { + out.spill_slots[offset] = TP_Type::make_from_ts(dts.parse_type_spec(type.type_name)); + } + return true; +} + +bool convert_to_old_format(Output& out, + FunctionCache& in, + std::string& error_string, + const std::unordered_map>& casts, + const std::unordered_map& stack_casts, + const DecompilerTypeSystem& dts, + bool recovery_mode) { + // for (auto& block : in.blocks) { + out.op_end_types.resize(in.instructions.size()); + out.block_init_types.resize(in.blocks.size()); + for (int block_idx : in.block_visit_order) { + auto& block = in.blocks[block_idx]; + if (!convert_to_old_format(out.block_init_types.at(block_idx), block.start_type_state, + error_string, block.instructions.at(0)->aop_idx, casts, stack_casts, + dts, recovery_mode)) { + error_string += fmt::format(" at the start of block {}\n", block_idx); + return false; + } + + for (auto& instr : block.instructions) { + if (!convert_to_old_format(out.op_end_types.at(instr->aop_idx), instr->types, error_string, + instr->aop_idx + 1, casts, stack_casts, dts, recovery_mode)) { + error_string += fmt::format(" at op {}\n", instr->aop_idx); + return false; + } + } + } + + return true; +} + +/*! + * Main Types2 Analysis pass. + */ +void run(Output& out, const Input& input) { + // First, construct our graph + FunctionCache function_cache; + auto stack_slots = find_stack_spill_slots(*input.func); + build_function(function_cache, *input.func, stack_slots); + + // annoying hack + if (input.func->guessed_name.kind == FunctionName::FunctionKind::METHOD) { + input.dts->type_prop_settings.current_method_type = input.func->guessed_name.type_name; + } + + if (input.function_type.last_arg() == TypeSpec("none")) { + auto as_end = dynamic_cast(input.func->ir2.atomic_ops->ops.back().get()); + ASSERT(as_end); + as_end->mark_function_as_no_return_value(); + } + + // mark the entry block + function_cache.blocks.at(0).needs_run = true; + construct_function_entry_types(function_cache.blocks.at(0).start_types, input.function_type, + stack_slots); + + // Run propagation, until we get through an iteration with no changes + int blocks_run = 0; + int outer_iterations = 0; + bool needs_rerun = true; + bool hit_error = false; + while (needs_rerun) { + outer_iterations++; + needs_rerun = false; + + for (auto block_idx : function_cache.block_visit_order) { + if (function_cache.blocks.at(block_idx).needs_run) { + blocks_run++; + needs_rerun = true; + if (!propagate_block(function_cache, block_idx, *input.func, *input.func->ir2.env.dts, + false)) { + hit_error = true; + goto end_type_pass; + } + } + } + + auto& return_type = input.function_type.last_arg(); + if (return_type != TypeSpec("none")) { + auto& last_instr = function_cache.instructions.back().types[Register(Reg::GPR, Reg::V0)]; + if (last_instr->tag.has_tag()) { + if (!last_instr->type || !input.dts->ts.tc(return_type, last_instr->type->typespec())) { + if (backprop_tagged_type(TP_Type::make_from_ts(return_type), *last_instr, *input.dts)) { + needs_rerun = true; + } + } + } + } + } + for (auto block_idx : function_cache.block_visit_order) { + if (block_idx != 0) { + auto& cblock = function_cache.blocks.at(block_idx).start_types; + for (auto& x : cblock.gpr_types) { + x.type = TP_Type::make_uninitialized(); + } + for (auto& x : cblock.fpr_types) { + x.type = TP_Type::make_uninitialized(); + } + + for (auto x : stack_slots) { + auto slot = cblock.try_find_stack_spill_slot(x); + ASSERT(slot); + slot->type.type = TP_Type::make_uninitialized(); + } + + cblock.next_state_type.type = TP_Type::make_uninitialized(); + } + } + + needs_rerun = true; + function_cache.blocks.at(0).needs_run = true; + while (needs_rerun) { + outer_iterations++; + needs_rerun = false; + for (auto block_idx : function_cache.block_visit_order) { + if (function_cache.blocks.at(block_idx).needs_run) { + blocks_run++; + needs_rerun = true; + if (!propagate_block(function_cache, block_idx, *input.func, *input.func->ir2.env.dts, + true)) { + hit_error = true; + goto end_type_pass; + } + } + } + } + +end_type_pass: + std::string error; + if (!convert_to_old_format(out, function_cache, error, input.func->ir2.env.casts(), + input.func->ir2.env.stack_casts(), *input.dts, hit_error)) { + fmt::print("Failed convert_to_old_format: {}\n", error); + } else { + input.func->ir2.env.types_succeeded = true; + auto last_type = out.op_end_types.back().get(Register(Reg::GPR, Reg::V0)).typespec(); + if (last_type != input.function_type.last_arg()) { + input.func->warnings.info("Return type mismatch {} vs {}.", last_type.print(), + input.function_type.last_arg().print()); + } + } + + // figure out the types of stack spill variables: + auto& env = input.func->ir2.env; + bool changed; + for (auto& type_info : out.op_end_types) { + for (auto& spill : type_info.spill_slots) { + auto& slot_info = env.stack_slot_entries[spill.first]; + slot_info.tp_type = + input.dts->tp_lca(env.stack_slot_entries[spill.first].tp_type, spill.second, &changed); + slot_info.offset = spill.first; + } + } + + for (auto& type_info : out.block_init_types) { + for (auto& spill : type_info.spill_slots) { + auto& slot_info = env.stack_slot_entries[spill.first]; + slot_info.tp_type = + input.dts->tp_lca(env.stack_slot_entries[spill.first].tp_type, spill.second, &changed); + slot_info.offset = spill.first; + } + } + + // convert to typespec + for (auto& info : env.stack_slot_entries) { + info.second.typespec = info.second.tp_type.typespec(); + // debug + // fmt::print("STACK {} : {} ({})\n", info.first, info.second.typespec.print(), + // info.second.tp_type.print()); + } + + // notify the label db of guessed labels + for (auto& instr : function_cache.instructions) { + if (instr.unknown_label_tag) { + if (!instr.unknown_label_tag->selected_type) { + throw std::runtime_error(fmt::format("Failed to guess label use for {} in {}:{}", + instr.unknown_label_tag->label_name, + input.func->name(), instr.aop_idx)); + } + auto& type = instr.unknown_label_tag->selected_type.value(); + int idx = instr.unknown_label_tag->label_idx; + ASSERT(type.base_type() != "pointer"); // want to test this if we find example... + env.file->label_db->set_and_get_previous(idx, type, false, {}); + } + + if (instr.unknown_stack_structure_tag) { + if (!instr.unknown_stack_structure_tag->selected_type) { + throw std::runtime_error(fmt::format("Failed to guess stack use for {} in {}:{}", + instr.unknown_stack_structure_tag->stack_offset, + input.func->name(), instr.aop_idx)); + } + + auto& type = instr.unknown_stack_structure_tag->selected_type.value(); + int offset = instr.unknown_stack_structure_tag->stack_offset; + ASSERT(type.base_type() != "pointer"); // want to test this if we find example... + StackStructureHint hint; + hint.stack_offset = offset; + hint.container_type = StackStructureHint::ContainerType::NONE; + hint.element_type = type.print(); + env.add_stack_structure_hint(hint); + } + } + + out.succeeded = !hit_error; +} + +} // namespace decompiler::types2 \ No newline at end of file diff --git a/decompiler/types2/types2.h b/decompiler/types2/types2.h new file mode 100644 index 0000000000..c19de84ca4 --- /dev/null +++ b/decompiler/types2/types2.h @@ -0,0 +1,248 @@ +#pragma once + +#include +#include +#include +#include + +#include "decompiler/Function/Function.h" +#include "decompiler/config.h" +#include "decompiler/util/DecompilerTypeSystem.h" +#include "decompiler/util/TP_Type.h" + +namespace decompiler::types2 { + +// Backprop tag types: +// these classes are "tags" that can be added to types to give a path to propagate constraints +// backward. For example, if we encounter a function call, and we know the expected argument types, +// the type pass will use these tags to propagate information backward. + +/*! + * Represents a case where there are multiple possible fields that could be accessed. + * For example, (&-> matrix vector 0), (&-> matrix data 0). Or any case with overlapping fields. + */ +struct AmbiguousFieldAccess { + struct Possibility { + TypeSpec type; + // TODO: probably stash more info here. + }; + std::vector possibilities; + int selected_possibility = -1; // -1 if not selected. +}; + +/*! + * Tag to link an unknown type back to a label with unknown type. + */ +struct UnknownLabel { + int label_idx = -1; + std::string label_name; // just for debug prints + std::optional selected_type; +}; + +/*! + * Tag to link an unknown type back to a stack structure with unknown type. + */ +struct UnknownStackStructure { + int stack_offset = -1; + std::optional selected_type; +}; + +/*! + * Tag to link a type back to something outside the block. + */ +struct BlockEntryType { + Register reg; + bool is_reg = true; + int stack_slot = -1; + std::optional selected_type; + bool updated = false; + std::optional* type_to_clear = nullptr; +}; + +struct AmbiguousIntOrFloatConstant { + std::optional is_float; +}; + +/*! + * Union of all tag types. + */ +struct Tag { + bool has_tag() { return kind != NONE; } + enum Kind { + FIELD_ACCESS, + UNKNOWN_LABEL, + UNKNOWN_STACK_STRUCTURE, + BLOCK_ENTRY, + INT_OR_FLOAT, + NONE + } kind = NONE; + + union { + AmbiguousFieldAccess* field_access; + BlockEntryType* block_entry; + UnknownLabel* unknown_label; + UnknownStackStructure* unknown_stack_structure; + AmbiguousIntOrFloatConstant* int_or_float; + }; +}; + +/*! + * The basic "type" that we're trying to figure out for each register on each instruction. + */ +struct Type { + Tag tag; // may have type "none" + std::optional type; // may be unknown +}; + +struct RegType { + Type type; + Register reg; +}; + +struct StackSlotType { + Type type; + int slot = -1; +}; + +struct TypeState { + Type* gpr_types[32]; + Type* fpr_types[32]; + Type* next_state_type = nullptr; + + Type*& operator[](const Register& reg) { + switch (reg.get_kind()) { + case Reg::FPR: + return fpr_types[reg.get_fpr()]; + case Reg::GPR: + return gpr_types[reg.get_gpr()]; + default: + ASSERT(false); + } + } + + const Type* operator[](const Register& reg) const { + switch (reg.get_kind()) { + case Reg::FPR: + return fpr_types[reg.get_fpr()]; + case Reg::GPR: + return gpr_types[reg.get_gpr()]; + default: + ASSERT(false); + } + } + + Type* try_find_stack_spill_slot(int slot) { + for (auto ss : stack_slot_types) { + if (ss->slot == slot) { + return &ss->type; + } + } + return nullptr; + } + + const Type* try_find_stack_spill_slot(int slot) const { + for (auto& ss : stack_slot_types) { + if (ss->slot == slot) { + return &ss->type; + } + } + return nullptr; + } + + template + void for_each_type(T&& f) { + for (auto gpr_type : gpr_types) { + f(*gpr_type); + } + for (auto fpr_type : fpr_types) { + f(*fpr_type); + } + for (auto spill : stack_slot_types) { + f(spill->type); + } + f(*next_state_type); + } + + std::vector stack_slot_types; +}; + +struct Instruction { + TypeState types; + size_t aop_idx = -1; + std::vector written_reg_types; + std::optional written_stack_slot_type; + std::optional written_next_state_type; + std::unique_ptr field_access_tag; + std::unique_ptr unknown_label_tag; + std::unique_ptr unknown_stack_structure_tag; + std::unique_ptr int_or_float; +}; + +struct BlockStartTypes { + Type gpr_types[32]; + Type fpr_types[32]; + Type next_state_type; + std::vector stack_slot_types; + + StackSlotType* try_find_stack_spill_slot(int slot) { + for (auto& ss : stack_slot_types) { + if (ss.slot == slot) { + return &ss; + } + } + return nullptr; + } + + Type& operator[](const Register& reg) { + switch (reg.get_kind()) { + case Reg::FPR: + return fpr_types[reg.get_fpr()]; + case Reg::GPR: + return gpr_types[reg.get_gpr()]; + default: + ASSERT(false); + } + } +}; + +struct Block { + bool needs_run = false; + BlockStartTypes start_types; + TypeState start_type_state; + std::vector instructions; + std::vector> block_entry_tags; +}; + +struct FunctionCache { + std::vector blocks; + std::vector instructions; + std::vector reg_type_casts; + std::vector stack_slot_casts; + std::vector block_visit_order; +}; + +struct Output { + std::vector<::decompiler::TypeState> block_init_types; + std::vector<::decompiler::TypeState> op_end_types; + std::vector stack_structure_hints; + bool succeeded = false; +}; + +struct Input { + TypeSpec function_type; + DecompilerTypeSystem* dts; + Function* func; +}; + +struct TypePropExtras { + bool needs_rerun = false; + bool tags_locked = false; +}; + +void run(Output& out, const Input& input); + +bool backprop_tagged_type(const TP_Type& expected_type, + types2::Type& actual_type, + const DecompilerTypeSystem& dts); + +} // namespace decompiler::types2 \ No newline at end of file diff --git a/decompiler/util/DecompilerTypeSystem.cpp b/decompiler/util/DecompilerTypeSystem.cpp index 38b67513dc..bfc3008606 100644 --- a/decompiler/util/DecompilerTypeSystem.cpp +++ b/decompiler/util/DecompilerTypeSystem.cpp @@ -412,8 +412,8 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const { } static const std::vector single_char_ignore_list = {'%', 'T'}; - static const std::vector multi_char_ignore_list = {"0L", "1L", "3L", "1K", - "2j", "0k", "30L", "1T"}; + static const std::vector multi_char_ignore_list = {"0L", "1L", "3L", "1K", "2j", + "0k", "30L", "1T", "2T"}; int arg_count = 0; for (size_t i = 0; i < str.length(); i++) { diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 2e5fa94011..268ac56904 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -279,7 +279,9 @@ goos::Object decompile_value_array(const TypeSpec& elt_type, for (int j = start; j < end; j++) { auto& word = obj_words.at(j / 4); if (word.kind() != LinkedWord::PLAIN_DATA) { - throw std::runtime_error("Got bad word in kind in array of values"); + throw std::runtime_error(fmt::format( + "Got bad word in kind in array of values: expecting array of {}'s, got a {}\n", + elt_type.print(), (int)word.kind())); } elt_bytes.push_back(word.get_byte(j % 4)); } @@ -592,6 +594,16 @@ goos::Object sp_launch_grp_launcher_decompile(const std::vector& wor return decomp_ref_to_inline_array_guess_size(words, labels, my_seg, field_location, ts, all_words, file, TypeSpec("sparticle-group-item"), 32); } +goos::Object probe_dir_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("vector"), 16); +} goos::Object decompile_sound_spec(const TypeSpec& type, const DecompilerLabel& label, @@ -746,12 +758,14 @@ goos::Object decompile_structure(const TypeSpec& type, // some structures we want to decompile to fancy macros instead of a raw static definiton if (use_fancy_macros) { if (type == TypeSpec("sp-field-init-spec")) { + ASSERT(file->version == GameVersion::Jak1); // need to update enums return decompile_sparticle_field_init(type, label, labels, words, ts, file); } if (type == TypeSpec("sparticle-group-item")) { + ASSERT(file->version == GameVersion::Jak1); // need to update enums return decompile_sparticle_group_item(type, label, labels, words, ts, file); } - if (type == TypeSpec("sound-spec")) { + if (type == TypeSpec("sound-spec") && file->version != GameVersion::Jak2) { return decompile_sound_spec(type, label, labels, words, ts, file); } } @@ -769,7 +783,8 @@ goos::Object decompile_structure(const TypeSpec& type, if (is_basic) { const auto& word = words.at(label.target_segment).at((offset_location / 4)); if (word.kind() != LinkedWord::TYPE_PTR) { - throw std::runtime_error("Basic does not start with type pointer"); + throw std::runtime_error( + fmt::format("Basic does not start with type pointer: {}", label.name)); } if (word.symbol_name() != actual_type.base_type()) { @@ -976,6 +991,10 @@ goos::Object decompile_structure(const TypeSpec& type, field.name(), decomp_ref_to_integer_array_guess_size( obj_words, labels, label.target_segment, field_start, ts, words, file, TypeSpec("uint8"), 1)); + } else if (field.name() == "probe-dirs" && type.print() == "lightning-probe-vars") { + field_defs_out.emplace_back(field.name(), + probe_dir_decompile(obj_words, labels, label.target_segment, + field_start, ts, words, file)); } else { if (field.type().base_type() == "pointer") { if (obj_words.at(field_start / 4).kind() != LinkedWord::SYM_PTR) { @@ -1400,6 +1419,8 @@ goos::Object decompile_boxed_array(const DecompilerLabel& label, (word.data & 0b111) == 0) { s32 val = word.data; result.push_back(pretty_print::to_symbol(fmt::format("(the binteger {})", val / 8))); + } else if (content_type == TypeSpec("type") && word.kind() == LinkedWord::TYPE_PTR) { + result.push_back(pretty_print::to_symbol(word.symbol_name())); } else { throw std::runtime_error( fmt::format("Unknown content type in boxed array of references, word idx {}", diff --git a/decompiler/util/goal_constants.h b/decompiler/util/goal_constants.h index 6d0a7cf484..eb3737e1ee 100644 --- a/decompiler/util/goal_constants.h +++ b/decompiler/util/goal_constants.h @@ -1,8 +1,11 @@ #pragma once #include "common/common_types.h" +#include "common/versions.h" // Separate constants for the decompiler, so we can make changes to the game without breaking // decompilation. constexpr s32 DECOMP_SYM_INFO_OFFSET = 8167 * 8 - 4; + +constexpr PerGameVersion OFFSET_OF_NEXT_STATE_STORE = {72, 64}; \ No newline at end of file diff --git a/goal_src/jak2/kernel-defs.gc b/goal_src/jak2/kernel-defs.gc index 2468fa510f..ca43b8de88 100644 --- a/goal_src/jak2/kernel-defs.gc +++ b/goal_src/jak2/kernel-defs.gc @@ -103,7 +103,7 @@ (define-extern __mem-move (function pointer pointer uint none)) (define-extern file-stream-read (function file-stream pointer int int)) -(define-extern file-stream-open (function file-stream basic symbol file-stream)) +(define-extern file-stream-open (function file-stream string symbol file-stream)) (define-extern file-stream-length (function file-stream int)) diff --git a/goalc/build_level/collide_bvh.cpp b/goalc/build_level/collide_bvh.cpp index cd832a688e..9e3f4a0e6f 100644 --- a/goalc/build_level/collide_bvh.cpp +++ b/goalc/build_level/collide_bvh.cpp @@ -1,6 +1,7 @@ #include "collide_bvh.h" #include +#include #include #include "common/log/log.h" @@ -19,15 +20,6 @@ namespace collide { namespace { constexpr int MAX_UNIQUE_VERTS_IN_FRAG = 128; -struct BBox { - math::Vector3f mins, maxs; - std::string sz_to_string() const { - return fmt::format("{} {} ({})", (mins / 4096.f).to_string_aligned(), - (maxs / 4096.f).to_string_aligned(), - ((maxs - mins) / 4096.f).to_string_aligned()); - } -}; - /*! * The Collide node. * If it's a leaf, it has faces @@ -45,20 +37,6 @@ struct VectorHash { } }; -/*! - * Recursively get a set of unique vertices. - */ -void collect_vertices(const CNode& node, std::unordered_set& verts) { - for (auto& child : node.child_nodes) { - collect_vertices(child, verts); - } - for (auto& face : node.faces) { - verts.insert(face.v[0]); - verts.insert(face.v[1]); - verts.insert(face.v[2]); - } -} - /*! * Recursively get a list of vertices. */ @@ -73,30 +51,6 @@ void collect_vertices(const CNode& node, std::vector& verts) { } } -/*! - * Get the axis-aligned bounding box of these vertices - */ -BBox compute_my_bbox(const std::vector& verts) { - ASSERT(!verts.empty()); - BBox result; - result.mins = verts.front(); - result.maxs = verts.front(); - for (auto& v : verts) { - result.mins.min_in_place(v); - result.maxs.min_in_place(v); - } - return result; -} - -/*! - * Get the axis-aligned bounding box of all vertices in this node and its children - */ -BBox compute_my_bbox(const CNode& node) { - std::vector verts; - collect_vertices(node, verts); - return compute_my_bbox(verts); -} - /*! * Find the vertex in verts that is most distant from pt. */ @@ -154,6 +108,7 @@ void split_along_dim(std::vector& faces, std::sort(faces.begin(), faces.end(), [=](const CollideFace& a, const CollideFace& b) { return a.bsphere[dim] < b.bsphere[dim]; }); + fmt::print("splitting with size: {}\n", faces.size()); size_t split_idx = faces.size() / 2; out0->insert(out0->end(), faces.begin(), faces.begin() + split_idx); out1->insert(out1->end(), faces.begin() + split_idx, faces.end()); @@ -165,7 +120,6 @@ void split_along_dim(std::vector& faces, void split_node_once(CNode& node, CNode* out0, CNode* out1) { compute_my_bsphere_ritters(node); CNode temps[6]; - // split_along_dim(node.faces, pick_dim_for_split(node.faces), &out0->faces, &out1->faces); split_along_dim(node.faces, 0, &temps[0].faces, &temps[1].faces); split_along_dim(node.faces, 1, &temps[2].faces, &temps[3].faces); split_along_dim(node.faces, 2, &temps[4].faces, &temps[5].faces); @@ -211,7 +165,7 @@ bool needs_split(const CNode& node) { } } - return unique_verts.size() >= 128; + return unique_verts.size() >= MAX_UNIQUE_VERTS_IN_FRAG; } void split_recursive(CNode& to_split) { @@ -342,7 +296,17 @@ CollideTree construct_collide_bvh(const std::vector& tris) { bvh_timer.start(); auto tree = build_collide_tree(root); debug_stats(tree); + lg::info("Tree layout done in {:.2f} ms", bvh_timer.getMs()); + std::map size_histogram; + for (const auto& f : tree.frags.frags) { + size_histogram[f.faces.size()]++; + } + + for (auto [size, count] : size_histogram) { + fmt::print(" [{:3d}] {:3d} ({})\n", size, count, size * count); + } + return tree; } diff --git a/test.sh b/test.sh index 32eb344025..c52aa0d52b 100755 --- a/test.sh +++ b/test.sh @@ -3,4 +3,4 @@ # Directory of this script DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -$DIR/build/goalc-test --gtest_brief=1 --gtest_color=yes "$@" --gtest_filter="-*MANUAL_TEST*" +$DIR/build/goalc-test --gtest_color=yes "$@" --gtest_filter="-*MANUAL_TEST*" diff --git a/test/decompiler/FormRegressionTest.h b/test/decompiler/FormRegressionTest.h index 974b8a4081..652652dab1 100644 --- a/test/decompiler/FormRegressionTest.h +++ b/test/decompiler/FormRegressionTest.h @@ -31,7 +31,7 @@ class FormRegressionTest : public ::testing::TestWithParam { static void TearDownTestCase(); struct TestData { - explicit TestData(int instrs, GameVersion version) : func(0, instrs, version) {} + explicit TestData(int instrs, GameVersion version) : func(0, instrs, version), file(version) {} decompiler::Function func; decompiler::LinkedObjectFile file; diff --git a/test/decompiler/reference/jak1/engine/anim/joint_REF.gc b/test/decompiler/reference/jak1/engine/anim/joint_REF.gc index fbc1a8b3c7..196610b1f7 100644 --- a/test/decompiler/reference/jak1/engine/anim/joint_REF.gc +++ b/test/decompiler/reference/jak1/engine/anim/joint_REF.gc @@ -541,7 +541,7 @@ ;; definition for method 9 of type art-mesh-geo ;; ERROR: Type Propagation failed: Failed type prop at op 20 ((set! v1 (l.h (+ s4 6)))): Could not get type of load: (set! v1 (l.h (+ s4 6))). -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed (defmethod login art-mesh-geo ((a0-0 art-mesh-geo)) (local-vars (v0-0 none) diff --git a/test/decompiler/reference/jak1/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak1/engine/draw/drawable_REF.gc index e932b74403..28bebca444 100644 --- a/test/decompiler/reference/jak1/engine/draw/drawable_REF.gc +++ b/test/decompiler/reference/jak1/engine/draw/drawable_REF.gc @@ -134,7 +134,7 @@ ;; definition for function vis-cull ;; ERROR: 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))). -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed ;; ERROR: 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)) diff --git a/test/decompiler/reference/jak1/engine/gfx/sky/sky_REF.gc b/test/decompiler/reference/jak1/engine/gfx/sky/sky_REF.gc index d9c5a079ee..94b3fcdde0 100644 --- a/test/decompiler/reference/jak1/engine/gfx/sky/sky_REF.gc +++ b/test/decompiler/reference/jak1/engine/gfx/sky/sky_REF.gc @@ -139,7 +139,7 @@ ;; definition for function sky-draw ;; ERROR: Type Propagation failed: Failed type prop at op 12 ((set! a0 (+ a0 16))): Cannot get_type_int2: (+ a0 16), args float and -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed (defun sky-draw ((a0-0 sky-parms)) (local-vars (v0-0 none) diff --git a/test/decompiler/reference/jak1/engine/math/vector_REF.gc b/test/decompiler/reference/jak1/engine/math/vector_REF.gc index c6a0bb7fb2..7ef66b5653 100644 --- a/test/decompiler/reference/jak1/engine/math/vector_REF.gc +++ b/test/decompiler/reference/jak1/engine/math/vector_REF.gc @@ -511,27 +511,7 @@ ;; definition for function vector-length (defun vector-length ((arg0 vector)) - (local-vars (v0-0 float)) - (rlet ((acc :class vf) - (Q :class vf) - (vf0 :class vf) - (vf1 :class vf) - ) - (init-vf0-vector) - (.lvf vf1 (&-> arg0 quad)) - (.mul.vf vf1 vf1 vf1) - (.mul.x.vf acc vf0 vf1 :mask #b1000) - (.add.mul.y.vf acc vf0 vf1 acc :mask #b1000) - (.add.mul.z.vf vf1 vf0 vf1 acc :mask #b1000) - (.sqrt.vf Q vf1 :ftf #b11) - (.add.w.vf vf1 vf0 vf0 :mask #b1) - (.wait.vf) - (.mul.vf vf1 vf1 Q :mask #b1) - (.nop.vf) - (.nop.vf) - (.mov v0-0 vf1) - v0-0 - ) + (vector-length arg0) ) ;; definition for function vector-length-squared diff --git a/test/decompiler/reference/jak1/engine/util/glist_REF.gc b/test/decompiler/reference/jak1/engine/util/glist_REF.gc index 4ee3d8e0b4..9888a3d8e5 100644 --- a/test/decompiler/reference/jak1/engine/util/glist_REF.gc +++ b/test/decompiler/reference/jak1/engine/util/glist_REF.gc @@ -112,7 +112,7 @@ ;; definition for function glst-find-node-by-name ;; ERROR: Type Propagation failed: Failed type prop at op 7 ((set! a0 (l.wu (+ v1 8)))): Could not get type of load: (set! a0 (l.wu (+ v1 8))). -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed (defun glst-find-node-by-name ((a0-0 glst-list) (a1-0 string)) (local-vars (v0-0 none) @@ -173,7 +173,7 @@ ;; definition for function glst-length-of-longest-name ;; ERROR: Type Propagation failed: Failed type prop at op 6 ((set! a0 (l.wu (+ v1 8)))): Could not get type of load: (set! a0 (l.wu (+ v1 8))). -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed (defun glst-length-of-longest-name ((a0-0 glst-list)) (local-vars (v0-0 none) diff --git a/test/decompiler/reference/jak1/levels/rolling/rolling-obs_REF.gc b/test/decompiler/reference/jak1/levels/rolling/rolling-obs_REF.gc index 51322f4954..8b90d8f4bf 100644 --- a/test/decompiler/reference/jak1/levels/rolling/rolling-obs_REF.gc +++ b/test/decompiler/reference/jak1/levels/rolling/rolling-obs_REF.gc @@ -872,7 +872,7 @@ ;; definition for function race-time-save ;; ERROR: Type Propagation failed: Failed type prop at op 6 ((set! v1 (l.wu (+ a0 -4)))): Could not get type of load: (set! v1 (l.wu (+ a0 -4))). -;; ERROR: Type Propagation failed: Type analysis failed +;; WARN: Type analysis failed ;; ERROR: Function may read a register that is not set: a2 (defun race-time-save ((a0-0 race-time) (a1-0 task-control)) (local-vars diff --git a/test/decompiler/reference/jak2/decompiler-macros.gc b/test/decompiler/reference/jak2/decompiler-macros.gc index 31e1cdc975..f6ff064fc8 100644 --- a/test/decompiler/reference/jak2/decompiler-macros.gc +++ b/test/decompiler/reference/jak2/decompiler-macros.gc @@ -554,4 +554,145 @@ (defmacro .mfc0 (&rest stuff) `(empty) + ) + +;; pad +(defmacro cpad-pressed (pad-idx) + `(-> *cpad-list* cpads ,pad-idx button0-rel 0) + ) + +(defmacro cpad-hold (pad-idx) + `(-> *cpad-list* cpads ,pad-idx button0-abs 0) + ) + +(defmacro cpad-pressed? (pad-idx &rest buttons) + `(logtest? (cpad-pressed ,pad-idx) (pad-buttons ,@buttons)) + ) + +(defmacro cpad-hold? (pad-idx &rest buttons) + `(logtest? (cpad-hold ,pad-idx) (pad-buttons ,@buttons)) + ) + +(defmacro res-lump-data (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0)) + "Helper macro to get data from a res-lump without interpolation." + `(the-as ,type ((method-of-type res-lump get-property-data) + ,lump + ,name + 'interp + ,time + (the-as pointer #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-data-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time 0.0)) + "Helper macro to get start of data from a res-lump." + `(the-as ,type ((method-of-type res-lump get-property-data) + ,lump + ,name + 'exact + ,time + (the-as pointer #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-struct (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0)) + `(the-as ,type ((method-of-type res-lump get-property-struct) + ,lump + ,name + 'interp + ,time + (the-as structure #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-struct-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time 0.0)) + `(the-as ,type ((method-of-type res-lump get-property-struct) + ,lump + ,name + 'exact + ,time + (the-as structure #f) + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-value (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default (the-as uint128 0)) &key (time -1000000000.0)) + "Helper macro to get a value from a res-lump with no interpolation." + `(the-as ,type ((method-of-type res-lump get-property-value) + ,lump + ,name + 'interp + ,time + ,default + ,tag-ptr + *res-static-buf* + ) + ) + ) + +(defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0) &key (time -1000000000.0)) + "Helper macro to get a float from a res-lump with no interpolation." + `((method-of-type res-lump get-property-value-float) + ,lump + ,name + 'interp + ,time + ,default + ,tag-ptr + *res-static-buf* + ) + ) + +(defmacro seek! (place target rate) + "Macro to use seek in-place. place is the base, and where the result is stored." + `(set! ,place (seek ,place ,target ,rate)) + ) + +(defmacro seekl! (place target rate) + "Macro to use seekl in-place. place is the base, and where the result is stored." + `(set! ,place (seekl ,place ,target ,rate)) + ) + + +;; run the given function in a process right now. +;; will return to here when: +;; - you return +;; - you deactivate +;; - you go +;; - you throw to 'initialize +(defmacro run-now-in-process (proc func &rest args) + `((the (function _varargs_ object) run-function-in-process) + ,proc ,func ,@args + ) + ) + +;; sets the main thread of the given process to run the given thing. +;; this resets the main thread stack back to the top +(defmacro run-next-time-in-process (proc func &rest args) + `((the (function _varargs_ object) set-to-run) + (-> ,proc main-thread) ,func ,@args + ) + ) + +(defmacro send-event (proc msg &key (from (with-pp pp)) &rest params) + "Send an event to a process. This should be used over send-event-function" + + `(let ((event-data (new 'stack-no-clear 'event-message-block))) + (set! (-> event-data from) (process->ppointer ,from)) + (set! (-> event-data num-params) ,(length params)) + (set! (-> event-data message) ,msg) + ,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params) + (send-event-function ,proc event-data) + ) ) \ No newline at end of file diff --git a/test/decompiler/reference/jak2/kernel/gstate_REF.gc b/test/decompiler/reference/jak2/kernel/gstate_REF.gc index 8102727ef5..219ab13e6b 100644 --- a/test/decompiler/reference/jak2/kernel/gstate_REF.gc +++ b/test/decompiler/reference/jak2/kernel/gstate_REF.gc @@ -47,7 +47,7 @@ ;; ERROR: Unsupported inline assembly instruction kind - [jr t9] ;; ERROR: Unsupported inline assembly instruction kind - [sw v1, 0(sp)] (defun enter-state ((arg0 object) (arg1 object) (arg2 object) (arg3 object) (arg4 object) (arg5 object)) - (local-vars (s7-0 none) (sp-0 int) (ra-0 int) (sv-0 none)) + (local-vars (s7-0 none) (sp-0 int) (ra-0 int)) (with-pp (logclear! (-> pp mask) (process-mask sleep sleep-code)) (logior! (-> pp mask) (process-mask going)) diff --git a/test/decompiler/test_InstructionDecode.cpp b/test/decompiler/test_InstructionDecode.cpp index 9489c4aa24..7f49b6ceba 100644 --- a/test/decompiler/test_InstructionDecode.cpp +++ b/test/decompiler/test_InstructionDecode.cpp @@ -7,7 +7,7 @@ using namespace decompiler; TEST(InstructionDecode, VDIV) { init_opcode_info(); - LinkedObjectFile file; + LinkedObjectFile file(GameVersion::Jak1); u32 vdiv_test = 0b010010'1'10'01'10100'01010'01110111100; // ...... z y 20 10 LinkedWord vdiv_word(vdiv_test); @@ -17,7 +17,7 @@ TEST(InstructionDecode, VDIV) { TEST(InstructionDecode, VRSQRT) { init_opcode_info(); - LinkedObjectFile file; + LinkedObjectFile file(GameVersion::Jak1); u32 vdiv_test = 0b010010'1'10'01'10100'01010'01110111110; // ...... z y 20 10 LinkedWord vdiv_word(vdiv_test); @@ -27,7 +27,7 @@ TEST(InstructionDecode, VRSQRT) { TEST(InstructionDecode, VSQRT) { init_opcode_info(); - LinkedObjectFile file; + LinkedObjectFile file(GameVersion::Jak1); u32 vdiv_test = 0b010010'1'10'00'10100'00000'01110111101; // ...... z X 20 X LinkedWord vdiv_word(vdiv_test); @@ -37,7 +37,7 @@ TEST(InstructionDecode, VSQRT) { TEST(Instruction, IntelMaskMove) { init_opcode_info(); - LinkedObjectFile file; + LinkedObjectFile file(GameVersion::Jak1); u32 vmove_instr = 0b010010'1'1100'00001'00010'01100111100; LinkedWord vmove_word(vmove_instr); auto instr = decode_instruction(vmove_word, file, 0, 0); diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 64a5c8dd02..2390abf35f 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -15,7 +15,26 @@ "(method 10 process)", "(method 14 dead-pool)", /// GSTATE - "enter-state" // stack pointer asm + "enter-state", // stack pointer asm + // MATH + "logf", "log2f", "cube-root", "lerp-scale", "rand-vu-init", "rand-vu", "rand-vu-nostep", + // MATRIX + "matrix-axis-sin-cos-vu!", "matrix-axis-sin-cos!", "matrix-3x3-normalize!", + // DMA + "disasm-dma-list", + // PAD (bug) + "service-cpads", + // GEOMETRY asm + "closest-pt-in-triangle", "circle-circle-xz-intersect", "calculate-basis-functions-vector!", "curve-evaluate!", + // TIMER asm + "(method 9 clock)", + // math camera stupid broken gif crap and CLIP + "update-math-camera", "transform-point-vector!", "transform-point-qword!", "transform-point-vector-scale!", + // quad thing + "(method 3 connection-minimap)", + "(method 3 sky-vertex)", + // cache asm + "invalidate-cache-line" ], "skip_compile_states": {} diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index 20cdc3d209..bffc6cbb8f 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -406,8 +406,8 @@ int main(int argc, char* argv[]) { app.add_flag("-d,--dump_current_output", dump_current_output, "Output the current output to a folder, use in conjunction with the reference test " "files update script"); - app.add_flag("-m,--max_files", max_files, - "Limit the amount of files ran in a single test, picks the first N"); + app.add_option("-m,--max_files", max_files, + "Limit the amount of files ran in a single test, picks the first N"); app.validate_positionals(); CLI11_PARSE(app, argc, argv); @@ -446,6 +446,7 @@ int main(int argc, char* argv[]) { auto compare_result = compare(decompiler, files, dump_current_output); lg::info("Compared {} lines. {}/{} files passed.", compare_result.total_lines, compare_result.ok_files, compare_result.total_files); + lg::info("Dump? {}\n", dump_current_output); if (!compare_result.failing_files.empty()) { lg::error("Failing files:");