diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index 57aa434631..4c13f4a3cb 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -1370,6 +1370,9 @@ bool TypeSystem::typecheck_base_types(const std::string& input_expected, } if (expected == "seconds") { + if (actual == "seconds") { + return true; + } expected = "uint"; } diff --git a/decompiler/Function/CfgVtx.cpp b/decompiler/Function/CfgVtx.cpp index 3f98b6c548..390ef4c9bc 100644 --- a/decompiler/Function/CfgVtx.cpp +++ b/decompiler/Function/CfgVtx.cpp @@ -914,26 +914,18 @@ bool ControlFlowGraph::find_infinite_continue() { int my_block = b0->get_first_block_id(); int dest_block = b0->succ_branch->get_first_block_id(); - fmt::print("Considering {} as an infinite continue:\n", b0->to_string()); + // fmt::print("Considering {} as an infinite continue:\n", b0->to_string()); if (b0->end_branch.asm_branch) { return true; } if (dest_block >= my_block) { - fmt::print(" Rejecting because destination block {} comes after me {}\n", dest_block, - my_block); return true; - } else { - fmt::print(" Order OK {} -> {}\n", my_block, dest_block); } int prev_count = get_prev_count(b0, b0->succ_branch); if (prev_count == -1) { - fmt::print( - " Rejecting because we can't find the destination in the current ungrouped sequence."); return true; - } else { - fmt::print(" Sequencing OK: {} prev's\n", prev_count); } replaced = true; @@ -1232,6 +1224,7 @@ bool ControlFlowGraph::clean_up_asm_branches() { else { lg::error("unhandled sequences in clean_up_asm_branches likely seq: {} {}", !!b0_seq, !!b1_seq); + lg::error("{} {}\n", b0->get_first_block_id(), b1->get_first_block_id()); } } else { diff --git a/decompiler/Function/Function.cpp b/decompiler/Function/Function.cpp index 8893790ecb..5270b1d389 100644 --- a/decompiler/Function/Function.cpp +++ b/decompiler/Function/Function.cpp @@ -289,8 +289,6 @@ void Function::resize_first_block(int new_start, const LinkedObjectFile&) { basic_blocks.at(0).start_word = new_start; if (basic_blocks.size() >= 2 && basic_blocks.at(1).start_word == new_start) { - lg::warn("Function {} loops back to the first instruction. This is rare/less tested.", - guessed_name.to_string()); // block 1 is now zero size, so we should eliminate it auto& block0 = basic_blocks.at(0); auto& block1 = basic_blocks.at(1); diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index ec6a2e2771..cf72dde719 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -629,6 +629,14 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input, return TP_Type::make_from_ts(TypeSpec("float")); } + auto& name = env.func->guessed_name; + if (name.kind == FunctionName::FunctionKind::METHOD && name.method_id == 7 && + env.func->type.arg_count() == 3) { + if (m_kind == Kind::ADD && arg1_type.typespec() == TypeSpec("int")) { + return arg0_type; + } + } + throw std::runtime_error(fmt::format("Cannot get_type_int2: {}, args {} and {}", to_form(env.file->labels, env).print(), arg0_type.print(), arg1_type.print())); diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index f12c180d46..e935cac4ba 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -1828,6 +1828,14 @@ std::string fixed_operator_to_string(FixedOperatorKind kind) { return "l32-false-check"; case FixedOperatorKind::VECTOR_3_DOT: return "vector-dot"; + case FixedOperatorKind::PROCESS_TO_PPOINTER: + return "process->ppointer"; + case FixedOperatorKind::PPOINTER_TO_HANDLE: + return "ppointer->handle"; + case FixedOperatorKind::PROCESS_TO_HANDLE: + return "process->handle"; + case FixedOperatorKind::PPOINTER_TO_PROCESS: + return "ppointer->process"; default: assert(false); return ""; diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index ad92abebc2..9886555166 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -118,6 +118,21 @@ Form* try_cast_simplify(Form* in, } } + if (new_type == TypeSpec("handle")) { + auto in_generic = in->try_as_element(); + if (in_generic && (in_generic->op().is_fixed(FixedOperatorKind::PROCESS_TO_HANDLE) || + in_generic->op().is_fixed(FixedOperatorKind::PPOINTER_TO_HANDLE))) { + return in; + } + } + + if (new_type == TypeSpec("process")) { + auto in_generic = in->try_as_element(); + if (in_generic && in_generic->op().is_fixed(FixedOperatorKind::PPOINTER_TO_PROCESS)) { + return in; + } + } + auto type_info = env.dts->ts.lookup_type(new_type); auto bitfield_info = dynamic_cast(type_info); if (bitfield_info) { @@ -1004,6 +1019,17 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, } } + auto& name = env.func->guessed_name; + if (name.kind == FunctionName::FunctionKind::METHOD && name.method_id == 7 && + env.func->type.arg_count() == 3) { + if (env.dts->ts.tc(TypeSpec("structure"), arg0_type.typespec()) && (arg1_i || arg1_u)) { + auto new_form = pool.alloc_element( + GenericOperator::make_fixed(FixedOperatorKind::ADDITION_PTR), args.at(0), args.at(1)); + result->push_back(new_form); + return; + } + } + if (false && ((arg0_i && arg1_i) || (arg0_u && arg1_u))) { auto new_form = pool.alloc_element( GenericOperator::make_fixed(FixedOperatorKind::ADDITION), args.at(0), args.at(1)); @@ -1569,6 +1595,46 @@ void SimpleExpressionElement::update_from_stack_logor_or_logand(const Env& env, return; } + auto make_handle_matcher = Matcher::op_fixed( + FixedOperatorKind::LOGIOR, + {Matcher::op_fixed( + FixedOperatorKind::SHL, + {Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::integer(0), DerefTokenMatcher::string("pid")}), + Matcher::integer(32)}), + Matcher::op_fixed(FixedOperatorKind::ASM_SLLV_R0, {Matcher::any_reg(1)})}); + + auto handle_mr = match(make_handle_matcher, &hack_form); + if (handle_mr.matched) { + auto var_a = handle_mr.maps.regs.at(0).value(); + auto var_b = handle_mr.maps.regs.at(1).value(); + if (env.get_variable_name(var_a) == env.get_variable_name(var_b) && + env.dts->ts.tc(TypeSpec("pointer", {TypeSpec("process")}), + env.get_variable_type(var_a, true))) { + auto* menv = const_cast(&env); + menv->disable_use(var_a); + + auto repopped = stack.pop_reg(var_b, {}, env, true, stack.size() - 1); + + if (!repopped) { + fmt::print("repop failed.\n{}\n", stack.print(env)); + repopped = var_to_form(var_b, pool); + } + + auto proc_to_ppointer_matcher = + Matcher::op_fixed(FixedOperatorKind::PROCESS_TO_PPOINTER, {Matcher::any(0)}); + auto proc_to_ppointer_mr = match(proc_to_ppointer_matcher, repopped); + if (proc_to_ppointer_mr.matched) { + element = pool.alloc_element( + GenericOperator::make_fixed(FixedOperatorKind::PROCESS_TO_HANDLE), + proc_to_ppointer_mr.maps.forms.at(0)); + } else { + element = pool.alloc_element( + GenericOperator::make_fixed(FixedOperatorKind::PPOINTER_TO_HANDLE), repopped); + } + } + } + result->push_back(element); } @@ -2737,7 +2803,8 @@ void FunctionCallElement::update_from_stack(const Env& env, match_result = match(matcher, temp_form); if (match_result.matched) { auto alloc = match_result.maps.strings.at(allocation); - if (alloc != "global" && alloc != "debug" && alloc != "process") { + if (alloc != "global" && alloc != "debug" && alloc != "process" && + alloc != "loading-level") { throw std::runtime_error("Unrecognized heap symbol for new: " + alloc); } auto type_2 = match_result.maps.strings.at(type_for_arg); @@ -2994,6 +3061,107 @@ void WhileElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stac stack.push_form_element(this, true); } +namespace { +// (if x (-> x ppointer)) -> (process->ppointer x) +Form* try_rewrite_as_process_to_ppointer(CondNoElseElement* value, + FormStack& stack, + FormPool& pool, + const Env& env) { + if (value->entries.size() != 1) { + return nullptr; + } + + auto condition = value->entries.at(0).condition; + auto body = value->entries[0].body; + + // safe to look for a reg directly here. + auto condition_matcher = + Matcher::op(GenericOpMatcher::condition(IR2_Condition::Kind::TRUTHY), {Matcher::any_reg(0)}); + auto condition_mr = match(condition_matcher, condition); + if (!condition_mr.matched) { + return nullptr; + } + + auto body_matcher = + Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string("ppointer")}); + auto body_mr = match(body_matcher, body); + + if (!body_mr.matched) { + return nullptr; + } + + auto body_var = *body_mr.maps.regs.at(0); + auto condition_var = *condition_mr.maps.regs.at(0); + + if (env.get_variable_name(body_var) != env.get_variable_name(condition_var)) { + return nullptr; + } + + // fmt::print("Matched condition {} in {}\n", condition_var.to_string(env), + // value->to_string(env)); + + auto* menv = const_cast(&env); + menv->disable_use(body_var); + auto repopped = stack.pop_reg(condition_var, {}, env, true); + if (!repopped) { + repopped = var_to_form(condition_var, pool); + } + + return pool.alloc_single_element_form( + nullptr, GenericOperator::make_fixed(FixedOperatorKind::PROCESS_TO_PPOINTER), repopped); +} + +// (if x (-> x 0 self)) -> (ppointer->process x) +Form* try_rewrite_as_pppointer_to_process(CondNoElseElement* value, + FormStack& stack, + FormPool& pool, + const Env& env) { + if (value->entries.size() != 1) { + return nullptr; + } + + auto condition = value->entries.at(0).condition; + auto body = value->entries[0].body; + + // safe to look for a reg directly here. + auto condition_matcher = + Matcher::op(GenericOpMatcher::condition(IR2_Condition::Kind::TRUTHY), {Matcher::any_reg(0)}); + auto condition_mr = match(condition_matcher, condition); + if (!condition_mr.matched) { + return nullptr; + } + + auto body_matcher = + Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::integer(0), DerefTokenMatcher::string("self")}); + auto body_mr = match(body_matcher, body); + + if (!body_mr.matched) { + return nullptr; + } + + auto body_var = *body_mr.maps.regs.at(0); + auto condition_var = *condition_mr.maps.regs.at(0); + + if (env.get_variable_name(body_var) != env.get_variable_name(condition_var)) { + return nullptr; + } + + // fmt::print("Matched condition {} in {}\n", condition_var.to_string(env), + // value->to_string(env)); + + auto* menv = const_cast(&env); + menv->disable_use(body_var); + auto repopped = stack.pop_reg(condition_var, {}, env, true); + if (!repopped) { + repopped = var_to_form(condition_var, pool); + } + + return pool.alloc_single_element_form( + nullptr, GenericOperator::make_fixed(FixedOperatorKind::PPOINTER_TO_PROCESS), repopped); +} +} // namespace + /////////////////// // CondNoElseElement /////////////////// @@ -3049,8 +3217,21 @@ void CondNoElseElement::push_to_stack(const Env& env, FormPool& pool, FormStack& if (used_as_value) { // TODO - is this wrong? - stack.push_value_to_reg(write_as_value, pool.alloc_single_form(nullptr, this), true, - env.get_variable_type(final_destination, false)); + auto as_process_to_ppointer = try_rewrite_as_process_to_ppointer(this, stack, pool, env); + if (as_process_to_ppointer) { + stack.push_value_to_reg(write_as_value, as_process_to_ppointer, true, + env.get_variable_type(final_destination, false)); + } else { + auto as_ppointer_to_process = try_rewrite_as_pppointer_to_process(this, stack, pool, env); + if (as_ppointer_to_process) { + stack.push_value_to_reg(write_as_value, as_ppointer_to_process, true, + env.get_variable_type(final_destination, false)); + } else { + stack.push_value_to_reg(write_as_value, pool.alloc_single_form(nullptr, this), true, + env.get_variable_type(final_destination, false)); + } + } + } else { stack.push_form_element(this, true); } @@ -3976,7 +4157,8 @@ void ReturnElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta if (var) { const auto& func_type = env.func->type.last_arg(); return_type = env.get_variable_type(*var, false); - if (func_type != return_type) { + // functions with no return can return stuff. + if (func_type != return_type && func_type != TypeSpec("none")) { auto as_cast = return_code->try_as_element(); if (as_cast) { return_code->clear(); @@ -4324,6 +4506,22 @@ void BranchElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta branch_delay = pool.alloc_single_element_form( nullptr, dst, src_form, true, env.get_variable_type(src, true)); } break; + case IR2_BranchDelay::Kind::SET_REG_FALSE: { + auto dst = m_op->branch_delay().var(0); + auto src_form = pool.alloc_single_element_form( + nullptr, SimpleAtom::make_sym_val("#f")); + + branch_delay = pool.alloc_single_element_form(nullptr, dst, src_form, true, + TypeSpec("symbol")); + } break; + case IR2_BranchDelay::Kind::SET_REG_TRUE: { + auto dst = m_op->branch_delay().var(0); + auto src_form = pool.alloc_single_element_form( + nullptr, SimpleAtom::make_sym_val("#t")); + + branch_delay = pool.alloc_single_element_form(nullptr, dst, src_form, true, + TypeSpec("symbol")); + } break; default: throw std::runtime_error("Unhandled branch delay in BranchElement::push_to_stack: " + m_op->to_string(env)); @@ -4552,11 +4750,13 @@ void ArrayFieldAccess::update_with_val(Form* new_val, {Matcher::integer(m_expected_stride), Matcher::any(0)}); mult_matcher = Matcher::match_or( {Matcher::cast("uint", mult_matcher), Matcher::cast("int", mult_matcher), mult_matcher}); - auto add_matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), - {Matcher::any(1), mult_matcher}); - add_matcher = Matcher::match_or( - {add_matcher, Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), - {mult_matcher, Matcher::any(1)})}); + + auto op_match = + GenericOpMatcher::or_match({GenericOpMatcher::fixed(FixedOperatorKind::ADDITION), + GenericOpMatcher::fixed(FixedOperatorKind::ADDITION_PTR)}); + auto add_matcher = Matcher::op(op_match, {Matcher::any(1), mult_matcher}); + add_matcher = + Matcher::match_or({add_matcher, Matcher::op(op_match, {mult_matcher, Matcher::any(1)})}); auto mr = match(add_matcher, new_val); if (!mr.matched) { diff --git a/decompiler/IR2/FormStack.h b/decompiler/IR2/FormStack.h index 51677b5afa..36a8b7ed96 100644 --- a/decompiler/IR2/FormStack.h +++ b/decompiler/IR2/FormStack.h @@ -128,6 +128,8 @@ class FormStack { assert(false); } + int size() const { return m_stack.size(); } + private: std::vector m_stack; bool m_is_root_stack = false; diff --git a/decompiler/IR2/GenericElementMatcher.cpp b/decompiler/IR2/GenericElementMatcher.cpp index d054ef5965..ab6a8a4071 100644 --- a/decompiler/IR2/GenericElementMatcher.cpp +++ b/decompiler/IR2/GenericElementMatcher.cpp @@ -23,6 +23,10 @@ Matcher Matcher::op(const GenericOpMatcher& op, const std::vector& args return m; } +Matcher Matcher::op_fixed(FixedOperatorKind op, const std::vector& args) { + return Matcher::op(GenericOpMatcher::fixed(op), args); +} + Matcher Matcher::op_with_rest(const GenericOpMatcher& op, const std::vector& args) { Matcher m; m.m_kind = Kind::GENERIC_OP_WITH_REST; diff --git a/decompiler/IR2/GenericElementMatcher.h b/decompiler/IR2/GenericElementMatcher.h index 9294f5bd86..4d4fd09409 100644 --- a/decompiler/IR2/GenericElementMatcher.h +++ b/decompiler/IR2/GenericElementMatcher.h @@ -27,6 +27,7 @@ class Matcher { static Matcher any_reg(int match_id = -1); static Matcher any_label(int match_id = -1); static Matcher op(const GenericOpMatcher& op, const std::vector& args); + static Matcher op_fixed(FixedOperatorKind op, const std::vector& args); static Matcher op_with_rest(const GenericOpMatcher& op, const std::vector& args); static Matcher set(const Matcher& dst, const Matcher& src); // form-form static Matcher set_var(const Matcher& src, int dst_match_id); // var-form diff --git a/decompiler/IR2/IR2_common.h b/decompiler/IR2/IR2_common.h index 02ca958296..735f761df0 100644 --- a/decompiler/IR2/IR2_common.h +++ b/decompiler/IR2/IR2_common.h @@ -160,6 +160,10 @@ enum class FixedOperatorKind { VECTOR_FLOAT_PRODUCT, L32_NOT_FALSE_CBOOL, VECTOR_3_DOT, + PROCESS_TO_PPOINTER, + PPOINTER_TO_HANDLE, + PROCESS_TO_HANDLE, + PPOINTER_TO_PROCESS, INVALID }; diff --git a/decompiler/IR2/bitfields.h b/decompiler/IR2/bitfields.h index e828fba3c5..b384d02cbc 100644 --- a/decompiler/IR2/bitfields.h +++ b/decompiler/IR2/bitfields.h @@ -145,6 +145,9 @@ class BitfieldStaticDefElement : public FormElement { result->push_back(this); } + const TypeSpec& bitfield_type() const { return m_type; } + const std::vector& defs() const { return m_field_defs; } + private: TypeSpec m_type; std::vector m_field_defs; diff --git a/decompiler/analysis/expression_build.cpp b/decompiler/analysis/expression_build.cpp index a1661fd130..4cc5d1575f 100644 --- a/decompiler/analysis/expression_build.cpp +++ b/decompiler/analysis/expression_build.cpp @@ -160,7 +160,6 @@ bool convert_to_expressions( f.guessed_name.to_string()); f.warnings.expression_build_warning(warn); lg::warn(warn); - return false; } } diff --git a/decompiler/analysis/static_refs.cpp b/decompiler/analysis/static_refs.cpp index 8bc3e13f8c..26fefc7671 100644 --- a/decompiler/analysis/static_refs.cpp +++ b/decompiler/analysis/static_refs.cpp @@ -7,6 +7,15 @@ namespace decompiler { namespace { + +bool kind_for_lambda(FunctionName::FunctionKind k) { + if (k == FunctionName::FunctionKind::UNIDENTIFIED || k == FunctionName::FunctionKind::NV_STATE || + k == FunctionName::FunctionKind::V_STATE) { + return true; + } + return false; +} + bool try_convert_lambda(const Function& parent_function, FormPool& pool, Form* f, @@ -17,23 +26,31 @@ bool try_convert_lambda(const Function& parent_function, auto& env = parent_function.ir2.env; auto label_kv = env.label_types().find(lab.name); if (label_kv != env.label_types().end()) { - if (label_kv->second.type_name == "_lambda_") { - auto& file = env.file; - auto other_func = file->try_get_function_at_label(atom->label()); - if (other_func) { - goos::Object result; - if (defstate_behavior) { - result = final_output_defstate_anonymous_behavior(*other_func); - } else { - result = final_output_lambda(*other_func); - } - - f->clear(); - f->push_back(pool.alloc_element(result)); - return true; - } + if (label_kv->second.type_name != "_lambda_") { + lg::error( + "Label {} wasn't marked as a lambda, but it is. Marking lambdas is no longer required.", + lab.name); } } + + auto& file = env.file; + auto other_func = file->try_get_function_at_label(atom->label()); + if (other_func && kind_for_lambda(other_func->guessed_name.kind)) { + if (!other_func->ir2.env.has_local_vars()) { + // don't bother if we don't even have vars. + return false; + } + goos::Object result; + if (defstate_behavior) { + result = final_output_defstate_anonymous_behavior(*other_func); + } else { + result = final_output_lambda(*other_func); + } + + f->clear(); + f->push_back(pool.alloc_element(result)); + return true; + } } return false; } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index cd5ba54523..0a37db9965 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -812,6 +812,9 @@ (sound-options #x129) (hidden-power-cell #x12f) ;; why is this here?? + + (saving-data #x136) + (do-not-remove-mem-card #x138) (continue-without-saving #x13f) (back #x13e) @@ -2199,7 +2202,7 @@ (rotv vector :inline :offset-assert 80) (scalev vector :inline :offset-assert 96) (dir-targ quaternion :inline :offset-assert 112) - (angle-change-time uint64 :offset-assert 128) + (angle-change-time int64 :offset-assert 128) (old-y-angle-diff float :offset-assert 136) ) :method-count-assert 28 @@ -2849,9 +2852,9 @@ (playing-id sound-id :offset-assert 8) (trans vector :inline :offset-assert 16) (name sound-name :offset-assert 32) - (play-time uint64 :offset-assert 48) - (time-base uint64 :offset-assert 56) - (time-random uint64 :offset-assert 64) + (play-time int64 :offset-assert 48) + (time-base int64 :offset-assert 56) + (time-random int64 :offset-assert 64) (volume int32 :offset-assert 72) (pitch int32 :offset-assert 76) (falloff-near int32 :offset-assert 80) @@ -3552,10 +3555,10 @@ (align uint8 6 :offset-assert 88) (direct uint8 6 :offset-assert 94) (buzz-val uint8 2 :offset-assert 100) - (buzz-time uint64 2 :offset-assert 104) + (buzz-time int64 2 :offset-assert 104) (buzz basic :offset-assert 120) (buzz-act int32 :offset-assert 124) - (change-time uint64 :offset-assert 128) + (change-time int64 :offset-assert 128) ) (:methods (new (symbol type int) _type_ 0) @@ -3580,8 +3583,8 @@ (define-extern cpad-set-buzz! (function cpad-info int int int none)) (define-extern cpad-get-data (function cpad-info cpad-info)) -(define-extern get-current-time (function uint)) -(define-extern get-integral-current-time (function uint)) +(define-extern get-current-time (function int)) +(define-extern get-integral-current-time (function int)) (define-extern cpad-invalid! (function cpad-info cpad-info)) ;; in the kernel. (define-extern cpad-open (function cpad-info int cpad-info)) @@ -4323,22 +4326,22 @@ (last-screen int32 :offset-assert 564) (frames virtual-frame 6 :inline :offset-assert 568) (bg-clear-color rgba 4 :offset-assert 760) - (real-frame-counter uint64 :offset-assert 776) - (base-frame-counter uint64 :offset-assert 784) - (game-frame-counter uint64 :offset-assert 792) - (integral-frame-counter uint64 :offset-assert 800) - (real-integral-frame-counter uint64 :offset-assert 808) - (actual-frame-counter uint64 :offset-assert 816) - (real-actual-frame-counter uint64 :offset-assert 824) - (part-frame-counter uint64 :offset-assert 832) - (old-real-frame-counter uint64 :offset-assert 840) - (old-base-frame-counter uint64 :offset-assert 848) - (old-game-frame-counter uint64 :offset-assert 856) - (old-integral-frame-counter uint64 :offset-assert 864) - (old-real-integral-frame-counter uint64 :offset-assert 872) - (old-actual-frame-counter uint64 :offset-assert 880) - (old-real-actual-frame-counter uint64 :offset-assert 888) - (old-part-frame-counter uint64 :offset-assert 896) + (real-frame-counter int64 :offset-assert 776) + (base-frame-counter int64 :offset-assert 784);; todo, change to signed? + (game-frame-counter int64 :offset-assert 792) + (integral-frame-counter int64 :offset-assert 800) + (real-integral-frame-counter int64 :offset-assert 808) + (actual-frame-counter int64 :offset-assert 816) + (real-actual-frame-counter int64 :offset-assert 824) + (part-frame-counter int64 :offset-assert 832) + (old-real-frame-counter int64 :offset-assert 840) + (old-base-frame-counter int64 :offset-assert 848) + (old-game-frame-counter int64 :offset-assert 856) + (old-integral-frame-counter int64 :offset-assert 864) + (old-real-integral-frame-counter int64 :offset-assert 872) + (old-actual-frame-counter int64 :offset-assert 880) + (old-real-actual-frame-counter int64 :offset-assert 888) + (old-part-frame-counter int64 :offset-assert 896) (time-ratio float :offset-assert 904) (seconds-per-frame float :offset-assert 908) (frames-per-second float :offset-assert 912) @@ -5463,7 +5466,7 @@ ((name basic :offset-assert 4) (length int16 :offset-assert 8) ;; in use elts of the data array (allocated-length int16 :offset-assert 10) ;; size of the data array - (engine-time uint64 :offset-assert 16) ;; frame that we last executed + (engine-time int64 :offset-assert 16) ;; frame that we last executed ;; terminating nodes for the next0/prev0 linked lists (alive-list connectable :inline :offset-assert 32) (alive-list-end connectable :inline :offset-assert 48) @@ -6243,8 +6246,8 @@ (num-success-before-killing int8 :offset-assert 13) (num-attempts int8 :offset-assert 14) (num-success int8 :offset-assert 15) - (start-time uint64 :offset-assert 16) - (last-time-called uint64 :offset-assert 24) + (start-time int64 :offset-assert 16) + (last-time-called int64 :offset-assert 24) ) :method-count-assert 9 :size-assert #x20 @@ -8879,7 +8882,7 @@ ;; - Functions -(define-extern mc-get-slot-info (function int mc-slot-info)) +(define-extern mc-get-slot-info (function int mc-slot-info none)) (define-extern mc-run (function none)) (define-extern mc-check-result (function int)) (define-extern mc-sync (function int)) @@ -8983,6 +8986,29 @@ ) ) +(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 structure) (declare-type game-save basic) (declare-type entity-perm-array basic) @@ -9023,7 +9049,7 @@ (death-movie-tick int32 :offset-assert 264) (want-auto-save symbol :offset-assert 268) (auto-save-proc handle :offset-assert 272) - (auto-save-status uint32 :offset-assert 280) + (auto-save-status mc-status-code :offset-assert 280) (auto-save-card int32 :offset-assert 284) (auto-save-which int32 :offset-assert 288) (pov-camera-handle handle :offset-assert 296) @@ -9052,7 +9078,7 @@ (seen-text? (_type_ game-text-id) symbol 21) (mark-text-as-seen (_type_ game-text-id) none 22) (got-buzzer? (_type_ game-task int) symbol 23) - (dummy-24 () none 24) + (save-game! (_type_ game-save string) none 24) (load-game! (_type_ game-save) game-save 25) (clear-text-seen! (_type_ game-text-id) none 26) (get-death-count (_type_ symbol) int 27) @@ -9767,8 +9793,9 @@ :flag-assert #x90000004c ) +(declare-type process-drawable process) (deftype fact-info (basic) - ((process process :offset-assert 4) + ((process process-drawable :offset-assert 4) (pickup-type pickup-type :offset-assert 8) (pickup-amount float :offset-assert 12) (pickup-spawn-amount float :offset-assert 16) @@ -9779,10 +9806,10 @@ :size-assert #x28 :flag-assert #xc00000028 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) (TODO-RENAME-9 (_type_ symbol process-tree fact-info int) uint 9) ;; See nav-enemy::process-drawable-death-event-handler (reset! (_type_ symbol) none 10) - (dummy-11 (_type_) float 11) + (pickup-collectable! (_type_ pickup-type float handle) float 11) ) ) @@ -9798,7 +9825,7 @@ (eco-pill float :offset-assert 80) (eco-pill-max float :offset-assert 84) (health-pickup-time uint64 :offset-assert 88) - (eco-source uint64 :offset-assert 96) + (eco-source handle :offset-assert 96) (eco-source-time uint64 :offset-assert 104) (money-pickup-time uint64 :offset-assert 112) (buzzer-pickup-time uint64 :offset-assert 120) @@ -9809,7 +9836,7 @@ :size-assert #x90 :flag-assert #xc00000090 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) @@ -9826,7 +9853,7 @@ :size-assert #x44 :flag-assert #xc00000044 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) @@ -10292,7 +10319,7 @@ (max-time int32 :offset-assert 4) (max-val float :offset-assert 8) (timer int32 :offset-assert 12) - (start-time uint64 :offset-assert 16) + (start-time int64 :offset-assert 16) (value float :offset-assert 24) ) :method-count-assert 11 @@ -10345,7 +10372,7 @@ (xz-max float :offset-assert 8) (y-max float :offset-assert 12) (timer int32 :offset-assert 16) - (start-time uint64 :offset-assert 24) + (start-time int64 :offset-assert 24) (value vector :inline :offset-assert 32) ) :method-count-assert 13 @@ -10386,7 +10413,7 @@ ;; - Types (deftype smush-control (structure) - ((start-time uint64 :offset-assert 0) + ((start-time int64 :offset-assert 0) (period float :offset-assert 8) (duration float :offset-assert 12) (amp float :offset-assert 16) @@ -10493,7 +10520,7 @@ (trans vector :inline :offset-assert 64) (quat quaternion :inline :offset-assert 80) (scale vector :inline :offset-assert 96) - (notice-time uint64 :offset-assert 112) + (notice-time int64 :offset-assert 112) (flex-blend float :offset-assert 120) (blend float :offset-assert 124) (max-dist meters :offset-assert 128) @@ -11020,7 +11047,7 @@ (transv-out vector :inline :offset-assert 48) (local-normal vector :inline :offset-assert 64) (surface-normal vector :inline :offset-assert 80) - (time uint64 :offset-assert 96) + (time int64 :offset-assert 96) (status uint64 :offset-assert 104) (pat pat-surface :offset-assert 112) (reaction-flag uint32 :offset-assert 116) @@ -13315,14 +13342,14 @@ (linger-duration uint16 :offset-assert 8) (flags uint16 :offset-assert 10) (name basic :offset-assert 12) - (launcher uint32 :offset-assert 16) + (launcher sparticle-group-item :offset-assert 16) (bounds sphere :inline :offset-assert 32) ) :method-count-assert 10 :size-assert #x30 :flag-assert #xa00000030 (:methods - (dummy-9 (_type_ process) _type_ 9) + (create-launch-control (_type_ process) sparticle-launch-control 9) ) ) @@ -13345,8 +13372,8 @@ (:methods (dummy-9 () none 9) (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) + (dummy-11 (_type_ vector) none 11) + (deactivate (_type_) none 12) (dummy-13 () none 13) ) ) @@ -14594,7 +14621,7 @@ (define-extern *dgo-name* string) (define-extern *load-dgo-rpc* rpc-buffer-pair) -(define-extern *dgo-time* uint) +(define-extern *dgo-time* int) (define-extern *play-str-rpc* rpc-buffer-pair) (define-extern *que-str-lock* symbol) (define-extern *load-str-lock* symbol) @@ -16606,12 +16633,12 @@ (which int32 :offset-assert 120) (buffer kheap :offset-assert 124) (mode basic :offset-assert 128) - (result uint32 :offset-assert 132) - (save basic :offset-assert 136) + (result mc-status-code :offset-assert 132) + (save game-save :offset-assert 136) (info mc-slot-info :inline :offset-assert 140) - (notify uint64 :offset-assert 440) + (notify handle :offset-assert 440) (state-time uint64 :offset-assert 448) - (part basic :offset-assert 456) + (part sparticle-launch-control :offset-assert 456) ) :heap-base #x160 :method-count-assert 23 @@ -16619,37 +16646,43 @@ :flag-assert #x17016001cc ;; inherited inspect of process (: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) + (get-heap () _type_ :state 14) + (get-card () _type_ :state 15) + (format-card () _type_ :state 16) + (create-file () _type_ :state 17) + (save () _type_ :state 18) + (restore () _type_ :state 19) + (error (mc-status-code) _type_ :state 20) + (done () _type_ :state 21) + (unformat-card () _type_ :state 22) ) ) ;; - Functions (define-extern auto-save-command (function symbol int int process-tree none)) ;; TODO - not confirmed -(define-extern auto-save-init-by-other function) +(define-extern auto-save-init-by-other (function symbol process-tree int int none :behavior auto-save)) (define-extern progress-allowed? (function symbol)) (define-extern print-game-text (function string font-context symbol int int float)) ; TODO decomp error, this seems correct though (define-extern get-aspect-ratio (function symbol)) (define-extern get-task-status (function game-task task-status)) (define-extern lookup-level-info (function symbol level-load-info)) -(define-extern calculate-completion function) +(define-extern calculate-completion (function symbol float)) (define-extern game-save-elt->string (function game-save-elt string)) (define-extern progress-level-index->string (function int string)) -(define-extern auto-save-post function) +(define-extern auto-save-post (function none :behavior auto-save)) (define-extern auto-save-check (function none)) +(define-extern mc-format (function int mc-status-code)) +(define-extern mc-unformat (function int mc-status-code)) +(define-extern mc-create-file (function int uint mc-status-code)) +(define-extern mc-save (function int int pointer int mc-status-code)) +(define-extern mc-load (function int int pointer mc-status-code)) + ;; - Unknowns -(define-extern *auto-save-info* mc-slot-info) ;; unknown type -;;(define-extern scf-get-time object) ;; unknown type +(define-extern *auto-save-info* mc-slot-info) +(define-extern scf-get-time (function scf-time none)) ;; ;; unknown type @@ -19601,7 +19634,7 @@ (define-extern pause-allowed? (function symbol)) (define-extern menu-respond-to-pause (function symbol)) (define-extern hide-progress-screen (function int)) -(define-extern set-letterbox-frames (function uint uint)) +(define-extern set-letterbox-frames (function int int)) (define-extern letterbox (function none)) (define-extern blackout (function none)) (define-extern main-cheats (function int)) @@ -21959,7 +21992,7 @@ (sim-time-remaining float :offset-assert 688) (float-height-offset float :offset-assert 692) (player-attack-id int32 :offset-assert 696) - (player-bonk-timeout uint64 :offset-assert 704) + (player-bonk-timeout int64 :offset-assert 704) (water-anim water-anim :offset-assert 712) (player-contact basic :offset-assert 716) ; not a basic (player-impulse collide-shape-prim-mesh :offset-assert 720) @@ -22080,15 +22113,15 @@ (momentum-speed float :offset-assert 296) (acceleration float :offset-assert 300) (rotate-speed float :offset-assert 304) - (turn-time uint64 :offset-assert 312) - (frustration-time uint64 :offset-assert 320) + (turn-time int64 :offset-assert 312) + (frustration-time int64 :offset-assert 320) (speed-scale float :offset-assert 328) (neck joint-mod :offset-assert 332) ; this is what `neck` is on the pelican - (reaction-time uint64 :offset-assert 336) - (notice-time uint64 :offset-assert 344) - (state-timeout uint64 :offset-assert 352) - (free-time uint64 :offset-assert 360) - (touch-time uint64 :offset-assert 368) + (reaction-time int64 :offset-assert 336) + (notice-time int64 :offset-assert 344) + (state-timeout int64 :offset-assert 352) + (free-time int64 :offset-assert 360) + (touch-time int64 :offset-assert 368) (nav-enemy-flags uint32 :offset-assert 376) (incomming-attack-id handle :offset-assert 384) (jump-return-state (state process) :offset-assert 392) @@ -22879,10 +22912,10 @@ ;; - Types (deftype ticky (structure) - ((delay-til-ramp uint64 :offset-assert 0) - (delay-til-timeout uint64 :offset-assert 8) - (starting-time uint64 :offset-assert 16) - (last-tick-time uint64 :offset-assert 24) + ((delay-til-ramp int64 :offset-assert 0) + (delay-til-timeout int64 :offset-assert 8) + (starting-time int64 :offset-assert 16) + (last-tick-time int64 :offset-assert 24) ) :method-count-assert 12 :size-assert #x20 diff --git a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc index 549699a816..fe4290b701 100644 --- a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc @@ -505,7 +505,12 @@ [496, "(function task-control symbol)"] ], - "game-info": [[17, "(function symbol symbol continue-point symbol none)"]], + "game-info": [ + [17, "(function symbol symbol continue-point symbol none)"], + [6, "(function process-drawable none)"], + [7, "(function none :behavior process-drawable)"], + [8, "(function object)"] + ], "default-menu": [ [3, "(function none)"], diff --git a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc index 6df1744675..f47205febf 100644 --- a/decompiler/config/jak1_ntsc_black_label/hacks.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/hacks.jsonc @@ -222,17 +222,6 @@ "sp-process-block-2d", "sp-get-particle", - // game-info BUG - "(method 11 fact-info-target)", - - // game-save BUG - "(anon-function 5 game-save)", // BUG: - "(anon-function 6 game-save)", // BUG: - "(anon-function 7 game-save)", // BUG: - "(anon-function 8 game-save)", // BUG: - "(anon-function 9 game-save)", // BUG: - "(anon-function 10 game-save)", - // mood BUG "update-mood-lava", // BUG: "update-mood-lightning", @@ -379,12 +368,6 @@ "(anon-function 10 ice-cube)", "(anon-function 15 ice-cube)", "(anon-function 45 lavatube-energy)", - "(anon-function 5 game-save)", - "(anon-function 6 game-save)", - "(anon-function 7 game-save)", - "(anon-function 8 game-save)", - "(anon-function 9 game-save)", - "(anon-function 10 game-save)", "mistycannon-find-best-solution", "target-flut-falling-anim-trans", "kermit-check-to-hit-player?", @@ -517,7 +500,8 @@ "unpack-comp-rle":[1, 3, 5, 6], "(method 16 level)":[ 1, 5, 13, 14, 15, 19, 26, 53], "unpack-comp-huf":[2, 4, 5, 6, 7, 8, 9], - "blerc-execute":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33] - + "blerc-execute":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], + "(method 11 fact-info-target)":[42], + "(code format-card auto-save)":[3, 4, 5, 6, 7, 8] } } diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index c7f3d1c7b7..778f0c02b5 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -191,6 +191,34 @@ ["L3", "game-info", true] ], + "game-save": [ + ["L321", "float", true], + ["L316", "float", true], + ["L317", "float", true], + ["L9", "_lambda_", true], + ["L20", "_lambda_", true], + ["L50", "_lambda_", true], + ["L53", "_lambda_", true], + ["L67", "_lambda_", true], + ["L79", "_lambda_", true], + ["L91", "_lambda_", true], + ["L98", "_lambda_", true], + ["L107", "_lambda_", true], + ["L123", "_lambda_", true], + ["L271", "_auto_", true], + ["L272", "_auto_", true], + ["L300", "_auto_", true], + ["L293", "_auto_", true], + ["L294", "_auto_", true], + ["L296", "_auto_", true], + ["L297", "_auto_", true], + ["L298", "_auto_", true], + ["L304", "sparticle-launch-group", true], + ["L299", "_auto_", true], + ["L302", "_auto_", true] + + ], + "wind-h": [["L3", "_auto_", true]], "dynamics-h": [["L6", "_auto_", true]], diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 33b2c9fe2b..a9eb516b15 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -1145,5 +1145,38 @@ [16, "vector"] ], + "(method 11 fact-info-target)": [ + [16, "event-message-block"] + ], + + "(anon-function 6 game-info)": [ + [16, "event-message-block"] + ], + + "(anon-function 8 game-info)": [ + [16, "event-message-block"] + ], + + "(method 24 game-info)": [ + [16, "scf-time"] + ], + + "auto-save-post": [ + [16, "font-context"], + [112, "font-context"] + ], + + "auto-save-init-by-other":[ + [16, "event-message-block"] + ], + + "(code error auto-save)": [ + [16, "event-message-block"] + ], + + "(code done auto-save)": [ + [16, "event-message-block"] + ], + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 2eb7da93aa..3ce13aa1bb 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -2234,7 +2234,7 @@ ], "(method 32 warrior)": [ - [75, "v1", "handle"] + [76, "v1", "handle"] ], "(method 43 warrior)": [ @@ -2250,5 +2250,55 @@ [19, "v1", "float"] ], + "(method 11 fact-info-target)": [ + [135, "v1", "target"], + [148, "v1", "collide-shape"], + [258, "v1", "target"], + [272, "v1", "target"], + [287, "v1", "target"], + [298, "v1", "target"], + [556, "t9", "(function process function vector meters int none)"], + [635, "t9", "(function cpu-thread function process-drawable none)"] + ], + + "(method 7 process)": [ + [[120, 124], "a0", "basic"], + [[127, 130], "a0", "basic"], + [47, "v1", "connection"], + [57, "v1", "connection"], + [[47, 88], "v1", "connection"] + ], + + "(anon-function 7 game-info)": [ + [2, "v1", "collide-shape"] + ], + + "(method 24 game-info)": [ + [112, "s3", "pointer"], + [[113, 165], "a0", "game-save-tag"], + [[148, 166], "s2", "game-save-tag"], + [[148, 168], "s4", "game-save-tag"], + [[171, 222], "a0", "game-save-tag"], + [[234, 241], "a0", "game-save-tag"], + [[253, 276], "a0", "game-save-tag"], + [[283, 302], "a0", "game-save-tag"], + [[319, 325], "a1", "game-save-tag"], + [[342, 348], "a1", "game-save-tag"], + [[395, 468], "a0", "game-save-tag"], + [[480, 488], "a0", "game-save-tag"], + [[500, 506], "a0", "game-save-tag"], + [[521, 528], "a0", "game-save-tag"], + [[543, 650], "a0", "game-save-tag"], + // [329, "a0", "pointer"], + // [338, "a0", "pointer"], + // [[173, 230], "a0", "game-save-tag"], + [252, "a0", "(pointer int32)"], + [654, "a0", "pointer"] + ], + + "auto-save-post":[ + [138, "t9", "(function object string object none)"] + ], + "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index ac65ea16eb..c6134cf050 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -3228,5 +3228,14 @@ "s4-0":"dma-buf" } }, + + "(method 11 fact-info-target)": { + "args":["obj", "kind", "amount", "source-handle"], + "vars":{"f0-29":"buzz-count","f30-0":"eco-lev"} + }, + + "auto-save-init-by-other": { + "args":["desired-mode", "notify-proc", "card-idx", "file-idx"] + }, "aaaaaaaaaaaaaaaaaaaaaaa": {} } diff --git a/docs/markdown/progress-notes/changelog.md b/docs/markdown/progress-notes/changelog.md index bc60bc15ec..3f4af572b4 100644 --- a/docs/markdown/progress-notes/changelog.md +++ b/docs/markdown/progress-notes/changelog.md @@ -190,4 +190,7 @@ - Added `get-enum-vals` which returns a list of pairs. Each pair is the name (symbol) and value (int) for each value in the enum - It is now possible to set a 64-bit memory location from a float, if you insert a cast. It will zero-extend the float, just like any other float -> 64-bit conversion. - Added `:state` option to `:methods`. -- Accessing the `enter` field of `state` will now magically give you a function with the right type. \ No newline at end of file +- Accessing the `enter` field of `state` will now magically give you a function with the right type. +- It is possible to access fields of the parent of a forward declared type +- Fixed a bug where casting a value to seconds, then setting a field of type seconds would incorrectly fail type-check +- Fixed a bug where nested rlet's didn't properly share register constraints, leading to inefficient register allocation, and some rare cases a regalloc constraint error \ No newline at end of file diff --git a/game/common/ramdisk_rpc_types.h b/game/common/ramdisk_rpc_types.h index 23870b6d36..bc02176a88 100644 --- a/game/common/ramdisk_rpc_types.h +++ b/game/common/ramdisk_rpc_types.h @@ -5,9 +5,6 @@ * Types used for the RamDisk Remote Procedure Call between the EE and the IOP */ -#ifndef JAK1_RAMDISK_RPC_TYPES_H -#define JAK1_RAMDISK_RPC_TYPES_H - #include "common/common_types.h" constexpr int RAMDISK_RPC_ID = 0xdeb3; @@ -17,11 +14,9 @@ constexpr int RAMDISK_RESET_AND_LOAD_FNO = 1; constexpr int RAMDISK_BYPASS_LOAD_FILE = 4; struct RPC_Ramdisk_LoadCmd { - char pad[4]; - uint32_t file_id_or_ee_addr; - uint32_t offset_into_file; - uint32_t size; + u32 pad; + u32 file_id_or_ee_addr; + u32 offset_into_file; + u32 size; char name[16]; // guess on length? }; - -#endif // JAK1_RAMDISK_RPC_TYPES_H diff --git a/game/kernel/kdgo.h b/game/kernel/kdgo.h index 7dbc3a5ee0..449d713d90 100644 --- a/game/kernel/kdgo.h +++ b/game/kernel/kdgo.h @@ -6,9 +6,6 @@ * DONE! */ -#ifndef JAK_V2_KDGO_H -#define JAK_V2_KDGO_H - #include "common/common_types.h" #include "Ptr.h" #include "kmalloc.h" @@ -20,6 +17,12 @@ void load_and_link_dgo(u64 name_gstr, u64 heap_info, u64 flag, u64 buffer_size); void StopIOP(); u64 RpcCall_wrapper(void* args); +s32 RpcCall(s32 rpcChannel, + u32 fno, + bool async, + void* sendBuff, + s32 sendSize, + void* recvBuff, + s32 recvSize); u32 RpcBusy(s32 channel); void LoadDGOTest(); -#endif // JAK_V2_KDGO_H diff --git a/game/kernel/kmemcard.cpp b/game/kernel/kmemcard.cpp index fe80470bba..827aa5a695 100644 --- a/game/kernel/kmemcard.cpp +++ b/game/kernel/kmemcard.cpp @@ -7,66 +7,218 @@ //#include "ps2/SCE_FS.h" //#include "ps2/common_types.h" //#include "kernel/kmachine.h" +#include "game/sce/sif_ee.h" #include "kmemcard.h" +#include "game/kernel/kdgo.h" +#include "game/common/ramdisk_rpc_types.h" +#include "game/kernel/fileio.h" #include +#include -// static s32 next; +using McCallbackFunc = void (*)(s32); + +McCallbackFunc callback; + +static s32 next; static s32 language; -// static MemoryCardOperation op; -// static mc_info mc[2]; +static MemoryCardOperation op; +static MemoryCard mc[2]; +static RPC_Ramdisk_LoadCmd ramdisk_cmd; + +// these are the return value for sceMcGetInfo. +static s32 p1, p2, p3, p4; +using namespace ee; + +void cb_reprobe_format(s32); +void cb_format_complete(s32); +void cb_unformat(s32); +void cb_reprobe_createfile(s32); +void cb_wait_for_ramdisk(s32); +void cb_wait_for_ramdisk_load(s32); +void cb_createfile_erasing(s32); +void cb_createdir(s32); +void cb_createdfile(s32); +void cb_writtenfile(s32); +void cb_closedfile(s32); +void cb_reprobe_save(s32); + +const char* filename[12] = { + "/BASCUS-97124AYBABTU!", "/BASCUS-97124AYBABTU!/icon.sys", + "/BASCUS-97124AYBABTU!/icon.ico", "/BASCUS-97124AYBABTU!/BASCUS-97124AYBABTU!", + "/BASCUS-97124AYBABTU!/bank0.bin", "/BASCUS-97124AYBABTU!/bank1.bin", + "/BASCUS-97124AYBABTU!/bank2.bin", "/BASCUS-97124AYBABTU!/bank3.bin", + "/BASCUS-97124AYBABTU!/bank4.bin", "/BASCUS-97124AYBABTU!/bank5.bin", + "/BASCUS-97124AYBABTU!/bank6.bin", "/BASCUS-97124AYBABTU!/bank7.bin"}; void kmemcard_init_globals() { - // next = 0; + next = 0; language = 0; + op = {}; + mc[0] = {}; + mc[1] = {}; + callback = nullptr; + p1 = 0; + p2 = 0; + p3 = 0; + p4 = 0; +} + +/*! + * Get a new memory card handle. + * Will never return 0. + */ +s32 new_mc_handle() { + s32 handle = next++; + + // if you wrap around, it avoid the zero handle. + // it doesn't seem like you will need billions of memory card handles + if (handle == 0) { + handle = next++; + } + return handle; +} + +/*! + * A questionable checksum. + */ +u32 mc_checksum(Ptr data, s32 size) { + if (size < 0) { + size += 3; + } + + u32 result = 0; + u32* data_u32 = (u32*)data.c(); + for (s32 i = 0; i < size / 4; i++) { + result = result << 1 ^ (s32)result >> 0x1f ^ data_u32[i] ^ 0x12345678; + } + + return result ^ 0xedd1e666; +} + +/*! + * Get the slot for a handle. The card must be in the given state. + * Return -1 if it fails. + */ +s32 handle_to_slot(u32 handle, MemoryCardState state) { + if (mc[0].state == state && mc[0].handle == handle) { + return 0; + } + if (mc[1].state == state && mc[0].handle == handle) { + return 1; + } else { + return -1; + } +} + +/*! + * Run the Memory Card state machine. + * This waits for in-progress ops to finish. + * If it is done, it starts a new op, if there is one pending. + */ +void MC_run() { + // if we have an in-progress operation, wait for it to complete. + if (callback) { + s32 sony_cmd, sony_status; + s32 status = sceMcSync(1, &sony_cmd, &sony_status); + McCallbackFunc callback_for_sync = callback; + if (status == sceMcExecRun) { + // busy, return. + return; + } + + if (status == sceMcExecFinish) { + // sony function is done. do the callback + callback = nullptr; + (*callback_for_sync)(sony_status); + } else { + // sony function is done, but failed. + assert(false); + callback = nullptr; + (*callback_for_sync)(0); + } + + if (callback) { + // if we got another callback, it means there's another op started by the prev callback. + // and this case, we're done. + return; + } + } + + // if we got here, there is no in-progress operation. So start the next one. + if (op.operation == MemoryCardOperationKind::FORMAT) { + // grab the slot. should be open, but not formatted + p1 = handle_to_slot(op.param, MemoryCardState::OPEN); + if (p1 == -1) { + // no slot in the right state. + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } else { + // do a getInfo + s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); + if (info_result == sceMcResSucceed) { + callback = cb_reprobe_format; + } + // allow some number of errors. + op.counter--; + if (op.counter == 0) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } else if (op.operation == MemoryCardOperationKind::UNFORMAT) { + p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); + if (p1 == -1) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } else { + s32 rv = sceMcUnformat(p1, 0); + if (rv == sceMcResSucceed) { + callback = cb_unformat; + } + op.counter--; + if (op.counter == 0) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } else if (op.operation == MemoryCardOperationKind::CREATE_FILE) { + p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); + if (p1 == -1) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } else { + s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); + if (info_result == sceMcResSucceed) { + callback = cb_reprobe_createfile; + } + // allow some number of errors. + op.counter--; + if (op.counter == 0) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } else if (op.operation == MemoryCardOperationKind::SAVE) { + p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); + if (p1 == -1) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } else { + s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); + if (info_result == sceMcResSucceed) { + callback = cb_reprobe_save; + } + // allow some number of errors. + op.counter--; + if (op.counter == 0) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } + // TODO: the rest. } -///*! -// * Get a new memory card handle. -// * Will never return 0. -// */ -// s32 new_mc_handle() { -// s32 handle = next++; -// -// // if you wrap around, it avoid the zero handle. -// // it doesn't seem like you will need billions of memory card handles -// if(handle == 0) { -// handle = next++; -// } -// return handle; -//} -// -///*! -// * A questionable checksum. -// */ -// u32 mc_checksum(Ptr data, s32 size) { -// if(size < 0) { -// size += 3; -// } -// -// u32 result = 0; -// u32* data_u32 = (u32*)data.c(); -// for(s32 i = 0; i < size / 4; i++) { -// result = result << 1 ^ result >> 0x1f ^ data_u32[i*4] ^ 0x12345678; -// } -// -// return result ^ 0xedd1e666; -//} -// -// u32 handle_to_slot(s32 handle, s32 p2) { -// if(mc[0].p0 == p2 && mc[0].handle == handle) { -// return 0; -// } -// if(mc[1].p0 == p2 && mc[0].handle == handle) { -// return 1; -// } else { -// return -1; -// } -//} -// -// void MC_run() { -// -//} -// /*! * Set the language or something. */ @@ -75,142 +227,417 @@ void MC_set_language(s32 l) { language = l; } -// u64 MC_format(s32 param) { -// u64 can_add = op.operation == NO_OP; -// if(can_add) { -// op.operation = FORMAT; -// op.result = 0; -// op.f_10 = 100; -// op.param = param; -// } -// return can_add; -//} -// -// -// u64 MC_unformat(s32 param) { -// u64 can_add = op.operation == NO_OP; -// if(can_add) { -// op.operation = UNFORMAT; -// op.result = 0; -// op.f_10 = 100; -// op.param = param; -// } -// return can_add; -//} -// -// u64 MC_createfile(s32 param, Ptr data) { -// u64 can_add = op.operation == NO_OP; -// if(can_add) { -// op.operation = CREATE_FILE; -// op.result = 0; -// op.f_10 = 100; -// op.param = param; -// op.data_ptr = data; -// } -// return can_add; -//} -// -// u64 MC_save(s32 param, s32 param2, Ptr data, Ptr data2) { -// u64 can_add = op.operation == NO_OP; -// if(can_add) { -// op.operation = SAVE; -// op.result = 0; -// op.f_10 = 100; -// op.param = param; -// op.param2 = param2; -// op.data_ptr = data; -// op.data_ptr2 = data2; -// } -// return can_add; -//} -// -// u64 MC_load(s32 param, s32 param2, Ptr data) { -// u64 can_add = op.operation == NO_OP; -// if(can_add) { -// op.operation = LOAD; -// op.result = 0; -// op.f_10 = 100; -// op.param = param; -// op.param2 = param2; -// op.data_ptr = data; -// } -// return can_add; -//} -// -///*! -// * Some sort of test function for memory card stuff. -// */ -// void MC_makefile(s32 port, s32 size) { -// sceMcMkdir(port, 0, "/BASCUS-00000XXXXXXXX"); -// // wait for operation to complete -// s32 cmd, result, fd; -// sceMcSync(0, &cmd, &result); -// -// if(result == sceMcResSucceed || result == sceMcResNoEntry) { -// // it worked, or the folder already exists... -// -// // open file -// sceMcOpen(port, 0, "/BASCUS-00000XXXXXXXX/BASCUS-00000XXXXXXXX", SCE_CREAT | SCE_WRONLY); -// sceMcSync(0, &cmd, &fd); -// -// if(result < 0) { -// printf("Can\'t open file on memcard [%d]\n", result); -// } else { -// // write some random crap into the memory card. -// sceMcWrite(fd, Ptr(0x1000000).c(), size); -// sceMcSync(0, &cmd, &result); -// if(result != size) { -// printf("Only written %d bytes\n", result); -// } -// sceMcClose(fd); -// sceMcSync(0, &cmd, &result); -// } -// } else { -// printf("Can\'t create garbage folder [%d]\n", result); -// } -//} -// -// u32 MC_check_result() { -// return op.result; -//} -// -// void MC_get_status(s32 slot, Ptr info) { -// info->handle = 0; -// info->known = 0; -// info->formatted = 0; -// info->initted = 0; -// for(s32 i = 0; i < 4; i++) { -// info->files[i].present = 0; -// } -// info->last_file = 0xffffffff; -// info->mem_required = SAVE_SIZE; -// info->mem_actual = 0; -// -// switch(mc[slot].p0) { -// case 1: -// info->known = 1; -// break; -// case 2: -// info->known = 1; -// info->handle = mc[slot].handle; -// break; -// case 3: -// info->known = 1; -// info->handle = mc[slot].handle; -// info->formatted = 1; -// if(mc[slot].inited == 0) { -// info->mem_actual = mc[slot].mem_actual; -// } else { -// info->initted = 1; -// for(s32 file = 0; file < 4; file++) { -// info->files[file].present = mc[slot].files[file].present; -// for(s32 i = 0; i < 64; i++) { // actually a loop over u32's -// info->files[file].data[i] = mc[slot].files[file].data[i]; -// } -// } -// info->last_file = mc[slot].last_file; -// -// } -// } -// -//} \ No newline at end of file +/*! + * Set the current memory card operation to FORMAT the given card. + */ +u64 MC_format(s32 card_idx) { + u64 can_add = op.operation == MemoryCardOperationKind::NO_OP; + if (can_add) { + op.operation = MemoryCardOperationKind::FORMAT; + op.result = McStatusCode::BUSY; + op.counter = 100; + op.param = card_idx; + } + return can_add; +} + +/*! + * Set the current memory card operation to UNFORMAT the given card. + */ +u64 MC_unformat(s32 card_idx) { + u64 can_add = op.operation == MemoryCardOperationKind::NO_OP; + if (can_add) { + op.operation = MemoryCardOperationKind::UNFORMAT; + op.result = McStatusCode::BUSY; + op.counter = 100; + op.param = card_idx; + } + return can_add; +} + +/*! + * Set the current memory card operation to create the save file. + * The data I believe is just an empty buffer. + */ +u64 MC_createfile(s32 param, Ptr data) { + u64 can_add = op.operation == MemoryCardOperationKind::NO_OP; + if (can_add) { + op.operation = MemoryCardOperationKind::CREATE_FILE; + op.result = McStatusCode::BUSY; + op.counter = 100; + op.param = param; + op.data_ptr = data; + } + return can_add; +} + +/*! + * Set the current operation to SAVE. + */ +u64 MC_save(s32 card_idx, s32 file_idx, Ptr save_data, Ptr save_summary_data) { + u64 can_add = op.operation == MemoryCardOperationKind::NO_OP; + if (can_add) { + op.operation = MemoryCardOperationKind::SAVE; + op.result = McStatusCode::BUSY; + op.counter = 100; + op.param = card_idx; + op.param2 = file_idx; + op.data_ptr = save_data; + op.data_ptr2 = save_summary_data; + } + return can_add; +} + +u64 MC_load(s32 card_idx, s32 file_idx, Ptr data) { + u64 can_add = op.operation == MemoryCardOperationKind::NO_OP; + if (can_add) { + op.operation = MemoryCardOperationKind::LOAD; + op.result = McStatusCode::BUSY; + op.counter = 100; + op.param = card_idx; + op.param2 = file_idx; + op.data_ptr = data; + } + return can_add; +} + +/*! + * Some sort of test function for memory card stuff. + * This is exported as a GOAL function, but nothing calls it. + */ +void MC_makefile(s32 port, s32 size) { + sceMcMkdir(port, 0, "/BASCUS-00000XXXXXXXX"); + // wait for operation to complete + s32 cmd, result, fd; + sceMcSync(0, &cmd, &result); + + if (result == sceMcResSucceed || result == sceMcResNoEntry) { + // it worked, or the folder already exists... + + // open file + sceMcOpen(port, 0, "/BASCUS-00000XXXXXXXX/BASCUS-00000XXXXXXXX", SCE_CREAT | SCE_WRONLY); + sceMcSync(0, &cmd, &fd); + + if (result < 0) { + printf("Can\'t open file on memcard [%d]\n", result); + } else { + // write some random crap into the memory card. + sceMcWrite(fd, Ptr(0x1000000).c(), size); + sceMcSync(0, &cmd, &result); + if (result != size) { + printf("Only written %d bytes\n", result); + } + sceMcClose(fd); + sceMcSync(0, &cmd, &result); + } + } else { + printf("Can\'t create garbage folder [%d]\n", result); + } +} + +u32 MC_check_result() { + return (u32)op.result; +} + +void MC_get_status(s32 slot, Ptr info) { + info->handle = 0; + info->known = 0; + info->formatted = 0; + info->initted = 0; + for (s32 i = 0; i < 4; i++) { + info->files[i].present = 0; + } + info->last_file = 0xffffffff; + info->mem_required = SAVE_SIZE; + info->mem_actual = 0; + + switch (mc[slot].state) { + case MemoryCardState::KNOWN: + info->known = 1; + break; + case MemoryCardState::OPEN: + info->known = 1; + info->handle = mc[slot].handle; + break; + case MemoryCardState::FORMATTED: + info->known = 1; + info->handle = mc[slot].handle; + info->formatted = 1; + if (mc[slot].inited == 0) { + info->mem_actual = mc[slot].mem_size; + } else { + info->initted = 1; + for (s32 file = 0; file < 4; file++) { + info->files[file].present = mc[slot].files[file].present; + for (s32 i = 0; i < 64; i++) { // actually a loop over u32's + info->files[file].data[i] = mc[slot].files[file].data[i]; + } + } + info->last_file = mc[slot].last_file; + } + case MemoryCardState::UNKNOWN: + break; + } +} + +/*! + * Check for an error. Returns true if there is an error and sets op.result as needed + */ +u64 cb_check(s32 sony_error, McStatusCode goal_error) { + if (sony_error < 0) { + // sony thing failed. + if (sony_error < -9) { + // memory card gone. reset state + mc[p1].state = MemoryCardState::UNKNOWN; + // kill in progress op + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + return 1; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = goal_error; + return 1; + } + } + return 0; +} + +// cb check open +// cb check read +// cb check close +// cb reprobe + +void cb_reprobe_format(s32 sync_result) { + if (sync_result == sceMcResSucceed) { + // get info succeeded. we can format. + s32 format_result = sceMcFormat(p1, 0); + if (format_result == sceMcResSucceed) { + callback = cb_format_complete; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else { + // get info failed. Revert the state to unknown, this will restart everything. + mc[p1].state = MemoryCardState::UNKNOWN; + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } +} + +void cb_format_complete(s32 sync_result) { + if (sync_result == sceMcResSucceed) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::OK; + mc[p1].state = MemoryCardState::FORMATTED; + mc[p1].formatted = 100; + mc[p1].inited = 0; + for (int i = 0; i < 4; i++) { + mc[p1].files[i].present = 0; + } + mc[p1].last_file = -1; + mc[p1].mem_size = 8000; + } else { + mc[p1].state = MemoryCardState::UNKNOWN; + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::FORMAT_FAILED; + } +} + +void cb_unformat(s32 sync_result) { + if (sync_result == sceMcResSucceed) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::OK; + mc[p1].state = MemoryCardState::UNKNOWN; + } else { + mc[p1].state = MemoryCardState::UNKNOWN; + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::FORMAT_FAILED; + } +} + +void cb_reprobe_createfile(s32 sync_result) { + if (sync_result == sceMcResSucceed) { + // if the ramdisk is ready, just jump directly to its callback + if (!RpcBusy(RAMDISK_RPC_CHANNEL)) { + cb_wait_for_ramdisk(0); + } else { + // otherwise, don't. + callback = cb_wait_for_ramdisk; + } + } else { + mc[p1].state = MemoryCardState::UNKNOWN; + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } +} + +void cb_wait_for_ramdisk(s32) { + RPC_Ramdisk_LoadCmd cmd; + cmd.pad = 0; + cmd.file_id_or_ee_addr = op.data_ptr.offset; + cmd.offset_into_file = 0; + cmd.size = 0x1e800; + memcpy(cmd.name, "SAVEGAME.ICO", 13); // was 16. + RpcCall(RAMDISK_RPC_CHANNEL, RAMDISK_BYPASS_LOAD_FILE, 1, &ramdisk_cmd, 0x20, nullptr, 0); + callback = cb_wait_for_ramdisk_load; +} + +void cb_wait_for_ramdisk_load(s32) { + if (RpcBusy(RAMDISK_RPC_CHANNEL) == 0) { + p2 = 11; // filenames left to delete + if (sceMcDelete(p1, 0, filename[11]) == sceMcResSucceed) { + callback = cb_createfile_erasing; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else { + callback = cb_wait_for_ramdisk_load; + } +} + +void cb_createfile_erasing(s32 sync_result) { + if (sync_result == sceMcResSucceed || sync_result == sceMcResNoEntry || + sync_result == sceMcResNotEmpty) { + mc[p1].inited = 0; + // delete didn't fail. + if (p2 < 1) { + // on the last one. which is the directory to create. + if (sceMcMkdir(p1, 0, filename[0]) == sceMcResSucceed) { + callback = cb_createdir; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else { + p2--; + if (sceMcDelete(p1, 0, filename[p2]) == sceMcResSucceed) { + callback = cb_createfile_erasing; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } else { + if (sync_result == sceMcResDeniedPermit) { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } else { + mc[p1].state = MemoryCardState::UNKNOWN; + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::BAD_HANDLE; + } + } +} + +void cb_createdir(s32 sync_result) { + if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { + // this sets up some stuff for the icon file that we will ignore. + // memset(&iconsys,0,0x3c4); + // kstrcpy(&iconsys,&DAT_00137000); + // if (language == Language::Japanese) { + // kstrcpy(&DAT_00137560,titles[5]); + // } else { + // // non japanese need to convert to shift-JIS format. + // ASCII2SJIS(&DAT_00137560,titles[language]); + // } + // DAT_001374a6 = 0x20; + // DAT_001374ac = 0; + // memcpy(&DAT_001374b0,bgcolor.610,0x40); + // memcpy(&DAT_001374f0,lightdir.611,0x30); + // memcpy(&DAT_00137520,lightcol.612,0x30); + // memcpy(&DAT_00137550,ambient.613,0x10); + // kstrcpy(&DAT_001375a4,"icon.ico"); + // kstrcpy(&DAT_001375e4,"icon.ico"); + // kstrcpy(&DAT_00137624,"icon.ico"); + + p2 = 1; + if (sceMcOpen(p1, 0, filename[1], 0x203) == 0) { + callback = cb_createdfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } +} + +void cb_createdfile(s32 sync_result) { + if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { + if (p2 == 1) { + p3 = sync_result; // the fd of the icon file. + // actually would write the icon sys file. + if (sceMcWrite(sync_result, nullptr, 0) == sceMcResSucceed) { + callback = cb_writtenfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else if (p2 == 2) { + p3 = sync_result; + // would write the icon data (ramdisk loaded into the temp buffer) + if (sceMcWrite(sync_result, nullptr, 0) == sceMcResSucceed) { + callback = cb_writtenfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else if (p2 == 3) { + p3 = sync_result; + kstrcpy(op.data_ptr.cast().c(), "Nope, the save game data isn\'t in this file!\n"); + if (sceMcWrite(p3, op.data_ptr.c(), strlen((const char*)op.data_ptr.c())) == + sceMcResSucceed) { + callback = cb_writtenfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else { + p3 = sync_result; + memset(op.data_ptr.c(), 0, 0x11800); + if (sceMcWrite(p3, op.data_ptr.c(), 0x11800)) { + callback = cb_writtenfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } + } +} + +void cb_writtenfile(s32 sync_result) { + if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { + if (sceMcClose(p3) == sceMcResSucceed) { + callback = cb_closedfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } +} + +void cb_closedfile(s32 sync_result) { + if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { + p2++; + if (p2 < 0xc) { + if (sceMcOpen(p1, 0, filename[p2], 0x203) == sceMcResSucceed) { + callback = cb_createdfile; + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::INTERNAL_ERROR; + } + } else { + op.operation = MemoryCardOperationKind::NO_OP; + op.result = McStatusCode::OK; + mc[p1].inited = 1; + for (int i = 0; i < 4; i++) { + mc[p1].files[i].present = 0; + } + mc[p1].last_file = -1; + } + } +} + +void cb_reprobe_save(s32) { + assert(false); +} \ No newline at end of file diff --git a/game/kernel/kmemcard.h b/game/kernel/kmemcard.h index f40781e446..ad36d88e23 100644 --- a/game/kernel/kmemcard.h +++ b/game/kernel/kmemcard.h @@ -12,21 +12,63 @@ void kmemcard_init_globals(); constexpr s32 SAVE_SIZE = 0x2b3; // likely different by versions! -enum MemoryCardOperationKind { +enum class MemoryCardState : u32 { UNKNOWN = 0, KNOWN = 1, OPEN = 2, FORMATTED = 3 }; + +// cached in ee memory so we can preview. +struct MemoryCardFile { + u32 present; + u32 pad1; + u32 pad2; + u8 data[64]; +}; + +// type of the mc field. +struct MemoryCard { + MemoryCardState state; + u32 handle; + u32 formatted; + u32 inited; + u32 last_file; + u32 mem_size; + MemoryCardFile files[4]; +}; + +enum class MemoryCardOperationKind : u32 { NO_OP = 0, - FORMAT = 1, - UNFORMAT = 2, - CREATE_FILE = 3, + FORMAT = 1, // (handle, unused), (slot, type, free, format) + UNFORMAT = 2, // (handle, unused), (slot) + CREATE_FILE = 3, // (handle, unused) SAVE = 4, LOAD = 5, }; +enum class McStatusCode : u32 { + 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 +}; + struct MemoryCardOperation { - uint32_t operation; + MemoryCardOperationKind operation; uint32_t param; uint32_t param2; - uint32_t result; - uint32_t f_10; + McStatusCode result; + uint32_t counter; Ptr data_ptr; Ptr data_ptr2; }; @@ -36,43 +78,24 @@ struct mc_file_info { u8 data[64]; }; -struct mc_file_info_2 { - u32 present; - u32 pad1; - u32 pad2; - u8 data[64]; -}; - struct mc_slot_info { u32 handle; u32 known; u32 formatted; u32 initted; - u32 last_file; + s32 last_file; u32 mem_required; u32 mem_actual; mc_file_info files[4]; }; -struct mc_info { - s32 p0; - s32 handle; - s32 inited; - s32 mem_actual; - s32 last_file; - mc_file_info_2 files[4]; -}; - -s32 new_mc_handle(); -u32 mc_checksum(Ptr data, s32 size); -u32 handle_to_slot(s32 p1, s32 p2); -void MC_run(); void MC_set_language(s32 lang); -u64 MC_format(s32 param); -u64 MC_unformat(s32 param); +void MC_run(); +u64 MC_format(s32 card_idx); +u64 MC_unformat(s32 card_idx); u64 MC_createfile(s32 param, Ptr data); -u64 MC_save(s32 param, s32 param2, Ptr data, Ptr data2); -u64 MC_load(s32 param, s32 param2, Ptr data); +u64 MC_save(s32 card_idx, s32 file_idx, Ptr save_data, Ptr save_summary_data); +u64 MC_load(s32 card_idx, s32 file_idx, Ptr data); void MC_makefile(s32 port, s32 size); -u32 MC_check_result(); void MC_get_status(s32 slot, Ptr info); +u32 MC_check_result(); \ No newline at end of file diff --git a/game/kernel/kscheme.cpp b/game/kernel/kscheme.cpp index 3e1d29ccfa..1d0a6f66ee 100644 --- a/game/kernel/kscheme.cpp +++ b/game/kernel/kscheme.cpp @@ -1937,15 +1937,15 @@ s32 InitHeapAndSymbol() { // game stuff make_stack_arg_function_symbol_from_c("link-begin", (void*)link_begin); make_function_symbol_from_c("link-resume", (void*)link_resume); - // make_function_symbol_from_c("mc-run", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-format", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-unformat", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-create-file", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-save", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-load", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-check-result", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-get-slot-info", &CKernel::not_yet_implemented); - // make_function_symbol_from_c("mc-makefile", &CKernel::not_yet_implemented); + make_function_symbol_from_c("mc-run", (void*)MC_run); + make_function_symbol_from_c("mc-format", (void*)MC_format); + make_function_symbol_from_c("mc-unformat", (void*)MC_unformat); + make_function_symbol_from_c("mc-create-file", (void*)MC_createfile); + make_function_symbol_from_c("mc-save", (void*)MC_save); + make_function_symbol_from_c("mc-load", (void*)MC_load); + make_function_symbol_from_c("mc-check-result", (void*)MC_check_result); + make_function_symbol_from_c("mc-get-slot-info", (void*)MC_get_status); + make_function_symbol_from_c("mc-makefile", (void*)MC_makefile); make_function_symbol_from_c("kset-language", (void*)MC_set_language); // set *debug-segment* diff --git a/game/sce/sif_ee.cpp b/game/sce/sif_ee.cpp index c14075d7d8..acbf88bfae 100644 --- a/game/sce/sif_ee.cpp +++ b/game/sce/sif_ee.cpp @@ -68,10 +68,6 @@ int sceSifLoadModule(const char* name, int arg_size, const char* args) { return 1; } -int sceMcInit() { - return 1; -} - s32 sceSifCallRpc(sceSifClientData* bd, u32 fno, u32 mode, @@ -178,4 +174,185 @@ s32 sceLseek(s32 fd, s32 offset, s32 where) { } } +/*! + * The actual data stored on the memory card. + */ +struct CardData { + // each file has a name and data. + struct File { + std::string name; + std::vector data; + }; + // can be formatted or unformatted card. + u32 is_formatted = 0; + std::unordered_map files; +}; + +/*! + * The actual memory card library state + current data. + */ +struct McState { + s32 current_function = -1; // -1 = nothing + s32 current_function_result = 0; + + struct McFileHandle { + std::string name; + u32 fd = 0; + s32 mode = 0; + }; + + std::unordered_map handles; + + // TODO: we should load this data at startup from a memory card file, and save it at each write. + CardData data; + int next_fd = 1; +} g_mc_state; + +int sceMcInit() { + g_mc_state = McState(); + return 1; +} + +s32 sceMcMkdir(s32 port, s32 slot, const char* name) { + assert(port == 0); + assert(slot == 0); + // TODO name + (void)name; + return sceMcResSucceed; +} + +s32 sceMcSync(s32 mode, s32* cmd, s32* result) { + // don't care about the mode, all memory card ops are instant. + assert(mode == 1 || mode == 0); + if (g_mc_state.current_function == -1) { + return sceMcExecIdle; + } else { + *cmd = g_mc_state.current_function; + *result = g_mc_state.current_function_result; + g_mc_state.current_function = -1; + return sceMcExecFinish; + } +} + +s32 sceMcOpen(s32 port, s32 slot, const char* name, s32 mode) { + assert(port == 0); + assert(slot == 0); + assert(g_mc_state.current_function == -1); + + // add existing file, if it does not exist. + auto existing_file = g_mc_state.data.files.find(name); + if (existing_file == g_mc_state.data.files.end()) { + assert(mode & SCE_CREAT); + g_mc_state.data.files[name] = {}; + } + + // create a handle. + g_mc_state.current_function = sceMcFuncNoOpen; + s32 fd = g_mc_state.next_fd++; + McState::McFileHandle handle; + handle.name = name; + handle.fd = fd; + handle.mode = mode; + g_mc_state.handles[fd] = handle; + + g_mc_state.current_function_result = fd; + return 0; +} + +s32 sceMcWrite(s32 fd, const void* buff, s32 size) { + assert(g_mc_state.current_function == -1); + + assert(size >= 0 && size < (1024 * 1024 * 1024)); + auto hand = g_mc_state.handles.find(fd); + assert(hand != g_mc_state.handles.end()); // make sure fd is valid + assert(hand->second.mode & SCE_WRONLY); // make sure we're allowed to write + + const auto& file = g_mc_state.data.files.find(hand->second.name); + assert(file != g_mc_state.data.files.end()); + + file->second.data.resize(size); + memcpy(file->second.data.data(), buff, size); + + // TODO: save memcard data to a file. + + g_mc_state.current_function = sceMcFuncNoWrite; + g_mc_state.current_function_result = size; + return 0; +} + +s32 sceMcClose(s32 fd) { + assert(g_mc_state.current_function == -1); + auto hand = g_mc_state.handles.find(fd); + assert(hand != g_mc_state.handles.end()); // make sure fd is valid + g_mc_state.handles.erase(fd); + g_mc_state.current_function = sceMcFuncNoClose; + g_mc_state.current_function_result = sceMcResSucceed; + return 0; +} + +s32 sceMcGetInfo(s32 port, s32 slot, s32* type, s32* free, s32* format) { + assert(g_mc_state.current_function == -1); + assert(port == 0); + assert(slot == 0); + if (type) { + *type = sceMcTypePS2; + } + + if (free) { + *free = 2 * 1024; // number of free 1 kB clusters + } + + if (format) { + *format = g_mc_state.data.is_formatted; + } + + g_mc_state.current_function = sceMcFuncNoCardInfo; + + // technically this should return something else the first time you call this function after + // changing cards. + g_mc_state.current_function_result = sceMcResSucceed; + return 0; +} + +s32 sceMcFormat(s32 port, s32 slot) { + assert(g_mc_state.current_function == -1); + assert(port == 0); + assert(slot == 0); + g_mc_state.data.is_formatted = true; + g_mc_state.current_function_result = sceMcResSucceed; + g_mc_state.current_function = sceMcFuncNoFormat; + return 0; +} + +s32 sceMcUnformat(s32 port, s32 slot) { + assert(g_mc_state.current_function == -1); + assert(port == 0); + assert(slot == 0); + g_mc_state.data.is_formatted = false; + g_mc_state.current_function_result = sceMcResSucceed; + g_mc_state.current_function = sceMcFuncNoUnformat; + return 0; +} + +s32 sceMcDelete(s32 port, s32 slot, const char* name) { + assert(g_mc_state.current_function == -1); + assert(port == 0); + assert(slot == 0); + g_mc_state.current_function = sceMcFuncNoDelete; + + if (!g_mc_state.data.is_formatted) { + g_mc_state.current_function_result = sceMcResNoFormat; + } else { + auto it = g_mc_state.data.files.find(name); + if (it == g_mc_state.data.files.end()) { + g_mc_state.current_function_result = sceMcResNoEntry; + } else { + // sometimes should be sceMcResNotEmpty, but doesn't matter. + g_mc_state.current_function_result = sceMcResSucceed; + g_mc_state.data.files.erase(it); + } + } + + return 0; +} } // namespace ee \ No newline at end of file diff --git a/game/sce/sif_ee.h b/game/sce/sif_ee.h index 51694db95a..4650f1ca24 100644 --- a/game/sce/sif_ee.h +++ b/game/sce/sif_ee.h @@ -1,8 +1,5 @@ #pragma once -#ifndef JAK1_SIF_EE_H -#define JAK1_SIF_EE_H - #include "common/common_types.h" class IOP; @@ -70,11 +67,41 @@ s32 sceSifBindRpc(sceSifClientData* bd, u32 request, u32 mode); #define SCE_NOBUF 0x4000 #define SCE_NOWAIT 0x8000 +#define sceMcExecIdle (-1) +#define sceMcExecRun 0 +#define sceMcExecFinish 1 + +#define sceMcResSucceed 0 +#define sceMcResNoFormat (-2) +#define sceMcResNoEntry (-4) +#define sceMcResDeniedPermit (-5) +#define sceMcResNotEmpty (-6) + +#define sceMcFuncNoCardInfo 1 +#define sceMcFuncNoOpen 2 +#define sceMcFuncNoClose 3 +#define sceMcFuncNoWrite 6 +#define sceMcFuncNoFormat 16 +#define sceMcFuncNoDelete 15 +#define sceMcFuncNoUnformat 17 + +#define sceMcTypePS2 2 + s32 sceOpen(const char* filename, s32 flag); s32 sceClose(s32 fd); s32 sceRead(s32 fd, void* buf, s32 nbyte); s32 sceWrite(s32 fd, const void* buf, s32 nbyte); s32 sceLseek(s32 fd, s32 offset, s32 where); +s32 sceMcMkdir(s32 port, s32 slot, const char* name); +s32 sceMcSync(s32 mode, s32* cmd, s32* result); +s32 sceMcOpen(s32 port, s32 slot, const char* name, s32 mode); +s32 sceMcWrite(s32 fd, const void* buff, s32 size); +s32 sceMcClose(s32 fd); + +s32 sceMcGetInfo(s32 port, s32 slot, s32* type, s32* free, s32* format); +s32 sceMcFormat(s32 port, s32 slot); +s32 sceMcUnformat(s32 port, s32 slot); +s32 sceMcDelete(s32 port, s32 slot, const char* name); + } // namespace ee -#endif // JAK1_SIF_EE_H diff --git a/goal_src/engine/ambient/mood.gc b/goal_src/engine/ambient/mood.gc index 7375b23ad7..ae4c8ae38e 100644 --- a/goal_src/engine/ambient/mood.gc +++ b/goal_src/engine/ambient/mood.gc @@ -343,10 +343,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-sun-table data 0 env-color)) - (the-as uint (* s5-0 32)) - ) + (+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s5-0 32)) ) ) ) @@ -366,17 +363,11 @@ (-> arg0 current-sun env-color) (the-as vector - (+ - (the-as uint (-> arg0 mood-sun-table data 0 env-color)) - (the-as uint (* s5-0 32)) - ) + (+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s5-0 32)) ) (the-as vector - (+ - (the-as uint (-> arg0 mood-sun-table data 0 env-color)) - (the-as uint (* s4-0 32)) - ) + (+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* s4-0 32)) ) f30-0 ) @@ -438,10 +429,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-fog-table data 0 fog-dists)) - (the-as uint (* 48 arg1)) - ) + (+ (the-as uint (-> arg0 mood-fog-table data 0 fog-dists)) (* 48 arg1)) ) ) ) @@ -450,10 +438,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-fog-table data 0 erase-color)) - (the-as uint (* 48 arg1)) - ) + (+ (the-as uint (-> arg0 mood-fog-table data 0 erase-color)) (* 48 arg1)) ) ) ) @@ -462,10 +447,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-lights-table data 0 prt-color)) - (the-as uint (* 80 arg3)) - ) + (+ (the-as uint (-> arg0 mood-lights-table data 0 prt-color)) (* 80 arg3)) ) ) ) @@ -478,10 +460,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-sun-table data 0 env-color)) - (the-as uint (* arg2 32)) - ) + (+ (the-as uint (-> arg0 mood-sun-table data 0 env-color)) (* arg2 32)) ) ) ) @@ -490,10 +469,7 @@ (-> (the-as (pointer uint128) - (+ - (the-as uint (-> arg0 mood-lights-table data 0 shadow)) - (the-as uint (* 80 arg3)) - ) + (+ (the-as uint (-> arg0 mood-lights-table data 0 shadow)) (* 80 arg3)) ) ) ) @@ -723,7 +699,7 @@ (arg6 float) ) (let* ((s5-0 (&-> arg0 state arg3)) - (s4-0 (+ (-> s5-0 0) (the-as uint arg1))) + (s4-0 (+ (-> s5-0 0) arg1)) (a0-1 (-> s5-0 1)) (v1-2 (-> s5-0 2)) (s0-0 (-> s5-0 3)) @@ -1028,6 +1004,7 @@ ;; definition for function update-mood-lightning ;; ERROR: function was not converted to expressions. Cannot decompile. +(define-extern update-mood-lightning (function mood-context int int int int float symbol none)) ;; definition of type light-time-state (deftype light-time-state (structure) @@ -1077,12 +1054,7 @@ (arg7 int) ) (let* ((gp-0 (&-> arg0 state arg2)) - (f0-1 - (the - float - (* (logand (+ (-> arg0 state arg3) (the-as uint arg7)) 255) 512) - ) - ) + (f0-1 (the float (* (logand (+ (-> arg0 state arg3) arg7) 255) 512))) (f0-4 (+ arg4 (* (cos f0-1) arg5))) (f30-1 (* 0.003921569 (the float (-> gp-0 0)))) ) @@ -1153,6 +1125,7 @@ ;; definition for function update-mood-lava ;; ERROR: function was not converted to expressions. Cannot decompile. +(define-extern update-mood-lava (function mood-context float int symbol none)) ;; definition for function update-mood-caustics (defun update-mood-caustics ((arg0 mood-context) (arg1 int) (arg2 int)) @@ -1161,9 +1134,9 @@ (f0-1 (* 0.125 (the float (logand a2-1 7)))) ) (let ((a2-4 (logand (+ v1-2 -1) 3))) - (set! (-> arg0 times (+ arg1 (the-as int a2-4)) w) (- 1.0 f0-1)) + (set! (-> arg0 times (+ arg1 a2-4) w) (- 1.0 f0-1)) ) - (set! (-> arg0 times (+ arg1 (the-as int v1-2)) w) f0-1) + (set! (-> arg0 times (+ arg1 v1-2) w) f0-1) f0-1 ) ) @@ -1282,7 +1255,7 @@ (update-mood-palette arg0 arg1 arg2) (when *time-of-day-effects* (update-mood-flames arg0 4 4 0 0.333 0.001953125 1.0) - ; TODO (update-mood-lightning arg0 2 2 4 2 0.5 #f) + (update-mood-lightning arg0 2 2 4 2 0.5 #f) ) (let ((a0-7 (-> arg0 light-group 1))) (update-light-kit a0-7 (-> arg0 light-group 0 ambi) 0.9) @@ -1404,7 +1377,7 @@ (update-mood-palette arg0 arg1 arg2) (when *time-of-day-effects* (update-mood-flames arg0 4 4 0 0.333 0.001953125 1.0) - ; TODO (update-mood-lightning arg0 2 2 4 2 0.5 #f) + (update-mood-lightning arg0 2 2 4 2 0.5 #f) ) (let ((f30-0 (fmax 0.0 (-> *math-camera* camera-rot vector 1 z)))) (let ((a2-4 (new 'stack-no-clear 'vector))) @@ -1986,10 +1959,7 @@ (* 0.0625 (cos - (the - float - (* 4000 (the-as int (-> *display* integral-frame-counter))) - ) + (the float (* 4000 (-> *display* integral-frame-counter))) ) ) ) @@ -2000,12 +1970,7 @@ ) (* 0.125 - (cos - (the - float - (* 1500 (the-as int (-> *display* integral-frame-counter))) - ) - ) + (cos (the float (* 1500 (-> *display* integral-frame-counter)))) ) ) ) @@ -2145,7 +2110,7 @@ (if (not (paused?)) (+! (-> arg0 state 4) 1) ) - ; TODO (update-mood-lightning arg0 2 2 5 2 0.5 #t) + (update-mood-lightning arg0 2 2 5 2 0.5 #t) ) (let ((a0-10 (-> arg0 light-group 1))) (update-light-kit a0-10 (-> arg0 light-group 0 ambi) 1.0) @@ -2242,10 +2207,7 @@ (let ((f0-19 (vector-vector-distance - (the-as - vector - (+ (the-as uint *rolling-spheres-light2*) (the-as uint (* s4-4 16))) - ) + (the-as vector (+ (the-as uint *rolling-spheres-light2*) (* s4-4 16))) s5-3 ) ) @@ -2343,9 +2305,9 @@ (update-mood-sky-texture arg0 arg1) (clear-mood-times arg0) (update-mood-palette arg0 arg1 arg2) - ; (if *time-of-day-effects* - ; ;; TODO (update-mood-lava arg0 (the-as float 4) 0 #t) - ; ) + (if *time-of-day-effects* + (update-mood-lava arg0 (the-as float 4) 0 #t) + ) (update-mood-itimes arg0) 0 (none) @@ -2948,7 +2910,7 @@ (if (not (paused?)) (+! (-> arg0 some-byte) 1) ) - ;; TODO - (update-mood-lava arg0 (the-as float 4) 0 #t) + (update-mood-lava arg0 (the-as float 4) 0 #t) ) (update-mood-quick arg0 0 0 0 arg2) (update-mood-itimes arg0) @@ -3005,9 +2967,9 @@ (rand-vu-float-range 64.0 2048.0) ) ) - ; (if (not (movie?)) - ; ; TODO (update-mood-lightning arg0 2 2 18 4 0.5 #f) - ; ) + (if (not (movie?)) + (update-mood-lightning arg0 2 2 18 4 0.5 #f) + ) (cond ((or (nonzero? *lightning-time2*) (movie?)) (if (not (paused?)) @@ -3334,11 +3296,11 @@ (when (and *target* (= (-> *target* next-state name) 'target-continue)) (set! (-> (the-as (pointer int64) s4-0) 0) - (the-as int (+ (-> *display* base-frame-counter) -10000)) + (+ (-> *display* base-frame-counter) -10000) ) (set! (-> (the-as (pointer int64) s4-0) 1) - (the-as int (+ (-> *display* base-frame-counter) -10000)) + (+ (-> *display* base-frame-counter) -10000) ) ) (update-mood-fog arg0 arg1) @@ -3412,7 +3374,7 @@ float (- (-> *display* base-frame-counter) - (the-as uint (-> (the-as (pointer int64) s4-0) 1)) + (-> (the-as (pointer int64) s4-0) 1) ) ) ) @@ -3455,7 +3417,7 @@ (else (set! (-> (the-as (pointer int64) s4-0) 1) - (the-as int (-> *display* base-frame-counter)) + (-> *display* base-frame-counter) ) ) ) @@ -3467,7 +3429,7 @@ float (- (-> *display* base-frame-counter) - (the-as uint (-> (the-as (pointer int64) s4-0) 0)) + (-> (the-as (pointer int64) s4-0) 0) ) ) ) @@ -3501,7 +3463,7 @@ (set! (-> *time-of-day-proc* 0 frame) 0) (set! (-> (the-as (pointer int64) s4-0) 0) - (the-as int (-> *display* base-frame-counter)) + (-> *display* base-frame-counter) ) (dotimes (v1-72 8) (set! (-> arg0 sky-times v1-72) 0.0) @@ -3701,13 +3663,7 @@ (* 0.125 (cos - (the - float - (* - 4000 - (the-as int (-> *display* integral-frame-counter)) - ) - ) + (the float (* 4000 (-> *display* integral-frame-counter))) ) ) ) @@ -3721,10 +3677,7 @@ (* 0.25 (cos - (the - float - (* 1500 (the-as int (-> *display* integral-frame-counter))) - ) + (the float (* 1500 (-> *display* integral-frame-counter))) ) ) ) @@ -3812,4 +3765,4 @@ ) (update-mood-itimes arg0) (none) - ) + ) \ No newline at end of file diff --git a/goal_src/engine/collide/collide-target-h.gc b/goal_src/engine/collide/collide-target-h.gc index bc1b5ccd4e..75e9f9c007 100644 --- a/goal_src/engine/collide/collide-target-h.gc +++ b/goal_src/engine/collide/collide-target-h.gc @@ -17,7 +17,7 @@ (transv-out vector :inline :offset-assert 48) (local-normal vector :inline :offset-assert 64) (surface-normal vector :inline :offset-assert 80) - (time uint64 :offset-assert 96) + (time int64 :offset-assert 96) (status uint64 :offset-assert 104) (pat pat-surface :offset-assert 112) (reaction-flag uint32 :offset-assert 116) diff --git a/goal_src/engine/engine/connect.gc b/goal_src/engine/engine/connect.gc index bb386b2903..6401fae166 100644 --- a/goal_src/engine/engine/connect.gc +++ b/goal_src/engine/engine/connect.gc @@ -86,7 +86,7 @@ ((name basic :offset-assert 4) (length int16 :offset-assert 8) ;; in use elts of the data array (allocated-length int16 :offset-assert 10) ;; size of the data array - (engine-time uint64 :offset-assert 16) ;; frame that we last executed + (engine-time int64 :offset-assert 16) ;; frame that we last executed ;; terminating nodes for the next0/prev0 linked lists (alive-list connectable :inline :offset-assert 32) diff --git a/goal_src/engine/game/fact-h.gc b/goal_src/engine/game/fact-h.gc index 291c42786f..356f071b14 100644 --- a/goal_src/engine/game/fact-h.gc +++ b/goal_src/engine/game/fact-h.gc @@ -70,7 +70,7 @@ ;; amounts or timings ;; The fact-info class stores data that is common to all fact-infos. (deftype fact-info (basic) - ((process process :offset-assert 4) ;; the process that this info is for + ((process process-drawable :offset-assert 4) ;; the process that this info is for (pickup-type pickup-type :offset-assert 8) (pickup-amount float :offset-assert 12) ;; eco increment on pickup (pickup-spawn-amount float :offset-assert 16) @@ -81,10 +81,10 @@ :size-assert #x28 :flag-assert #xc00000028 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) (TODO-RENAME-9 (_type_ symbol process-tree fact-info int) uint 9) ;; See nav-enemy::process-drawable-death-event-handler (reset! (_type_ symbol) none 10) - (dummy-11 (_type_) float 11) + (pickup-collectable! (_type_ pickup-type float handle) float 11) ) ) @@ -100,7 +100,7 @@ (eco-pill float :offset-assert 80) (eco-pill-max float :offset-assert 84) (health-pickup-time uint64 :offset-assert 88) - (eco-source uint64 :offset-assert 96) + (eco-source handle :offset-assert 96) (eco-source-time uint64 :offset-assert 104) (money-pickup-time uint64 :offset-assert 112) (buzzer-pickup-time uint64 :offset-assert 120) @@ -111,7 +111,7 @@ :size-assert #x90 :flag-assert #xc00000090 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) @@ -128,11 +128,13 @@ :size-assert #x44 :flag-assert #xc00000044 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) -(defmethod new fact-info ((allocation symbol) (type-to-make type) (proc process) (pkup-type pickup-type) (pkup-amount float)) +(declare-type process-drawable process) + +(defmethod new fact-info ((allocation symbol) (type-to-make type) (proc process-drawable) (pkup-type pickup-type) (pkup-amount float)) "Create information about a pickup. This should be called from a process which is a pickup. This will read settings from the entity of the process automatically. Will attempt to read pickup-type and amount from the entity, but if this fails will use the values in the arguments" @@ -190,11 +192,11 @@ ) ) -(defmethod dummy-11 fact-info ((obj fact-info)) +(defmethod pickup-collectable! fact-info ((obj fact-info) (arg0 pickup-type) (arg1 float) (arg2 handle)) 0.0 ) -(defmethod new fact-info-enemy ((allocation symbol) (type-to-make type) (proc process) (kind pickup-type) (amount float)) +(defmethod new fact-info-enemy ((allocation symbol) (type-to-make type) (proc process-drawable) (kind pickup-type) (amount float)) "Create information about an enemy. Possibly includes what the enemy will drop when it is killed?" ;; base class ctor (let ((obj (the-as fact-info-enemy ((method-of-type fact-info new) allocation type-to-make proc kind amount)))) @@ -212,10 +214,10 @@ ) ) -(defmethod new fact-info-target ((allocation symbol) (type-to-make type) (arg0 process) (arg1 pickup-type) (arg2 float)) +(defmethod new fact-info-target ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 pickup-type) (arg2 float)) "Create information about target. Not sure why this has stuff like pickup-type." (let ((obj (the-as fact-info-target ((method-of-type fact-info new) allocation type-to-make arg0 arg1 arg2)))) - (set! (-> obj eco-source) (the-as uint #f)) + (set! (-> obj eco-source) (the-as handle #f)) (reset! obj #f) obj ) diff --git a/goal_src/engine/game/game-info-h.gc b/goal_src/engine/game/game-info-h.gc index 3067bfe43c..a622f32a33 100644 --- a/goal_src/engine/game/game-info-h.gc +++ b/goal_src/engine/game/game-info-h.gc @@ -271,7 +271,7 @@ (death-movie-tick int32 :offset-assert 264) (want-auto-save symbol :offset-assert 268) (auto-save-proc handle :offset-assert 272) - (auto-save-status uint32 :offset-assert 280) + (auto-save-status mc-status-code :offset-assert 280) (auto-save-card int32 :offset-assert 284) (auto-save-which int32 :offset-assert 288) (pov-camera-handle handle :offset-assert 296) @@ -299,7 +299,7 @@ (seen-text? (_type_ game-text-id) symbol 21) (mark-text-as-seen (_type_ game-text-id) none 22) (got-buzzer? (_type_ game-task int) symbol 23) - (dummy-24 () none 24) + (save-game! (_type_ game-save string) none 24) (load-game! (_type_ game-save) game-save 25) (clear-text-seen! (_type_ game-text-id) none 26) (get-death-count (_type_ symbol) int 27) diff --git a/goal_src/engine/game/game-info.gc b/goal_src/engine/game/game-info.gc index 83677382f7..d948bba8b3 100644 --- a/goal_src/engine/game/game-info.gc +++ b/goal_src/engine/game/game-info.gc @@ -5,6 +5,18 @@ ;; name in dgo: game-info ;; dgos: GAME, ENGINE +;; The game-info is the logic for pickups/lives/eco/tasks/collectables/check points/saved data +;; The *game-info* object constains the "game state", like how many lives you have etc. + +;; The "perm" data is saved to the memory card. + + +;;;;;;;;;;;;;;;;;; +;; border plane +;;;;;;;;;;;;;;;;;; + +;; This border-plane seems to be unused. This is separate from load boundaries. + (defmethod debug-draw! border-plane ((obj border-plane)) "Debug draw a border plane with a vector and text." (let* ((v1-0 (-> obj action)) @@ -35,7 +47,7 @@ (defmethod task-complete? game-info ((obj game-info) (arg0 game-task)) "Likely closed, or in the process of closing" - (nonzero? (logand (-> obj task-perm-list data arg0 status) (entity-perm-status real-complete))) + (logtest? (-> obj task-perm-list data arg0 status) (entity-perm-status real-complete)) ) ;; set up a static continue point that can be used as a temporary continue point. @@ -549,7 +561,379 @@ (none) ) -;; todo method 11 +(declare-type vent process-drawable) +(define-extern touch-tracker-init function) + +(defmethod pickup-collectable! fact-info-target ((obj fact-info-target) (kind pickup-type) (amount float) (source-handle handle)) + "Pickup a thing!" + (with-pp + (case kind + (((pickup-type eco-green)) + ;; big green eco. This counts toward the health (up to 3), and if that's full, maxes out the little green ecos to 50. + (cond + ((>= amount 0.0) + ;; got a positive or 0 amount. + (when (< 0.0 amount) + ;; when we get a different source, OR we it's been more than 0.5 seconds since we last got eco + ;; from this source. + (if (or (!= (handle->process source-handle) (handle->process (-> obj eco-source))) + (>= (the-as int (- (-> *display* base-frame-counter) (-> obj eco-source-time))) 150) + ) + + ;; play the sound! + (sound-play-by-name (static-sound-name "get-green-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + + ;; remember the source. + (when (handle->process source-handle) + (set! (-> obj eco-source) source-handle) + (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) + ) + ) + + ;; if we are at max health (3), and collect additional an additional big green eco, + ;; then max out the little green ecos. + (if (= (-> obj health) (-> obj health-max)) + (pickup-collectable! + obj + (pickup-type eco-pill) + (-> *FACT-bank* eco-pill-max-default) + (process->handle (-> obj process)) + ) + ) + + ;; remember when + (set! (-> obj health-pickup-time) (-> *display* base-frame-counter)) + ;; increase the health! + (set! (-> obj health) (seek (-> obj health) (-> obj health-max) amount)) + ) + (else + ;; negative health. Subtract. + (set! (-> obj health) (seek (-> obj health) 0.0 (- amount))) + + ;; not sure why we do this. But this will set the eco pill collection time. + (if (>= amount -10.0) + (pickup-collectable! obj (pickup-type eco-pill) 0.0 source-handle) + ) + + ;; subtract lives. + (if (= (-> obj health) 0.0) + (adjust + (-> (the-as target (-> obj process)) game) + 'life + (- (-> *GAME-bank* life-single-inc)) + source-handle + ) + ) + ) + ) + + ;; some sort of hack for eco vents. + (b! (and (logtest? (-> (the-as collide-shape (-> obj process root)) root-prim prim-core action) 512) + (type-type? (-> (handle->process source-handle) type) vent) + ) + cfg-80) + (-> obj health) + ) + + (((pickup-type eco-pill)) + ;; collect small green eco + (when (>= amount 0.0) + ;; update small eco count + (set! (-> obj eco-pill-pickup-time) (-> *display* base-frame-counter)) + (set! (-> obj eco-pill) (seek (-> obj eco-pill) (-> obj eco-pill-max) amount)) + + ;; increment big health if needed + (when (and (>= (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) ;; have enough smalls + (< (-> obj health) (-> obj health-max)) ;; and enough room for another health + ) + ;; decrease eco pills + (set! (-> obj eco-pill) + (- (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) + ) + ;; get a big health. + (pickup-collectable! + obj + (pickup-type eco-green) + (-> *FACT-bank* health-small-inc) + (process->handle (-> obj process)) + ) + ) + ) + (-> obj eco-pill) + ) + + (((pickup-type money)) + ;; get money. + (when (< 0.0 amount) + ;; play sound. + (if (>= (the-as int (- (-> *display* base-frame-counter) (-> obj money-pickup-time))) 15) + (sound-play-by-name (static-sound-name "money-pickup") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (set! (-> obj money-pickup-time) (-> *display* base-frame-counter)) + ) + (adjust (-> (the-as target (-> obj process)) game) + 'money + amount + source-handle + ) + ) + (((pickup-type fuel-cell)) + ;; the amount is actually the index of the task. + (let ((s4-2 (the int amount))) + (if (not (or (task-complete? (-> (the-as target (-> obj process)) game) (the-as game-task s4-2) ) + (>= (the-as uint 1) (the-as uint s4-2)) + ) + ) + (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) + ) + ) + (adjust + (-> (the-as target (-> obj process)) game) + 'fuel-cell + amount + source-handle + ) + ) + (((pickup-type buzzer)) + ;; scout fly. + (let ((buzz-count (adjust + (-> (the-as target (-> obj process)) game) + 'buzzer + amount + source-handle + ) + ) + ) + (if (!= buzz-count (-> obj buzzer)) + (set! (-> obj buzzer-pickup-time) (-> *display* base-frame-counter)) + ) + (set! (-> obj buzzer) buzz-count) + ) + (-> obj buzzer) + ) + (((pickup-type eco-red) (pickup-type eco-blue) (pickup-type eco-yellow)) + ;; the green vent jumps here. + (label cfg-80) + + ;; if the amount is zero, we just want to know how much eco there is. + (if (= amount 0.0) + (return (if (= (-> obj eco-type) kind) + (-> obj eco-level) + 0.0 ;; we don't have this kind of eco. + ) + ) + ) + + ;; new type of eco. Reset and use the new type. + (when (!= (-> obj eco-type) kind) + ;; as far as I can tell, the eco-level isn't really used other than just 1 or 0. + (set! (-> obj eco-level) 0.0) + (set! (-> obj eco-timeout) (the-as seconds 0)) + 0 + ) + (set! (-> obj eco-type) (the-as int kind)) + + + (let ((eco-lev (-> obj eco-level))) + (set! (-> obj eco-level) 1.0) ;; just set to 1. + + ;; this check now doesn't make much sense... + (when (and (= eco-lev 0.0) (< 0.0 (-> obj eco-level))) + ;; didn't have eco and now we do, remember when + (set! (-> obj eco-pickup-time) (-> *display* game-frame-counter)) + + ;; send a reset-collide message. Not sure why we do this. + (let ((a1-24 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-24 from) pp) + (set! (-> a1-24 num-params) 0) + (set! (-> a1-24 message) 'reset-collide) + (send-event-function (-> obj process) a1-24) + ) + ) + + ;; this logic prevents eco from respawning before you are out. + ;; the time until respawn is min(full_eco_time, old_time + single_timeout) + (set! (-> obj eco-timeout) + (the-as seconds + (min (the-as int (+ (-> obj eco-timeout) (* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount)))) + (the-as int (+ (-> *FACT-bank* eco-full-timeout) (- (-> *display* game-frame-counter) (-> obj eco-pickup-time)))) + ) + ) + ) + + ;; if you max out the eco, this should trigger + (if (>= (the-as int (- (-> obj eco-timeout) (the-as uint (- (-> *display* game-frame-counter) (-> obj eco-pickup-time))))) + (the-as int (-> *FACT-bank* eco-full-timeout)) + ) + (set! (-> obj eco-level) 2.0) + ) + + + ;; sound and controller vibration. + (when (not (and (= (handle->process source-handle) (handle->process (-> obj eco-source))) + (< (the-as int (- (-> *display* base-frame-counter) (-> obj eco-source-time))) 150) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 60) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 17 60) + (case kind + (((pickup-type eco-blue)) + (sound-play-by-name (static-sound-name "get-blue-eco") (new-sound-id) 1024 0 0 (the-as uint 1) (the-as vector #t)) + ) + (((pickup-type eco-green)) + (sound-play-by-name (static-sound-name "get-green-eco") (new-sound-id) 1024 0 0 (the-as uint 1) (the-as vector #t)) + ) + (((pickup-type eco-yellow)) + (sound-play-by-name (static-sound-name "get-yellow-eco") (new-sound-id) 1024 0 0 (the-as uint 1) (the-as vector #t)) + ) + (((pickup-type eco-red)) + (sound-play-by-name (static-sound-name "get-red-eco") (new-sound-id) 1024 0 0 (the-as uint 1) (the-as vector #t)) + ) + ) + ) + + (set! (-> obj eco-source) source-handle) + (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) + + ;; special case for blue eco magnet effect + (when (= kind (pickup-type eco-blue)) + (when (= eco-lev 0.0) ;; old level was 0, we just got our first piece of eco + (let ((s5-1 (-> obj process))) + (let* ((s3-5 (get-process *default-dead-pool* touch-tracker #x4000)) + (s4-3 (when s3-5 + ;; interestingly, this uses the activate method of touch-tracker, not process. + (let ((t9-28 (method-of-type touch-tracker activate))) + (t9-28 (the-as touch-tracker s3-5) s5-1 'touch-tracker (the-as pointer #x70004000)) + ) + (run-next-time-in-process s3-5 touch-tracker-init (-> s5-1 root trans) (-> *FACT-bank* suck-bounce-dist) 300) + (-> s3-5 ppointer) + ) + ) + ) + + ;; send the touch tracker the target + (let ((a1-44 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-44 from) pp) + (set! (-> a1-44 num-params) 1) + (set! (-> a1-44 message) 'target) + (set! (-> a1-44 param 0) (the-as uint s5-1)) + (send-event-function (ppointer->process s4-3) a1-44) + ) + ;; tell it we have blue eco. + (let ((a1-45 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-45 from) pp) + (set! (-> a1-45 num-params) 1) + (set! (-> a1-45 message) 'event) + (set! (-> a1-45 param 0) (the-as uint 'eco-blue)) + (send-event-function (ppointer->process s4-3) a1-45) + ) + ;; give it a function to call to see if it's time to exit + (let ((a1-46 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-46 from) pp) + (set! (-> a1-46 num-params) 1) + (set! (-> a1-46 message) 'exit) + (set! (-> a1-46 param 0) + (the-as uint (lambda () + ;; check to see if target has powerup 3. + (with-pp + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) pp) + (set! (-> a1-0 num-params) 2) + (set! (-> a1-0 message) 'query) + (set! (-> a1-0 param 0) (the-as uint 'powerup)) + (set! (-> a1-0 param 1) (the-as uint 3)) + (send-event-function *target* a1-0) + ) + ) + ) + ) + ) + (send-event-function (ppointer->process s4-3) a1-46) + ) + ;; set up some collision thing. + (let ((a1-47 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-47 from) pp) + (set! (-> a1-47 num-params) 1) + (set! (-> a1-47 message) 'eval) + (set! (-> a1-47 param 0) + (the-as uint + (lambda :behavior process-drawable () + (set! (-> (the-as collide-shape (-> self root)) root-prim collide-with) + (the-as uint #x800e) + ) + (none) + ) + ) + ) + (send-event-function (ppointer->process s4-3) a1-47) + ) + ) + + ;; create a process that just keeps sending 'effect 'eco-blue + (let ((s4-4 (get-process *4k-dead-pool* process #x4000))) + (when s4-4 + (let ((t9-35 (method-of-type process activate))) + (t9-35 s4-4 s5-1 'process (the-as pointer #x70004000)) + ) + ((the-as + (function cpu-thread function process-drawable none) + set-to-run + ) + (-> s4-4 main-thread) + (lambda ((arg0 process-drawable)) + (with-pp + (let ((start-time (-> *display* base-frame-counter))) + (until (>= (the-as int (- (-> *display* base-frame-counter) start-time)) 180) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) pp) + (set! (-> a1-0 num-params) 1) + (set! (-> a1-0 message) 'effect) + (set! (-> a1-0 param 0) (the-as uint 'eco-blue)) + (send-event-function arg0 a1-0) + ) + (suspend) + ) + ) + (none) + ) + ) + s5-1 + ) + (-> s4-4 ppointer) + ) + ) + ) + ) + ) + ) + (-> obj eco-level) + ) + (else + ((method-of-type fact-info pickup-collectable!) + obj + kind + amount + source-handle + ) + ) + ) + ) + ) (defmethod lookup-entity-perm-by-aid game-info ((obj game-info) (aid actor-id)) (let ((v1-0 (-> obj perm-list))) @@ -776,7 +1160,7 @@ ) (set! (-> gp-0 want-auto-save) #f) (set! (-> gp-0 auto-save-proc) (the-as handle #f)) - (set! (-> gp-0 auto-save-status) (the-as uint 1)) + (set! (-> gp-0 auto-save-status) (mc-status-code ok)) (set! (-> gp-0 auto-save-card) 0) (set! (-> gp-0 auto-save-which) -1) (set! (-> gp-0 pov-camera-handle) (the-as handle #f)) diff --git a/goal_src/engine/game/game-save.gc b/goal_src/engine/game/game-save.gc index 7ec03313f1..77930ac486 100644 --- a/goal_src/engine/game/game-save.gc +++ b/goal_src/engine/game/game-save.gc @@ -5,8 +5,46 @@ ;; name in dgo: game-save ;; dgos: GAME, ENGINE +;; The game-save system implements the "background autosave" feature. + +;; The process works like this: +;; - The useful parts of game-info are packed into a game-save (all at once) +;; - The auto-save process runs a state machine to write this to memory card. +;; - Additionally, the main loop calls mc-run to run the C++ memory card state machine. + +;; Having two state machines, one in C++ and one in GOAL is kind of a questionable and confusing design. + +;; version identifier (defconstant SAVE_VERSION 1) +;; the C++ memory card functions also use these codes. +(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) + ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; state serialization +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; identifier for game save fields (defenum game-save-elt :type uint16 @@ -85,6 +123,8 @@ ;; A game-save is a dynamic type that contains the full save. ;; it contains common metadata plus all the tags +;; the common metadata is used to display info about a save, without needing to +;; fully unpack the data stored in the tags. (deftype game-save (basic) ((version int32 :offset-assert 4) (allocated-length int32 :offset-assert 8) @@ -256,7 +296,954 @@ (debug-print obj #f) ) -;; todo method 24 game-info +(defmethod save-game! game-info ((obj game-info) (arg0 game-save) (arg1 string)) + "Update the game-save to have the info from the current game state" + + ;; some stuff lives in the levels and needs to be copied into game-info. + (dotimes (s3-0 (-> *level* length)) + (let ((a1-1 (-> *level* level s3-0))) + (if (= (-> a1-1 status) 'active) + (copy-perms-from-level! obj a1-1) + ) + ) + ) + + ;; set common data + (set! (-> arg0 length) 0) + (set! (-> arg0 version) 1) + (set! + (-> arg0 level-index) + (-> (lookup-level-info (-> obj current-continue level)) index) + ) + (set! (-> arg0 fuel-cell-count) (-> obj fuel)) + (set! (-> arg0 money-count) (-> obj money-total)) + (set! (-> arg0 buzzer-count) (-> obj buzzer-total)) + (set! (-> arg0 completion-percentage) (calculate-completion #f)) + (when (string= (-> obj current-continue name) "title-start") + (set! (-> arg0 new-game) 1) + (set! (-> arg0 level-index) (-> (lookup-level-info 'training) index)) + (set! (-> arg0 fuel-cell-count) 0.0) + (set! (-> arg0 money-count) 0.0) + (set! (-> arg0 buzzer-count) 0.0) + (set! (-> arg0 completion-percentage) 0.0) + ) + (let ((s3-1 (new 'stack 'scf-time))) + (scf-get-time s3-1) + (when (zero? (-> s3-1 stat)) + (set! (-> arg0 minute) (-> s3-1 minute)) + (set! (-> arg0 hour) (-> s3-1 hour)) + (set! (-> arg0 day) (-> s3-1 day)) + (set! (-> arg0 week) (-> s3-1 week)) + (set! (-> arg0 month) (-> s3-1 month)) + (set! (-> arg0 year) (-> s3-1 year)) + ) + ) + + ;; set tags. + (let ((s3-2 (the-as object (-> arg0 tag)))) + (let ((s2-0 (-> (the-as (inline-array game-save-tag) s3-2) 0))) + (set! (-> s2-0 elt-type) (game-save-elt name)) + (set! (-> s2-0 elt-count) (+ (length arg1) 1)) + (set! (-> s2-0 elt-size) (the-as uint 1)) + ) + (copy-charp<-charp + (the-as (pointer uint8) (-> (the-as (inline-array game-save-tag) s3-2) 1)) + (-> arg1 data) + ) + (let + ((v1-37 + (&+ + (the-as pointer s3-2) + (+ + (logand + -16 + (+ (-> (the-as (inline-array game-save-tag) s3-2) 0 elt-count) 15) + ) + 16 + ) + ) + ) + ) + (let ((a0-15 (the-as game-save-tag (&+ v1-37 0)))) + (set! (-> a0-15 elt-type) (game-save-elt base-time)) + (set! (-> a0-15 elt-count) 0) + (set! + (-> a0-15 user-uint64) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + (let ((v1-38 (&+ v1-37 16))) + (let ((a0-16 (the-as game-save-tag (&+ v1-38 0)))) + (set! (-> a0-16 elt-type) (game-save-elt real-time)) + (set! (-> a0-16 elt-count) 0) + (set! + (-> a0-16 user-uint64) + (the-as uint (-> *display* real-frame-counter)) + ) + ) + (let ((v1-39 (&+ v1-38 16))) + (let ((a0-17 (the-as game-save-tag (&+ v1-39 0)))) + (set! (-> a0-17 elt-type) (game-save-elt game-time)) + (set! (-> a0-17 elt-count) 0) + (set! + (-> a0-17 user-uint64) + (the-as uint (-> *display* game-frame-counter)) + ) + ) + (let ((v1-40 (&+ v1-39 16))) + (let ((a0-18 (the-as game-save-tag (&+ v1-40 0)))) + (set! (-> a0-18 elt-type) (game-save-elt integral-time)) + (set! (-> a0-18 elt-count) 0) + (set! + (-> a0-18 user-uint64) + (the-as uint (-> *display* integral-frame-counter)) + ) + ) + (let ((s4-1 (the-as object (&+ v1-40 16)))) + (let ((s3-3 (-> obj current-continue name))) + (let + ((s2-1 + (the-as game-save-tag (-> (the-as game-save-tag s4-1) user-object)) + ) + ) + (set! (-> s2-1 elt-type) (game-save-elt continue)) + (set! (-> s2-1 elt-count) (+ (length s3-3) 1)) + (set! (-> s2-1 elt-size) (the-as uint 1)) + ) + (copy-charp<-charp + (the-as + (pointer uint8) + (the-as game-save-tag (&+ (the-as game-save-tag s4-1) 16)) + ) + (-> s3-3 data) + ) + ) + (let + ((v1-50 + (&+ + (the-as pointer s4-1) + (+ + (logand -16 (+ (-> (the-as game-save-tag s4-1) elt-count) 15)) + 16 + ) + ) + ) + ) + (let ((a0-24 (the-as game-save-tag (&+ v1-50 0)))) + (set! (-> a0-24 elt-type) (game-save-elt life)) + (set! (-> a0-24 elt-count) 0) + (set! (-> a0-24 user-float0) (-> obj life)) + ) + (let ((v1-51 (&+ v1-50 16))) + (let ((a0-25 (the-as game-save-tag (&+ v1-51 0)))) + (set! (-> a0-25 elt-type) (game-save-elt buzzer-total)) + (set! (-> a0-25 elt-count) 0) + (set! (-> a0-25 user-float0) (-> obj buzzer-total)) + ) + (let ((v1-52 (&+ v1-51 16))) + (let ((a0-26 (the-as game-save-tag (&+ v1-52 0)))) + (set! (-> a0-26 elt-type) (game-save-elt fuel-cell)) + (set! (-> a0-26 elt-count) 0) + (set! (-> a0-26 user-float0) (-> obj fuel)) + ) + (let ((v1-53 (&+ v1-52 16))) + (let ((a0-27 (the-as game-save-tag (&+ v1-53 0)))) + (set! (-> a0-27 elt-type) (game-save-elt death-movie-tick)) + (set! (-> a0-27 elt-count) 0) + (set! + (-> a0-27 user-uint64) + (the-as uint (-> obj death-movie-tick)) + ) + ) + (let ((v1-54 (&+ v1-53 16))) + (let ((a0-28 (the-as game-save-tag (&+ v1-54 0)))) + (set! (-> a0-28 elt-type) (game-save-elt money)) + (set! (-> a0-28 elt-count) 0) + (set! (-> a0-28 user-float0) (-> obj money)) + ) + (let ((v1-55 (&+ v1-54 16))) + (let ((a0-29 (the-as game-save-tag (&+ v1-55 0)))) + (set! (-> a0-29 elt-type) (game-save-elt money-total)) + (set! (-> a0-29 elt-count) 0) + (set! (-> a0-29 user-float0) (-> obj money-total)) + ) + (let ((v1-56 (&+ v1-55 16))) + (let ((a0-30 (the-as game-save-tag (&+ v1-56 0)))) + (set! (-> a0-30 elt-type) (game-save-elt moeny-per-level)) + (set! (-> a0-30 elt-count) 32) + (set! (-> a0-30 elt-size) (the-as uint 1)) + ) + (let ((v1-57 (&+ v1-56 16))) + (dotimes (a0-31 32) + (set! + (-> (the-as (pointer uint8) (&+ v1-57 a0-31))) + (-> obj money-per-level a0-31) + ) + ) + (let ((v1-58 (&+ v1-57 32))) + (let ((a0-34 (the-as object (&+ v1-58 0)))) + (set! + (-> (the-as game-save-tag a0-34) elt-type) + (game-save-elt level-open-list) + ) + (set! (-> (the-as game-save-tag a0-34) elt-count) 32) + (set! + (-> (the-as game-save-tag a0-34) elt-size) + (the-as uint 1) + ) + ) + (let ((v1-59 (&+ v1-58 16))) + (dotimes (a0-35 32) + (set! + (-> (the-as (pointer uint8) (&+ v1-59 a0-35))) + (-> obj level-opened a0-35) + ) + ) + (let ((v1-60 (&+ v1-59 32)) + (s4-2 + (-> (the-as (pointer int32) (-> obj perm-list)) 0) + ) + ) + (let ((a0-39 (the-as game-save-tag (&+ v1-60 0)))) + (set! (-> a0-39 elt-type) (game-save-elt perm-list)) + (set! (-> a0-39 elt-count) s4-2) + (set! (-> a0-39 elt-size) (the-as uint 16)) + ) + (let ((s3-4 (&+ v1-60 16))) + (dotimes (s2-2 s4-2) + (mem-copy! + (the-as + pointer + (the-as game-save-tag (&+ s3-4 (* s2-2 16))) + ) + (the-as pointer (-> obj perm-list data s2-2)) + 16 + ) + ) + (let ((v1-68 (&+ s3-4 (logand -16 (+ (* s4-2 16) 15)))) + (s4-3 (-> obj task-perm-list length)) + ) + (let ((a0-45 (the-as game-save-tag (&+ v1-68 0)))) + (set! (-> a0-45 elt-type) (game-save-elt task-list)) + (set! (-> a0-45 elt-count) s4-3) + (set! (-> a0-45 elt-size) (the-as uint 16)) + ) + (let ((s3-5 (&+ v1-68 16))) + (dotimes (s2-3 s4-3) + (mem-copy! + (the-as + pointer + (the-as game-save-tag (&+ s3-5 (* s2-3 16))) + ) + (the-as pointer (-> obj task-perm-list data s2-3)) + 16 + ) + ) + (let ((a0-49 (&+ s3-5 (logand -16 (+ (* s4-3 16) 15)))) + (v1-79 + (/ + (logand + -8 + (+ (-> obj text-ids-seen allocated-length) 7) + ) + 8 + ) + ) + ) + (let ((a1-46 (the-as object (&+ a0-49 0)))) + (set! + (-> (the-as game-save-tag a1-46) elt-type) + (game-save-elt text-list) + ) + (set! (-> (the-as game-save-tag a1-46) elt-count) v1-79) + (set! + (-> (the-as game-save-tag a1-46) elt-size) + (the-as uint 1) + ) + ) + (let ((a0-50 (&+ a0-49 16))) + (dotimes (a1-47 v1-79) + (set! + (-> (the-as (pointer uint8) (&+ a0-50 a1-47))) + (-> obj text-ids-seen bytes a1-47) + ) + ) + (let ((a0-51 (&+ a0-50 (logand -16 (+ v1-79 15)))) + (v1-84 (-> obj hint-control length)) + ) + (let ((a1-51 (the-as game-save-tag (&+ a0-51 0)))) + (set! (-> a1-51 elt-type) (game-save-elt hint-list)) + (set! (-> a1-51 elt-count) v1-84) + (set! (-> a1-51 elt-size) (the-as uint 32)) + ) + (let ((a0-52 (&+ a0-51 16))) + (dotimes (a1-52 v1-84) + (set! + (-> + (the-as + (pointer int64) + (&+ a0-52 (* (* a1-52 4) 8)) + ) + ) + (-> obj hint-control a1-52 start-time) + ) + (set! + (-> + (the-as + (pointer int64) + (&+ a0-52 (* (+ (* a1-52 4) 1) 8)) + ) + ) + (-> obj hint-control a1-52 last-time-called) + ) + (set! + (-> + (the-as + (pointer int8) + (&+ a0-52 (+ (* a1-52 32) 16)) + ) + ) + (-> obj hint-control a1-52 num-attempts) + ) + (set! + (-> + (the-as + (pointer int8) + (&+ a0-52 (+ (* a1-52 32) 17)) + ) + ) + (-> obj hint-control a1-52 num-success) + ) + ) + (let ((v1-86 (&+ a0-52 (* v1-84 32)))) + (let ((a0-54 (the-as game-save-tag (&+ v1-86 0)))) + (set! + (-> a0-54 elt-type) + (game-save-elt auto-save-count) + ) + (set! (-> a0-54 elt-count) 0) + (set! + (-> a0-54 user-uint64) + (the-as uint (-> obj auto-save-count)) + ) + ) + (let ((v1-87 (&+ v1-86 16))) + (let ((a0-55 (the-as game-save-tag (&+ v1-87 0)))) + (set! + (-> a0-55 elt-type) + (game-save-elt total-deaths) + ) + (set! (-> a0-55 elt-count) 0) + (set! + (-> a0-55 user-uint64) + (the-as uint (-> obj total-deaths)) + ) + ) + (let ((v1-88 (&+ v1-87 16))) + (let ((a0-56 (the-as game-save-tag (&+ v1-88 0)))) + (set! + (-> a0-56 elt-type) + (game-save-elt continue-deaths) + ) + (set! (-> a0-56 elt-count) 0) + (set! + (-> a0-56 user-uint64) + (the-as uint (-> obj continue-deaths)) + ) + ) + (let ((v1-89 (&+ v1-88 16))) + (let ((a0-57 (the-as game-save-tag (&+ v1-89 0)))) + (set! + (-> a0-57 elt-type) + (game-save-elt fuel-cell-deaths) + ) + (set! (-> a0-57 elt-count) 0) + (set! + (-> a0-57 user-uint64) + (the-as uint (-> obj fuel-cell-deaths)) + ) + ) + (let ((v1-90 (&+ v1-89 16))) + (let + ((a0-58 (the-as game-save-tag (&+ v1-90 0)))) + (set! + (-> a0-58 elt-type) + (game-save-elt game-start-time) + ) + (set! (-> a0-58 elt-count) 0) + (set! + (-> a0-58 user-uint64) + (-> obj game-start-time) + ) + ) + (let ((v1-91 (&+ v1-90 16))) + (let + ((a0-59 (the-as game-save-tag (&+ v1-91 0)))) + (set! + (-> a0-59 elt-type) + (game-save-elt continue-time) + ) + (set! (-> a0-59 elt-count) 0) + (set! + (-> a0-59 user-uint64) + (-> obj continue-time) + ) + ) + (let ((v1-92 (&+ v1-91 16))) + (let + ((a0-60 (the-as game-save-tag (&+ v1-92 0)))) + (set! + (-> a0-60 elt-type) + (game-save-elt death-time) + ) + (set! (-> a0-60 elt-count) 0) + (set! + (-> a0-60 user-uint64) + (-> obj death-time) + ) + ) + (let ((v1-93 (&+ v1-92 16))) + (let + ((a0-61 (the-as game-save-tag (&+ v1-93 0)))) + (set! + (-> a0-61 elt-type) + (game-save-elt hit-time) + ) + (set! (-> a0-61 elt-count) 0) + (set! + (-> a0-61 user-uint64) + (-> obj hit-time) + ) + ) + (let ((v1-94 (&+ v1-93 16))) + (let + ((a0-62 (the-as game-save-tag (&+ v1-94 0))) + ) + (set! + (-> a0-62 elt-type) + (game-save-elt fuel-cell-pickup-time) + ) + (set! (-> a0-62 elt-count) 0) + (set! + (-> a0-62 user-uint64) + (-> obj fuel-cell-pickup-time) + ) + ) + (let ((v1-95 (&+ v1-94 16))) + (let + ((a0-63 + (the-as game-save-tag (&+ v1-95 0)) + ) + ) + (set! + (-> a0-63 elt-type) + (game-save-elt fuel-cell-time) + ) + (set! (-> a0-63 elt-count) 116) + (set! (-> a0-63 elt-size) (the-as uint 8)) + ) + (let ((v1-96 (&+ v1-95 16))) + (let ((a0-64 (the-as object 0))) + (while (< (the-as int a0-64) 116) + (set! + (-> + (the-as + (pointer uint64) + (&+ v1-96 (* (the-as int a0-64) 8)) + ) + ) + (-> + obj + fuel-cell-time + (the-as int a0-64) + ) + ) + (set! a0-64 (+ (the-as int a0-64) 1)) + ) + ) + (let ((v1-97 (&+ v1-96 928))) + (let + ((a0-67 + (the-as game-save-tag (&+ v1-97 0)) + ) + ) + (set! + (-> a0-67 elt-type) + (game-save-elt deaths-per-level) + ) + (set! (-> a0-67 elt-count) 32) + (set! + (-> a0-67 elt-size) + (the-as uint 1) + ) + ) + (let ((v1-98 (&+ v1-97 16))) + (dotimes (a0-68 32) + (set! + (-> + (the-as + (pointer uint8) + (&+ v1-98 a0-68) + ) + ) + (-> obj deaths-per-level a0-68) + ) + ) + (let ((v1-99 (&+ v1-98 32))) + (let + ((a0-71 + (the-as game-save-tag (&+ v1-99 0)) + ) + ) + (set! + (-> a0-71 elt-type) + (game-save-elt enter-level-time) + ) + (set! (-> a0-71 elt-count) 32) + (set! + (-> a0-71 elt-size) + (the-as uint 8) + ) + ) + (let ((v1-100 (&+ v1-99 16))) + (dotimes (a0-72 32) + (set! + (-> + (the-as + (pointer uint64) + (&+ v1-100 (* a0-72 8)) + ) + ) + (-> obj enter-level-time a0-72) + ) + ) + (let ((v1-101 (&+ v1-100 256))) + (let + ((a0-75 + (the-as + game-save-tag + (&+ v1-101 0) + ) + ) + ) + (set! + (-> a0-75 elt-type) + (game-save-elt in-level-time) + ) + (set! (-> a0-75 elt-count) 32) + (set! + (-> a0-75 elt-size) + (the-as uint 8) + ) + ) + (let ((v1-102 (&+ v1-101 16))) + (dotimes (a0-76 32) + (set! + (-> + (the-as + (pointer uint64) + (&+ v1-102 (* a0-76 8)) + ) + ) + (-> obj in-level-time a0-76) + ) + ) + (let ((v1-103 (&+ v1-102 256))) + (let + ((a0-79 + (the-as + game-save-tag + (&+ v1-103 0) + ) + ) + ) + (set! + (-> a0-79 elt-type) + (game-save-elt sfx-volume) + ) + (set! (-> a0-79 elt-count) 0) + (set! + (-> a0-79 user-float0) + (-> + *setting-control* + default + sfx-volume + ) + ) + ) + (let ((v1-104 (&+ v1-103 16))) + (let + ((a0-80 + (the-as + game-save-tag + (&+ v1-104 0) + ) + ) + ) + (set! + (-> a0-80 elt-type) + (game-save-elt music-volume) + ) + (set! (-> a0-80 elt-count) 0) + (set! + (-> a0-80 user-float0) + (-> + *setting-control* + default + music-volume + ) + ) + ) + (let ((v1-105 (&+ v1-104 16))) + (let + ((a0-81 + (the-as + game-save-tag + (&+ v1-105 0) + ) + ) + ) + (set! + (-> a0-81 elt-type) + (game-save-elt dialog-volume) + ) + (set! (-> a0-81 elt-count) 0) + (set! + (-> a0-81 user-float0) + (-> + *setting-control* + default + dialog-volume + ) + ) + ) + (let ((v1-106 (&+ v1-105 16))) + (let + ((a0-82 + (the-as + game-save-tag + (&+ v1-106 0) + ) + ) + ) + (set! + (-> a0-82 elt-type) + (game-save-elt language) + ) + (set! (-> a0-82 elt-count) 0) + (set! + (-> a0-82 user-uint64) + (the-as + uint + (-> + *setting-control* + default + language + ) + ) + ) + ) + (let ((v1-107 (&+ v1-106 16))) + (let + ((a0-83 + (the-as + game-save-tag + (&+ v1-107 0) + ) + ) + ) + (set! + (-> a0-83 elt-type) + (game-save-elt screenx) + ) + (set! (-> a0-83 elt-count) 0) + (set! + (-> a0-83 user-float0) + (the + float + (-> + *setting-control* + default + screenx + ) + ) + ) + ) + (let ((v1-108 (&+ v1-107 16))) + (let + ((a0-84 + (the-as + game-save-tag + (&+ v1-108 0) + ) + ) + ) + (set! + (-> a0-84 elt-type) + (game-save-elt screeny) + ) + (set! (-> a0-84 elt-count) 0) + (set! + (-> a0-84 user-float0) + (the + float + (-> + *setting-control* + default + screeny + ) + ) + ) + ) + (let ((v1-109 (&+ v1-108 16))) + (let + ((a0-85 + (the-as + game-save-tag + (&+ v1-109 0) + ) + ) + ) + (set! + (-> a0-85 elt-type) + (game-save-elt vibration) + ) + (set! (-> a0-85 elt-count) 0) + (set! + (-> a0-85 user-uint64) + (the-as + uint + (if + (-> + *setting-control* + default + vibration + ) + 1 + 0 + ) + ) + ) + ) + (let ((v1-110 (&+ v1-109 16))) + (let + ((a0-86 + (the-as + game-save-tag + (&+ v1-110 0) + ) + ) + ) + (set! + (-> a0-86 elt-type) + (game-save-elt play-hints) + ) + (set! + (-> a0-86 elt-count) + 0 + ) + (set! + (-> a0-86 user-uint64) + (the-as + uint + (if + (-> + *setting-control* + default + play-hints + ) + 1 + 0 + ) + ) + ) + ) + (let + ((v1-111 (&+ v1-110 16))) + (let + ((a0-87 + (the-as + game-save-tag + (&+ v1-111 0) + ) + ) + ) + (set! + (-> a0-87 elt-type) + (game-save-elt video-mode) + ) + (set! + (-> a0-87 elt-count) + 0 + ) + (let + ((a1-121 + (-> + *setting-control* + default + video-mode + ) + ) + ) + (set! + (-> a0-87 user-uint64) + (the-as uint (cond + ((= + a1-121 + 'ntsc + ) + 1 + ) + ((= + a1-121 + 'pal + ) + 2 + ) + (else + 0 + ) + ) + ) + ) + ) + ) + (let + ((v1-112 (&+ v1-111 16))) + (let + ((a0-88 + (the-as + object + (&+ v1-112 0) + ) + ) + ) + (set! + (-> + (the-as + game-save-tag + a0-88 + ) + elt-type + ) + (game-save-elt + aspect-ratio + ) + ) + (set! + (-> + (the-as + game-save-tag + a0-88 + ) + elt-count + ) + 0 + ) + (let + ((a1-125 + (-> + *setting-control* + default + aspect-ratio + ) + ) + ) + (set! + (-> + (the-as + (pointer int64) + a0-88 + ) + ) + (cond + ((= a1-125 'aspect4x3) + 1 + ) + ((= a1-125 'aspect16x9) + 2 + ) + (else + 0 + ) + ) + ) + ) + ) + (set! + (-> arg0 length) + (&- + (&+ v1-112 16) + (the-as + uint + (the-as + pointer + (-> arg0 tag) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (if (< (-> arg0 allocated-length) (-> arg0 length)) + (format + 0 + "ERROR: SAVEGAME: fatal error, save is using ~D of ~D bytes." + (-> arg0 length) + (-> arg0 allocated-length) + ) + ) + (none) + ) (defmethod load-game! game-info ((obj game-info) (save game-save)) "Copy save data from a game-save to a game-info" @@ -309,7 +1296,7 @@ ((= v1-7 (game-save-elt base-time)) ;; updating this requires some care to not break things (let ((old-base-frame (-> *display* base-frame-counter))) - (set! (-> *display* base-frame-counter) (-> data user-uint64)) + (set! (-> *display* base-frame-counter) (the int (-> data user-uint64))) ;; remember the old value (set! (-> *display* old-base-frame-counter) (+ (-> *display* base-frame-counter) -1)) (let ((frame-counter-diff (- (-> *display* base-frame-counter) old-base-frame))) @@ -334,15 +1321,15 @@ ) ((= v1-7 (game-save-elt game-time)) - (set! (-> *display* game-frame-counter) (-> data user-uint64)) + (set! (-> *display* game-frame-counter) (the int (-> data user-uint64))) (set! (-> *display* old-game-frame-counter) (+ (-> *display* game-frame-counter) -1)) ) ((= v1-7 (game-save-elt real-time)) - (set! (-> *display* real-frame-counter) (-> data user-uint64)) + (set! (-> *display* real-frame-counter) (the int (-> data user-uint64))) (set! (-> *display* old-real-frame-counter) (+ (-> *display* real-frame-counter) -1)) ) ((= v1-7 (game-save-elt integral-time)) - (set! (-> *display* integral-frame-counter) (-> data user-uint64)) + (set! (-> *display* integral-frame-counter) (the int (-> data user-uint64))) (set! (-> *display* old-integral-frame-counter) (+ (-> *display* integral-frame-counter) -1)) ) ((= v1-7 (game-save-elt continue)) @@ -435,10 +1422,10 @@ (let ((v1-65 (&+ (the-as pointer data) 16))) (dotimes (a0-99 (-> data elt-count)) (set! (-> obj hint-control a0-99 start-time) - (-> (the-as (pointer uint64) (&+ v1-65 (* (* a0-99 4) 8)))) + (-> (the-as (pointer int64) (&+ v1-65 (* (* a0-99 4) 8)))) ) (set! (-> obj hint-control a0-99 last-time-called) - (-> (the-as (pointer uint64) (&+ v1-65 (* (+ (* a0-99 4) 1) 8)))) + (-> (the-as (pointer int64) (&+ v1-65 (* (+ (* a0-99 4) 1) 8)))) ) (set! (-> obj hint-control a0-99 num-attempts) (-> (the-as (pointer int8) @@ -575,6 +1562,7 @@ ) (defmethod load-from-file! game-save ((obj game-save) (filename string)) + "Load a game save from a file for debugging" (let ((stream (new 'stack 'file-stream filename 'read))) (let ((in-size (file-stream-length stream)) (my-size (-> obj allocated-length)) @@ -618,7 +1606,148 @@ obj ) -;; TODO sparticle stuff and more +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; particles +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; used for the flashing auto-save icon, I think. + +(set! (-> *part-group-id-table* 656) + (new 'static 'sparticle-launch-group + :length 1 + :duration #xbb8 + :linger-duration #x5dc + :flags #x4 + :name "group-part-save-icon" + :launcher + (new 'static 'sparticle-group-item :launcher #xa66) + :bounds (new 'static 'sphere :w 409600.0) + ) + ) + +;; todo floats/ints for these values. +(set! (-> *part-id-table* 2662) + (new 'static 'sparticle-launcher + :init-specs + (new 'static 'inline-array sp-field-init-spec 11 + (new 'static 'sp-field-init-spec :field #x1 :initial-value #x1cf06b00) + (new 'static 'sp-field-init-spec + :field #x6 + :flags #x1 + :initial-value #x3f800000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #xd + :flags #x1 + :initial-value #x45c00000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #x11 + :flags #x3 + :initial-value -4 + :random-mult 1 + ) + (new 'static 'sp-field-init-spec + :field #x12 + :flags #x1 + :initial-value #x43000000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #x13 + :flags #x1 + :initial-value #x43000000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #x14 + :flags #x1 + :initial-value #x43000000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #x15 + :flags #x1 + :initial-value #x43000000 + :random-mult #x3f800000 + ) + (new 'static 'sp-field-init-spec + :field #x2e + :initial-value 5 + :random-mult 1 + ) + (new 'static 'sp-field-init-spec + :field #x2f + :initial-value #x2204 + :random-mult 1 + ) + (new 'static 'sp-field-init-spec :field #x43) + ) + ) + ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; auto-save process +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; the status of the memory cards. +(define *auto-save-info* (new 'global 'mc-slot-info)) + +(deftype auto-save (process) + ((card int32 :offset-assert 112) + (slot int32 :offset-assert 116) + (which int32 :offset-assert 120) + (buffer kheap :offset-assert 124) + (mode basic :offset-assert 128) + (result mc-status-code :offset-assert 132) + (save game-save :offset-assert 136) + (info mc-slot-info :inline :offset-assert 140) + (notify handle :offset-assert 440) + (state-time uint64 :offset-assert 448) + (part sparticle-launch-control :offset-assert 456) + ) + :heap-base #x160 + :method-count-assert 23 + :size-assert #x1cc + :flag-assert #x17016001cc + (:methods + (get-heap () _type_ :state 14) + (get-card () _type_ :state 15) + (format-card () _type_ :state 16) + (create-file () _type_ :state 17) + (save () _type_ :state 18) + (restore () _type_ :state 19) + (error (mc-status-code) _type_ :state 20) + (done () _type_ :state 21) + (unformat-card () _type_ :state 22) + ) + ) + +(defmethod deactivate auto-save ((obj auto-save)) + "Deactivate the auto-save process." + ;; kill the particles + (if (nonzero? (-> obj part)) + (deactivate (-> obj part)) + ) + ;; and do a normal deactivate. + ((method-of-type process deactivate) obj) + (none) + ) + +(defmethod relocate auto-save ((obj auto-save) (arg0 int)) + "Relocate an auto-save process by arg0 bytes." + + ;; update our reference particle launch control, which is allocated on our process heap + (if (nonzero? (-> obj part)) + (&+! (-> obj part) arg0) + ) + + ;; then relocate the process. This will relocate the heap (memory, and basics on it). + (the-as auto-save ((method-of-type process relocate) obj arg0)) + ) + ;; TODO - for credits (define-extern print-game-text (function string font-context symbol int int float)) ; TODO decomp error, this seems correct though diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index c16092495c..91919946cf 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -9,7 +9,7 @@ ;; Letterbox and blackout ;;;;;;;;;;;;;;;;;;;;;;;;;; -(defun set-letterbox-frames ((arg0 uint)) +(defun set-letterbox-frames ((arg0 int)) "Set the letterbox frame counter for arg0 frames in the future" (let ((v0-0 (+ (-> *display* base-frame-counter) arg0))) (set! (-> *game-info* letterbox-time) v0-0) @@ -1275,7 +1275,7 @@ ) (set! *run* #t) (let ((new-dproc (make-function-process *4k-dead-pool* *display-pool* process display-loop :name 'display))) - (set! *dproc* (the process (as-process new-dproc))) + (set! *dproc* (the process (ppointer->process new-dproc))) ) (cond ((or (level-get-with-status *level* 'loaded) diff --git a/goal_src/engine/game/settings-h.gc b/goal_src/engine/game/settings-h.gc index bb6b5e1a2e..b882b40d67 100644 --- a/goal_src/engine/game/settings-h.gc +++ b/goal_src/engine/game/settings-h.gc @@ -83,11 +83,11 @@ (format #t "~Tscreeny: ~D~%" (-> obj screeny)) (format #t "~Tvibration: ~A~%" (-> obj vibration)) (format #t "~Tplay-hints: ~A~%" (-> obj play-hints)) - (format #t "~Tmovie: ~A~%" (as-process (-> obj movie))) - (format #t "~Ttalking: ~A~%" (as-process (-> obj talking))) - (format #t "~Tspooling: ~A~%" (as-process (-> obj spooling))) - (format #t "~Thint: ~A~%" (as-process (-> obj hint))) - (format #t "~Tambient: ~A~%" (as-process (-> obj ambient))) + (format #t "~Tmovie: ~A~%" (ppointer->process (-> obj movie))) + (format #t "~Ttalking: ~A~%" (ppointer->process (-> obj talking))) + (format #t "~Tspooling: ~A~%" (ppointer->process (-> obj spooling))) + (format #t "~Thint: ~A~%" (ppointer->process (-> obj hint))) + (format #t "~Tambient: ~A~%" (ppointer->process (-> obj ambient))) (format #t "~Tvideo-mode: ~A~%" (-> obj video-mode)) (format #t "~Taspect-ratio: ~A~%" (-> obj aspect-ratio)) (format #t "~Tsound-flava: ~D~%" (-> obj sound-flava)) diff --git a/goal_src/engine/game/settings.gc b/goal_src/engine/game/settings.gc index 23bef0fc05..4f1205d1cf 100644 --- a/goal_src/engine/game/settings.gc +++ b/goal_src/engine/game/settings.gc @@ -41,14 +41,7 @@ ) (('sfx-volume) (when (or (zero? (logand (-> *kernel-context* prevent-from-run) (process-mask progress))) - (let ((v1-18 (get-process conn)) - (a0-22 *progress-process*) - ) - (= v1-18 (if a0-22 - (-> a0-22 0 self) - ) - ) - ) + (= (get-process conn) (ppointer->process *progress-process*)) ) (let ((v1-20 (the-as symbol (-> conn param1)))) (if (= v1-20 'rel) diff --git a/goal_src/engine/game/task/hint-control-h.gc b/goal_src/engine/game/task/hint-control-h.gc index fa980a4a7a..e0a96f318b 100644 --- a/goal_src/engine/game/task/hint-control-h.gc +++ b/goal_src/engine/game/task/hint-control-h.gc @@ -12,8 +12,8 @@ (num-success-before-killing int8 :offset-assert 13) (num-attempts int8 :offset-assert 14) (num-success int8 :offset-assert 15) - (start-time uint64 :offset-assert 16) - (last-time-called uint64 :offset-assert 24) + (start-time int64 :offset-assert 16) + (last-time-called int64 :offset-assert 24) ) :method-count-assert 9 :size-assert #x20 diff --git a/goal_src/engine/game/task/hint-control.gc b/goal_src/engine/game/task/hint-control.gc index 96608adbba..967b6d6168 100644 --- a/goal_src/engine/game/task/hint-control.gc +++ b/goal_src/engine/game/task/hint-control.gc @@ -476,8 +476,8 @@ (let ((v1-2 (length (-> *game-info* hint-control)))) (dotimes (a0-1 v1-2) (let ((a1-2 (-> *game-info* hint-control a0-1))) - (set! (-> a1-2 start-time) (the-as uint 0)) - (set! (-> a1-2 last-time-called) (the-as uint 0)) + (set! (-> a1-2 start-time) 0) + (set! (-> a1-2 last-time-called) 0) (set! (-> a1-2 num-attempts) 0) (set! (-> a1-2 num-success) 0) ) diff --git a/goal_src/engine/gfx/hw/display-h.gc b/goal_src/engine/gfx/hw/display-h.gc index 5f43b84920..aea6c3ff2c 100644 --- a/goal_src/engine/gfx/hw/display-h.gc +++ b/goal_src/engine/gfx/hw/display-h.gc @@ -141,25 +141,25 @@ (frames virtual-frame 6 :inline :offset-assert 568) (bg-clear-color rgba 4 :offset-assert 760) ;; counters (why are there so many???) - (real-frame-counter uint64 :offset-assert 776) - (base-frame-counter uint64 :offset-assert 784) - (game-frame-counter uint64 :offset-assert 792) - (integral-frame-counter uint64 :offset-assert 800) - (real-integral-frame-counter uint64 :offset-assert 808) - (actual-frame-counter uint64 :offset-assert 816) - (real-actual-frame-counter uint64 :offset-assert 824) - (part-frame-counter uint64 :offset-assert 832) + (real-frame-counter int64 :offset-assert 776) + (base-frame-counter int64 :offset-assert 784) + (game-frame-counter int64 :offset-assert 792) + (integral-frame-counter int64 :offset-assert 800) + (real-integral-frame-counter int64 :offset-assert 808) + (actual-frame-counter int64 :offset-assert 816) + (real-actual-frame-counter int64 :offset-assert 824) + (part-frame-counter int64 :offset-assert 832) ;; the "old" counters are the values from the previous tick. ;; the counters above may jump during a load. - (old-real-frame-counter uint64 :offset-assert 840) - (old-base-frame-counter uint64 :offset-assert 848) - (old-game-frame-counter uint64 :offset-assert 856) - (old-integral-frame-counter uint64 :offset-assert 864) - (old-real-integral-frame-counter uint64 :offset-assert 872) - (old-actual-frame-counter uint64 :offset-assert 880) - (old-real-actual-frame-counter uint64 :offset-assert 888) - (old-part-frame-counter uint64 :offset-assert 896) + (old-real-frame-counter int64 :offset-assert 840) + (old-base-frame-counter int64 :offset-assert 848) + (old-game-frame-counter int64 :offset-assert 856) + (old-integral-frame-counter int64 :offset-assert 864) + (old-real-integral-frame-counter int64 :offset-assert 872) + (old-actual-frame-counter int64 :offset-assert 880) + (old-real-actual-frame-counter int64 :offset-assert 888) + (old-part-frame-counter int64 :offset-assert 896) ;; timing stats for how fast the engine is currently running. (time-ratio float :offset-assert 904) ;; engine speed, 1.0 = full speed @@ -242,3 +242,6 @@ (defmacro integral-current-time () `(-> *display* integral-frame-counter) ) + +(define-extern get-current-time (function int)) +(define-extern get-integral-current-time (function int)) \ No newline at end of file diff --git a/goal_src/engine/gfx/hw/display.gc b/goal_src/engine/gfx/hw/display.gc index 7d2b41d36e..bd3a0c3d88 100644 --- a/goal_src/engine/gfx/hw/display.gc +++ b/goal_src/engine/gfx/hw/display.gc @@ -230,12 +230,12 @@ (set-draw-env (-> disp draw1) psm w h ztest zpsm 320) ;; initialize a bunch of counters - (set! (-> disp base-frame-counter) (the-as uint #x493e0)) - (set! (-> disp game-frame-counter) (the-as uint #x493e0)) - (set! (-> disp real-frame-counter) (the-as uint #x493e0)) - (set! (-> disp part-frame-counter) (the-as uint #x493e0)) - (set! (-> disp integral-frame-counter) (the-as uint #x493e0)) - (set! (-> disp real-integral-frame-counter) (the-as uint #x493e0)) + (set! (-> disp base-frame-counter) #x493e0) + (set! (-> disp game-frame-counter) #x493e0) + (set! (-> disp real-frame-counter) #x493e0) + (set! (-> disp part-frame-counter) #x493e0) + (set! (-> disp integral-frame-counter) #x493e0) + (set! (-> disp real-integral-frame-counter) #x493e0) ;; and the "old" version, which I think was their value on the last... frame? (set! (-> disp old-base-frame-counter) (+ (-> disp base-frame-counter) -1)) @@ -403,7 +403,7 @@ (>= end-time (the-as int (-> worst-time-cache (/ bar-pos 10)))) ) (set! (-> worst-time-cache (/ bar-pos 10)) (the-as uint end-time)) - (set! (-> obj cache-time) (-> *display* real-frame-counter)) + (set! (-> obj cache-time) (the uint (-> *display* real-frame-counter))) ) ;; draw the time, either in ticks or percent. diff --git a/goal_src/engine/gfx/ripple.gc b/goal_src/engine/gfx/ripple.gc index 627f25ab24..cdb89c9d54 100644 --- a/goal_src/engine/gfx/ripple.gc +++ b/goal_src/engine/gfx/ripple.gc @@ -52,7 +52,7 @@ ) (defun ripple-update-waveform-offs ((arg0 ripple-wave-set)) - (let ((f0-1 (the float (- (-> *display* integral-frame-counter) (-> arg0 frame-save))))) + (let ((f0-1 (the float (- (-> *display* integral-frame-counter) (the int (-> arg0 frame-save)))))) (when (!= f0-1 0.0) (dotimes (v1-4 (-> arg0 count)) (let ((a1-4 (-> arg0 wave v1-4))) @@ -60,7 +60,7 @@ (set! (-> a1-4 offs) (the float (logand (the int (-> a1-4 offs)) #xffff))) ) ) - (set! (-> arg0 frame-save) (-> *display* integral-frame-counter)) + (set! (-> arg0 frame-save) (the uint (-> *display* integral-frame-counter))) ) ) (none) diff --git a/goal_src/engine/level/level-h.gc b/goal_src/engine/level/level-h.gc index 847e5fb8de..352ebc334b 100644 --- a/goal_src/engine/level/level-h.gc +++ b/goal_src/engine/level/level-h.gc @@ -405,3 +405,4 @@ ) (define-extern *level-load-list* pair) +(define-extern lookup-level-info (function symbol level-load-info)) \ No newline at end of file diff --git a/goal_src/engine/load/load-dgo.gc b/goal_src/engine/load/load-dgo.gc index 5f6e73e1fd..8b700e0f11 100644 --- a/goal_src/engine/load/load-dgo.gc +++ b/goal_src/engine/load/load-dgo.gc @@ -265,7 +265,7 @@ struct DgoHeader { ;; DGO LOAD and LINK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define *dgo-time* (the-as uint 0)) +(define *dgo-time* 0) (defun dgo-load-begin ((name string) (buffer1 pointer) (buffer2 pointer) (buffer-top pointer)) "Send a DGO load RPC!" diff --git a/goal_src/engine/math/transformq-h.gc b/goal_src/engine/math/transformq-h.gc index d1167e947b..69f9f2f6fc 100644 --- a/goal_src/engine/math/transformq-h.gc +++ b/goal_src/engine/math/transformq-h.gc @@ -33,7 +33,7 @@ (rotv vector :inline :offset-assert 80) (scalev vector :inline :offset-assert 96) (dir-targ quaternion :inline :offset-assert 112) - (angle-change-time uint64 :offset-assert 128) + (angle-change-time int64 :offset-assert 128) (old-y-angle-diff float :offset-assert 136) ) :method-count-assert 28 diff --git a/goal_src/engine/math/transformq.gc b/goal_src/engine/math/transformq.gc index 88860ba3c6..9bf68e9547 100644 --- a/goal_src/engine/math/transformq.gc +++ b/goal_src/engine/math/transformq.gc @@ -51,15 +51,15 @@ (defmethod seek-toward-heading-vec! trsqv ((obj trsqv) (dir vector) (vel float) (frame-count int)) "Adjust the orientation to point along dir, only changing our yaw. - The vel is a maximum velocity limit. - The frame count is the time constant (first order). - There's some logic to avoid rapidly changing directions" + The vel is a maximum velocity limit. + The frame count is the time constant (first order). + There's some logic to avoid rapidly changing directions" (let* ((yaw-error (deg-diff (quaternion-y-angle (-> obj quat)) (vector-y-angle dir))) ;; limit both on a max velocity, and a proportional to error term. (yaw-limit (fmin (* vel (-> *display* seconds-per-frame)) (/ (* 5.0 (fabs yaw-error)) (the float frame-count)) ) - ) + ) ;; saturate the yaw error (saturated-yaw (fmax (fmin yaw-error yaw-limit) (- yaw-limit))) ) @@ -71,10 +71,9 @@ ((or (= old-diff 0.0) (and (< 0.0 saturated-yaw) (< 0.0 old-diff)) (or (and (< saturated-yaw 0.0) (< old-diff 0.0)) - (>= (the-as int (- (-> *display* base-frame-counter) - (-> obj angle-change-time) - ) - ) + (>= (- (-> *display* base-frame-counter) + (-> obj angle-change-time) + ) 60 ) ) @@ -83,9 +82,9 @@ saturated-yaw ) (else - ;; not sure why this isn't 0. - (* 0.000000001 saturated-yaw) - ) + ;; not sure why this isn't 0. + (* 0.000000001 saturated-yaw) + ) ) ) ) diff --git a/goal_src/engine/ps2/memcard-h.gc b/goal_src/engine/ps2/memcard-h.gc index 45f0ee802d..af47a5ffda 100644 --- a/goal_src/engine/ps2/memcard-h.gc +++ b/goal_src/engine/ps2/memcard-h.gc @@ -67,7 +67,7 @@ "Print mc info to the screen." (let ((info (new 'stack-no-clear 'mc-slot-info))) (dotimes (slot-idx 2) - (mc-get-slot-info slot-idx) + (mc-get-slot-info slot-idx info) (cond ((zero? (-> info known)) (format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" slot-idx) diff --git a/goal_src/engine/ps2/pad.gc b/goal_src/engine/ps2/pad.gc index d7ec50a5ac..53f4dd82ce 100644 --- a/goal_src/engine/ps2/pad.gc +++ b/goal_src/engine/ps2/pad.gc @@ -10,6 +10,10 @@ ;; Use the service-cpads functions once per frame to update the data and vibration control ;; The cpad-set-buzz! function can be used for vibration. +;; in display, but we haven't gotten to display-h.gc yet. +(define-extern get-current-time (function int)) +(define-extern get-integral-current-time (function int)) + (defenum pad-buttons :bitfield #t :type uint32 @@ -39,10 +43,6 @@ (namco-gun 6) ) -;; these forward declarations should probably go somewhere else... -(define-extern get-current-time (function uint)) -(define-extern get-integral-current-time (function uint)) - ;; this gets set to #f later on. (define *cheat-mode* #t) @@ -86,10 +86,10 @@ (align uint8 6 :offset-assert 88) ;; hardware control of buzzing. (direct uint8 6 :offset-assert 94) ;; hardware control of buzzing. (buzz-val uint8 2 :offset-assert 100) ;; intensity for buzzing - (buzz-time uint64 2 :offset-assert 104) ;; when to stop buzzing + (buzz-time int64 2 :offset-assert 104) ;; when to stop buzzing (buzz basic :offset-assert 120) ;; is vibration enabled? (buzz-act int32 :offset-assert 124) - (change-time uint64 :offset-assert 128) + (change-time int64 :offset-assert 128) ) (:methods (new (symbol type int) _type_ 0) @@ -132,7 +132,7 @@ ;; probably a bug here, this should use v1-17 as the index. (dotimes (v1-17 2) (set! (-> pad buzz-val 0) (the-as uint 0)) - (set! (-> pad buzz-time 0) (the-as uint 0)) + (set! (-> pad buzz-time 0) 0) ) pad ) @@ -211,16 +211,14 @@ ;; we are already buzzing at this intensity. ;; buzz for max (old_buzz, new_buzz) duration (set! (-> pad buzz-time buzz-idx) - (max (the-as int (-> pad buzz-time buzz-idx)) - (the-as int (+ (get-current-time) (the-as uint duration))) - ) + (max (-> pad buzz-time buzz-idx) (+ (get-current-time) duration)) ) ) ((< (-> pad buzz-val buzz-idx) (the-as uint buzz-amount)) ;; buzz harder than the older value, overwrite the old buzz. (set! (-> pad buzz-val buzz-idx) buzz-amount) (set! (-> pad buzz-time buzz-idx) - (+ (get-current-time) (the-as uint duration)) + (+ (get-current-time) duration) ) ) ) @@ -247,9 +245,7 @@ (cond ;; check if okay to buzz: ((and (-> pad buzz) - (< (the-as int (get-current-time)) - (the-as int (-> pad buzz-time buzz-idx)) - ) + (< (get-current-time) (-> pad buzz-time buzz-idx)) (= *master-mode* 'game) ) (let ((v1-10 buzz-idx)) @@ -259,7 +255,7 @@ ;; an analog control (set! (-> pad direct buzz-idx) (logand (ash (-> pad buzz-val buzz-idx) - (- (the-as int (logand (get-integral-current-time) 7))) + (- (logand (get-integral-current-time) 7)) ) 1 ) diff --git a/goal_src/engine/sound/gsound-h.gc b/goal_src/engine/sound/gsound-h.gc index 1ba7b63641..717dbc4637 100644 --- a/goal_src/engine/sound/gsound-h.gc +++ b/goal_src/engine/sound/gsound-h.gc @@ -381,9 +381,9 @@ (playing-id sound-id :offset-assert 8) (trans vector :inline :offset-assert 16) (name sound-name :offset-assert 32) - (play-time uint64 :offset-assert 48) - (time-base uint64 :offset-assert 56) - (time-random uint64 :offset-assert 64) + (play-time int64 :offset-assert 48) + (time-base int64 :offset-assert 56) + (time-random int64 :offset-assert 64) (volume int32 :offset-assert 72) (pitch int32 :offset-assert 76) (falloff-near int32 :offset-assert 80) diff --git a/goal_src/engine/sound/gsound.gc b/goal_src/engine/sound/gsound.gc index 5b4d03acbf..e0663e4a32 100644 --- a/goal_src/engine/sound/gsound.gc +++ b/goal_src/engine/sound/gsound.gc @@ -563,11 +563,11 @@ ) (cond (sound-times - (set! (-> obj time-base) (the-as uint (the int (* 300.0 (-> sound-times 0))))) - (set! (-> obj time-random) (the-as uint (the int (* 300.0 (-> sound-times 1))))) + (set! (-> obj time-base) (the int (* 300.0 (-> sound-times 0)))) + (set! (-> obj time-random) (the int (* 300.0 (-> sound-times 1)))) ) (else - (set! (-> obj time-base) (the-as uint -1)) + (set! (-> obj time-base) -1) ) ) (set! (-> obj trans quad) (-> sound-trans quad)) @@ -592,14 +592,13 @@ ) (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 (or (< (-> obj time-base) 0) + (>= (-> *display* base-frame-counter) (-> obj play-time)) ) - (when (>= (the-as int (-> obj time-base)) 0) + (when (>= (-> obj time-base) 0) (set! (-> obj play-time) (+ (-> *display* base-frame-counter) (-> obj time-base) - (the-as uint (rand-vu-int-count (the-as int (-> obj time-random)))) + (rand-vu-int-count (-> obj time-random)) )) (set! (-> obj playing-id) (new-sound-id)) ) @@ -620,7 +619,7 @@ (vector-vector-distance (ear-trans) (-> obj trans)))) (return 0) ) - (when (and *debug-effect-control* (>= (the-as int (-> obj time-base)) 0)) + (when (and *debug-effect-control* (>= (-> obj time-base) 0)) (with-pp (format #t "(~5D) effect sound ~A ~G " (-> *display* base-frame-counter) @@ -641,7 +640,7 @@ ) (else (cond - ((< (the-as int (-> obj time-base)) 0) + ((< (-> obj time-base) 0) (set! (-> obj playing-id) (sound-play-by-name (-> obj name) (-> obj playing-id) @@ -652,8 +651,7 @@ (-> obj trans))) ) (else - (when (>= (the-as int (-> *display* base-frame-counter)) - (the-as int (-> obj play-time))) + (when (>= (-> *display* base-frame-counter) (-> obj play-time)) (set! (-> obj playing-id) (sound-play-by-name (-> obj name) (new-sound-id) @@ -664,7 +662,7 @@ (-> 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)))) + (rand-vu-int-count (-> obj time-random)) )) ) ) diff --git a/goal_src/engine/sparticle/sparticle-launcher-h.gc b/goal_src/engine/sparticle/sparticle-launcher-h.gc index b84013d03e..53ae4c351e 100644 --- a/goal_src/engine/sparticle/sparticle-launcher-h.gc +++ b/goal_src/engine/sparticle/sparticle-launcher-h.gc @@ -78,14 +78,14 @@ (linger-duration uint16 :offset-assert 8) (flags uint16 :offset-assert 10) (name basic :offset-assert 12) - (launcher uint32 :offset-assert 16) + (launcher sparticle-group-item :offset-assert 16) (bounds sphere :inline :offset-assert 32) ) :method-count-assert 10 :size-assert #x30 :flag-assert #xa00000030 (:methods - (dummy-9 (_type_ process) _type_ 9) + (create-launch-control (_type_ process) sparticle-launch-control 9) ) ) @@ -106,8 +106,8 @@ (:methods (dummy-9 () none 9) (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) + (dummy-11 (_type_ vector) none 11) + (deactivate (_type_) none 12) (dummy-13 () none 13) ) ) diff --git a/goal_src/engine/target/joint-mod-h.gc b/goal_src/engine/target/joint-mod-h.gc index 477544432b..0bc626ddcb 100644 --- a/goal_src/engine/target/joint-mod-h.gc +++ b/goal_src/engine/target/joint-mod-h.gc @@ -41,7 +41,7 @@ (trans vector :inline :offset-assert 64) (quat quaternion :inline :offset-assert 80) (scale vector :inline :offset-assert 96) - (notice-time uint64 :offset-assert 112) + (notice-time int64 :offset-assert 112) (flex-blend float :offset-assert 120) (blend float :offset-assert 124) (max-dist meters :offset-assert 128) @@ -225,15 +225,15 @@ (defmethod look-at-enemy! joint-mod ((obj joint-mod) (target-trans vector) (option symbol) (proc process)) "Set up animation for Jak looking at an enemy. If option is 'attacking, remember when this happened. - Will only override an existing look-at if this one is closer, or option is 'force. - " + Will only override an existing look-at if this one is closer, or option is 'force. + " (when (= option 'attacking) ;; make sure we got a process-drawable (let* ((s3-0 proc) (proc-drawable - (if (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) - (the-as process-drawable s3-0) - ) + (if (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) + (the-as process-drawable s3-0) + ) ) ) (when proc-drawable @@ -243,7 +243,7 @@ (the-as fact-info-enemy s0-0) ) ) - ) + ) ) ;; check that we have enemy facts, and that we are within the notice distance (when (and enemy-facts (< (vector-vector-distance (-> obj process root trans) (-> proc-drawable root trans)) @@ -253,16 +253,7 @@ ;; success! we consider this a noticed and remember when (set! (-> obj notice-time) (-> *display* base-frame-counter)) ;; and update the look at data - (let ((v1-12 (if proc - (-> proc ppointer) - ) - ) - ) - (set! - (-> last-try-to-look-at-data who) - (new 'static 'handle :process v1-12 :pid (-> v1-12 0 pid)) - ) - ) + (set! (-> last-try-to-look-at-data who) (process->handle proc)) ;; not sure what these are yet. (if (< (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) (set! (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) @@ -275,21 +266,21 @@ ) ) ) - + ;; in all cases, (let ((dist (vector-vector-distance (-> obj process root trans) target-trans))) (when (and - ;; done with previous - (or (= (-> obj blend) 0.0) - ;; closer than previous. - (or (< dist (vector-vector-distance (-> obj process root trans) (-> obj target))) - ;; force - (= option 'force) - ) - ) - ;; and in range - (< dist (-> obj max-dist)) - ) + ;; done with previous + (or (= (-> obj blend) 0.0) + ;; closer than previous. + (or (< dist (vector-vector-distance (-> obj process root trans) (-> obj target))) + ;; force + (= option 'force) + ) + ) + ;; and in range + (< dist (-> obj max-dist)) + ) ;; set mode, if we aren't in one (if (= (-> obj mode) (joint-mod-handler-mode reset)) (set-mode! obj (joint-mod-handler-mode look-at)) diff --git a/goal_src/engine/ui/progress-h.gc b/goal_src/engine/ui/progress-h.gc index 3411c5c9f2..1381949c1c 100644 --- a/goal_src/engine/ui/progress-h.gc +++ b/goal_src/engine/ui/progress-h.gc @@ -183,4 +183,5 @@ (define-extern activate-orb-all (function int int)) ;; maybe in hud? (define-extern progress-allowed? (function symbol)) (define-extern pause-allowed? (function symbol)) -(define-extern deactivate-progress (function none)) \ No newline at end of file +(define-extern deactivate-progress (function none)) +(define-extern calculate-completion (function symbol float)) \ No newline at end of file diff --git a/goal_src/engine/ui/text-h.gc b/goal_src/engine/ui/text-h.gc index c125822e98..6eef4ad777 100644 --- a/goal_src/engine/ui/text-h.gc +++ b/goal_src/engine/ui/text-h.gc @@ -35,6 +35,9 @@ (hidden-power-cell #x12f) ;; why is this here?? + (saving-data #x136) + (do-not-remove-mem-card #x138) + (continue-without-saving #x13f) (back #x13e) (load-game #x14b) @@ -45,7 +48,7 @@ (exit-demo #x15f) (press-start #x16e) (quit-game #x16f) - + (village1-mayor-money #x200) (vollage1-uncle-money #x201) (village1-yakow-herd #x202) diff --git a/goal_src/engine/util/smush-control-h.gc b/goal_src/engine/util/smush-control-h.gc index bcfe45c74a..d4b99fad96 100644 --- a/goal_src/engine/util/smush-control-h.gc +++ b/goal_src/engine/util/smush-control-h.gc @@ -11,13 +11,13 @@ ;; - the amplitude is additionally linearly scaled to go to zero over the duration. (deftype smush-control (structure) - ((start-time uint64 :offset-assert 0) - (period float :offset-assert 8) - (duration float :offset-assert 12) - (amp float :offset-assert 16) - (damp-amp float :offset-assert 20) - (damp-period float :offset-assert 24) ;; set a negative value here to flag as die on next update - (ticks float :offset-assert 28) + ((start-time int64 :offset-assert 0) + (period float :offset-assert 8) + (duration float :offset-assert 12) + (amp float :offset-assert 16) + (damp-amp float :offset-assert 20) + (damp-period float :offset-assert 24) ;; set a negative value here to flag as die on next update + (ticks float :offset-assert 28) ) :method-count-assert 15 :size-assert #x20 diff --git a/goal_src/engine/util/sync-info-h.gc b/goal_src/engine/util/sync-info-h.gc index 1e8ebd9307..c0b2cfa82b 100644 --- a/goal_src/engine/util/sync-info-h.gc +++ b/goal_src/engine/util/sync-info-h.gc @@ -64,7 +64,7 @@ (max-time int32 :offset-assert 4) (max-val float :offset-assert 8) (timer int32 :offset-assert 12) - (start-time uint64 :offset-assert 16) + (start-time int64 :offset-assert 16) (value float :offset-assert 24) ) :method-count-assert 11 @@ -117,7 +117,7 @@ (xz-max float :offset-assert 8) (y-max float :offset-assert 12) (timer int32 :offset-assert 16) - (start-time uint64 :offset-assert 24) + (start-time int64 :offset-assert 24) (value vector :inline :offset-assert 32) ) :method-count-assert 13 diff --git a/goal_src/engine/util/sync-info.gc b/goal_src/engine/util/sync-info.gc index c77fb4e4d6..792dc0e29d 100644 --- a/goal_src/engine/util/sync-info.gc +++ b/goal_src/engine/util/sync-info.gc @@ -233,7 +233,7 @@ (period-float (the float period)) ;; now + offset (current-time - (+ (the float (mod (-> *display* base-frame-counter) period)) + (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset) ) ) @@ -265,7 +265,7 @@ ) ;; with the current offset, what is the time (0, period)? (current-time - (+ (the float (mod (-> *display* base-frame-counter) period)) + (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset) ) ) @@ -299,7 +299,7 @@ "Get the current phase." (let* ((period (-> obj period)) (period-float (the float period)) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) ) ;; don't need to wrap this again. (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) @@ -314,7 +314,7 @@ (let* ((period (-> obj period)) (period-float (the float period)) (max-phase 1.0) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) ) (fmin max-phase (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) @@ -328,7 +328,7 @@ "This is just get-current-phase multiplied by max-val" (let* ((period (-> obj period)) (period-float (the float period)) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) ) (* (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) period-float @@ -348,7 +348,7 @@ (let* ((period (-> obj period)) (period-float (the float period)) (max-val 2.0) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) (phase-out-of-2 (* max-val (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) @@ -371,7 +371,7 @@ (let* ((period (-> obj period)) (period-float (the float period)) (max-val 2.0) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) (current-val (* max-val (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) @@ -424,7 +424,7 @@ ;; max val (f0-1 2.0) ;; current-time - (f2-2 (+ (the float (mod (-> *display* base-frame-counter) v1-0)) (-> obj offset))) + (f2-2 (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) v1-0)) (-> obj offset))) ;; phase (f0-2 (* f0-1 (/ (- f2-2 (* (the float (the int (/ f2-2 f1-0))) f1-0)) f1-0))) ;; offset for pause @@ -456,7 +456,7 @@ (let* ((period (-> obj period)) (period-float (the float period)) (max-val 2.0) - (current-time (+ (the float (mod (-> *display* base-frame-counter) period)) (-> obj offset))) + (current-time (+ (the float (mod (the-as uint (-> *display* base-frame-counter)) period)) (-> obj offset))) (current-val (* max-val (/ (- current-time (* (the float (the int (/ current-time period-float))) period-float)) @@ -490,7 +490,7 @@ (set! (-> obj min-time) min-tim) (set! (-> obj max-time) max-time) (set! (-> obj max-val) (* 0.5 max-times-two)) - (set! (-> obj start-time) (the-as uint 0)) + (set! (-> obj start-time) 0) (set! (-> obj timer) 0) (set! (-> obj value) 0.0) (-> obj value) @@ -498,7 +498,7 @@ (defmethod update! delayed-rand-float ((obj delayed-rand-float)) "Get the value." - (when (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) (-> obj timer)) + (when (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) ;; only update if enough time has passed. (set! (-> obj start-time) (-> *display* base-frame-counter)) ;; come up with a random end time. @@ -609,7 +609,7 @@ (set! (-> obj max-time) max-time) (set! (-> obj xz-max) (* 0.5 xz-range)) (set! (-> obj y-max) (* 0.5 y-range)) - (set! (-> obj start-time) (the-as uint 0)) + (set! (-> obj start-time) 0) (set! (-> obj timer) 0) (vector-reset! (-> obj value)) (-> obj value) @@ -627,7 +627,7 @@ (defmethod update-with-delay! delayed-rand-vector ((obj delayed-rand-vector)) "Update, if enough time has passed" - (if (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) (-> obj timer)) + (if (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) (update-now! obj) ) (-> obj value) @@ -635,7 +635,7 @@ (defmethod update-with-delay-or-reset! delayed-rand-vector ((obj delayed-rand-vector)) "Update, if enough time has passed. Otherwise reset to zero." - (if (>= (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) (-> obj timer)) + (if (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) (update-now! obj) (vector-reset! (-> obj value)) ) diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index 8c472e28d5..d4d4e04b2e 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -101,15 +101,38 @@ (define-extern dgo-load (function string kheap int int none)) (define-extern link-begin (function pointer (pointer uint8) int kheap link-flag int)) (define-extern link-resume (function int)) + +(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) + ) + (define-extern mc-run (function none)) -;; mc-format -;; mc-unformat -;; mc-create-file -;; mc-save -;; mc-load +(define-extern mc-format (function int mc-status-code)) +(define-extern mc-unformat (function int mc-status-code)) +(define-extern mc-create-file (function int uint mc-status-code)) +(define-extern mc-save (function int int pointer int mc-status-code)) +(define-extern mc-load (function int int pointer mc-status-code)) (declare-type mc-slot-info structure) (define-extern mc-sync (function int)) -(define-extern mc-get-slot-info (function int mc-slot-info)) +(define-extern mc-get-slot-info (function int mc-slot-info none)) (define-extern mc-check-result (function int)) ;; mc-makefile @@ -160,7 +183,8 @@ (define-extern file-stream-read (function file-stream pointer int int)) (define-extern file-stream-write (function file-stream pointer uint uint)) (define-extern scf-get-language (function uint)) -;; scf-get-time +(declare-type scf-time structure) +(define-extern scf-get-time (function scf-time none)) (define-extern scf-get-aspect (function uint)) (define-extern scf-get-volume (function int)) (define-extern scf-get-territory (function int)) diff --git a/goal_src/kernel/gkernel-h.gc b/goal_src/kernel/gkernel-h.gc index f546de2bb9..4380b319b0 100644 --- a/goal_src/kernel/gkernel-h.gc +++ b/goal_src/kernel/gkernel-h.gc @@ -401,17 +401,32 @@ (defmacro handle->process (handle) ;; the actual implementation is more clever than this. ;; Checks PID. - `(if (-> ,handle process) - (let ((proc (-> (-> ,handle process)))) - (if (= (-> ,handle pid) (-> proc pid)) - proc - ) + `(let ((the-handle ,handle)) + (if (-> the-handle process) + (let ((proc (-> (-> the-handle process)))) + (if (= (-> the-handle pid) (-> proc pid)) + proc + ) + ) ) - ) + ) + ) + +(defmacro ppointer->process (ppointer) + ;; convert a (pointer process) to a process. + ;; this uses the self field, which seems to always just get set to the object. + ;; perhaps when deleting a process you could have it set self to #f? + ;; I don't see this happen anywhere though, so it's not clear. + `(let ((the-pp ,ppointer)) + (the process (if the-pp (-> the-pp 0 self))) + ) ) (defmacro process->ppointer (proc) - `(if ,proc (the (pointer process) (-> ,proc ppointer))) + ;"safely get a (pointer process) from a process, returning #f if invalid." + `(let ((the-proc ,proc)) + (if the-proc (-> the-proc ppointer)) + ) ) (defmacro ppointer->handle (pproc) @@ -440,7 +455,7 @@ (deftype state (protect-frame) ((code function :offset-assert 16) (trans (function none) :offset-assert 20) - (post (function none) :offset-assert 24) + (post (function none) :offset-assert 24) (enter function :offset-assert 28) (event (function process int symbol event-message-block object) :offset-assert 32) ) @@ -471,23 +486,6 @@ :flag-assert #x900000048 ) -(defmacro as-process (ppointer) - ;; convert a (pointer process) to a process. - ;; this uses the self field, which seems to always just get set to the object. - ;; perhaps when deleting a process you could have it set self to #f? - ;; I don't see this happen anywhere though, so it's not clear. - `(if ,ppointer - (-> (-> ,ppointer) self) - ) - ) - -(defmacro as-ppointer (proc) - ;"safely get a (pointer process) from a process, returning #f if invalid." - `(if ,proc - (-> ,proc ppointer) - ) - ) - (defmacro process-stack-used (proc) ;; get how much stack the top thread of a process has used. `(- (the int (-> ,proc top-thread stack-top)) diff --git a/goal_src/kernel/gkernel.gc b/goal_src/kernel/gkernel.gc index 13df1127e4..f4899e9f1b 100644 --- a/goal_src/kernel/gkernel.gc +++ b/goal_src/kernel/gkernel.gc @@ -308,9 +308,9 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tname: ~S~%" (-> obj name)) (format #t "~Tmask: #x~X~%" (-> obj mask)) - (format #t "~Tparent: ~A~%" (as-process (-> obj parent))) - (format #t "~Tbrother: ~A~%" (as-process (-> obj brother))) - (format #t "~Tchild: ~A~%" (as-process (-> obj child))) + (format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> obj child))) obj ) @@ -394,9 +394,9 @@ (format #t "~Ttrans-hook: ~A~%" (-> obj trans-hook)) (format #t "~Tpost-hook: ~A~%" (-> obj post-hook)) (format #t "~Tevent-hook: ~A~%" (-> obj event-hook)) - (format #t "~Tparent: ~A~%" (as-process (-> obj parent))) - (format #t "~Tbrother: ~A~%" (as-process (-> obj brother))) - (format #t "~Tchild: ~A~%" (as-process (-> obj child))) + (format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> obj child))) (format #t "~Tconnection-list: ~`connectable`P~%" (-> obj connection-list)) (format #t "~Tstack-frame-top: ~A~%" (-> obj stack-frame-top)) (format #t "~Theap-base: #x~X~%" (-> obj heap-base)) @@ -845,8 +845,8 @@ ;; create each process (let ((old-bro (-> obj child)) (next ((method-of-type process new) allocation process 'dead stack-size))) - (set! (-> obj child) (as-ppointer next)) - (set! (-> next parent) (as-ppointer obj)) + (set! (-> obj child) (process->ppointer next)) + (set! (-> next parent) (process->ppointer obj)) (set! (-> next pool) obj) (set! (-> next brother) old-bro) ) @@ -865,7 +865,7 @@ (set! proc (the (pointer process-tree) (get-process *debug-dead-pool* type-to-make stack-size))) (when proc (format 0 "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%" - type-to-make (as-process proc) (-> obj name)) + type-to-make (ppointer->process proc) (-> obj name)) ) ;; there's a bug here. proc is a process here, but will be used as a process pointer. ;; let's just kill the program here. @@ -881,7 +881,7 @@ ) (else (format 0 "WARNING: ~A ~A could not be allocated, because ~A was empty.~%" - type-to-make (as-process proc) (-> obj name)) + type-to-make (ppointer->process proc) (-> obj name)) (the process #f) ) ) @@ -2007,12 +2007,12 @@ ;; need to remove obj from its current parent (when parent (let ((proc (-> (-> parent) child))) - (if (eq? (as-process proc) obj) + (if (eq? (ppointer->process proc) obj) ;; case where we're the first child is easy! (set! (-> (-> parent) child) (-> obj brother)) ;; otherwise, look through brothers to find us. (begin - (while (not (eq? (as-process (-> (-> proc) brother)) obj)) + (while (not (eq? (ppointer->process (-> (-> proc) brother)) obj)) (set! proc (-> (-> proc) brother)) ) ;; ok, got us, splice out of list. diff --git a/goal_src/levels/beach/bird-lady-beach.gc b/goal_src/levels/beach/bird-lady-beach.gc index 710c15a741..a98bf18526 100644 --- a/goal_src/levels/beach/bird-lady-beach.gc +++ b/goal_src/levels/beach/bird-lady-beach.gc @@ -70,34 +70,37 @@ (the-as game-task (current-task (-> obj tasks))) ) (close-current! (-> obj tasks)) - (let* ((s5-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-8 (when s5-1 - (let ((t9-4 (method-of-type manipy activate))) - (t9-4 - (the-as manipy s5-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-1 - manipy-init - (-> obj root trans) - (-> obj entity) - *flutflut-naked-sg* - #f - ) - (-> s5-1 ppointer) - ) - ) - ) - (set! - (-> obj flutflut) - (new 'static 'handle :process v1-8 :pid (-> v1-8 0 pid)) + (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj flutflut) (ppointer->handle (when s5-1 + (let + ((t9-4 + (method-of-type + manipy + activate + ) + ) + ) + (t9-4 + (the-as manipy s5-1) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-1 + manipy-init + (-> obj root trans) + (-> obj entity) + *flutflut-naked-sg* + #f + ) + (-> s5-1 ppointer) + ) + ) ) ) (let ((a1-4 (new 'stack-no-clear 'event-message-block))) @@ -114,34 +117,37 @@ (set! (-> a1-5 param 0) (the-as uint #t)) (send-event-function (handle->process (-> obj flutflut)) a1-5) ) - (let* ((s5-2 (get-process *default-dead-pool* manipy #x4000)) - (v1-28 (when s5-2 - (let ((t9-9 (method-of-type manipy activate))) - (t9-9 - (the-as manipy s5-2) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-2 - manipy-init - (-> obj root trans) - (-> obj entity) - *flutflutegg-sg* - #f - ) - (-> s5-2 ppointer) - ) - ) - ) - (set! - (-> obj egg) - (new 'static 'handle :process v1-28 :pid (-> v1-28 0 pid)) + (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj egg) (ppointer->handle (when s5-2 + (let + ((t9-9 + (method-of-type + manipy + activate + ) + ) + ) + (t9-9 + (the-as manipy s5-2) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-2 + manipy-init + (-> obj root trans) + (-> obj entity) + *flutflutegg-sg* + #f + ) + (-> s5-2 ppointer) + ) + ) ) ) (let ((a1-9 (new 'stack-no-clear 'event-message-block))) @@ -220,4 +226,4 @@ (set! (-> obj sound-flava) (the-as uint 7)) (dummy-42 obj) (none) - ) + ) \ No newline at end of file diff --git a/goal_src/levels/beach/sculptor.gc b/goal_src/levels/beach/sculptor.gc index 28db3e37d4..300f443d18 100644 --- a/goal_src/levels/beach/sculptor.gc +++ b/goal_src/levels/beach/sculptor.gc @@ -111,7 +111,7 @@ ((and (-> obj draw shadow) (zero? (-> obj draw cur-lod)) - (nonzero? (logand (-> obj draw status) 8)) + (logtest? (-> obj draw status) 8) ) (let ((v1-9 (-> obj draw shadow-ctrl))) (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) @@ -132,34 +132,47 @@ ;; definition for function muse-to-idle (defbehavior muse-to-idle sculptor ((arg0 muse)) (when (not (handle->process (-> arg0 incomming-attack-id))) - (let* ((s5-0 (get-process *default-dead-pool* manipy #x4000)) - (v1-5 (when s5-0 - (let ((t9-1 (method-of-type manipy activate))) - (t9-1 - (the-as manipy s5-0) - arg0 - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-0 - manipy-init - (-> arg0 collide-info trans) - (-> arg0 entity) - *sculptor-muse-sg* - #f - ) - (-> s5-0 ppointer) - ) - ) - ) - (set! - (-> arg0 incomming-attack-id) - (new 'static 'handle :process v1-5 :pid (-> v1-5 0 pid)) + (let ((s5-0 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> arg0 incomming-attack-id) (ppointer->handle (when s5-0 + (let + ((t9-1 + (method-of-type + manipy + activate + ) + ) + ) + (t9-1 + (the-as + manipy + s5-0 + ) + arg0 + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-0 + manipy-init + (-> + arg0 + collide-info + trans + ) + (-> arg0 entity) + *sculptor-muse-sg* + #f + ) + (-> s5-0 ppointer) + ) + ) ) ) ) @@ -308,34 +321,37 @@ (the-as game-task (current-task (-> obj tasks))) ) (close-current! (-> obj tasks)) - (let* ((s5-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-12 (when s5-1 - (let ((t9-5 (method-of-type manipy activate))) - (t9-5 - (the-as manipy s5-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-1 - manipy-init - (-> obj root trans) - (-> obj entity) - *sculptor-muse-sg* - #f - ) - (-> s5-1 ppointer) - ) - ) - ) - (set! - (-> obj muse) - (new 'static 'handle :process v1-12 :pid (-> v1-12 0 pid)) + (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj muse) (ppointer->handle (when s5-1 + (let + ((t9-5 + (method-of-type + manipy + activate + ) + ) + ) + (t9-5 + (the-as manipy s5-1) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-1 + manipy-init + (-> obj root trans) + (-> obj entity) + *sculptor-muse-sg* + #f + ) + (-> s5-1 ppointer) + ) + ) ) ) (let ((v1-18 (handle->process (-> obj muse)))) @@ -1229,4 +1245,4 @@ (set! (-> obj draw light-index) (the-as uint 3)) (dummy-42 obj) (none) - ) + ) \ No newline at end of file diff --git a/goal_src/levels/common/nav-enemy-h.gc b/goal_src/levels/common/nav-enemy-h.gc index c2f4bf69ab..65d5f5067b 100644 --- a/goal_src/levels/common/nav-enemy-h.gc +++ b/goal_src/levels/common/nav-enemy-h.gc @@ -77,15 +77,15 @@ (momentum-speed float :offset-assert 296) (acceleration float :offset-assert 300) (rotate-speed float :offset-assert 304) - (turn-time uint64 :offset-assert 312) - (frustration-time uint64 :offset-assert 320) + (turn-time int64 :offset-assert 312) + (frustration-time int64 :offset-assert 320) (speed-scale float :offset-assert 328) (neck joint-mod :offset-assert 332) ; this is what `neck` is on the pelican - (reaction-time uint64 :offset-assert 336) - (notice-time uint64 :offset-assert 344) - (state-timeout uint64 :offset-assert 352) - (free-time uint64 :offset-assert 360) - (touch-time uint64 :offset-assert 368) + (reaction-time int64 :offset-assert 336) + (notice-time int64 :offset-assert 344) + (state-timeout int64 :offset-assert 352) + (free-time int64 :offset-assert 360) + (touch-time int64 :offset-assert 368) (nav-enemy-flags uint32 :offset-assert 376) (incomming-attack-id handle :offset-assert 384) (jump-return-state (state process) :offset-assert 392) diff --git a/goal_src/levels/common/nav-enemy.gc b/goal_src/levels/common/nav-enemy.gc index 162abafbe2..99d8fd6a47 100644 --- a/goal_src/levels/common/nav-enemy.gc +++ b/goal_src/levels/common/nav-enemy.gc @@ -107,46 +107,43 @@ ;; INFO: Return type mismatch int vs none. (defmethod TODO-RENAME-39 nav-enemy ((obj nav-enemy)) (when - (and - (logtest? (-> obj nav-enemy-flags) 256) - (or - (not *target*) - (and - (zero? (logand (-> *target* state-flags) #x80f8)) - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj touch-time))) - 15 - ) - ) - ) + (and + (logtest? (-> obj nav-enemy-flags) 256) + (or + (not *target*) + (and + (zero? (logand (-> *target* state-flags) #x80f8)) + (>= (- (-> *display* base-frame-counter) (-> obj touch-time)) 15) ) - (dummy-54 (-> obj collide-info) 2 1) - (set! (-> obj nav-enemy-flags) (logand -257 (-> obj nav-enemy-flags))) + ) ) + (dummy-54 (-> obj collide-info) 2 1) + (set! (-> obj nav-enemy-flags) (logand -257 (-> obj nav-enemy-flags))) + ) ((method-of-object (-> obj draw shadow-ctrl) dummy-14)) (when *target* - (if *target* - (look-at-enemy! - (-> *target* neck) - (the-as vector (-> obj collide-info root-prim prim-core)) - (if (logtest? (-> obj nav-enemy-flags) 4) - 'attacking - ) - obj - ) - ) - (if (and (nonzero? (-> obj neck)) (logtest? (-> obj nav-enemy-flags) #x4000)) - (set-target! - (-> obj neck) - (target-pos (-> obj nav-info player-look-at-joint)) - ) - ) + (if *target* + (look-at-enemy! + (-> *target* neck) + (the-as vector (-> obj collide-info root-prim prim-core)) + (if (logtest? (-> obj nav-enemy-flags) 4) + 'attacking + ) + obj + ) ) + (if (and (nonzero? (-> obj neck)) (logtest? (-> obj nav-enemy-flags) #x4000)) + (set-target! + (-> obj neck) + (target-pos (-> obj nav-info player-look-at-joint)) + ) + ) + ) (when (-> obj nav-info debug-draw-neck) - (if (nonzero? (-> obj neck)) - (joint-mod-debug-draw (-> obj neck)) - ) + (if (nonzero? (-> obj neck)) + (joint-mod-debug-draw (-> obj neck)) ) + ) (ja-post) 0 (none) @@ -259,10 +256,11 @@ (set! (-> a1-1 mode) arg2) (set! (-> v1-0 param 1) (the-as uint a1-1)) ) - (when (send-event-function arg0 v1-0) - (dummy-54 (-> self collide-info) 2 0) - (logior! (-> self nav-enemy-flags) 256) - #t + (the-as object (when (send-event-function arg0 v1-0) + (dummy-54 (-> self collide-info) 2 0) + (logior! (-> self nav-enemy-flags) 256) + #t + ) ) ) ) @@ -456,19 +454,19 @@ nav-enemy-default-event-handler (if (or (logtest? (-> obj nav-enemy-flags) 128) - (nonzero? (logand #x80000 (-> obj nav flags))) + (logtest? #x80000 (-> obj nav flags)) ) (seek-to-point-toward-point! (-> obj collide-info) (-> obj nav target-pos) (-> obj rotate-speed) - (the-as int (-> obj turn-time)) + (-> obj turn-time) ) (seek-toward-heading-vec! (-> obj collide-info) (-> obj nav travel) (-> obj rotate-speed) - (the-as int (-> obj turn-time)) + (-> obj turn-time) ) ) ) @@ -487,7 +485,7 @@ nav-enemy-default-event-handler 8192.0 #f (-> obj nav-info hover-if-no-ground) - (nonzero? (logand (-> obj nav-enemy-flags) #x8000)) + (logtest? (-> obj nav-enemy-flags) #x8000) ) (dummy-58 (-> obj collide-info) (-> obj collide-info transv)) ) @@ -600,12 +598,12 @@ nav-enemy-default-event-handler ;; definition for function nav-enemy-face-player-post ;; INFO: Return type mismatch int vs none. (defbehavior nav-enemy-face-player-post nav-enemy () - (if (and *target* (nonzero? (logand (-> self nav-enemy-flags) 16))) + (if (and *target* (logtest? (-> self nav-enemy-flags) 16)) (seek-to-point-toward-point! (-> self collide-info) (target-pos 0) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (nav-enemy-simple-post) @@ -660,10 +658,7 @@ nav-enemy-default-event-handler ;; INFO: Return type mismatch int vs none. (defbehavior nav-enemy-neck-control-inactive nav-enemy () (when - (and - (nonzero? (-> self neck)) - (nonzero? (logand (-> self nav-enemy-flags) #x4000)) - ) + (and (nonzero? (-> self neck)) (logtest? (-> self nav-enemy-flags) #x4000)) (set! (-> self nav-enemy-flags) (logand -16385 (-> self nav-enemy-flags))) (shut-down! (-> self neck)) ) @@ -705,8 +700,8 @@ nav-enemy-default-event-handler ((logtest? (-> self nav-enemy-flags) 1) (when (>= - (the-as int (- (-> *display* base-frame-counter) (-> self notice-time))) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (-> self notice-time)) + (-> self reaction-time) ) (set! gp-0 #t) (set! (-> self nav-enemy-flags) (logand -2 (-> self nav-enemy-flags))) @@ -937,7 +932,10 @@ nav-enemy-default-event-handler (set! (-> v1-14 num-func) num-func-identity) (set! (-> v1-14 frame-num) 0.0) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status)) @@ -1019,7 +1017,7 @@ nav-enemy-default-event-handler (-> self collide-info) arg0 (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (suspend) (let ((a0-8 (-> self skel root-channel 0))) @@ -1033,7 +1031,7 @@ nav-enemy-default-event-handler (set! v1-16 (or - (>= (the-as int (- (-> *display* base-frame-counter) s4-0)) 3000) + (>= (- (-> *display* base-frame-counter) s4-0) 3000) (nav-enemy-facing-direction? arg0 arg1) ) ) @@ -1087,7 +1085,7 @@ nav-enemy-default-event-handler (nonzero? (-> obj skel)) (!= (-> obj skel root-channel 0) (-> obj skel channel)) ) - (and (nonzero? (-> obj draw)) (nonzero? (logand (-> obj draw status) 16))) + (and (nonzero? (-> obj draw)) (logtest? (-> obj draw status) 16)) ) ) ) @@ -1103,7 +1101,10 @@ nav-enemy-default-event-handler :enter (behavior () (nav-enemy-neck-control-inactive) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (if (-> self nav-info move-to-ground) (dummy-60 (-> self collide-info) @@ -1114,7 +1115,7 @@ nav-enemy-default-event-handler ) ) (set! (-> self nav-enemy-flags) (logand -7 (-> self nav-enemy-flags))) - (set! (-> self state-timeout) (the-as uint 300)) + (set! (-> self state-timeout) 300) (none) ) :trans @@ -1132,14 +1133,11 @@ nav-enemy-default-event-handler ) ) (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) (nonzero? (-> self draw)) - (nonzero? (logand (-> self draw status) 8)) + (logtest? (-> self draw status) 8) ) (go-virtual nav-enemy-patrol) ) @@ -1190,18 +1188,21 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self nav flags) (the-as nav-control-flags (the-as int (logior #x80000 (-> self nav flags)))) ) (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (logior! (-> self nav-enemy-flags) 8) - (set! (-> self state-timeout) (the-as uint 300)) + (set! (-> self state-timeout) 300) (set! (-> self target-speed) (-> self nav-info walk-travel-speed)) (set! (-> self acceleration) (-> self nav-info walk-acceleration)) (set! (-> self rotate-speed) (-> self nav-info walk-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info walk-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info walk-turn-time))) (none) ) :exit @@ -1213,25 +1214,15 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) - (if - (and - (nonzero? (-> self draw)) - (nonzero? (logand (-> self draw status) 8)) - ) + (if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) 8)) (set! (-> self free-time) (-> *display* base-frame-counter)) ) (if @@ -1246,10 +1237,7 @@ nav-enemy-default-event-handler ) ) ) - (>= - (the-as int (- (-> *display* base-frame-counter) (-> self free-time))) - 600 - ) + (>= (- (-> *display* base-frame-counter) (-> self free-time)) 600) ) (go-virtual nav-enemy-idle) ) @@ -1556,7 +1544,7 @@ nav-enemy-default-event-handler ) (dummy-11 (-> self nav) (-> self nav target-pos)) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (none) ) :code @@ -1605,7 +1593,7 @@ nav-enemy-default-event-handler (-> self collide-info) (-> self nav travel) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (suspend) (let ((a0-4 (-> self skel root-channel 0))) @@ -1648,18 +1636,18 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (none) ) :trans (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self reaction-time) ) (if (or @@ -1851,13 +1839,16 @@ nav-enemy-default-event-handler :enter (behavior () (nav-enemy-neck-control-look-at) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self free-time) (-> *display* base-frame-counter)) (logior! (-> self nav-enemy-flags) 4) (set! (-> self target-speed) (-> self nav-info run-travel-speed)) (set! (-> self acceleration) (-> self nav-info run-acceleration)) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (nav-enemy-reset-frustration) (none) ) @@ -1881,39 +1872,26 @@ nav-enemy-default-event-handler ) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self reaction-time) ) (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self frustration-time)) - ) - (the-as - int - (+ (-> self reaction-time) (-> self nav-info frustration-time)) - ) + (- (-> *display* base-frame-counter) (-> self frustration-time)) + (+ (-> self reaction-time) (-> self nav-info frustration-time)) ) (logior! (-> self nav-enemy-flags) 8192) ) (if (or (not (TODO-RENAME-46 self (-> self nav-info stop-chase-distance))) - (nonzero? (logand (-> self nav-enemy-flags) 8192)) + (logtest? (-> self nav-enemy-flags) 8192) ) (go-virtual nav-enemy-stop-chase) ) (cond ((logtest? #x20000 (-> self nav flags)) - (if - (>= - (the-as int (- (-> *display* base-frame-counter) (-> self free-time))) - 300 - ) + (if (>= (- (-> *display* base-frame-counter) (-> self free-time)) 300) (go-virtual nav-enemy-patrol) ) ) @@ -1969,7 +1947,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (let* ((f30-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0)) @@ -1987,22 +1968,19 @@ nav-enemy-default-event-handler (if (< f30-0 40960.0) (go-virtual nav-enemy-stare) ) - (set! (-> self state-timeout) (the-as uint gp-1)) + (set! (-> self state-timeout) gp-1) ) (set! (-> self target-speed) (-> self nav-info walk-travel-speed)) (set! (-> self acceleration) (-> self nav-info walk-acceleration)) (set! (-> self rotate-speed) (-> self nav-info walk-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info walk-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info walk-turn-time))) (none) ) :trans (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (logtest? (-> *target* state-flags) 128) @@ -2029,11 +2007,8 @@ nav-enemy-default-event-handler ) (logtest? #x20000 (-> self nav flags)) (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) ) (go-virtual nav-enemy-stare) @@ -2086,27 +2061,27 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self nav-enemy-flags) (logand -17 (-> self nav-enemy-flags))) (let ((f0-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0))) ) (set! (-> self state-timeout) - (the-as - uint - (the - int - (+ - (lerp-scale 3000.0 0.0 f0-0 12288.0 122880.0) - (nav-enemy-rnd-float-range 0.0 900.0) - ) + (the + int + (+ + (lerp-scale 3000.0 0.0 f0-0 12288.0 122880.0) + (nav-enemy-rnd-float-range 0.0 900.0) ) ) ) ) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (set! (-> self collide-info transv quad) (-> *null-vector* quad)) (none) ) @@ -2119,10 +2094,7 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (logtest? (-> *target* state-flags) 128) @@ -2133,11 +2105,8 @@ nav-enemy-default-event-handler (if (and (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self notice-time)) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (-> self notice-time)) + (-> self reaction-time) ) (not (nav-enemy-frustrated?)) ) @@ -2177,11 +2146,8 @@ nav-enemy-default-event-handler (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) (go-virtual nav-enemy-give-up) ) @@ -2198,7 +2164,7 @@ nav-enemy-default-event-handler ) ) ) - (nonzero? (logand #x20000 (-> self nav flags))) + (logtest? #x20000 (-> self nav flags)) ) (go-virtual nav-enemy-give-up) ) @@ -2224,7 +2190,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (nav-enemy-neck-control-inactive) (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (none) @@ -2233,10 +2202,7 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (TODO-RENAME-46 self (-> self nav-info notice-distance)) @@ -2362,16 +2328,7 @@ nav-enemy-default-event-handler (set! (-> a1-0 from) self) (set! (-> a1-0 num-params) 0) (set! (-> a1-0 message) 'child-die) - (let ((t9-0 send-event-function) - (v1-1 (-> self parent)) - ) - (t9-0 (the-as process (if v1-1 - (-> v1-1 0 self) - ) - ) - a1-0 - ) - ) + (send-event-function (ppointer->process (-> self parent)) a1-0) ) (none) ) @@ -2455,13 +2412,16 @@ nav-enemy-default-event-handler (-> self collide-info) (-> self jump-dest) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (when (logtest? (-> self nav-enemy-flags) 8) (let ((f30-0 - (the float (- (-> *display* base-frame-counter) (-> self jump-time))) + (the + float + (- (-> *display* base-frame-counter) (the-as int (-> self jump-time))) + ) ) ) (let @@ -2529,7 +2489,7 @@ nav-enemy-default-event-handler (logior! (-> self nav-enemy-flags) 1024) ) ) - (when (and arg1 (nonzero? (logand (-> self nav-enemy-flags) 1024))) + (when (and arg1 (logtest? (-> self nav-enemy-flags) 1024)) (set! (-> self nav-enemy-flags) (logand -513 (-> self nav-enemy-flags))) (set! f30-0 2048.0) ) @@ -2608,7 +2568,7 @@ nav-enemy-default-event-handler ) ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status))) - (set! (-> self jump-time) (-> *display* base-frame-counter)) + (set! (-> self jump-time) (the-as uint (-> *display* base-frame-counter))) (logior! (-> self nav-enemy-flags) 8) (cond ((logtest? (-> self nav-enemy-flags) 1024) @@ -2669,7 +2629,10 @@ nav-enemy-default-event-handler ) (while (< - (the float (- (-> *display* base-frame-counter) (-> self jump-time))) + (the + float + (- (-> *display* base-frame-counter) (the-as int (-> self jump-time))) + ) (-> self jump-trajectory time) ) (suspend) @@ -2785,7 +2748,10 @@ nav-enemy-default-event-handler nav-enemy-jump-event-handler :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (if (and (-> self nav-info use-jump-blocked) @@ -2850,19 +2816,19 @@ nav-enemy-default-event-handler (if (or (logtest? (-> self nav-enemy-flags) 128) - (nonzero? (logand #x80000 (-> self nav flags))) + (logtest? #x80000 (-> self nav flags)) ) (seek-to-point-toward-point! (-> self collide-info) (-> self nav target-pos) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (seek-toward-heading-vec! (-> self collide-info) (-> self nav travel) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (vector-v++! @@ -2892,7 +2858,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (logclear! (-> self nav flags) (nav-control-flags bit19)) (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self collide-info transv quad)) @@ -2909,13 +2878,10 @@ nav-enemy-default-event-handler (if (or (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 150 ) - (nonzero? (logand #x80000 (-> self nav flags))) + (logtest? #x80000 (-> self nav flags)) ) (go-virtual nav-enemy-chase) ) @@ -2941,17 +2907,17 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (none) ) :trans (behavior () (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 150 ) (go (-> self jump-return-state)) @@ -3023,7 +2989,10 @@ nav-enemy-default-event-handler ) :code (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (logior! (-> self nav-enemy-flags) 2048) (ja-channel-push! 1 30) (let ((f30-0 (nav-enemy-rnd-float-range 0.8 1.2))) @@ -3056,7 +3025,7 @@ nav-enemy-default-event-handler (let ((gp-0 (nav-enemy-rnd-int-range 0 150)) (s5-0 (-> *display* base-frame-counter)) ) - (until (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) + (until (>= (- (-> *display* base-frame-counter) s5-0) gp-0) (let ((a0-12 (-> self skel root-channel 0))) (set! (-> a0-12 param 0) f30-0) (joint-control-channel-group-eval! @@ -3093,7 +3062,10 @@ nav-enemy-default-event-handler ) :code (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (nav-enemy-initialize-jump (-> self event-param-point)) (nav-enemy-neck-control-look-at) (logior! (-> self nav-enemy-flags) 16) @@ -3183,7 +3155,7 @@ nav-enemy-default-event-handler (-> *FACT-bank* default-pill-inc) ) ) - (set! (-> obj reaction-time) (the-as uint (nav-enemy-rnd-int-range 30 240))) + (set! (-> obj reaction-time) (nav-enemy-rnd-int-range 30 240)) (set! (-> obj speed-scale) 1.0) (logior! (-> obj nav-enemy-flags) 4216) 0 @@ -3194,7 +3166,7 @@ nav-enemy-default-event-handler (defmethod TODO-RENAME-49 nav-enemy ((obj nav-enemy) (arg0 nav-enemy-info)) (set! (-> obj nav-info) arg0) (set! (-> obj rotate-speed) (-> obj nav-info walk-rotate-speed)) - (set! (-> obj turn-time) (the-as uint (-> obj nav-info walk-turn-time))) + (set! (-> obj turn-time) (the-as int (-> obj nav-info walk-turn-time))) (when (and (!= (-> obj nav-info neck-joint) -1) (zero? (-> obj neck))) (set! (-> obj neck) diff --git a/goal_src/levels/common/rigid-body.gc b/goal_src/levels/common/rigid-body.gc index e14f46d770..55a9d9185e 100644 --- a/goal_src/levels/common/rigid-body.gc +++ b/goal_src/levels/common/rigid-body.gc @@ -454,7 +454,7 @@ (sim-time-remaining float :offset-assert 688) (float-height-offset float :offset-assert 692) (player-attack-id int32 :offset-assert 696) - (player-bonk-timeout uint64 :offset-assert 704) + (player-bonk-timeout int64 :offset-assert 704) (water-anim water-anim :offset-assert 712) (player-contact basic :offset-assert 716) (player-impulse collide-shape-prim-mesh :offset-assert 720) @@ -739,10 +739,7 @@ (('bonk) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) - ) + (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) (the-as int (-> self info player-force-timeout)) ) (set! (-> self player-bonk-timeout) (-> *display* base-frame-counter)) @@ -791,12 +788,9 @@ ((= (-> arg3 param 1) 'flop) (when (>= - (the-as - int - (- - (-> *display* base-frame-counter) - (-> self player-bonk-timeout) - ) + (- + (-> *display* base-frame-counter) + (-> self player-bonk-timeout) ) (the-as int (-> self info player-force-timeout)) ) diff --git a/goal_src/levels/common/ticky.gc b/goal_src/levels/common/ticky.gc index 3c6a87b5f0..3d01fc26c5 100644 --- a/goal_src/levels/common/ticky.gc +++ b/goal_src/levels/common/ticky.gc @@ -7,10 +7,10 @@ ;; definition of type ticky (deftype ticky (structure) - ((delay-til-ramp uint64 :offset-assert 0) - (delay-til-timeout uint64 :offset-assert 8) - (starting-time uint64 :offset-assert 16) - (last-tick-time uint64 :offset-assert 24) + ((delay-til-ramp int64 :offset-assert 0) + (delay-til-timeout int64 :offset-assert 8) + (starting-time int64 :offset-assert 16) + (last-tick-time int64 :offset-assert 24) ) :method-count-assert 12 :size-assert #x20 @@ -21,14 +21,16 @@ (completed? (_type_) symbol 11) ) ) - ;; definition for method 9 of type ticky ;; INFO: Return type mismatch int vs none. (defmethod sleep ticky ((obj ticky) (arg0 uint)) (set! (-> obj starting-time) (-> *display* base-frame-counter)) - (set! (-> obj delay-til-timeout) arg0) - (set! (-> obj delay-til-ramp) (max 0 (the-as int (+ arg0 -1200)))) - (set! (-> obj last-tick-time) (the-as uint 0)) + (set! (-> obj delay-til-timeout) (the-as int arg0)) + (set! + (-> obj delay-til-ramp) + (the-as int (max 0 (the-as int (+ arg0 -1200)))) + ) + (set! (-> obj last-tick-time) 0) 0 (none) ) @@ -38,7 +40,7 @@ (let ((gp-0 #f)) (let ((v1-2 (- (-> *display* base-frame-counter) (-> obj starting-time)))) (cond - ((>= (the-as int v1-2) (the-as int (-> obj delay-til-timeout))) + ((>= v1-2 (-> obj delay-til-timeout)) (set! gp-0 #t) ) (else @@ -47,7 +49,7 @@ (fmin 1.0 (/ - (the float (max 0 (the-as int (- v1-2 (-> obj delay-til-ramp))))) + (the float (max 0 (- v1-2 (-> obj delay-til-ramp)))) (the float (- (-> obj delay-til-timeout) (-> obj delay-til-ramp))) ) ) @@ -55,13 +57,7 @@ (v1-7 (the int (lerp 105.0 41.0 f0-1))) ) (when - (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> obj last-tick-time)) - ) - v1-7 - ) + (>= (- (-> *display* base-frame-counter) (-> obj last-tick-time)) v1-7) (set! (-> obj last-tick-time) (-> *display* base-frame-counter)) (sound-play-by-name (static-sound-name "stopwatch") @@ -84,7 +80,7 @@ ;; definition for method 10 of type ticky (defmethod reached-delay? ticky ((obj ticky) (arg0 uint)) (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj starting-time))) + (- (-> *display* base-frame-counter) (-> obj starting-time)) (the-as int arg0) ) - ) + ) \ No newline at end of file diff --git a/goal_src/levels/misty/misty-warehouse.gc b/goal_src/levels/misty/misty-warehouse.gc index 7bd725c2cc..4e87e87313 100644 --- a/goal_src/levels/misty/misty-warehouse.gc +++ b/goal_src/levels/misty/misty-warehouse.gc @@ -104,11 +104,7 @@ ) (camera-change-to "camera-160" 150 #f) (let ((gp-0 (-> *display* base-frame-counter))) - (until - (>= - (the-as int (- (-> *display* base-frame-counter) gp-0)) - 900 - ) + (until (>= (- (-> *display* base-frame-counter) gp-0) 900) (suspend) ) ) @@ -144,9 +140,12 @@ ) (save-reminder gp-0 (logior v1-1 2) 0) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (let ((gp-1 (-> *display* base-frame-counter))) - (until (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) + (until (>= (- (-> *display* base-frame-counter) gp-1) 300) (suspend) ) ) @@ -286,9 +285,7 @@ (if (and (-> obj entity) - (nonzero? - (logand (-> obj entity extra perm status) (entity-perm-status complete)) - ) + (logtest? (-> obj entity extra perm status) (entity-perm-status complete)) ) (go silostep-rise #t) (go silostep-idle) diff --git a/goal_src/levels/village1/explorer.gc b/goal_src/levels/village1/explorer.gc index f67ba8cc87..c81ba8b993 100644 --- a/goal_src/levels/village1/explorer.gc +++ b/goal_src/levels/village1/explorer.gc @@ -62,7 +62,7 @@ ((and (-> obj draw shadow) (zero? (-> obj draw cur-lod)) - (nonzero? (logand (-> obj draw status) 8)) + (logtest? (-> obj draw status) 8) ) (let ((v1-9 (-> obj draw shadow-ctrl))) (set! (-> v1-9 settings flags) (logand -33 (-> v1-9 settings flags))) @@ -432,20 +432,14 @@ (v1-69 (the-as number (logior #x3f800000 v1-68))) ) (< - (the-as - int - (- - s5-0 - (the-as - uint - (the - int - (* f30-1 (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-69))))) - ) - ) + (- + s5-0 + (the + int + (* f30-1 (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-69))))) ) ) - (the-as int gp-1) + gp-1 ) ) (suspend) @@ -512,23 +506,17 @@ (v1-105 (the-as number (logior #x3f800000 v1-104))) ) (< - (the-as - int - (- - s5-1 - (the-as - uint - (the - int - (* - f30-2 - (+ f28-1 (* f26-1 (+ -1.0 (the-as float v1-105)))) - ) - ) + (- + s5-1 + (the + int + (* + f30-2 + (+ f28-1 (* f26-1 (+ -1.0 (the-as float v1-105)))) ) ) ) - (the-as int gp-2) + gp-2 ) ) (suspend) @@ -642,23 +630,17 @@ (v1-165 (the-as number (logior #x3f800000 v1-164))) ) (< - (the-as - int - (- - s5-2 - (the-as - uint - (the - int - (* - f30-3 - (+ f28-2 (* f26-2 (+ -1.0 (the-as float v1-165)))) - ) - ) + (- + s5-2 + (the + int + (* + f30-3 + (+ f28-2 (* f26-2 (+ -1.0 (the-as float v1-165)))) ) ) ) - (the-as int gp-3) + gp-3 ) ) (suspend) @@ -806,23 +788,14 @@ (v1-238 (the-as number (logior #x3f800000 v1-237))) ) (< - (the-as - int - (- - s5-3 - (the-as - uint - (the - int - (* - f30-4 - (+ f28-3 (* f26-3 (+ -1.0 (the-as float v1-238)))) - ) - ) - ) + (- + s5-3 + (the + int + (* f30-4 (+ f28-3 (* f26-3 (+ -1.0 (the-as float v1-238))))) ) ) - (the-as int gp-4) + gp-4 ) ) (suspend) @@ -882,23 +855,14 @@ (v1-269 (the-as number (logior #x3f800000 v1-268))) ) (< - (the-as - int - (- - s5-4 - (the-as - uint - (the - int - (* - f30-5 - (+ f28-4 (* f26-4 (+ -1.0 (the-as float v1-269)))) - ) - ) - ) + (- + s5-4 + (the + int + (* f30-5 (+ f28-4 (* f26-4 (+ -1.0 (the-as float v1-269))))) ) ) - (the-as int gp-5) + gp-5 ) ) (suspend) @@ -955,23 +919,14 @@ (v1-302 (the-as number (logior #x3f800000 v1-301))) ) (< - (the-as - int - (- - s5-5 - (the-as - uint - (the - int - (* - f30-6 - (+ f28-5 (* f26-5 (+ -1.0 (the-as float v1-302)))) - ) - ) - ) + (- + s5-5 + (the + int + (* f30-6 (+ f28-5 (* f26-5 (+ -1.0 (the-as float v1-302))))) ) ) - (the-as int gp-6) + gp-6 ) ) (suspend) @@ -1036,4 +991,4 @@ (set! (-> obj draw light-index) (the-as uint 5)) (dummy-42 obj) (none) - ) + ) \ No newline at end of file diff --git a/goal_src/levels/village1/sage.gc b/goal_src/levels/village1/sage.gc index 842a7d1c77..53fe477eb6 100644 --- a/goal_src/levels/village1/sage.gc +++ b/goal_src/levels/village1/sage.gc @@ -626,34 +626,37 @@ (set-setting! *setting-control* pp 'music-volume-movie 'abs 0.0 0) (copy-settings-from-target! *setting-control*) (close-status! (-> obj tasks) (task-status need-reward-speech)) - (let* ((s5-2 (get-process *default-dead-pool* manipy #x4000)) - (v1-41 (when s5-2 - (let ((t9-15 (method-of-type manipy activate))) - (t9-15 - (the-as manipy s5-2) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-2 - manipy-init - (-> obj root trans) - (-> obj entity) - *assistant-sg* - #f - ) - (-> s5-2 ppointer) - ) - ) - ) - (set! - (-> obj assistant) - (new 'static 'handle :process v1-41 :pid (-> v1-41 0 pid)) + (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj assistant) (ppointer->handle (when s5-2 + (let + ((t9-15 + (method-of-type + manipy + activate + ) + ) + ) + (t9-15 + (the-as manipy s5-2) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-2 + manipy-init + (-> obj root trans) + (-> obj entity) + *assistant-sg* + #f + ) + (-> s5-2 ppointer) + ) + ) ) ) (let ((a1-16 (new 'stack-no-clear 'event-message-block))) @@ -1390,4 +1393,4 @@ (set! (-> obj draw light-index) (the-as uint 1)) (dummy-42 obj) (none) - ) + ) \ No newline at end of file diff --git a/goal_src/levels/village_common/oracle.gc b/goal_src/levels/village_common/oracle.gc index 02375c5749..3c4feba16f 100644 --- a/goal_src/levels/village_common/oracle.gc +++ b/goal_src/levels/village_common/oracle.gc @@ -659,17 +659,24 @@ gp-0 ) ) + (a1-1 (if v1-1 + (-> + (the-as + collide-shape + v1-1 + ) + root-prim + prim-core + ) + (-> self root trans) + ) + ) ) - (if v1-1 - (-> - (the-as collide-shape v1-1) - root-prim - prim-core - ) - (-> self root trans) + (dummy-11 + (-> self part) + (the-as vector a1-1) ) ) - ((method-of-object (-> self part) dummy-11)) 0 (none) ) @@ -684,34 +691,42 @@ ) ) (vector<-cspace! s4-0 (-> obj node-list data 5)) - (let* ((s3-0 (get-process *default-dead-pool* manipy #x4000)) - (v1-13 (when s3-0 - (let ((t9-8 (method-of-type manipy activate))) - (t9-8 - (the-as manipy s3-0) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s3-0 - manipy-init - s4-0 - (-> obj entity) - *fuel-cell-sg* - (new 'static 'vector :w 4915.2) - ) - (-> s3-0 ppointer) - ) - ) - ) - (set! - (-> obj right-eye-cell) - (new 'static 'handle :process v1-13 :pid (-> v1-13 0 pid)) + (let ((s3-0 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj right-eye-cell) (ppointer->handle (when s3-0 + (let + ((t9-8 + (method-of-type + manipy + activate + ) + ) + ) + (t9-8 + (the-as manipy s3-0) + obj + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s3-0 + manipy-init + s4-0 + (-> obj entity) + *fuel-cell-sg* + (new 'static 'vector + :w 4915.2 + ) + ) + (-> s3-0 ppointer) + ) + ) ) ) (let ((a1-9 (new 'stack-no-clear 'event-message-block))) @@ -724,8 +739,8 @@ uint (lambda :behavior oracle () - (let ((v0-0 (dummy-9 (-> *part-group-id-table* 63) self))) - (set! (-> self part) (the-as sparticle-launch-control v0-0)) + (let ((v0-0 (create-launch-control (-> *part-group-id-table* 63) self))) + (set! (-> self part) v0-0) v0-0 ) ) @@ -749,34 +764,42 @@ ) ) (vector<-cspace! s4-0 (-> obj node-list data 6)) - (let* ((s3-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-33 (when s3-1 - (let ((t9-15 (method-of-type manipy activate))) - (t9-15 - (the-as manipy s3-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s3-1 - manipy-init - s4-0 - (-> obj entity) - *fuel-cell-sg* - (new 'static 'vector :w 4915.2) - ) - (-> s3-1 ppointer) - ) - ) - ) - (set! - (-> obj left-eye-cell) - (new 'static 'handle :process v1-33 :pid (-> v1-33 0 pid)) + (let ((s3-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj left-eye-cell) (ppointer->handle (when s3-1 + (let + ((t9-15 + (method-of-type + manipy + activate + ) + ) + ) + (t9-15 + (the-as manipy s3-1) + obj + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s3-1 + manipy-init + s4-0 + (-> obj entity) + *fuel-cell-sg* + (new 'static 'vector + :w 4915.2 + ) + ) + (-> s3-1 ppointer) + ) + ) ) ) (let ((a1-16 (new 'stack-no-clear 'event-message-block))) @@ -789,8 +812,8 @@ uint (lambda :behavior oracle () - (let ((v0-0 (dummy-9 (-> *part-group-id-table* 63) self))) - (set! (-> self part) (the-as sparticle-launch-control v0-0)) + (let ((v0-0 (create-launch-control (-> *part-group-id-table* 63) self))) + (set! (-> self part) v0-0) v0-0 ) ) @@ -810,4 +833,4 @@ (dummy-42 obj) (none) ) - ) + ) \ No newline at end of file diff --git a/goalc/compiler/compilation/Asm.cpp b/goalc/compiler/compilation/Asm.cpp index 10e2b117de..4ca2d27481 100644 --- a/goalc/compiler/compilation/Asm.cpp +++ b/goalc/compiler/compilation/Asm.cpp @@ -126,6 +126,10 @@ Val* Compiler::compile_rlet(const goos::Object& form, const goos::Object& rest, lenv->emit_ir(reset_regs); } + for (auto c : constraints) { + fenv->constrain(c); + } + Val* result = get_none(); for (u64 i = 1; i < args.unnamed.size(); i++) { auto& o = args.unnamed.at(i); @@ -135,10 +139,6 @@ Val* Compiler::compile_rlet(const goos::Object& form, const goos::Object& rest, } } - for (auto c : constraints) { - fenv->constrain(c); - } - return result; } diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index fa37d4617d..dc510d6820 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -685,7 +685,7 @@ Val* Compiler::compile_deref(const goos::Object& form, const goos::Object& _rest while (!rest->is_empty_list()) { auto field_obj = pair_car(*rest); rest = &pair_cdr(*rest); - auto type_info = m_ts.lookup_type(result->type()); + auto type_info = m_ts.lookup_type_allow_partial_def(result->type()); // attempt to treat it as a field. May not succeed if we're actually an array. if (field_obj.is_symbol()) { diff --git a/test/decompiler/reference/decompiler-macros.gc b/test/decompiler/reference/decompiler-macros.gc index 78e04ddb15..d0fd7ac954 100644 --- a/test/decompiler/reference/decompiler-macros.gc +++ b/test/decompiler/reference/decompiler-macros.gc @@ -94,15 +94,45 @@ (defmacro handle->process (handle) ;; the actual implementation is more clever than this. ;; Checks PID. - `(if (-> ,handle process) - (let ((proc (-> (-> ,handle process)))) - (if (= (-> ,handle pid) (-> proc pid)) - proc - ) + `(let ((the-handle ,handle)) + (if (-> the-handle process) + (let ((proc (-> (-> the-handle process)))) + (if (= (-> the-handle pid) (-> proc pid)) + proc + ) + ) ) - ) + ) ) +(defmacro ppointer->process (ppointer) + ;; convert a (pointer process) to a process. + ;; this uses the self field, which seems to always just get set to the object. + ;; perhaps when deleting a process you could have it set self to #f? + ;; I don't see this happen anywhere though, so it's not clear. + `(let ((the-pp ,ppointer)) + (the process (if the-pp (-> the-pp 0 self))) + ) + ) + +(defmacro process->ppointer (proc) + ;"safely get a (pointer process) from a process, returning #f if invalid." + `(let ((the-proc ,proc)) + (if the-proc (-> the-proc ppointer)) + ) + ) + +(defmacro ppointer->handle (pproc) + `(let ((the-process ,pproc)) + (new 'static 'handle :process the-process :pid (-> the-process 0 pid)) + ) + ) + +(defmacro process->handle (proc) + `(ppointer->handle (process->ppointer ,proc)) + ) + + (defmacro defbehavior (name process-type bindings &rest body) (if (and (> (length body) 1) ;; more than one thing in function diff --git a/test/decompiler/reference/engine/ambient/mood_REF.gc b/test/decompiler/reference/engine/ambient/mood_REF.gc index 5f2eb44349..62327dbc8c 100644 --- a/test/decompiler/reference/engine/ambient/mood_REF.gc +++ b/test/decompiler/reference/engine/ambient/mood_REF.gc @@ -1953,10 +1953,7 @@ (* 0.0625 (cos - (the - float - (* 4000 (the-as int (-> *display* integral-frame-counter))) - ) + (the float (* 4000 (-> *display* integral-frame-counter))) ) ) ) @@ -1967,12 +1964,7 @@ ) (* 0.125 - (cos - (the - float - (* 1500 (the-as int (-> *display* integral-frame-counter))) - ) - ) + (cos (the float (* 1500 (-> *display* integral-frame-counter)))) ) ) ) @@ -3298,11 +3290,11 @@ (when (and *target* (= (-> *target* next-state name) 'target-continue)) (set! (-> (the-as (pointer int64) s4-0) 0) - (the-as int (+ (-> *display* base-frame-counter) -10000)) + (+ (-> *display* base-frame-counter) -10000) ) (set! (-> (the-as (pointer int64) s4-0) 1) - (the-as int (+ (-> *display* base-frame-counter) -10000)) + (+ (-> *display* base-frame-counter) -10000) ) ) (update-mood-fog arg0 arg1) @@ -3376,7 +3368,7 @@ float (- (-> *display* base-frame-counter) - (the-as uint (-> (the-as (pointer int64) s4-0) 1)) + (-> (the-as (pointer int64) s4-0) 1) ) ) ) @@ -3419,7 +3411,7 @@ (else (set! (-> (the-as (pointer int64) s4-0) 1) - (the-as int (-> *display* base-frame-counter)) + (-> *display* base-frame-counter) ) ) ) @@ -3431,7 +3423,7 @@ float (- (-> *display* base-frame-counter) - (the-as uint (-> (the-as (pointer int64) s4-0) 0)) + (-> (the-as (pointer int64) s4-0) 0) ) ) ) @@ -3465,7 +3457,7 @@ (set! (-> *time-of-day-proc* 0 frame) 0) (set! (-> (the-as (pointer int64) s4-0) 0) - (the-as int (-> *display* base-frame-counter)) + (-> *display* base-frame-counter) ) (dotimes (v1-72 8) (set! (-> arg0 sky-times v1-72) 0.0) @@ -3665,13 +3657,7 @@ (* 0.125 (cos - (the - float - (* - 4000 - (the-as int (-> *display* integral-frame-counter)) - ) - ) + (the float (* 4000 (-> *display* integral-frame-counter))) ) ) ) @@ -3685,10 +3671,7 @@ (* 0.25 (cos - (the - float - (* 1500 (the-as int (-> *display* integral-frame-counter))) - ) + (the float (* 1500 (-> *display* integral-frame-counter))) ) ) ) diff --git a/test/decompiler/reference/engine/camera/cam-start_REF.gc b/test/decompiler/reference/engine/camera/cam-start_REF.gc index e174bf86c6..ddddf0de4f 100644 --- a/test/decompiler/reference/engine/camera/cam-start_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-start_REF.gc @@ -35,26 +35,44 @@ (-> s5-0 ppointer) ) ) - (let* ((s5-1 (get-process *camera-master-dead-pool* camera-master #x4000)) - (v1-5 (when s5-1 - (let ((t9-5 (method-of-type camera-master activate))) - (t9-5 - (the-as camera-master s5-1) - *camera-pool* - 'camera-master - (the-as pointer #x70004000) - ) - ) - ((the-as (function process object function) set-to-run) - (the-as process (-> s5-1 main-thread)) - cam-master-init - ) - (-> s5-1 ppointer) - ) - ) - ) - (set! *camera* (the-as camera-master (if v1-5 - (-> v1-5 0 self) + (let ((s5-1 (get-process *camera-master-dead-pool* camera-master #x4000))) + (set! *camera* (the-as camera-master (ppointer->process (when s5-1 + (let + ((t9-5 + (method-of-type + camera-master + activate + ) + ) + ) + (t9-5 + (the-as + camera-master + s5-1 + ) + *camera-pool* + 'camera-master + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process object function) + set-to-run + ) + (the-as + process + (-> + s5-1 + main-thread + ) + ) + cam-master-init + ) + (-> s5-1 ppointer) + ) ) ) ) @@ -68,7 +86,3 @@ ;; failed to figure out what this is: (cam-start #f) - - - - diff --git a/test/decompiler/reference/engine/collide/collide-target-h_REF.gc b/test/decompiler/reference/engine/collide/collide-target-h_REF.gc index e52de0bdb5..902bfa2796 100644 --- a/test/decompiler/reference/engine/collide/collide-target-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-target-h_REF.gc @@ -9,7 +9,7 @@ (transv-out vector :inline :offset-assert 48) (local-normal vector :inline :offset-assert 64) (surface-normal vector :inline :offset-assert 80) - (time uint64 :offset-assert 96) + (time int64 :offset-assert 96) (status uint64 :offset-assert 104) (pat pat-surface :offset-assert 112) (reaction-flag uint32 :offset-assert 116) diff --git a/test/decompiler/reference/engine/engine/connect_REF.gc b/test/decompiler/reference/engine/engine/connect_REF.gc index 72b03acde6..b51f681289 100644 --- a/test/decompiler/reference/engine/engine/connect_REF.gc +++ b/test/decompiler/reference/engine/engine/connect_REF.gc @@ -63,7 +63,7 @@ ((name basic :offset-assert 4) (length int16 :offset-assert 8) (allocated-length int16 :offset-assert 10) - (engine-time uint64 :offset-assert 16) + (engine-time int64 :offset-assert 16) (alive-list connectable :inline :offset-assert 32) (alive-list-end connectable :inline :offset-assert 48) (dead-list connectable :inline :offset-assert 64) diff --git a/test/decompiler/reference/engine/game/fact-h_REF.gc b/test/decompiler/reference/engine/game/fact-h_REF.gc index 7bf5d72900..bc396e1b47 100644 --- a/test/decompiler/reference/engine/game/fact-h_REF.gc +++ b/test/decompiler/reference/engine/game/fact-h_REF.gc @@ -107,21 +107,21 @@ ;; definition of type fact-info (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 uint64 :offset-assert 24) - (fade-time uint64 :offset-assert 32) + ((process process-drawable :offset-assert 4) + (pickup-type pickup-type :offset-assert 8) + (pickup-amount float :offset-assert 12) + (pickup-spawn-amount float :offset-assert 16) + (options uint64 :offset-assert 24) + (fade-time uint64 :offset-assert 32) ) :method-count-assert 12 :size-assert #x28 :flag-assert #xc00000028 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) (TODO-RENAME-9 (_type_ symbol process-tree fact-info int) uint 9) (reset! (_type_ symbol) none 10) - (dummy-11 (_type_) float 11) + (pickup-collectable! (_type_ pickup-type float handle) float 11) ) ) @@ -150,7 +150,7 @@ (eco-pill float :offset-assert 80) (eco-pill-max float :offset-assert 84) (health-pickup-time uint64 :offset-assert 88) - (eco-source uint64 :offset-assert 96) + (eco-source handle :offset-assert 96) (eco-source-time uint64 :offset-assert 104) (money-pickup-time uint64 :offset-assert 112) (buzzer-pickup-time uint64 :offset-assert 120) @@ -161,7 +161,7 @@ :size-assert #x90 :flag-assert #xc00000090 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) @@ -208,7 +208,7 @@ :size-assert #x44 :flag-assert #xc00000044 (:methods - (new (symbol type process pickup-type float) _type_ 0) + (new (symbol type process-drawable pickup-type float) _type_ 0) ) ) @@ -238,7 +238,7 @@ fact-info ((allocation symbol) (type-to-make type) - (proc process) + (proc process-drawable) (pkup-type pickup-type) (pkup-amount float) ) @@ -343,7 +343,10 @@ ) ;; definition for method 11 of type fact-info -(defmethod dummy-11 fact-info ((obj fact-info)) +(defmethod + pickup-collectable! + fact-info + ((obj fact-info) (arg0 pickup-type) (arg1 float) (arg2 handle)) 0.0 ) @@ -353,7 +356,7 @@ fact-info-enemy ((allocation symbol) (type-to-make type) - (arg0 process) + (arg0 process-drawable) (arg1 pickup-type) (arg2 float) ) @@ -482,7 +485,7 @@ fact-info-target ((allocation symbol) (type-to-make type) - (arg0 process) + (arg0 process-drawable) (arg1 pickup-type) (arg2 float) ) @@ -494,7 +497,7 @@ ) ) ) - (set! (-> obj eco-source) (the-as uint #f)) + (set! (-> obj eco-source) (the-as handle #f)) (reset! obj #f) obj ) diff --git a/test/decompiler/reference/engine/game/game-info-h_REF.gc b/test/decompiler/reference/engine/game/game-info-h_REF.gc index 44acc24d35..d2e1b1386c 100644 --- a/test/decompiler/reference/engine/game/game-info-h_REF.gc +++ b/test/decompiler/reference/engine/game/game-info-h_REF.gc @@ -197,7 +197,7 @@ (death-movie-tick int32 :offset-assert 264) (want-auto-save symbol :offset-assert 268) (auto-save-proc handle :offset-assert 272) - (auto-save-status uint32 :offset-assert 280) + (auto-save-status mc-status-code :offset-assert 280) (auto-save-card int32 :offset-assert 284) (auto-save-which int32 :offset-assert 288) (pov-camera-handle handle :offset-assert 296) @@ -225,7 +225,7 @@ (seen-text? (_type_ game-text-id) symbol 21) (mark-text-as-seen (_type_ game-text-id) none 22) (got-buzzer? (_type_ game-task int) symbol 23) - (dummy-24 () none 24) + (save-game! (_type_ game-save string) none 24) (load-game! (_type_ game-save) game-save 25) (clear-text-seen! (_type_ game-text-id) none 26) (get-death-count (_type_ symbol) int 27) diff --git a/test/decompiler/reference/engine/game/game-info_REF.gc b/test/decompiler/reference/engine/game/game-info_REF.gc new file mode 100644 index 0000000000..a576827d5e --- /dev/null +++ b/test/decompiler/reference/engine/game/game-info_REF.gc @@ -0,0 +1,1718 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 9 of type border-plane +;; INFO: Return type mismatch int vs none. +(defmethod debug-draw! border-plane ((obj border-plane)) + (let* ((v1-0 (-> obj action)) + (s5-0 (if (= v1-0 'load) + (new 'static 'rgba :g #xff :a #x80) + (new 'static 'rgba :r #xff :a #x80) + ) + ) + ) + (add-debug-text-sphere + #t + (bucket-id debug-draw1) + (-> obj trans) + 819.2 + (symbol->string (-> obj name)) + s5-0 + ) + (add-debug-vector + #t + (bucket-id debug-draw1) + (-> obj trans) + (-> obj normal) + (meters 2.0) + s5-0 + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type border-plane +(defmethod point-past-plane? border-plane ((obj border-plane) (arg0 vector)) + (>= + (vector-dot + (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) + (-> obj normal) + ) + 0.0 + ) + ) + +;; definition for method 11 of type game-info +(defmethod task-complete? game-info ((obj game-info) (arg0 game-task)) + (logtest? + (-> obj task-perm-list data arg0 status) + (entity-perm-status real-complete) + ) + ) + +;; definition for symbol *default-continue*, type continue-point +(define + *default-continue* + (new 'static 'continue-point + :name "default" + :level #f + :trans (new 'static 'vector :w 1.0) + :quat (new 'static 'quaternion :w 1.0) + :camera-trans (new 'static 'vector :w 1.0) + :load-commands '() + :vis-nick #f + :lev0 #f + :disp0 #f + :lev1 #f + :disp1 #f + ) + ) + +;; definition for method 17 of type game-info +(defmethod get-or-create-continue! game-info ((obj game-info)) + (cond + ((and (= (-> obj mode) 'play) (-> obj current-continue)) + (-> obj current-continue) + ) + (else + (let ((gp-0 *default-continue*)) + (position-in-front-of-camera! (-> gp-0 trans) 40960.0 4096.0) + (quaternion-identity! (-> gp-0 quat)) + (set! (-> gp-0 vis-nick) (-> *load-state* vis-nick)) + (set! (-> gp-0 lev0) (-> *load-state* want 0 name)) + (set! (-> gp-0 disp0) (-> *load-state* want 0 display?)) + (set! (-> gp-0 lev1) (-> *load-state* want 1 name)) + (set! (-> gp-0 disp1) (-> *load-state* want 1 display?)) + gp-0 + ) + ) + ) + ) + +;; definition for method 18 of type game-info +;; INFO: Return type mismatch object vs continue-point. +(defmethod get-continue-by-name game-info ((obj game-info) (arg0 string)) + (let ((s5-0 *level-load-list*)) + (while (not (null? s5-0)) + (let + ((s4-0 + (-> + (the-as level-load-info (-> (the-as symbol (car s5-0)) value)) + continues + ) + ) + ) + (while (not (null? s4-0)) + (let ((s3-0 (car s4-0))) + (if (string= arg0 (-> (the-as continue-point s3-0) name)) + (return (the-as continue-point s3-0)) + ) + ) + (set! s4-0 (cdr s4-0)) + ) + ) + (set! s5-0 (cdr s5-0)) + ) + ) + (the-as continue-point #f) + ) + +;; definition for method 19 of type game-info +(defmethod set-continue! game-info ((obj game-info) (arg0 basic)) + (let ((s5-0 (-> obj current-continue))) + (if (null? arg0) + (set! arg0 #f) + ) + (case (-> arg0 type) + ((string) + (let ((v1-5 (get-continue-by-name obj (the-as string arg0)))) + (if v1-5 + (set! (-> obj current-continue) v1-5) + ) + ) + ) + ((continue-point) + (set! (-> obj current-continue) (the-as continue-point arg0)) + ) + (else + (let ((s4-3 *default-continue*)) + (position-in-front-of-camera! (-> s4-3 trans) 40960.0 4096.0) + (quaternion-identity! (-> s4-3 quat)) + (set! (-> s4-3 vis-nick) (-> *load-state* vis-nick)) + (set! (-> s4-3 lev0) (-> *load-state* want 0 name)) + (set! (-> s4-3 disp0) (-> *load-state* want 0 display?)) + (set! (-> s4-3 lev1) (-> *load-state* want 1 name)) + (set! (-> s4-3 disp1) (-> *load-state* want 1 display?)) + (set! (-> obj current-continue) s4-3) + ) + ) + ) + (when (!= s5-0 (-> obj current-continue)) + (set! (-> obj continue-deaths) 0) + (set! + (-> obj continue-time) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + ) + (-> obj current-continue) + ) + +;; definition for method 13 of type game-info +(defmethod get-entity-task-perm game-info ((obj game-info) (arg0 game-task)) + (-> obj task-perm-list data arg0) + ) + +;; definition for method 9 of type game-info +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? +;; Used lq/sq +(defmethod + initialize! + game-info + ((obj game-info) + (cause symbol) + (save-to-load game-save) + (continue-point-override string) + ) + (local-vars (v0-0 int) (sv-96 symbol)) + (with-pp + (case cause + (('dead) + (+! (-> obj total-deaths) 1) + (+! (-> obj continue-deaths) 1) + (+! (-> obj fuel-cell-deaths) 1) + (when *target* + (let ((lev-info (-> *target* current-level info))) + (set! + v0-0 + (when (>= (-> *level-task-data-remap* length) (-> lev-info index)) + (set! + v0-0 + (seekl + (the-as + int + (-> + obj + deaths-per-level + (-> *level-task-data-remap* (+ (-> lev-info index) -1)) + ) + ) + 255 + 1 + ) + ) + (set! + (-> + obj + deaths-per-level + (-> *level-task-data-remap* (+ (-> lev-info index) -1)) + ) + (the-as uint v0-0) + ) + v0-0 + ) + ) + ) + ) + (case (-> obj mode) + (('play) + (if (< 0.0 (-> obj life)) + (set! cause 'life) + (set! cause 'try) + ) + ) + (else + (set! obj obj) + (goto cfg-50) + ) + ) + ) + ) + (kill-current-level-hint '() '() 'die) + (case cause + (('game) + (reset-all-hint-controls) + (set-continue! obj (cond + (continue-point-override + (empty) + continue-point-override + ) + ((!= *kernel-boot-message* 'play) + "demo-start" + ) + (*debug-segment* + "village1-hut" + ) + (else + "title-start" + ) + ) + ) + (set! (-> obj auto-save-count) 0) + (set! (-> *setting-control* default auto-save) #f) + (set! (-> obj money) 0.0) + (set! (-> obj fuel) 0.0) + (set! (-> obj money-total) 0.0) + (set! (-> obj buzzer-total) 0.0) + (set! (-> obj perm-list length) 0) + (clear-all! (-> obj text-ids-seen)) + (set! (-> obj death-movie-tick) (rand-vu-int-count 10)) + (set! (-> obj total-deaths) 0) + (set! (-> obj continue-deaths) 0) + (set! (-> obj fuel-cell-deaths) 0) + (set! (-> obj death-pos length) 0) + (set! + (-> obj game-start-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! + (-> obj fuel-cell-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! + (-> obj continue-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! (-> obj death-time) (the-as uint (-> *display* base-frame-counter))) + (set! (-> obj hit-time) (the-as uint (-> *display* base-frame-counter))) + (dotimes (v1-50 116) + (set! (-> obj fuel-cell-time 0) (the-as uint 0)) + (nop!) + ) + (dotimes (v1-53 32) + (set! (-> obj money-per-level v1-53) (the-as uint 0)) + (set! (-> obj deaths-per-level v1-53) (the-as uint 0)) + (set! (-> obj enter-level-time v1-53) (the-as uint 0)) + (set! (-> obj in-level-time v1-53) (the-as uint 0)) + (set! (-> obj level-opened v1-53) (the-as uint 0)) + (nop!) + ) + ) + ) + (case cause + (('game 'try) + (case (-> obj mode) + (('play) + (set! *display-profile* #f) + (set! *display-entity-errors* #f) + ) + ) + (set! (-> obj life-max) (-> *GAME-bank* life-max-default)) + (set! (-> obj life) (-> *GAME-bank* life-start-default)) + ) + ) + (let ((v1-65 (-> obj mode))) + (cond + ((= v1-65 'debug) + (reset-actors cause) + (if save-to-load + (load-game! obj save-to-load) + ) + ) + ((= v1-65 'play) + (when *target* + (set-setting! *setting-control* *target* 'allow-pause #f 0.0 0) + (set-setting! *setting-control* *target* 'allow-progress #f 0.0 0) + (copy-settings-from-target! *setting-control*) + ) + (let ((a1-11 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-11 from) pp) + (set! (-> a1-11 num-params) 0) + (set! (-> a1-11 message) 'die) + (send-event-function + (handle->process (-> *game-info* auto-save-proc)) + a1-11 + ) + ) + (set! (-> *level* border?) #f) + (set! (-> *setting-control* default border-mode) #f) + (set! *spawn-actors* #f) + (set-blackout-frames 30) + (let ((a1-12 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-12 from) pp) + (set! (-> a1-12 num-params) 0) + (set! (-> a1-12 message) 'reset) + (send-event-function *target* a1-12) + ) + (let ((s3-1 (get-process *4k-dead-pool* process #x4000))) + (when s3-1 + (let ((t9-15 (method-of-type process activate))) + (t9-15 s3-1 *default-pool* 'process (the-as pointer #x70004000)) + ) + (let + ((s2-0 + (the-as + (function cpu-thread function object object object object pointer) + set-to-run + ) + ) + (s1-0 (-> s3-1 main-thread)) + (s0-0 + (lambda + ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 symbol)) + (stop arg0) + (reset-actors arg1) + (set-continue! *game-info* arg2) + (when arg3 + (load-game! *game-info* (the-as game-save arg3)) + (set! arg2 (get-or-create-continue! *game-info*)) + ) + (suspend) + (start arg0 arg2) + (none) + ) + ) + ) + (set! sv-96 (-> obj mode)) + (let ((t0-2 (get-or-create-continue! obj)) + (t1-2 save-to-load) + ) + (s2-0 s1-0 s0-0 sv-96 cause t0-2 t1-2) + ) + ) + (-> s3-1 ppointer) + ) + ) + (set-master-mode 'game) + ) + ) + ) + (label cfg-50) + obj + ) + ) + +;; definition for method 10 of type game-info +(defmethod + adjust + game-info + ((obj game-info) (item symbol) (amount float) (source handle)) + (case item + (('life) + (if (>= amount 0.0) + (set! (-> obj life) (seek (-> obj life) (-> obj life-max) amount)) + (set! (-> obj life) (seek (-> obj life) 0.0 (- amount))) + ) + (-> obj life) + ) + (('money) + (if + (and + (< 0.0 amount) + (= (+ (-> obj money) amount) (-> *GAME-bank* money-task-inc)) + ) + (level-hint-spawn + (game-text-id MISSING-orb-hint) + "sksp0014" + #f + *entity-pool* + 0 + ) + ) + (when (< 0.0 amount) + (let ((proc (handle->process source))) + (when (and proc (-> proc entity)) + (when + (>= + (-> *level-task-data-remap* length) + (-> proc entity extra level info index) + ) + (let + ((level-idx + (-> + *level-task-data-remap* + (+ (-> proc entity extra level info index) -1) + ) + ) + ) + (+! (-> obj money-per-level level-idx) (the int amount)) + (+! (-> obj money-total) amount) + (if + (= + (-> obj money-per-level level-idx) + (-> (get-game-count level-idx) money-count) + ) + (activate-orb-all level-idx) + ) + ) + ) + ) + ) + ) + (let ((f0-18 (+ (-> obj money) amount))) + (set! (-> obj money) f0-18) + f0-18 + ) + ) + (('fuel-cell) + (let ((s5-1 (the int amount))) + (when + (not + (or + (task-complete? obj (the-as game-task s5-1)) + (>= (the-as uint 1) (the-as uint s5-1)) + ) + ) + (set! (-> obj fuel-cell-deaths) 0) + (set! + (-> obj fuel-cell-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! + (-> obj fuel-cell-time s5-1) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! (-> obj fuel) (+ 1.0 (-> obj fuel))) + (logior! + (-> obj task-perm-list data s5-1 status) + (entity-perm-status real-complete) + ) + (get-task-control (the-as game-task s5-1)) + (close-specific-task! + (the-as game-task s5-1) + (task-status need-resolution) + ) + ) + ) + (-> obj fuel) + ) + (('buzzer) + (let ((buzz-task (logand (the int amount) #xffff)) + (buzz-index (sar (the int amount) 16)) + (buzz-count 0.0) + ) + (when (> (the-as uint buzz-task) 0) + (let* ((ctrl (get-task-control (the-as game-task buzz-task))) + (buzz-bits (get-reminder ctrl 0)) + ) + (when + (and + (>= buzz-index 0) + (< buzz-index (the int (-> *FACT-bank* buzzer-max-default))) + ) + (if (zero? (logand buzz-bits (ash 1 buzz-index))) + (set! (-> obj buzzer-total) (+ 1.0 (-> obj buzzer-total))) + ) + (let ((t9-10 (method-of-object ctrl save-reminder))) + (set! buzz-bits (logior buzz-bits (ash 1 buzz-index))) + (t9-10 ctrl buzz-bits 0) + ) + ) + (countdown (v1-58 (the int (-> *FACT-bank* buzzer-max-default))) + (if (logtest? buzz-bits (ash 1 v1-58)) + (set! buzz-count (+ 1.0 buzz-count)) + ) + ) + ) + ) + buzz-count + ) + ) + ) + ) + +;; definition for method 23 of type game-info +(defmethod got-buzzer? game-info ((obj game-info) (arg0 game-task) (arg1 int)) + (logtest? (get-reminder (get-task-control arg0) 0) (ash 1 arg1)) + ) + +;; definition for method 20 of type game-info +(defmethod buzzer-count game-info ((obj game-info) (arg0 game-task)) + (let ((v1-1 (get-reminder (get-task-control arg0) 0)) + (v0-2 0) + ) + (countdown (a0-4 (the int (-> *FACT-bank* buzzer-max-default))) + (if (logtest? v1-1 (ash 1 a0-4)) + (+! v0-2 1) + ) + ) + v0-2 + ) + ) + +;; definition for method 21 of type game-info +(defmethod seen-text? game-info ((obj game-info) (arg0 game-text-id)) + (get-bit (-> obj text-ids-seen) (the-as int arg0)) + ) + +;; definition for method 22 of type game-info +;; INFO: Return type mismatch int vs none. +(defmethod mark-text-as-seen game-info ((obj game-info) (arg0 game-text-id)) + (if (and (< (the-as uint arg0) (the-as uint 4095)) (> (the-as uint arg0) 0)) + (set-bit (-> obj text-ids-seen) (the-as int arg0)) + ) + 0 + (none) + ) + +;; definition for method 26 of type game-info +;; INFO: Return type mismatch int vs none. +(defmethod clear-text-seen! game-info ((obj game-info) (arg0 game-text-id)) + (clear-bit (-> obj text-ids-seen) (the-as int arg0)) + 0 + (none) + ) + +;; definition for method 10 of type fact-info-target +;; INFO: Return type mismatch float vs none. +(defmethod reset! fact-info-target ((obj fact-info-target) (arg0 symbol)) + (when (or (not arg0) (= arg0 'eco)) + (set! (-> obj eco-timeout) (the-as seconds 0)) + (set! (-> obj eco-level) 0.0) + (set! + (-> obj eco-pickup-time) + (the-as uint (-> *display* game-frame-counter)) + ) + ) + (when (or (not arg0) (= arg0 'health)) + (set! (-> obj health-max) (-> *FACT-bank* health-max-default)) + (set! (-> obj health) (-> obj health-max)) + (set! (-> obj health-pickup-time) (the-as uint -30000)) + ) + (when (or (not arg0) (= arg0 'buzzer)) + (set! (-> obj buzzer-max) (-> *FACT-bank* buzzer-max-default)) + (set! (-> obj buzzer) 0.0) + ) + (when (or (not arg0) (= arg0 'eco-pill)) + (set! (-> obj eco-pill-max) (-> *FACT-bank* eco-pill-max-default)) + (set! (-> obj eco-pill) 0.0) + ) + (none) + ) + +;; definition for method 11 of type fact-info-target +(defmethod + pickup-collectable! + fact-info-target + ((obj fact-info-target) + (kind pickup-type) + (amount float) + (source-handle handle) + ) + (with-pp + (case kind + (((pickup-type eco-green)) + (cond + ((>= amount 0.0) + (when (< 0.0 amount) + (if + (or + (!= + (handle->process source-handle) + (handle->process (-> obj eco-source)) + ) + (>= + (- + (-> *display* base-frame-counter) + (the-as int (-> obj eco-source-time)) + ) + 150 + ) + ) + (sound-play-by-name + (static-sound-name "get-green-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (when (handle->process source-handle) + (set! (-> obj eco-source) source-handle) + (set! + (-> obj eco-source-time) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + ) + (if (= (-> obj health) (-> obj health-max)) + (pickup-collectable! + obj + (pickup-type eco-pill) + (-> *FACT-bank* eco-pill-max-default) + (process->handle (-> obj process)) + ) + ) + (set! + (-> obj health-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! (-> obj health) (seek (-> obj health) (-> obj health-max) amount)) + ) + (else + (set! (-> obj health) (seek (-> obj health) 0.0 (- amount))) + (if (>= amount -10.0) + (pickup-collectable! obj (pickup-type eco-pill) 0.0 source-handle) + ) + (if (= (-> obj health) 0.0) + (adjust + (-> (the-as target (-> obj process)) game) + 'life + (- (-> *GAME-bank* life-single-inc)) + source-handle + ) + ) + ) + ) + (b! + (and + (logtest? + (-> + (the-as collide-shape (-> obj process root)) + root-prim + prim-core + action + ) + 512 + ) + (type-type? (-> (handle->process source-handle) type) vent) + ) + cfg-80 + :delay + (nop!) + ) + (-> obj health) + ) + (((pickup-type eco-pill)) + (when (>= amount 0.0) + (set! + (-> obj eco-pill-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (set! + (-> obj eco-pill) + (seek (-> obj eco-pill) (-> obj eco-pill-max) amount) + ) + (when + (and + (>= (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) + (< (-> obj health) (-> obj health-max)) + ) + (set! + (-> obj eco-pill) + (- (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) + ) + (pickup-collectable! + obj + (pickup-type eco-green) + (-> *FACT-bank* health-small-inc) + (process->handle (-> obj process)) + ) + ) + ) + (-> obj eco-pill) + ) + (((pickup-type money)) + (when (< 0.0 amount) + (if + (>= + (- + (-> *display* base-frame-counter) + (the-as int (-> obj money-pickup-time)) + ) + 15 + ) + (sound-play-by-name + (static-sound-name "money-pickup") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (set! + (-> obj money-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + (adjust + (-> (the-as target (-> obj process)) game) + 'money + amount + source-handle + ) + ) + (((pickup-type fuel-cell)) + (let ((s4-2 (the int amount))) + (if + (not + (or + (task-complete? + (-> (the-as target (-> obj process)) game) + (the-as game-task s4-2) + ) + (>= (the-as uint 1) (the-as uint s4-2)) + ) + ) + (set! + (-> obj fuel-cell-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + ) + (adjust + (-> (the-as target (-> obj process)) game) + 'fuel-cell + amount + source-handle + ) + ) + (((pickup-type buzzer)) + (let + ((buzz-count + (adjust + (-> (the-as target (-> obj process)) game) + 'buzzer + amount + source-handle + ) + ) + ) + (if (!= buzz-count (-> obj buzzer)) + (set! + (-> obj buzzer-pickup-time) + (the-as uint (-> *display* base-frame-counter)) + ) + ) + (set! (-> obj buzzer) buzz-count) + ) + (-> obj buzzer) + ) + (((pickup-type eco-red) (pickup-type eco-blue) (pickup-type eco-yellow)) + (label cfg-80) + (if (= amount 0.0) + (return (if (= (-> obj eco-type) kind) + (-> obj eco-level) + 0.0 + ) + ) + ) + (when (!= (-> obj eco-type) kind) + (set! (-> obj eco-level) 0.0) + (set! (-> obj eco-timeout) (the-as seconds 0)) + 0 + ) + (set! (-> obj eco-type) (the-as int kind)) + (let ((eco-lev (-> obj eco-level))) + (set! (-> obj eco-level) 1.0) + (when (and (= eco-lev 0.0) (< 0.0 (-> obj eco-level))) + (set! + (-> obj eco-pickup-time) + (the-as uint (-> *display* game-frame-counter)) + ) + (let ((a1-24 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-24 from) pp) + (set! (-> a1-24 num-params) 0) + (set! (-> a1-24 message) 'reset-collide) + (send-event-function (-> obj process) a1-24) + ) + ) + (set! + (-> obj eco-timeout) + (the-as + seconds + (min + (the-as + int + (+ + (-> obj eco-timeout) + (* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount)) + ) + ) + (the-as + int + (+ + (-> *FACT-bank* eco-full-timeout) + (- + (-> *display* game-frame-counter) + (the-as int (-> obj eco-pickup-time)) + ) + ) + ) + ) + ) + ) + (if + (>= + (the-as + int + (- + (-> obj eco-timeout) + (the-as + uint + (- + (-> *display* game-frame-counter) + (the-as int (-> obj eco-pickup-time)) + ) + ) + ) + ) + (the-as int (-> *FACT-bank* eco-full-timeout)) + ) + (set! (-> obj eco-level) 2.0) + ) + (when + (not + (and + (= + (handle->process source-handle) + (handle->process (-> obj eco-source)) + ) + (< + (- + (-> *display* base-frame-counter) + (the-as int (-> obj eco-source-time)) + ) + 150 + ) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 60) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 17 60) + (case kind + (((pickup-type eco-blue)) + (sound-play-by-name + (static-sound-name "get-blue-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (((pickup-type eco-green)) + (sound-play-by-name + (static-sound-name "get-green-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (((pickup-type eco-yellow)) + (sound-play-by-name + (static-sound-name "get-yellow-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (((pickup-type eco-red)) + (sound-play-by-name + (static-sound-name "get-red-eco") + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + ) + ) + (set! (-> obj eco-source) source-handle) + (set! + (-> obj eco-source-time) + (the-as uint (-> *display* base-frame-counter)) + ) + (when (= kind (pickup-type eco-blue)) + (when (= eco-lev 0.0) + (let ((s5-1 (-> obj process))) + (let* ((s3-5 (get-process *default-dead-pool* touch-tracker #x4000)) + (s4-3 (when s3-5 + (let ((t9-28 (method-of-type touch-tracker activate))) + (t9-28 + (the-as touch-tracker s3-5) + s5-1 + 'touch-tracker + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function vector meters int none) + run-function-in-process + ) + s3-5 + touch-tracker-init + (-> s5-1 root trans) + (-> *FACT-bank* suck-bounce-dist) + 300 + ) + (-> s3-5 ppointer) + ) + ) + ) + (let ((a1-44 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-44 from) pp) + (set! (-> a1-44 num-params) 1) + (set! (-> a1-44 message) 'target) + (set! (-> a1-44 param 0) (the-as uint s5-1)) + (send-event-function (ppointer->process s4-3) a1-44) + ) + (let ((a1-45 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-45 from) pp) + (set! (-> a1-45 num-params) 1) + (set! (-> a1-45 message) 'event) + (set! (-> a1-45 param 0) (the-as uint 'eco-blue)) + (send-event-function (ppointer->process s4-3) a1-45) + ) + (let ((a1-46 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-46 from) pp) + (set! (-> a1-46 num-params) 1) + (set! (-> a1-46 message) 'exit) + (set! (-> a1-46 param 0) (the-as uint (lambda () + (with-pp + (let + ((a1-0 + (new 'stack-no-clear 'event-message-block + ) + ) + ) + (set! (-> a1-0 from) pp) + (set! + (-> a1-0 num-params) + 2 + ) + (set! + (-> a1-0 message) + 'query + ) + (set! + (-> a1-0 param 0) + (the-as uint 'powerup) + ) + (set! + (-> a1-0 param 1) + (the-as uint 3) + ) + (send-event-function + *target* + a1-0 + ) + ) + ) + ) + ) + ) + (send-event-function (ppointer->process s4-3) a1-46) + ) + (let ((a1-47 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-47 from) pp) + (set! (-> a1-47 num-params) 1) + (set! (-> a1-47 message) 'eval) + (set! + (-> a1-47 param 0) + (the-as + uint + (lambda :behavior process-drawable + () + (set! + (-> (the-as collide-shape (-> self root)) root-prim collide-with) + (the-as uint #x800e) + ) + (none) + ) + ) + ) + (send-event-function (ppointer->process s4-3) a1-47) + ) + ) + (let ((s4-4 (get-process *4k-dead-pool* process #x4000))) + (when s4-4 + (let ((t9-35 (method-of-type process activate))) + (t9-35 s4-4 s5-1 'process (the-as pointer #x70004000)) + ) + ((the-as + (function cpu-thread function process-drawable none) + set-to-run + ) + (-> s4-4 main-thread) + (lambda ((arg0 process-drawable)) + (with-pp + (let ((s5-0 (-> *display* base-frame-counter))) + (until (>= (- (-> *display* base-frame-counter) s5-0) 180) + (let ((a1-0 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-0 from) pp) + (set! (-> a1-0 num-params) 1) + (set! (-> a1-0 message) 'effect) + (set! (-> a1-0 param 0) (the-as uint 'eco-blue)) + (send-event-function arg0 a1-0) + ) + (suspend) + ) + ) + (none) + ) + ) + s5-1 + ) + (-> s4-4 ppointer) + ) + ) + ) + ) + ) + ) + (-> obj eco-level) + ) + (else + ((method-of-type fact-info pickup-collectable!) + obj + kind + amount + source-handle + ) + ) + ) + ) + ) + +;; definition for method 12 of type game-info +(defmethod lookup-entity-perm-by-aid game-info ((obj game-info) (arg0 actor-id)) + (let ((v1-0 (-> obj perm-list))) + (countdown (a0-1 (-> v1-0 length)) + (if (= arg0 (-> v1-0 data a0-1 aid)) + (return (-> v1-0 data a0-1)) + ) + ) + ) + (the-as entity-perm #f) + ) + +;; definition for method 14 of type game-info +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod copy-perms-from-level! game-info ((obj game-info) (lev level)) + (let ((perms (-> obj perm-list)) + (lev-entities (-> lev bsp level entity)) + ) + (dotimes (lev-entity-idx (-> lev-entities length)) + (let + ((lev-entity-perm (-> lev-entities data lev-entity-idx entity extra perm))) + (when (nonzero? (-> lev-entity-perm task)) + (let + ((info-entity-perm + (lookup-entity-perm-by-aid obj (-> lev-entity-perm aid)) + ) + ) + (cond + (info-entity-perm + (set! (-> info-entity-perm quad) (-> lev-entity-perm quad)) + ) + ((< (-> perms length) (-> perms allocated-length)) + (set! (-> perms data (-> perms length) quad) (-> lev-entity-perm quad)) + (+! (-> perms length) 1) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type game-info +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod copy-perms-to-level! game-info ((obj game-info) (lev level)) + (let ((lev-entities (-> lev bsp level entity))) + (dotimes (lev-entity-idx (-> lev-entities length)) + (let* + ((lev-entity-perm (-> lev-entities data lev-entity-idx entity extra perm)) + (info-entity-perm + (lookup-entity-perm-by-aid obj (-> lev-entity-perm aid)) + ) + ) + (when info-entity-perm + (set! (-> lev-entity-perm quad) (-> info-entity-perm quad)) + (update-perm! + lev-entity-perm + 'try + (entity-perm-status + bit-0 + bit-1 + dead + bit-3 + user-set-from-cstage + complete + bit-9 + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 2 of type continue-point +(defmethod print continue-point ((obj continue-point)) + (format #t "#<~A ~S @ #x~X>" (-> obj type) (-> obj name) obj) + obj + ) + +;; definition for method 9 of type continue-point +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod debug-draw! continue-point ((obj continue-point)) + (add-debug-x + #t + (bucket-id debug-draw1) + (-> obj trans) + (new 'static 'rgba :r #xff :a #x80) + ) + (add-debug-text-3d + #t + (bucket-id debug-draw1) + (-> obj name) + (-> obj trans) + (font-color white) + (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) + ) + (let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (-> obj quat)))) + (add-debug-vector + #t + (bucket-id debug-draw1) + (-> obj trans) + a3-2 + (meters 2.0) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function trsq->continue-point +;; INFO: Return type mismatch int vs none. +(defun-debug trsq->continue-point ((arg0 trsq)) + (let ((a2-0 (level-get-target-inside *level*))) + (format + #t + "~%(static-continue-point ~A ()~%" + (symbol->string (-> a2-0 name)) + ) + ) + (format + #t + " (target ~m ~m ~m " + (-> arg0 trans x) + (-> arg0 trans y) + (-> arg0 trans z) + ) + (format + #t + "~f ~f ~f ~f)~%" + (-> arg0 quat x) + (-> arg0 quat y) + (-> arg0 quat z) + (-> arg0 quat w) + ) + (let ((gp-1 *math-camera*)) + (format + #t + " (camera ~m ~m ~m ~f ~f ~f " + (-> gp-1 trans x) + (-> gp-1 trans y) + (-> gp-1 trans z) + (-> gp-1 inv-camera-rot vector 0 x) + (-> gp-1 inv-camera-rot vector 0 y) + (-> gp-1 inv-camera-rot vector 0 z) + ) + (format + #t + "~f ~f ~f ~f ~f ~f)~%" + (-> gp-1 inv-camera-rot vector 1 x) + (-> gp-1 inv-camera-rot vector 1 y) + (-> gp-1 inv-camera-rot vector 1 z) + (-> gp-1 inv-camera-rot vector 2 x) + (-> gp-1 inv-camera-rot vector 2 y) + (-> gp-1 inv-camera-rot vector 2 z) + ) + ) + (format + #t + " (load '~A '~A '~A '~A '~A)~%" + (-> *load-state* vis-nick) + (-> *load-state* want 0 name) + (-> *load-state* want 0 display?) + (-> *load-state* want 1 name) + (-> *load-state* want 1 display?) + ) + (format #t " )~%") + 0 + (none) + ) + +;; definition (debug) for function game-task->string +(defun-debug game-task->string ((arg0 game-task)) + (case arg0 + (((game-task max)) + "max" + ) + (((game-task assistant-village3)) + "assistant-village3" + ) + (((game-task leaving-misty)) + "leaving-misty" + ) + (((game-task plunger-lurker-hit)) + "plunger-lurker-hit" + ) + (((game-task finalboss-movies)) + "finalboss-movies" + ) + (((game-task village4-button)) + "village4-button" + ) + (((game-task ogre-secret)) + "ogre-secret" + ) + (((game-task intro)) + "intro" + ) + (((game-task lavatube-start)) + "lavatube-start" + ) + (((game-task lavatube-balls)) + "lavatube-balls" + ) + (((game-task red-eggtop)) + "red-eggtop" + ) + (((game-task village3-button)) + "village3-button" + ) + (((game-task swamp-arm)) + "swamp-arm" + ) + (((game-task village2-levitator)) + "village2-levitator" + ) + (((game-task firecanyon-assistant)) + "firecanyon-assistant" + ) + (((game-task village3-oracle-money2)) + "village3-oracle-money2" + ) + (((game-task village3-oracle-money1)) + "village3-oracle-money1" + ) + (((game-task village3-miner-money4)) + "village3-miner-money4" + ) + (((game-task village3-miner-money3)) + "village3-miner-money3" + ) + (((game-task village3-miner-money2)) + "village3-miner-money2" + ) + (((game-task village3-miner-money1)) + "village3-miner-money1" + ) + (((game-task training-buzzer)) + "training-buzzer" + ) + (((game-task training-climb)) + "training-climb" + ) + (((game-task training-door)) + "training-door" + ) + (((game-task training-gimmie)) + "training-gimmie" + ) + (((game-task citadel-buzzer)) + "citadel-buzzer" + ) + (((game-task lavatube-buzzer)) + "lavatube-buzzer" + ) + (((game-task lavatube-end)) + "lavatube-end" + ) + (((game-task ogre-buzzer)) + "ogre-buzzer" + ) + (((game-task ogre-end)) + "ogre-end" + ) + (((game-task ogre-boss)) + "ogre-boss" + ) + (((game-task cave-buzzer)) + "cave-buzzer" + ) + (((game-task cave-platforms)) + "cave-platforms" + ) + (((game-task cave-spider-tunnel)) + "cave-spider-tunnel" + ) + (((game-task cave-swing-poles)) + "cave-swing-poles" + ) + (((game-task cave-robot-climb)) + "cave-robot-climb" + ) + (((game-task cave-dark-climb)) + "cave-dark-climb" + ) + (((game-task cave-dark-crystals)) + "cave-dark-crystals" + ) + (((game-task cave-gnawers)) + "cave-gnawers" + ) + (((game-task village3-buzzer)) + "village3-buzzer" + ) + (((game-task village2-buzzer)) + "village2-buzzer" + ) + (((game-task village1-buzzer)) + "village1-buzzer" + ) + (((game-task village3-extra1)) + "village3-extra1" + ) + (((game-task citadel-sage-yellow)) + "citadel-sage-yellow" + ) + (((game-task citadel-sage-red)) + "citadel-sage-red" + ) + (((game-task citadel-sage-blue)) + "citadel-sage-blue" + ) + (((game-task citadel-sage-green)) + "citadel-sage-green" + ) + (((game-task firecanyon-end)) + "firecanyon-end" + ) + (((game-task firecanyon-buzzer)) + "firecanyon-buzzer" + ) + (((game-task snow-cage)) + "snow-cage" + ) + (((game-task snow-bumpers)) + "snow-bumpers" + ) + (((game-task snow-buzzer)) + "snow-buzzer" + ) + (((game-task snow-bunnies)) + "snow-bunnies" + ) + (((game-task snow-ball)) + "snow-ball" + ) + (((game-task snow-fort)) + "snow-fort" + ) + (((game-task snow-ram)) + "snow-ram" + ) + (((game-task snow-eggtop)) + "snow-eggtop" + ) + (((game-task rolling-ring-chase-2)) + "rolling-ring-chase-2" + ) + (((game-task rolling-ring-chase-1)) + "rolling-ring-chase-1" + ) + (((game-task rolling-buzzer)) + "rolling-buzzer" + ) + (((game-task rolling-lake)) + "rolling-lake" + ) + (((game-task rolling-plants)) + "rolling-plants" + ) + (((game-task rolling-moles)) + "rolling-moles" + ) + (((game-task rolling-robbers)) + "rolling-robbers" + ) + (((game-task rolling-race)) + "rolling-race" + ) + (((game-task sunken-spinning-room)) + "sunken-spinning-room" + ) + (((game-task sunken-top-of-helix)) + "sunken-top-of-helix" + ) + (((game-task sunken-buzzer)) + "sunken-buzzer" + ) + (((game-task sunken-sharks)) + "sunken-sharks" + ) + (((game-task sunken-room)) + "sunken-room" + ) + (((game-task sunken-slide)) + "sunken-slide" + ) + (((game-task sunken-pipe)) + "sunken-pipe" + ) + (((game-task sunken-platforms)) + "sunken-platforms" + ) + (((game-task swamp-buzzer)) + "swamp-buzzer" + ) + (((game-task swamp-tether-4)) + "swamp-tether-4" + ) + (((game-task swamp-tether-3)) + "swamp-tether-3" + ) + (((game-task swamp-tether-2)) + "swamp-tether-2" + ) + (((game-task swamp-tether-1)) + "swamp-tether-1" + ) + (((game-task swamp-battle)) + "swamp-battle" + ) + (((game-task swamp-flutflut)) + "swamp-flutflut" + ) + (((game-task swamp-billy)) + "swamp-billy" + ) + (((game-task village2-oracle-money2)) + "village2-oracle-money2" + ) + (((game-task village2-oracle-money1)) + "village2-oracle-money1" + ) + (((game-task village2-warrior-money)) + "village2-warrior-money" + ) + (((game-task village2-geologist-money)) + "village2-geologist-money" + ) + (((game-task village2-gambler-money)) + "village2-gambler-money" + ) + (((game-task misty-eco-challenge)) + "misty-eco-challenge" + ) + (((game-task misty-bike-jump)) + "misty-bike-jump" + ) + (((game-task misty-buzzer)) + "misty-buzzer" + ) + (((game-task misty-bike)) + "misty-bike" + ) + (((game-task misty-cannon)) + "misty-cannon" + ) + (((game-task misty-warehouse)) + "misty-warehouse" + ) + (((game-task misty-boat)) + "misty-boat" + ) + (((game-task misty-muse)) + "misty-muse" + ) + (((game-task beach-sentinel)) + "beach-sentinel" + ) + (((game-task beach-gimmie)) + "beach-gimmie" + ) + (((game-task beach-buzzer)) + "beach-buzzer" + ) + (((game-task beach-cannon)) + "beach-cannon" + ) + (((game-task beach-seagull)) + "beach-seagull" + ) + (((game-task beach-flutflut)) + "beach-flutflut" + ) + (((game-task beach-pelican)) + "beach-pelican" + ) + (((game-task beach-ecorocks)) + "beach-ecorocks" + ) + (((game-task village1-oracle-money2)) + "village1-oracle-money2" + ) + (((game-task village1-oracle-money1)) + "village1-oracle-money1" + ) + (((game-task village1-uncle-money)) + "village1-uncle-money" + ) + (((game-task village1-mayor-money)) + "village1-mayor-money" + ) + (((game-task village1-yakow)) + "village1-yakow" + ) + (((game-task jungle-temple-door)) + "jungle-temple-door" + ) + (((game-task jungle-canyon-end)) + "jungle-canyon-end" + ) + (((game-task jungle-buzzer)) + "jungle-buzzer" + ) + (((game-task jungle-plant)) + "jungle-plant" + ) + (((game-task jungle-fishgame)) + "jungle-fishgame" + ) + (((game-task jungle-tower)) + "jungle-tower" + ) + (((game-task jungle-lurkerm)) + "jungle-lurkerm" + ) + (((game-task jungle-eggtop)) + "jungle-eggtop" + ) + (((game-task complete)) + "complete" + ) + (((game-task none)) + "none" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition for method 16 of type game-info +(defmethod debug-print game-info ((obj game-info) (arg0 symbol)) + (inspect obj) + (when (or (not arg0) (= arg0 'game-task)) + (format #t "~Tgame-task:~%") + (dotimes (s4-0 116) + (if (task-complete? obj (the-as game-task s4-0)) + (format #t "~T~T~S~%" (game-task->string (the-as game-task s4-0))) + ) + ) + ) + (when (or (not arg0) (= arg0 'entity-perm)) + (format #t "~Tentity-perm:~%") + (let ((s5-1 (-> obj perm-list))) + (dotimes (s4-1 (-> s5-1 length)) + (format #t "~T~T~`entity-perm`P~%" (-> s5-1 data s4-1)) + ) + ) + ) + obj + ) + +;; failed to figure out what this is: +(let ((gp-0 *game-info*)) + (when (zero? (-> gp-0 perm-list)) + (set! (-> gp-0 perm-list) (new 'global 'entity-perm-array 4096)) + (set! (-> gp-0 perm-list length) 0) + 0 + ) + (when (zero? (-> gp-0 task-perm-list)) + (let ((v1-15 (new 'global 'entity-perm-array 116))) + (set! (-> gp-0 task-perm-list) v1-15) + (dotimes (a0-24 (-> v1-15 length)) + (set! (-> v1-15 data a0-24 task) (the-as game-task a0-24)) + ) + (logior! (-> v1-15 data 1 status) (entity-perm-status real-complete)) + ) + ) + (if (zero? (-> gp-0 text-ids-seen)) + (set! (-> gp-0 text-ids-seen) (new 'global 'bit-array 4095)) + ) + (when (zero? (-> gp-0 death-pos)) + (set! (-> gp-0 death-pos) (new 'global 'vector-array 64)) + (set! (-> gp-0 death-pos length) 0) + 0 + ) + (if (zero? (-> gp-0 display-text-handle)) + (set! (-> gp-0 display-text-handle) (the-as uint #f)) + ) + (if (not (-> gp-0 current-continue)) + (set-continue! gp-0 *default-continue*) + ) + (set! (-> gp-0 want-auto-save) #f) + (set! (-> gp-0 auto-save-proc) (the-as handle #f)) + (set! (-> gp-0 auto-save-status) (mc-status-code ok)) + (set! (-> gp-0 auto-save-card) 0) + (set! (-> gp-0 auto-save-which) -1) + (set! (-> gp-0 pov-camera-handle) (the-as handle #f)) + (set! (-> gp-0 other-camera-handle) (the-as handle #f)) + ) + +;; definition for method 27 of type game-info +(defmethod get-death-count game-info ((obj game-info) (arg0 symbol)) + (let + ((v1-13 + (if + (and + arg0 + *target* + (>= + (-> *level-task-data-remap* length) + (-> *target* current-level info index) + ) + ) + (the-as + int + (-> + obj + deaths-per-level + (-> + *level-task-data-remap* + (+ (-> *target* current-level info index) -1) + ) + ) + ) + (-> obj fuel-cell-deaths) + ) + ) + ) + 0 + (min 4 (/ v1-13 5)) + ) + ) + +;; definition for method 28 of type game-info +(defmethod get-health-percent-lost game-info ((obj game-info)) + (* 0.25 (the float (get-death-count obj #f))) + ) diff --git a/test/decompiler/reference/engine/game/settings-h_REF.gc b/test/decompiler/reference/engine/game/settings-h_REF.gc index a5d94931ef..7eb211c9c1 100644 --- a/test/decompiler/reference/engine/game/settings-h_REF.gc +++ b/test/decompiler/reference/engine/game/settings-h_REF.gc @@ -64,56 +64,11 @@ (format #t "~Tscreeny: ~D~%" (-> obj screeny)) (format #t "~Tvibration: ~A~%" (-> obj vibration)) (format #t "~Tplay-hints: ~A~%" (-> obj play-hints)) - (let ((t9-12 format) - (a0-13 #t) - (a1-12 "~Tmovie: ~A~%") - (v1-0 (-> obj movie)) - ) - (t9-12 a0-13 a1-12 (if v1-0 - (-> v1-0 0 self) - ) - ) - ) - (let ((t9-13 format) - (a0-14 #t) - (a1-13 "~Ttalking: ~A~%") - (v1-2 (-> obj talking)) - ) - (t9-13 a0-14 a1-13 (if v1-2 - (-> v1-2 0 self) - ) - ) - ) - (let ((t9-14 format) - (a0-15 #t) - (a1-14 "~Tspooling: ~A~%") - (v1-4 (-> obj spooling)) - ) - (t9-14 a0-15 a1-14 (if v1-4 - (-> v1-4 0 self) - ) - ) - ) - (let ((t9-15 format) - (a0-16 #t) - (a1-15 "~Thint: ~A~%") - (v1-6 (-> obj hint)) - ) - (t9-15 a0-16 a1-15 (if v1-6 - (-> v1-6 0 self) - ) - ) - ) - (let ((t9-16 format) - (a0-17 #t) - (a1-16 "~Tambient: ~A~%") - (v1-8 (-> obj ambient)) - ) - (t9-16 a0-17 a1-16 (if v1-8 - (-> v1-8 0 self) - ) - ) - ) + (format #t "~Tmovie: ~A~%" (ppointer->process (-> obj movie))) + (format #t "~Ttalking: ~A~%" (ppointer->process (-> obj talking))) + (format #t "~Tspooling: ~A~%" (ppointer->process (-> obj spooling))) + (format #t "~Thint: ~A~%" (ppointer->process (-> obj hint))) + (format #t "~Tambient: ~A~%" (ppointer->process (-> obj ambient))) (format #t "~Tvideo-mode: ~A~%" (-> obj video-mode)) (format #t "~Taspect-ratio: ~A~%" (-> obj aspect-ratio)) (format #t "~Tsound-flava: ~D~%" (-> obj sound-flava)) diff --git a/test/decompiler/reference/engine/game/settings_REF.gc b/test/decompiler/reference/engine/game/settings_REF.gc index a05af74d44..bd05d492a5 100644 --- a/test/decompiler/reference/engine/game/settings_REF.gc +++ b/test/decompiler/reference/engine/game/settings_REF.gc @@ -42,14 +42,7 @@ (zero? (logand (-> *kernel-context* prevent-from-run) (process-mask progress)) ) - (let ((v1-18 (get-process conn)) - (a0-22 *progress-process*) - ) - (= v1-18 (if a0-22 - (-> a0-22 0 self) - ) - ) - ) + (= (get-process conn) (ppointer->process *progress-process*)) ) (case (the-as symbol (-> conn param1)) (('rel) diff --git a/test/decompiler/reference/engine/game/task/hint-control-h_REF.gc b/test/decompiler/reference/engine/game/task/hint-control-h_REF.gc index 69a445aea8..72cd84ad50 100644 --- a/test/decompiler/reference/engine/game/task/hint-control-h_REF.gc +++ b/test/decompiler/reference/engine/game/task/hint-control-h_REF.gc @@ -9,8 +9,8 @@ (num-success-before-killing int8 :offset-assert 13) (num-attempts int8 :offset-assert 14) (num-success int8 :offset-assert 15) - (start-time uint64 :offset-assert 16) - (last-time-called uint64 :offset-assert 24) + (start-time int64 :offset-assert 16) + (last-time-called int64 :offset-assert 24) ) :method-count-assert 9 :size-assert #x20 diff --git a/test/decompiler/reference/engine/game/task/hint-control_REF.gc b/test/decompiler/reference/engine/game/task/hint-control_REF.gc index 4b50de8235..68e7747173 100644 --- a/test/decompiler/reference/engine/game/task/hint-control_REF.gc +++ b/test/decompiler/reference/engine/game/task/hint-control_REF.gc @@ -344,13 +344,9 @@ ) (when v1-0 (when *hint-semaphore* - (let ((v1-3 *hint-semaphore*)) - (set! v1-0 (dummy-15 (the-as level-hint (if v1-3 - (-> v1-3 0 self) - ) - ) - ) - ) + (set! + v1-0 + (dummy-15 (the-as level-hint (ppointer->process *hint-semaphore*))) ) 0 ) @@ -358,9 +354,9 @@ (and v1-0 (< - (the-as - int - (- (-> *display* base-frame-counter) (-> *game-info* hint-play-time)) + (- + (-> *display* base-frame-counter) + (the-as int (-> *game-info* hint-play-time)) ) 30 ) @@ -377,7 +373,7 @@ (not (-> *setting-control* current hint)) (not (-> *setting-control* current ambient)) (>= - (the-as int (-> *display* base-frame-counter)) + (-> *display* base-frame-counter) (the-as int (-> *game-info* blackout-time)) ) ) @@ -401,11 +397,7 @@ ) (v1-21 #t) ) - (if - (and - (= (-> gp-1 num-attempts-before-playing) 1) - (< (the-as int a0-24) 30) - ) + (if (and (= (-> gp-1 num-attempts-before-playing) 1) (< a0-24 30)) (+! (-> gp-1 start-time) a0-24) ) (cond @@ -413,10 +405,7 @@ (!= (-> gp-1 num-attempts-before-playing) 1) (nonzero? (-> gp-1 last-time-called)) (< - (the-as - int - (- (-> *display* base-frame-counter) (-> gp-1 last-time-called)) - ) + (- (-> *display* base-frame-counter) (-> gp-1 last-time-called)) 150 ) ) @@ -428,7 +417,7 @@ (when (nonzero? (-> gp-1 delay-before-playing)) (if (< - (the-as int (-> gp-1 start-time)) + (-> gp-1 start-time) (the-as int (-> gp-1 delay-before-playing)) ) (set! v1-21 #f) @@ -470,8 +459,8 @@ (let ((v1-2 (length (-> *game-info* hint-control)))) (dotimes (a0-1 v1-2) (let ((a1-2 (-> *game-info* hint-control a0-1))) - (set! (-> a1-2 start-time) (the-as uint 0)) - (set! (-> a1-2 last-time-called) (the-as uint 0)) + (set! (-> a1-2 start-time) 0) + (set! (-> a1-2 last-time-called) 0) (set! (-> a1-2 num-attempts) 0) (set! (-> a1-2 num-success) 0) ) diff --git a/test/decompiler/reference/engine/gfx/hw/display-h_REF.gc b/test/decompiler/reference/engine/gfx/hw/display-h_REF.gc index 921c97e646..119b14b287 100644 --- a/test/decompiler/reference/engine/gfx/hw/display-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/hw/display-h_REF.gc @@ -173,22 +173,22 @@ (last-screen int32 :offset-assert 564) (frames virtual-frame 6 :inline :offset-assert 568) (bg-clear-color rgba 4 :offset-assert 760) - (real-frame-counter uint64 :offset-assert 776) - (base-frame-counter uint64 :offset-assert 784) - (game-frame-counter uint64 :offset-assert 792) - (integral-frame-counter uint64 :offset-assert 800) - (real-integral-frame-counter uint64 :offset-assert 808) - (actual-frame-counter uint64 :offset-assert 816) - (real-actual-frame-counter uint64 :offset-assert 824) - (part-frame-counter uint64 :offset-assert 832) - (old-real-frame-counter uint64 :offset-assert 840) - (old-base-frame-counter uint64 :offset-assert 848) - (old-game-frame-counter uint64 :offset-assert 856) - (old-integral-frame-counter uint64 :offset-assert 864) - (old-real-integral-frame-counter uint64 :offset-assert 872) - (old-actual-frame-counter uint64 :offset-assert 880) - (old-real-actual-frame-counter uint64 :offset-assert 888) - (old-part-frame-counter uint64 :offset-assert 896) + (real-frame-counter int64 :offset-assert 776) + (base-frame-counter int64 :offset-assert 784) + (game-frame-counter int64 :offset-assert 792) + (integral-frame-counter int64 :offset-assert 800) + (real-integral-frame-counter int64 :offset-assert 808) + (actual-frame-counter int64 :offset-assert 816) + (real-actual-frame-counter int64 :offset-assert 824) + (part-frame-counter int64 :offset-assert 832) + (old-real-frame-counter int64 :offset-assert 840) + (old-base-frame-counter int64 :offset-assert 848) + (old-game-frame-counter int64 :offset-assert 856) + (old-integral-frame-counter int64 :offset-assert 864) + (old-real-integral-frame-counter int64 :offset-assert 872) + (old-actual-frame-counter int64 :offset-assert 880) + (old-real-actual-frame-counter int64 :offset-assert 888) + (old-part-frame-counter int64 :offset-assert 896) (time-ratio float :offset-assert 904) (seconds-per-frame float :offset-assert 908) (frames-per-second float :offset-assert 912) diff --git a/test/decompiler/reference/engine/gfx/hw/display_REF.gc b/test/decompiler/reference/engine/gfx/hw/display_REF.gc index 565f950cfe..8b6453929f 100644 --- a/test/decompiler/reference/engine/gfx/hw/display_REF.gc +++ b/test/decompiler/reference/engine/gfx/hw/display_REF.gc @@ -185,12 +185,12 @@ ) (set-draw-env (-> disp draw0) psm w h ztest zpsm 384) (set-draw-env (-> disp draw1) psm w h ztest zpsm 320) - (set! (-> disp base-frame-counter) (the-as uint #x493e0)) - (set! (-> disp game-frame-counter) (the-as uint #x493e0)) - (set! (-> disp real-frame-counter) (the-as uint #x493e0)) - (set! (-> disp part-frame-counter) (the-as uint #x493e0)) - (set! (-> disp integral-frame-counter) (the-as uint #x493e0)) - (set! (-> disp real-integral-frame-counter) (the-as uint #x493e0)) + (set! (-> disp base-frame-counter) #x493e0) + (set! (-> disp game-frame-counter) #x493e0) + (set! (-> disp real-frame-counter) #x493e0) + (set! (-> disp part-frame-counter) #x493e0) + (set! (-> disp integral-frame-counter) #x493e0) + (set! (-> disp real-integral-frame-counter) #x493e0) (set! (-> disp old-base-frame-counter) (+ (-> disp base-frame-counter) -1)) (set! (-> disp old-game-frame-counter) (+ (-> disp game-frame-counter) -1)) (set! (-> disp old-real-frame-counter) (+ (-> disp real-frame-counter) -1)) @@ -455,12 +455,12 @@ (or (< 75 - (the-as int (- (-> *display* real-frame-counter) (-> obj cache-time))) + (- (-> *display* real-frame-counter) (the-as int (-> obj cache-time))) ) (>= end-time (the-as int (-> worst-time-cache (/ bar-pos 10)))) ) (set! (-> worst-time-cache (/ bar-pos 10)) (the-as uint end-time)) - (set! (-> obj cache-time) (-> *display* real-frame-counter)) + (set! (-> obj cache-time) (the-as uint (-> *display* real-frame-counter))) ) (cond (*profile-ticks* diff --git a/test/decompiler/reference/engine/gfx/ripple_REF.gc b/test/decompiler/reference/engine/gfx/ripple_REF.gc index 705af4b35b..d3524c4976 100644 --- a/test/decompiler/reference/engine/gfx/ripple_REF.gc +++ b/test/decompiler/reference/engine/gfx/ripple_REF.gc @@ -70,7 +70,13 @@ (defun ripple-update-waveform-offs ((arg0 ripple-wave-set)) (let ((f0-1 - (the float (- (-> *display* integral-frame-counter) (-> arg0 frame-save))) + (the + float + (- + (-> *display* integral-frame-counter) + (the-as int (-> arg0 frame-save)) + ) + ) ) ) (when (!= f0-1 0.0) @@ -80,7 +86,10 @@ (set! (-> a1-4 offs) (the float (logand (the int (-> a1-4 offs)) #xffff))) ) ) - (set! (-> arg0 frame-save) (-> *display* integral-frame-counter)) + (set! + (-> arg0 frame-save) + (the-as uint (-> *display* integral-frame-counter)) + ) ) ) 0 diff --git a/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc index d4858b2208..0a2377af1b 100644 --- a/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/sparticle/sparticle-launcher-h_REF.gc @@ -141,19 +141,19 @@ ;; definition of type sparticle-launch-group (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) - (name basic :offset-assert 12) - (launcher uint32 :offset-assert 16) - (bounds sphere :inline :offset-assert 32) + ((length int16 :offset-assert 4) + (duration uint16 :offset-assert 6) + (linger-duration uint16 :offset-assert 8) + (flags uint16 :offset-assert 10) + (name basic :offset-assert 12) + (launcher sparticle-group-item :offset-assert 16) + (bounds sphere :inline :offset-assert 32) ) :method-count-assert 10 :size-assert #x30 :flag-assert #xa00000030 (:methods - (dummy-9 (_type_ process) _type_ 9) + (create-launch-control (_type_ process) sparticle-launch-control 9) ) ) @@ -188,8 +188,8 @@ (:methods (dummy-9 () none 9) (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) + (dummy-11 (_type_ vector) none 11) + (deactivate (_type_) none 12) (dummy-13 () none 13) ) ) diff --git a/test/decompiler/reference/engine/load/load-dgo_REF.gc b/test/decompiler/reference/engine/load/load-dgo_REF.gc index 8617935fef..730b537b35 100644 --- a/test/decompiler/reference/engine/load/load-dgo_REF.gc +++ b/test/decompiler/reference/engine/load/load-dgo_REF.gc @@ -226,8 +226,8 @@ (none) ) -;; definition for symbol *dgo-time*, type uint -(define *dgo-time* (the-as uint 0)) +;; definition for symbol *dgo-time*, type int +(define *dgo-time* 0) ;; definition for function dgo-load-begin ;; Used lq/sq diff --git a/test/decompiler/reference/engine/load/loader_REF.gc b/test/decompiler/reference/engine/load/loader_REF.gc index a274b3706c..275df28c9e 100644 --- a/test/decompiler/reference/engine/load/loader_REF.gc +++ b/test/decompiler/reference/engine/load/loader_REF.gc @@ -939,11 +939,7 @@ (set! (-> obj preload-stream name) arg0) (set! (-> obj preload-stream parts) arg1) (set! (-> obj preload-stream priority) arg3) - (let ((v1-8 (if arg2 - (-> arg2 ppointer) - ) - ) - ) + (let ((v1-8 (process->ppointer arg2))) (set! (-> obj preload-stream owner) (new 'static 'handle @@ -1010,11 +1006,7 @@ (set! (-> obj rec 0 name) arg0) (set! (-> obj rec 0 parts) arg1) (set! (-> obj rec 0 priority) arg3) - (let ((v1-34 (if arg2 - (-> arg2 ppointer) - ) - ) - ) + (let ((v1-34 (process->ppointer arg2))) (set! (-> obj rec 0 owner) (new 'static 'handle @@ -1029,12 +1021,7 @@ (set! (-> obj rec 1 name) arg0) (set! (-> obj rec 1 parts) arg1) (set! (-> obj rec 1 priority) arg3) - (let* ((a0-18 arg2) - (v1-40 (if a0-18 - (-> a0-18 ppointer) - ) - ) - ) + (let ((v1-40 (process->ppointer arg2))) (set! (-> obj rec 1 owner) (new 'static 'handle @@ -1048,12 +1035,7 @@ (set! (-> obj rec 2 name) arg0) (set! (-> obj rec 2 parts) arg1) (set! (-> obj rec 2 priority) arg3) - (let* ((a0-22 arg2) - (v1-44 (if a0-22 - (-> a0-22 ppointer) - ) - ) - ) + (let ((v1-44 (process->ppointer arg2))) (set! (-> obj rec 2 owner) (new 'static 'handle @@ -1101,18 +1083,13 @@ (set! sv-56 0) (set! spool-sound (new-sound-id)) (dummy-17 *load-state* (-> arg0 command-list)) - (let* ((a0-2 *setting-control*) - (t9-2 (method-of-object a0-2 set-setting!)) - (a1-2 self) - (a2-1 'spooling) - (v1-6 self) - ) - (t9-2 a0-2 a1-2 a2-1 (the-as symbol (if v1-6 - (-> v1-6 ppointer) - ) - ) - 0.0 0 - ) + (set-setting! + *setting-control* + self + 'spooling + (the-as symbol (process->ppointer self)) + 0.0 + 0 ) (logior! (-> self skel status) 7) (kill-current-level-hint '() '() 'die) @@ -1168,11 +1145,7 @@ ) ) ) - (let ((v1-46 (if self - (-> self ppointer) - ) - ) - ) + (let ((v1-46 (process->ppointer self))) (set! (-> *art-control* spool-lock) (new 'static 'handle @@ -1181,7 +1154,7 @@ ) ) ) - (set! sv-48 (the-as int (-> *display* base-frame-counter))) + (set! sv-48 (-> *display* base-frame-counter)) (while (< spool-part (-> arg0 parts)) (let* ((a0-27 *art-control*) (t9-13 (method-of-object a0-27 spool-push)) @@ -1286,7 +1259,7 @@ ) ) (set! sv-72 (current-str-pos spool-sound)) - (set! sv-40 (the-as int (-> *display* base-frame-counter))) + (set! sv-40 (-> *display* base-frame-counter)) (until (>= (the float v0-39) f28-0) (if (= (-> self skel root-channel 0) (-> self skel channel)) (logior! (-> self skel status) 32) @@ -1296,7 +1269,7 @@ (arg3 self) (and (<= sv-72 0) - (>= (the-as int (- (-> *display* base-frame-counter) sv-40)) 1200) + (>= (- (-> *display* base-frame-counter) sv-40) 1200) ) (and (< 300 sv-56) (<= sv-72 0)) ) @@ -1338,14 +1311,14 @@ ) ) ) - (set! sv-40 (the-as int (-> *display* base-frame-counter))) + (set! sv-40 (-> *display* base-frame-counter)) ) (else 0 ) ) (set! sv-32 sv-72) - (set! sv-48 (the-as int (-> *display* base-frame-counter))) + (set! sv-48 (-> *display* base-frame-counter)) (suspend) (let ((f0-14 (* (- (the float (current-str-pos spool-sound)) sv-24) f30-0)) diff --git a/test/decompiler/reference/engine/math/transformq-h_REF.gc b/test/decompiler/reference/engine/math/transformq-h_REF.gc index 7da5691f72..176f1ececc 100644 --- a/test/decompiler/reference/engine/math/transformq-h_REF.gc +++ b/test/decompiler/reference/engine/math/transformq-h_REF.gc @@ -47,7 +47,7 @@ (rotv vector :inline :offset-assert 80) (scalev vector :inline :offset-assert 96) (dir-targ quaternion :inline :offset-assert 112) - (angle-change-time uint64 :offset-assert 128) + (angle-change-time int64 :offset-assert 128) (old-y-angle-diff float :offset-assert 136) ) :method-count-assert 28 diff --git a/test/decompiler/reference/engine/math/transformq_REF.gc b/test/decompiler/reference/engine/math/transformq_REF.gc index 12c935faa1..8dc2bbda11 100644 --- a/test/decompiler/reference/engine/math/transformq_REF.gc +++ b/test/decompiler/reference/engine/math/transformq_REF.gc @@ -76,12 +76,9 @@ (or (and (< saturated-yaw 0.0) (< old-diff 0.0)) (>= - (the-as - int - (- - (-> *display* base-frame-counter) - (-> obj angle-change-time) - ) + (- + (-> *display* base-frame-counter) + (-> obj angle-change-time) ) 60 ) diff --git a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc index 726dc997ba..b746060847 100644 --- a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc +++ b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc @@ -93,7 +93,7 @@ (defun show-mc-info ((dma-buf dma-buffer)) (let ((info (new 'stack-no-clear 'mc-slot-info))) (dotimes (slot-idx 2) - (mc-get-slot-info slot-idx) + (mc-get-slot-info slot-idx info) (cond ((zero? (-> info known)) (format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" slot-idx) diff --git a/test/decompiler/reference/engine/ps2/pad_REF.gc b/test/decompiler/reference/engine/ps2/pad_REF.gc index 7f98946d1f..5d8f0bf1f9 100644 --- a/test/decompiler/reference/engine/ps2/pad_REF.gc +++ b/test/decompiler/reference/engine/ps2/pad_REF.gc @@ -50,10 +50,10 @@ (align uint8 6 :offset-assert 88) (direct uint8 6 :offset-assert 94) (buzz-val uint8 2 :offset-assert 100) - (buzz-time uint64 2 :offset-assert 104) + (buzz-time int64 2 :offset-assert 104) (buzz basic :offset-assert 120) (buzz-act int32 :offset-assert 124) - (change-time uint64 :offset-assert 128) + (change-time int64 :offset-assert 128) ) :method-count-assert 9 :size-assert #x88 @@ -122,7 +122,7 @@ ) (dotimes (v1-17 2) (set! (-> pad buzz-val 0) (the-as uint 0)) - (set! (-> pad buzz-time 0) (the-as uint 0)) + (set! (-> pad buzz-time 0) 0) ) pad ) @@ -214,10 +214,7 @@ ((= buzz-amount (-> pad buzz-val buzz-idx)) (set! (-> pad buzz-time buzz-idx) - (max - (the-as int (-> pad buzz-time buzz-idx)) - (the-as int (+ (get-current-time) duration)) - ) + (max (-> pad buzz-time buzz-idx) (+ (get-current-time) duration)) ) ) ((< (-> pad buzz-val buzz-idx) (the-as uint buzz-amount)) @@ -247,10 +244,7 @@ (cond ((and (-> pad buzz) - (< - (the-as int (get-current-time)) - (the-as int (-> pad buzz-time buzz-idx)) - ) + (< (get-current-time) (-> pad buzz-time buzz-idx)) (= *master-mode* 'game) ) (let ((v1-10 buzz-idx)) @@ -261,7 +255,7 @@ (logand (ash (-> pad buzz-val buzz-idx) - (- (the-as int (logand (get-integral-current-time) 7))) + (- (logand (get-integral-current-time) 7)) ) 1 ) diff --git a/test/decompiler/reference/engine/sound/gsound-h_REF.gc b/test/decompiler/reference/engine/sound/gsound-h_REF.gc index 486da1f435..fcfc81059c 100644 --- a/test/decompiler/reference/engine/sound/gsound-h_REF.gc +++ b/test/decompiler/reference/engine/sound/gsound-h_REF.gc @@ -764,9 +764,9 @@ (playing-id sound-id :offset-assert 8) (trans vector :inline :offset-assert 16) (name sound-name :offset-assert 32) - (play-time uint64 :offset-assert 48) - (time-base uint64 :offset-assert 56) - (time-random uint64 :offset-assert 64) + (play-time int64 :offset-assert 48) + (time-base int64 :offset-assert 56) + (time-random int64 :offset-assert 64) (volume int32 :offset-assert 72) (pitch int32 :offset-assert 76) (falloff-near int32 :offset-assert 80) diff --git a/test/decompiler/reference/engine/sound/gsound_REF.gc b/test/decompiler/reference/engine/sound/gsound_REF.gc index 14cb178e7d..f94f833a91 100644 --- a/test/decompiler/reference/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/engine/sound/gsound_REF.gc @@ -797,15 +797,15 @@ (sv-48 (set! (-> obj time-base) - (the-as uint (the int (* 300.0 (-> sv-48 0)))) + (the int (* 300.0 (-> sv-48 0))) ) (set! (-> obj time-random) - (the-as uint (the int (* 300.0 (-> sv-48 1)))) + (the int (* 300.0 (-> sv-48 1))) ) ) (else - (set! (-> obj time-base) (the-as uint -1)) + (set! (-> obj time-base) -1) ) ) (set! (-> obj trans quad) (-> arg1 quad)) @@ -830,19 +830,16 @@ ((-> obj spec) (when (or - (< (the-as int (-> obj time-base)) 0) - (>= - (the-as int (-> *display* base-frame-counter)) - (the-as int (-> obj play-time)) - ) + (< (-> obj time-base) 0) + (>= (-> *display* base-frame-counter) (-> obj play-time)) ) - (when (>= (the-as int (-> obj time-base)) 0) + (when (>= (-> obj time-base) 0) (set! (-> obj play-time) (+ (-> *display* base-frame-counter) (-> obj time-base) - (rand-vu-int-count (the-as int (-> obj time-random))) + (rand-vu-int-count (-> obj time-random)) ) ) (set! (-> obj playing-id) (new-sound-id)) @@ -869,7 +866,7 @@ ) (return 0) ) - (when (and *debug-effect-control* (>= (the-as int (-> obj time-base)) 0)) + (when (and *debug-effect-control* (>= (-> obj time-base) 0)) (format #t "(~5D) effect sound ~A ~G " @@ -895,7 +892,7 @@ ) ) ) - ((< (the-as int (-> obj time-base)) 0) + ((< (-> obj time-base) 0) (set! (-> obj playing-id) (sound-play-by-name @@ -910,11 +907,7 @@ ) ) (else - (when - (>= - (the-as int (-> *display* base-frame-counter)) - (the-as int (-> obj play-time)) - ) + (when (>= (-> *display* base-frame-counter) (-> obj play-time)) (set! (-> obj playing-id) (sound-play-by-name @@ -932,7 +925,7 @@ (+ (-> *display* base-frame-counter) (-> obj time-base) - (rand-vu-int-count (the-as int (-> obj time-random))) + (rand-vu-int-count (-> obj time-random)) ) ) ) diff --git a/test/decompiler/reference/engine/target/joint-mod-h_REF.gc b/test/decompiler/reference/engine/target/joint-mod-h_REF.gc index b03b78d125..f81c314d55 100644 --- a/test/decompiler/reference/engine/target/joint-mod-h_REF.gc +++ b/test/decompiler/reference/engine/target/joint-mod-h_REF.gc @@ -12,7 +12,7 @@ (trans vector :inline :offset-assert 64) (quat quaternion :inline :offset-assert 80) (scale vector :inline :offset-assert 96) - (notice-time uint64 :offset-assert 112) + (notice-time int64 :offset-assert 112) (flex-blend float :offset-assert 120) (blend float :offset-assert 124) (max-dist meters :offset-assert 128) @@ -295,16 +295,7 @@ ) ) (set! (-> obj notice-time) (-> *display* base-frame-counter)) - (let ((v1-12 (if proc - (-> proc ppointer) - ) - ) - ) - (set! - (-> last-try-to-look-at-data who) - (new 'static 'handle :process v1-12 :pid (-> v1-12 0 pid)) - ) - ) + (set! (-> last-try-to-look-at-data who) (process->handle proc)) (if (< (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) (set! (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) ) diff --git a/test/decompiler/reference/engine/util/smush-control-h_REF.gc b/test/decompiler/reference/engine/util/smush-control-h_REF.gc index 9b45f68c57..ca54cfd399 100644 --- a/test/decompiler/reference/engine/util/smush-control-h_REF.gc +++ b/test/decompiler/reference/engine/util/smush-control-h_REF.gc @@ -3,13 +3,13 @@ ;; definition of type smush-control (deftype smush-control (structure) - ((start-time uint64 :offset-assert 0) - (period float :offset-assert 8) - (duration float :offset-assert 12) - (amp float :offset-assert 16) - (damp-amp float :offset-assert 20) - (damp-period float :offset-assert 24) - (ticks float :offset-assert 28) + ((start-time int64 :offset-assert 0) + (period float :offset-assert 8) + (duration float :offset-assert 12) + (amp float :offset-assert 16) + (damp-amp float :offset-assert 20) + (damp-period float :offset-assert 24) + (ticks float :offset-assert 28) ) :method-count-assert 15 :size-assert #x20 diff --git a/test/decompiler/reference/engine/util/sync-info-h_REF.gc b/test/decompiler/reference/engine/util/sync-info-h_REF.gc index 5fc40dc25e..02c599d028 100644 --- a/test/decompiler/reference/engine/util/sync-info-h_REF.gc +++ b/test/decompiler/reference/engine/util/sync-info-h_REF.gc @@ -78,12 +78,12 @@ ;; definition of type delayed-rand-float (deftype delayed-rand-float (structure) - ((min-time int32 :offset-assert 0) - (max-time int32 :offset-assert 4) - (max-val float :offset-assert 8) - (timer int32 :offset-assert 12) - (start-time uint64 :offset-assert 16) - (value float :offset-assert 24) + ((min-time int32 :offset-assert 0) + (max-time int32 :offset-assert 4) + (max-val float :offset-assert 8) + (timer int32 :offset-assert 12) + (start-time int64 :offset-assert 16) + (value float :offset-assert 24) ) :method-count-assert 11 :size-assert #x1c @@ -173,7 +173,7 @@ (xz-max float :offset-assert 8) (y-max float :offset-assert 12) (timer int32 :offset-assert 16) - (start-time uint64 :offset-assert 24) + (start-time int64 :offset-assert 24) (value vector :inline :offset-assert 32) ) :method-count-assert 13 @@ -232,7 +232,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/engine/util/sync-info_REF.gc b/test/decompiler/reference/engine/util/sync-info_REF.gc index da1c866363..582c5844f5 100644 --- a/test/decompiler/reference/engine/util/sync-info_REF.gc +++ b/test/decompiler/reference/engine/util/sync-info_REF.gc @@ -277,7 +277,10 @@ (period-float (the float period)) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -312,7 +315,10 @@ ) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -355,7 +361,10 @@ (period-float (the float period)) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -377,7 +386,10 @@ (max-phase 1.0) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -401,7 +413,10 @@ (period-float (the float period)) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -434,7 +449,10 @@ (max-val 2.0) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -468,7 +486,10 @@ (max-val 2.0) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -529,7 +550,10 @@ (f0-1 2.0) (f2-2 (+ - (the float (mod (-> *display* base-frame-counter) v1-0)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) v1-0) + ) (-> obj offset) ) ) @@ -569,7 +593,10 @@ (max-val 2.0) (current-time (+ - (the float (mod (-> *display* base-frame-counter) period)) + (the + float + (mod (the-as uint (-> *display* base-frame-counter)) period) + ) (-> obj offset) ) ) @@ -620,7 +647,7 @@ (set! (-> obj min-time) min-tim) (set! (-> obj max-time) max-time) (set! (-> obj max-val) (* 0.5 max-times-two)) - (set! (-> obj start-time) (the-as uint 0)) + (set! (-> obj start-time) 0) (set! (-> obj timer) 0) (set! (-> obj value) 0.0) (-> obj value) @@ -629,10 +656,7 @@ ;; definition for method 10 of type delayed-rand-float (defmethod update! delayed-rand-float ((obj delayed-rand-float)) (when - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) - ) + (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) (set! (-> obj start-time) (-> *display* base-frame-counter)) (set! (-> obj timer) (rand-vu-int-range (-> obj min-time) (-> obj max-time))) (set! @@ -752,7 +776,7 @@ (set! (-> obj max-time) max-time) (set! (-> obj xz-max) (* 0.5 xz-range)) (set! (-> obj y-max) (* 0.5 y-range)) - (set! (-> obj start-time) (the-as uint 0)) + (set! (-> obj start-time) 0) (set! (-> obj timer) 0) (vector-reset! (-> obj value)) (-> obj value) @@ -780,10 +804,7 @@ ;; definition for method 11 of type delayed-rand-vector (defmethod update-with-delay! delayed-rand-vector ((obj delayed-rand-vector)) (if - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) - ) + (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) (update-now! obj) ) (-> obj value) @@ -795,10 +816,7 @@ delayed-rand-vector ((obj delayed-rand-vector)) (if - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj start-time))) - (-> obj timer) - ) + (>= (- (-> *display* base-frame-counter) (-> obj start-time)) (-> obj timer)) (update-now! obj) (vector-reset! (-> obj value)) ) @@ -865,7 +883,3 @@ ) (-> obj value) ) - - - - diff --git a/test/decompiler/reference/kernel/gkernel_REF.gc b/test/decompiler/reference/kernel/gkernel_REF.gc index d969b8f819..c2ddd16d1d 100644 --- a/test/decompiler/reference/kernel/gkernel_REF.gc +++ b/test/decompiler/reference/kernel/gkernel_REF.gc @@ -315,36 +315,9 @@ (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tname: ~S~%" (-> obj name)) (format #t "~Tmask: #x~X~%" (-> obj mask)) - (let ((t9-3 format) - (a0-4 #t) - (a1-3 "~Tparent: ~A~%") - (v1-0 (-> obj parent)) - ) - (t9-3 a0-4 a1-3 (if v1-0 - (-> v1-0 0 self) - ) - ) - ) - (let ((t9-4 format) - (a0-5 #t) - (a1-4 "~Tbrother: ~A~%") - (v1-2 (-> obj brother)) - ) - (t9-4 a0-5 a1-4 (if v1-2 - (-> v1-2 0 self) - ) - ) - ) - (let ((t9-5 format) - (a0-6 #t) - (a1-5 "~Tchild: ~A~%") - (v1-4 (-> obj child)) - ) - (t9-5 a0-6 a1-5 (if v1-4 - (-> v1-4 0 self) - ) - ) - ) + (format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> obj child))) obj ) @@ -431,36 +404,9 @@ (format #t "~Ttrans-hook: ~A~%" (-> obj trans-hook)) (format #t "~Tpost-hook: ~A~%" (-> obj post-hook)) (format #t "~Tevent-hook: ~A~%" (-> obj event-hook)) - (let ((t9-12 format) - (a0-13 #t) - (a1-12 "~Tparent: ~A~%") - (v1-0 (-> obj parent)) - ) - (t9-12 a0-13 a1-12 (if v1-0 - (-> v1-0 0 self) - ) - ) - ) - (let ((t9-13 format) - (a0-14 #t) - (a1-13 "~Tbrother: ~A~%") - (v1-2 (-> obj brother)) - ) - (t9-13 a0-14 a1-13 (if v1-2 - (-> v1-2 0 self) - ) - ) - ) - (let ((t9-14 format) - (a0-15 #t) - (a1-14 "~Tchild: ~A~%") - (v1-4 (-> obj child)) - ) - (t9-14 a0-15 a1-14 (if v1-4 - (-> v1-4 0 self) - ) - ) - ) + (format #t "~Tparent: ~A~%" (ppointer->process (-> obj parent))) + (format #t "~Tbrother: ~A~%" (ppointer->process (-> obj brother))) + (format #t "~Tchild: ~A~%" (ppointer->process (-> obj child))) (format #t "~Tconnection-list: ~`connectable`P~%" (-> obj connection-list)) (format #t "~Tstack-frame-top: ~A~%" (-> obj stack-frame-top)) (format #t "~Theap-base: #x~X~%" (-> obj heap-base)) @@ -547,18 +493,8 @@ (let ((s1-0 (-> s3-0 child)) (v1-5 ((method-of-type process new) allocation process 'dead arg1)) ) - (let ((a0-3 v1-5)) - (set! (-> s3-0 child) (if a0-3 - (-> a0-3 ppointer) - ) - ) - ) - (let ((a0-4 s3-0)) - (set! (-> v1-5 parent) (if a0-4 - (-> a0-4 ppointer) - ) - ) - ) + (set! (-> s3-0 child) (process->ppointer v1-5)) + (set! (-> v1-5 parent) (process->ppointer s3-0)) (set! (-> v1-5 pool) s3-0) (set! (-> v1-5 brother) s1-0) ) @@ -577,20 +513,13 @@ (!= obj *debug-dead-pool*) ) (set! s4-0 (get-process *debug-dead-pool* arg0 arg1)) - (when (the-as process s4-0) - (let ((t9-1 format) - (a0-2 0) - (a1-2 - "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%" - ) - (a2-1 arg0) - (v1-6 (the-as object s4-0)) - ) - (t9-1 a0-2 a1-2 a2-1 (if (the-as process v1-6) - (-> (the-as (pointer process) v1-6) 0 self) - ) - (-> obj name) - ) + (if (the-as process s4-0) + (format + 0 + "WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%" + arg0 + (ppointer->process (the-as process s4-0)) + (-> obj name) ) ) ) @@ -604,9 +533,7 @@ 0 "WARNING: ~A ~A could not be allocated, because ~A was empty.~%" arg0 - (if (the-as (pointer process) s4-0) - (-> (the-as (pointer process) s4-0) 0 self) - ) + (ppointer->process (the-as (pointer process) s4-0)) (-> obj name) ) (the-as process #f) @@ -1526,25 +1453,13 @@ (defun change-parent ((arg0 process-tree) (arg1 process-tree)) (let ((a2-0 (-> arg0 parent))) (when a2-0 - (let* ((v1-2 (-> a2-0 0 child)) - (a3-0 v1-2) - ) + (let ((v1-2 (-> a2-0 0 child))) (cond - ((= (if a3-0 - (-> a3-0 0 self) - ) - arg0 - ) + ((= (ppointer->process v1-2) arg0) (set! (-> a2-0 0 child) (-> arg0 brother)) ) (else - (while (let ((a2-2 (-> v1-2 0 brother))) - (!= (if a2-2 - (-> a2-2 0 self) - ) - arg0 - ) - ) + (while (!= (ppointer->process (-> v1-2 0 brother)) arg0) (nop!) (nop!) (nop!) @@ -1571,46 +1486,18 @@ (a3-1 (the-as (pointer process-tree) #f)) (v1-4 (the-as (pointer process-tree) #f)) ) - (let ((t1-0 t0-0)) - (if (= (if t1-0 - (-> t1-0 0 self) - ) - arg0 - ) - (set! a3-1 a2-1) - ) + (if (= (ppointer->process t0-0) arg0) + (set! a3-1 a2-1) ) - (let ((t1-4 t0-0)) - (if (= (if t1-4 - (-> t1-4 0 self) - ) - arg1 - ) - (set! v1-4 a2-1) - ) + (if (= (ppointer->process t0-0) arg1) + (set! v1-4 a2-1) ) (while (and (-> t0-0 0 brother) (or (not a3-1) (not v1-4))) - (let ((t1-8 t0-0)) - (if (= (-> (if t1-8 - (-> t1-8 0 self) - ) - brother - ) - arg1 - ) - (set! v1-4 t0-0) - ) + (if (= (-> (ppointer->process t0-0) brother) arg1) + (set! v1-4 t0-0) ) - (let ((t1-13 t0-0)) - (if (= (-> (if t1-13 - (-> t1-13 0 self) - ) - brother - ) - arg0 - ) - (set! a3-1 t0-0) - ) + (if (= (-> (ppointer->process t0-0) brother) arg0) + (set! a3-1 t0-0) ) (set! t0-0 (-> t0-0 0 brother)) ) diff --git a/test/decompiler/reference/levels/beach/bird-lady-beach_REF.gc b/test/decompiler/reference/levels/beach/bird-lady-beach_REF.gc index 5b12b40b5b..bf7ae4f532 100644 --- a/test/decompiler/reference/levels/beach/bird-lady-beach_REF.gc +++ b/test/decompiler/reference/levels/beach/bird-lady-beach_REF.gc @@ -74,34 +74,37 @@ (the-as game-task (current-task (-> obj tasks))) ) (close-current! (-> obj tasks)) - (let* ((s5-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-8 (when s5-1 - (let ((t9-4 (method-of-type manipy activate))) - (t9-4 - (the-as manipy s5-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-1 - manipy-init - (-> obj root trans) - (-> obj entity) - *flutflut-naked-sg* - #f - ) - (-> s5-1 ppointer) - ) - ) - ) - (set! - (-> obj flutflut) - (new 'static 'handle :process v1-8 :pid (-> v1-8 0 pid)) + (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj flutflut) (ppointer->handle (when s5-1 + (let + ((t9-4 + (method-of-type + manipy + activate + ) + ) + ) + (t9-4 + (the-as manipy s5-1) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-1 + manipy-init + (-> obj root trans) + (-> obj entity) + *flutflut-naked-sg* + #f + ) + (-> s5-1 ppointer) + ) + ) ) ) (let ((a1-4 (new 'stack-no-clear 'event-message-block))) @@ -118,34 +121,37 @@ (set! (-> a1-5 param 0) (the-as uint #t)) (send-event-function (handle->process (-> obj flutflut)) a1-5) ) - (let* ((s5-2 (get-process *default-dead-pool* manipy #x4000)) - (v1-28 (when s5-2 - (let ((t9-9 (method-of-type manipy activate))) - (t9-9 - (the-as manipy s5-2) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-2 - manipy-init - (-> obj root trans) - (-> obj entity) - *flutflutegg-sg* - #f - ) - (-> s5-2 ppointer) - ) - ) - ) - (set! - (-> obj egg) - (new 'static 'handle :process v1-28 :pid (-> v1-28 0 pid)) + (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj egg) (ppointer->handle (when s5-2 + (let + ((t9-9 + (method-of-type + manipy + activate + ) + ) + ) + (t9-9 + (the-as manipy s5-2) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-2 + manipy-init + (-> obj root trans) + (-> obj entity) + *flutflutegg-sg* + #f + ) + (-> s5-2 ppointer) + ) + ) ) ) (let ((a1-9 (new 'stack-no-clear 'event-message-block))) diff --git a/test/decompiler/reference/levels/beach/sculptor_REF.gc b/test/decompiler/reference/levels/beach/sculptor_REF.gc index fb7d8e24c6..c5b59d3ca2 100644 --- a/test/decompiler/reference/levels/beach/sculptor_REF.gc +++ b/test/decompiler/reference/levels/beach/sculptor_REF.gc @@ -101,34 +101,47 @@ ;; definition for function muse-to-idle (defbehavior muse-to-idle sculptor ((arg0 muse)) (when (not (handle->process (-> arg0 incomming-attack-id))) - (let* ((s5-0 (get-process *default-dead-pool* manipy #x4000)) - (v1-5 (when s5-0 - (let ((t9-1 (method-of-type manipy activate))) - (t9-1 - (the-as manipy s5-0) - arg0 - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-0 - manipy-init - (-> arg0 collide-info trans) - (-> arg0 entity) - *sculptor-muse-sg* - #f - ) - (-> s5-0 ppointer) - ) - ) - ) - (set! - (-> arg0 incomming-attack-id) - (new 'static 'handle :process v1-5 :pid (-> v1-5 0 pid)) + (let ((s5-0 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> arg0 incomming-attack-id) (ppointer->handle (when s5-0 + (let + ((t9-1 + (method-of-type + manipy + activate + ) + ) + ) + (t9-1 + (the-as + manipy + s5-0 + ) + arg0 + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-0 + manipy-init + (-> + arg0 + collide-info + trans + ) + (-> arg0 entity) + *sculptor-muse-sg* + #f + ) + (-> s5-0 ppointer) + ) + ) ) ) ) @@ -277,34 +290,37 @@ (the-as game-task (current-task (-> obj tasks))) ) (close-current! (-> obj tasks)) - (let* ((s5-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-12 (when s5-1 - (let ((t9-5 (method-of-type manipy activate))) - (t9-5 - (the-as manipy s5-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-1 - manipy-init - (-> obj root trans) - (-> obj entity) - *sculptor-muse-sg* - #f - ) - (-> s5-1 ppointer) - ) - ) - ) - (set! - (-> obj muse) - (new 'static 'handle :process v1-12 :pid (-> v1-12 0 pid)) + (let ((s5-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj muse) (ppointer->handle (when s5-1 + (let + ((t9-5 + (method-of-type + manipy + activate + ) + ) + ) + (t9-5 + (the-as manipy s5-1) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-1 + manipy-init + (-> obj root trans) + (-> obj entity) + *sculptor-muse-sg* + #f + ) + (-> s5-1 ppointer) + ) + ) ) ) (let ((v1-18 (handle->process (-> obj muse)))) diff --git a/test/decompiler/reference/levels/common/nav-enemy-h_REF.gc b/test/decompiler/reference/levels/common/nav-enemy-h_REF.gc index 252b2705ad..4f1aee3949 100644 --- a/test/decompiler/reference/levels/common/nav-enemy-h_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy-h_REF.gc @@ -152,15 +152,15 @@ (momentum-speed float :offset-assert 296) (acceleration float :offset-assert 300) (rotate-speed float :offset-assert 304) - (turn-time uint64 :offset-assert 312) - (frustration-time uint64 :offset-assert 320) + (turn-time int64 :offset-assert 312) + (frustration-time int64 :offset-assert 320) (speed-scale float :offset-assert 328) (neck joint-mod :offset-assert 332) - (reaction-time uint64 :offset-assert 336) - (notice-time uint64 :offset-assert 344) - (state-timeout uint64 :offset-assert 352) - (free-time uint64 :offset-assert 360) - (touch-time uint64 :offset-assert 368) + (reaction-time int64 :offset-assert 336) + (notice-time int64 :offset-assert 344) + (state-timeout int64 :offset-assert 352) + (free-time int64 :offset-assert 360) + (touch-time int64 :offset-assert 368) (nav-enemy-flags uint32 :offset-assert 376) (incomming-attack-id handle :offset-assert 384) (jump-return-state (state process) :offset-assert 392) diff --git a/test/decompiler/reference/levels/common/nav-enemy_REF.gc b/test/decompiler/reference/levels/common/nav-enemy_REF.gc index d61bad8f7e..5460684beb 100644 --- a/test/decompiler/reference/levels/common/nav-enemy_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy_REF.gc @@ -109,10 +109,7 @@ (not *target*) (and (zero? (logand (-> *target* state-flags) #x80f8)) - (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj touch-time))) - 15 - ) + (>= (- (-> *display* base-frame-counter) (-> obj touch-time)) 15) ) ) ) @@ -459,13 +456,13 @@ nav-enemy-default-event-handler (-> obj collide-info) (-> obj nav target-pos) (-> obj rotate-speed) - (the-as int (-> obj turn-time)) + (-> obj turn-time) ) (seek-toward-heading-vec! (-> obj collide-info) (-> obj nav travel) (-> obj rotate-speed) - (the-as int (-> obj turn-time)) + (-> obj turn-time) ) ) ) @@ -602,7 +599,7 @@ nav-enemy-default-event-handler (-> self collide-info) (target-pos 0) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (nav-enemy-simple-post) @@ -699,8 +696,8 @@ nav-enemy-default-event-handler ((logtest? (-> self nav-enemy-flags) 1) (when (>= - (the-as int (- (-> *display* base-frame-counter) (-> self notice-time))) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (-> self notice-time)) + (-> self reaction-time) ) (set! gp-0 #t) (set! (-> self nav-enemy-flags) (logand -2 (-> self nav-enemy-flags))) @@ -931,7 +928,10 @@ nav-enemy-default-event-handler (set! (-> v1-14 num-func) num-func-identity) (set! (-> v1-14 frame-num) 0.0) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status)) @@ -1013,7 +1013,7 @@ nav-enemy-default-event-handler (-> self collide-info) arg0 (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (suspend) (let ((a0-8 (-> self skel root-channel 0))) @@ -1027,7 +1027,7 @@ nav-enemy-default-event-handler (set! v1-16 (or - (>= (the-as int (- (-> *display* base-frame-counter) s4-0)) 3000) + (>= (- (-> *display* base-frame-counter) s4-0) 3000) (nav-enemy-facing-direction? arg0 arg1) ) ) @@ -1097,7 +1097,10 @@ nav-enemy-default-event-handler :enter (behavior () (nav-enemy-neck-control-inactive) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (if (-> self nav-info move-to-ground) (dummy-60 (-> self collide-info) @@ -1108,7 +1111,7 @@ nav-enemy-default-event-handler ) ) (set! (-> self nav-enemy-flags) (logand -7 (-> self nav-enemy-flags))) - (set! (-> self state-timeout) (the-as uint 300)) + (set! (-> self state-timeout) 300) (none) ) :trans @@ -1126,11 +1129,8 @@ nav-enemy-default-event-handler ) ) (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) (nonzero? (-> self draw)) (logtest? (-> self draw status) 8) @@ -1184,18 +1184,21 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self nav flags) (the-as nav-control-flags (the-as int (logior #x80000 (-> self nav flags)))) ) (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (logior! (-> self nav-enemy-flags) 8) - (set! (-> self state-timeout) (the-as uint 300)) + (set! (-> self state-timeout) 300) (set! (-> self target-speed) (-> self nav-info walk-travel-speed)) (set! (-> self acceleration) (-> self nav-info walk-acceleration)) (set! (-> self rotate-speed) (-> self nav-info walk-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info walk-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info walk-turn-time))) (none) ) :exit @@ -1207,19 +1210,13 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) (if (and (nonzero? (-> self draw)) (logtest? (-> self draw status) 8)) (set! (-> self free-time) (-> *display* base-frame-counter)) @@ -1236,10 +1233,7 @@ nav-enemy-default-event-handler ) ) ) - (>= - (the-as int (- (-> *display* base-frame-counter) (-> self free-time))) - 600 - ) + (>= (- (-> *display* base-frame-counter) (-> self free-time)) 600) ) (go-virtual nav-enemy-idle) ) @@ -1546,7 +1540,7 @@ nav-enemy-default-event-handler ) (dummy-11 (-> self nav) (-> self nav target-pos)) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (none) ) :code @@ -1595,7 +1589,7 @@ nav-enemy-default-event-handler (-> self collide-info) (-> self nav travel) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (suspend) (let ((a0-4 (-> self skel root-channel 0))) @@ -1638,18 +1632,18 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (none) ) :trans (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self reaction-time) ) (if (or @@ -1841,13 +1835,16 @@ nav-enemy-default-event-handler :enter (behavior () (nav-enemy-neck-control-look-at) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self free-time) (-> *display* base-frame-counter)) (logior! (-> self nav-enemy-flags) 4) (set! (-> self target-speed) (-> self nav-info run-travel-speed)) (set! (-> self acceleration) (-> self nav-info run-acceleration)) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (nav-enemy-reset-frustration) (none) ) @@ -1871,22 +1868,13 @@ nav-enemy-default-event-handler ) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self reaction-time) ) (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self frustration-time)) - ) - (the-as - int - (+ (-> self reaction-time) (-> self nav-info frustration-time)) - ) + (- (-> *display* base-frame-counter) (-> self frustration-time)) + (+ (-> self reaction-time) (-> self nav-info frustration-time)) ) (logior! (-> self nav-enemy-flags) 8192) ) @@ -1899,11 +1887,7 @@ nav-enemy-default-event-handler ) (cond ((logtest? #x20000 (-> self nav flags)) - (if - (>= - (the-as int (- (-> *display* base-frame-counter) (-> self free-time))) - 300 - ) + (if (>= (- (-> *display* base-frame-counter) (-> self free-time)) 300) (go-virtual nav-enemy-patrol) ) ) @@ -1959,7 +1943,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (let* ((f30-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0)) @@ -1977,22 +1964,19 @@ nav-enemy-default-event-handler (if (< f30-0 40960.0) (go-virtual nav-enemy-stare) ) - (set! (-> self state-timeout) (the-as uint gp-1)) + (set! (-> self state-timeout) gp-1) ) (set! (-> self target-speed) (-> self nav-info walk-travel-speed)) (set! (-> self acceleration) (-> self nav-info walk-acceleration)) (set! (-> self rotate-speed) (-> self nav-info walk-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info walk-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info walk-turn-time))) (none) ) :trans (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (logtest? (-> *target* state-flags) 128) @@ -2019,11 +2003,8 @@ nav-enemy-default-event-handler ) (logtest? #x20000 (-> self nav flags)) (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) ) (go-virtual nav-enemy-stare) @@ -2076,27 +2057,27 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (set! (-> self nav-enemy-flags) (logand -17 (-> self nav-enemy-flags))) (let ((f0-0 (vector-vector-distance (-> self collide-info trans) (target-pos 0))) ) (set! (-> self state-timeout) - (the-as - uint - (the - int - (+ - (lerp-scale 3000.0 0.0 f0-0 12288.0 122880.0) - (nav-enemy-rnd-float-range 0.0 900.0) - ) + (the + int + (+ + (lerp-scale 3000.0 0.0 f0-0 12288.0 122880.0) + (nav-enemy-rnd-float-range 0.0 900.0) ) ) ) ) (set! (-> self rotate-speed) (-> self nav-info run-rotate-speed)) - (set! (-> self turn-time) (the-as uint (-> self nav-info run-turn-time))) + (set! (-> self turn-time) (the-as int (-> self nav-info run-turn-time))) (set! (-> self collide-info transv quad) (-> *null-vector* quad)) (none) ) @@ -2109,10 +2090,7 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (logtest? (-> *target* state-flags) 128) @@ -2123,11 +2101,8 @@ nav-enemy-default-event-handler (if (and (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self notice-time)) - ) - (the-as int (-> self reaction-time)) + (- (-> *display* base-frame-counter) (-> self notice-time)) + (-> self reaction-time) ) (not (nav-enemy-frustrated?)) ) @@ -2167,11 +2142,8 @@ nav-enemy-default-event-handler (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) - (the-as int (-> self state-timeout)) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) + (-> self state-timeout) ) (go-virtual nav-enemy-give-up) ) @@ -2214,7 +2186,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (nav-enemy-neck-control-inactive) (set! (-> self nav-enemy-flags) (logand -5 (-> self nav-enemy-flags))) (none) @@ -2223,10 +2198,7 @@ nav-enemy-default-event-handler (behavior () (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 30 ) (if (TODO-RENAME-46 self (-> self nav-info notice-distance)) @@ -2352,16 +2324,7 @@ nav-enemy-default-event-handler (set! (-> a1-0 from) self) (set! (-> a1-0 num-params) 0) (set! (-> a1-0 message) 'child-die) - (let ((t9-0 send-event-function) - (v1-1 (-> self parent)) - ) - (t9-0 (the-as process (if v1-1 - (-> v1-1 0 self) - ) - ) - a1-0 - ) - ) + (send-event-function (ppointer->process (-> self parent)) a1-0) ) (none) ) @@ -2445,13 +2408,16 @@ nav-enemy-default-event-handler (-> self collide-info) (-> self jump-dest) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (when (logtest? (-> self nav-enemy-flags) 8) (let ((f30-0 - (the float (- (-> *display* base-frame-counter) (-> self jump-time))) + (the + float + (- (-> *display* base-frame-counter) (the-as int (-> self jump-time))) + ) ) ) (let @@ -2598,7 +2564,7 @@ nav-enemy-default-event-handler ) ) (set! (-> self collide-info status) (logand -8 (-> self collide-info status))) - (set! (-> self jump-time) (-> *display* base-frame-counter)) + (set! (-> self jump-time) (the-as uint (-> *display* base-frame-counter))) (logior! (-> self nav-enemy-flags) 8) (cond ((logtest? (-> self nav-enemy-flags) 1024) @@ -2659,7 +2625,10 @@ nav-enemy-default-event-handler ) (while (< - (the float (- (-> *display* base-frame-counter) (-> self jump-time))) + (the + float + (- (-> *display* base-frame-counter) (the-as int (-> self jump-time))) + ) (-> self jump-trajectory time) ) (suspend) @@ -2775,7 +2744,10 @@ nav-enemy-default-event-handler nav-enemy-jump-event-handler :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (if (and (-> self nav-info use-jump-blocked) @@ -2846,13 +2818,13 @@ nav-enemy-default-event-handler (-> self collide-info) (-> self nav target-pos) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) (seek-toward-heading-vec! (-> self collide-info) (-> self nav travel) (-> self rotate-speed) - (the-as int (-> self turn-time)) + (-> self turn-time) ) ) (vector-v++! @@ -2882,7 +2854,10 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (logclear! (-> self nav flags) (nav-control-flags bit19)) (let ((gp-0 (new 'stack-no-clear 'vector))) (set! (-> gp-0 quad) (-> self collide-info transv quad)) @@ -2899,10 +2874,7 @@ nav-enemy-default-event-handler (if (or (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 150 ) (logtest? #x80000 (-> self nav flags)) @@ -2931,17 +2903,17 @@ nav-enemy-default-event-handler ) :enter (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (none) ) :trans (behavior () (if (>= - (the-as - int - (- (-> *display* base-frame-counter) (the-as uint (-> self state-time))) - ) + (- (-> *display* base-frame-counter) (the-as int (-> self state-time))) 150 ) (go (-> self jump-return-state)) @@ -3013,7 +2985,10 @@ nav-enemy-default-event-handler ) :code (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (logior! (-> self nav-enemy-flags) 2048) (ja-channel-push! 1 30) (let ((f30-0 (nav-enemy-rnd-float-range 0.8 1.2))) @@ -3046,7 +3021,7 @@ nav-enemy-default-event-handler (let ((gp-0 (nav-enemy-rnd-int-range 0 150)) (s5-0 (-> *display* base-frame-counter)) ) - (until (>= (the-as int (- (-> *display* base-frame-counter) s5-0)) gp-0) + (until (>= (- (-> *display* base-frame-counter) s5-0) gp-0) (let ((a0-12 (-> self skel root-channel 0))) (set! (-> a0-12 param 0) f30-0) (joint-control-channel-group-eval! @@ -3083,7 +3058,10 @@ nav-enemy-default-event-handler ) :code (behavior () - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (nav-enemy-initialize-jump (-> self event-param-point)) (nav-enemy-neck-control-look-at) (logior! (-> self nav-enemy-flags) 16) @@ -3173,7 +3151,7 @@ nav-enemy-default-event-handler (-> *FACT-bank* default-pill-inc) ) ) - (set! (-> obj reaction-time) (the-as uint (nav-enemy-rnd-int-range 30 240))) + (set! (-> obj reaction-time) (nav-enemy-rnd-int-range 30 240)) (set! (-> obj speed-scale) 1.0) (logior! (-> obj nav-enemy-flags) 4216) 0 @@ -3184,7 +3162,7 @@ nav-enemy-default-event-handler (defmethod TODO-RENAME-49 nav-enemy ((obj nav-enemy) (arg0 nav-enemy-info)) (set! (-> obj nav-info) arg0) (set! (-> obj rotate-speed) (-> obj nav-info walk-rotate-speed)) - (set! (-> obj turn-time) (the-as uint (-> obj nav-info walk-turn-time))) + (set! (-> obj turn-time) (the-as int (-> obj nav-info walk-turn-time))) (when (and (!= (-> obj nav-info neck-joint) -1) (zero? (-> obj neck))) (set! (-> obj neck) diff --git a/test/decompiler/reference/levels/common/rigid-body_REF.gc b/test/decompiler/reference/levels/common/rigid-body_REF.gc index d3c8217dc3..f4205d6099 100644 --- a/test/decompiler/reference/levels/common/rigid-body_REF.gc +++ b/test/decompiler/reference/levels/common/rigid-body_REF.gc @@ -450,7 +450,7 @@ (sim-time-remaining float :offset-assert 688) (float-height-offset float :offset-assert 692) (player-attack-id int32 :offset-assert 696) - (player-bonk-timeout uint64 :offset-assert 704) + (player-bonk-timeout int64 :offset-assert 704) (water-anim water-anim :offset-assert 712) (player-contact basic :offset-assert 716) (player-impulse collide-shape-prim-mesh :offset-assert 720) @@ -735,10 +735,7 @@ (('bonk) (when (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) - ) + (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) (the-as int (-> self info player-force-timeout)) ) (set! (-> self player-bonk-timeout) (-> *display* base-frame-counter)) @@ -787,12 +784,9 @@ ((= (-> arg3 param 1) 'flop) (when (>= - (the-as - int - (- - (-> *display* base-frame-counter) - (-> self player-bonk-timeout) - ) + (- + (-> *display* base-frame-counter) + (-> self player-bonk-timeout) ) (the-as int (-> self info player-force-timeout)) ) diff --git a/test/decompiler/reference/levels/common/ticky_REF.gc b/test/decompiler/reference/levels/common/ticky_REF.gc index e8c1aae4a8..431f02ac92 100644 --- a/test/decompiler/reference/levels/common/ticky_REF.gc +++ b/test/decompiler/reference/levels/common/ticky_REF.gc @@ -3,10 +3,10 @@ ;; definition of type ticky (deftype ticky (structure) - ((delay-til-ramp uint64 :offset-assert 0) - (delay-til-timeout uint64 :offset-assert 8) - (starting-time uint64 :offset-assert 16) - (last-tick-time uint64 :offset-assert 24) + ((delay-til-ramp int64 :offset-assert 0) + (delay-til-timeout int64 :offset-assert 8) + (starting-time int64 :offset-assert 16) + (last-tick-time int64 :offset-assert 24) ) :method-count-assert 12 :size-assert #x20 @@ -32,9 +32,12 @@ ;; INFO: Return type mismatch int vs none. (defmethod sleep ticky ((obj ticky) (arg0 uint)) (set! (-> obj starting-time) (-> *display* base-frame-counter)) - (set! (-> obj delay-til-timeout) arg0) - (set! (-> obj delay-til-ramp) (max 0 (the-as int (+ arg0 -1200)))) - (set! (-> obj last-tick-time) (the-as uint 0)) + (set! (-> obj delay-til-timeout) (the-as int arg0)) + (set! + (-> obj delay-til-ramp) + (the-as int (max 0 (the-as int (+ arg0 -1200)))) + ) + (set! (-> obj last-tick-time) 0) 0 (none) ) @@ -44,7 +47,7 @@ (let ((gp-0 #f)) (let ((v1-2 (- (-> *display* base-frame-counter) (-> obj starting-time)))) (cond - ((>= (the-as int v1-2) (the-as int (-> obj delay-til-timeout))) + ((>= v1-2 (-> obj delay-til-timeout)) (set! gp-0 #t) ) (else @@ -53,7 +56,7 @@ (fmin 1.0 (/ - (the float (max 0 (the-as int (- v1-2 (-> obj delay-til-ramp))))) + (the float (max 0 (- v1-2 (-> obj delay-til-ramp)))) (the float (- (-> obj delay-til-timeout) (-> obj delay-til-ramp))) ) ) @@ -61,13 +64,7 @@ (v1-7 (the int (lerp 105.0 41.0 f0-1))) ) (when - (>= - (the-as - int - (- (-> *display* base-frame-counter) (-> obj last-tick-time)) - ) - v1-7 - ) + (>= (- (-> *display* base-frame-counter) (-> obj last-tick-time)) v1-7) (set! (-> obj last-tick-time) (-> *display* base-frame-counter)) (sound-play-by-name (static-sound-name "stopwatch") @@ -90,11 +87,7 @@ ;; definition for method 10 of type ticky (defmethod reached-delay? ticky ((obj ticky) (arg0 uint)) (>= - (the-as int (- (-> *display* base-frame-counter) (-> obj starting-time))) + (- (-> *display* base-frame-counter) (-> obj starting-time)) (the-as int arg0) ) ) - - - - diff --git a/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc b/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc index 52dcef9bc4..0626332046 100644 --- a/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc +++ b/test/decompiler/reference/levels/misty/misty-warehouse_REF.gc @@ -101,11 +101,7 @@ ) (camera-change-to "camera-160" 150 #f) (let ((gp-0 (-> *display* base-frame-counter))) - (until - (>= - (the-as int (- (-> *display* base-frame-counter) gp-0)) - 900 - ) + (until (>= (- (-> *display* base-frame-counter) gp-0) 900) (suspend) ) ) @@ -141,9 +137,12 @@ ) (save-reminder gp-0 (logior v1-1 2) 0) ) - (set! (-> self state-time) (-> *display* base-frame-counter)) + (set! + (-> self state-time) + (the-as seconds (-> *display* base-frame-counter)) + ) (let ((gp-1 (-> *display* base-frame-counter))) - (until (>= (the-as int (- (-> *display* base-frame-counter) gp-1)) 300) + (until (>= (- (-> *display* base-frame-counter) gp-1) 300) (suspend) ) ) diff --git a/test/decompiler/reference/levels/village1/explorer_REF.gc b/test/decompiler/reference/levels/village1/explorer_REF.gc index d6f6334cf8..eb1c3c43d9 100644 --- a/test/decompiler/reference/levels/village1/explorer_REF.gc +++ b/test/decompiler/reference/levels/village1/explorer_REF.gc @@ -434,20 +434,14 @@ (v1-69 (the-as number (logior #x3f800000 v1-68))) ) (< - (the-as - int - (- - s5-0 - (the-as - uint - (the - int - (* f30-1 (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-69))))) - ) - ) + (- + s5-0 + (the + int + (* f30-1 (+ f28-0 (* f26-0 (+ -1.0 (the-as float v1-69))))) ) ) - (the-as int gp-1) + gp-1 ) ) (suspend) @@ -514,23 +508,17 @@ (v1-105 (the-as number (logior #x3f800000 v1-104))) ) (< - (the-as - int - (- - s5-1 - (the-as - uint - (the - int - (* - f30-2 - (+ f28-1 (* f26-1 (+ -1.0 (the-as float v1-105)))) - ) - ) + (- + s5-1 + (the + int + (* + f30-2 + (+ f28-1 (* f26-1 (+ -1.0 (the-as float v1-105)))) ) ) ) - (the-as int gp-2) + gp-2 ) ) (suspend) @@ -644,23 +632,17 @@ (v1-165 (the-as number (logior #x3f800000 v1-164))) ) (< - (the-as - int - (- - s5-2 - (the-as - uint - (the - int - (* - f30-3 - (+ f28-2 (* f26-2 (+ -1.0 (the-as float v1-165)))) - ) - ) + (- + s5-2 + (the + int + (* + f30-3 + (+ f28-2 (* f26-2 (+ -1.0 (the-as float v1-165)))) ) ) ) - (the-as int gp-3) + gp-3 ) ) (suspend) @@ -808,23 +790,14 @@ (v1-238 (the-as number (logior #x3f800000 v1-237))) ) (< - (the-as - int - (- - s5-3 - (the-as - uint - (the - int - (* - f30-4 - (+ f28-3 (* f26-3 (+ -1.0 (the-as float v1-238)))) - ) - ) - ) + (- + s5-3 + (the + int + (* f30-4 (+ f28-3 (* f26-3 (+ -1.0 (the-as float v1-238))))) ) ) - (the-as int gp-4) + gp-4 ) ) (suspend) @@ -884,23 +857,14 @@ (v1-269 (the-as number (logior #x3f800000 v1-268))) ) (< - (the-as - int - (- - s5-4 - (the-as - uint - (the - int - (* - f30-5 - (+ f28-4 (* f26-4 (+ -1.0 (the-as float v1-269)))) - ) - ) - ) + (- + s5-4 + (the + int + (* f30-5 (+ f28-4 (* f26-4 (+ -1.0 (the-as float v1-269))))) ) ) - (the-as int gp-5) + gp-5 ) ) (suspend) @@ -957,23 +921,14 @@ (v1-302 (the-as number (logior #x3f800000 v1-301))) ) (< - (the-as - int - (- - s5-5 - (the-as - uint - (the - int - (* - f30-6 - (+ f28-5 (* f26-5 (+ -1.0 (the-as float v1-302)))) - ) - ) - ) + (- + s5-5 + (the + int + (* f30-6 (+ f28-5 (* f26-5 (+ -1.0 (the-as float v1-302))))) ) ) - (the-as int gp-6) + gp-6 ) ) (suspend) diff --git a/test/decompiler/reference/levels/village1/sage_REF.gc b/test/decompiler/reference/levels/village1/sage_REF.gc index 8b2f0f13a2..f39ca1d097 100644 --- a/test/decompiler/reference/levels/village1/sage_REF.gc +++ b/test/decompiler/reference/levels/village1/sage_REF.gc @@ -630,34 +630,37 @@ (set-setting! *setting-control* pp 'music-volume-movie 'abs 0.0 0) (copy-settings-from-target! *setting-control*) (close-status! (-> obj tasks) (task-status need-reward-speech)) - (let* ((s5-2 (get-process *default-dead-pool* manipy #x4000)) - (v1-41 (when s5-2 - (let ((t9-15 (method-of-type manipy activate))) - (t9-15 - (the-as manipy s5-2) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s5-2 - manipy-init - (-> obj root trans) - (-> obj entity) - *assistant-sg* - #f - ) - (-> s5-2 ppointer) - ) - ) - ) - (set! - (-> obj assistant) - (new 'static 'handle :process v1-41 :pid (-> v1-41 0 pid)) + (let ((s5-2 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj assistant) (ppointer->handle (when s5-2 + (let + ((t9-15 + (method-of-type + manipy + activate + ) + ) + ) + (t9-15 + (the-as manipy s5-2) + obj + 'manipy + (the-as pointer #x70004000) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s5-2 + manipy-init + (-> obj root trans) + (-> obj entity) + *assistant-sg* + #f + ) + (-> s5-2 ppointer) + ) + ) ) ) (let ((a1-16 (new 'stack-no-clear 'event-message-block))) diff --git a/test/decompiler/reference/levels/village2/warrior_REF.gc b/test/decompiler/reference/levels/village2/warrior_REF.gc index 4f7fd212a8..c144c5ff96 100644 --- a/test/decompiler/reference/levels/village2/warrior_REF.gc +++ b/test/decompiler/reference/levels/village2/warrior_REF.gc @@ -177,23 +177,7 @@ (set! (-> s5-1 from) pp) (set! (-> s5-1 num-params) 1) (set! (-> s5-1 message) 'clone) - (let* ((a0-10 obj) - (v1-19 (if a0-10 - (-> a0-10 ppointer) - ) - ) - ) - (set! - (-> s5-1 param 0) - (the-as - uint - (logior - (shl (-> v1-19 0 pid) 32) - (new 'static 'handle :process v1-19) - ) - ) - ) - ) + (set! (-> s5-1 param 0) (the-as uint (process->handle obj))) (send-event-function (-> (entity-by-type allpontoons) extra process) s5-1 diff --git a/test/decompiler/reference/levels/village_common/oracle_REF.gc b/test/decompiler/reference/levels/village_common/oracle_REF.gc index 38255acb0b..e48d48e835 100644 --- a/test/decompiler/reference/levels/village_common/oracle_REF.gc +++ b/test/decompiler/reference/levels/village_common/oracle_REF.gc @@ -665,17 +665,24 @@ gp-0 ) ) + (a1-1 (if v1-1 + (-> + (the-as + collide-shape + v1-1 + ) + root-prim + prim-core + ) + (-> self root trans) + ) + ) ) - (if v1-1 - (-> - (the-as collide-shape v1-1) - root-prim - prim-core - ) - (-> self root trans) + (dummy-11 + (-> self part) + (the-as vector a1-1) ) ) - ((method-of-object (-> self part) dummy-11)) 0 (none) ) @@ -690,34 +697,42 @@ ) ) (vector<-cspace! s4-0 (-> obj node-list data 5)) - (let* ((s3-0 (get-process *default-dead-pool* manipy #x4000)) - (v1-13 (when s3-0 - (let ((t9-8 (method-of-type manipy activate))) - (t9-8 - (the-as manipy s3-0) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s3-0 - manipy-init - s4-0 - (-> obj entity) - *fuel-cell-sg* - (new 'static 'vector :w 4915.2) - ) - (-> s3-0 ppointer) - ) - ) - ) - (set! - (-> obj right-eye-cell) - (new 'static 'handle :process v1-13 :pid (-> v1-13 0 pid)) + (let ((s3-0 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj right-eye-cell) (ppointer->handle (when s3-0 + (let + ((t9-8 + (method-of-type + manipy + activate + ) + ) + ) + (t9-8 + (the-as manipy s3-0) + obj + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s3-0 + manipy-init + s4-0 + (-> obj entity) + *fuel-cell-sg* + (new 'static 'vector + :w 4915.2 + ) + ) + (-> s3-0 ppointer) + ) + ) ) ) (let ((a1-9 (new 'stack-no-clear 'event-message-block))) @@ -730,9 +745,10 @@ uint (lambda :behavior oracle () - (let ((v0-0 (dummy-9 (-> *part-group-id-table* 63) self))) - (set! (-> self part) (the-as sparticle-launch-control v0-0)) - v0-0 + (let + ((v0-0 (create-launch-control (-> *part-group-id-table* 63) self))) + (set! (-> self part) v0-0) + (the-as sparticle-launch-group v0-0) ) ) ) @@ -755,34 +771,42 @@ ) ) (vector<-cspace! s4-0 (-> obj node-list data 6)) - (let* ((s3-1 (get-process *default-dead-pool* manipy #x4000)) - (v1-33 (when s3-1 - (let ((t9-15 (method-of-type manipy activate))) - (t9-15 - (the-as manipy s3-1) - obj - 'manipy - (the-as pointer #x70004000) - ) - ) - ((the-as - (function process function object object object object object) - run-function-in-process - ) - s3-1 - manipy-init - s4-0 - (-> obj entity) - *fuel-cell-sg* - (new 'static 'vector :w 4915.2) - ) - (-> s3-1 ppointer) - ) - ) - ) - (set! - (-> obj left-eye-cell) - (new 'static 'handle :process v1-33 :pid (-> v1-33 0 pid)) + (let ((s3-1 (get-process *default-dead-pool* manipy #x4000))) + (set! (-> obj left-eye-cell) (ppointer->handle (when s3-1 + (let + ((t9-15 + (method-of-type + manipy + activate + ) + ) + ) + (t9-15 + (the-as manipy s3-1) + obj + 'manipy + (the-as + pointer + #x70004000 + ) + ) + ) + ((the-as + (function process function object object object object object) + run-function-in-process + ) + s3-1 + manipy-init + s4-0 + (-> obj entity) + *fuel-cell-sg* + (new 'static 'vector + :w 4915.2 + ) + ) + (-> s3-1 ppointer) + ) + ) ) ) (let ((a1-16 (new 'stack-no-clear 'event-message-block))) @@ -795,9 +819,10 @@ uint (lambda :behavior oracle () - (let ((v0-0 (dummy-9 (-> *part-group-id-table* 63) self))) - (set! (-> self part) (the-as sparticle-launch-control v0-0)) - v0-0 + (let + ((v0-0 (create-launch-control (-> *part-group-id-table* 63) self))) + (set! (-> self part) v0-0) + (the-as sparticle-launch-group v0-0) ) ) ) diff --git a/test/decompiler/test_FormExpressionBuild2.cpp b/test/decompiler/test_FormExpressionBuild2.cpp index 4b8433c069..bbea3252b0 100644 --- a/test/decompiler/test_FormExpressionBuild2.cpp +++ b/test/decompiler/test_FormExpressionBuild2.cpp @@ -201,7 +201,7 @@ TEST_F(FormRegressionTest, EliminateFloatDeadSet) { " (f0-1 0.0)\n" " (f2-2\n" " (+\n" - " (the float (mod (-> *display* base-frame-counter) v1-0))\n" + " (the float (mod (the-as uint (-> *display* base-frame-counter)) v1-0))\n" " (-> arg0 offset)\n" " )\n" " )\n" diff --git a/test/decompiler/test_gkernel_decomp.cpp b/test/decompiler/test_gkernel_decomp.cpp index de224bd341..d74e508e0b 100644 --- a/test/decompiler/test_gkernel_decomp.cpp +++ b/test/decompiler/test_gkernel_decomp.cpp @@ -540,18 +540,9 @@ TEST_F(FormRegressionTest, RemoveMethod3ProcessTree) { " (format #t \"[~8x] ~A~%\" arg0 (-> arg0 type))\n" " (format #t \"~Tname: ~S~%\" (-> arg0 name))\n" " (format #t \"~Tmask: #x~X~%\" (-> arg0 mask))\n" - " (let\n" - " ((t9-3 format) (a0-4 #t) (a1-3 \"~Tparent: ~A~%\") (v1-0 (-> arg0 parent)))\n" - " (t9-3 a0-4 a1-3 (if v1-0 (-> v1-0 0 self)))\n" - " )\n" - " (let\n" - " ((t9-4 format) (a0-5 #t) (a1-4 \"~Tbrother: ~A~%\") (v1-2 (-> arg0 brother)))\n" - " (t9-4 a0-5 a1-4 (if v1-2 (-> v1-2 0 self)))\n" - " )\n" - " (let\n" - " ((t9-5 format) (a0-6 #t) (a1-5 \"~Tchild: ~A~%\") (v1-4 (-> arg0 child)))\n" - " (t9-5 a0-6 a1-5 (if v1-4 (-> v1-4 0 self)))\n" - " )\n" + " (format #t \"~Tparent: ~A~%\" (ppointer->process (-> arg0 parent)))\n" + " (format #t \"~Tbrother: ~A~%\" (ppointer->process (-> arg0 brother)))\n" + " (format #t \"~Tchild: ~A~%\" (ppointer->process (-> arg0 child)))\n" " arg0\n" " )"; test_with_expr(func, type, expected, false, "process-tree", @@ -932,8 +923,7 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPool) { " daddiu sp, sp, 112"; std::string type = "(function symbol type int int basic dead-pool)"; std::string expected = - "(let\n" - " ((s3-0 (object-new arg0 arg1 (the-as int (-> arg1 size)))))\n" + "(let ((s3-0 (object-new arg0 arg1 (the-as int (-> arg1 size)))))\n" " (set! (-> s3-0 name) arg4)\n" " (set! (-> s3-0 mask) (process-mask process-tree))\n" " (set! (-> s3-0 parent) (the-as (pointer process-tree) #f))\n" @@ -941,14 +931,12 @@ TEST_F(FormRegressionTest, ExprMethod0DeadPool) { " (set! (-> s3-0 child) (the-as (pointer process-tree) #f))\n" " (set! (-> s3-0 self) s3-0)\n" " (set! (-> s3-0 ppointer) (the-as (pointer process) (&-> s3-0 self)))\n" - " (dotimes\n" - " (s2-1 arg2)\n" - " (let\n" - " ((s1-0 (-> s3-0 child))\n" - " (v1-5 ((method-of-type process new) arg0 process (quote dead) arg3))\n" - " )\n" - " (let ((a0-3 v1-5)) (set! (-> s3-0 child) (if a0-3 (-> a0-3 ppointer))))\n" - " (let ((a0-4 s3-0)) (set! (-> v1-5 parent) (if a0-4 (-> a0-4 ppointer))))\n" + " (dotimes (s2-1 arg2)\n" + " (let ((s1-0 (-> s3-0 child))\n" + " (v1-5 ((method-of-type process new) arg0 process 'dead arg3))\n" + " )\n" + " (set! (-> s3-0 child) (process->ppointer v1-5))\n" + " (set! (-> v1-5 parent) (process->ppointer s3-0))\n" " (set! (-> v1-5 pool) s3-0)\n" " (set! (-> v1-5 brother) s1-0)\n" " )\n" @@ -1066,21 +1054,13 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPool) { " (!= arg0 *debug-dead-pool*)\n" " )\n" " (set! s4-0 (get-process *debug-dead-pool* arg1 arg2))\n" - " (when (the-as process s4-0)\n" - " (let ((t9-1 format)\n" - " (a0-2 0)\n" - " (a1-2\n" - " \"WARNING: ~A ~A had to be allocated from the debug pool, because ~A was " - "empty.~%\"\n" - " )\n" - " (a2-1 arg1)\n" - " (v1-6 (the-as object s4-0))\n" - " )\n" - " (t9-1 a0-2 a1-2 a2-1 (if (the-as process v1-6)\n" - " (-> (the-as (pointer process) v1-6) 0 self)\n" - " )\n" - " (-> arg0 name)\n" - " )\n" + " (if (the-as process s4-0)\n" + " (format\n" + " 0\n" + " \"WARNING: ~A ~A had to be allocated from the debug pool, because ~A was empty.~%\"\n" + " arg1\n" + " (ppointer->process (the-as process s4-0))\n" + " (-> arg0 name)\n" " )\n" " )\n" " )\n" @@ -1094,9 +1074,7 @@ TEST_F(FormRegressionTest, ExprMethod14DeadPool) { " 0\n" " \"WARNING: ~A ~A could not be allocated, because ~A was empty.~%\"\n" " arg1\n" - " (if (the-as (pointer process) s4-0)\n" - " (-> (the-as (pointer process) s4-0) 0 self)\n" - " )\n" + " (ppointer->process (the-as (pointer process) s4-0))\n" " (-> arg0 name)\n" " )\n" " (the-as process #f)\n" diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index 436b7123dd..fdbc1ef843 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -99,7 +99,7 @@ const std::unordered_set g_functions_to_skip_compiling = { /// GKERNEL // asm - "(method 10 process)", + "(method 10 process)", "(method 14 dead-pool)", /// GSTATE "enter-state", // stack pointer asm diff --git a/tools/MemoryDumpTool/main.cpp b/tools/MemoryDumpTool/main.cpp index b9a95eb15e..b462391207 100644 --- a/tools/MemoryDumpTool/main.cpp +++ b/tools/MemoryDumpTool/main.cpp @@ -188,6 +188,52 @@ std::unordered_map> find_basics( return result; } +void inspect_process_self(const Ram& ram, + const std::unordered_map>& basics, + const std::unordered_map& types, + const TypeSystem& type_system) { + std::vector sorted_type_names; + for (auto& x : basics) { + sorted_type_names.emplace_back(x.first); + } + std::sort(sorted_type_names.begin(), sorted_type_names.end(), [&](const auto& a, const auto& b) { + return basics.at(a).size() < basics.at(b).size(); + }); + + for (const auto& name : sorted_type_names) { + // first, try looking up the type. + if (!type_system.fully_defined_type_exists(name)) { + continue; + } + + auto type = dynamic_cast(type_system.lookup_type(name)); + if (!type) { + continue; + } + + for (auto& field : type->fields()) { + if (field.name() == "self") { + for (auto base_addr : basics.at(name)) { + int field_addr = base_addr + field.offset(); + if (ram.word_in_memory(field_addr)) { + auto field_val = ram.word(field_addr); + if (base_addr + 4 != field_val) { + fmt::print("Process type {} had mismatched self #x{:x} #x{:x}\n", name, field_val, + base_addr); + if (ram.word_in_memory(field_val - 4)) { + auto type_lookup = types.find(ram.word(field_val - 4)); + if (type_lookup != types.end()) { + fmt::print(" The actual thing had type {}\n", type_lookup->second); + } + } + } + } + } + } + } + } +} + void inspect_basics(const Ram& ram, const std::unordered_map>& basics, const std::unordered_map& types, @@ -438,6 +484,7 @@ int main(int argc, char** argv) { inspect_basics(ram, basics, types, symbol_map, dts.ts, results); inspect_symbols(ram, types, symbol_map); + inspect_process_self(ram, basics, types, dts.ts); if (fs::exists(output_folder / "ee-results.json")) { fs::remove(output_folder / "ee-results.json");