[decompiler] detect res-lump macros (#796)

* support res lump float

* handle data macro

* rest of res macros

* add vi3 to the build system

* missing close paren
This commit is contained in:
water111 2021-08-31 15:01:54 -04:00 committed by GitHub
parent e399a5bd8a
commit c2c6d3ba46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 846 additions and 1018 deletions

View file

@ -37,3 +37,5 @@ constexpr double METER_LENGTH = 4096.0;
constexpr double DEGREES_PER_ROT = 65536.0;
constexpr double DEGREES_LENGTH = DEGREES_PER_ROT / 360.0;
constexpr u64 TICKS_PER_SECOND = 300.0;
constexpr float DEFAULT_RES_TIME = -1000000000.0;

View file

@ -44,6 +44,7 @@ add_library(
IR2/AtomicOpTypeAnalysis.cpp
IR2/bitfields.cpp
IR2/Env.cpp
IR2/ExpressionHelpers.cpp
IR2/Form.cpp
IR2/FormExpressionAnalysis.cpp
IR2/FormStack.cpp

View file

@ -152,7 +152,13 @@ class SimpleAtom {
bool is_int() const { return m_kind == Kind::INTEGER_CONSTANT; };
bool is_int(s64 integer) const { return is_int() && get_int() == integer; }
bool is_sym_ptr() const { return m_kind == Kind::SYMBOL_PTR; };
bool is_sym_ptr(const std::string& str) const {
return m_kind == Kind::SYMBOL_PTR && m_string == str;
}
bool is_sym_val() const { return m_kind == Kind::SYMBOL_VAL; };
bool is_sym_val(const std::string& str) const {
return m_kind == Kind::SYMBOL_VAL && m_string == str;
}
bool is_empty_list() const { return m_kind == Kind::EMPTY_LIST; };
bool is_static_addr() const { return m_kind == Kind::STATIC_ADDRESS; };
Kind get_kind() const { return m_kind; }

View file

@ -0,0 +1,203 @@
#include "ExpressionHelpers.h"
#include "decompiler/IR2/Form.h"
#include "decompiler/IR2/Env.h"
#include "common/goal_constants.h"
namespace decompiler {
FormElement* handle_get_property_value_float(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env) {
assert(forms.size() == 7);
// lump object
// name
// 'interp
// -1000000000.0 = DEFAULT_RES_TIME
// default value
// tag pointer
// *res-static-buf*
// get the res-lump. This can be anything.
Form* lump_object = forms.at(0);
// get the name of the the thing we're looking up. This can be anything.
Form* property_name = forms.at(1);
// get the mode. It must be interp.
auto mode_atom = form_as_atom(forms.at(2));
if (!mode_atom || !mode_atom->is_sym_ptr("interp")) {
fmt::print("fail: bad mode {}\n", forms.at(2)->to_string(env));
return nullptr;
}
// get the time. It must be DEFAULT_RES_TIME
auto lookup_time = forms.at(3)->try_as_element<ConstantFloatElement>();
if (!lookup_time || lookup_time->value() != DEFAULT_RES_TIME) {
fmt::print("fail: bad time {}\n", forms.at(3)->to_string(env));
return nullptr;
}
// get the default value. It can be anything...
Form* default_value = forms.at(4);
// but let's see if it's 0, because that's the default in the macro
auto default_value_float = default_value->try_as_element<ConstantFloatElement>();
if (default_value_float && default_value_float->value() == 0) {
default_value = nullptr;
}
// get the tag pointer. It can be anything...
Form* tag_pointer = forms.at(5);
// but let's see if it's (the-as (pointer res-tag) #f)
if (tag_pointer->to_string(env) == "(the-as (pointer res-tag) #f)") {
tag_pointer = nullptr;
}
// get the buffer. It should be *res-static-buf*
auto buf_atom = form_as_atom(forms.at(6));
if (!buf_atom || !buf_atom->is_sym_val("*res-static-buf*")) {
return nullptr;
}
// (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0))
std::vector<Form*> macro_args;
macro_args.push_back(lump_object);
macro_args.push_back(property_name);
if (default_value) {
macro_args.push_back(pool.form<ConstantTokenElement>(":default"));
macro_args.push_back(default_value);
}
if (tag_pointer) {
macro_args.push_back(pool.form<ConstantTokenElement>(":tag-ptr"));
macro_args.push_back(tag_pointer);
}
GenericOperator op =
GenericOperator::make_function(pool.form<ConstantTokenElement>("res-lump-float"));
return pool.alloc_element<GenericElement>(op, macro_args);
}
namespace {
FormElement* handle_get_property_data_or_structure(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env,
ResLumpMacroElement::Kind kind,
const std::string& expcted_default,
const TypeSpec& default_type) {
// (-> obj entity)
// 'water-anim-fade-dist
// 'interp
// -1000000000.0
// (the-as pointer #f)
// (the-as (pointer res-tag) #f)
// *res-static-buf*
// get the res-lump. This can be anything.
Form* lump_object = forms.at(0);
// get the name of the the thing we're looking up. This can be anything.
Form* property_name = forms.at(1);
// get the mode. It must be interp.
auto mode_atom = form_as_atom(forms.at(2));
if (!mode_atom || !mode_atom->is_sym_ptr("interp")) {
fmt::print("fail data: bad mode {}\n", forms.at(2)->to_string(env));
return nullptr;
}
// get the time. It can be anything, but there's a default.
auto time = forms.at(3);
auto lookup_time = time->try_as_element<ConstantFloatElement>();
if (lookup_time && lookup_time->value() == DEFAULT_RES_TIME) {
time = nullptr;
}
// get the default value. It must be (the-as pointer #f)
Form* default_value = forms.at(4);
// but let's see if it's 0, because that's the default in the macro
if (default_value->to_string(env) != expcted_default) {
fmt::print("fail data: bad default {}\n", default_value->to_string(env));
return nullptr;
}
// get the tag pointer. It can be anything...
Form* tag_pointer = forms.at(5);
// but let's see if it's (the-as (pointer res-tag) #f)
if (tag_pointer->to_string(env) == "(the-as (pointer res-tag) #f)") {
tag_pointer = nullptr;
}
// get the buffer. It should be *res-static-buf*
auto buf_atom = form_as_atom(forms.at(6));
if (!buf_atom || !buf_atom->is_sym_val("*res-static-buf*")) {
return nullptr;
}
return pool.alloc_element<ResLumpMacroElement>(kind, lump_object, property_name,
nullptr, // default, must be #f
tag_pointer, time, default_type);
}
} // namespace
FormElement* handle_get_property_data(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env) {
return handle_get_property_data_or_structure(forms, pool, env, ResLumpMacroElement::Kind::DATA,
"(the-as pointer #f)", TypeSpec("pointer"));
}
FormElement* handle_get_property_struct(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env) {
return handle_get_property_data_or_structure(forms, pool, env, ResLumpMacroElement::Kind::STRUCT,
"#f", TypeSpec("structure"));
}
FormElement* handle_get_property_value(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env) {
// get the res-lump. This can be anything.
Form* lump_object = forms.at(0);
// get the name of the the thing we're looking up. This can be anything.
Form* property_name = forms.at(1);
// get the mode. It must be interp.
auto mode_atom = form_as_atom(forms.at(2));
if (!mode_atom || !mode_atom->is_sym_ptr("interp")) {
fmt::print("fail data: bad mode {}\n", forms.at(2)->to_string(env));
return nullptr;
}
// get the time. It can be anything, but there's a default.
auto time = forms.at(3);
auto lookup_time = time->try_as_element<ConstantFloatElement>();
if (lookup_time && lookup_time->value() == DEFAULT_RES_TIME) {
time = nullptr;
}
// get the default value. It can be whatever.
Form* default_value = forms.at(4);
// but let's see if it's 0, because that's the default in the macro
if (default_value->to_string(env) == "(the-as uint128 0)") {
default_value = nullptr;
}
// get the tag pointer. It can be anything...
Form* tag_pointer = forms.at(5);
// but let's see if it's (the-as (pointer res-tag) #f)
if (tag_pointer->to_string(env) == "(the-as (pointer res-tag) #f)") {
tag_pointer = nullptr;
}
// get the buffer. It should be *res-static-buf*
auto buf_atom = form_as_atom(forms.at(6));
if (!buf_atom || !buf_atom->is_sym_val("*res-static-buf*")) {
return nullptr;
}
return pool.alloc_element<ResLumpMacroElement>(ResLumpMacroElement::Kind::VALUE, lump_object,
property_name, default_value, tag_pointer, time,
TypeSpec("uint128"));
}
} // namespace decompiler

View file

@ -0,0 +1,24 @@
#pragma once
#include <vector>
namespace decompiler {
class FormElement;
class Form;
class Env;
class FormPool;
FormElement* handle_get_property_value_float(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env);
FormElement* handle_get_property_data(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env);
FormElement* handle_get_property_struct(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env);
FormElement* handle_get_property_value(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env);
} // namespace decompiler

View file

@ -2904,6 +2904,135 @@ goos::Object DefstateElement::to_form_internal(const Env& env) const {
return pretty_print::build_list(forms);
}
////////////////////////////////
// ResLumpMacroElement
////////////////////////////////
ResLumpMacroElement::ResLumpMacroElement(Kind kind,
Form* lump_object,
Form* property_name,
Form* default_arg,
Form* tag_ptr,
Form* time,
const TypeSpec& result_type)
: m_kind(kind),
m_lump_object(lump_object),
m_property_name(property_name),
m_default_arg(default_arg),
m_tag_ptr(tag_ptr),
m_time(time),
m_result_type(result_type) {
m_lump_object->parent_element = this;
m_property_name->parent_element = this;
if (m_default_arg) {
m_default_arg->parent_element = this;
}
if (m_tag_ptr) {
m_tag_ptr->parent_element = this;
}
if (m_time) {
m_time->parent_element = this;
}
}
void ResLumpMacroElement::apply(const std::function<void(FormElement*)>& f) {
f(this);
m_lump_object->apply(f);
m_property_name->apply(f);
if (m_default_arg) {
m_default_arg->apply(f);
}
if (m_tag_ptr) {
m_tag_ptr->apply(f);
}
if (m_time) {
m_time->apply(f);
}
}
void ResLumpMacroElement::apply_form(const std::function<void(Form*)>& f) {
m_lump_object->apply_form(f);
m_property_name->apply_form(f);
if (m_default_arg) {
m_default_arg->apply_form(f);
}
if (m_tag_ptr) {
m_tag_ptr->apply_form(f);
}
if (m_time) {
m_time->apply_form(f);
}
}
void ResLumpMacroElement::collect_vars(RegAccessSet& vars, bool recursive) const {
if (recursive) {
m_lump_object->collect_vars(vars, recursive);
m_property_name->collect_vars(vars, recursive);
if (m_default_arg) {
m_default_arg->collect_vars(vars, recursive);
}
if (m_tag_ptr) {
m_tag_ptr->collect_vars(vars, recursive);
}
if (m_time) {
m_time->collect_vars(vars, recursive);
}
}
}
void ResLumpMacroElement::get_modified_regs(RegSet& regs) const {
m_lump_object->get_modified_regs(regs);
m_property_name->get_modified_regs(regs);
if (m_default_arg) {
m_default_arg->get_modified_regs(regs);
}
if (m_tag_ptr) {
m_tag_ptr->get_modified_regs(regs);
}
if (m_time) {
m_time->get_modified_regs(regs);
}
}
goos::Object ResLumpMacroElement::to_form_internal(const Env& env) const {
std::vector<goos::Object> forms;
switch (m_kind) {
case Kind::DATA:
forms.push_back(pretty_print::to_symbol("res-lump-data"));
break;
case Kind::STRUCT:
forms.push_back(pretty_print::to_symbol("res-lump-struct"));
break;
case Kind::VALUE:
forms.push_back(pretty_print::to_symbol("res-lump-value"));
break;
default:
assert(false);
}
forms.push_back(m_lump_object->to_form(env));
forms.push_back(m_property_name->to_form(env));
forms.push_back(pretty_print::to_symbol(m_result_type.print()));
if (m_default_arg) {
forms.push_back(pretty_print::to_symbol(":default"));
forms.push_back(m_default_arg->to_form(env));
}
if (m_tag_ptr) {
forms.push_back(pretty_print::to_symbol(":tag-ptr"));
forms.push_back(m_tag_ptr->to_form(env));
}
if (m_time) {
forms.push_back(pretty_print::to_symbol(":time"));
forms.push_back(m_time->to_form(env));
}
return pretty_print::build_list(forms);
}
////////////////////////////////
// Utilities
////////////////////////////////

View file

@ -1628,6 +1628,38 @@ class DefstateElement : public FormElement {
bool m_is_virtual = false;
};
class ResLumpMacroElement : public FormElement {
public:
enum class Kind { DATA, STRUCT, VALUE, INVALID };
ResLumpMacroElement(Kind kind,
Form* lump_object,
Form* property_name,
Form* default_arg,
Form* tag_ptr,
Form* time,
const TypeSpec& result_type);
goos::Object to_form_internal(const Env& env) const override;
void apply(const std::function<void(FormElement*)>& f) override;
void apply_form(const std::function<void(Form*)>& f) override;
void collect_vars(RegAccessSet& vars, bool recursive) const override;
void update_from_stack(const Env& env,
FormPool& pool,
FormStack& stack,
std::vector<FormElement*>* result,
bool allow_side_effects) override;
void get_modified_regs(RegSet& regs) const override;
void apply_cast(const TypeSpec& new_type) { m_result_type = new_type; }
private:
Kind m_kind = Kind::INVALID;
Form* m_lump_object = nullptr;
Form* m_property_name = nullptr;
Form* m_default_arg = nullptr; // may be null
Form* m_tag_ptr = nullptr; // may be null
Form* m_time = nullptr; // may be null
TypeSpec m_result_type;
};
/*!
* A Form is a wrapper around one or more FormElements.
* This is done for two reasons:
@ -1789,6 +1821,14 @@ class FormPool {
return form;
}
template <typename T, class... Args>
Form* form(Args&&... args) {
auto elt = new T(std::forward<Args>(args)...);
m_elements.emplace_back(elt);
auto form = alloc_single_form(nullptr, elt);
return form;
}
Form* alloc_single_form(FormElement* parent, FormElement* elt) {
auto form = new Form(parent, elt);
m_forms.push_back(form);

View file

@ -8,6 +8,7 @@
#include "decompiler/IR2/bitfields.h"
#include "common/util/BitUtils.h"
#include "common/type_system/state.h"
#include "decompiler/IR2/ExpressionHelpers.h"
/*
* TODO
@ -85,6 +86,12 @@ Form* try_cast_simplify(Form* in,
return in; // no need to cast again, it already has it!
}
auto in_as_reslump = in->try_as_element<ResLumpMacroElement>();
if (in_as_reslump) {
in_as_reslump->apply_cast(new_type);
return in;
}
if (new_type == TypeSpec("meters")) {
auto fc = get_goal_float_constant(in);
@ -554,22 +561,6 @@ void SimpleExpressionElement::update_from_stack_identity(const Env& env,
result->push_back(pool.alloc_element<StringConstantElement>(str));
} else {
// look for a label hint:
/*
auto kv = env.label_types().find(lab.name);
if (kv != env.label_types().end()) {
auto type_name = kv->second.type_name;
// the actual decompilation is deferred until later, once static lambdas are done.
if (type_name == "_auto_") {
result->push_back(pool.alloc_element<DecompiledDataElement>(lab));
} else if (type_name == "_lambda_") {
result->push_back(this);
} else {
result->push_back(pool.alloc_element<DecompiledDataElement>(lab, kv->second));
}
} else {
result->push_back(this);
}
*/
const auto& hint = env.file->label_db->lookup(lab.name);
if (!hint.known) {
throw std::runtime_error(
@ -2935,6 +2926,32 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto type_source_form = match_result.maps.forms.at(type_source);
if (name == "get-property-value-float" && type_source_form->to_string(env) == "res-lump") {
auto as_macro = handle_get_property_value_float(arg_forms, pool, env);
if (as_macro) {
result->push_back(as_macro);
return;
}
} else if (name == "get-property-data" && type_source_form->to_string(env) == "res-lump") {
auto as_macro = handle_get_property_data(arg_forms, pool, env);
if (as_macro) {
result->push_back(as_macro);
return;
}
} else if (name == "get-property-struct" && type_source_form->to_string(env) == "res-lump") {
auto as_macro = handle_get_property_struct(arg_forms, pool, env);
if (as_macro) {
result->push_back(as_macro);
return;
}
} else if (name == "get-property-value" && type_source_form->to_string(env) == "res-lump") {
auto as_macro = handle_get_property_value(arg_forms, pool, env);
if (as_macro) {
result->push_back(as_macro);
return;
}
}
// if the type is the exact type of the argument, we want to build it into a method call
if (type_source_form->to_string(env) == first_arg_type.base_type() && name != "new") {
if (env.dts->ts.should_use_virtual_methods(tp_type.method_from_type(),
@ -2996,6 +3013,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto gop = GenericOperator::make_function(method_op);
result->push_back(pool.alloc_element<GenericElement>(gop, arg_forms));
return;
}
}
@ -5236,6 +5254,15 @@ void DefstateElement::update_from_stack(const Env&,
result->push_back(this);
}
void ResLumpMacroElement::update_from_stack(const Env&,
FormPool&,
FormStack&,
std::vector<FormElement*>* result,
bool) {
mark_popped();
result->push_back(this);
}
void LabelDerefElement::update_from_stack(const Env& env,
FormPool& pool,
FormStack& stack,

View file

@ -603,18 +603,10 @@
// FACT-H
"(method 0 fact-info-enemy)": [
[[3, 92], "gp", "fact-info-enemy"],
[16, "v0", "float"],
[28, "v0", "float"],
[40, "v0", "float"],
[52, "v0", "float"],
[64, "v0", "float"],
[76, "v0", "float"],
[88, "v0", "float"]
[[3, 92], "gp", "fact-info-enemy"]
],
"(method 0 fact-info)": [
[81, "v0", "float"],
//[16, "t9", "(function string none)"],
["_stack_", 16, "res-tag"],
[[32, 43], "v1", "(pointer int32)"],
@ -1872,7 +1864,8 @@
],
"(method 25 water-anim)": [
[[27, 45], "v1", "transform"]
[25, "v0", "(pointer float)"],
["_stack_", 16, "res-tag"]
],
"(method 22 rigid-body-platform)": [
@ -1910,7 +1903,7 @@
],
"(method 22 mud)": [
[[37, 41], "v1", "ripple-control"]
[35, "v0", "(pointer float)"]
],
"(method 11 twister)": [

View file

@ -12,4 +12,5 @@ SCREEN1.USA resources/SCREEN1.USA
0COMMON.TXT out/iso/0COMMON.TXT
5COMMON.TXT out/iso/5COMMON.TXT
0TEST.TXT out/iso/0TEST.TXT
VI1.DGO out/iso/VI1.DGO
VI1.DGO out/iso/VI1.DGO
VI3.DGO out/iso/VI3.DGO

37
goal_src/dgos/vi3.gd Normal file
View file

@ -0,0 +1,37 @@
("VI3.DGO"
("villagep-obs.o" "villagep-obs")
("oracle.o" "oracle")
("village3-part.o" "village3-part")
("village3-obs.o" "village3-obs")
("minecart.o" "minecart")
("miners.o" "miners")
("assistant-village3.o" "assistant-village3")
("sage-village3.o" "sage-village3")
("tpage-1208.go" "tpage-1208")
("tpage-1210.go" "tpage-1210")
("tpage-1209.go" "tpage-1209")
("tpage-1194.go" "tpage-1194")
("assistant-village3-ag.go" "assistant-village3")
("cavegem-ag.go" "cavegem")
("evilbro-village3-ag.go" "evilbro-village3")
("evilsis-village3-ag.go" "evilsis-village3")
("gondola-ag.go" "gondola")
("gondolacables-ag.go" "gondolacables")
("lavaspoutdrip-ag.go" "lavaspoutdrip")
("medres-finalboss-ag.go" "medres-finalboss")
("medres-ogre-ag.go" "medres-ogre")
("medres-ogre2-ag.go" "medres-ogre2")
("medres-ogre3-ag.go" "medres-ogre3")
("minecartsteel-ag.go" "minecartsteel")
("minershort-ag.go" "minershort")
("minertall-ag.go" "minertall")
("oracle-ag-VI3.go" "oracle")
("pistons-ag.go" "pistons")
("sage-village3-ag.go" "sage-village3")
("vil3-bridge-36-ag.go" "vil3-bridge-36")
("village-cam-ag-VI3.go" "village-cam")
("warp-gate-switch-ag-VI1-VI3.go" "warp-gate-switch")
("warpgate-ag.go" "warpgate")
("water-anim-village3-ag.go" "water-anim-village3")
("village3-vis.go" "village3-vis")
)

View file

@ -22,18 +22,7 @@
(set! s3-0 (-> arg0 quat))
)
(else
(set!
s3-0
((method-of-type res-lump get-property-struct)
arg0
arg2
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(set! s3-0 (res-lump-struct arg0 arg2 structure))
)
)
(let ((s2-0 (method-of-type res-lump get-property-struct)))
@ -70,21 +59,10 @@
;; definition for function cam-slave-get-flags
(defun cam-slave-get-flags ((arg0 entity) (arg1 symbol))
(let
((gp-0
((method-of-type res-lump get-property-value)
arg0
arg1
'interp
-1000000000.0
(the-as uint128 0)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s3-0 (method-of-type res-lump get-property-value))
(s2-0 arg0)
)
(let ((gp-0 (res-lump-value arg0 arg1 uint128))
(s3-0 (method-of-type res-lump get-property-value))
(s2-0 arg0)
)
(format (clear *res-key-string*) "~S~S" arg1 '-on)
(let
((s3-1
@ -122,20 +100,9 @@
;; definition for function cam-slave-get-float
(defun cam-slave-get-float ((arg0 entity) (arg1 symbol) (arg2 float))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
arg1
'interp
-1000000000.0
arg2
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s4-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 arg1 :default arg2))
(s4-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" arg1 '-offset)
(+
f30-0
@ -154,20 +121,9 @@
;; definition for function cam-slave-get-fov
(defun cam-slave-get-fov ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'fov
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'fov))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'fov '-offset)
(let
((f0-0
@ -192,20 +148,9 @@
;; definition for function cam-slave-get-intro-step
(defun cam-slave-get-intro-step ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'intro-time
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'intro-time))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'intro-time '-offset)
(let
((f0-1
@ -233,20 +178,9 @@
;; definition for function cam-slave-get-interp-time
(defun cam-slave-get-interp-time ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'interpTime
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'interpTime))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'interpTime '-offset)
(let
((f0-1
@ -315,26 +249,10 @@
((not arg0)
(the-as state #f)
)
(((method-of-type res-lump get-property-struct)
arg0
'pivot
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
((res-lump-struct arg0 'pivot structure)
cam-circular
)
(((method-of-type res-lump get-property-struct)
arg0
'align
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
((res-lump-struct arg0 'align structure)
cam-standoff-read-entity
)
((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0)
@ -416,7 +334,7 @@
;; definition for function third-power
(defun third-power ((arg0 float))
(* (* arg0 arg0) arg0)
(* arg0 arg0 arg0)
)
;; definition for function parameter-ease-sqr-clamp
@ -474,17 +392,7 @@
(the-as uint (cam-slave-get-flags arg1 (string->symbol *res-key-string*)))
)
(let
((s3-2
((method-of-type res-lump get-property-data)
arg1
arg0
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
((s3-2 (res-lump-data arg1 arg0 pointer))
(s0-1 (method-of-type res-lump get-property-struct))
)
(set! sv-32 format)
@ -649,10 +557,7 @@
(- (-> obj summed-len) (-> obj point arg0 tp-length))
)
(vector-!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 arg0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0)))
(the-as vector (-> obj point v1-11))
(the-as vector (-> obj point arg0))
)
@ -660,10 +565,7 @@
(set!
(-> obj point arg0 tp-length)
(vector-normalize-ret-len!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 arg0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 arg0)))
1.0
)
)
@ -758,16 +660,13 @@
(vector-dot
(the-as
vector
(+
(the-as uint (-> obj point 0 direction))
(the-as uint (* 48 v1-15))
)
(+ (the-as uint (-> obj point 0 direction)) (* 48 v1-15))
)
(the-as
vector
(+
(the-as uint (the-as vector (-> obj point 0 direction)))
(the-as uint (* 48 a0-14))
(* 48 a0-14)
)
)
)
@ -822,16 +721,13 @@
(vector-dot
(the-as
vector
(+
(the-as uint (-> obj point 0 direction))
(the-as uint (* 48 s4-1))
)
(+ (the-as uint (-> obj point 0 direction)) (* 48 s4-1))
)
(the-as
vector
(+
(the-as uint (the-as vector (-> obj point 0 direction)))
(the-as uint (* 48 v1-11))
(* 48 v1-11)
)
)
)
@ -862,20 +758,14 @@
(s2-0 (-> obj end-point))
)
(vector-!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s2-0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0)))
arg0
(the-as vector (-> obj point s2-0))
)
(set!
(-> obj point s2-0 tp-length)
(vector-normalize-ret-len!
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s2-0)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s2-0)))
1.0
)
)
@ -1035,18 +925,12 @@
(let ((s1-0 (-> obj point v1-8 next)))
(vector-!
s2-0
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 s1-0)))
)
(the-as
vector
(+ (the-as uint (-> obj point 0 direction)) (the-as uint (* 48 v1-8)))
)
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 s1-0)))
(the-as vector (+ (the-as uint (-> obj point 0 direction)) (* 48 v1-8)))
)
(let* ((f0-4 (vector-normalize-ret-len! s2-0 1.0))
(f0-5 (* 0.5 f0-4))
(f26-0 (* (* (fmin 1.0 f0-5) f30-0) (vector-dot arg0 s2-0)))
(f26-0 (* (fmin 1.0 f0-5) f30-0 (vector-dot arg0 s2-0)))
)
(let ((f2-7 (vector-dot s2-0 s3-0)))
(cond
@ -1876,7 +1760,7 @@
(set! f0-3 1.0)
)
)
(let ((f30-0 (* (* 364.0889 (-> *display* time-adjust-ratio)) f0-3)))
(let ((f30-0 (* 364.0889 (-> *display* time-adjust-ratio) f0-3)))
(matrix->quaternion s4-0 arg0)
(matrix->quaternion s2-0 arg3)
(quaternion-conjugate! gp-0 s4-0)
@ -1886,8 +1770,8 @@
(quaternion-negate! gp-0 gp-0)
)
(let ((f28-0 (acos (-> gp-0 w))))
(if (< (* (* 0.25 (-> *display* time-adjust-ratio)) f28-0) f30-0)
(set! f30-0 (* (* 0.25 (-> *display* time-adjust-ratio)) f28-0))
(if (< (* 0.25 (-> *display* time-adjust-ratio) f28-0) f30-0)
(set! f30-0 (* 0.25 (-> *display* time-adjust-ratio) f28-0))
)
(cond
((< (-> gp-0 w) 0.9999999)
@ -2054,7 +1938,6 @@
)
)
)
; ;; definition for function slave-set-rotation!
; ;; INFO: Return type mismatch int vs none.
; ;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3]

View file

@ -442,33 +442,7 @@ This is updated from the entity system used in Crash 2, which had most of these
default
)
(defmacro res-lump-data (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0))
"Helper macro to get data from a res-lump without interpolation."
`(the-as ,type ((method-of-type res-lump get-property-data)
,lump
,name
'interp
,time
(the-as pointer #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-data-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
"Helper macro to get start of data from a res-lump."
`(the-as ,type ((method-of-type res-lump get-property-data)
,lump
,name
'exact
0.0
(the-as pointer #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmethod get-property-struct res-lump ((obj res-lump) (name symbol) (mode symbol) (time float) (default structure) (tag-addr (pointer res-tag)) (buf-addr pointer))
"Returns a given struct property's value at a specific time stamp, or default on error.
@ -499,31 +473,7 @@ This is updated from the entity system used in Crash 2, which had most of these
default
)
(defmacro res-lump-struct (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
`(the-as ,type ((method-of-type res-lump get-property-struct)
,lump
,name
'interp
-1000000000.0
(the-as structure #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-struct-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
`(the-as ,type ((method-of-type res-lump get-property-struct)
,lump
,name
'exact
0.0
(the-as structure #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmethod get-property-value res-lump ((obj res-lump) (name symbol) (mode symbol) (time float) (default uint128) (tag-addr (pointer res-tag)) (buf-addr pointer))
"Returns a given value property's value at a specific time stamp, or default on error.
@ -578,19 +528,6 @@ This is updated from the entity system used in Crash 2, which had most of these
default
)
(defmacro res-lump-value (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
"Helper macro to get a value from a res-lump with no interpolation."
`(the-as ,type ((method-of-type res-lump get-property-value)
,lump
,name
'interp
-1000000000.0
(the-as uint128 0)
,tag-ptr
*res-static-buf*
)
)
)
(defmethod get-property-value-float res-lump ((obj res-lump) (name symbol) (mode symbol) (time float) (default float) (tag-addr (pointer res-tag)) (buf-addr pointer))
"same as get-property-value but float type is checked first?"
@ -641,19 +578,6 @@ This is updated from the entity system used in Crash 2, which had most of these
default
)
(defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0))
"Helper macro to get a float from a res-lump with no interpolation."
`((method-of-type res-lump get-property-value-float)
,lump
,name
'interp
-1000000000.0
,default
,tag-ptr
*res-static-buf*
)
)
(defmethod sort! res-lump ((obj res-lump))
"Sort all tags based on name, then key-frame."
@ -999,3 +923,89 @@ This is updated from the entity system used in Crash 2, which had most of these
(define *res-static-buf* (malloc 'global 128))
;; There are four common types of lookup:
;; data. This is something like (pointer int32) or (inline-array vector), it should have a size.
;; struct. This will get a GOAL struct or basic. Like a string.
;; value. This will get a value. Possibly even a 128-bit value, though this does not appear to work properly.
;; float. This will get a float. If the value stored is an int, it will converted to a float.
(defmacro res-lump-data (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0))
"Helper macro to get data from a res-lump without interpolation."
`(the-as ,type ((method-of-type res-lump get-property-data)
,lump
,name
'interp
,time
(the-as pointer #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-data-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
"Helper macro to get start of data from a res-lump."
`(the-as ,type ((method-of-type res-lump get-property-data)
,lump
,name
'exact
0.0
(the-as pointer #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-struct (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
`(the-as ,type ((method-of-type res-lump get-property-struct)
,lump
,name
'interp
-1000000000.0
(the-as structure #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-struct-exact (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
`(the-as ,type ((method-of-type res-lump get-property-struct)
,lump
,name
'exact
0.0
(the-as structure #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-value (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default (the-as uint128 0)))
"Helper macro to get a value from a res-lump with no interpolation."
`(the-as ,type ((method-of-type res-lump get-property-value)
,lump
,name
'interp
-1000000000.0
,default
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0))
"Helper macro to get a float from a res-lump with no interpolation."
`((method-of-type res-lump get-property-value-float)
,lump
,name
'interp
-1000000000.0
,default
,tag-ptr
*res-static-buf*
)
)

View file

@ -27,20 +27,7 @@
(set! sv-16 (new 'static 'res-tag))
;; look up the reference
(let ((v1-1 (the-as (pointer uint32)
(get-property-data
lump
name
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
)
(let ((v1-1 (res-lump-data lump name (pointer uint32) :tag-ptr (& sv-16))))
(the-as entity-actor
;; check in range, and lookup succesful
(when (and v1-1 (< idx (the-as int (-> sv-16 elt-count))))
@ -59,15 +46,7 @@
This works on more than just next/prev."
(local-vars (tag res-tag))
(set! tag (new 'static 'res-tag))
(if (get-property-data
res
name
'interp
-1000000000.0
(the-as pointer #f)
(& tag)
*res-static-buf*
)
(if (res-lump-data res name pointer :tag-ptr (& tag))
(the-as int (-> tag elt-count))
0
)

View file

@ -297,16 +297,7 @@
;; now construct the engine, looking up the size from the res-lump.
(set! (-> entity-nav-mesh user-list)
(new 'process-level-heap 'engine 'nav-engine
(the int ((method-of-type res-lump get-property-value)
(the-as res-lump ent)
'nav-max-users
'interp
-1000000000.0
(the-as uint128 32)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-value ent 'nav-max-users int :default (the-as uint128 32))
)
)
@ -346,54 +337,34 @@
)
)
;; todo fix up this
(defmethod new nav-control ((allocation symbol) (type-to-make type) (shape collide-shape) (sphere-count int) (nearest-y-threshold-default float))
(with-pp
(let ((obj (object-new allocation type-to-make
(the-as int (+ (-> type-to-make size) (* sphere-count 16)))
)
)
)
;; check for alloc fail.
(when (zero? obj)
(go process-drawable-art-error "memory")
(set! obj (the-as nav-control 0))
(goto cfg-4)
)
;; set up fields
(set! (-> obj max-spheres) sphere-count)
(set! (-> obj flags) (nav-control-flags bit8 bit13))
;; connect things
(set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj))
;; get the nearest-y-threshold
(let ((ent (-> shape process entity)))
(set! (-> obj nearest-y-threshold)
((method-of-type res-lump get-property-value-float)
(the-as res-lump ent)
'nearest-y-threshold
'interp
-1000000000.0
nearest-y-threshold-default
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set! (-> obj shape) shape)
(set! (-> obj process) (-> shape process))
(set! (-> obj gap-event) #f)
(set! (-> obj current-poly) #f)
(set! (-> obj next-poly) #f)
(set! (-> obj target-poly) #f)
(set! (-> obj user-poly) #f)
(set! (-> obj portal 0) #f)
(set! (-> obj portal 1) #f)
(set! (-> obj nav-cull-radius) 40960.0)
(label cfg-4)
(the-as nav-control obj)
)
(let ((obj (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* sphere-count 16))))))
(when (zero? obj)
(go process-drawable-art-error "memory")
(set! obj (the-as nav-control 0))
(goto cfg-4)
)
(set! (-> obj max-spheres) sphere-count)
(set! (-> obj flags) (nav-control-flags bit8 bit13))
(set! (-> obj mesh) (nav-mesh-connect (-> shape process) shape obj))
(let ((ent (-> shape process entity)))
(set! (-> obj nearest-y-threshold)
(res-lump-float ent 'nearest-y-threshold :default nearest-y-threshold-default)
)
)
(set! (-> obj shape) shape)
(set! (-> obj process) (-> shape process))
(set! (-> obj gap-event) #f)
(set! (-> obj current-poly) #f)
(set! (-> obj next-poly) #f)
(set! (-> obj target-poly) #f)
(set! (-> obj user-poly) #f)
(set! (-> obj portal 0) #f)
(set! (-> obj portal 1) #f)
(set! (-> obj nav-cull-radius) 40960.0)
(label cfg-4)
(the-as nav-control obj)
)
)
@ -425,17 +396,6 @@
the res-lump."
(the-as
symbol
(or (-> arg0 nav-mesh) ;; has it loaded already
;; has it in the res-lump
((method-of-type res-lump get-property-struct)
arg0
'nav-mesh-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(or (-> arg0 nav-mesh) (res-lump-struct arg0 'nav-mesh-actor structure))
)
)

View file

@ -80,18 +80,7 @@
;; look up the curve data
(set! tag (new 'static 'res-tag))
(let ((data ((method-of-type res-lump get-property-data)
(the-as res-lump ent)
name
'interp
time
(the-as pointer #f)
(& tag)
*res-static-buf*
)
)
)
(let ((data (res-lump-data ent name pointer :tag-ptr (& tag) :time time)))
(cond
(data
;; success, we got some data

View file

@ -106,17 +106,7 @@
the specified defaults."
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let ((v1-1 ((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(let ((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
;; res lookup succeeded, we should have two values: a period (not yet in seconds) and a phase.
@ -143,17 +133,7 @@
If res lookup totally fails, will return #f and use all defaults."
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let ((v1-1 ((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(let ((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
;; we may not get all the parameters
@ -187,17 +167,7 @@
"Load and setup a sync-info-paused."
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let ((v1-1 ((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(let ((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
(if (>= (-> sv-16 elt-count) (the-as uint 4))

View file

@ -210,6 +210,7 @@
"out/iso/KERNEL.CGO"
"out/iso/GAME.CGO"
"out/iso/VI1.DGO"
"out/iso/VI3.DGO"
)
@ -287,6 +288,51 @@
"village1-vis"
)
;;;;;;;;;;;;;;;;;;;;;
;; Village 3
;;;;;;;;;;;;;;;;;;;;;
;; the definition for the DGO file.
(cgo "VI3.DGO""vi3.gd")
;; the code
(goal-src-sequence
"levels/"
:deps ;; no idea what these depend on, make it depend on the whole engine
("out/obj/default-menu.o")
"village3/village3-part.gc"
"village3/village3-obs.gc"
"village3/minecart.gc"
"village3/miners.gc"
"village3/assistant-village3.gc"
"village3/sage-village3.gc"
)
(copy-textures 1208 1210 1209 1194)
(copy-gos
"assistant-village3-ag"
"cavegem-ag"
"evilbro-village3-ag"
"evilsis-village3-ag"
"gondola-ag"
"gondolacables-ag"
"lavaspoutdrip-ag"
"medres-finalboss-ag"
"medres-ogre-ag"
"medres-ogre2-ag"
"medres-ogre3-ag"
"minecartsteel-ag"
"minershort-ag"
"minertall-ag"
"oracle-ag-VI3"
"pistons-ag"
"sage-village3-ag"
"vil3-bridge-36-ag"
"village-cam-ag-VI3"
"water-anim-village3-ag"
"village3-vis"
)
;;;;;;;;;;;;;;;;;;;;;
;; Game Engine Code

View file

@ -607,14 +607,12 @@
(set! (-> obj button-id) -1)
(let
((v1-4
((method-of-type res-lump get-property-value)
(res-lump-value
(-> obj entity)
'extra-id
'interp
-1000000000.0
uint128
:default
(the-as uint128 -1)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
@ -624,24 +622,8 @@
)
(when
(or
(get-property-struct
arg0
'next-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(get-property-struct
arg0
'prev-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(res-lump-struct arg0 'next-actor structure)
(res-lump-struct arg0 'prev-actor structure)
)
(set! (-> obj link) (new 'process 'actor-link-info obj))
(if (< (-> obj button-id) 0)
@ -661,18 +643,7 @@
(set! (-> obj down?) v1-16)
)
(set! (-> obj notify-actor) (entity-actor-lookup arg0 'alt-actor 0))
(set!
(-> obj timeout)
(get-property-value-float
arg0
'timeout
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(set! (-> obj timeout) (res-lump-float arg0 'timeout))
(if (not (-> obj spawned-by-other?))
(nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
)

View file

@ -1838,62 +1838,30 @@
;; definition for method 25 of type water-anim
;; Used lq/sq
(defmethod TODO-RENAME-25 water-anim ((obj water-anim))
(local-vars (sv-16 int))
(local-vars (sv-16 res-tag))
(set! (-> obj play-ambient-sound?) #t)
(set!
(-> obj look)
(the-as
int
((method-of-type res-lump get-property-value)
(-> obj entity)
'look
'interp
-1000000000.0
(the-as uint128 -1)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(set! (-> obj look)
(res-lump-value (-> obj entity) 'look int :default (the-as uint128 -1))
)
(set! sv-16 0)
(set! sv-16 (new 'static 'res-tag))
(let
((v1-3
(the-as
object
((method-of-type res-lump get-property-data)
(-> obj entity)
'trans-offset
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) (& sv-16))
*res-static-buf*
)
(res-lump-data
(-> obj entity)
'trans-offset
(pointer float)
:tag-ptr
(& sv-16)
)
)
)
(when (the-as pointer v1-3)
(+! (-> obj root trans x) (-> (the-as transform v1-3) trans x))
(+! (-> obj root trans y) (-> (the-as transform v1-3) trans y))
(set!
(-> (the-as transform (-> obj root)) rot y)
(+ (-> obj root trans z) (-> (the-as transform v1-3) trans z))
)
(when v1-3
(+! (-> obj root trans x) (-> v1-3 0))
(+! (-> obj root trans y) (-> v1-3 1))
(+! (-> obj root trans z) (-> v1-3 2))
)
)
(let
((f0-6
((method-of-type res-lump get-property-value-float)
(-> obj entity)
'rotoffset
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(let ((f0-6 (res-lump-float (-> obj entity) 'rotoffset)))
(if (!= f0-6 0.0)
(quaternion-rotate-y! (-> obj root quat) (-> obj root quat) f0-6)
)

View file

@ -260,15 +260,7 @@
(set!
(-> obj anim-limit)
(*
(get-property-value-float
arg0
'distance
'interp
-1000000000.0
1.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(res-lump-float arg0 'distance :default 1.0)
(the
float
(+

View file

@ -61,29 +61,12 @@
(set! (-> gp-0 waveform) ripple-for-mud)
(let
((v1-9
(the-as
object
((method-of-type res-lump get-property-data)
(-> obj entity)
'water-anim-fade-dist
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-data (-> obj entity) 'water-anim-fade-dist (pointer float))
)
)
(when (the-as pointer v1-9)
(set!
(-> gp-0 close-fade-dist)
(-> (the-as ripple-control v1-9) global-scale)
)
(set!
(-> gp-0 far-fade-dist)
(-> (the-as ripple-control v1-9) last-frame-scale)
)
(when v1-9
(set! (-> gp-0 close-fade-dist) (-> v1-9 0))
(set! (-> gp-0 far-fade-dist) (-> v1-9 1))
)
)
(case (-> obj look)

View file

@ -623,21 +623,7 @@
)
)
(set! (-> obj first-task) (the-as uint (-> arg0 extra perm task)))
(set!
(-> obj second-task)
(the-as
uint
(get-property-value
arg0
'alt-task
'interp
-1000000000.0
(the-as uint128 0)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set! (-> obj second-task) (res-lump-value arg0 'alt-task uint))
(set!
(-> obj tasks)
(get-task-control (the-as game-task (-> obj first-task)))

View file

@ -439,3 +439,58 @@
(defmacro .sra (result in sa)
`(set! ,result (sext32 (sar (logand #xffffffff (the-as int ,in)) ,sa)))
)
(defmacro res-lump-float (lump name &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default 0.0))
"Helper macro to get a float from a res-lump with no interpolation."
`((method-of-type res-lump get-property-value-float)
,lump
,name
'interp
-1000000000.0
,default
,tag-ptr
*res-static-buf*
)
)
(defmacro res-lump-data (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (time -1000000000.0))
"Helper macro to get data from a res-lump without interpolation."
`(the-as ,type ((method-of-type res-lump get-property-data)
,lump
,name
'interp
,time
(the-as pointer #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-struct (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)))
`(the-as ,type ((method-of-type res-lump get-property-struct)
,lump
,name
'interp
-1000000000.0
(the-as structure #f)
,tag-ptr
*res-static-buf*
)
)
)
(defmacro res-lump-value (lump name type &key (tag-ptr (the-as (pointer res-tag) #f)) &key (default (the-as uint128 0)))
"Helper macro to get a value from a res-lump with no interpolation."
`(the-as ,type ((method-of-type res-lump get-property-value)
,lump
,name
'interp
-1000000000.0
,default
,tag-ptr
*res-static-buf*
)
)
)

View file

@ -18,18 +18,7 @@
(set! s3-0 (-> arg0 quat))
)
(else
(set!
s3-0
((method-of-type res-lump get-property-struct)
arg0
arg2
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(set! s3-0 (res-lump-struct arg0 arg2 structure))
)
)
(let ((s2-0 (method-of-type res-lump get-property-struct)))
@ -66,21 +55,10 @@
;; definition for function cam-slave-get-flags
(defun cam-slave-get-flags ((arg0 entity) (arg1 symbol))
(let
((gp-0
((method-of-type res-lump get-property-value)
arg0
arg1
'interp
-1000000000.0
(the-as uint128 0)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s3-0 (method-of-type res-lump get-property-value))
(s2-0 arg0)
)
(let ((gp-0 (res-lump-value arg0 arg1 uint128))
(s3-0 (method-of-type res-lump get-property-value))
(s2-0 arg0)
)
(format (clear *res-key-string*) "~S~S" arg1 '-on)
(let
((s3-1
@ -118,20 +96,9 @@
;; definition for function cam-slave-get-float
(defun cam-slave-get-float ((arg0 entity) (arg1 symbol) (arg2 float))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
arg1
'interp
-1000000000.0
arg2
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s4-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 arg1 :default arg2))
(s4-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" arg1 '-offset)
(+
f30-0
@ -150,20 +117,9 @@
;; definition for function cam-slave-get-fov
(defun cam-slave-get-fov ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'fov
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'fov))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'fov '-offset)
(let
((f0-0
@ -188,20 +144,9 @@
;; definition for function cam-slave-get-intro-step
(defun cam-slave-get-intro-step ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'intro-time
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'intro-time))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'intro-time '-offset)
(let
((f0-1
@ -229,20 +174,9 @@
;; definition for function cam-slave-get-interp-time
(defun cam-slave-get-interp-time ((arg0 entity))
(let
((f30-0
((method-of-type res-lump get-property-value-float)
arg0
'interpTime
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s5-0 (method-of-type res-lump get-property-value-float))
)
(let ((f30-0 (res-lump-float arg0 'interpTime))
(s5-0 (method-of-type res-lump get-property-value-float))
)
(format (clear *res-key-string*) "~S~S" 'interpTime '-offset)
(let
((f0-1
@ -311,26 +245,10 @@
((not arg0)
(the-as state #f)
)
(((method-of-type res-lump get-property-struct)
arg0
'pivot
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
((res-lump-struct arg0 'pivot structure)
cam-circular
)
(((method-of-type res-lump get-property-struct)
arg0
'align
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
((res-lump-struct arg0 'align structure)
cam-standoff-read-entity
)
((get-curve-data! arg0 s5-0 'campath 'campath-k -1000000000.0)
@ -469,20 +387,9 @@
(-> obj flags)
(the-as uint (cam-slave-get-flags arg1 (string->symbol *res-key-string*)))
)
(let
((s3-2
((method-of-type res-lump get-property-data)
arg1
arg0
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(s0-1 (method-of-type res-lump get-property-struct))
)
(let ((s3-2 (res-lump-data arg1 arg0 pointer))
(s0-1 (method-of-type res-lump get-property-struct))
)
(set! sv-32 format)
(let ((a0-7 (clear *res-key-string*))
(a1-4 "~S~S")

View file

@ -7,22 +7,7 @@
(defun entity-actor-lookup ((lump res-lump) (name symbol) (idx int))
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
(the-as
(pointer uint32)
(get-property-data
lump
name
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
)
(let ((v1-1 (res-lump-data lump name (pointer uint32) :tag-ptr (& sv-16))))
(the-as
entity-actor
(when (and v1-1 (< idx (the-as int (-> sv-16 elt-count))))
@ -43,16 +28,7 @@
(defun entity-actor-count ((res res-lump) (name symbol))
(local-vars (tag res-tag))
(set! tag (new 'static 'res-tag))
(if
(get-property-data
res
name
'interp
-1000000000.0
(the-as pointer #f)
(& tag)
*res-static-buf*
)
(if (res-lump-data res name pointer :tag-ptr (& tag))
(the-as int (-> tag elt-count))
0
)

View file

@ -46,15 +46,7 @@
effect-control
((allocation symbol) (type-to-make type) (arg0 process-drawable))
(cond
(((method-of-type res-lump get-property-struct)
(-> arg0 draw jgeo extra)
'effect-name
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
((res-lump-struct (-> arg0 draw jgeo extra) 'effect-name structure)
(let
((v0-1
(object-new allocation type-to-make (the-as int (-> type-to-make size)))

View file

@ -258,18 +258,7 @@
(set! tag (new 'static 'res-tag))
(let
((v1-6
(the-as
(pointer int32)
((method-of-type res-lump get-property-data)
ent
'eco-info
'interp
0.0
(the-as pointer #f)
(& tag)
*res-static-buf*
)
)
(res-lump-data ent 'eco-info (pointer int32) :tag-ptr (& tag) :time 0.0)
)
)
(cond
@ -295,45 +284,11 @@
)
)
)
(set!
(-> obj options)
(the-as
uint
((method-of-type res-lump get-property-value)
ent
'options
'interp
-1000000000.0
(the-as uint128 0)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set! (-> obj options) (res-lump-value ent 'options uint))
(if (logtest? #x80200 (-> obj options))
(set!
(-> obj fade-time)
(the-as
uint
(the
int
(*
300.0
(the-as
float
((method-of-type res-lump get-property-value-float)
ent
'timeout
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
)
)
(the-as uint (the int (* 300.0 (res-lump-float ent 'timeout))))
)
)
)
@ -369,110 +324,24 @@
)
)
(let ((entity (-> obj process entity)))
(set!
(-> obj speed)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'speed
'interp
-1000000000.0
1.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set! (-> obj speed) (res-lump-float entity 'speed :default 1.0))
(set!
(-> obj idle-distance)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'idle-distance
'interp
-1000000000.0
327680.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-float entity 'idle-distance :default 327680.0)
)
(set!
(-> obj notice-top)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'notice-top
'interp
-1000000000.0
4096000.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-float entity 'notice-top :default 4096000.0)
)
(set!
(-> obj notice-bottom)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'notice-bottom
'interp
-1000000000.0
4096000.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set!
(-> obj cam-horz)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'cam-horz
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set!
(-> obj cam-vert)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'cam-vert
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-float entity 'notice-bottom :default 4096000.0)
)
(set! (-> obj cam-horz) (res-lump-float entity 'cam-horz))
(set! (-> obj cam-vert) (res-lump-float entity 'cam-vert))
(set!
(-> obj cam-notice-dist)
(the-as
float
((method-of-type res-lump get-property-value-float)
entity
'cam-notice-dist
'interp
-1000000000.0
-4096.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-float entity 'cam-notice-dist :default -4096.0)
)
)
obj

View file

@ -481,14 +481,12 @@
(set! sv-32 'nav-engine)
(let
((a3-1
((method-of-type res-lump get-property-value)
(res-lump-value
ent
'nav-max-users
'interp
-1000000000.0
uint128
:default
(the-as uint128 32)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
@ -561,14 +559,11 @@
(let ((ent (-> shape process entity)))
(set!
(-> obj nearest-y-threshold)
((method-of-type res-lump get-property-value-float)
(res-lump-float
ent
'nearest-y-threshold
'interp
-1000000000.0
:default
nearest-y-threshold-default
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
@ -615,17 +610,6 @@
(defun has-nav-mesh? ((arg0 entity-actor))
(the-as
symbol
(or
(-> arg0 nav-mesh)
((method-of-type res-lump get-property-struct)
arg0
'nav-mesh-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(or (-> arg0 nav-mesh) (res-lump-struct arg0 'nav-mesh-actor structure))
)
)

View file

@ -99,19 +99,7 @@
)
)
(set! tag (new 'static 'res-tag))
(let
((data
((method-of-type res-lump get-property-data)
ent
name
'interp
time
(the-as pointer #f)
(& tag)
*res-static-buf*
)
)
)
(let ((data (res-lump-data ent name pointer :tag-ptr (& tag) :time time)))
(cond
(data
(set! (-> obj cverts) (the-as (inline-array vector) data))

View file

@ -702,18 +702,7 @@
)
(set!
sv-48
(the-as
(pointer float)
((method-of-type res-lump get-property-data)
(the-as res-lump arg0)
'cycle-speed
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-data (the-as res-lump arg0) 'cycle-speed (pointer float))
)
(set! sv-16 *ambient-spec*)
(set! sv-64 (new 'static 'res-tag))

View file

@ -130,18 +130,7 @@
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
(setup-params!
@ -176,18 +165,7 @@
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
(if (>= (-> sv-16 elt-count) (the-as uint 4))
@ -231,18 +209,7 @@
(local-vars (sv-16 res-tag))
(set! sv-16 (new 'static 'res-tag))
(let
((v1-1
((method-of-type res-lump get-property-data)
(-> proc entity)
'sync
'interp
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
((v1-1 (res-lump-data (-> proc entity) 'sync pointer :tag-ptr (& sv-16))))
(cond
(v1-1
(if (>= (-> sv-16 elt-count) (the-as uint 4))

View file

@ -621,14 +621,12 @@
(set! (-> obj button-id) -1)
(let
((v1-4
((method-of-type res-lump get-property-value)
(res-lump-value
(-> obj entity)
'extra-id
'interp
-1000000000.0
uint128
:default
(the-as uint128 -1)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
@ -638,24 +636,8 @@
)
(when
(or
(get-property-struct
arg0
'next-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(get-property-struct
arg0
'prev-actor
'interp
-1000000000.0
#f
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(res-lump-struct arg0 'next-actor structure)
(res-lump-struct arg0 'prev-actor structure)
)
(set! (-> obj link) (new 'process 'actor-link-info obj))
(if (< (-> obj button-id) 0)
@ -675,18 +657,7 @@
(set! (-> obj down?) v1-16)
)
(set! (-> obj notify-actor) (entity-actor-lookup arg0 'alt-actor 0))
(set!
(-> obj timeout)
(get-property-value-float
arg0
'timeout
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(set! (-> obj timeout) (res-lump-float arg0 'timeout))
(if (not (-> obj spawned-by-other?))
(nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
)

View file

@ -1847,62 +1847,31 @@
;; definition for method 25 of type water-anim
;; Used lq/sq
(defmethod TODO-RENAME-25 water-anim ((obj water-anim))
(local-vars (sv-16 int))
(local-vars (sv-16 res-tag))
(set! (-> obj play-ambient-sound?) #t)
(set!
(-> obj look)
(the-as
int
((method-of-type res-lump get-property-value)
(-> obj entity)
'look
'interp
-1000000000.0
(the-as uint128 -1)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-value (-> obj entity) 'look int :default (the-as uint128 -1))
)
(set! sv-16 0)
(set! sv-16 (new 'static 'res-tag))
(let
((v1-3
(the-as
object
((method-of-type res-lump get-property-data)
(-> obj entity)
'trans-offset
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) (& sv-16))
*res-static-buf*
)
(res-lump-data
(-> obj entity)
'trans-offset
(pointer float)
:tag-ptr
(& sv-16)
)
)
)
(when (the-as pointer v1-3)
(+! (-> obj root trans x) (-> (the-as transform v1-3) trans x))
(+! (-> obj root trans y) (-> (the-as transform v1-3) trans y))
(set!
(-> (the-as transform (-> obj root)) rot y)
(+ (-> obj root trans z) (-> (the-as transform v1-3) trans z))
)
(when v1-3
(+! (-> obj root trans x) (-> v1-3 0))
(+! (-> obj root trans y) (-> v1-3 1))
(+! (-> obj root trans z) (-> v1-3 2))
)
)
(let
((f0-6
((method-of-type res-lump get-property-value-float)
(-> obj entity)
'rotoffset
'interp
-1000000000.0
0.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(let ((f0-6 (res-lump-float (-> obj entity) 'rotoffset)))
(if (!= f0-6 0.0)
(quaternion-rotate-y! (-> obj root quat) (-> obj root quat) f0-6)
)

View file

@ -257,15 +257,7 @@
(set!
(-> obj anim-limit)
(*
(get-property-value-float
arg0
'distance
'interp
-1000000000.0
1.0
(the-as (pointer res-tag) #f)
*res-static-buf*
)
(res-lump-float arg0 'distance :default 1.0)
(the
float
(+

View file

@ -65,29 +65,12 @@
(set! (-> gp-0 waveform) ripple-for-mud)
(let
((v1-9
(the-as
object
((method-of-type res-lump get-property-data)
(-> obj entity)
'water-anim-fade-dist
'interp
-1000000000.0
(the-as pointer #f)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
(res-lump-data (-> obj entity) 'water-anim-fade-dist (pointer float))
)
)
(when (the-as pointer v1-9)
(set!
(-> gp-0 close-fade-dist)
(-> (the-as ripple-control v1-9) global-scale)
)
(set!
(-> gp-0 far-fade-dist)
(-> (the-as ripple-control v1-9) last-frame-scale)
)
(when v1-9
(set! (-> gp-0 close-fade-dist) (-> v1-9 0))
(set! (-> gp-0 far-fade-dist) (-> v1-9 1))
)
)
(case (-> obj look)

View file

@ -629,21 +629,7 @@
)
)
(set! (-> obj first-task) (the-as uint (-> arg0 extra perm task)))
(set!
(-> obj second-task)
(the-as
uint
(get-property-value
arg0
'alt-task
'interp
-1000000000.0
(the-as uint128 0)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
(set! (-> obj second-task) (res-lump-value arg0 'alt-task uint))
(set!
(-> obj tasks)
(get-task-control (the-as game-task (-> obj first-task)))