mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
clean up to gsound! (#709)
This commit is contained in:
parent
9ed1170046
commit
c76b51d805
|
@ -967,7 +967,8 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
|
|||
} else {
|
||||
auto casted0 = args.at(0);
|
||||
|
||||
if (!arg0_i && !arg0_u && arg0_type.typespec() != TypeSpec("binteger")) {
|
||||
if (!arg0_i && !arg0_u && arg0_type.typespec() != TypeSpec("binteger") &&
|
||||
!env.dts->ts.tc(TypeSpec("integer"), arg0_type.typespec())) {
|
||||
casted0 = pool.alloc_single_element_form<CastElement>(
|
||||
nullptr, TypeSpec(arg0_i ? "int" : "uint"), args.at(0));
|
||||
}
|
||||
|
@ -975,8 +976,9 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
|
|||
auto casted1 = pool.alloc_single_element_form<CastElement>(
|
||||
nullptr, TypeSpec(arg0_i ? "int" : "uint"), args.at(1));
|
||||
|
||||
auto new_form = pool.alloc_element<GenericElement>(
|
||||
FormElement* new_form = pool.alloc_element<GenericElement>(
|
||||
GenericOperator::make_fixed(FixedOperatorKind::ADDITION), casted0, casted1);
|
||||
|
||||
result->push_back(new_form);
|
||||
}
|
||||
}
|
||||
|
@ -3289,6 +3291,23 @@ Form* try_make_constant_from_int_for_compare(s64 value,
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<Form*> cast_to_64_bit(const std::vector<Form*>& forms,
|
||||
const std::vector<TypeSpec>& types,
|
||||
FormPool& pool,
|
||||
const Env& env) {
|
||||
std::vector<Form*> result;
|
||||
for (size_t i = 0; i < forms.size(); i++) {
|
||||
if (env.dts->ts.tc(TypeSpec("uint128"), types.at(i))) {
|
||||
result.push_back(cast_form(forms[i], TypeSpec("uint"), pool, env));
|
||||
} else if (env.dts->ts.tc(TypeSpec("int128"), types.at(i))) {
|
||||
result.push_back(cast_form(forms[i], TypeSpec("int"), pool, env));
|
||||
} else {
|
||||
result.push_back(forms[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
FormElement* ConditionElement::make_zero_check_generic(const Env& env,
|
||||
|
@ -3388,16 +3407,18 @@ FormElement* ConditionElement::make_equal_check_generic(const Env& env,
|
|||
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::EQ),
|
||||
forms_with_cast);
|
||||
} else {
|
||||
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::EQ),
|
||||
source_forms);
|
||||
return pool.alloc_element<GenericElement>(
|
||||
GenericOperator::make_fixed(FixedOperatorKind::EQ),
|
||||
cast_to_64_bit(source_forms, source_types, pool, env));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormElement* ConditionElement::make_not_equal_check_generic(const Env&,
|
||||
FormPool& pool,
|
||||
const std::vector<Form*>& source_forms,
|
||||
const std::vector<TypeSpec>&) {
|
||||
FormElement* ConditionElement::make_not_equal_check_generic(
|
||||
const Env& env,
|
||||
FormPool& pool,
|
||||
const std::vector<Form*>& source_forms,
|
||||
const std::vector<TypeSpec>& source_types) {
|
||||
assert(source_forms.size() == 2);
|
||||
// (!= thing '())
|
||||
auto ref = source_forms.at(1);
|
||||
|
@ -3409,8 +3430,9 @@ FormElement* ConditionElement::make_not_equal_check_generic(const Env&,
|
|||
pool.alloc_single_element_form<GenericElement>(
|
||||
nullptr, GenericOperator::make_fixed(FixedOperatorKind::NULLP), source_forms.at(0)));
|
||||
} else {
|
||||
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::NEQ),
|
||||
source_forms);
|
||||
return pool.alloc_element<GenericElement>(
|
||||
GenericOperator::make_fixed(FixedOperatorKind::NEQ),
|
||||
cast_to_64_bit(source_forms, source_types, pool, env));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4088,6 +4110,7 @@ void BranchElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
|
|||
m_op->to_string(env));
|
||||
}
|
||||
|
||||
assert(!m_op->likely());
|
||||
auto op = pool.alloc_element<TranslatedAsmBranch>(branch_condition, branch_delay,
|
||||
m_op->label_id(), m_op->likely());
|
||||
// fmt::print("rewrote (non-asm) as {}\n", op->to_string(env));
|
||||
|
|
|
@ -306,8 +306,17 @@ void ObjectFileDB::ir2_atomic_op_pass(const Config& config) {
|
|||
bool inline_asm =
|
||||
config.hacks.hint_inline_assembly_functions.find(func.guessed_name.to_string()) !=
|
||||
config.hacks.hint_inline_assembly_functions.end();
|
||||
|
||||
std::unordered_set<int> blocks_ending_in_asm_branch;
|
||||
auto asm_branch_it = config.hacks.blocks_ending_in_asm_branch_by_func_name.find(
|
||||
func.guessed_name.to_string());
|
||||
|
||||
if (asm_branch_it != config.hacks.blocks_ending_in_asm_branch_by_func_name.end()) {
|
||||
blocks_ending_in_asm_branch = asm_branch_it->second;
|
||||
}
|
||||
|
||||
auto ops = convert_function_to_atomic_ops(func, data.linked_data.labels, func.warnings,
|
||||
inline_asm);
|
||||
inline_asm, blocks_ending_in_asm_branch);
|
||||
func.ir2.atomic_ops = std::make_shared<FunctionAtomicOps>(std::move(ops));
|
||||
func.ir2.atomic_ops_succeeded = true;
|
||||
func.ir2.env.set_end_var(func.ir2.atomic_ops->end_op().return_var());
|
||||
|
|
|
@ -11,7 +11,10 @@ namespace decompiler {
|
|||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_1(const Instruction& i0, int idx, bool hint_inline_asm);
|
||||
std::unique_ptr<AtomicOp> convert_1(const Instruction& i0,
|
||||
int idx,
|
||||
bool hint_inline_asm,
|
||||
bool force_asm_branch);
|
||||
|
||||
//////////////////////
|
||||
// Register Helpers
|
||||
|
@ -364,7 +367,9 @@ std::unique_ptr<AtomicOp> make_asm_op(const Instruction& i0, int idx) {
|
|||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_1_allow_asm(const Instruction& i0, int idx) {
|
||||
auto as_normal = convert_1(i0, idx, false);
|
||||
// only used for delay slots, so fine to assume that this can never be an asm branch itself
|
||||
// as there are no branches in delay slots anywhere.
|
||||
auto as_normal = convert_1(i0, idx, false, false);
|
||||
if (as_normal) {
|
||||
return as_normal;
|
||||
}
|
||||
|
@ -426,15 +431,6 @@ std::unique_ptr<AtomicOp> make_branch(const IR2_Condition& condition,
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> make_branch_no_delay(const IR2_Condition& condition,
|
||||
bool likely,
|
||||
int dest_label,
|
||||
int my_idx) {
|
||||
assert(likely);
|
||||
IR2_BranchDelay delay(IR2_BranchDelay::Kind::NO_DELAY);
|
||||
return std::make_unique<BranchOp>(likely, condition, dest_label, delay, my_idx);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> make_asm_branch_no_delay(const IR2_Condition& condition,
|
||||
bool likely,
|
||||
int dest_label,
|
||||
|
@ -443,6 +439,19 @@ std::unique_ptr<AtomicOp> make_asm_branch_no_delay(const IR2_Condition& conditio
|
|||
return std::make_unique<AsmBranchOp>(likely, condition, dest_label, nullptr, my_idx);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> make_branch_no_delay(const IR2_Condition& condition,
|
||||
bool likely,
|
||||
int dest_label,
|
||||
int my_idx,
|
||||
bool force_asm_branch) {
|
||||
if (force_asm_branch) {
|
||||
return make_asm_branch_no_delay(condition, likely, dest_label, my_idx);
|
||||
}
|
||||
assert(likely);
|
||||
IR2_BranchDelay delay(IR2_BranchDelay::Kind::NO_DELAY);
|
||||
return std::make_unique<BranchOp>(likely, condition, dest_label, delay, my_idx);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> make_asm_branch(const IR2_Condition& condition,
|
||||
const Instruction& delay,
|
||||
bool likely,
|
||||
|
@ -705,12 +714,16 @@ std::unique_ptr<AtomicOp> convert_dsrl32_1(const Instruction& i0, int idx) {
|
|||
std::unique_ptr<AtomicOp> convert_likely_branch_1(const Instruction& i0,
|
||||
IR2_Condition::Kind kind,
|
||||
bool likely,
|
||||
int idx) {
|
||||
int idx,
|
||||
bool force_asm) {
|
||||
return make_branch_no_delay(IR2_Condition(kind, make_src_atom(i0.get_src(0).get_reg(), idx)),
|
||||
likely, i0.get_src(1).get_label(), idx);
|
||||
likely, i0.get_src(1).get_label(), idx, force_asm);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_beql_1(const Instruction& i0, int idx, bool likely) {
|
||||
std::unique_ptr<AtomicOp> convert_beql_1(const Instruction& i0,
|
||||
int idx,
|
||||
bool likely,
|
||||
bool force_asm) {
|
||||
auto s0 = i0.get_src(0).get_reg();
|
||||
auto s1 = i0.get_src(1).get_reg();
|
||||
auto dest = i0.get_src(2).get_label();
|
||||
|
@ -735,10 +748,13 @@ std::unique_ptr<AtomicOp> convert_beql_1(const Instruction& i0, int idx, bool li
|
|||
IR2_Condition(IR2_Condition::Kind::EQUAL, make_src_atom(s0, idx), make_src_atom(s1, idx));
|
||||
condition.make_flipped();
|
||||
}
|
||||
return make_branch_no_delay(condition, likely, dest, idx);
|
||||
return make_branch_no_delay(condition, likely, dest, idx, force_asm);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_bnel_1(const Instruction& i0, int idx, bool likely) {
|
||||
std::unique_ptr<AtomicOp> convert_bnel_1(const Instruction& i0,
|
||||
int idx,
|
||||
bool likely,
|
||||
bool force_asm) {
|
||||
auto s0 = i0.get_src(0).get_reg();
|
||||
auto s1 = i0.get_src(1).get_reg();
|
||||
auto dest = i0.get_src(2).get_label();
|
||||
|
@ -756,7 +772,7 @@ std::unique_ptr<AtomicOp> convert_bnel_1(const Instruction& i0, int idx, bool li
|
|||
make_src_atom(s1, idx));
|
||||
condition.make_flipped();
|
||||
}
|
||||
return make_branch_no_delay(condition, likely, dest, idx);
|
||||
return make_branch_no_delay(condition, likely, dest, idx, force_asm);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_subu_1(const Instruction& i0, int idx) {
|
||||
|
@ -771,7 +787,10 @@ std::unique_ptr<AtomicOp> convert_subu_1(const Instruction& i0, int idx) {
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicOp> convert_1(const Instruction& i0, int idx, bool hint_inline_asm) {
|
||||
std::unique_ptr<AtomicOp> convert_1(const Instruction& i0,
|
||||
int idx,
|
||||
bool hint_inline_asm,
|
||||
bool force_asm_branch) {
|
||||
switch (i0.kind) {
|
||||
case InstructionKind::OR:
|
||||
return convert_or_1(i0, idx);
|
||||
|
@ -895,15 +914,18 @@ std::unique_ptr<AtomicOp> convert_1(const Instruction& i0, int idx, bool hint_in
|
|||
case InstructionKind::MOVZ:
|
||||
return convert_cmov_1(i0, idx);
|
||||
case InstructionKind::BGTZL:
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::GREATER_THAN_ZERO_SIGNED, true, idx);
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::GREATER_THAN_ZERO_SIGNED, true, idx,
|
||||
force_asm_branch);
|
||||
case InstructionKind::BGEZL:
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::GEQ_ZERO_SIGNED, true, idx);
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::GEQ_ZERO_SIGNED, true, idx,
|
||||
force_asm_branch);
|
||||
case InstructionKind::BLTZL:
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::LESS_THAN_ZERO_SIGNED, true, idx);
|
||||
return convert_likely_branch_1(i0, IR2_Condition::Kind::LESS_THAN_ZERO_SIGNED, true, idx,
|
||||
force_asm_branch);
|
||||
case InstructionKind::BEQL:
|
||||
return convert_beql_1(i0, idx, true);
|
||||
return convert_beql_1(i0, idx, true, force_asm_branch);
|
||||
case InstructionKind::BNEL:
|
||||
return convert_bnel_1(i0, idx, true);
|
||||
return convert_bnel_1(i0, idx, true, force_asm_branch);
|
||||
case InstructionKind::SUBU:
|
||||
return convert_subu_1(i0, idx); // may fail
|
||||
default:
|
||||
|
@ -1787,7 +1809,8 @@ int convert_block_to_atomic_ops(int begin_idx,
|
|||
const std::vector<DecompilerLabel>& labels,
|
||||
FunctionAtomicOps* container,
|
||||
DecompWarnings& warnings,
|
||||
bool hint_inline_asm) {
|
||||
bool hint_inline_asm,
|
||||
bool block_ends_in_asm_branch) {
|
||||
container->block_id_to_first_atomic_op.push_back(container->ops.size());
|
||||
for (auto& instr = begin; instr < end;) {
|
||||
// how many instructions can we look at, at most?
|
||||
|
@ -1859,7 +1882,8 @@ int convert_block_to_atomic_ops(int begin_idx,
|
|||
|
||||
if (!converted) {
|
||||
// try 1 instruction
|
||||
op = convert_1(*instr, op_idx, hint_inline_asm);
|
||||
bool force_asm_branch = n_instr == 1 && block_ends_in_asm_branch;
|
||||
op = convert_1(*instr, op_idx, hint_inline_asm, force_asm_branch);
|
||||
if (op) {
|
||||
converted = true;
|
||||
length = 1;
|
||||
|
@ -1899,10 +1923,12 @@ int convert_block_to_atomic_ops(int begin_idx,
|
|||
return int(container->ops.size());
|
||||
}
|
||||
|
||||
FunctionAtomicOps convert_function_to_atomic_ops(const Function& func,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
DecompWarnings& warnings,
|
||||
bool hint_inline_asm) {
|
||||
FunctionAtomicOps convert_function_to_atomic_ops(
|
||||
const Function& func,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
DecompWarnings& warnings,
|
||||
bool hint_inline_asm,
|
||||
const std::unordered_set<int>& blocks_ending_in_asm_branches) {
|
||||
FunctionAtomicOps result;
|
||||
|
||||
int last_op = 0;
|
||||
|
@ -1912,8 +1938,9 @@ FunctionAtomicOps convert_function_to_atomic_ops(const Function& func,
|
|||
if (block.end_word > block.start_word) {
|
||||
auto begin = func.instructions.begin() + block.start_word;
|
||||
auto end = func.instructions.begin() + block.end_word;
|
||||
last_op = convert_block_to_atomic_ops(block.start_word, begin, end, labels, &result, warnings,
|
||||
hint_inline_asm);
|
||||
last_op = convert_block_to_atomic_ops(
|
||||
block.start_word, begin, end, labels, &result, warnings, hint_inline_asm,
|
||||
blocks_ending_in_asm_branches.find(i) != blocks_ending_in_asm_branches.end());
|
||||
if (i == int(func.basic_blocks.size()) - 1) {
|
||||
// we're the last block. insert the function end op.
|
||||
result.ops.push_back(std::make_unique<FunctionEndOp>(int(result.ops.size())));
|
||||
|
|
|
@ -48,13 +48,16 @@ int convert_block_to_atomic_ops(int begin_idx,
|
|||
const std::vector<DecompilerLabel>& labels,
|
||||
FunctionAtomicOps* container,
|
||||
DecompWarnings& warnings,
|
||||
bool inline_asm_hint = false);
|
||||
bool inline_asm_hint = false,
|
||||
bool block_ends_in_asm_branch = false);
|
||||
|
||||
/*!
|
||||
* Convert an entire function to AtomicOps
|
||||
*/
|
||||
FunctionAtomicOps convert_function_to_atomic_ops(const Function& func,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
DecompWarnings& warnings,
|
||||
bool hint_inline_asm);
|
||||
FunctionAtomicOps convert_function_to_atomic_ops(
|
||||
const Function& func,
|
||||
const std::vector<DecompilerLabel>& labels,
|
||||
DecompWarnings& warnings,
|
||||
bool hint_inline_asm,
|
||||
const std::unordered_set<int>& blocks_ending_in_asm_branches);
|
||||
} // namespace decompiler
|
|
@ -2841,10 +2841,10 @@
|
|||
:flag-assert #xe0000006c
|
||||
(:methods
|
||||
(new (symbol type basic vector) _type_ 0)
|
||||
(dummy-9 (_type_) int 9)
|
||||
(dummy-10 (_type_ sound-name) int 10)
|
||||
(dummy-11 (_type_ vector) int 11)
|
||||
(dummy-12 (_type_ int) int 12)
|
||||
(update! (_type_) int 9)
|
||||
(change-sound! (_type_ sound-name) int 10)
|
||||
(update-trans! (_type_ vector) int 11)
|
||||
(update-vol! (_type_ int) int 12)
|
||||
(stop! (_type_) int 13)
|
||||
)
|
||||
)
|
||||
|
@ -11534,9 +11534,9 @@
|
|||
(:methods
|
||||
(dummy-9 (_type_) none 9)
|
||||
(dummy-10 (_type_) none 10)
|
||||
(PERF-COUNTER-REG-ACCESS-11 (_type_) none 11)
|
||||
(PERF-COUNTER-REG-ACCESS-12 (_type_) none 12)
|
||||
(update-wait-stats-13 (_type_ uint uint uint) none 13)
|
||||
(reset! (_type_) none 11)
|
||||
(read! (_type_) none 12)
|
||||
(update-wait-stats (_type_ uint uint uint) none 13)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -13498,8 +13498,8 @@
|
|||
(:methods
|
||||
(init-cam-float-seeker (_type_ float float float float) none 9)
|
||||
(copy-cam-float-seeker (_type_ _type_) none 10)
|
||||
(TODO-RENAME-11 (_type_ float) none 11)
|
||||
(TODO-RENAME-12 (_type_ float) float 12)
|
||||
(update! (_type_ float) none 11)
|
||||
(jump-to-target! (_type_ float) float 12)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -13515,8 +13515,8 @@
|
|||
:size-assert #x3c
|
||||
:flag-assert #xb0000003c
|
||||
(:methods
|
||||
(TODO-RENAME-9 (_type_ vector float float float) none 9)
|
||||
(TODO-RENAME-10 (_type_ vector) none 10)
|
||||
(init! (_type_ vector float float float) none 9)
|
||||
(update! (_type_ vector) none 10)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -14637,7 +14637,7 @@
|
|||
(define-extern sound-buffer-dump (function int))
|
||||
(define-extern swap-sound-buffers (function vector vector float int))
|
||||
(define-extern free-last-sound-buffer-entry (function int))
|
||||
(define-extern sound-basic-cb function)
|
||||
(define-extern sound-basic-cb (function int (pointer int32) none))
|
||||
(define-extern sound-set-volume (function uint float int))
|
||||
(define-extern sound-set-reverb (function int float float uint int))
|
||||
(define-extern sound-pause (function sound-id int))
|
||||
|
|
|
@ -104,10 +104,6 @@
|
|||
// collide-mesh-h
|
||||
"(method 11 collide-mesh-cache)",
|
||||
|
||||
// actor-link-h (BUG)
|
||||
"(method 21 actor-link-info)", // BUG: sc cfg / cfg-ir bug
|
||||
"(method 20 actor-link-info)",
|
||||
|
||||
// collide-func
|
||||
"moving-sphere-triangle-intersect", // P: weird branching
|
||||
"collide-do-primitives", // P: asm branching
|
||||
|
@ -434,12 +430,8 @@
|
|||
// (these are NOT actually asm functions)
|
||||
"(method 15 sync-info)", // NEED *res-static-buf*
|
||||
"(method 15 sync-info-eased)", // NEED *res-static-buf*
|
||||
"(method 15 sync-info-paused)", // NEED *res-static-buf*
|
||||
"(method 15 sync-info-paused)" // NEED *res-static-buf*
|
||||
|
||||
// stats-h
|
||||
// May or may not be inline-asm but they are related to perf counter registers that only live on the PS2
|
||||
"(method 11 perf-stat)",
|
||||
"(method 12 perf-stat)"
|
||||
],
|
||||
|
||||
// these functions use pairs and the decompiler
|
||||
|
@ -539,6 +531,11 @@
|
|||
|
||||
"load-game-text-info": [12, 13, 14, 18],
|
||||
|
||||
"real-main-draw-hook": [75, 77]
|
||||
"real-main-draw-hook": [75, 77],
|
||||
|
||||
"(method 12 perf-stat)": [0],
|
||||
"(method 11 perf-stat)": [0],
|
||||
"(method 20 actor-link-info)": [2],
|
||||
"(method 21 actor-link-info)": [2]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,6 +334,8 @@
|
|||
[64, "vector"]
|
||||
],
|
||||
|
||||
"(method 20 actor-link-info)": [[16, "event-message-block"]],
|
||||
"(method 21 actor-link-info)": [[16, "event-message-block"]],
|
||||
"(method 23 actor-link-info)": [[16, "event-message-block"]],
|
||||
|
||||
"(method 24 actor-link-info)": [[16, "event-message-block"]],
|
||||
|
|
|
@ -637,8 +637,6 @@
|
|||
|
||||
"num-func-chan": [[8, "v1", "joint-control-channel"]],
|
||||
|
||||
"cspace-by-name-no-fail": [[[0, 100], "v0", "cspace"]],
|
||||
|
||||
"shrubbery-login-post-texture": [
|
||||
//[[13, 41], "a3", "qword"],
|
||||
// [[13, 41], "a2", "qword"]
|
||||
|
@ -656,7 +654,6 @@
|
|||
|
||||
"(method 3 sparticle-cpuinfo)": [[106, "f0", "float"]],
|
||||
|
||||
"cspace-by-name-no-fail": [[[0, 100], "v0", "cspace"]],
|
||||
|
||||
"camera-teleport-to-entity": [[9, "a0", "transform"]],
|
||||
|
||||
|
|
|
@ -1711,6 +1711,16 @@
|
|||
}
|
||||
},
|
||||
|
||||
"(method 20 actor-link-info)": {
|
||||
"args": ["obj", "message"],
|
||||
"vars": {
|
||||
"s4-0":"iter",
|
||||
"s5-0":"result",
|
||||
"a0-1":"proc",
|
||||
"a1-1":"msg-block"
|
||||
}
|
||||
},
|
||||
|
||||
// LEVEL
|
||||
"lookup-level-info": {
|
||||
"args": ["name"],
|
||||
|
@ -2389,5 +2399,17 @@
|
|||
"s2-0":"grav-rt-body",
|
||||
"a1-5":"vel-rt-body"
|
||||
}
|
||||
},
|
||||
|
||||
"(method 11 cam-float-seeker)" : {
|
||||
"args": ["obj", "offset"],
|
||||
"vars": {
|
||||
"f1-2":"pos-error",
|
||||
"f0-5":"partial-velocity-limit",
|
||||
"f1-3":"daccel",
|
||||
"f1-6":"abs-vel",
|
||||
"f0-6":"abs-vel-limit",
|
||||
"f0-10":"dpos"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,9 @@
|
|||
)
|
||||
)
|
||||
|
||||
;; definition of type cam-float-seeker
|
||||
;; cam-float-seeker moves value toward target in a smooth way, with second order dynamics.
|
||||
;; The acceleration is proportional to the error.
|
||||
;; This isn't stable by itself, so there is a velocity limit (proportional to distance) applied.
|
||||
(deftype cam-float-seeker (structure)
|
||||
((target float :offset-assert 0)
|
||||
(value float :offset-assert 4)
|
||||
|
@ -129,8 +131,8 @@
|
|||
(:methods
|
||||
(init-cam-float-seeker (_type_ float float float float) none 9)
|
||||
(copy-cam-float-seeker (_type_ _type_) none 10)
|
||||
(TODO-RENAME-11 (_type_ float) none 11)
|
||||
(TODO-RENAME-12 (_type_ float) float 12)
|
||||
(update! (_type_ float) none 11)
|
||||
(jump-to-target! (_type_ float) float 12)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -158,35 +160,37 @@
|
|||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 11 of type cam-float-seeker
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defmethod TODO-RENAME-11 cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
(let ((f0-0 0.0))
|
||||
)
|
||||
(let ((f0-1 0.0))
|
||||
)
|
||||
(let* ((f1-2 (- (+ (-> obj target) arg0) (-> obj value)))
|
||||
(f0-5 (* (-> obj max-partial) (fabs f1-2)))
|
||||
(defmethod update! cam-float-seeker ((obj cam-float-seeker) (offset float))
|
||||
"Seek toward target + offset"
|
||||
(let* ((pos-error (- (+ (-> obj target) offset) (-> obj value)))
|
||||
;; the velocity limit based on distance to target
|
||||
(partial-velocity-limit (* (-> obj max-partial) (fabs pos-error)))
|
||||
)
|
||||
(let ((f1-3 (* f1-2 (* (-> obj accel) (-> *display* time-adjust-ratio)))))
|
||||
(set! (-> obj vel) (+ (-> obj vel) f1-3))
|
||||
|
||||
;; apply acceleration to velocity
|
||||
(let ((daccel (* pos-error (* (-> obj accel) (-> *display* time-adjust-ratio)))))
|
||||
(+! (-> obj vel) daccel)
|
||||
)
|
||||
(let ((f1-6 (fabs (-> obj vel)))
|
||||
(f0-6 (fmin f0-5 (-> obj max-vel)))
|
||||
|
||||
;; limit velocity using max-vel and the partial limit
|
||||
(let ((abs-vel (fabs (-> obj vel)))
|
||||
(abs-vel-limit (fmin partial-velocity-limit (-> obj max-vel)))
|
||||
)
|
||||
(if (< f0-6 f1-6)
|
||||
(set! (-> obj vel) (* (-> obj vel) (/ f0-6 f1-6)))
|
||||
(if (< abs-vel-limit abs-vel)
|
||||
(set! (-> obj vel) (* (-> obj vel) (/ abs-vel-limit abs-vel)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((f0-10 (* (-> obj vel) (-> *display* time-adjust-ratio))))
|
||||
(set! (-> obj value) (+ (-> obj value) f0-10))
|
||||
|
||||
;; update position
|
||||
(let ((dpos (* (-> obj vel) (-> *display* time-adjust-ratio))))
|
||||
(+! (-> obj value) dpos)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 12 of type cam-float-seeker
|
||||
(defmethod TODO-RENAME-12 cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
(defmethod jump-to-target! cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
"Jump to target + arg0 and set velocity to 0"
|
||||
(set! (-> obj value) (+ (-> obj target) arg0))
|
||||
(let ((f0-2 0.0))
|
||||
(set! (-> obj vel) f0-2)
|
||||
|
@ -194,7 +198,8 @@
|
|||
)
|
||||
)
|
||||
|
||||
;; definition of type cam-vector-seeker
|
||||
;; very similar to cam-float-seeker but works on an
|
||||
;; entire vector.
|
||||
(deftype cam-vector-seeker (structure)
|
||||
((target vector :inline :offset-assert 0)
|
||||
(value vector :inline :offset-assert 16)
|
||||
|
@ -207,15 +212,12 @@
|
|||
:size-assert #x3c
|
||||
:flag-assert #xb0000003c
|
||||
(:methods
|
||||
(TODO-RENAME-9 (_type_ vector float float float) none 9)
|
||||
(TODO-RENAME-10 (_type_ vector) none 10)
|
||||
(init! (_type_ vector float float float) none 9)
|
||||
(update! (_type_ vector) none 10)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 9 of type cam-vector-seeker
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; Used lq/sq
|
||||
(defmethod TODO-RENAME-9 cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
|
||||
(defmethod init! cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
|
||||
(cond
|
||||
(arg0
|
||||
(set! (-> obj target quad) (-> arg0 quad))
|
||||
|
@ -230,16 +232,12 @@
|
|||
(set! (-> obj accel) arg1)
|
||||
(set! (-> obj max-vel) arg2)
|
||||
(set! (-> obj max-partial) arg3)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
|
||||
;; definition for method 10 of type cam-vector-seeker
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; TODO - vector-float*! replacement
|
||||
(defmethod TODO-RENAME-10 cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector))
|
||||
(defmethod update! cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector))
|
||||
(let ((gp-0 (new 'stack-no-clear 'vector)))
|
||||
0.0
|
||||
(cond
|
||||
(arg0
|
||||
(vector+! gp-0 (-> obj target) arg0)
|
||||
|
@ -271,7 +269,6 @@
|
|||
(none)
|
||||
)
|
||||
|
||||
;; definition of type cam-rotation-tracker
|
||||
(deftype cam-rotation-tracker (structure)
|
||||
((inv-mat matrix :inline :offset-assert 0)
|
||||
(no-follow basic :offset-assert 64)
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
(:methods
|
||||
(dummy-9 (_type_) none 9)
|
||||
(dummy-10 (_type_) none 10)
|
||||
(PERF-COUNTER-REG-ACCESS-11 (_type_) none 11)
|
||||
(PERF-COUNTER-REG-ACCESS-12 (_type_) none 12)
|
||||
(update-wait-stats-13 (_type_ uint uint uint) none 13)
|
||||
(reset! (_type_) none 11)
|
||||
(read! (_type_) none 12)
|
||||
(update-wait-stats (_type_ uint uint uint) none 13)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -68,17 +68,45 @@
|
|||
;; failed to figure out what this is:
|
||||
(set! (-> perf-stat-array heap-base) (the-as uint 52))
|
||||
|
||||
(defmethod PERF-COUNTER-REG-ACCESS-11 perf-stat ((obj perf-stat))
|
||||
(defmethod reset! perf-stat ((obj perf-stat))
|
||||
"Perfomance counters are not implemented, so this does nothing."
|
||||
#|
|
||||
(let ((v1-0 (-> obj ctrl)))
|
||||
(+! (-> obj count) 1)
|
||||
(b! (zero? v1-0) cfg-2)
|
||||
(.mtc0 Perf r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mtpc pcr0 r0-0)
|
||||
(.mtpc pcr1 r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mtc0 Perf v1-0)
|
||||
)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(label cfg-2)
|
||||
|#
|
||||
(none)
|
||||
)
|
||||
|
||||
(defmethod PERF-COUNTER-REG-ACCESS-12 perf-stat ((obj perf-stat))
|
||||
(defmethod read! perf-stat ((obj perf-stat))
|
||||
"Perfomance counters are not implemented, so this does nothing."
|
||||
#|
|
||||
(b! (zero? (-> obj ctrl)) cfg-2)
|
||||
(.mtc0 Perf r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mfpc v1-1 pcr0)
|
||||
(+! (-> obj accum0) (the-as uint v1-1))
|
||||
(.mfpc v1-3 pcr1)
|
||||
(+! (-> obj accum1) (the-as uint v1-3))
|
||||
(label cfg-2)
|
||||
|#
|
||||
(none)
|
||||
)
|
||||
|
||||
(defmethod update-wait-stats-13 perf-stat ((obj perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
||||
(defmethod update-wait-stats perf-stat ((obj perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
||||
(when (nonzero? (-> obj ctrl))
|
||||
(set! (-> obj to-vu0-waits) (+ (-> obj to-vu0-waits) arg0))
|
||||
(set! (-> obj to-spr-waits) (+ (-> obj to-spr-waits) arg1))
|
||||
|
|
|
@ -5,10 +5,21 @@
|
|||
;; name in dgo: actor-link-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; The exact details of actor-link-h are not yet understood, but this system links entities to processes.
|
||||
;; The exact details of actor-link-h are not yet understood, but this system caches lookups for entities/process.
|
||||
;; Each entity has a res-lump. Some entities may reference other entities. This is done with an element in a res-lump
|
||||
;; than contains named lists (possibly of size 1) of other entities. These lists may store entities by a name, or by an
|
||||
;; actor id (AID).
|
||||
|
||||
;; One entity may have a reference to another entity, either by name or by ID.
|
||||
;; Some common ones are next-actor and prev-actor.
|
||||
;; This process is slow: it involves going from a process, to its entity, to doing a res-lump, deciding if you have an AID/string,
|
||||
;; then looking up the other actor by name, or AID. Lookup by name is extremely slow, as it involves checking each actor's name
|
||||
;; a res lookup per every actor in every level. Lookup by aid isn't bad, but is still a binary search through all actors.
|
||||
|
||||
;; The next-actor and prev-actor res build a linked list of actors.
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Initial Lookup Functions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; these functions find actors before we've built the links.
|
||||
|
||||
(defun entity-actor-lookup ((lump res-lump) (name symbol) (idx int))
|
||||
"Given an entity (the res-lump), look up a reference to another entity and return that entity."
|
||||
|
@ -29,6 +40,7 @@
|
|||
)
|
||||
)
|
||||
)
|
||||
|
||||
(the-as entity-actor
|
||||
;; check in range, and lookup succesful
|
||||
(when (and v1-1 (< idx (the-as int (-> sv-16 elt-count))))
|
||||
|
@ -62,7 +74,11 @@
|
|||
)
|
||||
|
||||
;; entity-actors are part of a linked list of entities.
|
||||
;; It is not yet known where these are allocated.
|
||||
;; these prevent you from looking up next-actor, prev-actor again and again to iterate.
|
||||
;; The actor-link-info for an entity is stored in that res-lump's "extra"
|
||||
;; of course, this only works for cases where each entity has at most 1 process.
|
||||
|
||||
;; These are allocated on the process heap of the entity's process.
|
||||
|
||||
(deftype actor-link-info (basic)
|
||||
((process process :offset-assert 4) ;; process for this entity
|
||||
|
@ -94,6 +110,10 @@
|
|||
)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;
|
||||
;; Link Setup
|
||||
;;;;;;;;;;;;;;;;
|
||||
|
||||
(defmethod next-actor entity-actor ((obj entity-actor))
|
||||
"Utility function to look up the next actor in the list, assuming we don't have actor-link-info yet."
|
||||
;; look up reference to next-actor - this is slow.
|
||||
|
@ -124,6 +144,9 @@
|
|||
)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
;; Access
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; These methods can now be used to get next/prev more efficiently, without having to do a res lookup.
|
||||
(defmethod get-next actor-link-info ((obj actor-link-info))
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
;; name in dgo: bsp-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; The level's layout is stored in a BSP.
|
||||
;; There is a bsp-header that contains the actual nodes
|
||||
;; as well as lists of entities and other stuff found in the level.
|
||||
;; As a result, it is more than just a BSP.
|
||||
;; The final file in the level DGO is the BSP, and is the largest file.
|
||||
|
||||
(declare-type entity-camera basic)
|
||||
|
||||
(deftype bsp-node (structure)
|
||||
|
@ -59,6 +65,7 @@
|
|||
)
|
||||
)
|
||||
|
||||
;; seems to be unused?
|
||||
(deftype game-level (basic)
|
||||
((master-bsp basic :offset-assert 4)
|
||||
)
|
||||
|
|
|
@ -399,10 +399,10 @@
|
|||
:flag-assert #xe0000006c
|
||||
(:methods
|
||||
(new (symbol type basic vector) _type_ 0)
|
||||
(dummy-9 (_type_) int 9)
|
||||
(dummy-10 (_type_ sound-name) int 10)
|
||||
(dummy-11 (_type_ vector) int 11)
|
||||
(dummy-12 (_type_ int) int 12)
|
||||
(update! (_type_) int 9)
|
||||
(change-sound! (_type_ sound-name) int 10)
|
||||
(update-trans! (_type_ vector) int 11)
|
||||
(update-vol! (_type_ int) int 12)
|
||||
(stop! (_type_) int 13)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
;; name in dgo: gsound
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
|
||||
;; The sound playback stuff is all on the IOP so we use IOP RPCs to control it.
|
||||
;; Ther is a "player" that plays sound effects, and a "loader" that takes care of loading banks.
|
||||
(define *sound-player-rpc* (new 'global 'rpc-buffer-pair (the uint (size-of sound-rpc-union)) (the-as uint 128) RPC-SOUND-PLAYER))
|
||||
(define *sound-loader-rpc* (new 'global 'rpc-buffer-pair (the uint (size-of sound-rpc-union)) (the-as uint 1) RPC-SOUND-LOADER))
|
||||
|
||||
|
@ -101,6 +102,8 @@
|
|||
0
|
||||
)
|
||||
|
||||
;; Note: we check the IRX version on load to make sure that the OVERLORD driver is the right version
|
||||
;; and has loaded successfully.
|
||||
(check-irx-version)
|
||||
|
||||
|
||||
|
@ -276,7 +279,11 @@
|
|||
0
|
||||
)
|
||||
|
||||
;; sound-basic-cb
|
||||
(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32)))
|
||||
"This function is unused."
|
||||
(set! (-> arg1 0) arg0)
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun sound-trans-convert ((dest vector3w) (src vector))
|
||||
(let ((vec (if src src (ear-trans))))
|
||||
|
@ -327,6 +334,17 @@
|
|||
0
|
||||
)
|
||||
|
||||
(defun sound-set-reverb ((arg0 int) (arg1 float) (arg2 float) (arg3 uint))
|
||||
(let ((cmd (the-as sound-rpc-set-reverb (get-sound-buffer-entry))))
|
||||
(set! (-> cmd command) (sound-command set-reverb))
|
||||
(set! (-> cmd core) arg3)
|
||||
(set! (-> cmd reverb) arg0)
|
||||
(set! (-> cmd left) (the-as uint (the int (* 32767.0 arg1))))
|
||||
(set! (-> cmd right) (the-as uint (the int (* 32767.0 arg2))))
|
||||
)
|
||||
0
|
||||
)
|
||||
|
||||
(defun sound-set-ear-trans ((ear-trans vector) (cam-trans vector) (cam-angle float))
|
||||
|
||||
(let ((cmd (the sound-rpc-set-ear-trans (get-sound-buffer-entry))))
|
||||
|
@ -591,17 +609,18 @@
|
|||
|
||||
(defun-extern effect-param->sound-spec sound-spec sound-play-parms int sound-spec)
|
||||
(define-extern *debug-effect-control* symbol)
|
||||
(defmethod dummy-9 ambient-sound ((obj ambient-sound))
|
||||
(defmethod update! ambient-sound ((obj ambient-sound))
|
||||
"Called once per frame to update the sound playback"
|
||||
|
||||
(if (not *ambient-sound-class*)
|
||||
(return (the int #f))
|
||||
)
|
||||
(return (the int #f))
|
||||
)
|
||||
(cond
|
||||
((-> obj spec)
|
||||
(when (or (< (the-as int (-> obj time-base)) 0)
|
||||
(>= (the-as int (-> *display* base-frame-counter))
|
||||
(the-as int (-> obj play-time)))
|
||||
)
|
||||
)
|
||||
(when (>= (the-as int (-> obj time-base)) 0)
|
||||
(set! (-> obj play-time) (+ (-> *display* base-frame-counter)
|
||||
(-> obj time-base)
|
||||
|
@ -610,64 +629,64 @@
|
|||
(set! (-> obj playing-id) (new-sound-id))
|
||||
)
|
||||
(let ((spec (-> obj spec)))
|
||||
(when (= spec *ambient-spec*)
|
||||
(set! (-> spec volume) (-> obj volume))
|
||||
(set! (-> spec pitch-mod) (-> obj pitch))
|
||||
(set! (-> spec bend) 0)
|
||||
(set! (-> spec sound-name) (-> obj name))
|
||||
(set! (-> spec fo-max) (-> obj falloff-far))
|
||||
(set! (-> spec mask) (the-as uint 0))
|
||||
(if (-> obj params)
|
||||
(when (= spec *ambient-spec*)
|
||||
(set! (-> spec volume) (-> obj volume))
|
||||
(set! (-> spec pitch-mod) (-> obj pitch))
|
||||
(set! (-> spec bend) 0)
|
||||
(set! (-> spec sound-name) (-> obj name))
|
||||
(set! (-> spec fo-max) (-> obj falloff-far))
|
||||
(set! (-> spec mask) (the-as uint 0))
|
||||
(if (-> obj params)
|
||||
(effect-param->sound-spec spec (-> obj params) (-> obj param-count))
|
||||
)
|
||||
)
|
||||
(if (and (nonzero? (-> spec fo-max))
|
||||
(< (* 4096.0 (the float (-> spec fo-max)))
|
||||
(vector-vector-distance (ear-trans) (-> obj trans))))
|
||||
)
|
||||
(if (and (nonzero? (-> spec fo-max))
|
||||
(< (* 4096.0 (the float (-> spec fo-max)))
|
||||
(vector-vector-distance (ear-trans) (-> obj trans))))
|
||||
(return 0)
|
||||
)
|
||||
(when (and *debug-effect-control* (>= (the-as int (-> obj time-base)) 0))
|
||||
(with-pp
|
||||
(format #t "(~5D) effect sound ~A ~G "
|
||||
(-> *display* base-frame-counter)
|
||||
(-> pp name)
|
||||
(-> spec sound-name-char))
|
||||
(format #t "volume: ~f pitch-mod: ~f~%"
|
||||
(* (1/ 10.24) (the float (-> spec volume)))
|
||||
(* 0.000656168 (the float (-> spec pitch-mod))))
|
||||
)
|
||||
(when (and *debug-effect-control* (>= (the-as int (-> obj time-base)) 0))
|
||||
(with-pp
|
||||
(format #t "(~5D) effect sound ~A ~G "
|
||||
(-> *display* base-frame-counter)
|
||||
(-> pp name)
|
||||
(-> spec sound-name-char))
|
||||
(format #t "volume: ~f pitch-mod: ~f~%"
|
||||
(* (1/ 10.24) (the float (-> spec volume)))
|
||||
(* 0.000656168 (the float (-> spec pitch-mod))))
|
||||
)
|
||||
(let ((spec-volume (-> spec volume)))
|
||||
(set! (-> spec volume) (-> obj volume))
|
||||
(set! (-> obj playing-id) (sound-play-by-spec spec (-> obj playing-id) (-> obj trans)))
|
||||
(set! (-> spec volume) spec-volume)
|
||||
)
|
||||
)
|
||||
(let ((spec-volume (-> spec volume)))
|
||||
(set! (-> spec volume) (-> obj volume))
|
||||
(set! (-> obj playing-id) (sound-play-by-spec spec (-> obj playing-id) (-> obj trans)))
|
||||
(set! (-> spec volume) spec-volume)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(cond
|
||||
((< (the-as int (-> obj time-base)) 0)
|
||||
(set! (-> obj playing-id) (sound-play-by-name
|
||||
(-> obj name)
|
||||
(-> obj playing-id)
|
||||
(-> obj volume)
|
||||
(-> obj pitch)
|
||||
0
|
||||
(the-as uint 1)
|
||||
(-> obj trans)))
|
||||
(-> obj name)
|
||||
(-> obj playing-id)
|
||||
(-> obj volume)
|
||||
(-> obj pitch)
|
||||
0
|
||||
(the-as uint 1)
|
||||
(-> obj trans)))
|
||||
)
|
||||
(else
|
||||
(when (>= (the-as int (-> *display* base-frame-counter))
|
||||
(the-as int (-> obj play-time)))
|
||||
(set! (-> obj playing-id) (sound-play-by-name
|
||||
(-> obj name)
|
||||
(new-sound-id)
|
||||
(-> obj volume)
|
||||
(-> obj pitch)
|
||||
0
|
||||
(the-as uint 1)
|
||||
(-> obj trans)))
|
||||
(-> obj name)
|
||||
(new-sound-id)
|
||||
(-> obj volume)
|
||||
(-> obj pitch)
|
||||
0
|
||||
(the-as uint 1)
|
||||
(-> obj trans)))
|
||||
(set! (-> obj play-time) (+ (-> *display* base-frame-counter)
|
||||
(-> obj time-base)
|
||||
(the-as uint (rand-vu-int-count (the-as int (-> obj time-random))))
|
||||
|
@ -687,8 +706,8 @@
|
|||
0
|
||||
)
|
||||
|
||||
(defmethod dummy-11 ambient-sound ((obj ambient-sound) (sound-trans vector))
|
||||
|
||||
(defmethod update-trans! ambient-sound ((obj ambient-sound) (sound-trans vector))
|
||||
"Update the position of the thing playing the sound"
|
||||
(set! (-> obj trans quad) (-> sound-trans quad))
|
||||
(when (nonzero? (-> obj playing-id))
|
||||
(let ((cmd (the sound-rpc-set-param (get-sound-buffer-entry))))
|
||||
|
@ -704,7 +723,23 @@
|
|||
0
|
||||
)
|
||||
|
||||
(defmethod dummy-10 ambient-sound ((obj ambient-sound) (name sound-name))
|
||||
(defmethod update-vol! ambient-sound ((obj ambient-sound) (arg0 int))
|
||||
"Update the volume of the sound"
|
||||
(when (nonzero? (-> obj playing-id))
|
||||
(let ((cmd (the-as sound-rpc-set-param (get-sound-buffer-entry))))
|
||||
(set! (-> cmd command) (sound-command set-param))
|
||||
(set! (-> cmd id) (-> obj playing-id))
|
||||
(set! (-> cmd parms volume) (the int (* 10.24 (the float arg0))))
|
||||
(set! (-> cmd parms mask) (the-as uint 1))
|
||||
(-> cmd id)
|
||||
)
|
||||
)
|
||||
(set! (-> obj volume) (the int (* 10.24 (the float arg0))))
|
||||
0
|
||||
)
|
||||
|
||||
(defmethod change-sound! ambient-sound ((obj ambient-sound) (name sound-name))
|
||||
"Change the sound being played"
|
||||
(when (not (sound-name= (-> obj name) name))
|
||||
(stop! obj)
|
||||
(set! (-> obj playing-id) (new-sound-id))
|
||||
|
@ -1007,6 +1042,3 @@
|
|||
(flava-table-add 'credits
|
||||
(49 2)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-perm *target* target #f)
|
||||
|
||||
(deftype sidekick (process-drawable)
|
||||
((control control-info :offset 112)
|
||||
(anim-seed uint64 :offset 192)
|
||||
|
@ -54,7 +56,6 @@
|
|||
;; inherited inspect of process-drawable
|
||||
)
|
||||
|
||||
(define-perm *target* target #f)
|
||||
(define-perm *sidekick* sidekick #f)
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
;; name in dgo: progress-h
|
||||
;; dgos: GAME, ENGINE
|
||||
|
||||
;; progress screen display-state enum:
|
||||
;; 32 - nocd
|
||||
;; 33 - dirtycd
|
||||
|
||||
(deftype count-info (structure)
|
||||
((money-count int32 :offset-assert 0)
|
||||
(buzzer-count int32 :offset-assert 4)
|
||||
|
|
|
@ -164,7 +164,7 @@ std::unique_ptr<FormRegressionTest::TestData> FormRegressionTest::make_function(
|
|||
|
||||
// convert instruction to atomic ops
|
||||
DecompWarnings warnings;
|
||||
auto ops = convert_function_to_atomic_ops(test->func, program.labels, warnings, false);
|
||||
auto ops = convert_function_to_atomic_ops(test->func, program.labels, warnings, false, {});
|
||||
test->func.ir2.atomic_ops = std::make_shared<FunctionAtomicOps>(std::move(ops));
|
||||
test->func.ir2.atomic_ops_succeeded = true;
|
||||
test->func.ir2.env.set_end_var(test->func.ir2.atomic_ops->end_op().return_var());
|
||||
|
|
|
@ -212,4 +212,25 @@
|
|||
(set! (-> pp next-state) ,next-state)
|
||||
((the (function _varargs_ object) enter-state) ,@args)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro static-sound-name (str)
|
||||
"Convert a string constant to a static sound-name."
|
||||
|
||||
;; all this is done at compile-time so we can come up with 2
|
||||
;; 64-bit constants to use
|
||||
(when (> (string-length str) 16)
|
||||
(error "static-sound-name got a string that is too long")
|
||||
)
|
||||
(let ((lo-val 0)
|
||||
(hi-val 0)
|
||||
)
|
||||
(dotimes (i (string-length str))
|
||||
(if (>= i 8)
|
||||
(+! hi-val (ash (string-ref str i) (* 8 (- i 8))))
|
||||
(+! lo-val (ash (string-ref str i) (* 8 i)))
|
||||
)
|
||||
)
|
||||
`(new 'static 'sound-name :lo ,lo-val :hi ,hi-val)
|
||||
)
|
||||
)
|
|
@ -218,8 +218,8 @@
|
|||
(:methods
|
||||
(init-cam-float-seeker (_type_ float float float float) none 9)
|
||||
(copy-cam-float-seeker (_type_ _type_) none 10)
|
||||
(TODO-RENAME-11 (_type_ float) none 11)
|
||||
(TODO-RENAME-12 (_type_ float) float 12)
|
||||
(update! (_type_ float) none 11)
|
||||
(jump-to-target! (_type_ float) float 12)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -269,32 +269,33 @@
|
|||
|
||||
;; definition for method 11 of type cam-float-seeker
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defmethod TODO-RENAME-11 cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
(defmethod update! cam-float-seeker ((obj cam-float-seeker) (offset float))
|
||||
0.0
|
||||
0.0
|
||||
(let* ((f1-2 (- (+ (-> obj target) arg0) (-> obj value)))
|
||||
(f0-5 (* (-> obj max-partial) (fabs f1-2)))
|
||||
(let* ((pos-error (- (+ (-> obj target) offset) (-> obj value)))
|
||||
(partial-velocity-limit (* (-> obj max-partial) (fabs pos-error)))
|
||||
)
|
||||
(let ((f1-3 (* f1-2 (* (-> obj accel) (-> *display* time-adjust-ratio)))))
|
||||
(+! (-> obj vel) f1-3)
|
||||
(let
|
||||
((daccel (* pos-error (* (-> obj accel) (-> *display* time-adjust-ratio)))))
|
||||
(+! (-> obj vel) daccel)
|
||||
)
|
||||
(let ((f1-6 (fabs (-> obj vel)))
|
||||
(f0-6 (fmin f0-5 (-> obj max-vel)))
|
||||
(let ((abs-vel (fabs (-> obj vel)))
|
||||
(abs-vel-limit (fmin partial-velocity-limit (-> obj max-vel)))
|
||||
)
|
||||
(if (< f0-6 f1-6)
|
||||
(set! (-> obj vel) (* (-> obj vel) (/ f0-6 f1-6)))
|
||||
(if (< abs-vel-limit abs-vel)
|
||||
(set! (-> obj vel) (* (-> obj vel) (/ abs-vel-limit abs-vel)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((f0-10 (* (-> obj vel) (-> *display* time-adjust-ratio))))
|
||||
(+! (-> obj value) f0-10)
|
||||
(let ((dpos (* (-> obj vel) (-> *display* time-adjust-ratio))))
|
||||
(+! (-> obj value) dpos)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 12 of type cam-float-seeker
|
||||
(defmethod TODO-RENAME-12 cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
(defmethod jump-to-target! cam-float-seeker ((obj cam-float-seeker) (arg0 float))
|
||||
(set! (-> obj value) (+ (-> obj target) arg0))
|
||||
(let ((f0-2 0.0))
|
||||
(set! (-> obj vel) f0-2)
|
||||
|
@ -315,8 +316,8 @@
|
|||
:size-assert #x3c
|
||||
:flag-assert #xb0000003c
|
||||
(:methods
|
||||
(TODO-RENAME-9 (_type_ vector float float float) none 9)
|
||||
(TODO-RENAME-10 (_type_ vector) none 10)
|
||||
(init! (_type_ vector float float float) none 9)
|
||||
(update! (_type_ vector) none 10)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -336,7 +337,7 @@
|
|||
;; INFO: Return type mismatch int vs none.
|
||||
;; Used lq/sq
|
||||
(defmethod
|
||||
TODO-RENAME-9
|
||||
init!
|
||||
cam-vector-seeker
|
||||
((obj cam-vector-seeker) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
|
||||
(cond
|
||||
|
@ -359,10 +360,7 @@
|
|||
|
||||
;; definition for method 10 of type cam-vector-seeker
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defmethod
|
||||
TODO-RENAME-10
|
||||
cam-vector-seeker
|
||||
((obj cam-vector-seeker) (arg0 vector))
|
||||
(defmethod update! cam-vector-seeker ((obj cam-vector-seeker) (arg0 vector))
|
||||
(let ((gp-0 (new 'stack-no-clear 'vector)))
|
||||
0.0
|
||||
(cond
|
||||
|
@ -745,3 +743,7 @@
|
|||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -67,9 +67,9 @@
|
|||
(:methods
|
||||
(dummy-9 (_type_) none 9)
|
||||
(dummy-10 (_type_) none 10)
|
||||
(PERF-COUNTER-REG-ACCESS-11 (_type_) none 11)
|
||||
(PERF-COUNTER-REG-ACCESS-12 (_type_) none 12)
|
||||
(update-wait-stats-13 (_type_ uint uint uint) none 13)
|
||||
(reset! (_type_) none 11)
|
||||
(read! (_type_) none 12)
|
||||
(update-wait-stats (_type_ uint uint uint) none 13)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -114,15 +114,64 @@
|
|||
(set! (-> perf-stat-array heap-base) (the-as uint 52))
|
||||
|
||||
;; definition for method 11 of type perf-stat
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.l]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.p]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mtpc pcr0, r0]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mtpc pcr1, r0]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.l]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.p]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, v1]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.l]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.p]
|
||||
(defmethod reset! perf-stat ((obj perf-stat))
|
||||
(local-vars (r0-0 none))
|
||||
(let ((v1-0 (-> obj ctrl)))
|
||||
(+! (-> obj count) 1)
|
||||
(b! (zero? v1-0) cfg-2)
|
||||
(.mtc0 Perf r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mtpc pcr0 r0-0)
|
||||
(.mtpc pcr1 r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mtc0 Perf v1-0)
|
||||
)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(label cfg-2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 12 of type perf-stat
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.l]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [sync.p]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mfpc v1, pcr0]
|
||||
;; WARN: Unsupported inline assembly instruction kind - [mfpc v1, pcr1]
|
||||
(defmethod read! perf-stat ((obj perf-stat))
|
||||
(local-vars (r0-0 none) (v1-1 int) (v1-3 int))
|
||||
(b! (zero? (-> obj ctrl)) cfg-2)
|
||||
(.mtc0 Perf r0-0)
|
||||
(.sync.l)
|
||||
(.sync.p)
|
||||
(.mfpc v1-1 pcr0)
|
||||
(+! (-> obj accum0) (the-as uint v1-1))
|
||||
(.mfpc v1-3 pcr1)
|
||||
(+! (-> obj accum1) (the-as uint v1-3))
|
||||
(label cfg-2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type perf-stat
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
(defmethod
|
||||
update-wait-stats-13
|
||||
update-wait-stats
|
||||
perf-stat
|
||||
((obj perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
|
||||
(when (nonzero? (-> obj ctrl))
|
||||
|
@ -140,3 +189,7 @@
|
|||
(set! (-> perf-stat method-table 12) nothing)
|
||||
(set! (-> perf-stat method-table 13) nothing)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(the-as cspace (cond
|
||||
(result
|
||||
(empty)
|
||||
(the-as cspace result)
|
||||
result
|
||||
)
|
||||
(else
|
||||
(format 0 "no cspace (~A)~%" arg1)
|
||||
|
|
|
@ -233,10 +233,64 @@
|
|||
)
|
||||
|
||||
;; definition for method 20 of type actor-link-info
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
(defmethod
|
||||
send-to-all-after
|
||||
actor-link-info
|
||||
((obj actor-link-info) (message object))
|
||||
(with-pp
|
||||
(let ((iter (-> obj next))
|
||||
(result (the-as object #f))
|
||||
)
|
||||
(while iter
|
||||
(let ((proc (-> iter extra process)))
|
||||
(when proc
|
||||
(let ((msg-block (new 'stack-no-clear 'event-message-block)))
|
||||
(set! (-> msg-block from) pp)
|
||||
(set! (-> msg-block num-params) 0)
|
||||
(set! (-> msg-block message) (the-as basic message))
|
||||
(let ((v1-3 (send-event-function proc msg-block)))
|
||||
(b! v1-3 cfg-4 :likely-delay (set! result v1-3))
|
||||
)
|
||||
)
|
||||
(label cfg-4)
|
||||
)
|
||||
)
|
||||
(set! iter (entity-actor-lookup iter 'next-actor 0))
|
||||
)
|
||||
result
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 21 of type actor-link-info
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
(defmethod
|
||||
send-to-all-before
|
||||
actor-link-info
|
||||
((obj actor-link-info) (arg0 object))
|
||||
(with-pp
|
||||
(let ((s4-0 (-> obj prev))
|
||||
(s5-0 (the-as object #f))
|
||||
)
|
||||
(while s4-0
|
||||
(let ((a0-1 (-> s4-0 extra process)))
|
||||
(when a0-1
|
||||
(let ((a1-1 (new 'stack-no-clear 'event-message-block)))
|
||||
(set! (-> a1-1 from) pp)
|
||||
(set! (-> a1-1 num-params) 0)
|
||||
(set! (-> a1-1 message) (the-as basic arg0))
|
||||
(let ((v1-3 (send-event-function a0-1 a1-1)))
|
||||
(b! v1-3 cfg-4 :likely-delay (set! s5-0 v1-3))
|
||||
)
|
||||
)
|
||||
(label cfg-4)
|
||||
)
|
||||
)
|
||||
(set! s4-0 (entity-actor-lookup s4-0 'prev-actor 0))
|
||||
)
|
||||
s5-0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 23 of type actor-link-info
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
|
@ -436,3 +490,7 @@
|
|||
incomplete-count
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -782,10 +782,10 @@
|
|||
:flag-assert #xe0000006c
|
||||
(:methods
|
||||
(new (symbol type basic vector) _type_ 0)
|
||||
(dummy-9 (_type_) int 9)
|
||||
(dummy-10 (_type_ sound-name) int 10)
|
||||
(dummy-11 (_type_ vector) int 11)
|
||||
(dummy-12 (_type_ int) int 12)
|
||||
(update! (_type_) int 9)
|
||||
(change-sound! (_type_ sound-name) int 10)
|
||||
(update-trans! (_type_ vector) int 11)
|
||||
(update-vol! (_type_ int) int 12)
|
||||
(stop! (_type_) int 13)
|
||||
)
|
||||
)
|
||||
|
|
1741
test/decompiler/reference/engine/sound/gsound_REF.gc
Normal file
1741
test/decompiler/reference/engine/sound/gsound_REF.gc
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1310,7 +1310,8 @@ TEST_F(FormRegressionTest, SoundNameEqual) {
|
|||
" jr ra\n"
|
||||
" daddu sp, sp, r0";
|
||||
std::string type = "(function sound-name sound-name symbol)";
|
||||
std::string expected = "(and (= arg0 arg1) (= (-> arg0 hi) (-> arg1 hi)))";
|
||||
std::string expected =
|
||||
"(and (= (the-as uint arg0) (the-as uint arg1)) (= (-> arg0 hi) (-> arg1 hi)))";
|
||||
test_with_expr(func, type, expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,6 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
|
|||
// display
|
||||
"vblank-handler", // asm
|
||||
"vif1-handler", "vif1-handler-debug",
|
||||
// stats-h
|
||||
"(method 11 perf-stat)", "(method 12 perf-stat)",
|
||||
// ripple - asm
|
||||
"ripple-execute-init", "ripple-create-wave-table", "ripple-apply-wave-table",
|
||||
"ripple-matrix-scale",
|
||||
|
@ -78,10 +76,6 @@ const std::unordered_set<std::string> g_functions_expected_to_reject = {
|
|||
// collide-mesh-h
|
||||
"(method 11 collide-mesh-cache)", // asm
|
||||
|
||||
// actor-link-h
|
||||
"(method 21 actor-link-info)", // BUG: sc cfg / cfg-ir bug
|
||||
"(method 20 actor-link-info)",
|
||||
|
||||
"debug-menu-item-var-render" // asm
|
||||
};
|
||||
|
||||
|
@ -143,6 +137,9 @@ const std::unordered_set<std::string> g_functions_to_skip_compiling = {
|
|||
// asm
|
||||
"invalidate-cache-line",
|
||||
|
||||
// stats-h
|
||||
"(method 11 perf-stat)", "(method 12 perf-stat)",
|
||||
|
||||
// sync-info
|
||||
"(method 15 sync-info)", // needs display stuff first
|
||||
"(method 15 sync-info-eased)", // needs display stuff first
|
||||
|
|
Loading…
Reference in a new issue