diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 90203686c9..d694850ff5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -36,6 +36,7 @@ add_library(common cross_sockets/XSocketServer.cpp custom_data/pack_helpers.cpp custom_data/TFrag3Data.cpp + demacro/demacro.cpp dma/dma_copy.cpp dma/dma.cpp dma/gs.cpp diff --git a/common/demacro/demacro.cpp b/common/demacro/demacro.cpp new file mode 100644 index 0000000000..6eb478c155 --- /dev/null +++ b/common/demacro/demacro.cpp @@ -0,0 +1,689 @@ +#include "demacro.h" + +#include +#include +#include +#include +#include +#include + +#include "common/formatter/formatter.h" +#include "common/util/FileUtil.h" +#include "common/util/json_util.h" +#include "common/util/string_util.h" + +#include "fmt/format.h" +#include "third-party/json.hpp" +#include "tree_sitter/api.h" + +extern "C" { +extern const TSLanguage* tree_sitter_opengoal(); +} + +namespace demacro { +namespace { + +struct Node { + bool is_list = false; + uint32_t start = 0; + uint32_t end = 0; + std::string atom; + std::vector children; +}; + +struct Comment { + uint32_t start = 0; + uint32_t end = 0; +}; + +struct ParsedSource { + Node root; + std::vector comments; +}; + +struct Captures { + std::unordered_map single; + std::unordered_map> sequence; +}; + +struct CompiledRule { + std::string name; + std::vector match; + std::vector rewrite; + size_t index = 0; +}; + +struct Candidate { + uint32_t start = 0; + uint32_t end = 0; + size_t rule_index = 0; + Captures captures; +}; + +struct Edit { + uint32_t start = 0; + uint32_t end = 0; + size_t rule_index = 0; + std::string replacement; +}; + +bool is_comment_node(const TSNode& node) { + const std::string_view type = ts_node_type(node); + return type == "comment" || type == "block_comment"; +} + +bool is_gap_node(const TSNode& node) { + const std::string_view type = ts_node_type(node); + return type == "(" || type == ")" || type == "_ws" || type == "ERROR" || + is_comment_node(node); +} + +std::string node_text(const std::string& source, const TSNode& node) { + const auto start = ts_node_start_byte(node); + const auto end = ts_node_end_byte(node); + return source.substr(start, end - start); +} + +void collect_comments(const TSNode& node, std::vector* comments) { + if (is_comment_node(node)) { + comments->push_back({ts_node_start_byte(node), ts_node_end_byte(node)}); + return; + } + for (uint32_t i = 0; i < ts_node_child_count(node); ++i) { + collect_comments(ts_node_child(node, i), comments); + } +} + +std::optional convert_node(const std::string& source, const TSNode& node) { + if (is_gap_node(node)) { + return {}; + } + + Node result; + result.start = ts_node_start_byte(node); + result.end = ts_node_end_byte(node); + + const std::string_view type = ts_node_type(node); + if (type == "list_lit" || type == "source") { + result.is_list = true; + for (uint32_t i = 0; i < ts_node_child_count(node); ++i) { + auto child = convert_node(source, ts_node_child(node, i)); + if (child) { + result.children.push_back(std::move(*child)); + } + } + } else { + // Reader forms and strings are deliberately atomic. Demacro is interested in the shape of + // ordinary lists, and retaining their exact spelling avoids damaging quoted data or strings. + result.atom = node_text(source, node); + } + return result; +} + +ParsedSource parse_source(const std::string& source, const std::string& source_name) { + std::shared_ptr parser(ts_parser_new(), formatter::TreeSitterParserDeleter()); + ts_parser_set_language(parser.get(), tree_sitter_opengoal()); + std::shared_ptr tree( + ts_parser_parse_string(parser.get(), nullptr, source.c_str(), source.size()), + formatter::TreeSitterTreeDeleter()); + + auto root = ts_tree_root_node(tree.get()); + if (ts_node_is_null(root) || ts_node_has_error(root)) { + throw std::runtime_error(fmt::format("Unable to parse OpenGOAL forms in {}", source_name)); + } + ParsedSource result; + auto converted = convert_node(source, root); + if (!converted) { + throw std::runtime_error( + fmt::format("OpenGOAL parser returned an empty tree for {}", source_name)); + } + result.root = std::move(*converted); + collect_comments(root, &result.comments); + return result; +} + +std::vector json_string_or_array(const nlohmann::json& value, + const std::string& rule_name, + const std::string& field_name) { + if (value.is_string()) { + return {value.get()}; + } + if (value.is_array()) { + std::vector result; + for (const auto& entry : value) { + if (!entry.is_string()) { + throw std::runtime_error( + fmt::format("Demacro rule '{}' field '{}' must contain only strings", rule_name, + field_name)); + } + result.push_back(entry.get()); + } + return result; + } + throw std::runtime_error( + fmt::format("Demacro rule '{}' field '{}' must be a string or array", rule_name, field_name)); +} + +std::string substitute_row_values( + std::string text, + const std::unordered_map& substitutions, + const std::string& rule_name) { + for (const auto& [key, value] : substitutions) { + const auto placeholder = "{{" + key + "}}"; + size_t cursor = 0; + while ((cursor = text.find(placeholder, cursor)) != std::string::npos) { + text.replace(cursor, placeholder.size(), value); + cursor += value.size(); + } + } + if (text.find("{{") != std::string::npos) { + throw std::runtime_error( + fmt::format("Demacro rule '{}' contains an unresolved table placeholder", rule_name)); + } + return text; +} + +Rule parse_rule(const nlohmann::json& entry, + const std::unordered_map& substitutions, + const std::string& name_suffix) { + Rule rule; + const auto base_name = entry.at("name").get(); + rule.name = substitute_row_values(base_name, substitutions, base_name) + name_suffix; + rule.match = json_string_or_array(entry.at("match"), rule.name, "match"); + rule.rewrite = json_string_or_array(entry.at("rewrite"), rule.name, "rewrite"); + for (auto& form : rule.match) { + form = substitute_row_values(std::move(form), substitutions, rule.name); + } + for (auto& form : rule.rewrite) { + form = substitute_row_values(std::move(form), substitutions, rule.name); + } + return rule; +} + +std::vector parse_form_sequence(const std::vector& forms, + const std::string& description) { + std::vector result; + for (const auto& form : forms) { + auto parsed = parse_source(form, description); + if (parsed.root.children.size() != 1) { + throw std::runtime_error( + fmt::format("{} must contain exactly one OpenGOAL form", description)); + } + result.push_back(std::move(parsed.root.children.front())); + } + return result; +} + +bool is_capture(const Node& node, std::string* name) { + if (node.is_list || node.atom.size() < 2 || node.atom.front() != '$' || node.atom[1] == '*') { + return false; + } + *name = node.atom.substr(1); + return true; +} + +bool is_sequence_capture(const Node& node, std::string* name) { + if (node.is_list || node.atom.size() < 3 || !str_util::starts_with(node.atom, "$*")) { + return false; + } + *name = node.atom.substr(2); + return true; +} + +bool structurally_equal(const Node& a, const Node& b) { + if (a.is_list != b.is_list) { + return false; + } + if (!a.is_list) { + return a.atom == b.atom; + } + if (a.children.size() != b.children.size()) { + return false; + } + for (size_t i = 0; i < a.children.size(); ++i) { + if (!structurally_equal(a.children.at(i), b.children.at(i))) { + return false; + } + } + return true; +} + +std::vector match_node_all(const Node& pattern, + const Node& input, + const Captures& captures); + +bool sequence_equal(const std::vector& a, const std::vector& b) { + if (a.size() != b.size()) { + return false; + } + for (size_t i = 0; i < a.size(); ++i) { + if (!structurally_equal(*a.at(i), *b.at(i))) { + return false; + } + } + return true; +} + +std::vector match_children_all(const std::vector& patterns, + size_t pattern_idx, + const std::vector& inputs, + size_t input_idx, + const Captures& captures) { + if (pattern_idx == patterns.size()) { + return input_idx == inputs.size() ? std::vector{captures} + : std::vector{}; + } + + std::string sequence_name; + if (is_sequence_capture(patterns.at(pattern_idx), &sequence_name)) { + std::vector results; + for (size_t count = 0; input_idx + count <= inputs.size(); ++count) { + std::vector captured; + captured.reserve(count); + for (size_t i = 0; i < count; ++i) { + captured.push_back(&inputs.at(input_idx + i)); + } + + auto next = captures; + const auto previous = next.sequence.find(sequence_name); + if (previous != next.sequence.end() && !sequence_equal(previous->second, captured)) { + continue; + } + next.sequence[sequence_name] = std::move(captured); + auto matches = + match_children_all(patterns, pattern_idx + 1, inputs, input_idx + count, next); + results.insert(results.end(), std::make_move_iterator(matches.begin()), + std::make_move_iterator(matches.end())); + } + return results; + } + + if (input_idx == inputs.size()) { + return {}; + } + std::vector results; + for (auto& node_match : + match_node_all(patterns.at(pattern_idx), inputs.at(input_idx), captures)) { + auto matches = + match_children_all(patterns, pattern_idx + 1, inputs, input_idx + 1, node_match); + results.insert(results.end(), std::make_move_iterator(matches.begin()), + std::make_move_iterator(matches.end())); + } + return results; +} + +std::vector match_node_all(const Node& pattern, + const Node& input, + const Captures& captures) { + std::string capture_name; + if (is_capture(pattern, &capture_name)) { + const auto previous = captures.single.find(capture_name); + if (previous != captures.single.end()) { + return structurally_equal(*previous->second, input) ? std::vector{captures} + : std::vector{}; + } + auto result = captures; + result.single[capture_name] = &input; + return {std::move(result)}; + } + + if (pattern.is_list != input.is_list) { + return {}; + } + if (!pattern.is_list) { + return pattern.atom == input.atom ? std::vector{captures} + : std::vector{}; + } + return match_children_all(pattern.children, 0, input.children, 0, captures); +} + +bool match_sibling_sequence(const std::vector& patterns, + const std::vector& inputs, + size_t start, + Captures* captures, + size_t* count) { + if (start > inputs.size()) { + return false; + } + + // A top-level rule sequence intentionally has a fixed number of forms. Variable-length captures + // belong inside a form, where their surrounding list gives them an unambiguous boundary. + if (start + patterns.size() > inputs.size()) { + return false; + } + std::vector matches{*captures}; + for (size_t i = 0; i < patterns.size(); ++i) { + std::vector next; + for (const auto& current : matches) { + auto node_matches = match_node_all(patterns.at(i), inputs.at(start + i), current); + next.insert(next.end(), std::make_move_iterator(node_matches.begin()), + std::make_move_iterator(node_matches.end())); + } + if (next.empty()) { + return false; + } + matches = std::move(next); + } + *captures = std::move(matches.front()); + *count = patterns.size(); + return true; +} + +std::string original_text(const Node& node, const std::string& source) { + return source.substr(node.start, node.end - node.start); +} + +std::string render_template(const Node& node, + const Captures& captures, + const std::string& source); + +std::string render_template_children(const std::vector& nodes, + const Captures& captures, + const std::string& source) { + std::string result; + for (const auto& child : nodes) { + std::string sequence_name; + if (is_sequence_capture(child, &sequence_name)) { + const auto found = captures.sequence.find(sequence_name); + if (found == captures.sequence.end()) { + throw std::runtime_error( + fmt::format("Unknown demacro sequence capture '$*{}'", sequence_name)); + } + for (const auto* captured : found->second) { + if (!result.empty()) { + result += " "; + } + result += original_text(*captured, source); + } + } else { + if (!result.empty()) { + result += " "; + } + result += render_template(child, captures, source); + } + } + return result; +} + +std::string render_template(const Node& node, + const Captures& captures, + const std::string& source) { + std::string capture_name; + if (is_capture(node, &capture_name)) { + const auto found = captures.single.find(capture_name); + if (found == captures.single.end()) { + throw std::runtime_error(fmt::format("Unknown demacro capture '${}'", capture_name)); + } + return original_text(*found->second, source); + } + if (!node.is_list) { + return node.atom; + } + return "(" + render_template_children(node.children, captures, source) + ")"; +} + +std::string indentation_at(const std::string& source, uint32_t offset) { + const auto line_start = source.rfind('\n', offset == 0 ? 0 : offset - 1); + const auto start = line_start == std::string::npos ? 0 : line_start + 1; + size_t cursor = start; + while (cursor < offset && (source.at(cursor) == ' ' || source.at(cursor) == '\t')) { + ++cursor; + } + return source.substr(start, cursor - start); +} + +std::string indent_after_newlines(std::string text, const std::string& indentation) { + size_t cursor = 0; + while ((cursor = text.find('\n', cursor)) != std::string::npos) { + ++cursor; + if (cursor < text.size()) { + text.insert(cursor, indentation); + cursor += indentation.size(); + } + } + return text; +} + +std::string render_rewrite(const CompiledRule& rule, + const Candidate& candidate, + const ParsedSource& parsed, + const std::string& source) { + const auto indentation = indentation_at(source, candidate.start); + std::string replacement; + for (const auto& form : rule.rewrite) { + if (!replacement.empty()) { + replacement += "\n" + indentation; + } + replacement += indent_after_newlines( + render_template(form, candidate.captures, source), indentation); + } + + // Comments are not part of semantic matching. Retain any comment which would otherwise be + // swallowed by replacing a multi-form expansion. Comments already inside a raw captured form are + // present in replacement and are not duplicated. + std::string saved_comments; + for (const auto& comment : parsed.comments) { + if (comment.start < candidate.start || comment.end > candidate.end) { + continue; + } + const auto text = source.substr(comment.start, comment.end - comment.start); + if (replacement.find(text) == std::string::npos) { + if (!saved_comments.empty()) { + saved_comments += "\n" + indentation; + } + saved_comments += text; + } + } + if (!saved_comments.empty()) { + replacement = saved_comments + "\n" + indentation + replacement; + } + return replacement; +} + +void find_candidates(const Node& parent, + const std::vector& rules, + std::vector* result) { + if (!parent.is_list) { + return; + } + + for (size_t child_idx = 0; child_idx < parent.children.size(); ++child_idx) { + for (const auto& rule : rules) { + Captures captures; + size_t match_count = 0; + if (match_sibling_sequence(rule.match, parent.children, child_idx, &captures, &match_count)) { + result->push_back({parent.children.at(child_idx).start, + parent.children.at(child_idx + match_count - 1).end, rule.index, + std::move(captures)}); + } + } + } + + for (const auto& child : parent.children) { + find_candidates(child, rules, result); + } +} + +std::vector select_non_overlapping(std::vector candidates) { + std::sort(candidates.begin(), candidates.end(), [](const Candidate& a, const Candidate& b) { + if (a.start != b.start) { + return a.start < b.start; + } + if (a.rule_index != b.rule_index) { + return a.rule_index < b.rule_index; + } + return a.end < b.end; + }); + + std::vector result; + uint32_t last_end = 0; + bool have_last = false; + for (auto& candidate : candidates) { + if (have_last && candidate.start < last_end) { + continue; + } + last_end = candidate.end; + have_last = true; + result.push_back(std::move(candidate)); + } + return result; +} + +std::vector compile_rules(const RuleSet& rules) { + std::vector result; + for (size_t i = 0; i < rules.rules.size(); ++i) { + const auto& rule = rules.rules.at(i); + if (rule.match.empty()) { + throw std::runtime_error(fmt::format("Demacro rule '{}' has an empty match", rule.name)); + } + if (rule.rewrite.empty()) { + throw std::runtime_error(fmt::format("Demacro rule '{}' has an empty rewrite", rule.name)); + } + result.push_back({rule.name, + parse_form_sequence(rule.match, "match for demacro rule " + rule.name), + parse_form_sequence(rule.rewrite, "rewrite for demacro rule " + rule.name), + i}); + } + return result; +} + +RewriteResult rewrite_compiled(const std::string& source, + const RuleSet& rules, + const std::vector& compiled) { + RewriteResult result; + result.source = source; + for (const auto& rule : rules.rules) { + result.stats.push_back({rule.name, 0}); + } + + // Reparse after each batch so patterns created by another rewrite can be recognized, while a + // malformed or cyclic rule file cannot loop forever. + constexpr int kMaxPasses = 100; + for (int pass = 0; pass < kMaxPasses; ++pass) { + const auto parsed = parse_source(result.source, ""); + std::vector candidates; + find_candidates(parsed.root, compiled, &candidates); + auto selected = select_non_overlapping(std::move(candidates)); + if (selected.empty()) { + return result; + } + + std::vector edits; + edits.reserve(selected.size()); + for (const auto& candidate : selected) { + edits.push_back({candidate.start, candidate.end, candidate.rule_index, + render_rewrite(compiled.at(candidate.rule_index), candidate, parsed, + result.source)}); + result.stats.at(candidate.rule_index).rewrites++; + } + for (auto edit = edits.rbegin(); edit != edits.rend(); ++edit) { + result.source.replace(edit->start, edit->end - edit->start, edit->replacement); + } + } + + throw std::runtime_error("Demacro exceeded 100 rewrite passes; the rule set is probably cyclic"); +} + +struct CachedRuleSet { + RuleSet rules; + std::vector compiled; +}; + +const CachedRuleSet& load_cached_rules(const fs::path& path) { + static std::mutex cache_mutex; + static std::unordered_map> cache; + + const auto key = fs::absolute(path).lexically_normal().string(); + std::lock_guard lock(cache_mutex); + const auto existing = cache.find(key); + if (existing != cache.end()) { + return *existing->second; + } + + auto loaded = std::make_unique(); + loaded->rules = load_rules(path); + loaded->compiled = compile_rules(loaded->rules); + return *cache.emplace(key, std::move(loaded)).first->second; +} + +} // namespace + +int RewriteResult::rewrite_count() const { + int result = 0; + for (const auto& stat : stats) { + result += stat.rewrites; + } + return result; +} + +RuleSet parse_rules(const std::string& contents, const std::string& source_name) { + const auto json = parse_commented_json(contents, source_name); + if (!json.is_object() || !json.contains("rules") || !json.at("rules").is_array()) { + throw std::runtime_error(fmt::format("{} must contain a 'rules' array", source_name)); + } + + std::unordered_map>> tables; + if (json.contains("tables")) { + if (!json.at("tables").is_object()) { + throw std::runtime_error(fmt::format("{} field 'tables' must be an object", source_name)); + } + for (const auto& [table_name, rows] : json.at("tables").items()) { + if (!rows.is_array()) { + throw std::runtime_error( + fmt::format("{} table '{}' must be an array", source_name, table_name)); + } + for (const auto& row : rows) { + if (!row.is_object()) { + throw std::runtime_error( + fmt::format("{} table '{}' contains a non-object row", source_name, table_name)); + } + std::unordered_map values; + for (const auto& [key, value] : row.items()) { + if (!value.is_string()) { + throw std::runtime_error(fmt::format( + "{} table '{}' row values must be strings", source_name, table_name)); + } + values[key] = value.get(); + } + tables[table_name].push_back(std::move(values)); + } + } + } + + RuleSet result; + for (const auto& entry : json.at("rules")) { + if (!entry.is_object()) { + throw std::runtime_error(fmt::format("{} contains a non-object rule", source_name)); + } + if (entry.contains("for_each")) { + const auto table_name = entry.at("for_each").get(); + const auto table = tables.find(table_name); + if (table == tables.end()) { + throw std::runtime_error(fmt::format("Demacro rule '{}' refers to unknown table '{}'", + entry.at("name").get(), table_name)); + } + for (size_t i = 0; i < table->second.size(); ++i) { + result.rules.push_back(parse_rule(entry, table->second.at(i), + fmt::format("[{}:{}]", table_name, i))); + } + } else { + result.rules.push_back(parse_rule(entry, {}, "")); + } + } + return result; +} + +RuleSet load_rules(const fs::path& path) { + return parse_rules(file_util::read_text_file(path), path.string()); +} + +RewriteResult rewrite(const std::string& source, const RuleSet& rules) { + return rewrite_compiled(source, rules, compile_rules(rules)); +} + +RewriteResult rewrite(const std::string& source, const fs::path& rule_path) { + const auto& cached = load_cached_rules(rule_path); + return rewrite_compiled(source, cached.rules, cached.compiled); +} + +} // namespace demacro diff --git a/common/demacro/demacro.h b/common/demacro/demacro.h new file mode 100644 index 0000000000..b6806cdd8a --- /dev/null +++ b/common/demacro/demacro.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +#include "common/util/FileUtil.h" + +namespace demacro { + +struct Rule { + std::string name; + std::vector match; + std::vector rewrite; +}; + +struct RuleSet { + std::vector rules; +}; + +struct RuleStat { + std::string name; + int rewrites = 0; +}; + +struct RewriteResult { + std::string source; + std::vector stats; + + int rewrite_count() const; +}; + +RuleSet parse_rules(const std::string& contents, const std::string& source_name = ""); +RuleSet load_rules(const fs::path& path); + +RewriteResult rewrite(const std::string& source, const RuleSet& rules); +RewriteResult rewrite(const std::string& source, const fs::path& rule_path); + +} // namespace demacro diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index 389078ee10..f6b5f3f673 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -1151,6 +1151,21 @@ void TypeSystem::add_builtin_types(GameVersion version) { auto uint_type = add_builtin_value_type("uinteger", "uint", 8, false, false); uint_type->disallow_in_runtime(); + // Jak 1's built-in mem-usage method takes these traversal/classification flags. The method is + // declared before any GOAL source is loaded, so its argument enum must also be a built-in type. + if (version == GameVersion::Jak1) { + const std::unordered_map mem_usage_flag_entries = { + {"prototype-data", 0}, {"instance-colors", 1}, {"tie-geometry-1", 2}, + {"tie-geometry-2", 3}, {"tie-geometry-3", 4}, {"include-dead-pools", 5}, + {"resource-entity", 6}, {"resource-ambient", 7}, {"resource-camera", 8}, + {"resource-joint-geo", 9}}; + auto* parent = get_type_of_type("uint32"); + auto flags = + std::make_unique(parent, "mem-usage-flags", true, mem_usage_flag_entries); + flags->set_runtime_type(parent->get_runtime_name()); + add_type("mem-usage-flags", std::move(flags)); + } + // Methods and Fields forward_declare_type_as("memory-usage-block", "basic"); @@ -1169,7 +1184,11 @@ void TypeSystem::add_builtin_types(GameVersion version) { declare_method(obj_type, "relocate", {}, false, make_function_typespec({"_type_", "int"}, "_type_"), false); declare_method(obj_type, "mem-usage", {}, false, - make_function_typespec({"_type_", "memory-usage-block", "int"}, "_type_"), false); + make_function_typespec( + {"_type_", "memory-usage-block", + version == GameVersion::Jak1 ? "mem-usage-flags" : "int"}, + "_type_"), + false); // STRUCTURE // structure new doesn't support dynamic sizing, which is kinda weird - it grabs the size from diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 93abfe6884..958540e24a 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3150,7 +3150,8 @@ bool try_to_rewrite_vector_inline_ctor(const Env& env, } bool try_to_rewrite_matrix_inline_copy(const Env& env, FormPool& pool, FormStack& stack) { - if (env.func->name() == "(method 63 collide-shape-moving)") { + if (env.func->name() == "matrix-copy!" || + env.func->name() == "(method 63 collide-shape-moving)") { return false; } auto matrix_entries = @@ -3158,13 +3159,21 @@ bool try_to_rewrite_matrix_inline_copy(const Env& env, FormPool& pool, FormStack if (matrix_entries) { // first, check the loads. they should be something like source = (-> MAT vec quad) // MAT should always be a variable - const char* names[] = {"rvec", "uvec", "fvec", "trans"}; - std::vector load_src_ras, store_dest_ras, store_src_ras; for (int i = 0; i < 4; i++) { - auto deref_matcher = - Matcher::deref(Matcher::any_reg(0), false, - {DerefTokenMatcher::string(names[i]), DerefTokenMatcher::string("quad")}); + Matcher deref_matcher; + if (env.version == GameVersion::Jak1) { + deref_matcher = Matcher::deref( + Matcher::any_reg(0), false, + {DerefTokenMatcher::string("vector"), DerefTokenMatcher::integer(i), + DerefTokenMatcher::string("quad")}); + } else { + const char* names[] = {"rvec", "uvec", "fvec", "trans"}; + deref_matcher = + Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::string(names[i]), + DerefTokenMatcher::string("quad")}); + } auto mr = match(deref_matcher, matrix_entries->at(i).source, &env); if (!mr.matched) { return false; @@ -3174,10 +3183,20 @@ bool try_to_rewrite_matrix_inline_copy(const Env& env, FormPool& pool, FormStack // check the stores for (int i = 4; i < 8; i++) { - Matcher matcher = Matcher::set(Matcher::deref(Matcher::any_reg(0), false, - {DerefTokenMatcher::string(names[i - 4]), - DerefTokenMatcher::string("quad")}), - Matcher::any_reg(1)); + Matcher dst_matcher; + if (env.version == GameVersion::Jak1) { + dst_matcher = Matcher::deref( + Matcher::any_reg(0), false, + {DerefTokenMatcher::string("vector"), DerefTokenMatcher::integer(i - 4), + DerefTokenMatcher::string("quad")}); + } else { + const char* names[] = {"rvec", "uvec", "fvec", "trans"}; + dst_matcher = + Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::string(names[i - 4]), + DerefTokenMatcher::string("quad")}); + } + Matcher matcher = Matcher::set(dst_matcher, Matcher::any_reg(1)); auto mr = match(matcher, matrix_entries->at(i).elt, &env); if (!mr.matched) { return false; @@ -3356,6 +3375,8 @@ bool try_to_rewrite_matrix_inline_ctor(const Env& env, FormPool& pool, FormStack } } } break; + case GameVersion::JakX: + return false; } // success! @@ -3380,6 +3401,50 @@ bool is_deref_to_quad(DerefElement* deref) { deref->tokens().back().is_field_name("quad"); } +struct DerefContainerInfo { + TypeSpec type; + bool is_matrix_row = false; +}; + +std::optional deref_container_info(DerefElement* deref, const Env& env) { + if (!is_deref_to_quad(deref)) { + return {}; + } + + auto base = deref->base()->try_as_element(); + if (!base || base->expr().kind() != SimpleExpression::Kind::IDENTITY || + !base->expr().get_arg(0).is_var()) { + return {}; + } + + TypeSpec current = env.get_variable_type(base->expr().get_arg(0).var(), true); + bool is_matrix_row = current == TypeSpec("matrix") || current == TypeSpec("matrix3"); + for (size_t i = 0; i + 1 < deref->tokens().size(); ++i) { + const auto& token = deref->tokens().at(i); + if (token.kind() == DerefToken::Kind::FIELD_NAME) { + try { + current = env.dts->ts.lookup_field_info(current.base_type(), token.field_name()).type; + } catch (const std::exception&) { + return {}; + } + } else if (token.kind() == DerefToken::Kind::INTEGER_CONSTANT || + token.kind() == DerefToken::Kind::INTEGER_EXPRESSION) { + if (!current.has_single_arg()) { + return {}; + } + // get_single_arg() refers into current, so copy it before assignment destroys the argument + // storage. + const auto element_type = current.get_single_arg(); + current = element_type; + } else { + return {}; + } + is_matrix_row = + is_matrix_row || current == TypeSpec("matrix") || current == TypeSpec("matrix3"); + } + return DerefContainerInfo{current, is_matrix_row}; +} + Form* pop_last_deref_token(Form* form) { auto deref = form->try_as_element(); ASSERT(deref); @@ -3392,9 +3457,7 @@ Form* pop_last_deref_token(Form* form) { } FormElement* try_to_rewrite_vector_copy(Form* dst, - const TypeSpec& dst_type, Form* src, - const TypeSpec& src_type, FormPool& pool, const Env& env) { if (env.func->name() == "vector-copy!") { @@ -3402,16 +3465,6 @@ FormElement* try_to_rewrite_vector_copy(Form* dst, } if (dst && src) { - // check types - if (dst_type != TypeSpec("vector")) { - return nullptr; - } - - // kinda sus - we really want to check the place where this was loaded... - if (src_type != TypeSpec("uint128")) { - return nullptr; - } - auto* dst_deref = dst->try_as_element(); auto* src_deref = src->try_as_element(); if (!dst_deref) { @@ -3422,11 +3475,17 @@ FormElement* try_to_rewrite_vector_copy(Form* dst, return nullptr; } - if (!is_deref_to_quad(dst_deref)) { + const auto dst_info = deref_container_info(dst_deref, env); + const auto src_info = deref_container_info(src_deref, env); + if (!dst_info || !src_info || + !env.dts->ts.tc(TypeSpec("vector"), dst_info->type) || + !env.dts->ts.tc(TypeSpec("vector"), src_info->type)) { return nullptr; } - if (!is_deref_to_quad(src_deref)) { + // A matrix row is represented by an inline vector, but folding its individual quadword copy + // would prevent the four-row matrix-copy! recognizer from seeing the complete operation. + if (dst_info->is_matrix_row || src_info->is_matrix_row) { return nullptr; } @@ -3439,6 +3498,39 @@ FormElement* try_to_rewrite_vector_copy(Form* dst, return nullptr; } +FormElement* try_to_rewrite_vector_zero(Form* dst, + Form* value, + FormPool& pool, + const Env& env) { + if (env.func->name() == "vector-zero!") { + return nullptr; + } + + auto dst_deref = dst ? dst->try_as_element() : nullptr; + const auto dst_info = dst_deref ? deref_container_info(dst_deref, env) : std::nullopt; + if (!dst_info || !env.dts->ts.tc(TypeSpec("vector"), dst_info->type) || + dst_info->is_matrix_row) { + return nullptr; + } + if (!match(Matcher::cast("uint128", Matcher::integer(0)), value, &env).matched) { + return nullptr; + } + + return pool.alloc_element( + GenericOperator::make_function(pool.form("vector-zero!")), + std::vector{pop_last_deref_token(dst)}); +} + +bool is_pending_stack_vector_ctor(const FormStack& stack, RegisterAccess destination) { + auto entries = stack.try_getting_active_stack_entries({true}); + if (!entries || !entries->front().destination || + entries->front().destination->reg() != destination.reg()) { + return false; + } + auto stack_value = entries->front().source->try_as_element(); + return stack_value && stack_value->type() == TypeSpec("vector"); +} + } // namespace void StorePlainDeref::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) { @@ -3462,11 +3554,9 @@ void StorePlainDeref::push_to_stack(const Env& env, FormPool& pool, FormStack& s FormElement* fr = nullptr; - // hack: for now only do this on Jak 3 - if (size() == 16 && env.version == GameVersion::Jak3) { - fr = try_to_rewrite_vector_copy( - m_dst, env.get_variable_type(m_base_var, true), popped.at(0), - m_src_cast_type.value_or(env.get_variable_type(m_expr.var(), true)), pool, env); + if (size() == 16 && + (env.version == GameVersion::Jak1 || env.version == GameVersion::Jak3)) { + fr = try_to_rewrite_vector_copy(m_dst, popped.at(0), pool, env); } if (!fr) { @@ -3486,10 +3576,19 @@ void StorePlainDeref::push_to_stack(const Env& env, FormPool& pool, FormStack& s m_dst->try_as_element()->inline_nested(); auto val = pool.form(m_expr, m_my_idx); val->mark_popped(); - auto fr = pool.alloc_element( - m_dst, make_optional_cast(m_src_cast_type, val, pool, env)); - fr->mark_popped(); - stack.push_form_element(fr, true); + auto typed_value = make_optional_cast(m_src_cast_type, val, pool, env); + FormElement* fr = nullptr; + if (size() == 16 && env.version == GameVersion::Jak1 && + !is_pending_stack_vector_ctor(stack, m_base_var)) { + fr = try_to_rewrite_vector_zero(m_dst, typed_value, pool, env); + } + if (!fr) { + fr = pool.alloc_element(m_dst, typed_value); + fr->mark_popped(); + stack.push_form_element(fr, true); + } else { + fr->push_to_stack(env, pool, stack); + } } if (!try_to_rewrite_matrix_inline_ctor(env, pool, stack)) { diff --git a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp index 02d984988d..ae97ef3fb6 100644 --- a/decompiler/ObjectFile/ObjectFileDB_IR2.cpp +++ b/decompiler/ObjectFile/ObjectFileDB_IR2.cpp @@ -5,6 +5,7 @@ #include "ObjectFileDB.h" +#include "common/demacro/demacro.h" #include "common/formatter/formatter.h" #include "common/goos/PrettyPrinter.h" #include "common/link_types.h" @@ -880,6 +881,10 @@ void ObjectFileDB::ir2_write_results(const fs::path& output_dir, file_util::write_text_file(file_name, file_text); auto unformatted_code = ir2_final_out(obj, imports, {}); + if (!config.demacro_file.empty()) { + unformatted_code = + demacro::rewrite(unformatted_code, file_util::get_file_path({config.demacro_file})).source; + } auto final_name = output_dir / (obj.to_unique_name() + "_disasm.gc"); if (config.format_code) { const auto formatted_code = formatter::format_code(unformatted_code); diff --git a/decompiler/config.cpp b/decompiler/config.cpp index 55322cd027..275a04fd90 100644 --- a/decompiler/config.cpp +++ b/decompiler/config.cpp @@ -46,6 +46,9 @@ Config make_config_via_json(nlohmann::json& json) { config.expected_elf_name = json.at("expected_elf_name").get(); } config.all_types_file = json.at("all_types_file").get(); + if (json.contains("demacro_file")) { + config.demacro_file = json.at("demacro_file").get(); + } auto inputs_json = read_json_file_from_config(json, "inputs_file"); config.dgo_names = json.contains("dgo_names") diff --git a/decompiler/config.h b/decompiler/config.h index 6282d798e7..20fddebce6 100644 --- a/decompiler/config.h +++ b/decompiler/config.h @@ -106,6 +106,7 @@ struct Config { std::string obj_file_name_map_file; std::string all_types_file; + std::string demacro_file; bool disassemble_code = false; bool dump_function_metadata = false; diff --git a/decompiler/config/jak1/all-types.gc b/decompiler/config/jak1/all-types.gc index 9da5380a71..b24bedcd54 100644 --- a/decompiler/config/jak1/all-types.gc +++ b/decompiler/config/jak1/all-types.gc @@ -19576,10 +19576,15 @@ the original scratchpad decompressor remains available through the development s (define-extern mem-size "Collect value's memory categories using flags, optionally print the complete category table, and return the sum of aligned total bytes." - (function basic symbol int int)) + (function basic symbol mem-usage-flags int)) (define-extern jacc-mem-usage "Account for a compressed animation control block, its fixed data, and each compressed frame." - (function joint-anim-compressed-control memory-usage-block int joint-anim-compressed-control)) + (function + joint-anim-compressed-control + memory-usage-block + mem-usage-flags + joint-anim-compressed-control + )) (define-extern joint-anim-inspect-elt "Inspect the payload element selected by rounding index to an integer. Matrix and transformq animations have specialized displays; other animation payload types are left unchanged." @@ -19722,7 +19727,7 @@ under label, then add those totals into the aggregate collision statistics." (define-extern mem-usage-bsp-tree "Recursively count the 32-byte internal nodes reachable from node in the BSP-node memory category. Nonpositive terminal children are not followed; header and flags are unused." - (function bsp-header bsp-node memory-usage-block int none)) + (function bsp-header bsp-node memory-usage-block mem-usage-flags none)) (define-extern bsp-camera-asm "Traverse the BSP for camera-position. At each split, select front when dot(camera-position, plane.xyz) - plane.w is nonnegative. Store the terminal leaf index and that @@ -21384,7 +21389,7 @@ instance distance to the level." (define-extern mem-usage-shrub-walk "Recursively account for node storage and leaf instance-shrubbery records across node-count contiguous shrub BVH roots. flags is forwarded for the memory-usage traversal." - (function draw-node int memory-usage-block int draw-node)) + (function draw-node int memory-usage-block mem-usage-flags draw-node)) (define-extern shrub-make-perspective-matrix "Copy the current camera transform to out, divide its homogeneous coefficients by pfog0, and fold the horizontal, vertical, depth, and fog offsets into the first three components." diff --git a/decompiler/config/jak1/demacro.jsonc b/decompiler/config/jak1/demacro.jsonc new file mode 100644 index 0000000000..61f87e6741 --- /dev/null +++ b/decompiler/config/jak1/demacro.jsonc @@ -0,0 +1,407 @@ +{ + // Patterns are matched against LISP forms after type analysis, expression construction, and + // let insertion have finished. A `$name` atom captures one form; repeated captures must match + // structurally. `$*name` captures zero or more forms within a list, which lets a rule tolerate + // unrelated bindings merged into a compiler-generated let. + // + // `match` and `rewrite` may be either one form string or an array of adjacent form strings. + // Rules are tried in file order. Keep rules conservative: this pass intentionally has no type + // information with which to disambiguate structurally identical operations. + "tables": { + // Mirrors memory-usage-h.gc. `next` is the one-past category index stored in + // memory-usage-block.length. + "mem-usage-id": [ + {"value": "0", "next": "1", "symbol": "drawable-group"}, + {"value": "1", "next": "2", "symbol": "tfragment"}, + {"value": "2", "next": "3", "symbol": "tfragment-base"}, + {"value": "3", "next": "4", "symbol": "tfragment-common"}, + {"value": "4", "next": "5", "symbol": "tfragment-level0"}, + {"value": "5", "next": "6", "symbol": "tfragment-level1"}, + {"value": "6", "next": "7", "symbol": "tfragment-color"}, + {"value": "7", "next": "8", "symbol": "tfragment-debug"}, + {"value": "8", "next": "9", "symbol": "tfragment-pal"}, + {"value": "9", "next": "10", "symbol": "tie-fragment"}, + {"value": "10", "next": "11", "symbol": "tie-gif"}, + {"value": "11", "next": "12", "symbol": "tie-points"}, + {"value": "12", "next": "13", "symbol": "tie-colors"}, + {"value": "13", "next": "14", "symbol": "tie-draw-points"}, + {"value": "14", "next": "15", "symbol": "tie-debug"}, + {"value": "15", "next": "16", "symbol": "tie-near"}, + {"value": "16", "next": "17", "symbol": "tie-pal"}, + {"value": "17", "next": "18", "symbol": "tie-generic"}, + {"value": "18", "next": "19", "symbol": "instance-tie"}, + {"value": "19", "next": "20", "symbol": "instance-tie-colors0"}, + {"value": "20", "next": "21", "symbol": "instance-tie-colors1"}, + {"value": "21", "next": "22", "symbol": "instance-tie-colors2"}, + {"value": "22", "next": "23", "symbol": "instance-tie-colors3"}, + {"value": "23", "next": "24", "symbol": "instance-tie-colors*"}, + {"value": "24", "next": "25", "symbol": "prototype-bucket-shrub"}, + {"value": "25", "next": "26", "symbol": "generic-shrub"}, + {"value": "26", "next": "27", "symbol": "generic-shrub-data"}, + {"value": "27", "next": "28", "symbol": "shrubbery"}, + {"value": "28", "next": "29", "symbol": "shrubbery-object"}, + {"value": "29", "next": "30", "symbol": "shrubbery-vertex"}, + {"value": "30", "next": "31", "symbol": "shrubbery-color"}, + {"value": "31", "next": "32", "symbol": "shrubbery-stq"}, + {"value": "32", "next": "33", "symbol": "shrubbery-pal"}, + {"value": "33", "next": "34", "symbol": "billboard"}, + {"value": "34", "next": "35", "symbol": "instance-shrubbery"}, + {"value": "35", "next": "36", "symbol": "pris-fragment"}, + {"value": "43", "next": "44", "symbol": "entity"}, + {"value": "44", "next": "45", "symbol": "camera"}, + {"value": "45", "next": "46", "symbol": "nav-mesh"}, + {"value": "48", "next": "49", "symbol": "res"}, + {"value": "49", "next": "50", "symbol": "ambient"}, + {"value": "50", "next": "51", "symbol": "collide-fragment-0"}, + {"value": "51", "next": "52", "symbol": "collision-poly-0"}, + {"value": "52", "next": "53", "symbol": "collision-vertex-0"}, + {"value": "53", "next": "54", "symbol": "collide-fragment-1"}, + {"value": "54", "next": "55", "symbol": "collision-poly-1"}, + {"value": "55", "next": "56", "symbol": "collision-vertex-1"}, + {"value": "56", "next": "57", "symbol": "bsp-main"}, + {"value": "57", "next": "58", "symbol": "bsp-misc"}, + {"value": "58", "next": "59", "symbol": "bsp-node"}, + {"value": "59", "next": "60", "symbol": "bsp-leaf-vis-self"}, + {"value": "60", "next": "61", "symbol": "bsp-leaf-vis-adj"}, + {"value": "61", "next": "62", "symbol": "draw-node"}, + {"value": "62", "next": "63", "symbol": "pat"}, + {"value": "63", "next": "64", "symbol": "level-code"}, + {"value": "64", "next": "65", "symbol": "entity-links"}, + {"value": "65", "next": "66", "symbol": "joint"}, + {"value": "66", "next": "67", "symbol": "joint-anim-compressed"}, + {"value": "67", "next": "68", "symbol": "joint-anim-compressed-control"}, + {"value": "68", "next": "69", "symbol": "joint-anim-fixed"}, + {"value": "69", "next": "70", "symbol": "joint-anim-frame"}, + {"value": "70", "next": "71", "symbol": "art-group"}, + {"value": "71", "next": "72", "symbol": "art-mesh-anim"}, + {"value": "72", "next": "73", "symbol": "art-mesh-geo"}, + {"value": "73", "next": "74", "symbol": "art-joint-geo"}, + {"value": "74", "next": "75", "symbol": "art-joint-anim"}, + {"value": "75", "next": "76", "symbol": "merc-ctrl"}, + {"value": "76", "next": "77", "symbol": "joint-anim-drawable"}, + {"value": "77", "next": "78", "symbol": "blend-shape"}, + {"value": "78", "next": "79", "symbol": "collide-mesh"}, + {"value": "79", "next": "80", "symbol": "texture"}, + {"value": "80", "next": "81", "symbol": "string"}, + {"value": "81", "next": "82", "symbol": "array"}, + {"value": "82", "next": "83", "symbol": "sprite"}, + {"value": "83", "next": "84", "symbol": "depth-cue"}, + {"value": "84", "next": "85", "symbol": "debug"}, + {"value": "85", "next": "86", "symbol": "sky"}, + {"value": "86", "next": "87", "symbol": "pris-generic"}, + {"value": "87", "next": "88", "symbol": "4k-dead-pool"}, + {"value": "88", "next": "89", "symbol": "8k-dead-pool"}, + {"value": "89", "next": "90", "symbol": "16k-dead-pool"}, + {"value": "90", "next": "91", "symbol": "nk-dead-pool"}, + {"value": "91", "next": "92", "symbol": "target-dead-pool"}, + {"value": "92", "next": "93", "symbol": "camera-dead-pool"}, + {"value": "93", "next": "94", "symbol": "debug-dead-pool"}, + {"value": "94", "next": "95", "symbol": "process-active"}, + {"value": "95", "next": "96", "symbol": "heap-total"}, + {"value": "96", "next": "97", "symbol": "heap-process"}, + {"value": "97", "next": "98", "symbol": "heap-header"}, + {"value": "98", "next": "99", "symbol": "heap-thread"}, + {"value": "99", "next": "100", "symbol": "heap-root"}, + {"value": "100", "next": "101", "symbol": "heap-draw-control"}, + {"value": "101", "next": "102", "symbol": "heap-joint-control"}, + {"value": "102", "next": "103", "symbol": "heap-cspace"}, + {"value": "103", "next": "104", "symbol": "heap-bone"}, + {"value": "104", "next": "105", "symbol": "heap-part"}, + {"value": "105", "next": "106", "symbol": "heap-collide-prim"}, + {"value": "106", "next": "107", "symbol": "heap-misc"}, + {"value": "107", "next": "108", "symbol": "shadow-geo"}, + {"value": "108", "next": "109", "symbol": "eye-anim"} + ], + "scratchpad-object-type": [ + {"type": "terrain-context"}, + {"type": "cam-dbg-scratch"}, + {"type": "terrain-bsp"}, + {"type": "collide-puss-work"}, + {"type": "vector"}, + {"type": "vector4w"}, + {"type": "bone-memory"}, + {"type": "joint"}, + {"type": "bone"}, + {"type": "vu-lights"}, + {"type": "bone-regs"}, + {"type": "matrix"}, + {"type": "generic-tie-shadow"}, + {"type": "generic-tie-calls"}, + {"type": "collide-probe-stack"}, + {"type": "ambient-list"}, + {"type": "adgif-shader"}, + {"type": "(inline-array ocean-vertex)"} + ], + "scratchpad-pointer-type": [ + {"type": "rgba"}, + {"type": "uint128"}, + {"type": "process-drawable"} + ] + }, + "rules": [ + { + "name": "current-frame", + "match": "(-> *display* frames (-> *display* on-screen) frame)", + "rewrite": "(current-frame)" + }, + { + // Let insertion can merge consecutive traversals which reuse the same node and cached-next + // locals. Peel off the first traversal and rebuild the remaining let; repeated rule passes + // then recover every traversal in the chain. + "name": "iterate-engine-connections-merged-let", + "match": + "(let (($node (-> $engine alive-list next0))) $engine (let (($next (-> $node next0))) (while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) $engine (set! $next (-> $next next0))) (set! $node (-> $next-engine alive-list next0)) $next-engine (set! $next (-> $node next0)) $*remaining))", + "rewrite": [ + "(iterate-engine-connections ($node $engine) $*body)", + "(let (($node (-> $next-engine alive-list next0))) $next-engine (let (($next (-> $node next0))) $*remaining))" + ] + }, + { + // Function-scoped locals produce assignments instead of let bindings around the traversal. + "name": "iterate-engine-connections-set-locals", + "match": [ + "(set! $node (-> $engine alive-list next0))", + "$engine", + "(set! $next (-> $node next0))", + "(while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) $engine (set! $next (-> $next next0)))" + ], + "rewrite": "(iterate-engine-connections ($node $engine) $*body)" + }, + { + // Constant engine globals sometimes survive as no-op forms around the cached-next traversal. + "name": "iterate-engine-connections-with-engine-forms", + "match": + "(let (($node (-> $engine alive-list next0))) $engine (let (($next (-> $node next0))) (while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) $engine (set! $next (-> $next next0)))))", + "rewrite": "(iterate-engine-connections ($node $engine) $*body)" + }, + { + "name": "iterate-engine-connections-nested-let", + "match": + "(let (($node (-> $engine alive-list next0))) (let (($next (-> $node next0))) (while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) (set! $next (-> $next next0)))))", + "rewrite": "(iterate-engine-connections ($node $engine) $*body)" + }, + { + "name": "iterate-engine-connections-let-star", + "match": + "(let* (($node (-> $engine alive-list next0)) ($next (-> $node next0))) (while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) (set! $next (-> $next next0))))", + "rewrite": "(iterate-engine-connections ($node $engine) $*body)" + }, + { + // Preserve unrelated bindings which let insertion combined with the traversal's node local. + // Exact single-binding lets are handled above so this fallback never emits an empty let. + "name": "iterate-engine-connections-merged-bindings", + "match": + "(let ($*before ($node (-> $engine alive-list next0)) $*after) $engine (let (($next (-> $node next0))) (while (!= $node (-> $engine alive-list-end)) $*body (set! $node $next) $engine (set! $next (-> $next next0)))))", + "rewrite": "(let ($*before $*after) (iterate-engine-connections ($node $engine) $*body))" + }, + { + "name": "with-dma-buffer-add-bucket", + "match": + "(let* (($buf $buffer) ($start (-> $buf base))) $*body (let (($edge (-> $buf base))) (let (($packet (the-as dma-packet (-> $buf base)))) (set! (-> $packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) (set! (-> $packet vif0) (new 'static 'vif-tag)) (set! (-> $packet vif1) (new 'static 'vif-tag)) (set! (-> $buf base) (&+ (the-as pointer $packet) 16))) (dma-bucket-insert-tag $bucket-group $bucket-id $start (the-as (pointer dma-tag) $edge))))", + "rewrite": + "(with-dma-buffer-add-bucket (($buf $buffer) $bucket-id) :bucket-group $bucket-group $*body)" + }, + { + "name": "with-dma-buffer-add-bucket-pointer-add-cast", + "match": + "(let* (($buf $buffer) ($start (-> $buf base))) $*body (let (($edge (-> $buf base))) (let (($packet (the-as dma-packet (-> $buf base)))) (set! (-> $packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) (set! (-> $packet vif0) (new 'static 'vif-tag)) (set! (-> $packet vif1) (new 'static 'vif-tag)) (set! (-> $buf base) (the-as pointer (&+ $packet 16)))) (dma-bucket-insert-tag $bucket-group $bucket-id $start (the-as (pointer dma-tag) $edge))))", + "rewrite": + "(with-dma-buffer-add-bucket (($buf $buffer) $bucket-id) :bucket-group $bucket-group $*body)" + }, + { + "name": "with-dma-buffer-add-bucket-object-packet", + "match": + "(let* (($buf $buffer) ($start (-> $buf base))) $*body (let (($edge (-> $buf base))) (let (($packet (the-as object (-> $buf base)))) (set! (-> (the-as dma-packet $packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) (set! (-> (the-as dma-packet $packet) vif0) (new 'static 'vif-tag)) (set! (-> (the-as dma-packet $packet) vif1) (new 'static 'vif-tag)) (set! (-> $buf base) (&+ (the-as pointer $packet) 16))) (dma-bucket-insert-tag $bucket-group $bucket-id $start (the-as (pointer dma-tag) $edge))))", + "rewrite": + "(with-dma-buffer-add-bucket (($buf $buffer) $bucket-id) :bucket-group $bucket-group $*body)" + }, + { + // The font setters are methods rather than macros, but Jak 1 inlines them. The enum + // constructors make these two field stores structurally unambiguous without type data. + "name": "font-set-color-conditional-aliased", + "match": + "(let (($alias $font)) (set! (-> $alias color) (if $condition (font-color $*true-colors) (font-color $*false-colors))))", + "rewrite": + "(set-color! $font (if $condition (font-color $*true-colors) (font-color $*false-colors)))" + }, + { + "name": "font-set-color-aliased", + "match": + "(let (($alias $font)) (set! (-> $alias color) (font-color $*colors)))", + "rewrite": "(set-color! $font (font-color $*colors))" + }, + { + "name": "font-set-color", + "match": "(set! (-> $font color) (font-color $*colors))", + "rewrite": "(set-color! $font (font-color $*colors))" + }, + { + "name": "font-set-flags-aliased", + "match": + "(let (($alias $font)) (set! (-> $alias flags) (font-flags $*flags)))", + "rewrite": "(set-flags! $font (font-flags $*flags))" + }, + { + "name": "font-set-flags", + "match": "(set! (-> $font flags) (font-flags $*flags))", + "rewrite": "(set-flags! $font (font-flags $*flags))" + }, + { + "name": "mem-usage-add-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data {{value}} name) \"{{symbol}}\")", + "(+! (-> $usage data {{value}} count) $count)", + "(let (($temp $bytes)) (+! (-> $usage data {{value}} used) $temp) (+! (-> $usage data {{value}} total) (logand -16 (+ $temp 15))))" + ], + "rewrite": "(mem-usage-add! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-enum-index-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data (mem-usage-id {{symbol}}) name) \"{{symbol}}\")", + "(+! (-> $usage data (mem-usage-id {{symbol}}) count) $count)", + "(let (($temp $bytes)) (+! (-> $usage data (mem-usage-id {{symbol}}) used) $temp) (+! (-> $usage data (mem-usage-id {{symbol}}) total) (logand -16 (+ $temp 15))))" + ], + "rewrite": "(mem-usage-add! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-runtime-name-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data {{value}} name) (symbol->string '{{symbol}}))", + "(+! (-> $usage data {{value}} count) $count)", + "(let (($temp $bytes)) (+! (-> $usage data {{value}} used) $temp) (+! (-> $usage data {{value}} total) (logand -16 (+ $temp 15))))" + ], + "rewrite": "(mem-usage-add-symbol! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-enum-index-runtime-name-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data (mem-usage-id {{symbol}}) name) (symbol->string '{{symbol}}))", + "(+! (-> $usage data (mem-usage-id {{symbol}}) count) $count)", + "(let (($temp $bytes)) (+! (-> $usage data (mem-usage-id {{symbol}}) used) $temp) (+! (-> $usage data (mem-usage-id {{symbol}}) total) (logand -16 (+ $temp 15))))" + ], + "rewrite": "(mem-usage-add-symbol! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-flattened-let-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data {{value}} name) \"{{symbol}}\")", + "(+! (-> $usage data {{value}} count) $count)", + "(+! (-> $usage data {{value}} used) $bytes)", + "(+! (-> $usage data {{value}} total) (logand -16 (+ $bytes 15)))" + ], + "rewrite": "(mem-usage-add! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-enum-index-flattened-let-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data (mem-usage-id {{symbol}}) name) \"{{symbol}}\")", + "(+! (-> $usage data (mem-usage-id {{symbol}}) count) $count)", + "(+! (-> $usage data (mem-usage-id {{symbol}}) used) $bytes)", + "(+! (-> $usage data (mem-usage-id {{symbol}}) total) (logand -16 (+ $bytes 15)))" + ], + "rewrite": "(mem-usage-add! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-runtime-name-flattened-let-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data {{value}} name) (symbol->string '{{symbol}}))", + "(+! (-> $usage data {{value}} count) $count)", + "(+! (-> $usage data {{value}} used) $bytes)", + "(+! (-> $usage data {{value}} total) (logand -16 (+ $bytes 15)))" + ], + "rewrite": "(mem-usage-add-symbol! $usage {{symbol}} $count $bytes)" + }, + { + "name": "mem-usage-add-enum-index-runtime-name-flattened-let-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data (mem-usage-id {{symbol}}) name) (symbol->string '{{symbol}}))", + "(+! (-> $usage data (mem-usage-id {{symbol}}) count) $count)", + "(+! (-> $usage data (mem-usage-id {{symbol}}) used) $bytes)", + "(+! (-> $usage data (mem-usage-id {{symbol}}) total) (logand -16 (+ $bytes 15)))" + ], + "rewrite": "(mem-usage-add-symbol! $usage {{symbol}} $count $bytes)" + }, + { + // A zero increment is sometimes decompiled as a self-assignment instead of `(+! ... 0)`. + "name": "mem-usage-add-zero-count-{{symbol}}", + "for_each": "mem-usage-id", + "match": [ + "(set! (-> $usage length) (max {{next}} (-> $usage length)))", + "(set! (-> $usage data {{value}} name) \"{{symbol}}\")", + "(set! (-> $usage data {{value}} count) (-> $usage data {{value}} count))", + "(let (($temp $bytes)) (+! (-> $usage data {{value}} used) $temp) (+! (-> $usage data {{value}} total) (logand -16 (+ $temp 15))))" + ], + "rewrite": "(mem-usage-add! $usage {{symbol}} 0 $bytes)" + }, + { + // These adjacent calls share the larger one-past length after decompilation. + "name": "mem-usage-add-generic-shrub-pair", + "match": [ + "(set! (-> $usage length) (max 27 (-> $usage length)))", + "(set! (-> $usage data 25 name) \"generic-shrub\")", + "(+! (-> $usage data 25 count) $header-count)", + "(let (($header-temp $header-bytes)) (+! (-> $usage data 25 used) $header-temp) (+! (-> $usage data 25 total) (logand -16 (+ $header-temp 15))))", + "(set! (-> $usage data 26 name) \"generic-shrub-data\")", + "(+! (-> $usage data 26 count) $stream-count)", + "(let (($stream-temp $stream-bytes)) (+! (-> $usage data 26 used) $stream-temp) (+! (-> $usage data 26 total) (logand -16 (+ $stream-temp 15))))" + ], + "rewrite": [ + "(mem-usage-add! $usage generic-shrub $header-count $header-bytes)", + "(mem-usage-add! $usage generic-shrub-data $stream-count $stream-bytes)" + ] + }, + { + "name": "scratchpad-object-direct-{{type}}", + "for_each": "scratchpad-object-type", + "match": "(the-as {{type}} #x70000000)", + "rewrite": "(scratchpad-object {{type}})" + }, + { + "name": "scratchpad-object-offset-{{type}}", + "for_each": "scratchpad-object-type", + "match": "(the-as {{type}} (+ $offset #x70000000))", + "rewrite": "(scratchpad-object {{type}} :offset $offset)" + }, + { + "name": "scratchpad-object-reversed-offset-{{type}}", + "for_each": "scratchpad-object-type", + "match": "(the-as {{type}} (+ #x70000000 $offset))", + "rewrite": "(scratchpad-object {{type}} :offset $offset)" + }, + { + "name": "scratchpad-pointer-direct-{{type}}", + "for_each": "scratchpad-pointer-type", + "match": "(the-as (pointer {{type}}) #x70000000)", + "rewrite": "(scratchpad-ptr {{type}})" + }, + { + "name": "scratchpad-pointer-offset-{{type}}", + "for_each": "scratchpad-pointer-type", + "match": "(the-as (pointer {{type}}) (+ $offset #x70000000))", + "rewrite": "(scratchpad-ptr {{type}} :offset $offset)" + }, + { + "name": "scratchpad-pointer-reversed-offset-{{type}}", + "for_each": "scratchpad-pointer-type", + "match": "(the-as (pointer {{type}}) (+ #x70000000 $offset))", + "rewrite": "(scratchpad-ptr {{type}} :offset $offset)" + } + ] +} diff --git a/decompiler/config/jak1/jak1_config.jsonc b/decompiler/config/jak1/jak1_config.jsonc index 912f662778..2d5a285cfa 100644 --- a/decompiler/config/jak1/jak1_config.jsonc +++ b/decompiler/config/jak1/jak1_config.jsonc @@ -101,6 +101,7 @@ "art_info_file": "decompiler/config/jak1/ntsc_v1/art_info.jsonc", "import_deps_file": "decompiler/config/jak1/ntsc_v1/import_deps.jsonc", "all_types_file": "decompiler/config/jak1/all-types.gc", + "demacro_file": "decompiler/config/jak1/demacro.jsonc", "art_group_dump_file": "decompiler/config/jak1/ntsc_v1/art-group-info.min.json", "joint_node_dump_file": "decompiler/config/jak1/ntsc_v1/joint-node-info.min.json", "tex_dump_file": "decompiler/config/jak1/ntsc_v1/tex-info.min.json", diff --git a/goal_src/jak1/engine/anim/aligner.gc b/goal_src/jak1/engine/anim/aligner.gc index 535ae65698..4e7e385719 100644 --- a/goal_src/jak1/engine/anim/aligner.gc +++ b/goal_src/jak1/engine/anim/aligner.gc @@ -53,7 +53,7 @@ ;; Shift the decomposed transform and source matrix into the previous-sample slots. (mem-copy! (the-as pointer (-> this transform 1)) (the-as pointer (-> this transform)) 48) (quaternion-copy! (-> this transform 1 quat) (-> this align quat)) - (set! (-> this transform 1 scale quad) (-> this align scale quad)) + (vector-copy! (-> this transform 1 scale) (-> this align scale)) (matrix-copy! (-> this matrix 1) (-> this matrix 0)) ;; Evaluate the alignment joint, copy its bone matrix, and apply the process root scale to its diff --git a/goal_src/jak1/engine/anim/joint-exploder.gc b/goal_src/jak1/engine/anim/joint-exploder.gc index 52964f0039..903802d0a1 100644 --- a/goal_src/jak1/engine/anim/joint-exploder.gc +++ b/goal_src/jak1/engine/anim/joint-exploder.gc @@ -161,8 +161,8 @@ ((-> joint-list bbox-valid?) (add-point! (-> joint-list bbox) (the-as vector3s joint-position))) (else (set! (-> joint-list bbox-valid?) #t) - (set! (-> joint-list bbox min quad) (-> joint-position quad)) - (set! (-> joint-list bbox max quad) (-> joint-position quad))))) + (vector-copy! (-> joint-list bbox min) joint-position) + (vector-copy! (-> joint-list bbox max) joint-position)))) (add-point! (-> joint-list bbox) (the-as vector3s (-> joint-data prev-pos))) (none)) @@ -339,8 +339,8 @@ (+! i 1)) (let ((combined-bounds (new 'stack-no-clear 'bounding-box))) (let ((root-position (-> self root trans))) - (set! (-> combined-bounds min quad) (-> root-position quad)) - (set! (-> combined-bounds max quad) (-> root-position quad))) + (vector-copy! (-> combined-bounds min) root-position) + (vector-copy! (-> combined-bounds max) root-position)) (set! i 0) (while (< i 5) (set! joint-list (-> self lists i)) @@ -368,13 +368,6 @@ (defmethod init-joints! ((this joint-exploder)) "Build each fragment's base transform, spin matrix, linked-list indices, and launch velocity from the static joint table and selected explosion style, then seed the main list and bounds." - (local-vars - (basis-x uint128) - (basis-y uint128) - (basis-z uint128) - (fragment-matrix matrix) - (source-matrix matrix) - (translation uint128)) (let ((joint-array (-> this joints)) (i 0)) (while (< i (-> joint-array num-joints)) @@ -388,28 +381,10 @@ (cond ((>= parent-index 0) (if (zero? parent-index) (set! parent-index (-> static-joint joint-index))) - (set! source-matrix (-> this parent-override 0 node-list data parent-index bone transform)) - (set! fragment-matrix (-> joint-data mat)) - (set! basis-x (-> source-matrix vector 0 quad)) - (set! basis-y (-> source-matrix vector 1 quad)) - (set! basis-z (-> source-matrix vector 2 quad)) - (set! translation (-> source-matrix vector 3 quad)) - (set! (-> fragment-matrix vector 0 quad) basis-x) - (set! (-> fragment-matrix vector 1 quad) basis-y) - (set! (-> fragment-matrix vector 2 quad) basis-z) - (set! (-> fragment-matrix vector 3 quad) translation) + (matrix-copy! (-> joint-data mat) (-> this parent-override 0 node-list data parent-index bone transform)) (matrix-identity! (-> joint-data rmat))) (else - (set! source-matrix (-> this node-list data (-> static-joint joint-index) bone transform)) - (set! fragment-matrix (-> joint-data mat)) - (set! basis-x (-> source-matrix vector 0 quad)) - (set! basis-y (-> source-matrix vector 1 quad)) - (set! basis-z (-> source-matrix vector 2 quad)) - (set! translation (-> source-matrix vector 3 quad)) - (set! (-> fragment-matrix vector 0 quad) basis-x) - (set! (-> fragment-matrix vector 1 quad) basis-y) - (set! (-> fragment-matrix vector 2 quad) basis-z) - (set! (-> fragment-matrix vector 3 quad) translation) + (matrix-copy! (-> joint-data mat) (-> this node-list data (-> static-joint joint-index) bone transform)) (matrix-identity! (-> joint-data rmat))))) (case (-> this tuning explosion) ((1) @@ -465,9 +440,9 @@ (set! (-> joint-list pre-moved?) #f))) (logior! (-> self mask) (process-mask enemy)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> self parent-override 0 root trans quad)) + (vector-copy! (-> self root trans) (-> self parent-override 0 root trans)) (quaternion-copy! (-> self root quat) (-> self parent-override 0 root quat)) - (set! (-> self root scale quad) (-> self parent-override 0 root scale quad)) + (vector-copy! (-> self root scale) (-> self parent-override 0 root scale)) (initialize-skeleton self exploder-sg '()) (logior! (-> self skel status) (janim-status inited)) (set! (-> self anim) (the-as art-joint-anim (-> self draw art-group data animation-index))) diff --git a/goal_src/jak1/engine/anim/joint-mod-h.gc b/goal_src/jak1/engine/anim/joint-mod-h.gc index 910a93d7a8..9358efb7c2 100644 --- a/goal_src/jak1/engine/anim/joint-mod-h.gc +++ b/goal_src/jak1/engine/anim/joint-mod-h.gc @@ -170,9 +170,9 @@ (defmethod set-trs! ((this joint-mod) (trans vector) (rot quaternion) (scale vector)) "Replace any nonfalse translation, rotation, and scale override components." - (if trans (set! (-> this trans quad) (-> trans quad))) + (if trans (vector-copy! (-> this trans) trans)) (if rot (quaternion-copy! (-> this quat) rot)) - (if scale (set! (-> this scale quad) (-> scale quad))) + (if scale (vector-copy! (-> this scale) scale)) 0 (none)) @@ -183,7 +183,7 @@ ;; how far are we from the target? (let ((distance (vector-vector-distance (-> this process root trans) target-trans))) (set! (-> this shutting-down?) #f) - (set! (-> this target quad) (-> target-trans quad)) + (vector-copy! (-> this target) target-trans) (if (< distance (-> this max-dist)) (set! (-> this blend) 1.0) (set! (-> this blend) 0.0))) 0 (none)) @@ -227,7 +227,7 @@ (or (< dist (vector-vector-distance (-> this process root trans) (-> this target))) (= option 'force))) (< dist (-> this max-dist))) (if (= (-> this mode) (joint-mod-handler-mode reset)) (set-mode! this (joint-mod-handler-mode look-at))) - (set! (-> this target quad) (-> target-trans quad)) + (vector-copy! (-> this target) target-trans) (set! (-> this blend) 1.0) (set! (-> this shutting-down?) #f))) 0 @@ -366,9 +366,9 @@ (defun joint-mod-joint-set-handler ((node cspace) (local-transform transformq)) "Replace the joint's local translation, rotation, and scale with the configured transform." (let ((s4-0 (the-as joint-mod (-> node param1)))) - (set! (-> local-transform trans quad) (-> s4-0 trans quad)) + (vector-copy! (-> local-transform trans) (-> s4-0 trans)) (quaternion-copy! (-> local-transform quat) (-> s4-0 quat)) - (set! (-> local-transform scale quad) (-> s4-0 scale quad))) + (vector-copy! (-> local-transform scale) (-> s4-0 scale))) (cspace<-parented-transformq-joint! node local-transform) 0 (none)) @@ -461,9 +461,9 @@ (let ((v1-0 (the-as joint-mod-set-local (-> node param1)))) (cond ((-> v1-0 enable) - (if (not (-> v1-0 set-translation)) (set! (-> v1-0 transform trans quad) (-> local-transform trans quad))) + (if (not (-> v1-0 set-translation)) (vector-copy! (-> v1-0 transform trans) (-> local-transform trans))) (if (not (-> v1-0 set-rotation)) (set! (-> v1-0 transform quat vec quad) (-> local-transform quat vec quad))) - (if (not (-> v1-0 set-scale)) (set! (-> v1-0 transform scale quad) (-> local-transform scale quad))) + (if (not (-> v1-0 set-scale)) (vector-copy! (-> v1-0 transform scale) (-> local-transform scale))) (cspace<-parented-transformq-joint! node (-> v1-0 transform))) (else (cspace<-parented-transformq-joint! node local-transform)))) (none)) diff --git a/goal_src/jak1/engine/anim/joint.gc b/goal_src/jak1/engine/anim/joint.gc index 484bccb972..2e54fefb33 100644 --- a/goal_src/jak1/engine/anim/joint.gc +++ b/goal_src/jak1/engine/anim/joint.gc @@ -449,12 +449,9 @@ (format #t "#<~A ~S ~D @ #x~X>" (-> this type) (-> this name) (-> this number) this) this) -(defmethod mem-usage ((this joint) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this joint) (usage memory-usage-block) (flags mem-usage-flags)) "Add this skeleton joint descriptor to the joint memory-usage category." - (set! (-> usage length) (max 66 (-> usage length))) - (set! (-> usage data 65 name) "joint") - (+! (-> usage data 65 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 65 used) v1-6) (+! (-> usage data 65 total) (logand -16 (+ v1-6 15)))) + (mem-usage-add! usage joint 1 (asize-of this)) this) (defmethod print ((this joint-anim)) @@ -509,37 +506,19 @@ (format #t "~`transform`P~%" (-> (the-as joint-anim-transformq animation) data (the int index))))) animation) -(defmethod mem-usage ((this joint-anim-drawable) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this joint-anim-drawable) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this animation and recursively account for every drawable payload." - (set! (-> usage length) (max 77 (-> usage length))) - (set! (-> usage data 76 name) "joint-anim-drawable") - (+! (-> usage data 76 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 76 used) v1-6) (+! (-> usage data 76 total) (logand -16 (+ v1-6 15)))) + (mem-usage-add! usage joint-anim-drawable 1 (asize-of this)) (dotimes (s3-0 (-> this length)) (mem-usage (-> this data s3-0) usage flags)) this) -(defun jacc-mem-usage ((compressed joint-anim-compressed-control) (usage memory-usage-block) (flags int)) +(defun jacc-mem-usage ((compressed joint-anim-compressed-control) (usage memory-usage-block) (flags mem-usage-flags)) "Account for a compressed animation control block, its fixed data, and each compressed frame." - (set! (-> usage length) (max 68 (-> usage length))) - (set! (-> usage data 67 name) "joint-anim-compressed-control") - (+! (-> usage data 67 count) 1) - (let ((control-size (+ (* (-> compressed num-frames) 4) 16))) - (+! (-> usage data 67 used) control-size) - (+! (-> usage data 67 total) (logand -16 (+ control-size 15)))) - (set! (-> usage length) (max 69 (-> usage length))) - (set! (-> usage data 68 name) "joint-anim-fixed") - (+! (-> usage data 68 count) 1) - (let ((fixed-size (+ (-> compressed fixed-qwc) 16))) - (+! (-> usage data 68 used) fixed-size) - (+! (-> usage data 68 total) (logand -16 (+ fixed-size 15)))) + (mem-usage-add! usage joint-anim-compressed-control 1 (+ (* (-> compressed num-frames) 4) 16)) + (mem-usage-add! usage joint-anim-fixed 1 (+ (-> compressed fixed-qwc) 16)) (dotimes (i (the-as int (-> compressed num-frames))) - (set! (-> usage length) (max 70 (-> usage length))) - (set! (-> usage data 69 name) "joint-anim-frame") - (+! (-> usage data 69 count) 1) - (let ((frame-size (* (-> compressed frame-qwc) 16))) - (+! (-> usage data 69 used) frame-size) - (+! (-> usage data 69 total) (logand -16 (+ frame-size 15))))) + (mem-usage-add! usage joint-anim-frame 1 (* (-> compressed frame-qwc) 16))) compressed) (defmethod print ((this joint-control-channel)) @@ -639,40 +618,24 @@ (set! (-> this extra tag) (&+ (the-as (pointer res-tag) (-> this extra)) 28))) this) -(defmethod mem-usage ((this art-mesh-anim) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this art-mesh-anim) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this mesh animation, its resource lump, and every payload object." - (set! (-> usage length) (max 72 (-> usage length))) - (set! (-> usage data 71 name) "art-mesh-anim") - (+! (-> usage data 71 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 71 used) v1-6) (+! (-> usage data 71 total) (logand -16 (+ v1-6 15)))) - (if (-> this extra) (mem-usage (-> this extra) usage (logior flags 512))) + (mem-usage-add! usage art-mesh-anim 1 (asize-of this)) + (if (-> this extra) (mem-usage (-> this extra) usage (logior flags (mem-usage-flags resource-joint-geo)))) (dotimes (s3-0 (-> this length)) (mem-usage (-> this data s3-0) usage flags)) this) -(defmethod mem-usage ((this art-joint-anim) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this art-joint-anim) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this animation group, compressed frame storage, eye animation data, and resource lump." - (set! (-> usage length) (max 75 (-> usage length))) - (set! (-> usage data 74 name) "art-joint-anim") - (+! (-> usage data 74 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 74 used) v1-6) (+! (-> usage data 74 total) (logand -16 (+ v1-6 15)))) - (if (-> this extra) (mem-usage (-> this extra) usage (logior flags 512))) + (mem-usage-add! usage art-joint-anim 1 (asize-of this)) + (if (-> this extra) (mem-usage (-> this extra) usage (logior flags (mem-usage-flags resource-joint-geo)))) (jacc-mem-usage (-> this frames) usage flags) (dotimes (s4-1 (-> this length)) - (set! (-> usage length) (max 67 (-> usage length))) - (set! (-> usage data 66 name) "joint-anim-compressed") - (+! (-> usage data 66 count) 1) - (let ((v1-22 (asize-of (-> this data s4-1)))) - (+! (-> usage data 66 used) v1-22) - (+! (-> usage data 66 total) (logand -16 (+ v1-22 15))))) + (mem-usage-add! usage joint-anim-compressed 1 (asize-of (-> this data s4-1)))) (when (and (nonzero? (-> this eye-anim-data)) (-> this eye-anim-data)) - (set! (-> usage length) (max 109 (-> usage length))) - (set! (-> usage data 108 name) "eye-anim") - (+! (-> usage data 108 count) 1) - (let ((v1-41 (* (* (+ (-> this eye-anim-data max-frame) 1) 2) 8))) - (+! (-> usage data 108 used) v1-41) - (+! (-> usage data 108 total) (logand -16 (+ v1-41 15))))) + (mem-usage-add! usage eye-anim 1 (* (* (+ (-> this eye-anim-data max-frame) 1) 2) 8))) this) (defmethod asize-of ((this art-joint-anim)) @@ -705,7 +668,7 @@ (format #t "~Tdata[~D]: @ #x~X~%" (-> this length) (-> this data)) (dotimes (s5-0 (-> this length)) (if (-> this data s5-0) - (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> this data s5-0) (mem-size (-> this data s5-0) #f 0)) + (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> this data s5-0) (mem-size (-> this data s5-0) #f (mem-usage-flags))) (format #t "~T [~D] ~A (~D bytes)~%" s5-0 (-> this data s5-0) 0))) this) @@ -759,13 +722,10 @@ (if (-> this data s5-0) (set! (-> this data s5-0) (login (-> this data s5-0))))) this) -(defmethod mem-usage ((this art-group) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this art-group) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this art group, its resource lump, and every populated art entry." - (set! (-> usage length) (max 71 (-> usage length))) - (set! (-> usage data 70 name) "art-group") - (+! (-> usage data 70 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 70 used) v1-6) (+! (-> usage data 70 total) (logand -16 (+ v1-6 15)))) - (if (-> this extra) (mem-usage (-> this extra) usage (logior flags 512))) + (mem-usage-add! usage art-group 1 (asize-of this)) + (if (-> this extra) (mem-usage (-> this extra) usage (logior flags (mem-usage-flags resource-joint-geo)))) (dotimes (s3-0 (-> this length)) (if (-> this data s3-0) (mem-usage (-> this data s3-0) usage flags))) this) @@ -792,13 +752,10 @@ "Return the art header size plus one pointer-sized mesh payload entry." (the-as int (+ (-> art size) (* (-> this length) 4)))) -(defmethod mem-usage ((this art-mesh-geo) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this art-mesh-geo) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this mesh geometry, its resource lump, and every payload object." - (set! (-> usage length) (max 73 (-> usage length))) - (set! (-> usage data 72 name) "art-mesh-geo") - (+! (-> usage data 72 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 72 used) v1-6) (+! (-> usage data 72 total) (logand -16 (+ v1-6 15)))) - (if (-> this extra) (mem-usage (-> this extra) usage (logior flags 512))) + (mem-usage-add! usage art-mesh-geo 1 (asize-of this)) + (if (-> this extra) (mem-usage (-> this extra) usage (logior flags (mem-usage-flags resource-joint-geo)))) (dotimes (s3-0 (-> this length)) (mem-usage (-> this data s3-0) usage flags)) this) @@ -845,13 +802,10 @@ (the-as int #f)) (else (dotimes (s4-1 (-> this length)) (if (name= joint-name (-> this data s4-1 name)) (return s4-1))) (the-as int #f)))) -(defmethod mem-usage ((this art-joint-geo) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this art-joint-geo) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this joint geometry, its resource lump, and every joint descriptor." - (set! (-> usage length) (max 74 (-> usage length))) - (set! (-> usage data 73 name) "art-joint-geo") - (+! (-> usage data 73 count) 1) - (let ((v1-6 (asize-of this))) (+! (-> usage data 73 used) v1-6) (+! (-> usage data 73 total) (logand -16 (+ v1-6 15)))) - (if (-> this extra) (mem-usage (-> this extra) usage (logior flags 512))) + (mem-usage-add! usage art-joint-geo 1 (asize-of this)) + (if (-> this extra) (mem-usage (-> this extra) usage (logior flags (mem-usage-flags resource-joint-geo)))) (dotimes (s3-0 (-> this length)) (mem-usage (-> this data s3-0) usage flags)) this) @@ -1119,15 +1073,9 @@ (frame-check clamped-frame)) (cond ((= (the float (the int frame-check)) frame-check) - (let* ((source-matrix (matrix-from-joint-anim-frame (-> animation-group frames) matrix-index (the int clamped-frame))) - (row0 (-> source-matrix vector 0 quad)) - (row1 (-> source-matrix vector 1 quad)) - (row2 (-> source-matrix vector 2 quad)) - (row3 (-> source-matrix vector 3 quad))) - (set! (-> destination vector 0 quad) row0) - (set! (-> destination vector 1 quad) row1) - (set! (-> destination vector 2 quad) row2) - (set! (-> destination vector 3 quad) row3)) + (matrix-copy! + destination + (matrix-from-joint-anim-frame (-> animation-group frames) matrix-index (the int clamped-frame))) destination) (else (let ((first-matrix (matrix-from-joint-anim-frame (-> animation-group frames) matrix-index (the int clamped-frame))) @@ -1162,16 +1110,7 @@ channel)) ((and (= mode 'no-push) (= command 'stack)) (set! (-> stack top) (the-as matrix (&- (the-as pointer (-> stack top)) (the-as uint matrix-size)))) - (let* ((previous-matrix (the-as matrix (&- (the-as pointer (-> stack top)) (the-as uint matrix-size)))) - (top-matrix (-> stack top)) - (row0 (-> top-matrix vector 0 quad)) - (row1 (-> top-matrix vector 1 quad)) - (row2 (-> top-matrix vector 2 quad)) - (row3 (-> top-matrix vector 3 quad))) - (set! (-> previous-matrix vector 0 quad) row0) - (set! (-> previous-matrix vector 1 quad) row1) - (set! (-> previous-matrix vector 2 quad) row2) - (set! (-> previous-matrix vector 3 quad) row3))) + (matrix-copy! (the-as matrix (&- (the-as pointer (-> stack top)) (the-as uint matrix-size))) (-> stack top))) ((= command 'push) (matrix-from-control-channel! (-> stack top) skeleton-joint channel) (set! (-> stack top) (the-as matrix (+ (the-as uint (-> stack top)) matrix-size)))) @@ -1208,15 +1147,7 @@ (defun cspace<-cspace! ((destination cspace) (source cspace)) "Copy source's bone transform into destination." (let ((destination-matrix (-> destination bone transform))) - (let* ((source-matrix (-> source bone transform)) - (row0 (-> source-matrix vector 0 quad)) - (row1 (-> source-matrix vector 1 quad)) - (row2 (-> source-matrix vector 2 quad)) - (row3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row0) - (set! (-> destination-matrix vector 1 quad) row1) - (set! (-> destination-matrix vector 2 quad) row2) - (set! (-> destination-matrix vector 3 quad) row3)) + (matrix-copy! destination-matrix (-> source bone transform)) destination-matrix)) (defun cspace<-rot-yxy! ((destination cspace) (xform transform)) @@ -1261,28 +1192,13 @@ control 'no-push)) (destination-matrix (-> space bone transform))) - (let ((row0 (-> input-matrix vector 0 quad)) - (row1 (-> input-matrix vector 1 quad)) - (row2 (-> input-matrix vector 2 quad)) - (row3 (-> input-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row0) - (set! (-> destination-matrix vector 1 quad) row1) - (set! (-> destination-matrix vector 2 quad) row2) - (set! (-> destination-matrix vector 3 quad) row3)) + (matrix-copy! destination-matrix input-matrix) destination-matrix)) (defun cspace<-matrix-joint! ((space cspace) (input-matrix matrix)) "Copy a matrix joint directly into this coordinate space's bone transform." (let ((destination-matrix (-> space bone transform))) - (let* ((source-matrix input-matrix) - (row0 (-> source-matrix vector 0 quad)) - (row1 (-> source-matrix vector 1 quad)) - (row2 (-> source-matrix vector 2 quad)) - (row3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row0) - (set! (-> destination-matrix vector 1 quad) row1) - (set! (-> destination-matrix vector 2 quad) row2) - (set! (-> destination-matrix vector 3 quad) row3)) + (matrix-copy! destination-matrix input-matrix) destination-matrix)) (defun cspace<-parented-matrix-joint! ((space cspace) (input-matrix matrix)) @@ -3125,101 +3041,101 @@ ;; 7 -> nothing 15 -> nothing (straight to fixed-next-transform) ;; frm-jmp-table and pair-jmp-table take the set bits, so their tables are the same list read ;; the other way round: 0 and 8 are the nothing case and 15 is all three with wide translation. - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 0) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 0) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 108 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 1) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 1) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 199 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 2) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 2) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 233 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 3) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 3) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 286 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 4) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 4) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 301 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 5) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 5) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 366 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 6) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 6) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 387 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 7) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 7) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 100 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 8) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 8) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 155 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 9) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 9) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 199 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 10) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 10) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 261 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 11) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 11) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 286 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 12) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 12) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 335 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 13) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 13) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 366 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 14) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 14) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 402 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work fix-jmp-table 15) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work fix-jmp-table 15) (the-as (function none) (+ (the-as uint decompress-fixed-data-to-accumulator) (* 100 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 0) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 0) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 84 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 1) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 1) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 92 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 2) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 2) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 119 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 3) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 3) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 140 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 4) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 4) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 205 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 5) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 5) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 220 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 6) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 6) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 273 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 7) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 7) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 307 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 8) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 8) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 84 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 9) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 9) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 107 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 10) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 10) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 119 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 11) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 11) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 174 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 12) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 12) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 205 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 13) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 13) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 248 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 14) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 14) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 273 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work frm-jmp-table 15) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work frm-jmp-table 15) (the-as (function none) (+ (the-as uint decompress-frame-data-to-accumulator) (* 354 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 0) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 0) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 117 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 1) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 1) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 125 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 2) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 2) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 169 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 3) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 3) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 197 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 4) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 4) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 293 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 5) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 5) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 318 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 6) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 6) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 408 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 7) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 7) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 459 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 8) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 8) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 117 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 9) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 9) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 150 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 10) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 10) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 169 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 11) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 11) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 248 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 12) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 12) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 293 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 13) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 13) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 366 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 14) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 14) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 408 4)))) - (set! (-> (the-as terrain-context #x70000000) work foreground joint-work pair-jmp-table 15) + (set! (-> (scratchpad-object terrain-context) work foreground joint-work pair-jmp-table 15) (the-as (function none) (+ (the-as uint decompress-frame-data-pair-to-accumulator) (* 533 4)))) 0) diff --git a/goal_src/jak1/engine/camera/cam-combiner.gc b/goal_src/jak1/engine/camera/cam-combiner.gc index bd0f5a7fd7..6fe9101579 100644 --- a/goal_src/jak1/engine/camera/cam-combiner.gc +++ b/goal_src/jak1/engine/camera/cam-combiner.gc @@ -29,7 +29,7 @@ (cond ((-> block param 0) (set! (-> self tracking use-point-of-interest) #t) - (set! (-> self tracking point-of-interest quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self tracking point-of-interest) (the-as vector (-> block param 0))) (set! (-> self tracking point-of-interest-blend target) 1.0)) (else (set! (-> self tracking use-point-of-interest) #f) (set! (-> self tracking point-of-interest-blend target) 0.0)))) (('set-interpolation) @@ -64,7 +64,7 @@ (copy-cam-float-seeker (-> self tracking tilt-adjust) (-> source-slave tracking tilt-adjust)) (copy-cam-float-seeker (-> self tracking underwater-blend) (-> source-slave tracking underwater-blend)) (set! (-> self tracking use-point-of-interest) (-> source-slave tracking use-point-of-interest)) - (set! (-> self tracking point-of-interest quad) (-> source-slave tracking point-of-interest quad)) + (vector-copy! (-> self tracking point-of-interest) (-> source-slave tracking point-of-interest)) (copy-cam-float-seeker (-> self tracking point-of-interest-blend) (-> source-slave tracking point-of-interest-blend)) (let ((source-position (-> source-slave trans))) (cam-calc-follow! (-> self tracking) source-position #f) @@ -93,20 +93,11 @@ (set! (-> self tracking no-follow) (-> source-slave tracking no-follow)) (copy-cam-float-seeker (-> self tracking tilt-adjust) (-> source-slave tracking tilt-adjust)) (copy-cam-float-seeker (-> self tracking underwater-blend) (-> source-slave tracking underwater-blend)) - (set! (-> self tracking follow-off quad) (-> source-slave tracking follow-off quad)) - (set! (-> self tracking follow-pt quad) (-> source-slave tracking follow-pt quad)) - (let* ((destination-tracker (-> self tracking)) - (source-tracker (-> source-slave tracking)) - (row-0 (-> source-tracker inv-mat vector 0 quad)) - (row-1 (-> source-tracker inv-mat vector 1 quad)) - (row-2 (-> source-tracker inv-mat vector 2 quad)) - (row-3 (-> source-tracker inv-mat vector 3 quad))) - (set! (-> destination-tracker inv-mat vector 0 quad) row-0) - (set! (-> destination-tracker inv-mat vector 1 quad) row-1) - (set! (-> destination-tracker inv-mat vector 2 quad) row-2) - (set! (-> destination-tracker inv-mat vector 3 quad) row-3)) + (vector-copy! (-> self tracking follow-off) (-> source-slave tracking follow-off)) + (vector-copy! (-> self tracking follow-pt) (-> source-slave tracking follow-pt)) + (matrix-copy! (-> self tracking inv-mat) (-> source-slave tracking inv-mat)) (set! (-> self tracking use-point-of-interest) (-> source-slave tracking use-point-of-interest)) - (set! (-> self tracking point-of-interest quad) (-> source-slave tracking point-of-interest quad)) + (vector-copy! (-> self tracking point-of-interest) (-> source-slave tracking point-of-interest)) (copy-cam-float-seeker (-> self tracking point-of-interest-blend) (-> source-slave tracking point-of-interest-blend)))))))) :code (behavior () @@ -132,16 +123,7 @@ ((= (-> self tracking-status) 1) (cam-calc-follow! (-> self tracking) (-> self trans) #t) (slave-set-rotation! (-> self tracking) (-> self trans) (the-as float (-> self tracking-options)) (-> self fov) #t) - (let* ((output-matrix (-> self inv-camera-rot)) - (combined-tracker (-> self tracking)) - (row-0 (-> combined-tracker inv-mat vector 0 quad)) - (row-1 (-> combined-tracker inv-mat vector 1 quad)) - (row-2 (-> combined-tracker inv-mat vector 2 quad)) - (row-3 (-> combined-tracker inv-mat vector 3 quad))) - (set! (-> output-matrix vector 0 quad) row-0) - (set! (-> output-matrix vector 1 quad) row-1) - (set! (-> output-matrix vector 2 quad) row-2) - (set! (-> output-matrix vector 3 quad) row-3))) + (matrix-copy! (-> self inv-camera-rot) (-> self tracking inv-mat))) (else (set! source-tracker (-> source-slave 0 tracking)) (let ((source-position (-> source-slave 0 trans)) @@ -262,27 +244,9 @@ ((= (-> self tracking-status) 1) (cam-calc-follow! (-> self tracking) (-> self trans) #t) (slave-set-rotation! (-> self tracking) (-> self trans) (the-as float (-> self tracking-options)) (-> self fov) #t) - (let* ((output-matrix (-> self inv-camera-rot)) - (combined-tracker (-> self tracking)) - (row-0 (-> combined-tracker inv-mat vector 0 quad)) - (row-1 (-> combined-tracker inv-mat vector 1 quad)) - (row-2 (-> combined-tracker inv-mat vector 2 quad)) - (row-3 (-> combined-tracker inv-mat vector 3 quad))) - (set! (-> output-matrix vector 0 quad) row-0) - (set! (-> output-matrix vector 1 quad) row-1) - (set! (-> output-matrix vector 2 quad) row-2) - (set! (-> output-matrix vector 3 quad) row-3))) + (matrix-copy! (-> self inv-camera-rot) (-> self tracking inv-mat))) (else - (let* ((output-matrix (-> self inv-camera-rot)) - (source-tracker (-> source-slave 0 tracking)) - (row-0 (-> source-tracker inv-mat vector 0 quad)) - (row-1 (-> source-tracker inv-mat vector 1 quad)) - (row-2 (-> source-tracker inv-mat vector 2 quad)) - (row-3 (-> source-tracker inv-mat vector 3 quad))) - (set! (-> output-matrix vector 0 quad) row-0) - (set! (-> output-matrix vector 1 quad) row-1) - (set! (-> output-matrix vector 2 quad) row-2) - (set! (-> output-matrix vector 3 quad) row-3))))))) + (matrix-copy! (-> self inv-camera-rot) (-> source-slave 0 tracking inv-mat))))))) (vector-! (-> self velocity) (-> self trans) previous-position))) (if (and *dproc* *debug-segment*) (add-frame (-> *display* frames (-> *display* on-screen) frame profile-bar 0) 'camera (new 'static 'rgba :b #xff :a #x80))) diff --git a/goal_src/jak1/engine/camera/cam-debug.gc b/goal_src/jak1/engine/camera/cam-debug.gc index 0f064fba57..e8a242845a 100644 --- a/goal_src/jak1/engine/camera/cam-debug.gc +++ b/goal_src/jak1/engine/camera/cam-debug.gc @@ -127,61 +127,49 @@ (defun cam-line-dma () "Append the current transformed debug-line endpoints and color to the no-depth-test debug DMA bucket." - (let* ((debug-buffer (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> debug-buffer base))) - (let ((cnt-tag (the-as object (-> debug-buffer base)))) - (let* ((write-buffer debug-buffer) - (dma-header (the-as object (-> write-buffer base)))) - (set! (-> (the-as dma-packet dma-header) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-header) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) - (set! (-> write-buffer base) (&+ (the-as pointer dma-header) 16))) - (let* ((write-buffer debug-buffer) - (gif-header (the-as object (-> write-buffer base)))) - (set! (-> (the-as gs-gif-tag gif-header) tag) - (new 'static - 'gif-tag64 - :nloop #x1 - :eop #x1 - :pre #x1 - :prim - (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) - :nreg #x4)) - (set! (-> (the-as gs-gif-tag gif-header) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id rgbaq) - :regs1 (gif-reg-id xyzf2) - :regs2 (gif-reg-id rgbaq) - :regs3 (gif-reg-id xyzf2))) - (set! (-> write-buffer base) (&+ (the-as pointer gif-header) 16))) - (let* ((write-buffer debug-buffer) - (vertex-packet (-> write-buffer base))) - (set! (-> (the-as (pointer uint128) vertex-packet) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) - (set! (-> (the-as (pointer uint128) vertex-packet) 1) - (-> (the-as vector (-> (scratchpad-object cam-dbg-scratch) linevec4w)) quad)) - (set! (-> write-buffer base) (&+ vertex-packet 32))) - (let* ((write-buffer debug-buffer) - (vertex-packet (-> write-buffer base))) - (set! (-> (the-as (pointer uint128) vertex-packet) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) - (set! (-> (the-as (pointer uint128) vertex-packet) 1) (-> (the-as vector (+ 16 (scratchpad-object int))) quad)) - (set! (-> write-buffer base) (&+ vertex-packet 32))) - (let ((qwc (/ (the-as int (+ (- -16 (the-as int cnt-tag)) (the-as int (-> debug-buffer base)))) 16))) - (cond - ((nonzero? qwc) - (logior! (-> (the-as dma-packet cnt-tag) dma) (shr (shl qwc 48) 48)) - (logior! (-> (the-as (pointer uint64) cnt-tag) 1) (shl (shr (shl qwc 48) 48) 32))) - (else (set! (-> debug-buffer base) (the-as (pointer uint64) cnt-tag)))))) - (let ((next-tag (-> debug-buffer base))) - (let ((next-header (the-as object (-> debug-buffer base)))) - (set! (-> (the-as dma-packet next-header) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-header) vif1) (new 'static 'vif-tag)) - (set! (-> debug-buffer base) (&+ (the-as pointer next-header) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug-no-zbuf) - packet-start - (the-as (pointer dma-tag) next-tag))))) + (with-dma-buffer-add-bucket ((debug-buffer (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug-no-zbuf)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((cnt-tag (the-as object (-> debug-buffer base)))) + (let* ((write-buffer debug-buffer) + (dma-header (the-as object (-> write-buffer base)))) + (set! (-> (the-as dma-packet dma-header) dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet dma-header) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet dma-header) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1)) + (set! (-> write-buffer base) (&+ (the-as pointer dma-header) 16))) + (let* ((write-buffer debug-buffer) + (gif-header (the-as object (-> write-buffer base)))) + (set! (-> (the-as gs-gif-tag gif-header) tag) + (new 'static + 'gif-tag64 + :nloop #x1 + :eop #x1 + :pre #x1 + :prim + (new 'static 'gs-prim :prim (gs-prim-type line) :iip #x1 :abe #x1) + :nreg #x4)) + (set! (-> (the-as gs-gif-tag gif-header) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id rgbaq) + :regs1 (gif-reg-id xyzf2) + :regs2 (gif-reg-id rgbaq) + :regs3 (gif-reg-id xyzf2))) + (set! (-> write-buffer base) (&+ (the-as pointer gif-header) 16))) + (let* ((write-buffer debug-buffer) + (vertex-packet (-> write-buffer base))) + (set! (-> (the-as (pointer uint128) vertex-packet) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) + (set! (-> (the-as (pointer uint128) vertex-packet) 1) + (-> (the-as vector (-> (scratchpad-object cam-dbg-scratch) linevec4w)) quad)) + (set! (-> write-buffer base) (&+ vertex-packet 32))) + (let* ((write-buffer debug-buffer) + (vertex-packet (-> write-buffer base))) + (set! (-> (the-as (pointer uint128) vertex-packet) 0) (-> (the-as vector (+ 32 (scratchpad-object int))) quad)) + (set! (-> (the-as (pointer uint128) vertex-packet) 1) (-> (the-as vector (+ 16 (scratchpad-object int))) quad)) + (set! (-> write-buffer base) (&+ vertex-packet 32))) + (let ((qwc (/ (the-as int (+ (- -16 (the-as int cnt-tag)) (the-as int (-> debug-buffer base)))) 16))) + (cond + ((nonzero? qwc) + (logior! (-> (the-as dma-packet cnt-tag) dma) (shr (shl qwc 48) 48)) + (logior! (-> (the-as (pointer uint64) cnt-tag) 1) (shl (shr (shl qwc 48) 48) 32))) + (else (set! (-> debug-buffer base) (the-as (pointer uint64) cnt-tag)))))))) (defun camera-line2d ((start vector4w) (end vector4w)) "Draw a line between two screen-space points. Convert pixels to GS 12.4 @@ -914,15 +902,15 @@ camera-slave state needed to reproduce and inspect the probe." (when *record-cam-collide-history* (let ((record (the-as cam-collision-record (+ (+ (* 176 *cam-collision-record-last*) 12) (the-as int *cam-collision-record*))))) - (set! (-> record pos quad) (-> position quad)) - (set! (-> record vel quad) (-> velocity quad)) - (set! (-> record view-flat quad) (-> slave view-flat quad)) - (set! (-> record desired-pos quad) (-> slave desired-pos quad)) - (set! (-> record cam-tpos-cur quad) (-> *camera* tpos-curr-adj quad)) - (set! (-> record cam-tpos-old quad) (-> *camera* tpos-old-adj quad)) - (set! (-> record string-min-val quad) (-> slave string-min-val quad)) - (set! (-> record string-max-val quad) (-> slave string-max-val quad)) - (set! (-> record view-off quad) (-> slave view-off quad)) + (vector-copy! (-> record pos) position) + (vector-copy! (-> record vel) velocity) + (vector-copy! (-> record view-flat) (-> slave view-flat)) + (vector-copy! (-> record desired-pos) (-> slave desired-pos)) + (vector-copy! (-> record cam-tpos-cur) (-> *camera* tpos-curr-adj)) + (vector-copy! (-> record cam-tpos-old) (-> *camera* tpos-old-adj)) + (vector-copy! (-> record string-min-val) (-> slave string-min-val)) + (vector-copy! (-> record string-max-val) (-> slave string-max-val)) + (vector-copy! (-> record view-off) (-> slave view-off)) (set! (-> record frame) (the-as int (-> *display* base-frame-counter))) (set! (-> record iteration) iteration) (set! (-> record move-type) move-kind) @@ -1061,16 +1049,8 @@ to the fixed state. Return position." (when (and *camera* *camera-combiner*) (send-event *camera* 'change-state cam-free-floating 0) - (set! (-> *camera-combiner* trans quad) (-> position quad)) - (let ((destination-rotation (-> *camera-combiner* inv-camera-rot)) - (row-0 (-> inverse-rotation vector 0 quad)) - (row-1 (-> inverse-rotation vector 1 quad)) - (row-2 (-> inverse-rotation vector 2 quad)) - (row-3 (-> inverse-rotation vector 3 quad))) - (set! (-> destination-rotation vector 0 quad) row-0) - (set! (-> destination-rotation vector 1 quad) row-1) - (set! (-> destination-rotation vector 2 quad) row-2) - (set! (-> destination-rotation vector 3 quad) row-3)) + (vector-copy! (-> *camera-combiner* trans) position) + (matrix-copy! (-> *camera-combiner* inv-camera-rot) inverse-rotation) (send-event *camera* 'change-state cam-fixed 0)) position) @@ -1080,16 +1060,7 @@ (vector-reset! (-> *math-camera* trans)) (matrix-identity! (-> *math-camera* inv-camera-rot)) (when *camera-combiner* - (let* ((destination-rotation (-> *math-camera* inv-camera-rot)) - (source-rotation (-> *camera-combiner* inv-camera-rot)) - (row-0 (-> source-rotation vector 0 quad)) - (row-1 (-> source-rotation vector 1 quad)) - (row-2 (-> source-rotation vector 2 quad)) - (row-3 (-> source-rotation vector 3 quad))) - (set! (-> destination-rotation vector 0 quad) row-0) - (set! (-> destination-rotation vector 1 quad) row-1) - (set! (-> destination-rotation vector 2 quad) row-2) - (set! (-> destination-rotation vector 3 quad) row-3)) - (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad))) + (matrix-copy! (-> *math-camera* inv-camera-rot) (-> *camera-combiner* inv-camera-rot)) + (vector-copy! (-> *math-camera* trans) (-> *camera-combiner* trans))) 0 (none)) diff --git a/goal_src/jak1/engine/camera/cam-interface.gc b/goal_src/jak1/engine/camera/cam-interface.gc index 6da31fa517..dd1d53b9a6 100644 --- a/goal_src/jak1/engine/camera/cam-interface.gc +++ b/goal_src/jak1/engine/camera/cam-interface.gc @@ -54,7 +54,7 @@ orientation and the position stored in the scale vector of its extra transform, then send it to the camera master as an immediate teleport." (let ((teleport-transform (new 'stack 'transformq))) - (set! (-> teleport-transform trans quad) (-> (the-as transform (-> start-entity extra)) scale quad)) + (vector-copy! (-> teleport-transform trans) (-> (the-as transform (-> start-entity extra)) scale)) (quaternion-copy! (-> teleport-transform quat) (-> start-entity quat)) (vector-identity! (-> teleport-transform scale)) (send-event *camera* 'teleport-to-transformq teleport-transform)) diff --git a/goal_src/jak1/engine/camera/cam-layout.gc b/goal_src/jak1/engine/camera/cam-layout.gc index ec37bb5596..0266adec68 100644 --- a/goal_src/jak1/engine/camera/cam-layout.gc +++ b/goal_src/jak1/engine/camera/cam-layout.gc @@ -109,19 +109,7 @@ (defun cam-layout-print ((x int) (y int) (text string)) "Draw debug text at screen coordinates x and y, terminate its DMA chain, and insert the result in the current frame's debug bucket." - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buf base))) - (draw-string-xy text dma-buf x y (font-color white) (font-flags shadow kerning)) - (let ((tail-tag (-> dma-buf base))) - (let ((packet (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) tail-tag))))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy text dma-buf x y (font-color white) (font-flags shadow kerning)))) (defun cam-layout-intersect-dist ((plane vector) (point vector) (direction vector)) "Return the signed distance along direction from point to plane, or a large sentinel when the @@ -210,7 +198,7 @@ (set! segment-distance 0.0) (set! clip-count 0) (set! clip-plane (new-stack-vector0)) - (set! (-> segment-start quad) (-> candidate-point quad)) + (vector-copy! segment-start candidate-point) (set! clip-plane-index 0) (while (< clip-plane-index (the-as int (-> tag elt-count))) (when (and (!= clip-plane-index plane-index) (!= clip-plane-index other-plane-index)) @@ -751,30 +739,22 @@ (while (< (-> self cur-entity) 0) (+! (-> self cur-entity) (-> self num-entities))) (set! *last-cur-entity* (-> self cur-entity)) - (let ((entities-left (-> self cur-entity)) - (node (-> *camera-engine* alive-list next0))) - *camera-engine* - (let ((next-node (-> node next0))) - (while (!= node (-> *camera-engine* alive-list-end)) - (let ((camera (-> (the-as connection node) param1))) - (cond - ((zero? entities-left) - (set! (-> self cam-entity) (the-as entity-camera camera)) - (set! *volume-descriptor-current* 0) - (set! *volume-point-current* 0) - (set! *volume-normal-current* 0) - (set! (-> self num-volumes) 0) - (cam-layout-entity-volume-info-create (-> self cam-entity) 'vol) - (set! (-> self first-pvol) (-> self num-volumes)) - (cam-layout-entity-volume-info-create (-> self cam-entity) 'pvol) - (set! (-> self first-cutoutvol) (-> self num-volumes)) - (cam-layout-entity-volume-info-create (-> self cam-entity) 'cutoutvol) - (set! (-> *CAM_LAYOUT-bank* intro-step) (cam-slave-get-intro-step (-> self cam-entity))) - (return #f)) - (else (+! entities-left -1)))) - (set! node next-node) - *camera-engine* - (set! next-node (-> next-node next0))))) + (let ((entities-left (-> self cur-entity))) (iterate-engine-connections (node *camera-engine*) (let ((camera (-> (the-as connection node) param1))) + (cond + ((zero? entities-left) + (set! (-> self cam-entity) (the-as entity-camera camera)) + (set! *volume-descriptor-current* 0) + (set! *volume-point-current* 0) + (set! *volume-normal-current* 0) + (set! (-> self num-volumes) 0) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'vol) + (set! (-> self first-pvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'pvol) + (set! (-> self first-cutoutvol) (-> self num-volumes)) + (cam-layout-entity-volume-info-create (-> self cam-entity) 'cutoutvol) + (set! (-> *CAM_LAYOUT-bank* intro-step) (cam-slave-get-intro-step (-> self cam-entity))) + (return #f)) + (else (+! entities-left -1)))))) #t) (defbehavior clmf-to-vol-attr cam-layout () @@ -820,7 +800,7 @@ and enable it for ten frames." (set! (-> *camera-other-fov* data) (cam-slave-get-fov (-> self cam-entity))) (cam-slave-get-vector-with-offset (the-as entity-actor (-> self cam-entity)) *camera-other-trans* 'trans) - (set! (-> *camera-other-root* quad) (-> *camera-other-trans* quad)) + (vector-copy! *camera-other-root* *camera-other-trans*) (cam-slave-get-rot (the-as entity-actor (-> self cam-entity)) *camera-other-matrix*) (set! *camera-look-through-other* 10) (set! *camera-read-analog* #f) @@ -1566,15 +1546,8 @@ (let ((print? (logtest? (the-as int options) 8)) (named-file? (logtest? (the-as int options) 16))) (if print? (format #t "~%~%~%=================================~%")) - (let ((node (-> *camera-engine* alive-list next0))) - *camera-engine* - (let ((next-node (-> node next0))) - (while (!= node (-> *camera-engine* alive-list-end)) - (let ((camera (-> (the-as connection node) param1))) - (clmf-save-single (the-as entity-camera camera) print? named-file?)) - (set! node next-node) - *camera-engine* - (set! next-node (-> next-node next0))))) + (iterate-engine-connections (node *camera-engine*) (let ((camera (-> (the-as connection node) param1))) + (clmf-save-single (the-as entity-camera camera) print? named-file?))) (if print? (format #t "===============================~%~%~%~%")) (if named-file? (format #t "camera save all completed~%"))) #t) @@ -2858,15 +2831,7 @@ and enter the active camera-layout state." (set! (-> self res-key) -1000000000.0) (set! (-> self num-entities) 0) - (let ((node (-> *camera-engine* alive-list next0))) - *camera-engine* - (let ((next-node (-> node next0))) - (while (!= node (-> *camera-engine* alive-list-end)) - (-> (the-as connection node) param1) - (+! (-> self num-entities) 1) - (set! node next-node) - *camera-engine* - (set! next-node (-> next-node next0))))) + (iterate-engine-connections (node *camera-engine*) (-> (the-as connection node) param1) (+! (-> self num-entities) 1)) (set! (-> self cur-entity) *last-cur-entity*) (clmf-next-entity 0) (set! *clm* *clm-select*) diff --git a/goal_src/jak1/engine/camera/cam-master.gc b/goal_src/jak1/engine/camera/cam-master.gc index 5d3486339c..207ceb3b25 100644 --- a/goal_src/jak1/engine/camera/cam-master.gc +++ b/goal_src/jak1/engine/camera/cam-master.gc @@ -43,22 +43,22 @@ (defbehavior reset-follow camera-master () "Reset the tracked player position and vertical speed without rebuilding the rest of the tracking state." - (set! (-> self tpos-old quad) (-> (target-cam-pos) quad)) - (set! (-> self tpos-curr quad) (-> self tpos-old quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (vector-copy! (-> self tpos-old) (target-cam-pos)) + (vector-copy! (-> self tpos-curr) (-> self tpos-old)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-curr-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-tgt) (-> self tpos-old)) (set! (-> self upspeed) 0.0)) (defbehavior reset-target-tracking camera-master () "Reset all target tracking state from the player, including position and facing, attack-aware string limits, water state, vertical offsets, and the target trail." - (set! (-> self tpos-old quad) (-> (target-cam-pos) quad)) - (set! (-> self tpos-curr quad) (-> self tpos-old quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-tgt quad) (-> self tpos-old quad)) + (vector-copy! (-> self tpos-old) (target-cam-pos)) + (vector-copy! (-> self tpos-curr) (-> self tpos-old)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-curr-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-tgt) (-> self tpos-old)) (quaternion->matrix (-> self tgt-rot-mat) (-> *target* control dir-targ)) (quaternion->matrix (-> self tgt-face-mat) (-> *target* control quat-for-control)) (vector-reset! (-> self pitch-off)) @@ -101,10 +101,10 @@ (let ((tracked-target (the-as target (-> self drawable-target process 0)))) (if (nonzero? (-> tracked-target node-list)) (vector<-cspace! (-> self tpos-old) (-> tracked-target node-list data (-> self which-bone))) - (set! (-> self tpos-old quad) (-> tracked-target control trans quad)))) - (set! (-> self tpos-curr quad) (-> self tpos-old quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (vector-copy! (-> self tpos-old) (-> tracked-target control trans)))) + (vector-copy! (-> self tpos-curr) (-> self tpos-old)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-curr-adj) (-> self tpos-old)) (set! (-> self upspeed) 0.0)) (defbehavior reset-drawable-tracking camera-master () @@ -114,43 +114,16 @@ (cond ((nonzero? (-> tracked-target node-list)) (vector<-cspace! (-> self tpos-old) (-> tracked-target node-list data (-> self which-bone))) - (let* ((target-rotation (-> self tgt-rot-mat)) - (bone-matrix (-> tracked-target node-list data (-> self which-bone) bone transform)) - (row-0 (-> bone-matrix vector 0 quad)) - (row-1 (-> bone-matrix vector 1 quad)) - (row-2 (-> bone-matrix vector 2 quad)) - (row-3 (-> bone-matrix vector 3 quad))) - (set! (-> target-rotation vector 0 quad) row-0) - (set! (-> target-rotation vector 1 quad) row-1) - (set! (-> target-rotation vector 2 quad) row-2) - (set! (-> target-rotation vector 3 quad) row-3)) + (matrix-copy! (-> self tgt-rot-mat) (-> tracked-target node-list data (-> self which-bone) bone transform)) (set! (-> self tgt-rot-mat vector 3 quad) (the-as uint128 0)) - (let* ((target-facing (-> self tgt-face-mat)) - (rotation-source (-> self tgt-rot-mat)) - (row-0 (-> rotation-source vector 0 quad)) - (row-1 (-> rotation-source vector 1 quad)) - (row-2 (-> rotation-source vector 2 quad)) - (row-3 (-> rotation-source vector 3 quad))) - (set! (-> target-facing vector 0 quad) row-0) - (set! (-> target-facing vector 1 quad) row-1) - (set! (-> target-facing vector 2 quad) row-2) - (set! (-> target-facing vector 3 quad) row-3))) + (matrix-copy! (-> self tgt-face-mat) (-> self tgt-rot-mat))) (else - (set! (-> self tpos-old quad) (-> tracked-target control trans quad)) + (vector-copy! (-> self tpos-old) (-> tracked-target control trans)) (quaternion->matrix (-> self tgt-rot-mat) (-> tracked-target control quat)) - (let* ((target-facing (-> self tgt-face-mat)) - (rotation-source (-> self tgt-rot-mat)) - (row-0 (-> rotation-source vector 0 quad)) - (row-1 (-> rotation-source vector 1 quad)) - (row-2 (-> rotation-source vector 2 quad)) - (row-3 (-> rotation-source vector 3 quad))) - (set! (-> target-facing vector 0 quad) row-0) - (set! (-> target-facing vector 1 quad) row-1) - (set! (-> target-facing vector 2 quad) row-2) - (set! (-> target-facing vector 3 quad) row-3))))) - (set! (-> self tpos-curr quad) (-> self tpos-old quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-old quad)) - (set! (-> self tpos-curr-adj quad) (-> self tpos-old quad)) + (matrix-copy! (-> self tgt-face-mat) (-> self tgt-rot-mat))))) + (vector-copy! (-> self tpos-curr) (-> self tpos-old)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-old)) + (vector-copy! (-> self tpos-curr-adj) (-> self tpos-old)) (vector-reset! (-> self pitch-off)) (set! (-> self upspeed) 0.0) (set! (-> self foot-offset) (-> *CAMERA_MASTER-bank* onscreen-foot-height)) @@ -182,44 +155,18 @@ ((and (logtest? (-> self master-options) 2) (handle->process (-> self drawable-target))) (let ((tracked-target (-> self drawable-target process 0))) (if (paused?) (return (the-as symbol #f))) - (set! (-> self tpos-old quad) (-> self tpos-curr quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-curr-adj quad)) + (vector-copy! (-> self tpos-old) (-> self tpos-curr)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-curr-adj)) (cond ((nonzero? (-> (the-as target tracked-target) node-list)) - (let* ((target-rotation (-> self tgt-rot-mat)) - (bone-matrix (-> (the-as target tracked-target) node-list data (-> self which-bone) bone transform)) - (row-0 (-> bone-matrix vector 0 quad)) - (row-1 (-> bone-matrix vector 1 quad)) - (row-2 (-> bone-matrix vector 2 quad)) - (row-3 (-> bone-matrix vector 3 quad))) - (set! (-> target-rotation vector 0 quad) row-0) - (set! (-> target-rotation vector 1 quad) row-1) - (set! (-> target-rotation vector 2 quad) row-2) - (set! (-> target-rotation vector 3 quad) row-3)) + (matrix-copy! (-> self tgt-rot-mat) + (-> (the-as target tracked-target) node-list data (-> self which-bone) bone transform)) (set! (-> self tgt-rot-mat vector 3 quad) (the-as uint128 0)) - (let* ((target-facing (-> self tgt-face-mat)) - (rotation-source (-> self tgt-rot-mat)) - (row-0 (-> rotation-source vector 0 quad)) - (row-1 (-> rotation-source vector 1 quad)) - (row-2 (-> rotation-source vector 2 quad)) - (row-3 (-> rotation-source vector 3 quad))) - (set! (-> target-facing vector 0 quad) row-0) - (set! (-> target-facing vector 1 quad) row-1) - (set! (-> target-facing vector 2 quad) row-2) - (set! (-> target-facing vector 3 quad) row-3)) + (matrix-copy! (-> self tgt-face-mat) (-> self tgt-rot-mat)) (vector<-cspace! (-> self tpos-curr) (-> (the-as target tracked-target) node-list data (-> self which-bone)))) (else (quaternion->matrix (-> self tgt-rot-mat) (-> (the-as target tracked-target) control quat)) - (let* ((target-facing (-> self tgt-face-mat)) - (rotation-source (-> self tgt-rot-mat)) - (row-0 (-> rotation-source vector 0 quad)) - (row-1 (-> rotation-source vector 1 quad)) - (row-2 (-> rotation-source vector 2 quad)) - (row-3 (-> rotation-source vector 3 quad))) - (set! (-> target-facing vector 0 quad) row-0) - (set! (-> target-facing vector 1 quad) row-1) - (set! (-> target-facing vector 2 quad) row-2) - (set! (-> target-facing vector 3 quad) row-3))))) + (matrix-copy! (-> self tgt-face-mat) (-> self tgt-rot-mat))))) (let ((ground-adjust (new-stack-vector0))) 0.0 (vector-! ground-adjust (-> self tpos-curr-adj) (-> self tpos-curr)) @@ -255,8 +202,8 @@ (not (logtest? (-> *target* water flag) (water-flag swim-ground)))) (set! (-> self under-water) 2)) ((> (-> self under-water) 0) (+! (-> self under-water) -1))) - (set! (-> self tpos-old quad) (-> self tpos-curr quad)) - (set! (-> self tpos-old-adj quad) (-> self tpos-curr-adj quad)) + (vector-copy! (-> self tpos-old) (-> self tpos-curr)) + (vector-copy! (-> self tpos-old-adj) (-> self tpos-curr-adj)) (quaternion->matrix (-> self tgt-rot-mat) (-> *target* control dir-targ)) (quaternion->matrix (-> self tgt-face-mat) (-> *target* control quat-for-control)) ;; A newly selected target eases from its saved position. The optional destination @@ -271,7 +218,7 @@ (else (vector-lerp! (-> self tpos-curr) (-> self ease-from) (target-cam-pos) (parameter-ease-sin-clamp (-> self ease-t))))) (+! (-> self ease-t) (-> self ease-step))) - (else (set! (-> self tpos-curr quad) (-> (target-cam-pos) quad)))) + (else (vector-copy! (-> self tpos-curr) (target-cam-pos)))) ;; During an edge grab, sweep a broad sphere along the target-facing axis and back the ;; tracked position away from any camera-blocking surface encountered before the end. (when (logtest? (-> *target* control root-prim prim-core action) (collide-action edgegrab-cam)) @@ -333,7 +280,7 @@ ((logtest? (-> *target* water flag) (water-flag touch-water)) (set! (-> self upspeed) 0.0)) ((< 0.0 ground-vertical-delta) (set! (-> self upspeed) 0.0)) (else (set! (-> self upspeed) ground-vertical-delta)))) - (set! (-> self tpos-tgt quad) (-> self tpos-curr quad)) + (vector-copy! (-> self tpos-tgt) (-> self tpos-curr)) (vector-! tracking-delta (-> self tpos-curr-adj) (-> self tpos-curr)) (let* ((ground-adjust-delta (vector-dot tracking-delta (-> self local-down))) (ground-pitch-adjust (if (< 0.0 ground-adjust-delta) @@ -567,17 +514,11 @@ *res-static-buf*))))) #f) (else - (let ((connection (-> *camera-engine* alive-list next0))) - *camera-engine* - (let ((next-connection (-> connection next0))) - (while (!= connection (-> *camera-engine* alive-list-end)) - (let ((region (-> (the-as connection connection) param1))) - (when (and (not (in-cam-entity-volume? (target-pos 0) (the-as entity region) 1024.0 'cutoutvol)) - (in-cam-entity-volume? (target-pos 0) (the-as entity region) 0.0 'vol)) - (if (master-switch-to-entity (the-as entity region)) (return #t)))) - (set! connection next-connection) - *camera-engine* - (set! next-connection (-> next-connection next0))))) + (iterate-engine-connections (connection *camera-engine*) + (let ((region (-> (the-as connection connection) param1))) + (when (and (not (in-cam-entity-volume? (target-pos 0) (the-as entity region) 1024.0 'cutoutvol)) + (in-cam-entity-volume? (target-pos 0) (the-as entity region) 0.0 'vol)) + (if (master-switch-to-entity (the-as entity region)) (return #t))))) (master-unset-region)))) ;; The master owns at most two camera slaves. A change-state event may name a state to instantiate @@ -626,7 +567,7 @@ (send-event self 'teleport)))) ((= event-type 'teleport-to-other-start-string) (let ((aim-direction (new 'stack-no-clear 'vector))) - (set! (-> *camera-combiner* trans quad) (-> *camera-other-trans* quad)) + (vector-copy! (-> *camera-combiner* trans) *camera-other-trans*) (vector-! aim-direction (-> self tpos-curr-adj) *camera-other-trans*) (vector-normalize! aim-direction 1.0) (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) aim-direction (new 'static 'vector :y -1.0))) @@ -644,7 +585,7 @@ (when (> argc 0) (let ((start-position (the-as object (-> block param 0))) (aim-direction (new 'stack-no-clear 'vector))) - (set! (-> *camera-combiner* trans quad) (-> (the-as vector start-position) quad)) + (vector-copy! (-> *camera-combiner* trans) (the-as vector start-position)) (vector-! aim-direction (-> self tpos-curr-adj) (the-as vector start-position)) (vector-normalize! aim-direction 1.0) (forward-down->inv-matrix (-> *camera-combiner* inv-camera-rot) aim-direction (new 'static 'vector :y -1.0))) @@ -684,7 +625,7 @@ (set! result #f)) ((= event-type 'reset-root) (dotimes (i (-> self num-slaves)) - (set! (-> self slave i 0 trans quad) (the-as uint128 0)) + (vector-zero! (-> self slave i 0 trans)) (matrix-identity! (-> self slave i 0 tracking inv-mat))) (vector-reset! (-> *camera-combiner* trans)) (set! result (matrix-identity! (-> *camera-combiner* tracking inv-mat)))) @@ -897,11 +838,11 @@ (logand! (-> self master-options) -33)) (else (if (< (the-as float (-> block param 0)) (-> self ease-t)) (set! (-> self ease-t) (the-as float (-> block param 0)))) - (set! (-> self ease-to quad) (-> (the-as vector (-> block param 1)) quad)) + (vector-copy! (-> self ease-to) (the-as vector (-> block param 1))) (logior! (-> self master-options) 32))) (set! (-> self ease-step) 0.033333335) (set! result (-> self ease-from)) - (set! (-> (the-as vector result) quad) (-> self tpos-curr-adj quad))) + (vector-copy! (the-as vector result) (-> self tpos-curr-adj))) ((= event-type 'damp-up) (let ((zero-speed 0.0)) (set! (-> self upspeed) zero-speed) (set! result zero-speed))) ((= event-type 'reset-follow) (set! result (if (handle->process (-> self drawable-target)) (reset-drawable-follow) (reset-follow)))) diff --git a/goal_src/jak1/engine/camera/cam-states.gc b/goal_src/jak1/engine/camera/cam-states.gc index afc70267b3..c93a9f3522 100644 --- a/goal_src/jak1/engine/camera/cam-states.gc +++ b/goal_src/jak1/engine/camera/cam-states.gc @@ -24,7 +24,7 @@ :enter (behavior () (when (not (-> self enter-has-run)) - (set! (-> self saved-pt quad) (-> self trans quad)) + (vector-copy! (-> self saved-pt) (-> self trans)) (set! (-> self blend-from-type) (the-as uint 1)) (set! (-> self blend-to-type) (the-as uint 0)) 0)) @@ -33,7 +33,7 @@ (loop (when (not (paused?)) (let ((curve-forward (new 'stack-no-clear 'vector))) - (set! (-> self trans quad) (-> self saved-pt quad)) + (vector-copy! (-> self trans) (-> self saved-pt)) (cam-curve-pos (-> self trans) curve-forward (the-as curve #f) #f) (when (!= (-> curve-forward w) 0.0) (vector-normalize! curve-forward (the-as float 1.0)) @@ -92,16 +92,9 @@ (when (not (paused?)) (vector<-cspace! (-> self trans) (-> (the-as pov-camera (-> *camera* pov-handle process 0)) node-list data (-> *camera* pov-bone))) - (let* ((tracking (-> self tracking)) - (bone-transform (-> (the-as pov-camera (-> *camera* pov-handle process 0)) node-list data (-> *camera* pov-bone) bone transform)) - (row-0 (-> bone-transform vector 0 quad)) - (row-1 (-> bone-transform vector 1 quad)) - (row-2 (-> bone-transform vector 2 quad)) - (row-3 (-> bone-transform vector 3 quad))) - (set! (-> tracking inv-mat vector 0 quad) row-0) - (set! (-> tracking inv-mat vector 1 quad) row-1) - (set! (-> tracking inv-mat vector 2 quad) row-2) - (set! (-> tracking inv-mat vector 3 quad) row-3)) + (matrix-copy! + (-> self tracking inv-mat) + (-> (the-as pov-camera (-> *camera* pov-handle process 0)) node-list data (-> *camera* pov-bone) bone transform)) (vector-reset! (-> self tracking inv-mat vector 3))) (suspend)))) @@ -143,7 +136,7 @@ (cond ((and (< (vector-vector-distance position previous-position) 40960.0) (< (cos (the-as float 3640.889)) (vector-dot previous-forward forward))) - (set! (-> self trans quad) (-> position quad)) + (vector-copy! (-> self trans) position) (vector-negate! (the-as vector (-> self tracking)) (-> bone-transform vector 0)) (set! (-> self tracking inv-mat vector 1 quad) (-> bone-transform vector 1 quad)) (vector-negate! (-> self tracking inv-mat vector 2) (-> bone-transform vector 2)) @@ -153,8 +146,8 @@ (if first-valid-frame? (set! first-valid-frame? #f)) first-valid-frame?) (else #t))) - (set! (-> previous-position quad) (-> position quad))) - (set! (-> previous-forward quad) (-> forward quad)))) + (vector-copy! previous-position position)) + (vector-copy! previous-forward forward))) (suspend))))) (defstate cam-pov-track (camera-slave) @@ -463,7 +456,7 @@ (vector-negate! (-> self saved-pt) (-> self spline-offset)) (let ((spline-offset-data (res-lump-struct (-> self cam-entity) 'spline-offset structure :time (the-as float -1000000000.0)))) (if spline-offset-data (vector+! (-> self spline-offset) (-> self spline-offset) (the-as vector spline-offset-data)))) - (set! (-> self trans quad) (-> self saved-pt quad)) + (vector-copy! (-> self trans) (-> self saved-pt)) (cam-calc-follow! (-> self tracking) (-> self trans) #f) (set! (-> self spline-follow-dist) (cam-slave-get-float (-> self cam-entity) 'spline-follow-dist (the-as float 0.0))) (cond @@ -503,7 +496,7 @@ (when (not (paused?)) (cam-calc-follow! (-> self tracking) (-> self trans) #t) (new 'stack 'curve) - (set! (-> self trans quad) (-> self saved-pt quad)) + (vector-copy! (-> self trans) (-> self saved-pt)) (cam-curve-pos (-> self trans) (the-as vector #f) (the-as curve #f) #t)) (suspend)))) @@ -517,7 +510,7 @@ (else (cam-standard-event-handler proc argc message block)))) :enter (behavior () - (if (not (-> self enter-has-run)) (set! (-> self saved-pt quad) (-> self trans quad)))) + (if (not (-> self enter-has-run)) (vector-copy! (-> self saved-pt) (-> self trans)))) :code (behavior () (loop @@ -558,16 +551,16 @@ (vertical-speed (-> self velocity y))) (let ((horizontal-position (new 'stack-no-clear 'vector)) (horizontal-velocity (new 'stack-no-clear 'vector))) - (set! (-> horizontal-position quad) (-> self trans quad)) + (vector-copy! horizontal-position (-> self trans)) (set! (-> horizontal-position y) 0.0) - (set! (-> horizontal-velocity quad) (-> self velocity quad)) + (vector-copy! horizontal-velocity (-> self velocity)) (set! (-> horizontal-velocity y) 0.0) (init! horizontal-seeker horizontal-position (the-as float 81.92) (fmax 819.2 (vector-length horizontal-velocity)) (the-as float 0.75)) - (set! (-> horizontal-seeker vel quad) (-> horizontal-velocity quad))) + (vector-copy! (-> horizontal-seeker vel) horizontal-velocity)) (loop (when (not (paused?)) (set! (-> horizontal-seeker target x) (-> (target-pos 0) x)) @@ -640,7 +633,7 @@ (* (fmin 1.0 (* approach-scale (-> *display* time-adjust-ratio))) (- (-> self max-angle-curr) angle)))) (vector-matrix*! current-direction ideal-direction rotation)) (else - (set! (-> current-direction quad) (-> ideal-direction quad)) + (vector-copy! current-direction ideal-direction) (if (logtest? (-> self options) 2048) (set! (-> self max-angle-curr) angle))))) (vector-normalize! current-direction (-> self pivot-rad))) @@ -669,7 +662,7 @@ (defbehavior cam-circular-code camera-slave () "Update the authored pivot, smoothly follow the target around it, constrain the camera to its orbit, and apply an optional position-driven focal pull." - (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (vector-copy! (-> self pivot-pt) (-> self saved-pt)) (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f) (let ((target-from-pivot (new-stack-vector0))) (vector-! target-from-pivot (-> *camera* tpos-curr-adj) (-> self pivot-pt)) @@ -701,7 +694,7 @@ (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) (case message (('teleport) #f) - (('outro-done) (set! (-> self trans quad) (-> *camera-combiner* trans quad)) (cam-circular-position #f)) + (('outro-done) (vector-copy! (-> self trans) (-> *camera-combiner* trans)) (cam-circular-position #f)) (else (cam-standard-event-handler proc argc message block)))) :enter (behavior () @@ -711,7 +704,7 @@ (let ((authored-offset (new-stack-vector0))) (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) (set! (-> self view-off-param) 1.0) - (set! (-> self circular-follow quad) (-> *camera* tpos-curr-adj quad)) + (vector-copy! (-> self circular-follow) (-> *camera* tpos-curr-adj)) (set! (-> self max-angle-offset) 0.0) (cond ((-> self cam-entity) @@ -733,21 +726,21 @@ (lerp-clamp (-> self fov0) (-> self fov1) (point->parameter (-> self fov-index) (-> *camera* tpos-curr-adj))))) (else (set! (-> self fov1) 0.0))) (cam-curve-setup (-> self saved-pt)) - (set! (-> self pivot-pt quad) (-> self saved-pt quad)) + (vector-copy! (-> self pivot-pt) (-> self saved-pt)) (cam-curve-pos (-> self pivot-pt) (the-as vector #f) (the-as curve #f) #f)) ((logtest? (-> self options) 128) (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) - (set! (-> self pivot-pt quad) (-> self trans quad)) - (set! (-> self saved-pt quad) (-> self pivot-pt quad))) + (vector-copy! (-> self pivot-pt) (-> self trans)) + (vector-copy! (-> self saved-pt) (-> self pivot-pt))) (else (vector-! (-> self pivot-pt) (-> *camera* tpos-curr-adj) (-> self trans)) (vector-float*! (-> self pivot-pt) (-> self pivot-pt) 0.5) (vector-flatten! (-> self pivot-pt) (-> self pivot-pt) (-> *camera* local-down)) (set! (-> self pivot-rad) (vector-length (-> self pivot-pt))) (vector+! (-> self pivot-pt) (-> self trans) (-> self pivot-pt)) - (set! (-> self saved-pt quad) (-> self pivot-pt quad))))) + (vector-copy! (-> self saved-pt) (-> self pivot-pt))))) (cam-circular-position #f) (set! (-> self blend-from-type) (the-as uint 2)) (set! (-> self blend-to-type) (the-as uint 2)))) @@ -799,7 +792,7 @@ (if (= (vector-normalize-ret-len! default-offset (- (+ 1024.0 (-> *CAMERA-bank* default-string-min-z)))) 0.0) (set! (-> default-offset z) (+ 1024.0 (-> *CAMERA-bank* default-string-min-z)))) (vector--float*! default-offset default-offset (-> *camera* local-down) (-> *CAMERA-bank* default-string-min-y)) - (set! (-> out-offset quad) (-> default-offset quad)) + (vector-copy! out-offset default-offset) (loop (vector--float*! target-offset out-offset (-> *camera* local-down) (-> *camera* target-height)) (if (< (fill-and-probe-using-line-sphere *collide-cache* @@ -816,7 +809,7 @@ (cond ((>= -32768.0 search-angle) (format #t "cam-string didn't find a spot~%") - (set! (-> out-offset quad) (-> default-offset quad)) + (vector-copy! out-offset default-offset) (return #f) search-angle) ((< 0.0 search-angle) (- search-angle)) @@ -831,7 +824,7 @@ (vector-flatten! (-> self view-flat) relative-offset (-> *camera* local-down)) (set! (-> self min-z-override) (vector-length (-> self view-flat))) (vector+! (-> self desired-pos) relative-offset (-> *camera* tpos-curr-adj)) - (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-copy! (-> self string-trans) (-> self desired-pos)) (reset! (-> self position-spline) (-> self desired-pos)) (vector-reset! (-> self velocity)) (let ((options-without-jump (logand -4097 (-> self options)))) @@ -1247,14 +1240,14 @@ (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline used-point)) (set! (-> self los-tgt-spline-pt-incarnation) (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation)) (logior! (-> self options) 4096) - (set! (-> self good-point quad) (-> *camera* target-spline point (-> *camera* target-spline used-point) position quad)) - (set! (-> self los-last-pos quad) (-> self good-point quad)) + (vector-copy! (-> self good-point) (-> *camera* target-spline point (-> *camera* target-spline used-point) position)) + (vector-copy! (-> self los-last-pos) (-> self good-point)) (when *debug-segment* (let ((jump-displacement (new 'stack-no-clear 'vector))) (vector-! jump-displacement (-> self good-point) (-> self string-trans)) (cam-collision-record-save (-> self string-trans) jump-displacement -3 'jump self))) - (set! (-> self desired-pos quad) (-> self good-point quad)) - (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-copy! (-> self desired-pos) (-> self good-point)) + (vector-copy! (-> self string-trans) (-> self good-point)) (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) (vector-reset! (-> self velocity)) @@ -1269,7 +1262,7 @@ (if *display-cam-los-debug* (format *stdcon* "good ~f~%" trail-hit-fraction)) (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline end-point)) (set! (-> self los-tgt-spline-pt-incarnation) (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation)) - (set! (-> self los-last-pos quad) (-> camera-position quad))) + (vector-copy! (-> self los-last-pos) camera-position)) ((begin (if *display-cam-los-debug* (format *stdcon* @@ -1296,14 +1289,14 @@ (set! (-> self los-tgt-spline-pt) (-> *camera* target-spline point trail-index next)) (set! (-> self los-tgt-spline-pt-incarnation) (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation)) (logior! (-> self options) 4096) - (set! (-> self good-point quad) (-> *camera* target-spline point trail-index position quad)) - (set! (-> self los-last-pos quad) (-> self good-point quad)) + (vector-copy! (-> self good-point) (-> *camera* target-spline point trail-index position)) + (vector-copy! (-> self los-last-pos) (-> self good-point)) (when *debug-segment* (let ((jump-displacement (new 'stack-no-clear 'vector))) (vector-! jump-displacement (-> self good-point) (-> self string-trans)) (cam-collision-record-save (-> self string-trans) jump-displacement -3 'jump self))) - (set! (-> self desired-pos quad) (-> self good-point quad)) - (set! (-> self string-trans quad) (-> self good-point quad)) + (vector-copy! (-> self desired-pos) (-> self good-point)) + (vector-copy! (-> self string-trans) (-> self good-point)) (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) (vector-reset! (-> self velocity)) @@ -1313,7 +1306,7 @@ (if *display-cam-los-debug* (format *stdcon* " ok~%")) (set! (-> self los-tgt-spline-pt) last-clear-index) (set! (-> self los-tgt-spline-pt-incarnation) (-> *camera* target-spline point (-> self los-tgt-spline-pt) incarnation)) - (set! (-> self los-last-pos quad) (-> camera-position quad))) + (vector-copy! (-> self los-last-pos) camera-position)) (else (if *display-cam-los-debug* (format *stdcon* @@ -1356,7 +1349,7 @@ (vector+! (-> self good-point) (-> self good-point) (the-as vector (+ (the-as uint (-> *camera* target-spline)) (* 48 (-> self los-tgt-spline-pt))))) - (set! (-> self los-last-pos quad) (-> self good-point quad)) + (vector-copy! (-> self los-last-pos) (-> self good-point)) (when *display-cam-los-debug* (format 0 "going because u(~f) > 0 frame ~D~%" recovery-fraction (current-time)) (format *stdcon* " going because u(~f) > 0 frame ~D~%" recovery-fraction (current-time))) @@ -1721,7 +1714,7 @@ (vector-! jump-displacement (-> self good-point) (-> self string-trans)) (cam-collision-record-save (-> self string-trans) jump-displacement -2 'jump self))) (logand! (-> self options) -4097) - (set! (-> self desired-pos quad) (-> self good-point quad)) + (vector-copy! (-> self desired-pos) (-> self good-point)) (cam-string-move) (vector-! (-> self view-flat) (-> self string-trans) (-> *camera* tpos-curr-adj)) (vector-flatten! (-> self view-flat) (-> self view-flat) (-> *camera* local-down)) @@ -1742,9 +1735,9 @@ "Refresh the string camera's minimum and maximum offset vectors from the camera master unless the values are locked." (when (not (-> self string-val-locked)) - (set! (-> self string-min-val quad) (-> *camera* string-min value quad)) + (vector-copy! (-> self string-min-val) (-> *camera* string-min value)) (let ((maximum-values (-> self string-max-val))) - (set! (-> maximum-values quad) (-> *camera* string-max value quad)) + (vector-copy! maximum-values (-> *camera* string-max value)) maximum-values))) ;; Main third-person camera. view-flat is the horizontal target-to-camera string. Each frame it @@ -1768,8 +1761,8 @@ (cond ((-> block param 0) (set! (-> self string-val-locked) #t) - (set! (-> self string-min-val quad) (-> (the-as vector (-> block param 0)) quad)) - (set! (-> self string-max-val quad) (-> (the-as vector (-> block param 1)) quad)) + (vector-copy! (-> self string-min-val) (the-as vector (-> block param 0))) + (vector-copy! (-> self string-max-val) (the-as vector (-> block param 1))) (set! (-> self string-max-val x) (fmax (-> self string-max-val x) (-> self string-min-val x))) (set! (-> self string-max-val y) (fmax (-> self string-max-val y) (-> self string-min-val y))) (set! (-> self string-max-val z) (fmax (-> self string-max-val z) (-> self string-min-val z)))) @@ -1823,7 +1816,7 @@ (-> *camera* local-down) (+ (-> *camera* target-height) (-> self view-off y))) (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) - (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-copy! (-> self string-trans) (-> self desired-pos)) (vector-reset! (-> self velocity)) (let ((probe-result (new 'stack-no-clear 'collide-tri-result)) (target-head (new 'stack-no-clear 'vector)) @@ -1861,10 +1854,10 @@ (-> *camera* local-down) (+ (-> *camera* target-height) (-> self view-off y))) (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) - (set! (-> self string-trans quad) (-> self desired-pos quad)) + (vector-copy! (-> self string-trans) (-> self desired-pos)) (vector-reset! (-> self velocity)))))))) - (set! (-> self trans quad) (-> self string-trans quad)) - (set! (-> self los-last-pos quad) (-> self string-trans quad)) + (vector-copy! (-> self trans) (-> self string-trans)) + (vector-copy! (-> self los-last-pos) (-> self string-trans)) (reset! (-> self position-spline) (-> self string-trans)) (set! (-> self blend-from-type) (the-as uint 2)) (set! (-> self blend-to-type) (the-as uint 2)))) @@ -1974,7 +1967,7 @@ (vector-normalize! (-> self view-flat) (-> self view-off z)) (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) (vector+! (-> self desired-pos) (-> self desired-pos) (-> self tracking follow-pt)) - (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-copy! (-> self trans) (-> self desired-pos)) (vector-reset! (-> self velocity)) (set! (-> self blend-from-type) (the-as uint 2)) (set! (-> self blend-to-type) (the-as uint 2)) @@ -2139,7 +2132,7 @@ (vector-normalize! (-> self view-flat) (-> self view-off z)) (vector--float*! (-> self desired-pos) (-> self view-flat) (-> *camera* local-down) (-> self view-off y)) (vector+! (-> self desired-pos) (-> self desired-pos) (-> *camera* tpos-curr-adj)) - (set! (-> self trans quad) (-> self desired-pos quad)) + (vector-copy! (-> self trans) (-> self desired-pos)) (vector-reset! (-> self velocity)) (set! (-> self blend-from-type) (the-as uint 0)) (set! (-> self blend-to-type) (the-as uint 1)) diff --git a/goal_src/jak1/engine/camera/cam-update.gc b/goal_src/jak1/engine/camera/cam-update.gc index 4d034a6641..160206103c 100644 --- a/goal_src/jak1/engine/camera/cam-update.gc +++ b/goal_src/jak1/engine/camera/cam-update.gc @@ -185,16 +185,7 @@ (if (= (vector-length up) 0.0) (set! (-> up y) -1.0)) (if (logtest? *external-cam-options* (external-cam-option allow-z)) (set! up (the-as vector #f))) (cam-free-floating-move *save-camera-inv-rot* (-> camera trans) up controller-index)))) - (let* ((destination-matrix (-> *math-camera* inv-camera-rot)) - (source-matrix *save-camera-inv-rot*) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3)) + (matrix-copy! (-> *math-camera* inv-camera-rot) *save-camera-inv-rot*) camera) ;; og:preserve-this PAL patch here (moved from cam-debug) @@ -204,17 +195,8 @@ (vector-reset! (-> *math-camera* trans)) (matrix-identity! (-> *math-camera* inv-camera-rot)) (when *camera-combiner* - (let* ((destination-matrix (-> *math-camera* inv-camera-rot)) - (source-matrix (-> *camera-combiner* inv-camera-rot)) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3)) - (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad))) + (matrix-copy! (-> *math-camera* inv-camera-rot) (-> *camera-combiner* inv-camera-rot)) + (vector-copy! (-> *math-camera* trans) (-> *camera-combiner* trans))) 0 (none)) @@ -251,7 +233,7 @@ (-> *target* control trans x) (-> *target* control trans y) (-> *target* control trans z)) - (set! (-> *start-pos* quad) (-> *target* control trans quad))) + (vector-copy! *start-pos* (-> *target* control trans))) (when (= *timer-value* 480) (format #t "Player pos = ~F ~F ~F~%" @@ -299,52 +281,16 @@ (*external-cam-mode* (move-camera-from-pad *math-camera*)) ((nonzero? *camera-look-through-other*) (set! (-> *math-camera* fov) (-> *camera-other-fov* data)) - (set! (-> *math-camera* trans quad) (-> *camera-other-trans* quad)) + (vector-copy! (-> *math-camera* trans) *camera-other-trans*) (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) - (let* ((destination-matrix (-> *math-camera* inv-camera-rot)) - (source-matrix *camera-other-matrix*) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3)) - (let* ((destination-matrix *save-camera-inv-rot*) - (source-matrix *camera-other-matrix*) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3))) + (matrix-copy! (-> *math-camera* inv-camera-rot) *camera-other-matrix*) + (matrix-copy! *save-camera-inv-rot* *camera-other-matrix*)) ((and *camera-combiner* (not *external-cam-mode*)) (set! (-> *math-camera* fov) (-> *camera-combiner* fov)) - (set! (-> *math-camera* trans quad) (-> *camera-combiner* trans quad)) + (vector-copy! (-> *math-camera* trans) (-> *camera-combiner* trans)) (+! (-> *math-camera* trans y) (get-no-update *camera-smush-control*)) - (let* ((destination-matrix (-> *math-camera* inv-camera-rot)) - (source-matrix (-> *camera-combiner* inv-camera-rot)) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3)) - (let* ((destination-matrix *save-camera-inv-rot*) - (source-matrix (-> *camera-combiner* inv-camera-rot)) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3))) + (matrix-copy! (-> *math-camera* inv-camera-rot) (-> *camera-combiner* inv-camera-rot)) + (matrix-copy! *save-camera-inv-rot* (-> *camera-combiner* inv-camera-rot))) (else (move-camera-from-pad *math-camera*))) (matrix-transpose! (-> *math-camera* camera-rot) (-> *math-camera* inv-camera-rot)) ;; 11650.845 GOAL angle units is 64 degrees. Narrower fields of view @@ -369,31 +315,13 @@ (-> *math-camera* smooth-t)) (quaternion->matrix (-> *math-camera* inv-camera-rot-smooth) smooth-rotation))) (else - (let* ((destination-matrix (-> *math-camera* inv-camera-rot-smooth)) - (source-matrix (-> *math-camera* inv-camera-rot)) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> destination-matrix vector 0 quad) row-0) - (set! (-> destination-matrix vector 1 quad) row-1) - (set! (-> destination-matrix vector 2 quad) row-2) - (set! (-> destination-matrix vector 3 quad) row-3)))) + (matrix-copy! (-> *math-camera* inv-camera-rot-smooth) (-> *math-camera* inv-camera-rot)))) (if (and (!= *master-mode* 'menu) *display-camera-info*) (format *stdcon* "cam pos ~M ~M ~M~%" (-> *math-camera* trans x) (-> *math-camera* trans y) (-> *math-camera* trans z))) ;; Preserve the old view-projection before rebuilding it. A reset instead ;; copies the new matrix afterward, suppressing one frame of camera motion. (when (zero? (-> *math-camera* reset)) - (let* ((previous-view-projection (-> *math-camera* prev-camera-temp)) - (view-projection (-> *math-camera* camera-temp)) - (row-0 (-> view-projection vector 0 quad)) - (row-1 (-> view-projection vector 1 quad)) - (row-2 (-> view-projection vector 2 quad)) - (row-3 (-> view-projection vector 3 quad))) - (set! (-> previous-view-projection vector 0 quad) row-0) - (set! (-> previous-view-projection vector 1 quad) row-1) - (set! (-> previous-view-projection vector 2 quad) row-2) - (set! (-> previous-view-projection vector 3 quad) row-3))) + (matrix-copy! (-> *math-camera* prev-camera-temp) (-> *math-camera* camera-temp))) (let ((view-projection (-> *math-camera* camera-temp)) (view-matrix (-> *math-camera* camera-rot)) (inverse-view-matrix (-> *math-camera* inv-camera-rot)) @@ -410,16 +338,7 @@ (matrix*! view-projection view-matrix (-> *math-camera* perspective)) (set! (-> inverse-view-matrix vector 3 quad) (-> camera-position quad))) (when (nonzero? (-> *math-camera* reset)) - (let* ((previous-view-projection (-> *math-camera* prev-camera-temp)) - (view-projection (-> *math-camera* camera-temp)) - (row-0 (-> view-projection vector 0 quad)) - (row-1 (-> view-projection vector 1 quad)) - (row-2 (-> view-projection vector 2 quad)) - (row-3 (-> view-projection vector 3 quad))) - (set! (-> previous-view-projection vector 0 quad) row-0) - (set! (-> previous-view-projection vector 1 quad) row-1) - (set! (-> previous-view-projection vector 2 quad) row-2) - (set! (-> previous-view-projection vector 3 quad) row-3)) + (matrix-copy! (-> *math-camera* prev-camera-temp) (-> *math-camera* camera-temp)) (set! (-> *math-camera* reset) 0) 0) ;; Publish the per-frame fog, homogeneous clipping, screen-offset, and @@ -448,14 +367,14 @@ ;; guard planes give TIE and shrub generation room around the visible area. (update-view-planes *math-camera* (-> *math-camera* plane) 1.0) (update-view-planes *math-camera* (-> *math-camera* guard-plane) 4.0) - (set! (-> *instance-shrub-work* guard-plane 0 quad) (-> *math-camera* guard-plane 0 quad)) - (set! (-> *instance-shrub-work* guard-plane 1 quad) (-> *math-camera* guard-plane 1 quad)) - (set! (-> *instance-shrub-work* guard-plane 2 quad) (-> *math-camera* guard-plane 2 quad)) - (set! (-> *instance-shrub-work* guard-plane 3 quad) (-> *math-camera* guard-plane 3 quad)) - (set! (-> *instance-tie-work* guard-plane 0 quad) (-> *math-camera* guard-plane 0 quad)) - (set! (-> *instance-tie-work* guard-plane 1 quad) (-> *math-camera* guard-plane 1 quad)) - (set! (-> *instance-tie-work* guard-plane 2 quad) (-> *math-camera* guard-plane 2 quad)) - (set! (-> *instance-tie-work* guard-plane 3 quad) (-> *math-camera* guard-plane 3 quad)) + (vector-copy! (-> *instance-shrub-work* guard-plane 0) (-> *math-camera* guard-plane 0)) + (vector-copy! (-> *instance-shrub-work* guard-plane 1) (-> *math-camera* guard-plane 1)) + (vector-copy! (-> *instance-shrub-work* guard-plane 2) (-> *math-camera* guard-plane 2)) + (vector-copy! (-> *instance-shrub-work* guard-plane 3) (-> *math-camera* guard-plane 3)) + (vector-copy! (-> *instance-tie-work* guard-plane 0) (-> *math-camera* guard-plane 0)) + (vector-copy! (-> *instance-tie-work* guard-plane 1) (-> *math-camera* guard-plane 1)) + (vector-copy! (-> *instance-tie-work* guard-plane 2) (-> *math-camera* guard-plane 2)) + (vector-copy! (-> *instance-tie-work* guard-plane 3) (-> *math-camera* guard-plane 3)) (update-visible *math-camera*) (if (not (paused?)) (update-wind *wind-work* *wind-scales*)) #f) diff --git a/goal_src/jak1/engine/camera/camera-h.gc b/goal_src/jak1/engine/camera/camera-h.gc index e4e7d1807c..2f2f9142be 100644 --- a/goal_src/jak1/engine/camera/camera-h.gc +++ b/goal_src/jak1/engine/camera/camera-h.gc @@ -234,7 +234,7 @@ "Initialize target and value from initial-value, or zero when it is false; clear velocity and set the acceleration and speed limits." (cond - (initial-value (set! (-> this target quad) (-> initial-value quad)) (set! (-> this value quad) (-> initial-value quad))) + (initial-value (vector-copy! (-> this target) initial-value) (vector-copy! (-> this value) initial-value)) (else (vector-reset! (-> this target)) (vector-reset! (-> this value)))) (vector-reset! (-> this vel)) (set! (-> this accel) accel) diff --git a/goal_src/jak1/engine/camera/camera.gc b/goal_src/jak1/engine/camera/camera.gc index c65e494f4e..d2796edf4d 100644 --- a/goal_src/jak1/engine/camera/camera.gc +++ b/goal_src/jak1/engine/camera/camera.gc @@ -36,7 +36,7 @@ *res-static-buf*))) (cond ((and base-value offset-value) (vector+! out (the-as vector base-value) (the-as vector offset-value)) #t) - ((the-as vector base-value) (set! (-> out quad) (-> (the-as vector base-value) quad)) #t) + ((the-as vector base-value) (vector-copy! out (the-as vector base-value)) #t) (else #f))))) (defun cam-slave-get-flags ((source-entity entity) (prop-name symbol)) @@ -244,8 +244,8 @@ (set! (-> this vec 0 quad) (-> (the-as (pointer uint128) (&+ points-data 0)))) (set! (-> this vec 1 quad) (-> (the-as (pointer uint128) (&+ points-data 16))))))) (fallback-curve - (set! (-> this vec 0 quad) (-> fallback-curve cverts 0 quad)) - (set! (-> this vec 1 quad) (-> fallback-curve cverts (+ (-> fallback-curve num-cverts) -1) quad))) + (vector-copy! (-> this vec 0) (-> fallback-curve cverts 0)) + (vector-copy! (-> this vec 1) (-> fallback-curve cverts (+ (-> fallback-curve num-cverts) -1)))) (else (return #f))))) (let ((tmp-vec (new-stack-vector0))) 0.0 @@ -256,14 +256,14 @@ (vector-! tmp-vec (-> this vec 0) cam-pos) (set! (-> this vec 1 x) (vector-length tmp-vec)) (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) - (set! (-> this vec 0 quad) (-> cam-pos quad))) + (vector-copy! (-> this vec 0) cam-pos)) ((logtest? (-> this flags) (cam-index-options RADIAL)) (vector-! tmp-vec (-> this vec 1) cam-pos) (set! (-> this vec 1 w) (vector-length tmp-vec)) (vector-! tmp-vec (-> this vec 0) cam-pos) (set! (-> this vec 1 x) (vector-length tmp-vec)) (set! (-> this vec 1 w) (- (-> this vec 1 w) (-> this vec 1 x))) - (set! (-> this vec 0 quad) (-> cam-pos quad))) + (vector-copy! (-> this vec 0) cam-pos)) (else (vector-! (-> this vec 1) (-> this vec 1) (-> this vec 0)) (set! (-> this vec 1 w) (vector-normalize-ret-len! (-> this vec 1) 1.0))))) @@ -302,7 +302,7 @@ (defmethod reset! ((this tracking-spline) (start-pos vector)) "Reset the trail to start-pos and rebuild the free chain over the remaining slots." - (set! (-> this point 0 position quad) (-> start-pos quad)) + (vector-copy! (-> this point 0 position) start-pos) (set! (-> this point 0 next) -134250495) (set! (-> this summed-len) 0.0) (set! (-> this free-point) 1) @@ -313,7 +313,7 @@ (set! (-> this max-move) 0.0) (set! (-> this sample-len) 0.0) (set! (-> this used-count) 1) - (set! (-> this old-position quad) (-> start-pos quad)) + (vector-copy! (-> this old-position) start-pos) (let ((i 1)) (while (!= i 31) (set! (-> this point i next) (+ i 1)) (+! i 1)) (set! (-> this point i next) -134250495)) 0 (none)) @@ -452,7 +452,7 @@ (set! (-> this end-point) free-pt) (set! (-> this next-to-last-point) tail-pt) (set! (-> this point free-pt next) -134250495) - (set! (-> this point free-pt position quad) (-> new-pos quad)) + (vector-copy! (-> this point free-pt position) new-pos) (+! (-> this used-count) 1) (if (< 0.0 prune-budget) (prune-shallow-points! this prune-budget))))) 0) @@ -579,12 +579,12 @@ (let ((cursor-pt (-> sampler cur-pt))) (set! (-> this debug-last-point) cursor-pt) (let ((delta (new 'stack-no-clear 'vector))) - (set! (-> this debug-old-position quad) (-> this old-position quad)) - (set! (-> this debug-out-position quad) (-> pos quad)) + (vector-copy! (-> this debug-old-position) (-> this old-position)) + (vector-copy! (-> this debug-out-position) pos) (vector-! delta pos (-> this old-position)) (apply-trail-correction! this delta cursor-pt) (vector+! pos (-> this old-position) delta))))) - (set! (-> this old-position quad) (-> pos quad)) + (vector-copy! (-> this old-position) pos) pos) (defmethod trim-to-length! ((this tracking-spline) (max-len float)) @@ -643,30 +643,12 @@ (set! (-> self change-event-from) (the-as (pointer process-drawable) #f)))) (cond (*camera-combiner* - (set! (-> self trans quad) (-> *camera-combiner* trans quad)) - (let* ((tracker (-> self tracking)) - (combiner-matrix (-> *camera-combiner* inv-camera-rot)) - (matrix-row-0 (-> combiner-matrix vector 0 quad)) - (matrix-row-1 (-> combiner-matrix vector 1 quad)) - (matrix-row-2 (-> combiner-matrix vector 2 quad)) - (matrix-row-3 (-> combiner-matrix vector 3 quad))) - (set! (-> tracker inv-mat vector 0 quad) matrix-row-0) - (set! (-> tracker inv-mat vector 1 quad) matrix-row-1) - (set! (-> tracker inv-mat vector 2 quad) matrix-row-2) - (set! (-> tracker inv-mat vector 3 quad) matrix-row-3)) + (vector-copy! (-> self trans) (-> *camera-combiner* trans)) + (matrix-copy! (-> self tracking inv-mat) (-> *camera-combiner* inv-camera-rot)) (when *camera-init-mat* - (let* ((init-tracker (-> self tracking)) - (init-matrix *camera-init-mat*) - (init-row-0 (-> init-matrix vector 0 quad)) - (init-row-1 (-> init-matrix vector 1 quad)) - (init-row-2 (-> init-matrix vector 2 quad)) - (init-row-3 (-> init-matrix vector 3 quad))) - (set! (-> init-tracker inv-mat vector 0 quad) init-row-0) - (set! (-> init-tracker inv-mat vector 1 quad) init-row-1) - (set! (-> init-tracker inv-mat vector 2 quad) init-row-2) - (set! (-> init-tracker inv-mat vector 3 quad) init-row-3))) + (matrix-copy! (-> self tracking inv-mat) *camera-init-mat*)) (set! (-> self fov) (-> *camera-combiner* fov)) - (set! (-> self velocity quad) (-> *camera-combiner* velocity quad))) + (vector-copy! (-> self velocity) (-> *camera-combiner* velocity))) (else (vector-reset! (-> self trans)) (matrix-identity! (-> self tracking inv-mat)) @@ -754,7 +736,7 @@ (cond ((-> message param 0) (set! (-> self tracking use-point-of-interest) #t) - (set! (-> self tracking point-of-interest quad) (-> (the-as vector (-> message param 0)) quad)) + (vector-copy! (-> self tracking point-of-interest) (the-as vector (-> message param 0))) (set! (-> self tracking point-of-interest-blend target) 1.0)) (else (set! (-> self tracking use-point-of-interest) #f) (set! (-> self tracking point-of-interest-blend target) 0.0)))) (('teleport) @@ -800,8 +782,8 @@ (let ((reference-pos (new 'stack-no-clear 'vector))) (curve-length (-> self spline-curve)) (if use-follow-point? - (set! (-> reference-pos quad) (-> self tracking follow-pt quad)) - (set! (-> reference-pos quad) (-> *camera* tpos-curr-adj quad))) + (vector-copy! reference-pos (-> self tracking follow-pt)) + (vector-copy! reference-pos (-> *camera* tpos-curr-adj))) (set! (-> self spline-tt) (curve-closest-point (-> self spline-curve) reference-pos (-> self spline-tt) 1024.0 10 (-> self spline-follow-dist)))) (curve-get-pos! curve-offset (-> self spline-tt) (-> self spline-curve)) @@ -881,7 +863,7 @@ (vector-float*! desired-offset desired-offset blend-factor)) (+! (-> tracker follow-blend) (/ (-> *display* time-adjust-ratio) 60)) (vector+! (-> tracker follow-off) (-> tracker follow-off) desired-offset)) - (else (set! (-> tracker follow-off quad) (-> desired-offset quad))))) + (else (vector-copy! (-> tracker follow-off) desired-offset)))) (vector+! (-> tracker follow-pt) (-> *camera* tpos-curr-adj) (-> tracker follow-off)) (vector--float*! (-> tracker follow-pt) (-> tracker follow-pt) @@ -1123,16 +1105,7 @@ (cond (smooth? (slave-matrix-blend-2 (-> tracker inv-mat) options-bits aim-vector target-matrix)) (else - (let* ((output-matrix (-> tracker inv-mat)) - (source-matrix target-matrix) - (row-0 (-> source-matrix vector 0 quad)) - (row-1 (-> source-matrix vector 1 quad)) - (row-2 (-> source-matrix vector 2 quad)) - (row-3 (-> source-matrix vector 3 quad))) - (set! (-> output-matrix vector 0 quad) row-0) - (set! (-> output-matrix vector 1 quad) row-1) - (set! (-> output-matrix vector 2 quad) row-2) - (set! (-> output-matrix vector 3 quad) row-3))))) + (matrix-copy! (-> tracker inv-mat) target-matrix)))) (mat-remove-z-rot (-> tracker inv-mat) (-> *camera* local-down)) 0 (none))) @@ -1182,7 +1155,7 @@ (if (< axis-side 0.0) (vector-negate! rotation-axis rotation-axis)))) (else (set! (-> from-direction quad) (-> from-vector quad)) - (set! (-> to-direction quad) (-> to-vector quad)) + (vector-copy! to-direction to-vector) (set! from-length (vector-normalize-ret-len! from-direction 1.0)) (set! to-length (vector-normalize-ret-len! to-direction 1.0)) (vector-normalize! (vector-cross! rotation-axis to-vector from-vector) 1.0))) @@ -1232,7 +1205,7 @@ (if (< axis-side 0.0) (vector-negate! rotation-axis rotation-axis)))) (else (set! (-> from-direction quad) (-> from-vector quad)) - (set! (-> to-direction quad) (-> to-vector quad)) + (vector-copy! to-direction to-vector) (set! from-length (vector-normalize-ret-len! from-direction 1.0)) (set! to-length (vector-normalize-ret-len! to-direction 1.0)) (vector-normalize! (vector-cross! rotation-axis to-vector from-vector) 1.0))) diff --git a/goal_src/jak1/engine/camera/pov-camera.gc b/goal_src/jak1/engine/camera/pov-camera.gc index 95c8da8f09..bf8cedbc85 100644 --- a/goal_src/jak1/engine/camera/pov-camera.gc +++ b/goal_src/jak1/engine/camera/pov-camera.gc @@ -147,7 +147,7 @@ (set-time! (-> self debounce-start-time)) (logclear! (-> self mask) (process-mask actor-pause movie enemy platform projectile)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (when (logtest? (-> self flags) (pov-camera-flag inherit-orientation)) (let ((orientation-source (if (and (nonzero? owner) (type-type? (-> owner type) process-drawable)) owner))) (quaternion-copy! (-> self root quat) (-> orientation-source root quat)))) diff --git a/goal_src/jak1/engine/collide/collide-cache.gc b/goal_src/jak1/engine/collide/collide-cache.gc index 355927ca5b..f370957993 100644 --- a/goal_src/jak1/engine/collide/collide-cache.gc +++ b/goal_src/jak1/engine/collide/collide-cache.gc @@ -3554,156 +3554,132 @@ integer bounds overlap collide-work.collide-box4w." (s3-0 (-> obj collide-box4w max quad))) (let ((v1-1 (the-as uint128 (make-u128 0 16)))) (.pand v1-2 v1-1 s5-0)) (when (nonzero? (the-as int v1-2)) - (let ((v1-5 (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((s2-0 (-> v1-5 next0))) - (while (!= v1-5 (-> *collide-player-list* alive-list-end)) - (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) - (a0-3 (-> v1-6 root-prim))) - (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s5-0 a1-0)) - (b! (zero? (the-as int a1-1)) cfg-7) - (nop!) - (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-0 vf4) - (let ((v1-7 (-> v1-6 process))) - (.mov a3-0 vf5) - (let ((a1-3 (-> obj proc))) - (.pcgtw a2-1 a2-0 s3-0) - (.pcgtw a3-1 s4-0 a3-0) - (.por a2-2 a2-1 a3-1) - (.ppach a2-3 zero a2-2) - (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) - (b! (= a1-3 v1-7) cfg-6 :delay (nop!)))) - (add-fg-prim-using-box a0-3 obj)) - (label cfg-6) - 0 - (label cfg-7) - (set! v1-5 s2-0) - *collide-player-list* - (set! s2-0 (-> s2-0 next0)))))) + (iterate-engine-connections (v1-5 *collide-player-list*) + (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (a0-3 (-> v1-6 root-prim))) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s5-0 a1-0)) + (b! (zero? (the-as int a1-1)) cfg-7) + (nop!) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-0 vf4) + (let ((v1-7 (-> v1-6 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s3-0) + (.pcgtw a3-1 s4-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) + (b! (= a1-3 v1-7) cfg-6 :delay (nop!)))) + (add-fg-prim-using-box a0-3 obj)) + (label cfg-6) + 0 + (label cfg-7))) (let ((v1-14 (the-as uint128 (make-u128 0 14)))) (.pand v1-15 v1-14 s5-0)) (when (nonzero? (the-as int v1-15)) (let ((v1-17 (the-as uint128 (make-u128 0 2)))) (.pand v1-18 v1-17 s5-0)) (when (nonzero? (the-as int v1-18)) - (let ((v1-21 (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((s2-1 (-> v1-21 next0))) - (while (!= v1-21 (-> *collide-hit-by-player-list* alive-list-end)) - (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) - (a0-10 (-> v1-22 root-prim))) - (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s5-0 a1-5)) - (b! (zero? (the-as int a1-6)) cfg-18) - (nop!) - (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-5 vf4) - (let ((v1-23 (-> v1-22 process))) - (.mov a3-2 vf5) - (let ((a1-8 (-> obj proc))) - (.pcgtw a2-6 a2-5 s3-0) - (.pcgtw a3-3 s4-0 a3-2) - (.por a2-7 a2-6 a3-3) - (.ppach a2-8 zero a2-7) - (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) - (b! (= a1-8 v1-23) cfg-17 :delay (nop!)))) - (add-fg-prim-using-box a0-10 obj)) - (label cfg-17) - 0 - (label cfg-18) - (set! v1-21 s2-1) - *collide-hit-by-player-list* - (set! s2-1 (-> s2-1 next0)))))) + (iterate-engine-connections (v1-21 *collide-hit-by-player-list*) + (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) + (a0-10 (-> v1-22 root-prim))) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s5-0 a1-5)) + (b! (zero? (the-as int a1-6)) cfg-18) + (nop!) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-23 (-> v1-22 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s3-0) + (.pcgtw a3-3 s4-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) + (b! (= a1-8 v1-23) cfg-17 :delay (nop!)))) + (add-fg-prim-using-box a0-10 obj)) + (label cfg-17) + 0 + (label cfg-18))) (let ((v1-30 (the-as uint128 (make-u128 0 4)))) (.pand v1-31 v1-30 s5-0)) (when (nonzero? (the-as int v1-31)) - (let ((v1-34 (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((s2-2 (-> v1-34 next0))) - (while (!= v1-34 (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) - (a0-17 (-> v1-35 root-prim))) - (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s5-0 a1-10)) - (b! (zero? (the-as int a1-11)) cfg-28) - (nop!) - (nop!) - (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-10 vf4) - (let ((v1-36 (-> v1-35 process))) - (.mov a3-4 vf5) - (let ((a1-13 (-> obj proc))) - (.pcgtw a2-11 a2-10 s3-0) - (.pcgtw a3-5 s4-0 a3-4) - (.por a2-12 a2-11 a3-5) - (.ppach a2-13 zero a2-12) - (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) - (b! (= a1-13 v1-36) cfg-27 :delay (nop!)))) - (add-fg-prim-using-box a0-17 obj)) - (label cfg-27) - 0 - (label cfg-28) - (set! v1-34 s2-2) - *collide-usually-hit-by-player-list* - (set! s2-2 (-> s2-2 next0)))))) + (iterate-engine-connections (v1-34 *collide-usually-hit-by-player-list*) + (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) + (a0-17 (-> v1-35 root-prim))) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s5-0 a1-10)) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-36 (-> v1-35 process))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s3-0) + (.pcgtw a3-5 s4-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) + (b! (= a1-13 v1-36) cfg-27 :delay (nop!)))) + (add-fg-prim-using-box a0-17 obj)) + (label cfg-27) + 0 + (label cfg-28))) (let ((v1-43 (the-as uint128 (make-u128 0 8)))) (.pand v1-44 v1-43 s5-0)) (when (nonzero? (the-as int v1-44)) - (let ((v1-46 (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((s2-3 (-> v1-46 next0))) - (while (!= v1-46 (-> *collide-hit-by-others-list* alive-list-end)) - (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) - (a0-24 (-> v1-47 root-prim))) - (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s5-0 a1-15)) - (b! (zero? (the-as int a1-16)) cfg-38) - (nop!) - (nop!) - (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-15 vf4) - (let ((v1-48 (-> v1-47 process))) - (.mov a3-6 vf5) - (let ((a1-18 (-> obj proc))) - (.pcgtw a2-16 a2-15 s3-0) - (.pcgtw a3-7 s4-0 a3-6) - (.por a2-17 a2-16 a3-7) - (.ppach a2-18 zero a2-17) - (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) - (b! (= a1-18 v1-48) cfg-37 :delay (nop!)))) - (add-fg-prim-using-box a0-24 obj)) - (label cfg-37) - 0 - (label cfg-38) - (set! v1-46 s2-3) - *collide-hit-by-others-list* - (set! s2-3 (-> s2-3 next0)))))))) + (iterate-engine-connections (v1-46 *collide-hit-by-others-list*) + (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) + (a0-24 (-> v1-47 root-prim))) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s5-0 a1-15)) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-48 (-> v1-47 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s3-0) + (.pcgtw a3-7 s4-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) + (b! (= a1-18 v1-48) cfg-37 :delay (nop!)))) + (add-fg-prim-using-box a0-24 obj)) + (label cfg-37) + 0 + (label cfg-38))))) (none))) (defmethod add-fg-prim-using-box ((obj collide-shape-prim) (cache collide-cache)) @@ -3859,151 +3835,127 @@ integer bounds overlap collide-work.collide-box4w." (s3-0 (-> obj collide-box4w max quad))) (let ((v1-1 (the-as uint128 (make-u128 0 16)))) (.pand v1-2 v1-1 s5-0)) (when (nonzero? (the-as int v1-2)) - (let ((v1-5 (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((s2-0 (-> v1-5 next0))) - (while (!= v1-5 (-> *collide-player-list* alive-list-end)) - (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) - (a0-3 (-> v1-6 root-prim))) - (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s5-0 a1-0)) - (b! (zero? (the-as int a1-1)) cfg-7) - (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (.add.w.vf vf3 vf1 vf1) - (.ftoi.vf vf4 vf2) - (.ftoi.vf vf5 vf3) - (.mov a2-0 vf4) - (let ((v1-7 (-> v1-6 process))) - (.mov a3-0 vf5) - (let ((a1-3 (-> obj proc))) - (.pcgtw a2-1 a2-0 s3-0) - (.pcgtw a3-1 s4-0 a3-0) - (.por a2-2 a2-1 a3-1) - (.ppach a2-3 zero a2-2) - (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) - (b! (= a1-3 v1-7) cfg-6 :delay (nop!)))) - (add-fg-prim-using-y-probe a0-3 obj)) - (label cfg-6) - 0 - (label cfg-7) - (set! v1-5 s2-0) - *collide-player-list* - (set! s2-0 (-> s2-0 next0)))))) + (iterate-engine-connections (v1-5 *collide-player-list*) + (let* ((v1-6 (the-as collide-shape (-> (the-as connection v1-5) param1))) + (a0-3 (-> v1-6 root-prim))) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s5-0 a1-0)) + (b! (zero? (the-as int a1-1)) cfg-7) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (.add.w.vf vf3 vf1 vf1) + (.ftoi.vf vf4 vf2) + (.ftoi.vf vf5 vf3) + (.mov a2-0 vf4) + (let ((v1-7 (-> v1-6 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s3-0) + (.pcgtw a3-1 s4-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) + (b! (= a1-3 v1-7) cfg-6 :delay (nop!)))) + (add-fg-prim-using-y-probe a0-3 obj)) + (label cfg-6) + 0 + (label cfg-7))) (let ((v1-14 (the-as uint128 (make-u128 0 14)))) (.pand v1-15 v1-14 s5-0)) (when (nonzero? (the-as int v1-15)) (let ((v1-17 (the-as uint128 (make-u128 0 2)))) (.pand v1-18 v1-17 s5-0)) (when (nonzero? (the-as int v1-18)) - (let ((v1-21 (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((s2-1 (-> v1-21 next0))) - (while (!= v1-21 (-> *collide-hit-by-player-list* alive-list-end)) - (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) - (a0-10 (-> v1-22 root-prim))) - (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s5-0 a1-5)) - (b! (zero? (the-as int a1-6)) cfg-18) - (nop!) - (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-5 vf4) - (let ((v1-23 (-> v1-22 process))) - (.mov a3-2 vf5) - (let ((a1-8 (-> obj proc))) - (.pcgtw a2-6 a2-5 s3-0) - (.pcgtw a3-3 s4-0 a3-2) - (.por a2-7 a2-6 a3-3) - (.ppach a2-8 zero a2-7) - (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) - (b! (= a1-8 v1-23) cfg-17 :delay (nop!)))) - (add-fg-prim-using-y-probe a0-10 obj)) - (label cfg-17) - 0 - (label cfg-18) - (set! v1-21 s2-1) - *collide-hit-by-player-list* - (set! s2-1 (-> s2-1 next0)))))) + (iterate-engine-connections (v1-21 *collide-hit-by-player-list*) + (let* ((v1-22 (the-as collide-shape (-> (the-as connection v1-21) param1))) + (a0-10 (-> v1-22 root-prim))) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s5-0 a1-5)) + (b! (zero? (the-as int a1-6)) cfg-18) + (nop!) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-23 (-> v1-22 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s3-0) + (.pcgtw a3-3 s4-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) + (b! (= a1-8 v1-23) cfg-17 :delay (nop!)))) + (add-fg-prim-using-y-probe a0-10 obj)) + (label cfg-17) + 0 + (label cfg-18))) (let ((v1-30 (the-as uint128 (make-u128 0 4)))) (.pand v1-31 v1-30 s5-0)) (when (nonzero? (the-as int v1-31)) - (let ((v1-34 (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((s2-2 (-> v1-34 next0))) - (while (!= v1-34 (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) - (a0-17 (-> v1-35 root-prim))) - (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s5-0 a1-10)) - (b! (zero? (the-as int a1-11)) cfg-28) - (nop!) - (nop!) - (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-10 vf4) - (let ((v1-36 (-> v1-35 process))) - (.mov a3-4 vf5) - (let ((a1-13 (-> obj proc))) - (.pcgtw a2-11 a2-10 s3-0) - (.pcgtw a3-5 s4-0 a3-4) - (.por a2-12 a2-11 a3-5) - (.ppach a2-13 zero a2-12) - (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) - (b! (= a1-13 v1-36) cfg-27 :delay (nop!)))) - (add-fg-prim-using-y-probe a0-17 obj)) - (label cfg-27) - 0 - (label cfg-28) - (set! v1-34 s2-2) - *collide-usually-hit-by-player-list* - (set! s2-2 (-> s2-2 next0)))))) + (iterate-engine-connections (v1-34 *collide-usually-hit-by-player-list*) + (let* ((v1-35 (the-as collide-shape (-> (the-as connection v1-34) param1))) + (a0-17 (-> v1-35 root-prim))) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s5-0 a1-10)) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-36 (-> v1-35 process))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s3-0) + (.pcgtw a3-5 s4-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) + (b! (= a1-13 v1-36) cfg-27 :delay (nop!)))) + (add-fg-prim-using-y-probe a0-17 obj)) + (label cfg-27) + 0 + (label cfg-28))) (let ((v1-43 (the-as uint128 (make-u128 0 8)))) (.pand v1-44 v1-43 s5-0)) (when (nonzero? (the-as int v1-44)) - (let ((v1-46 (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((s2-3 (-> v1-46 next0))) - (while (!= v1-46 (-> *collide-hit-by-others-list* alive-list-end)) - (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) - (a0-24 (-> v1-47 root-prim))) - (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s5-0 a1-15)) - (b! (zero? (the-as int a1-16)) cfg-38) - (nop!) - (nop!) - (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) - (.sub.w.vf vf2 vf1 vf1) - (nop!) - (.add.w.vf vf3 vf1 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-15 vf4) - (let ((v1-48 (-> v1-47 process))) - (.mov a3-6 vf5) - (let ((a1-18 (-> obj proc))) - (.pcgtw a2-16 a2-15 s3-0) - (.pcgtw a3-7 s4-0 a3-6) - (.por a2-17 a2-16 a3-7) - (.ppach a2-18 zero a2-17) - (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) - (b! (= a1-18 v1-48) cfg-37 :delay (nop!)))) - (add-fg-prim-using-y-probe a0-24 obj)) - (label cfg-37) - 0 - (label cfg-38) - (set! v1-46 s2-3) - *collide-hit-by-others-list* - (set! s2-3 (-> s2-3 next0)))))))) + (iterate-engine-connections (v1-46 *collide-hit-by-others-list*) + (let* ((v1-47 (the-as collide-shape (-> (the-as connection v1-46) param1))) + (a0-24 (-> v1-47 root-prim))) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s5-0 a1-15)) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (nop!) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.sub.w.vf vf2 vf1 vf1) + (nop!) + (.add.w.vf vf3 vf1 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-48 (-> v1-47 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s3-0) + (.pcgtw a3-7 s4-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) + (b! (= a1-18 v1-48) cfg-37 :delay (nop!)))) + (add-fg-prim-using-y-probe a0-24 obj)) + (label cfg-37) + 0 + (label cfg-38))))) (none))) (defmethod add-fg-prim-using-y-probe ((obj collide-shape-prim) (cache collide-cache)) @@ -4205,180 +4157,156 @@ integer bounds overlap collide-work.collide-box4w." (.mov v1-1 vf31) (let ((v1-3 (the-as uint128 (make-u128 0 16)))) (.pand v1-4 v1-3 s3-0)) (when (nonzero? (the-as int v1-4)) - (let ((v1-7 (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((s2-0 (-> v1-7 next0))) - (while (!= v1-7 (-> *collide-player-list* alive-list-end)) - (let* ((v1-8 (the-as collide-shape (-> (the-as connection v1-7) param1))) - (a0-3 (-> v1-8 root-prim))) - (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s3-0 a1-0)) - (b! (zero? (the-as int a1-1)) cfg-7) - (.mul.w.vf acc vf31 vf0) - (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) - (.add.mul.x.vf acc vf28 vf1 acc) - (nop!) - (.add.mul.y.vf acc vf29 vf1 acc) - (nop!) - (.add.mul.z.vf vf6 vf30 vf1 acc) - (nop!) - (.sub.w.vf.xyz vf2 vf6 vf1) - (nop!) - (.add.w.vf.xyz vf3 vf6 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-0 vf4) - (let ((v1-9 (-> v1-8 process))) - (.mov a3-0 vf5) - (let ((a1-3 (-> obj proc))) - (.pcgtw a2-1 a2-0 s4-0) - (.pcgtw a3-1 s5-0 a3-0) - (.por a2-2 a2-1 a3-1) - (.ppach a2-3 zero a2-2) - (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) - (b! (= a1-3 v1-9) cfg-6 :delay (nop!)))) - (add-fg-prim-using-line-sphere a0-3 obj)) - (label cfg-6) - 0 - (label cfg-7) - (set! v1-7 s2-0) - *collide-player-list* - (set! s2-0 (-> s2-0 next0)))))) + (iterate-engine-connections (v1-7 *collide-player-list*) + (let* ((v1-8 (the-as collide-shape (-> (the-as connection v1-7) param1))) + (a0-3 (-> v1-8 root-prim))) + (let ((a1-0 (the-as uint128 (-> a0-3 prim-core collide-as)))) (.pand a1-1 s3-0 a1-0)) + (b! (zero? (the-as int a1-1)) cfg-7) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-3 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf.xyz vf2 vf6 vf1) + (nop!) + (.add.w.vf.xyz vf3 vf6 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-0 vf4) + (let ((v1-9 (-> v1-8 process))) + (.mov a3-0 vf5) + (let ((a1-3 (-> obj proc))) + (.pcgtw a2-1 a2-0 s4-0) + (.pcgtw a3-1 s5-0 a3-0) + (.por a2-2 a2-1 a3-1) + (.ppach a2-3 zero a2-2) + (let ((a2-4 (shl (the-as int a2-3) 16))) (nop!) (b! (nonzero? a2-4) cfg-6 :delay (nop!))) + (b! (= a1-3 v1-9) cfg-6 :delay (nop!)))) + (add-fg-prim-using-line-sphere a0-3 obj)) + (label cfg-6) + 0 + (label cfg-7))) (let ((v1-16 (the-as uint128 (make-u128 0 14)))) (.pand v1-17 v1-16 s3-0)) (when (nonzero? (the-as int v1-17)) (let ((v1-19 (the-as uint128 (make-u128 0 2)))) (.pand v1-20 v1-19 s3-0)) (when (nonzero? (the-as int v1-20)) - (let ((v1-23 (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((s2-1 (-> v1-23 next0))) - (while (!= v1-23 (-> *collide-hit-by-player-list* alive-list-end)) - (let* ((v1-24 (the-as collide-shape (-> (the-as connection v1-23) param1))) - (a0-10 (-> v1-24 root-prim))) - (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s3-0 a1-5)) - (b! (zero? (the-as int a1-6)) cfg-18) - (.mul.w.vf acc vf31 vf0) - (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) - (.add.mul.x.vf acc vf28 vf1 acc) - (nop!) - (.add.mul.y.vf acc vf29 vf1 acc) - (nop!) - (.add.mul.z.vf vf6 vf30 vf1 acc) - (nop!) - (.sub.w.vf.xyz vf2 vf6 vf1) - (nop!) - (.add.w.vf.xyz vf3 vf6 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-5 vf4) - (let ((v1-25 (-> v1-24 process))) - (.mov a3-2 vf5) - (let ((a1-8 (-> obj proc))) - (.pcgtw a2-6 a2-5 s4-0) - (.pcgtw a3-3 s5-0 a3-2) - (.por a2-7 a2-6 a3-3) - (.ppach a2-8 zero a2-7) - (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) - (b! (= a1-8 v1-25) cfg-17 :delay (nop!)))) - (add-fg-prim-using-line-sphere a0-10 obj)) - (label cfg-17) - 0 - (label cfg-18) - (set! v1-23 s2-1) - *collide-hit-by-player-list* - (set! s2-1 (-> s2-1 next0)))))) + (iterate-engine-connections (v1-23 *collide-hit-by-player-list*) + (let* ((v1-24 (the-as collide-shape (-> (the-as connection v1-23) param1))) + (a0-10 (-> v1-24 root-prim))) + (let ((a1-5 (the-as uint128 (-> a0-10 prim-core collide-as)))) (.pand a1-6 s3-0 a1-5)) + (b! (zero? (the-as int a1-6)) cfg-18) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-10 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf.xyz vf2 vf6 vf1) + (nop!) + (.add.w.vf.xyz vf3 vf6 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-5 vf4) + (let ((v1-25 (-> v1-24 process))) + (.mov a3-2 vf5) + (let ((a1-8 (-> obj proc))) + (.pcgtw a2-6 a2-5 s4-0) + (.pcgtw a3-3 s5-0 a3-2) + (.por a2-7 a2-6 a3-3) + (.ppach a2-8 zero a2-7) + (let ((a2-9 (shl (the-as int a2-8) 16))) (nop!) (b! (nonzero? a2-9) cfg-17 :delay (nop!))) + (b! (= a1-8 v1-25) cfg-17 :delay (nop!)))) + (add-fg-prim-using-line-sphere a0-10 obj)) + (label cfg-17) + 0 + (label cfg-18))) (let ((v1-32 (the-as uint128 (make-u128 0 4)))) (.pand v1-33 v1-32 s3-0)) (when (nonzero? (the-as int v1-33)) - (let ((v1-36 (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((s2-2 (-> v1-36 next0))) - (while (!= v1-36 (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let* ((v1-37 (the-as collide-shape (-> (the-as connection v1-36) param1))) - (a0-17 (-> v1-37 root-prim))) - (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s3-0 a1-10)) - (b! (zero? (the-as int a1-11)) cfg-28) - (nop!) - (.mul.w.vf acc vf31 vf0) - (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) - (.add.mul.x.vf acc vf28 vf1 acc) - (nop!) - (.add.mul.y.vf acc vf29 vf1 acc) - (nop!) - (.add.mul.z.vf vf6 vf30 vf1 acc) - (nop!) - (.sub.w.vf.xyz vf2 vf6 vf1) - (nop!) - (.add.w.vf.xyz vf3 vf6 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-10 vf4) - (let ((v1-38 (the-as basic (-> v1-37 process)))) - (.mov a3-4 vf5) - (let ((a1-13 (-> obj proc))) - (.pcgtw a2-11 a2-10 s4-0) - (.pcgtw a3-5 s5-0 a3-4) - (.por a2-12 a2-11 a3-5) - (.ppach a2-13 zero a2-12) - (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) - (b! (= a1-13 (the-as process-drawable v1-38)) cfg-27 :delay (nop!)))) - (add-fg-prim-using-line-sphere a0-17 obj)) - (label cfg-27) - 0 - (label cfg-28) - (set! v1-36 s2-2) - *collide-usually-hit-by-player-list* - (set! s2-2 (-> s2-2 next0)))))) + (iterate-engine-connections (v1-36 *collide-usually-hit-by-player-list*) + (let* ((v1-37 (the-as collide-shape (-> (the-as connection v1-36) param1))) + (a0-17 (-> v1-37 root-prim))) + (let ((a1-10 (the-as uint128 (-> a0-17 prim-core collide-as)))) (.pand a1-11 s3-0 a1-10)) + (b! (zero? (the-as int a1-11)) cfg-28) + (nop!) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-17 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf.xyz vf2 vf6 vf1) + (nop!) + (.add.w.vf.xyz vf3 vf6 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-10 vf4) + (let ((v1-38 (the-as basic (-> v1-37 process)))) + (.mov a3-4 vf5) + (let ((a1-13 (-> obj proc))) + (.pcgtw a2-11 a2-10 s4-0) + (.pcgtw a3-5 s5-0 a3-4) + (.por a2-12 a2-11 a3-5) + (.ppach a2-13 zero a2-12) + (let ((a2-14 (shl (the-as int a2-13) 16))) (nop!) (b! (nonzero? a2-14) cfg-27 :delay (nop!))) + (b! (= a1-13 (the-as process-drawable v1-38)) cfg-27 :delay (nop!)))) + (add-fg-prim-using-line-sphere a0-17 obj)) + (label cfg-27) + 0 + (label cfg-28))) (let ((v1-45 (the-as uint128 (make-u128 0 8)))) (.pand v1-46 v1-45 s3-0)) (when (nonzero? (the-as int v1-46)) - (let ((v1-48 (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((s2-3 (-> v1-48 next0))) - (while (!= v1-48 (-> *collide-hit-by-others-list* alive-list-end)) - (let* ((v1-49 (the-as collide-shape (-> (the-as connection v1-48) param1))) - (a0-24 (-> v1-49 root-prim))) - (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s3-0 a1-15)) - (b! (zero? (the-as int a1-16)) cfg-38) - (nop!) - (.mul.w.vf acc vf31 vf0) - (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) - (.add.mul.x.vf acc vf28 vf1 acc) - (nop!) - (.add.mul.y.vf acc vf29 vf1 acc) - (nop!) - (.add.mul.z.vf vf6 vf30 vf1 acc) - (nop!) - (.sub.w.vf.xyz vf2 vf6 vf1) - (nop!) - (.add.w.vf.xyz vf3 vf6 vf1) - (nop!) - (.ftoi.vf vf4 vf2) - (nop!) - (.ftoi.vf vf5 vf3) - (nop!) - (.mov a2-15 vf4) - (let ((v1-50 (-> v1-49 process))) - (.mov a3-6 vf5) - (let ((a1-18 (-> obj proc))) - (.pcgtw a2-16 a2-15 s4-0) - (.pcgtw a3-7 s5-0 a3-6) - (.por a2-17 a2-16 a3-7) - (.ppach a2-18 zero a2-17) - (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) - (b! (= a1-18 v1-50) cfg-37 :delay (nop!)))) - (add-fg-prim-using-line-sphere a0-24 obj)) - (label cfg-37) - 0 - (label cfg-38) - (set! v1-48 s2-3) - *collide-hit-by-others-list* - (set! s2-3 (-> s2-3 next0)))))))) + (iterate-engine-connections (v1-48 *collide-hit-by-others-list*) + (let* ((v1-49 (the-as collide-shape (-> (the-as connection v1-48) param1))) + (a0-24 (-> v1-49 root-prim))) + (let ((a1-15 (the-as uint128 (-> a0-24 prim-core collide-as)))) (.pand a1-16 s3-0 a1-15)) + (b! (zero? (the-as int a1-16)) cfg-38) + (nop!) + (.mul.w.vf acc vf31 vf0) + (.lvf vf1 (&-> a0-24 prim-core world-sphere quad)) + (.add.mul.x.vf acc vf28 vf1 acc) + (nop!) + (.add.mul.y.vf acc vf29 vf1 acc) + (nop!) + (.add.mul.z.vf vf6 vf30 vf1 acc) + (nop!) + (.sub.w.vf.xyz vf2 vf6 vf1) + (nop!) + (.add.w.vf.xyz vf3 vf6 vf1) + (nop!) + (.ftoi.vf vf4 vf2) + (nop!) + (.ftoi.vf vf5 vf3) + (nop!) + (.mov a2-15 vf4) + (let ((v1-50 (-> v1-49 process))) + (.mov a3-6 vf5) + (let ((a1-18 (-> obj proc))) + (.pcgtw a2-16 a2-15 s4-0) + (.pcgtw a3-7 s5-0 a3-6) + (.por a2-17 a2-16 a3-7) + (.ppach a2-18 zero a2-17) + (let ((a2-19 (shl (the-as int a2-18) 16))) (nop!) (b! (nonzero? a2-19) cfg-37 :delay (nop!))) + (b! (= a1-18 v1-50) cfg-37 :delay (nop!)))) + (add-fg-prim-using-line-sphere a0-24 obj)) + (label cfg-37) + 0 + (label cfg-38))))) (none))) (defmethod add-fg-prim-using-line-sphere ((obj collide-shape-prim) (cache collide-cache)) @@ -4744,7 +4672,7 @@ integer bounds overlap collide-work.collide-box4w." (closest-point (new 'stack-no-clear 'vector)) (normal (new 'stack-no-clear 'vector)) (triangles-left (-> cache num-tris))) - (set! (-> target-position quad) (-> (target-pos 0) quad)) + (vector-copy! target-position (target-pos 0)) (while (nonzero? triangles-left) (+! triangles-left -1) (normal-of-plane normal @@ -4755,6 +4683,6 @@ integer bounds overlap collide-work.collide-box4w." (let ((distance-squared (vector-vector-distance-squared closest-point target-position))) (when (or (< best-distance-squared 0.0) (< distance-squared best-distance-squared)) (set! best-distance-squared distance-squared) - (set! (-> nearest-point quad) (-> closest-point quad)))) + (vector-copy! nearest-point closest-point))) (set! tri (-> (the-as (inline-array collide-cache-tri) tri) 1))))) #f) diff --git a/goal_src/jak1/engine/collide/collide-edge-grab.gc b/goal_src/jak1/engine/collide/collide-edge-grab.gc index 7d6cfeef88..4fccb105de 100644 --- a/goal_src/jak1/engine/collide/collide-edge-grab.gc +++ b/goal_src/jak1/engine/collide/collide-edge-grab.gc @@ -1075,7 +1075,7 @@ (let ((distance (vector-segment-distance-point! test-point (-> edge vertex-ptr 0 0) (-> edge vertex-ptr 1 0) closest-point))) (when (or (< best-distance 0.0) (< distance best-distance)) (set! best-distance distance) - (set! (-> output quad) (-> closest-point quad))))))))) + (vector-copy! output closest-point)))))))) best-distance)) (defmethod should-add-to-list? ((this collide-edge-work) (hold-item collide-edge-hold-item) (edge collide-edge-edge)) @@ -1306,7 +1306,7 @@ (item-count 0)) (let ((marker (new 'stack-no-clear 'vector)) (first-item? #t)) - (set! (-> marker quad) (-> *target* control midpoint-of-hands quad)) + (vector-copy! marker (-> *target* control midpoint-of-hands)) (while item (+! item-count 1) (set! (-> marker y) (-> item center-pt y)) diff --git a/goal_src/jak1/engine/collide/collide-frag.gc b/goal_src/jak1/engine/collide/collide-frag.gc index feb962e8e8..316faaebe5 100644 --- a/goal_src/jak1/engine/collide/collide-frag.gc +++ b/goal_src/jak1/engine/collide/collide-frag.gc @@ -46,11 +46,11 @@ 0 (none)) -(defmethod mem-usage ((this collide-fragment) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this collide-fragment) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the fragment and mesh headers, packed polygon stream and PAT indices, and packed vertex quadwords. Bit 0 of flags selects the prototype categories instead of the ordinary background-collision categories." - (let ((category (if (logtest? flags 1) (mem-usage-id collide-fragment-1) (mem-usage-id collide-fragment-0))) + (let ((category (if (logtest? flags (mem-usage-flags prototype-data)) (mem-usage-id collide-fragment-1) (mem-usage-id collide-fragment-0))) (mesh (-> this mesh))) (set! (-> usage data category name) (symbol->string 'collide-fragment)) (+! (-> usage data category count) 1) @@ -124,15 +124,10 @@ 0 (none)) -(defmethod mem-usage ((this drawable-inline-array-collide-fragment) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-collide-fragment) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the inline-array header and delegate memory accounting to every collision fragment." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) diff --git a/goal_src/jak1/engine/collide/collide-mesh.gc b/goal_src/jak1/engine/collide/collide-mesh.gc index acff7ae508..537f3a34d4 100644 --- a/goal_src/jak1/engine/collide/collide-mesh.gc +++ b/goal_src/jak1/engine/collide/collide-mesh.gc @@ -12,21 +12,11 @@ array. The separately allocated vertex-data buffer is not part of this size." (the-as int (+ (-> collide-mesh size) (* (+ (-> this num-tris) -1) 8)))) -(defmethod mem-usage ((this collide-mesh) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this collide-mesh) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the mesh-and-triangle allocation and the separate sixteen-byte-per-vertex buffer as two allocations in the collide-mesh category." - (set! (-> usage length) (max 79 (-> usage length))) - (set! (-> usage data (mem-usage-id collide-mesh) name) "collide-mesh") - (+! (-> usage data (mem-usage-id collide-mesh) count) 1) - (let ((mesh-allocation-bytes (asize-of this))) - (+! (-> usage data (mem-usage-id collide-mesh) used) mesh-allocation-bytes) - (+! (-> usage data (mem-usage-id collide-mesh) total) (logand -16 (+ mesh-allocation-bytes 15)))) - (set! (-> usage length) (max 79 (-> usage length))) - (set! (-> usage data (mem-usage-id collide-mesh) name) "collide-mesh") - (+! (-> usage data (mem-usage-id collide-mesh) count) 1) - (let ((vertex-buffer-bytes (* (-> this num-verts) 16))) - (+! (-> usage data (mem-usage-id collide-mesh) used) vertex-buffer-bytes) - (+! (-> usage data (mem-usage-id collide-mesh) total) (logand -16 (+ vertex-buffer-bytes 15)))) + (mem-usage-add! usage collide-mesh 1 (asize-of this)) + (mem-usage-add! usage collide-mesh 1 (* (-> this num-verts) 16)) (the-as collide-mesh 0)) (defmethod debug-draw-tris ((this collide-mesh) (draw-owner process-drawable) (joint-index int)) diff --git a/goal_src/jak1/engine/collide/collide-shape-rider.gc b/goal_src/jak1/engine/collide/collide-shape-rider.gc index 1352efe9b9..7ea39addc2 100644 --- a/goal_src/jak1/engine/collide/collide-shape-rider.gc +++ b/goal_src/jak1/engine/collide/collide-shape-rider.gc @@ -83,11 +83,11 @@ (set! (-> overlap-result best-dist) separation) (set! (-> overlap-result best-from-prim) this) (set! (-> overlap-result best-to-prim) other-prim) - (set! (-> overlap-result best-from-tri vertex 0 quad) (-> tri-result vertex 0 quad)) - (set! (-> overlap-result best-from-tri vertex 1 quad) (-> tri-result vertex 1 quad)) - (set! (-> overlap-result best-from-tri vertex 2 quad) (-> tri-result vertex 2 quad)) - (set! (-> overlap-result best-from-tri intersect quad) (-> tri-result intersect quad)) - (set! (-> overlap-result best-from-tri normal quad) (-> tri-result normal quad)) + (vector-copy! (-> overlap-result best-from-tri vertex 0) (-> tri-result vertex 0)) + (vector-copy! (-> overlap-result best-from-tri vertex 1) (-> tri-result vertex 1)) + (vector-copy! (-> overlap-result best-from-tri vertex 2) (-> tri-result vertex 2)) + (vector-copy! (-> overlap-result best-from-tri intersect) (-> tri-result intersect)) + (vector-copy! (-> overlap-result best-from-tri normal) (-> tri-result normal)) (set! (-> overlap-result best-from-tri pat) (-> tri-result pat)))))))) (none)) @@ -124,110 +124,86 @@ 0 (let ((with-mask (-> this root-prim collide-with))) (when (logtest? with-mask (collide-kind target)) - (let ((node (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-player-list* alive-list-end)) - (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) - (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) - (when (logtest? with-mask (-> candidate-root prim-core collide-as)) - (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) - (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) - (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) - (when rider-entry - (let ((platform-prim (-> overlap-result best-from-prim))) - (set! (-> rider-entry sticky-prim) platform-prim) - (let ((bone-transform (-> (the-as process-drawable (-> this process)) node-list data (-> platform-prim transform-index) bone transform))) - (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) - (let ((inverse-transform (new 'stack-no-clear 'matrix))) - (matrix-4x4-inverse! inverse-transform bone-transform) - (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) - (send-event (-> this process) 'ridden rider-entry))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-player-list*) + (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) + (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) + (when (logtest? with-mask (-> candidate-root prim-core collide-as)) + (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) + (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) + (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) + (when rider-entry + (let ((platform-prim (-> overlap-result best-from-prim))) + (set! (-> rider-entry sticky-prim) platform-prim) + (let ((bone-transform (-> (the-as process-drawable (-> this process)) node-list data (-> platform-prim transform-index) bone transform))) + (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) + (let ((inverse-transform (new 'stack-no-clear 'matrix))) + (matrix-4x4-inverse! inverse-transform bone-transform) + (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) + (send-event (-> this process) 'ridden rider-entry))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-1 cak-2 cak-3)) (when (logtest? with-mask (collide-kind cak-1)) - (let ((node (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-player-list* alive-list-end)) - (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) - (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) - (when (logtest? with-mask (-> candidate-root prim-core collide-as)) - (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) - (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) - (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) - (when rider-entry - (let ((platform-prim (-> overlap-result best-from-prim))) - (set! (-> rider-entry sticky-prim) platform-prim) - (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) - (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) - (let ((inverse-transform (new 'stack-no-clear 'matrix))) - (matrix-4x4-inverse! inverse-transform bone-transform) - (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) - (send-event (-> this process) 'ridden rider-entry))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-hit-by-player-list*) + (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) + (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) + (when (logtest? with-mask (-> candidate-root prim-core collide-as)) + (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) + (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) + (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) + (when rider-entry + (let ((platform-prim (-> overlap-result best-from-prim))) + (set! (-> rider-entry sticky-prim) platform-prim) + (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) + (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) + (let ((inverse-transform (new 'stack-no-clear 'matrix))) + (matrix-4x4-inverse! inverse-transform bone-transform) + (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) + (send-event (-> this process) 'ridden rider-entry))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-2)) - (let ((node (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) - (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) - (when (logtest? with-mask (-> candidate-root prim-core collide-as)) - (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) - (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) - (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) - (when rider-entry - (let ((platform-prim (-> overlap-result best-from-prim))) - (set! (-> rider-entry sticky-prim) platform-prim) - (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) - (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) - (let ((inverse-transform (new 'stack-no-clear 'matrix))) - (matrix-4x4-inverse! inverse-transform bone-transform) - (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) - (send-event (-> this process) 'ridden rider-entry))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-usually-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-usually-hit-by-player-list*) + (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) + (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) + (when (logtest? with-mask (-> candidate-root prim-core collide-as)) + (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) + (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) + (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) + (when rider-entry + (let ((platform-prim (-> overlap-result best-from-prim))) + (set! (-> rider-entry sticky-prim) platform-prim) + (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) + (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) + (let ((inverse-transform (new 'stack-no-clear 'matrix))) + (matrix-4x4-inverse! inverse-transform bone-transform) + (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) + (send-event (-> this process) 'ridden rider-entry))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-3)) - (let ((node (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-others-list* alive-list-end)) - (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) - (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) - (when (logtest? with-mask (-> candidate-root prim-core collide-as)) - (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) - (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) - (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) - (when rider-entry - (let ((platform-prim (-> overlap-result best-from-prim))) - (set! (-> rider-entry sticky-prim) platform-prim) - (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) - (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) - (let ((inverse-transform (new 'stack-no-clear 'matrix))) - (matrix-4x4-inverse! inverse-transform bone-transform) - (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) - (send-event (-> this process) 'ridden rider-entry))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-hit-by-others-list* - (set! next-node (-> next-node next0))))) + (iterate-engine-connections (node *collide-hit-by-others-list*) + (let* ((candidate-shape (the-as object (-> (the-as connection node) param1))) + (candidate-root (-> (the-as collide-shape candidate-shape) root-prim))) + (when (logtest? with-mask (-> candidate-root prim-core collide-as)) + (when (and (logtest? (-> candidate-root prim-core action) (collide-action rider-target)) + (!= (-> this process) (-> (the-as collide-shape candidate-shape) process))) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (on-platform this (the-as collide-shape candidate-shape) overlap-result) + (let ((rider-entry (add-rider! rider-group (the-as process-drawable (process->handle (-> (the-as collide-shape candidate-shape) process)))))) + (when rider-entry + (let ((platform-prim (-> overlap-result best-from-prim))) + (set! (-> rider-entry sticky-prim) platform-prim) + (let ((bone-transform (-> this process node-list data (-> platform-prim transform-index) bone transform))) + (set! (-> rider-entry prim-ry) (matrix-y-angle bone-transform)) + (let ((inverse-transform (new 'stack-no-clear 'matrix))) + (matrix-4x4-inverse! inverse-transform bone-transform) + (vector-matrix*! (-> rider-entry rider-local-pos) (-> (the-as collide-shape candidate-shape) trans) inverse-transform)))) + (send-event (-> this process) 'ridden rider-entry))) + (set! with-mask (-> this root-prim collide-with)))))))) #f)))))) (defmethod pull-riders! ((this collide-shape)) @@ -269,7 +245,7 @@ (let ((rider-shape (-> pull-info rider-cshape))) (let ((move-delta (new 'stack-no-clear 'vector)) (old-position (new 'stack-no-clear 'vector))) - (set! (-> old-position quad) (-> rider-shape trans quad)) + (vector-copy! old-position (-> rider-shape trans)) (vector-! move-delta (-> pull-info rider-dest) old-position) (cond ((logtest? (-> this root-prim prim-core action) (collide-action rider-plat)) @@ -278,7 +254,7 @@ (fill-cache-for-shape! rider-shape (+ 8192.0 (vector-length move-delta)) (-> rider-shape root-prim collide-with)) (set! (-> this root-prim prim-core collide-as) saved-platform-collide-as)) (let ((rider-velocity (new 'stack-no-clear 'vector))) - (set! (-> rider-velocity quad) (-> move-delta quad)) + (vector-copy! rider-velocity move-delta) (let ((velocity-output rider-velocity)) (.lvf vf1 (&-> rider-velocity quad)) (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) diff --git a/goal_src/jak1/engine/collide/collide-shape.gc b/goal_src/jak1/engine/collide/collide-shape.gc index a3755f0f41..319387d5c2 100644 --- a/goal_src/jak1/engine/collide/collide-shape.gc +++ b/goal_src/jak1/engine/collide/collide-shape.gc @@ -285,11 +285,11 @@ ;; remeber this triangle! (set! (-> overlap-result best-from-prim) this) (set! (-> overlap-result best-to-prim) other-prim) - (set! (-> overlap-result best-from-tri vertex 0 quad) (-> tri-result vertex 0 quad)) - (set! (-> overlap-result best-from-tri vertex 1 quad) (-> tri-result vertex 1 quad)) - (set! (-> overlap-result best-from-tri vertex 2 quad) (-> tri-result vertex 2 quad)) - (set! (-> overlap-result best-from-tri intersect quad) (-> tri-result intersect quad)) - (set! (-> overlap-result best-from-tri normal quad) (-> tri-result normal quad)) + (vector-copy! (-> overlap-result best-from-tri vertex 0) (-> tri-result vertex 0)) + (vector-copy! (-> overlap-result best-from-tri vertex 1) (-> tri-result vertex 1)) + (vector-copy! (-> overlap-result best-from-tri vertex 2) (-> tri-result vertex 2)) + (vector-copy! (-> overlap-result best-from-tri intersect) (-> tri-result intersect)) + (vector-copy! (-> overlap-result best-from-tri normal) (-> tri-result normal)) (set! (-> overlap-result best-from-tri pat) (-> tri-result pat)))) (label nothing-to-report) (b! #t done :delay (nop!)) @@ -361,7 +361,7 @@ (hit-point (-> overlap-result best-from-tri intersect))) (vector-float*! hit-point hit-normal (-> this prim-core world-sphere w)) (vector+! hit-point hit-point (the-as vector (-> this prim-core))) - (set! (-> overlap-result best-from-tri vertex 0 quad) (-> hit-point quad)) + (vector-copy! (-> overlap-result best-from-tri vertex 0) hit-point) (point-in-plane-<-point+normal! (-> overlap-result best-from-tri vertex 1) hit-point hit-normal) (let* ((tangent (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> overlap-result best-from-tri vertex 1) @@ -415,7 +415,7 @@ (let ((hit-point2 (-> overlap-result best-from-tri intersect))) (vector-float*! hit-point2 hit-normal2 (-> this prim-core world-sphere w)) (vector+! hit-point2 hit-point2 (the-as vector (-> this prim-core))) - (set! (-> overlap-result best-from-tri vertex 0 quad) (-> hit-point2 quad)) + (vector-copy! (-> overlap-result best-from-tri vertex 0) hit-point2) (point-in-plane-<-point+normal! (-> overlap-result best-from-tri vertex 1) hit-point2 hit-normal2) (let* ((tangent2 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> overlap-result best-from-tri vertex 1) @@ -684,7 +684,7 @@ (= (-> result-tri pat event) (pat-event none)) ;; and it's not more dangerous ground (< 0.7 (-> result-tri normal y)) ;; and it's pretty flat ) - (set! (-> ground-result quad) (-> result-tri intersect quad)) ;; remember it + (vector-copy! ground-result (-> result-tri intersect)) ;; remember it ;; count this as a success (set! hit-count (+ hit-count 1)) ;; if we get 2 or more hits, it seems like a good place to land, let's do it! @@ -793,7 +793,7 @@ (set! surface-normal (new-stack-vector0)) (set! adjusted-input-velocity (new 'stack-no-clear 'vector)) (set! status-mask (collide-status)) - (set! (-> adjusted-input-velocity quad) (-> vel-in quad)) + (vector-copy! adjusted-input-velocity vel-in) ;; move along the vector by the best move-vec ;; this will hit the best-tri (let ((move-amount (new 'stack-no-clear 'vector))) @@ -809,8 +809,8 @@ ;; ? (if (= (-> isect best-u) 0.0) (move-by-vector! cshape surface-normal)) ;; - (set! (-> cshape surface-normal quad) (-> surface-normal quad)) - (set! (-> cshape poly-normal quad) (-> isect best-tri normal quad)) + (vector-copy! (-> cshape surface-normal) surface-normal) + (vector-copy! (-> cshape poly-normal) (-> isect best-tri normal)) (set! (-> cshape surface-angle) (vector-dot surface-normal (-> cshape dynam gravity-normal))) (set! (-> cshape poly-angle) (vector-dot (-> cshape poly-normal) (-> cshape dynam gravity-normal))) (set! (-> cshape touch-angle) @@ -849,14 +849,14 @@ (set! (-> cshape cur-pat mode) (pat-mode wall))) (else (set! status-mask (logior status-mask (collide-status on-surface))) ;; on. - (set! (-> cshape local-normal quad) (-> surface-normal quad)))) + (vector-copy! (-> cshape local-normal) surface-normal))) (vector-reflect-flat! vel-out adjusted-input-velocity surface-normal) (when (and (not wall?) (>= (-> cshape coverage) COLLIDE-GROUND-COVERAGE)) (set! status-mask (logior status-mask (collide-status on-ground))) - (set! (-> cshape ground-poly-normal quad) (-> cshape poly-normal quad)) + (vector-copy! (-> cshape ground-poly-normal) (-> cshape poly-normal)) (when (!= (-> cshape poly-pat mode) (pat-mode wall)) (set! (-> cshape ground-pat) (-> cshape poly-pat)) - (set! (-> cshape ground-touch-point quad) (-> isect best-tri intersect quad)))) + (vector-copy! (-> cshape ground-touch-point) (-> isect best-tri intersect)))) (logior! (-> cshape status) status-mask) (the-as collide-status status-mask)) @@ -908,7 +908,7 @@ ((>= hit-u 0.0) (let ((debug-in-vel (new 'stack-no-clear 'vector))) ;; if debugging, remember our input velocity. - (if *display-collision-marks* (set! (-> debug-in-vel quad) (-> vel-in quad))) + (if *display-collision-marks* (vector-copy! debug-in-vel vel-in)) ;; do the collision reaction! this function should move the collide shape. (set! (-> this prev-status) (the-as collide-status ((-> this reaction) this isect vel-out vel-in))) ;; debug draw collision marks. @@ -949,7 +949,7 @@ ;; and do the move ourself (move-by-vector! this move-vec) ;; velocity is unchanged - (set! (-> vel-out quad) (-> vel-in quad)) + (vector-copy! vel-out vel-in) ;; moved the whole way! (return 1.0))))) 1.0) @@ -984,9 +984,9 @@ ;; update the world-spheres for us and our children. (update-transforms! this) ;; remember our history - (set! (-> this trans-old 2 quad) (-> this trans-old 1 quad)) - (set! (-> this trans-old 1 quad) (-> this trans-old 0 quad)) - (set! (-> this trans-old 0 quad) (-> this trans quad)) + (vector-copy! (-> this trans-old 2) (-> this trans-old 1)) + (vector-copy! (-> this trans-old 1) (-> this trans-old 0)) + (vector-copy! (-> this trans-old 0) (-> this trans)) (set! (-> this prev-status) (-> this status)) ;; setup (logclear! (-> this status) @@ -1003,9 +1003,9 @@ impact-surface touch-background stuck)) - (set! (-> this local-normal quad) (-> this dynam gravity-normal quad)) - (set! (-> this surface-normal quad) (-> this dynam gravity-normal quad)) - (set! (-> this poly-normal quad) (-> this dynam gravity-normal quad)) + (vector-copy! (-> this local-normal) (-> this dynam gravity-normal)) + (vector-copy! (-> this surface-normal) (-> this dynam gravity-normal)) + (vector-copy! (-> this poly-normal) (-> this dynam gravity-normal)) (set! (-> this coverage) 0.0) (set! (-> this touch-angle) 0.0) ;; we want to take a step of 1.0 @@ -1037,7 +1037,7 @@ ;; The animation collision track moves the body independently of its ordinary velocity. Rotate ;; that offset to world space, feed its per-frame delta into collision, and cancel the same ;; displacement from the drawn model because the animation already contains it. - (set! (-> this old-anim-collide-offset-world quad) (-> this anim-collide-offset-world quad)) + (vector-copy! (-> this old-anim-collide-offset-world) (-> this anim-collide-offset-world)) (vector-matrix*! (-> this anim-collide-offset-world) (-> this anim-collide-offset-local) (-> this root-orientation)) (vector-! (-> this anim-collide-offset-delta-world) (-> this anim-collide-offset-world) @@ -1046,7 +1046,7 @@ (vector-seek! (-> this cspace-offset) total-draw-offset (* 16384.0 (-> *display* seconds-per-frame)))) (let ((velocity-with-anim-offset (vector+float*! (new-stack-vector0) velocity (-> this anim-collide-offset-delta-world) 60.0)) (saved-input-velocity (new 'stack-no-clear 'vector))) - (set! (-> saved-input-velocity quad) (-> velocity quad)) + (vector-copy! saved-input-velocity velocity) ;; call the normal integrate. (let ((parent-integrate (method-of-type collide-shape-moving integrate-and-collide!))) (parent-integrate this velocity-with-anim-offset)) @@ -1095,12 +1095,12 @@ (set! (-> this blocked-in-air-factor) (seek (-> this blocked-in-air-factor) 0.0 (* 2.0 (-> *display* seconds-per-frame))))))))) (if (logtest? (-> this status) (collide-status on-surface)) - (set! (-> velocity quad) (-> velocity-with-anim-offset quad)) + (vector-copy! velocity velocity-with-anim-offset) (vector--float*! velocity velocity-with-anim-offset (-> this anim-collide-offset-delta-world) 60.0)) (if (and (logtest? (-> this status) (collide-status on-surface)) (and (not (logtest? (-> this status) (collide-status touch-wall blocked))) (< (vector-length (-> this btransv)) (vector-length saved-input-velocity)))) - (set! (-> this btransv quad) (-> saved-input-velocity quad)))) + (vector-copy! (-> this btransv) saved-input-velocity))) (let ((align-xz-direction (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this align-xz-vel) 1.0)) (align-xz-speed (vector-length (-> this align-xz-vel)))) (set! (-> this zx-vel-frac) @@ -1118,12 +1118,12 @@ (move-to-point! this ground-point) (set! (-> velocity y) 0.0) (logior! (-> this status) (collide-status on-surface on-ground touch-surface)) - (set! (-> this poly-normal quad) (-> ground-normal quad)) - (set! (-> this surface-normal quad) (-> ground-normal quad)) - (set! (-> this local-normal quad) (-> ground-normal quad)) - (set! (-> this ground-poly-normal quad) (-> ground-normal quad)) + (vector-copy! (-> this poly-normal) ground-normal) + (vector-copy! (-> this surface-normal) ground-normal) + (vector-copy! (-> this local-normal) ground-normal) + (vector-copy! (-> this ground-poly-normal) ground-normal) (set! (-> this ground-impact-vel) (- (vector-dot velocity (-> this dynam gravity-normal)))) - (set! (-> this ground-touch-point quad) (-> ground-point quad)) + (vector-copy! (-> this ground-touch-point) ground-point) 0 (none)) @@ -1136,9 +1136,9 @@ (seconds-vf :class vf)) (init-vf0-vector) (update-transforms! this) - (set! (-> this trans-old 2 quad) (-> this trans-old 1 quad)) - (set! (-> this trans-old 1 quad) (-> this trans-old 0 quad)) - (set! (-> this trans-old 0 quad) (-> this trans quad)) + (vector-copy! (-> this trans-old 2) (-> this trans-old 1)) + (vector-copy! (-> this trans-old 1) (-> this trans-old 0)) + (vector-copy! (-> this trans-old 0) (-> this trans)) (set! (-> this prev-status) (-> this status)) (logclear! (-> this status) (collide-status on-surface @@ -1154,9 +1154,9 @@ impact-surface touch-background stuck)) - (set! (-> this local-normal quad) (-> this dynam gravity-normal quad)) - (set! (-> this surface-normal quad) (-> this dynam gravity-normal quad)) - (set! (-> this poly-normal quad) (-> this dynam gravity-normal quad)) + (vector-copy! (-> this local-normal) (-> this dynam gravity-normal)) + (vector-copy! (-> this surface-normal) (-> this dynam gravity-normal)) + (vector-copy! (-> this poly-normal) (-> this dynam gravity-normal)) (set! (-> this coverage) 0.0) (set! (-> this touch-angle) 0.0) (let* ((shape-to-move this) @@ -1169,7 +1169,7 @@ (.mul.x.vf.xyz move-amount-vf move-amount-vf seconds-vf) (.svf (&-> move-amount quad) move-amount-vf) (move-function shape-to-move move-amount)) - (set! (-> this shadow-pos quad) (-> this trans quad)) + (vector-copy! (-> this shadow-pos) (-> this trans)) 0 (none))) @@ -1193,14 +1193,14 @@ (move-to-point! this position) (logior! (-> this status) (collide-status on-surface on-ground touch-surface)) (let ((triangle-normal (-> triangle normal))) - (set! (-> this poly-normal quad) (-> triangle-normal quad)) - (set! (-> this surface-normal quad) (-> triangle-normal quad)) - (set! (-> this local-normal quad) (-> triangle-normal quad)) - (set! (-> this ground-poly-normal quad) (-> triangle-normal quad))) + (vector-copy! (-> this poly-normal) triangle-normal) + (vector-copy! (-> this surface-normal) triangle-normal) + (vector-copy! (-> this local-normal) triangle-normal) + (vector-copy! (-> this ground-poly-normal) triangle-normal)) (set! (-> this poly-pat) (-> triangle pat)) (set! (-> this cur-pat) (-> triangle pat)) (set! (-> this ground-pat) (-> triangle pat)) - (set! (-> this ground-touch-point quad) (-> position quad)) + (vector-copy! (-> this ground-touch-point) position) 0 (none)) @@ -1222,7 +1222,7 @@ (integrate-no-collide! this velocity) ;; set our position to shadow (not sure why) (let ((probe-position (-> this shadow-pos))) - (set! (-> probe-position quad) (-> this trans quad)) + (vector-copy! probe-position (-> this trans)) (set! ground-triangle (new 'stack-no-clear 'collide-tri-result)) ;; move off the ground by the given height probe offset (+! (-> probe-position y) probe-start-height) @@ -1279,7 +1279,7 @@ (let ((probe-position (new 'stack-no-clear 'vector)) (ground-triangle (new 'stack-no-clear 'collide-tri-result))) (let ((probe-length (+ snap-up-height search-below))) - (set! (-> probe-position quad) (-> this trans quad)) + (vector-copy! probe-position (-> this trans)) (+! (-> probe-position y) snap-up-height) 0.0 ;; find the ground @@ -1302,7 +1302,7 @@ ;; calulate the ground position. (set! (-> probe-position y) (- (-> probe-position y) (* probe-u probe-length))))) ;; move our shadow there too - (set! (-> this shadow-pos quad) (-> probe-position quad)) + (vector-copy! (-> this shadow-pos) probe-position) ;; and move us there! (move-to-tri! this ground-triangle probe-position)) (if *debug-segment* @@ -1704,58 +1704,34 @@ 819.2 (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)) (when *display-collision-marks* - (let ((node (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-player-list* alive-list-end)) - (let ((cshape (-> (the-as connection node) param1))) - (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) - (or (= (-> (the-as collide-shape cshape) process) *target*) - (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) - (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) - (debug-draw (the-as collide-shape cshape)))) - (set! node next-node) - *collide-player-list* - (set! next-node (-> next-node next0))))) - (let ((node (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-player-list* alive-list-end)) - (let ((cshape (-> (the-as connection node) param1))) - (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) - (or (= (-> (the-as collide-shape cshape) process) *target*) - (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) - (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) - (debug-draw (the-as collide-shape cshape)))) - (set! node next-node) - *collide-hit-by-player-list* - (set! next-node (-> next-node next0))))) - (let ((node (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let ((cshape (-> (the-as connection node) param1))) - (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) - (or (= (-> (the-as collide-shape cshape) process) *target*) - (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) - (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) - (debug-draw (the-as collide-shape cshape)))) - (set! node next-node) - *collide-usually-hit-by-player-list* - (set! next-node (-> next-node next0))))) - (let ((node (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-others-list* alive-list-end)) - (let ((cshape (-> (the-as connection node) param1))) - (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) - (or (= (-> (the-as collide-shape cshape) process) *target*) - (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) - (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) - (debug-draw (the-as collide-shape cshape)))) - (set! node next-node) - *collide-hit-by-others-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-player-list*) + (let ((cshape (-> (the-as connection node) param1))) + (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) + (or (= (-> (the-as collide-shape cshape) process) *target*) + (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) + (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) + (debug-draw (the-as collide-shape cshape))))) + (iterate-engine-connections (node *collide-hit-by-player-list*) + (let ((cshape (-> (the-as connection node) param1))) + (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) + (or (= (-> (the-as collide-shape cshape) process) *target*) + (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) + (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) + (debug-draw (the-as collide-shape cshape))))) + (iterate-engine-connections (node *collide-usually-hit-by-player-list*) + (let ((cshape (-> (the-as connection node) param1))) + (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) + (or (= (-> (the-as collide-shape cshape) process) *target*) + (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) + (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) + (debug-draw (the-as collide-shape cshape))))) + (iterate-engine-connections (node *collide-hit-by-others-list*) + (let ((cshape (-> (the-as connection node) param1))) + (if (or (and (not *display-actor-anim*) (not *display-process-anim*)) + (or (= (-> (the-as collide-shape cshape) process) *target*) + (name= *display-actor-anim* (-> (the-as collide-shape cshape) process name)) + (= (ppointer->process *display-process-anim*) (-> (the-as collide-shape cshape) process)))) + (debug-draw (the-as collide-shape cshape)))))) 0 (none)) @@ -2014,7 +1990,7 @@ (defmethod init! ((this collide-shape-intersect) (direction vector)) "Initialize the intersection in the given direction." - (set! (-> this move-vec quad) (-> direction quad)) + (vector-copy! (-> this move-vec) direction) (set! (-> this best-u) COLLISION_MISS) (set! (-> this best-from-prim) #f) (set! (-> this best-to-prim) #f) @@ -2095,226 +2071,202 @@ (let ((with-mask (-> this root-prim collide-with))) ;; we collide with target, so check the player list. (when (logtest? with-mask (collide-kind target)) - (let ((node (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-player-list* alive-list-end)) - (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) - (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) - ;; we might collide with this! - (when (!= (-> this process) (-> victim process)) ;; self check - ;; see if we collide! - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) ;; we collide! - ;; fill the collide cache. - (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) - ;; 3 iterations to solve it. - (let ((iterations-left PUSH-AWAY-PASSES)) - (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) ;; run until we're out. - (let ((push-vector (new 'stack-no-clear 'vector))) - (let ((clamped-center (new 'stack-no-clear 'vector))) - (set! (-> clamped-center quad) (-> victim trans quad)) - ;; this is... a bit of a hack. - ;; this adjusts our collision to be within 0.7 - 1.4m of our base. - ;; (note, this only applies for intermediate iterations of this loop) - (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) ;; minimum-push-y = 0.7 m above use - (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) ;; 1.4m above us - (contact-y (-> overlap-result best-from-tri intersect y))) - (cond - ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) - ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) - (set! (-> clamped-center y) contact-y)) - (.lvf push-anchor (&-> clamped-center quad))) - (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) - (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) - (.sub.vf push-direction push-anchor contact-point) - (.mul.vf dot-products contact-normal push-direction) - (.add.x.vf.y dot-products dot-products dot-products) - (.add.z.vf.y dot-products dot-products dot-products) - ;; The dot product is in the y lane. normal-side-bits must stay an int so - ;; this move is 64 bits wide and the sign test below reads bit 63, which is - ;; y's sign. Declaring it float narrows the move to lane x and silently - ;; tests contact-normal.x * push-direction.x instead. The EE does the same - ;; thing with qmfc2.i followed by bltzl. - (.mov normal-side-bits dot-products) - (b! (< (the-as int normal-side-bits) 0) dir-ready-player :likely-delay (.sub.vf push-direction vf0 push-direction)) - (label dir-ready-player) - (.svf (&-> push-vector quad) push-direction) - (vector-normalize! push-vector 1.0) - (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) - ;; Distance to velocity for the integrator. dot-products and - ;; push-direction are reused here as plain vector temporaries. - (let ((push-vector push-vector)) - (.lvf dot-products (&-> push-vector quad)) - (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) - (.mov push-direction frames-per-second-bits) - (.mov.vf.w dot-products vf0) - (.mul.x.vf.xyz dot-products dot-products push-direction) - (.svf (&-> push-vector quad) dot-products)) - (let ((saved-status (-> victim status))) - ;; step. - (integrate-and-collide! victim push-vector) - (set! (-> victim status) saved-status))) - (+! iterations-left -1))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-player-list*) + (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) + (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) + ;; we might collide with this! + (when (!= (-> this process) (-> victim process)) ;; self check + ;; see if we collide! + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) ;; we collide! + ;; fill the collide cache. + (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) + ;; 3 iterations to solve it. + (let ((iterations-left PUSH-AWAY-PASSES)) + (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) ;; run until we're out. + (let ((push-vector (new 'stack-no-clear 'vector))) + (let ((clamped-center (new 'stack-no-clear 'vector))) + (vector-copy! clamped-center (-> victim trans)) + ;; this is... a bit of a hack. + ;; this adjusts our collision to be within 0.7 - 1.4m of our base. + ;; (note, this only applies for intermediate iterations of this loop) + (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) ;; minimum-push-y = 0.7 m above use + (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) ;; 1.4m above us + (contact-y (-> overlap-result best-from-tri intersect y))) + (cond + ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) + ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) + (set! (-> clamped-center y) contact-y)) + (.lvf push-anchor (&-> clamped-center quad))) + (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) + (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) + (.sub.vf push-direction push-anchor contact-point) + (.mul.vf dot-products contact-normal push-direction) + (.add.x.vf.y dot-products dot-products dot-products) + (.add.z.vf.y dot-products dot-products dot-products) + ;; The dot product is in the y lane. normal-side-bits must stay an int so + ;; this move is 64 bits wide and the sign test below reads bit 63, which is + ;; y's sign. Declaring it float narrows the move to lane x and silently + ;; tests contact-normal.x * push-direction.x instead. The EE does the same + ;; thing with qmfc2.i followed by bltzl. + (.mov normal-side-bits dot-products) + (b! (< (the-as int normal-side-bits) 0) dir-ready-player :likely-delay (.sub.vf push-direction vf0 push-direction)) + (label dir-ready-player) + (.svf (&-> push-vector quad) push-direction) + (vector-normalize! push-vector 1.0) + (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) + ;; Distance to velocity for the integrator. dot-products and + ;; push-direction are reused here as plain vector temporaries. + (let ((push-vector push-vector)) + (.lvf dot-products (&-> push-vector quad)) + (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) + (.mov push-direction frames-per-second-bits) + (.mov.vf.w dot-products vf0) + (.mul.x.vf.xyz dot-products dot-products push-direction) + (.svf (&-> push-vector quad) dot-products)) + (let ((saved-status (-> victim status))) + ;; step. + (integrate-and-collide! victim push-vector) + (set! (-> victim status) saved-status))) + (+! iterations-left -1))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-1 cak-2 cak-3)) ;; The same loop again for cak-1, cak-2 and cak-3. (when (logtest? with-mask (collide-kind cak-1)) - (let ((node (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-player-list* alive-list-end)) - (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) - (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) - (when (!= (-> this process) (-> victim process)) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) - (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) - (let ((iterations-left PUSH-AWAY-PASSES)) - (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) - (let ((push-vector (new 'stack-no-clear 'vector))) - (let ((clamped-center (new 'stack-no-clear 'vector))) - (set! (-> clamped-center quad) (-> victim trans quad)) - (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) - (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) - (contact-y (-> overlap-result best-from-tri intersect y))) - (cond - ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) - ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) - (set! (-> clamped-center y) contact-y)) - (.lvf push-anchor (&-> clamped-center quad))) - (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) - (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) - (.sub.vf push-direction push-anchor contact-point) - (.mul.vf dot-products contact-normal push-direction) - (.add.x.vf.y dot-products dot-products dot-products) - (.add.z.vf.y dot-products dot-products dot-products) - (.mov normal-side-bits dot-products) - (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-1 :likely-delay (.sub.vf push-direction vf0 push-direction)) - (label dir-ready-cak-1) - (.svf (&-> push-vector quad) push-direction) - (vector-normalize! push-vector 1.0) - (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) - (let ((push-vector push-vector)) - (.lvf dot-products (&-> push-vector quad)) - (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) - (.mov push-direction frames-per-second-bits) - (.mov.vf.w dot-products vf0) - (.mul.x.vf.xyz dot-products dot-products push-direction) - (.svf (&-> push-vector quad) dot-products)) - (let ((saved-status (-> victim status))) - (integrate-and-collide! victim push-vector) - (set! (-> victim status) saved-status))) - (+! iterations-left -1))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-hit-by-player-list*) + (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) + (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) + (when (!= (-> this process) (-> victim process)) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) + (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) + (let ((iterations-left PUSH-AWAY-PASSES)) + (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) + (let ((push-vector (new 'stack-no-clear 'vector))) + (let ((clamped-center (new 'stack-no-clear 'vector))) + (vector-copy! clamped-center (-> victim trans)) + (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) + (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) + (contact-y (-> overlap-result best-from-tri intersect y))) + (cond + ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) + ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) + (set! (-> clamped-center y) contact-y)) + (.lvf push-anchor (&-> clamped-center quad))) + (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) + (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) + (.sub.vf push-direction push-anchor contact-point) + (.mul.vf dot-products contact-normal push-direction) + (.add.x.vf.y dot-products dot-products dot-products) + (.add.z.vf.y dot-products dot-products dot-products) + (.mov normal-side-bits dot-products) + (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-1 :likely-delay (.sub.vf push-direction vf0 push-direction)) + (label dir-ready-cak-1) + (.svf (&-> push-vector quad) push-direction) + (vector-normalize! push-vector 1.0) + (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) + (let ((push-vector push-vector)) + (.lvf dot-products (&-> push-vector quad)) + (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) + (.mov push-direction frames-per-second-bits) + (.mov.vf.w dot-products vf0) + (.mul.x.vf.xyz dot-products dot-products push-direction) + (.svf (&-> push-vector quad) dot-products)) + (let ((saved-status (-> victim status))) + (integrate-and-collide! victim push-vector) + (set! (-> victim status) saved-status))) + (+! iterations-left -1))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-2)) - (let ((node (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) - (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) - (when (!= (-> this process) (-> victim process)) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) - (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) - (let ((iterations-left PUSH-AWAY-PASSES)) - (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) - (let ((push-vector (new 'stack-no-clear 'vector))) - (let ((clamped-center (new 'stack-no-clear 'vector))) - (set! (-> clamped-center quad) (-> victim trans quad)) - (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) - (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) - (contact-y (-> overlap-result best-from-tri intersect y))) - (cond - ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) - ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) - (set! (-> clamped-center y) contact-y)) - (.lvf push-anchor (&-> clamped-center quad))) - (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) - (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) - (.sub.vf push-direction push-anchor contact-point) - (.mul.vf dot-products contact-normal push-direction) - (.add.x.vf.y dot-products dot-products dot-products) - (.add.z.vf.y dot-products dot-products dot-products) - (.mov normal-side-bits dot-products) - (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-2 :likely-delay (.sub.vf push-direction vf0 push-direction)) - (label dir-ready-cak-2) - (.svf (&-> push-vector quad) push-direction) - (vector-normalize! push-vector 1.0) - (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) - (let ((push-vector push-vector)) - (.lvf dot-products (&-> push-vector quad)) - (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) - (.mov push-direction frames-per-second-bits) - (.mov.vf.w dot-products vf0) - (.mul.x.vf.xyz dot-products dot-products push-direction) - (.svf (&-> push-vector quad) dot-products)) - (let ((saved-status (-> victim status))) - (integrate-and-collide! victim push-vector) - (set! (-> victim status) saved-status))) - (+! iterations-left -1))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-usually-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-usually-hit-by-player-list*) + (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) + (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) + (when (!= (-> this process) (-> victim process)) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) + (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) + (let ((iterations-left PUSH-AWAY-PASSES)) + (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) + (let ((push-vector (new 'stack-no-clear 'vector))) + (let ((clamped-center (new 'stack-no-clear 'vector))) + (vector-copy! clamped-center (-> victim trans)) + (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) + (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) + (contact-y (-> overlap-result best-from-tri intersect y))) + (cond + ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) + ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) + (set! (-> clamped-center y) contact-y)) + (.lvf push-anchor (&-> clamped-center quad))) + (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) + (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) + (.sub.vf push-direction push-anchor contact-point) + (.mul.vf dot-products contact-normal push-direction) + (.add.x.vf.y dot-products dot-products dot-products) + (.add.z.vf.y dot-products dot-products dot-products) + (.mov normal-side-bits dot-products) + (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-2 :likely-delay (.sub.vf push-direction vf0 push-direction)) + (label dir-ready-cak-2) + (.svf (&-> push-vector quad) push-direction) + (vector-normalize! push-vector 1.0) + (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) + (let ((push-vector push-vector)) + (.lvf dot-products (&-> push-vector quad)) + (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) + (.mov push-direction frames-per-second-bits) + (.mov.vf.w dot-products vf0) + (.mul.x.vf.xyz dot-products dot-products push-direction) + (.svf (&-> push-vector quad) dot-products)) + (let ((saved-status (-> victim status))) + (integrate-and-collide! victim push-vector) + (set! (-> victim status) saved-status))) + (+! iterations-left -1))) + (set! with-mask (-> this root-prim collide-with))))))))) (when (logtest? with-mask (collide-kind cak-3)) - (let ((node (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-others-list* alive-list-end)) - (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) - (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) - (when (!= (-> this process) (-> victim process)) - (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) - (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) - (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) - (let ((iterations-left PUSH-AWAY-PASSES)) - (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) - (let ((push-vector (new 'stack-no-clear 'vector))) - (let ((clamped-center (new 'stack-no-clear 'vector))) - (set! (-> clamped-center quad) (-> victim trans quad)) - (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) - (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) - (contact-y (-> overlap-result best-from-tri intersect y))) - (cond - ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) - ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) - (set! (-> clamped-center y) contact-y)) - (.lvf push-anchor (&-> clamped-center quad))) - (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) - (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) - (.sub.vf push-direction push-anchor contact-point) - (.mul.vf dot-products contact-normal push-direction) - (.add.x.vf.y dot-products dot-products dot-products) - (.add.z.vf.y dot-products dot-products dot-products) - (.mov normal-side-bits dot-products) - (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-3 :likely-delay (.sub.vf push-direction vf0 push-direction)) - (label dir-ready-cak-3) - (.svf (&-> push-vector quad) push-direction) - (vector-normalize! push-vector 1.0) - (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) - (let ((push-vector push-vector)) - (.lvf dot-products (&-> push-vector quad)) - (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) - (.mov push-direction frames-per-second-bits) - (.mov.vf.w dot-products vf0) - (.mul.x.vf.xyz dot-products dot-products push-direction) - (.svf (&-> push-vector quad) dot-products)) - (let ((saved-status (-> victim status))) - (integrate-and-collide! victim push-vector) - (set! (-> victim status) saved-status))) - (+! iterations-left -1))) - (set! with-mask (-> this root-prim collide-with))))))) - (set! node next-node) - *collide-hit-by-others-list* - (set! next-node (-> next-node next0))))) + (iterate-engine-connections (node *collide-hit-by-others-list*) + (let ((victim (the-as collide-shape-moving (-> (the-as connection node) param1)))) + (when (logtest? with-mask (-> victim root-prim prim-core collide-as)) + (when (!= (-> this process) (-> victim process)) + (let ((overlap-result (new 'stack-no-clear 'collide-overlap-result))) + (when (and (should-push-away this victim overlap-result) (>= PUSH-AWAY-MIN-OVERLAP (-> overlap-result best-dist))) + (fill-cache-for-shape! victim PUSH-AWAY-CACHE-PADDING (-> victim root-prim collide-with)) + (let ((iterations-left PUSH-AWAY-PASSES)) + (until (or (<= iterations-left 0) (not (should-push-away this victim overlap-result))) + (let ((push-vector (new 'stack-no-clear 'vector))) + (let ((clamped-center (new 'stack-no-clear 'vector))) + (vector-copy! clamped-center (-> victim trans)) + (let* ((minimum-push-y (+ PUSH-AWAY-CONTACT-LOW (-> clamped-center y))) + (maximum-push-y (+ PUSH-AWAY-CONTACT-BAND minimum-push-y)) + (contact-y (-> overlap-result best-from-tri intersect y))) + (cond + ((< contact-y minimum-push-y) (set! contact-y minimum-push-y)) + ((< maximum-push-y contact-y) (set! contact-y maximum-push-y))) + (set! (-> clamped-center y) contact-y)) + (.lvf push-anchor (&-> clamped-center quad))) + (.lvf contact-point (&-> overlap-result best-from-tri intersect quad)) + (.lvf contact-normal (&-> overlap-result best-from-tri normal quad)) + (.sub.vf push-direction push-anchor contact-point) + (.mul.vf dot-products contact-normal push-direction) + (.add.x.vf.y dot-products dot-products dot-products) + (.add.z.vf.y dot-products dot-products dot-products) + (.mov normal-side-bits dot-products) + (b! (< (the-as int normal-side-bits) 0) dir-ready-cak-3 :likely-delay (.sub.vf push-direction vf0 push-direction)) + (label dir-ready-cak-3) + (.svf (&-> push-vector quad) push-direction) + (vector-normalize! push-vector 1.0) + (vector-float*! push-vector push-vector (- (-> overlap-result best-dist))) + (let ((push-vector push-vector)) + (.lvf dot-products (&-> push-vector quad)) + (let ((frames-per-second (-> *display* frames-per-second))) (.mov frames-per-second-bits frames-per-second)) + (.mov push-direction frames-per-second-bits) + (.mov.vf.w dot-products vf0) + (.mul.x.vf.xyz dot-products dot-products push-direction) + (.svf (&-> push-vector quad) dot-products)) + (let ((saved-status (-> victim status))) + (integrate-and-collide! victim push-vector) + (set! (-> victim status) saved-status))) + (+! iterations-left -1))) + (set! with-mask (-> this root-prim collide-with)))))))) #f))))) ;;;;;;;;;;;;;;;;;;;;;;; @@ -2360,200 +2312,176 @@ (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) (let ((with-mask (-> our-root collide-with))) (b! (zero? (logand with-mask (collide-kind target))) after-player-list) - (let ((node (-> *collide-player-list* alive-list next0))) - *collide-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-player-list* alive-list-end)) - (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) - (other-root (-> other-shape root-prim))) - (when (logtest? with-mask (-> other-root prim-core collide-as)) - (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) - (.sub.vf delta our-sphere other-sphere) - (.add.w.vf.w radius-sum our-sphere other-sphere) - (.mul.vf.xyz delta delta delta) - (.mul.w.vf.w radius-sum radius-sum radius-sum) - (.mul.x.vf.w acc vf0 delta) - (.add.mul.y.vf.w acc vf0 delta acc) - (.add.mul.z.vf.w delta vf0 delta acc) - (.sub.w.vf.w delta delta radius-sum) - (let ((zero-distance 0.0)) - (.add.w.vf.x delta vf0 delta) - (let ((our-process (-> this process))) - (.mov sphere-separation-squared delta) - (let ((other-process (-> other-shape process))) - (b! (< zero-distance sphere-separation-squared) next-player :delay (set! options (-> params options))) - (b! (= our-process other-process) - next-player - :delay - (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) - (b! (zero? root-overlap-option) leaf-test-player :delay (set! touching-list (-> params tlist))) - (b! (= touching-list #f) after-test-player :delay (set! direct-hit? #t)) - (set! hit? direct-hit?) - (add-touching-prims touching-list - our-root - other-root - -1.0 - (the-as collide-tri-result #f) - (the-as collide-tri-result #f)) - (b! #t after-test-player :delay #t) - (label leaf-test-player) - (set! hit? (overlaps-others-test our-root params other-root)) - (label after-test-player) - (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) - (b! (= hit? #f) next-player :delay (set! with-mask (-> our-root collide-with))) - (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) - (label next-player) - 0)) - (set! node next-node) - *collide-player-list* - (set! next-node (-> next-node next0))))) + (iterate-engine-connections (node *collide-player-list*) + (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) + (other-root (-> other-shape root-prim))) + (when (logtest? with-mask (-> other-root prim-core collide-as)) + (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) + (.sub.vf delta our-sphere other-sphere) + (.add.w.vf.w radius-sum our-sphere other-sphere) + (.mul.vf.xyz delta delta delta) + (.mul.w.vf.w radius-sum radius-sum radius-sum) + (.mul.x.vf.w acc vf0 delta) + (.add.mul.y.vf.w acc vf0 delta acc) + (.add.mul.z.vf.w delta vf0 delta acc) + (.sub.w.vf.w delta delta radius-sum) + (let ((zero-distance 0.0)) + (.add.w.vf.x delta vf0 delta) + (let ((our-process (-> this process))) + (.mov sphere-separation-squared delta) + (let ((other-process (-> other-shape process))) + (b! (< zero-distance sphere-separation-squared) next-player :delay (set! options (-> params options))) + (b! (= our-process other-process) + next-player + :delay + (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) + (b! (zero? root-overlap-option) leaf-test-player :delay (set! touching-list (-> params tlist))) + (b! (= touching-list #f) after-test-player :delay (set! direct-hit? #t)) + (set! hit? direct-hit?) + (add-touching-prims touching-list + our-root + other-root + -1.0 + (the-as collide-tri-result #f) + (the-as collide-tri-result #f)) + (b! #t after-test-player :delay #t) + (label leaf-test-player) + (set! hit? (overlaps-others-test our-root params other-root)) + (label after-test-player) + (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) + (b! (= hit? #f) next-player :delay (set! with-mask (-> our-root collide-with))) + (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) + (label next-player) + 0))) (label after-player-list) (when (logtest? with-mask (collide-kind cak-1 cak-2 cak-3)) ;; The same loop again for cak-1, cak-2 and cak-3. (when (logtest? with-mask (collide-kind cak-1)) - (let ((node (-> *collide-hit-by-player-list* alive-list next0))) - *collide-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-player-list* alive-list-end)) - (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) - (other-root (-> other-shape root-prim))) - (when (logtest? with-mask (-> other-root prim-core collide-as)) - (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) - (.sub.vf delta our-sphere other-sphere) - (.add.w.vf.w radius-sum our-sphere other-sphere) - (.mul.vf.xyz delta delta delta) - (.mul.w.vf.w radius-sum radius-sum radius-sum) - (.mul.x.vf.w acc vf0 delta) - (.add.mul.y.vf.w acc vf0 delta acc) - (.add.mul.z.vf.w delta vf0 delta acc) - (.sub.w.vf.w delta delta radius-sum) - (let ((zero-distance 0.0)) - (.add.w.vf.x delta vf0 delta) - (let ((our-process (-> this process))) - (.mov sphere-separation-squared delta) - (let ((other-process (-> other-shape process))) - (b! (< zero-distance sphere-separation-squared) next-cak-1 :delay (set! options (-> params options))) - (b! (= our-process other-process) - next-cak-1 - :delay - (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) - (b! (zero? root-overlap-option) leaf-test-cak-1 :delay (set! touching-list (-> params tlist))) - (b! (= touching-list #f) after-test-cak-1 :delay (set! direct-hit? #t)) - (set! hit? direct-hit?) - (add-touching-prims touching-list - our-root - other-root - -1.0 - (the-as collide-tri-result #f) - (the-as collide-tri-result #f)) - (b! #t after-test-cak-1 :delay #t) - (label leaf-test-cak-1) - (set! hit? (overlaps-others-test our-root params other-root)) - (label after-test-cak-1) - (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) - (b! (= hit? #f) next-cak-1 :delay (set! with-mask (-> our-root collide-with))) - (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) - (label next-cak-1) - 0)) - (set! node next-node) - *collide-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-hit-by-player-list*) + (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) + (other-root (-> other-shape root-prim))) + (when (logtest? with-mask (-> other-root prim-core collide-as)) + (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) + (.sub.vf delta our-sphere other-sphere) + (.add.w.vf.w radius-sum our-sphere other-sphere) + (.mul.vf.xyz delta delta delta) + (.mul.w.vf.w radius-sum radius-sum radius-sum) + (.mul.x.vf.w acc vf0 delta) + (.add.mul.y.vf.w acc vf0 delta acc) + (.add.mul.z.vf.w delta vf0 delta acc) + (.sub.w.vf.w delta delta radius-sum) + (let ((zero-distance 0.0)) + (.add.w.vf.x delta vf0 delta) + (let ((our-process (-> this process))) + (.mov sphere-separation-squared delta) + (let ((other-process (-> other-shape process))) + (b! (< zero-distance sphere-separation-squared) next-cak-1 :delay (set! options (-> params options))) + (b! (= our-process other-process) + next-cak-1 + :delay + (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) + (b! (zero? root-overlap-option) leaf-test-cak-1 :delay (set! touching-list (-> params tlist))) + (b! (= touching-list #f) after-test-cak-1 :delay (set! direct-hit? #t)) + (set! hit? direct-hit?) + (add-touching-prims touching-list + our-root + other-root + -1.0 + (the-as collide-tri-result #f) + (the-as collide-tri-result #f)) + (b! #t after-test-cak-1 :delay #t) + (label leaf-test-cak-1) + (set! hit? (overlaps-others-test our-root params other-root)) + (label after-test-cak-1) + (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) + (b! (= hit? #f) next-cak-1 :delay (set! with-mask (-> our-root collide-with))) + (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) + (label next-cak-1) + 0)))) (when (logtest? with-mask (collide-kind cak-2)) - (let ((node (-> *collide-usually-hit-by-player-list* alive-list next0))) - *collide-usually-hit-by-player-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-usually-hit-by-player-list* alive-list-end)) - (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) - (other-root (-> other-shape root-prim))) - (when (logtest? with-mask (-> other-root prim-core collide-as)) - (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) - (.sub.vf delta our-sphere other-sphere) - (.add.w.vf.w radius-sum our-sphere other-sphere) - (.mul.vf.xyz delta delta delta) - (.mul.w.vf.w radius-sum radius-sum radius-sum) - (.mul.x.vf.w acc vf0 delta) - (.add.mul.y.vf.w acc vf0 delta acc) - (.add.mul.z.vf.w delta vf0 delta acc) - (.sub.w.vf.w delta delta radius-sum) - (let ((zero-distance 0.0)) - (.add.w.vf.x delta vf0 delta) - (let ((our-process (-> this process))) - (.mov sphere-separation-squared delta) - (let ((other-process (-> other-shape process))) - (b! (< zero-distance sphere-separation-squared) next-cak-2 :delay (set! options (-> params options))) - (b! (= our-process other-process) - next-cak-2 - :delay - (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) - (b! (zero? root-overlap-option) leaf-test-cak-2 :delay (set! touching-list (-> params tlist))) - (b! (= touching-list #f) after-test-cak-2 :delay (set! direct-hit? #t)) - (set! hit? direct-hit?) - (add-touching-prims touching-list - our-root - other-root - -1.0 - (the-as collide-tri-result #f) - (the-as collide-tri-result #f)) - (b! #t after-test-cak-2 :delay #t) - (label leaf-test-cak-2) - (set! hit? (overlaps-others-test our-root params other-root)) - (label after-test-cak-2) - (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) - (b! (= hit? #f) next-cak-2 :delay (set! with-mask (-> our-root collide-with))) - (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) - (label next-cak-2) - 0)) - (set! node next-node) - *collide-usually-hit-by-player-list* - (set! next-node (-> next-node next0)))))) + (iterate-engine-connections (node *collide-usually-hit-by-player-list*) + (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) + (other-root (-> other-shape root-prim))) + (when (logtest? with-mask (-> other-root prim-core collide-as)) + (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) + (.sub.vf delta our-sphere other-sphere) + (.add.w.vf.w radius-sum our-sphere other-sphere) + (.mul.vf.xyz delta delta delta) + (.mul.w.vf.w radius-sum radius-sum radius-sum) + (.mul.x.vf.w acc vf0 delta) + (.add.mul.y.vf.w acc vf0 delta acc) + (.add.mul.z.vf.w delta vf0 delta acc) + (.sub.w.vf.w delta delta radius-sum) + (let ((zero-distance 0.0)) + (.add.w.vf.x delta vf0 delta) + (let ((our-process (-> this process))) + (.mov sphere-separation-squared delta) + (let ((other-process (-> other-shape process))) + (b! (< zero-distance sphere-separation-squared) next-cak-2 :delay (set! options (-> params options))) + (b! (= our-process other-process) + next-cak-2 + :delay + (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) + (b! (zero? root-overlap-option) leaf-test-cak-2 :delay (set! touching-list (-> params tlist))) + (b! (= touching-list #f) after-test-cak-2 :delay (set! direct-hit? #t)) + (set! hit? direct-hit?) + (add-touching-prims touching-list + our-root + other-root + -1.0 + (the-as collide-tri-result #f) + (the-as collide-tri-result #f)) + (b! #t after-test-cak-2 :delay #t) + (label leaf-test-cak-2) + (set! hit? (overlaps-others-test our-root params other-root)) + (label after-test-cak-2) + (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) + (b! (= hit? #f) next-cak-2 :delay (set! with-mask (-> our-root collide-with))) + (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) + (label next-cak-2) + 0)))) (when (logtest? with-mask (collide-kind cak-3)) - (let ((node (-> *collide-hit-by-others-list* alive-list next0))) - *collide-hit-by-others-list* - (let ((next-node (-> node next0))) - (while (!= node (-> *collide-hit-by-others-list* alive-list-end)) - (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) - (other-root (-> other-shape root-prim))) - (when (logtest? with-mask (-> other-root prim-core collide-as)) - (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) - (.sub.vf delta our-sphere other-sphere) - (.add.w.vf.w radius-sum our-sphere other-sphere) - (.mul.vf.xyz delta delta delta) - (.mul.w.vf.w radius-sum radius-sum radius-sum) - (.mul.x.vf.w acc vf0 delta) - (.add.mul.y.vf.w acc vf0 delta acc) - (.add.mul.z.vf.w delta vf0 delta acc) - (.sub.w.vf.w delta delta radius-sum) - (let ((zero-distance 0.0)) - (.add.w.vf.x delta vf0 delta) - (let ((our-process (-> this process))) - (.mov sphere-separation-squared delta) - (let ((other-process (-> other-shape process))) - (b! (< zero-distance sphere-separation-squared) next-cak-3 :delay (set! options (-> params options))) - (b! (= our-process other-process) - next-cak-3 - :delay - (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) - (b! (zero? root-overlap-option) leaf-test-cak-3 :delay (set! touching-list (-> params tlist))) - (b! (= touching-list #f) after-test-cak-3 :delay (set! direct-hit? #t)) - (set! hit? direct-hit?) - (add-touching-prims touching-list - our-root - other-root - -1.0 - (the-as collide-tri-result #f) - (the-as collide-tri-result #f)) - (b! #t after-test-cak-3 :delay #t) - (label leaf-test-cak-3) - (set! hit? (overlaps-others-test our-root params other-root)) - (label after-test-cak-3) - (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) - (b! (= hit? #f) next-cak-3 :delay (set! with-mask (-> our-root collide-with))) - (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) - (label next-cak-3) - 0)) - (set! node next-node) - *collide-hit-by-others-list* - (set! next-node (-> next-node next0))))))))) + (iterate-engine-connections (node *collide-hit-by-others-list*) + (let* ((other-shape (the-as collide-shape-moving (-> (the-as connection node) param1))) + (other-root (-> other-shape root-prim))) + (when (logtest? with-mask (-> other-root prim-core collide-as)) + (.lvf other-sphere (&-> other-root prim-core world-sphere quad)) + (.sub.vf delta our-sphere other-sphere) + (.add.w.vf.w radius-sum our-sphere other-sphere) + (.mul.vf.xyz delta delta delta) + (.mul.w.vf.w radius-sum radius-sum radius-sum) + (.mul.x.vf.w acc vf0 delta) + (.add.mul.y.vf.w acc vf0 delta acc) + (.add.mul.z.vf.w delta vf0 delta acc) + (.sub.w.vf.w delta delta radius-sum) + (let ((zero-distance 0.0)) + (.add.w.vf.x delta vf0 delta) + (let ((our-process (-> this process))) + (.mov sphere-separation-squared delta) + (let ((other-process (-> other-shape process))) + (b! (< zero-distance sphere-separation-squared) next-cak-3 :delay (set! options (-> params options))) + (b! (= our-process other-process) + next-cak-3 + :delay + (set! root-overlap-option (logand options (overlaps-others-options accept-root-sphere-overlap))))))) + (b! (zero? root-overlap-option) leaf-test-cak-3 :delay (set! touching-list (-> params tlist))) + (b! (= touching-list #f) after-test-cak-3 :delay (set! direct-hit? #t)) + (set! hit? direct-hit?) + (add-touching-prims touching-list + our-root + other-root + -1.0 + (the-as collide-tri-result #f) + (the-as collide-tri-result #f)) + (b! #t after-test-cak-3 :delay #t) + (label leaf-test-cak-3) + (set! hit? (overlaps-others-test our-root params other-root)) + (label after-test-cak-3) + (.lvf our-sphere (&-> our-root prim-core world-sphere quad)) + (b! (= hit? #f) next-cak-3 :delay (set! with-mask (-> our-root collide-with))) + (b! (= (-> params tlist) #f) finish :delay (set! found-any? 0)) + (label next-cak-3) + 0))))))) (label finish) (b! (= (the-as int found-any?) #f) done :delay (nop!)) (set! found-any? #t) @@ -2848,11 +2776,10 @@ (vector-normalize! shove-direction 1.0) (when (< minimum-up-dot (-> shove-direction y)) (let ((shove-vector (new 'stack-no-clear 'vector))) - (set! (-> shove-vector quad) (-> (the-as process-drawable shove-target) root transv quad)) + (vector-copy! shove-vector (-> (the-as process-drawable shove-target) root transv)) (let ((xz-speed (vector-xz-length (-> (the-as process-drawable shove-target) root transv)))) (if (= xz-speed 0.0) - (set! (-> shove-vector quad) - (-> (vector-z-quaternion! shove-vector (-> (the-as process-drawable shove-target) root quat)) quad))) + (vector-copy! shove-vector (vector-z-quaternion! shove-vector (-> (the-as process-drawable shove-target) root quat)))) (vector-xz-normalize! shove-vector (fmax xz-speed minimum-xz-velocity))) (set! (-> shove-vector y) shove-up-velocity) (let ((shove-event (new 'stack-no-clear 'event-message-block))) @@ -2861,7 +2788,7 @@ (set! (-> shove-event message) 'shove) (set! (-> shove-event param 0) (the-as uint touch-entry)) (let ((shove-attack (new 'static 'attack-info :mask #x802))) - (set! (-> shove-attack vector quad) (-> shove-vector quad)) + (vector-copy! (-> shove-attack vector) shove-vector) (set! (-> shove-attack angle) 'jump) (set! (-> shove-event param 1) (the-as uint shove-attack))) (send-event-function shove-target shove-event)))))))))) @@ -2882,5 +2809,5 @@ (let ((distance-squared (vector-vector-distance-squared target-position path-point))) (when (or (< best-distance-squared 0.0) (< distance-squared best-distance-squared)) (set! best-distance-squared distance-squared) - (set! (-> closest-point quad) (-> path-point quad)))))) + (vector-copy! closest-point path-point))))) (vector-! (-> attack vector) closest-point target-position))) diff --git a/goal_src/jak1/engine/collide/collide-target-h.gc b/goal_src/jak1/engine/collide/collide-target-h.gc index 4132b1f163..93f2c9f985 100644 --- a/goal_src/jak1/engine/collide/collide-target-h.gc +++ b/goal_src/jak1/engine/collide/collide-target-h.gc @@ -205,12 +205,12 @@ "Record a collision-history sample, including the contact point, final position, incoming and outgoing velocity, contact normals, collision state, reaction flags, surface properties, and the current time." - (set! (-> this intersect quad) (-> intersect quad)) - (set! (-> this transv quad) (-> incoming-velocity quad)) - (set! (-> this transv-out quad) (-> outgoing-velocity quad)) - (set! (-> this trans quad) (-> shape trans quad)) - (set! (-> this local-normal quad) (-> shape local-normal quad)) - (set! (-> this surface-normal quad) (-> shape surface-normal quad)) + (vector-copy! (-> this intersect) intersect) + (vector-copy! (-> this transv) incoming-velocity) + (vector-copy! (-> this transv-out) outgoing-velocity) + (vector-copy! (-> this trans) (-> shape trans)) + (vector-copy! (-> this local-normal) (-> shape local-normal)) + (vector-copy! (-> this surface-normal) (-> shape surface-normal)) (set-time! (-> this time)) (set! (-> this status) (-> shape status)) (set! (-> this reaction-flag) (-> shape reaction-flag)) diff --git a/goal_src/jak1/engine/common-obs/babak.gc b/goal_src/jak1/engine/common-obs/babak.gc index 81bfe1c080..8d12d0fa08 100644 --- a/goal_src/jak1/engine/common-obs/babak.gc +++ b/goal_src/jak1/engine/common-obs/babak.gc @@ -24,9 +24,15 @@ :code (behavior () (cond + ;; Preserve the special handoff only when the hop is the animation currently driving Babak. ((ja-group? babak-give-up-hop-ja) + ;; Keep the end of the hop under the walk for 0.15 seconds, softening the change of gait. (ja-channel-push! 1 (seconds 0.15)) + ;; Join the walk at artist frame 12 and seek through the remainder before normal patrol + ;; takes over. `ja-aframe` keeps this join tied to the animator's timeline numbering. (ja-play :group! babak-walk-ja :num! (seek!) :frame-num (ja-aframe 12.0 0))) + ;; All other entries get a slightly gentler 0.2-second blend for the patrol animation + ;; selected by the shared nav-enemy state. (else (ja-channel-push! 1 (seconds 0.2)))) ((the-as (function none) (-> (method-of-type nav-enemy nav-enemy-patrol) code))))) @@ -37,20 +43,30 @@ ;; Blend the landing pose into a fresh run cycle; otherwise start the run directly. (let ((animation-speed (nav-enemy-rnd-float-range 0.9 1.1))) (cond + ;; The landing has a deliberate run handoff; other incoming poses use the ordinary start. ((ja-group? babak-jump-land-ja) + ;; Finish configuring the landing seek without evaluating it again before it is stacked. (ja-no-eval :num! (seek!)) + ;; Retain the landing beneath the new run for a short, responsive cross-fade. (ja-channel-push! 1 (seconds 0.17)) + ;; Run once from frame zero to the end at this creature's chosen speed. Evaluating the + ;; lower stack each tick lets the landing continue naturally while its influence fades. (ja-play :group! (-> self draw art-group data (-> self nav-info run-anim)) :num! (seek! max animation-speed) :frame-num 0.0 (ja-blend-eval))) (else + ;; Give an arbitrary incoming pose a little more time to blend into locomotion. (ja-channel-push! 1 (seconds 0.2)) + ;; Select the run group first, without advancing it, so its opening pose is available. (ja :group! (-> self draw art-group data (-> self nav-info run-anim))) + ;; Hold that opening pose at frame zero until the chase loop begins advancing the run. (ja :num-func num-func-identity :frame-num 0.0))) (loop (suspend) + ;; Advance and wrap the established run every game tick, with a small per-Babak speed + ;; variation to keep a group of creatures from moving in mechanical lockstep. (ja :num! (loop! animation-speed)))))) ;; Face the player, idle, and celebrate after a landed attack or occasional vulnerable opening. @@ -62,24 +78,41 @@ (let ((animation-speed (nav-enemy-rnd-float-range 0.8 1.2))) (when (or (logtest? (-> self nav-enemy-flags) (nav-enemy-flags attack-landed)) (and (nav-enemy-player-vulnerable?) (nav-enemy-rnd-percent? 0.5))) + ;; Blend quickly into the celebratory gesture so a successful attack reads immediately. (ja-channel-push! 1 (seconds 0.1)) + ;; Play from frame zero through artist frame 68, converting that authored beat to the + ;; internal timeline and stopping there rather than running into the clip's recovery. (ja-play :group! babak-win-ja :num! (seek! (ja-aframe 68.0 0) animation-speed) :frame-num 0.0)) (loop (when (not (nav-enemy-facing-player? 2730.6667)) (logior! (-> self nav-enemy-flags) (nav-enemy-flags enable-travel)) + ;; Leave the outgoing pose on a looping rule without evaluating it yet; it will remain + ;; alive underneath the turn while the blend is in progress. (ja-no-eval :num! (loop!)) + ;; Stack one turn channel over the outgoing motion with a relaxed 0.2-second fade. (ja-channel-push! 1 (seconds 0.2)) + ;; Install the turn animation without advancing it so the first pose can be held cleanly. (ja :group! babak-turn-ja) + ;; Pin the turn to frame zero until steering has entered the tighter facing tolerance. (ja :num-func num-func-identity :frame-num 0.0) (until (nav-enemy-facing-player? 1820.4445) + ;; Keep the pose below the turn current; otherwise the cross-fade would blend against + ;; a frozen outgoing frame. (ja-blend-eval) (suspend) + ;; Advance and wrap the turn at three-quarter speed while navigation rotates Babak. (ja :num! (loop! 0.75))) (logclear! (-> self nav-enemy-flags) (nav-enemy-flags enable-travel))) + ;; Do not stack an identical idle over itself. Any other pose gets a smooth 0.2-second + ;; transition before the idle is selected. (if (not (ja-group? babak-idle-ja)) (ja-channel-push! 1 (seconds 0.2))) + ;; Play one complete idle pass at the chosen personality speed, starting from frame zero. (ja-play :group! babak-idle-ja :num! (seek! max animation-speed) :frame-num 0.0) (when (nav-enemy-rnd-percent? 0.3) + ;; The optional flourish should snap into the rhythm, so use a brisk 0.1-second blend. (ja-channel-push! 1 (seconds 0.1)) + ;; Repeat the same authored celebration beat, stopping at artist frame 68 before the + ;; stare loop returns to idle. (ja-play :group! babak-win-ja :num! (seek! (ja-aframe 68.0 0) animation-speed) :frame-num 0.0)))))) (defstate nav-enemy-give-up (babak) @@ -88,6 +121,7 @@ (behavior () (set! (-> self rotate-speed) 218453.33) (set! (-> self turn-time) (seconds 0.5)) + ;; Establish one blended action channel for the optional gesture and the hop that follows it. (ja-channel-push! 1 (seconds 0.15)) ;; Only play the give-up gesture when the player is within 70 degrees of Babak's facing. (let ((collision (-> self collide-info)) @@ -95,9 +129,12 @@ (if (< (fabs (deg-diff (y-angle collision) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) player-position (-> collision trans))))) 12743.111) + ;; Seek the give-up gesture from frame zero to its natural end as a complete one-shot. (ja-play :group! babak-give-up-ja :num! (seek!) :frame-num 0.0))) (logclear! (-> self nav flags) (nav-control-flags blocked reached-destination)) (nav-enemy-get-new-patrol-point) + ;; Play the hop from beginning to end. The body steers toward the new patrol point every + ;; frame, keeping the authored hop and the navigation turn visibly locked together. (ja-play :group! babak-give-up-hop-ja :num! (seek!) @@ -113,8 +150,12 @@ :virtual #t :code (behavior () + ;; Put the outgoing jump on its final-frame seek without evaluating it before the blend. (ja-no-eval :num! (seek!)) + ;; The landing needs a short blend so its contact remains sharp instead of looking slippery. (ja-channel-push! 1 (seconds 0.075)) + ;; Play only the first 32 artist frames of the landing at half speed. While waiting, update + ;; the jump below it so the blend has a live source pose all the way through the contact. (ja-play :group! (-> self draw art-group data (-> self nav-info jump-land-anim)) :num! diff --git a/goal_src/jak1/engine/common-obs/basebutton.gc b/goal_src/jak1/engine/common-obs/basebutton.gc index cd018d96db..dcb5a86a4a 100644 --- a/goal_src/jak1/engine/common-obs/basebutton.gc +++ b/goal_src/jak1/engine/common-obs/basebutton.gc @@ -48,8 +48,8 @@ component of the current root transform." (set! (-> this move-to?) #t) (if position - (set! (-> this move-to-pos quad) (-> position quad)) - (set! (-> this move-to-pos quad) (-> this root trans quad))) + (vector-copy! (-> this move-to-pos) position) + (vector-copy! (-> this move-to-pos) (-> this root trans))) (if rotation (quaternion-copy! (-> this move-to-quat) rotation) (quaternion-copy! (-> this move-to-quat) (-> this root quat)))) @@ -84,7 +84,7 @@ (behavior () (when (-> self move-to?) (set! (-> self move-to?) #f) - (set! (-> self root trans quad) (-> self move-to-pos quad)) + (vector-copy! (-> self root trans) (-> self move-to-pos)) (quaternion-copy! (-> self root quat) (-> self move-to-quat)) (rider-post)))) @@ -108,7 +108,7 @@ (behavior () (when (-> self move-to?) (set! (-> self move-to?) #f) - (set! (-> self root trans quad) (-> self move-to-pos quad)) + (vector-copy! (-> self root trans) (-> self move-to-pos)) (quaternion-copy! (-> self root quat) (-> self move-to-quat))) (rider-post))) @@ -140,7 +140,7 @@ (behavior () (when (-> self move-to?) (set! (-> self move-to?) #f) - (set! (-> self root trans quad) (-> self move-to-pos quad)) + (vector-copy! (-> self root trans) (-> self move-to-pos)) (quaternion-copy! (-> self root quat) (-> self move-to-quat)) (rider-post)))) @@ -164,7 +164,7 @@ (behavior () (when (-> self move-to?) (set! (-> self move-to?) #f) - (set! (-> self root trans quad) (-> self move-to-pos quad)) + (vector-copy! (-> self root trans) (-> self move-to-pos)) (quaternion-copy! (-> self root quat) (-> self move-to-quat))) (rider-post))) @@ -316,7 +316,7 @@ (set! (-> self timeout) timeout) (if source-entity (set! (-> self entity) source-entity)) (setup-collision! self) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-copy! (-> self root quat) rotation) (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) (arm-trigger-event! self) @@ -357,7 +357,7 @@ (set! (-> event-block message) 'change-state) (set! (-> event-block param 0) (the-as uint target-warp-out)) (let ((gate-position (new 'static 'vector))) - (set! (-> gate-position quad) (-> self root trans quad)) + (vector-copy! gate-position (-> self root trans)) (set! (-> event-block param 1) (the-as uint gate-position))) (set! (-> event-block param 2) (the-as uint (target-pos 0))) (send-event-function *target* event-block)) @@ -426,13 +426,13 @@ (set-time! (-> self state-time)) (logclear! (-> self control status) (collide-status on-surface on-ground touch-surface)) (set! (-> self control mod-surface) *warp-jump-mods*) - (set! (-> self control state-vector0 quad) (-> gate-position quad)) - (set! (-> self control state-vector1 quad) (-> camera-position quad)) + (vector-copy! (-> self control state-vector0) gate-position) + (vector-copy! (-> self control state-vector1) camera-position) (+! (-> self control state-vector0 y) -4096.0) (set! (-> self control state-var0) (the-as uint #f)) (vector-reset! (-> self control transv)) (logior! (-> self state-flags) (state-flags use-alt-cam-pos)) - (set! (-> self alt-cam-pos quad) (-> camera-position quad))) + (vector-copy! (-> self alt-cam-pos) camera-position)) :exit (behavior () (logclear! (-> self state-flags) (state-flags use-alt-cam-pos))) diff --git a/goal_src/jak1/engine/common-obs/baseplat.gc b/goal_src/jak1/engine/common-obs/baseplat.gc index cdb8714643..295718862b 100644 --- a/goal_src/jak1/engine/common-obs/baseplat.gc +++ b/goal_src/jak1/engine/common-obs/baseplat.gc @@ -61,7 +61,7 @@ "Mark the skeleton initialized, save the collision root's current translation as the platform's resting transform, and clear the bounce state." (logior! (-> this skel status) (janim-status inited)) - (set! (-> this basetrans quad) (-> this root trans quad)) + (vector-copy! (-> this basetrans) (-> this root trans)) (set! (-> this bouncing) #f) 0 (none)) @@ -100,7 +100,7 @@ (cond ((-> self bouncing) (let ((bounce-transform (new 'stack-no-clear 'vector))) - (set! (-> bounce-transform quad) (-> self basetrans quad)) + (vector-copy! bounce-transform (-> self basetrans)) (+! (-> bounce-transform y) (* 819.2 (update! (-> self smush)))) (move-to-point! (-> self root) bounce-transform)) (if (not (!= (-> self smush amp) 0.0)) (set! (-> self bouncing) #f))) diff --git a/goal_src/jak1/engine/common-obs/collectables-part.gc b/goal_src/jak1/engine/common-obs/collectables-part.gc index 91c0412bf7..4da6b31061 100644 --- a/goal_src/jak1/engine/common-obs/collectables-part.gc +++ b/goal_src/jak1/engine/common-obs/collectables-part.gc @@ -72,7 +72,7 @@ (-> tracker root trans) (vector<-cspace! (new 'stack-no-clear 'vector) (-> target-process node-list data 5)))) (tracker-position (-> tracker root trans))) - (set! (-> tracker-position quad) (-> target-position quad)) + (vector-copy! tracker-position target-position) tracker-position)) (defpartgroup group-eco-blue diff --git a/goal_src/jak1/engine/common-obs/collectables.gc b/goal_src/jak1/engine/common-obs/collectables.gc index fd3015d2cf..ed23aca7a6 100644 --- a/goal_src/jak1/engine/common-obs/collectables.gc +++ b/goal_src/jak1/engine/common-obs/collectables.gc @@ -70,8 +70,8 @@ (set! (-> this fadeout-timeout) fadeout-time)) (set! (-> this collect-timeout) (seconds 0.33)) (set-time! (-> this birth-time)) - (set! (-> this base quad) (-> this root trans quad)) - (set! (-> this old-base quad) (-> this root trans quad)) + (vector-copy! (-> this base) (-> this root trans)) + (vector-copy! (-> this old-base) (-> this root trans)) (set! (-> this pickup-handle) (the-as handle #f)) (case (-> this fact pickup-type) (((pickup-type eco-pill) (pickup-type eco-green) (pickup-type money) (pickup-type eco-blue)) @@ -180,8 +180,8 @@ (set! (-> self fact pickup-type) kind) (set! (-> self fact pickup-amount) amount)) (set! (-> self fact options) (-> pickup-info options)) - (set! (-> self root trans quad) (-> position quad)) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root trans) position) + (vector-copy! (-> self root transv) velocity) (initialize-effect self (-> self fact pickup-type)) (set! (-> self notify-parent) #f) (case (-> self fact pickup-type) @@ -203,7 +203,7 @@ (set! (-> this pickup-amount) amount) (set! (-> this pickup-type) kind) (initialize this) - (set! (-> this root trans quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this root trans) (-> source-entity extra trans)) (initialize-effect this (-> this fact pickup-type)) (initialize-params this 0 (the-as float 1024.0)) (update-transforms! (-> this root)) @@ -312,8 +312,8 @@ (animate self) (suspend) (if (nonzero? (-> self skel)) (ja :num! (loop! 0.5))))) - (set! (-> self root trans quad) (-> self jump-pos quad)) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self root trans) (-> self jump-pos)) + (vector-copy! (-> self base) (-> self root trans)) (vector-reset! (-> self root transv)) (update-transforms! (-> self root)) (logclear! (-> self flags) (collectable-flags trans)) @@ -345,12 +345,12 @@ (logclear! (-> self mask) (process-mask actor-pause)) (go-virtual notice-blue (process->handle proc)))) ((= message 'trans) - (set! (-> self root trans quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self root trans) (the-as vector (-> block param 0))) (update-transforms! (-> self root)) (ja-post)) ((= message 'jump) (logclear! (-> self mask) (process-mask actor-pause)) - (set! (-> self jump-pos quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self jump-pos) (the-as vector (-> block param 0))) (go-virtual jump)) ((= message 'pickup) (when (!= (-> self next-state name) 'pickup) @@ -395,7 +395,7 @@ (logclear! (-> self flags) (collectable-flags trans)) (logior! (-> self flags) (collectable-flags can-collect)) (if (-> self actor-pause) (logior! (-> self mask) (process-mask actor-pause))) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self base) (-> self root trans)) (if (and (logtest? (-> self fact options) (fact-options can-collect)) (not (logtest? (-> self flags) (collectable-flags ignore-blue)))) (go-virtual notice-blue (process->handle *target*))) @@ -438,7 +438,7 @@ :enter (behavior ((target-handle handle)) (set! (-> self target) target-handle) - (set! (-> self speed quad) (the-as uint128 0)) + (vector-zero! (-> self speed)) (set! (-> self speed z) (the-as float (if (rand-vu-percent? (the-as float 0.5)) 1.0 -1.0))) (set! (-> self suck-y-offset) 0.0) (logclear! (-> self mask) (process-mask actor-pause))) @@ -458,7 +458,7 @@ :code (behavior ((target-handle handle)) (loop - (set! (-> self root trans quad) (-> self base quad)) + (vector-copy! (-> self root trans) (-> self base)) (add-blue-motion #t #f #t #f) (update-transforms! (-> self root)) (if (nonzero? (-> self draw)) (ja-post)) @@ -602,8 +602,8 @@ (else (while (let ((zero 0.0)) (< zero (the-as float (send-event *target* 'query 'pickup (-> self fact pickup-type))))) (suspend)))) - (set! (-> self base quad) (-> self old-base quad)) - (set! (-> self root trans quad) (-> self base quad)) + (vector-copy! (-> self base) (-> self old-base)) + (vector-copy! (-> self root trans) (-> self base)) (restore-collide-with-as (-> self root)) (go-virtual wait))) @@ -758,7 +758,7 @@ (behavior ((target-handle handle)) (loop (quaternion-rotate-y! (-> self root quat) (-> self root quat) (* 91022.22 (seconds-per-frame))) - (set! (-> self root trans quad) (-> self base quad)) + (vector-copy! (-> self root trans) (-> self base)) (add-blue-motion #t #t #t #f) (let ((bob-amount (-> self bob-amount))) (if (< 0.0 bob-amount) @@ -839,10 +839,10 @@ (set! (-> self fact pickup-amount) amount)) (set! (-> self fact options) (-> pickup-info options)) (set! (-> self notify-parent) #t) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-identity! (-> self root quat)) (vector-identity! (-> self root scale)) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root transv) velocity) (initialize-params self (seconds 15) (the-as float 1024.0)) (update-transforms! (-> self root)) (set! (-> self event-hook) (-> (method-of-object self wait) event)) @@ -859,10 +859,10 @@ (set! (-> self fact pickup-type) kind) (set! (-> self fact pickup-amount) amount) (set! (-> self notify-parent) #t) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-identity! (-> self root quat)) (vector-identity! (-> self root scale)) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root transv) velocity) (initialize-params self (seconds 15) (the-as float 0.0)) (logior! (-> self flags) (collectable-flags ignore-blue)) (update-transforms! (-> self root)) @@ -956,8 +956,8 @@ (go-virtual pickup #f (process->handle proc))) (cond ((= message 'trans) - (set! (-> self root trans quad) (-> (the-as vector (-> block param 0)) quad)) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self root trans) (the-as vector (-> block param 0))) + (vector-copy! (-> self base) (-> self root trans)) (update-transforms! (-> self root))) ((= message 'pickup) (when (!= (-> self next-state name) 'pickup) @@ -1191,8 +1191,8 @@ (set! (-> this notify-parent) #f) (set! (-> this fact) (new 'process 'fact-info this (pickup-type fuel-cell) (the-as float 0.0))) (initialize-skeleton this *fuel-cell-sg* '()) - (set! (-> this base quad) (-> this root trans quad)) - (set! (-> this old-base quad) (-> this root trans quad)) + (vector-copy! (-> this base) (-> this root trans)) + (vector-copy! (-> this old-base) (-> this root trans)) (set! (-> this part) (create-launch-control group-fuel-cell-starburst this)) (set! (-> this sound) (new 'process 'ambient-sound (static-sound-spec "powercell-idle" :fo-max 40) (-> this root trans))) (set! (-> this victory-anim) (fuel-cell-pick-anim this)) @@ -1223,24 +1223,24 @@ (set! (-> self fact pickup-amount) amount)) (set! (-> self fact options) (-> pickup-info options)) (set! (-> self notify-parent) #t) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-identity! (-> self root quat)) (vector-identity! (-> self root scale)) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root transv) velocity) (initialize-params self 0 (the-as float 1024.0)) (logclear! (-> self fact options) (fact-options can-collect)) (update-transforms! (-> self root)) (let ((movie-position (res-lump-struct (-> self entity) 'movie-pos structure :time (the-as float -1000000000.0)))) (cond ((and *debug-segment* (< (-> *fuel-cell-tune-pos* w) 1000000000.0)) - (set! (-> self jump-pos quad) (-> *fuel-cell-tune-pos* quad)) + (vector-copy! (-> self jump-pos) *fuel-cell-tune-pos*) (+! (-> self jump-pos y) 4096.0) (go-virtual jump)) ((and movie-position (not (logtest? (res-lump-value (-> self entity) 'options fact-options :time (the-as float -1000000000.0)) (fact-options skip-jump-anim))) (not (logtest? (-> self fact options) (fact-options skip-jump-anim)))) - (set! (-> self jump-pos quad) (-> (the-as vector movie-position) quad)) + (vector-copy! (-> self jump-pos) (the-as vector movie-position)) (+! (-> self jump-pos y) 4096.0) (go-virtual jump)))) (set! (-> self event-hook) (-> (method-of-object self wait) event)) @@ -1257,12 +1257,12 @@ (logclear! (-> self mask) (process-mask actor-pause)) (go-virtual pickup #f (the-as handle #f)))) (('trans) - (set! (-> self root trans quad) (-> (the-as vector (-> block param 0)) quad)) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self root trans) (the-as vector (-> block param 0))) + (vector-copy! (-> self base) (-> self root trans)) (update-transforms! (-> self root))) (('stop-cloning 'notify) - (set! (-> self root trans quad) (-> self draw origin quad)) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self root trans) (-> self draw origin)) + (vector-copy! (-> self base) (-> self root trans)) (ja-channel-set! 1) (ja :group! fuel-cell-idle-ja) (logclear! (-> self draw status) (draw-status hidden)) @@ -1448,10 +1448,10 @@ (set! (-> self fact pickup-amount) amount)) (set! (-> self fact options) (-> pickup-info options)) (set! (-> self notify-parent) #t) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-identity! (-> self root quat)) (vector-identity! (-> self root scale)) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root transv) velocity) (initialize-params self 0 (the-as float 1024.0)) (update-transforms! (-> self root)) (update-trans! (-> self sound) (-> self root trans)) @@ -1649,7 +1649,7 @@ (+ (rand-vu-float-range (the-as float 3.0) (+ 5.0 amount)) (the float amount-bonus))) (else (+ (rand-vu-float-range (the-as float 2.0) (+ 3.0 amount)) (the float amount-bonus))))))) (let ((spawn-position (new 'stack-no-clear 'vector))) - (set! (-> spawn-position quad) (-> this process root trans quad)) + (vector-copy! spawn-position (-> this process root trans)) (+! (-> spawn-position y) 12288.0) (let ((ground-hit (new 'stack-no-clear 'collide-tri-result))) (if (>= (fill-and-probe-using-y-probe *collide-cache* @@ -1660,8 +1660,8 @@ ground-hit (new 'static 'pat-surface :noentity #x1)) 0.0) - (set! (-> spawn-position quad) (-> ground-hit intersect quad)) - (set! (-> spawn-position quad) (-> this process root trans quad)))) + (vector-copy! spawn-position (-> ground-hit intersect)) + (vector-copy! spawn-position (-> this process root trans)))) (if (= (the-as int kind) 6) (+! (-> spawn-position y) 6144.0)) (birth-pickup-at-point spawn-position (the-as pickup-type kind) amount radial-velocity? destination-pool this)))) @@ -1720,11 +1720,11 @@ (if (and *target* (logtest? (-> *target* control root-prim prim-core action) (collide-action racer))) (clear-collide-with-as (-> self root))) (set! (-> self block-func) block-fn) - (set! (-> self root trans quad) (-> (the-as process-drawable (-> self parent 0)) root trans quad)) + (vector-copy! (-> self root trans) (-> (the-as process-drawable (-> self parent 0)) root trans)) (set-vector! (-> self offset-target) 0.0 -2252.8 0.0 1.0) (if (not ((-> self block-func) (the-as vent (ppointer->process (-> self parent))))) (set-vector! (-> self offset-target) 0.0 0.0 0.0 1.0)) - (set! (-> self offset quad) (-> self offset-target quad)) + (vector-copy! (-> self offset) (-> self offset-target)) (initialize-skeleton self *ecovalve-sg* '()) (move-to-point! (-> self root) (vector+! (new 'stack-no-clear 'vector) (-> (the-as process-drawable (-> self parent 0)) root trans) (-> self offset))) @@ -1762,7 +1762,7 @@ (set! (-> collision-shape nav-radius) (* 0.75 (-> collision-shape root-prim local-sphere w))) (backup-collide-with-as collision-shape) (set! (-> this root) collision-shape)) - (set! (-> this root trans quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this root trans) (-> source-entity extra trans)) (update-transforms! (-> this root)) (set! (-> this root pause-adjust-distance) 409600.0) (set! (-> this fact) (new 'process 'fact-info this kind (-> *FACT-bank* eco-full-inc))) diff --git a/goal_src/jak1/engine/common-obs/crates.gc b/goal_src/jak1/engine/common-obs/crates.gc index 8db67b9187..66a3fce29c 100644 --- a/goal_src/jak1/engine/common-obs/crates.gc +++ b/goal_src/jak1/engine/common-obs/crates.gc @@ -590,7 +590,7 @@ (go-virtual die #f 0)) (when (rand-vu-percent? 0.5) (let ((glow-position (new 'stack-no-clear 'vector))) - (set! (-> glow-position quad) (-> crate-core world-sphere quad)) + (vector-copy! glow-position (-> crate-core world-sphere)) (dotimes (i 3) (+! (-> glow-position data i) (rand-vu-float-range -5324.8 5324.8))) (eco-blue-glow glow-position))) @@ -762,7 +762,7 @@ "Initialize a spawned crate from entity, place it at position, use crate-type for both its look and defense, initialize its art, and enter its saved-dead or ordinary wait state." (params-init self entity-record) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set! (-> self look) crate-type) (set! (-> self defense) crate-type) (art-init self) @@ -863,7 +863,7 @@ (set! (-> this root root-prim prim-core offense) (collide-offense normal-attack))) ((logtest? (-> this fact options) (fact-options touch)) (set! (-> this root root-prim prim-core offense) (collide-offense touch)))) - (set! (-> this base quad) (-> this root trans quad)) + (vector-copy! (-> this base) (-> this root trans)) (crate-post) (nav-mesh-connect this (-> this root) (the-as nav-control #f)) this) diff --git a/goal_src/jak1/engine/common-obs/generic-obs.gc b/goal_src/jak1/engine/common-obs/generic-obs.gc index c35a4bf708..2e3bc43598 100644 --- a/goal_src/jak1/engine/common-obs/generic-obs.gc +++ b/goal_src/jak1/engine/common-obs/generic-obs.gc @@ -54,7 +54,7 @@ (collision-root (if (and (nonzero? root) (type-type? (-> root type) collide-shape)) (the-as collide-shape root)))) (if collision-root (move-to-point! collision-root (-> (the-as process-drawable source) root trans)) - (set! (-> self root trans quad) (-> (the-as process-drawable source) root trans quad)))) + (vector-copy! (-> self root trans) (-> (the-as process-drawable source) root trans)))) (quaternion-copy! (-> self root quat) (-> (the-as process-drawable source) root quat))) (if (logtest? (-> (the-as process-drawable source) skel status) (janim-status spool)) (logior! (-> self skel status) (janim-status spool))) @@ -114,7 +114,7 @@ (stack-size-set! (-> this main-thread) 128) (logior! (-> this mask) (process-mask actor-pause)) (set! (-> this root) (new 'process 'trsq)) - (set! (-> this root trans quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this root trans) (-> source-entity extra trans)) (quaternion-copy! (-> this root quat) (-> source-entity quat)) (vector-identity! (-> this root scale)) (vector-y-quaternion! (-> this dir) (-> this root quat)) @@ -201,7 +201,7 @@ (let ((grabbed-process (handle->process (-> self cur-grab-handle)))) (when grabbed-process (set! result (-> self old-grab-pos)) - (set! (-> (the-as vector result) quad) (-> (the-as process-drawable grabbed-process) root trans quad)) + (vector-copy! (the-as vector result) (-> (the-as process-drawable grabbed-process) root trans)) result))) (('target) (set! result (process->handle (the-as process (-> block param 0)))) @@ -213,7 +213,7 @@ (move-to-point! (the-as collide-shape (-> self root)) (the-as vector (-> block param 0)))) (else (set! result (-> self root trans)) - (set! (-> (the-as vector result) quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (the-as vector result) (the-as vector (-> block param 0))) result))) (('rot) (let ((rotation-matrix (new 'stack-no-clear 'matrix))) @@ -270,7 +270,7 @@ (vector+! (-> self root trans) (-> self root trans) (vector-! (new 'stack-no-clear 'vector) grabbed-position (-> self old-grab-pos)))) - (set! (-> self old-grab-pos quad) (-> grabbed-position quad))))) + (vector-copy! (-> self old-grab-pos) grabbed-position)))) ((-> self cur-trans-hook))) :code (behavior () @@ -344,7 +344,7 @@ (backup-collide-with-as collectable-root) (set! (-> self root) collectable-root))) (else (set! (-> self root) (new 'process 'trsqv)))) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (initialize-skeleton self skel-group '()) (if (type-type? (-> self root type) collide-shape) (update-transforms! (the-as collide-shape (-> self root)))) (set! (-> self shadow-backup) (-> self draw shadow)) @@ -423,8 +423,8 @@ group's duration when duration is not positive, invoking callback each frame when supplied." (stack-size-set! (-> self main-thread) 128) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> origin world-sphere quad)) - (set! (-> self offset quad) (-> origin world-sphere quad)) + (vector-copy! (-> self root trans) (-> origin world-sphere)) + (vector-copy! (-> self offset) (-> origin world-sphere)) (set! (-> self callback) (the-as (function part-tracker vector) frame-callback)) (set! (-> self linger-callback) #f) (set! (-> self userdata) (the-as uint userdata)) @@ -1187,7 +1187,7 @@ (vector--float*! (-> self trans) (-> *camera* tpos-curr) (-> *camera* local-down) 28672.0) (vector-flatten! level-forward (-> self tracking inv-mat vector 2) (-> *camera* local-down)) (vector-normalize! level-forward 1.0) - (set! (-> self pivot-pt quad) (-> level-forward quad)) + (vector-copy! (-> self pivot-pt) level-forward) (vector+float*! level-forward level-forward (-> *camera* local-down) 1000.0) (vector-normalize-copy! (-> self tracking inv-mat vector 2) level-forward 1.0)) (vector-cross! (-> self tracking inv-mat vector 1) @@ -1416,7 +1416,7 @@ (set! (-> root-shape nav-radius) (* 0.75 (-> root-shape root-prim local-sphere w))) (backup-collide-with-as root-shape) (set! (-> self root) root-shape)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) (set-vector! (-> self root quat) 0.0 0.0 0.0 1.0) (update-transforms! (-> self root)) @@ -1518,7 +1518,7 @@ (let* ((target-root (-> (the-as process-drawable target-drawable) root)) (target-shape (if (and (nonzero? target-root) (type-type? (-> target-root type) collide-shape)) target-root))) (if target-shape - (set! (-> self root trans quad) (-> (the-as collide-shape target-shape) root-prim prim-core world-sphere quad)))))) + (vector-copy! (-> self root trans) (-> (the-as collide-shape target-shape) root-prim prim-core world-sphere)))))) (if (-> self callback) ((-> self callback) self)) (update-transforms! (-> self root)) (let ((overlap-params (new 'stack-no-clear 'overlaps-others-params))) @@ -1548,7 +1548,7 @@ (backup-collide-with-as tracker-shape) (set! (-> tracker-shape event-self) 'touched) (set! (-> self root) tracker-shape)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set! (-> self duration) duration) (set! (-> self target) (the-as handle #f)) (set! (-> self event) #f) diff --git a/goal_src/jak1/engine/common-obs/nav-enemy.gc b/goal_src/jak1/engine/common-obs/nav-enemy.gc index 853d3fec06..602ab5112f 100644 --- a/goal_src/jak1/engine/common-obs/nav-enemy.gc +++ b/goal_src/jak1/engine/common-obs/nav-enemy.gc @@ -160,13 +160,13 @@ (go-virtual nav-enemy-die)) (('jump) (when (!= (-> self next-state name) 'nav-enemy-jump-land) - (set! (-> self event-param-point quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self event-param-point) (the-as vector (-> block param 0))) (set! (-> self nav user-poly) (the-as nav-poly (-> block param 1))) (set! (-> self jump-return-state) (the-as (state process) (-> self state))) (go-virtual nav-enemy-jump))) (('cue-jump-to-point) (when (logtest? (-> self nav-enemy-flags) (nav-enemy-flags waiting-for-cue)) - (set! (-> self event-param-point quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self event-param-point) (the-as vector (-> block param 0))) (let ((new-flags (the-as object (logclear (-> self nav-enemy-flags) (nav-enemy-flags waiting-for-cue))))) (set! (-> self nav-enemy-flags) (the-as nav-enemy-flags new-flags)) new-flags))) @@ -415,7 +415,7 @@ nav-enemy-default-event-handler "Return true when the enemy's horizontal facing is within angle-tolerance of direction." (let ((facing-direction (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self collide-info quat))) (test-direction (new 'stack-no-clear 'vector))) - (set! (-> test-direction quad) (-> direction quad)) + (vector-copy! test-direction direction) (set! (-> test-direction y) 0.0) (vector-normalize! test-direction 1.0) (>= (vector-dot facing-direction test-direction) (cos angle-tolerance)))) @@ -480,7 +480,7 @@ nav-enemy-default-event-handler (let* ((hit-direction (-> self hit-from-dir)) (attacker-process source) (attacker (if (and (nonzero? attacker-process) (type-type? (-> attacker-process type) process-drawable)) attacker-process))) - (set! (-> hit-direction quad) (-> *null-vector* quad)) + (vector-copy! hit-direction *null-vector*) (when attacker (vector-! hit-direction (-> self collide-info trans) (-> (the-as process-drawable attacker) root trans)) (set! (-> hit-direction y) 0.0) @@ -728,7 +728,7 @@ nav-enemy-default-event-handler "Clear frustrated, record the player's current shadow position, and restart the frustration timer." (logclear! (-> self nav-enemy-flags) (nav-enemy-flags frustrated)) - (if *target* (set! (-> self frustration-point quad) (-> *target* control shadow-pos quad))) + (if *target* (vector-copy! (-> self frustration-point) (-> *target* control shadow-pos))) (set-time! (-> self frustration-time)) 0 (none)) @@ -834,7 +834,7 @@ nav-enemy-default-event-handler (the int (+ (lerp-scale 3000.0 0.0 distance-to-player 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) (-> self nav-info run-turn-time)) - (set! (-> self collide-info transv quad) (-> *null-vector* quad))) + (vector-copy! (-> self collide-info transv) *null-vector*)) :exit (behavior () (logior! (-> self nav-enemy-flags) (nav-enemy-flags enable-travel))) @@ -897,7 +897,7 @@ nav-enemy-default-event-handler :event nav-enemy-default-event-handler :enter (behavior () - (set! (-> self collide-info transv quad) (-> *null-vector* quad))) + (vector-copy! (-> self collide-info transv) *null-vector*)) :code (behavior () (ja-channel-push! 1 (seconds 0.075)) @@ -984,7 +984,7 @@ nav-enemy-default-event-handler (defbehavior nav-enemy-initialize-custom-jump nav-enemy ((destination vector) (use-drop-arc? symbol) (minimum-height float) (height-factor float) (gravity float)) "Solve a ballistic jump to destination from minimum height, distance height factor, and gravity. Classify standing and drop jumps and reserve the destination as an extra navigation sphere." - (set! (-> self jump-dest quad) (-> destination quad)) + (vector-copy! (-> self jump-dest) destination) (let* ((start-position (-> self collide-info trans)) (horizontal-distance (vector-vector-xz-distance start-position destination)) (arc-height (fmax minimum-height (* height-factor horizontal-distance)))) @@ -1059,7 +1059,7 @@ nav-enemy-default-event-handler (suspend) (ja :num! (seek!)) (ja-blend-eval)) - (set! (-> self collide-info trans quad) (-> self jump-dest quad)) + (vector-copy! (-> self collide-info trans) (-> self jump-dest)) (set! (-> self collide-info transv y) 0.0) (logclear! (-> self collide-info nav-flags) (nav-flags avoid-extra-sphere)) 0 @@ -1147,7 +1147,7 @@ nav-enemy-default-event-handler (set-time! (-> self state-time)) (logclear! (-> self nav flags) (nav-control-flags reached-destination)) (let ((flat-velocity (new 'stack-no-clear 'vector))) - (set! (-> flat-velocity quad) (-> self collide-info transv quad)) + (vector-copy! flat-velocity (-> self collide-info transv)) (set! (-> flat-velocity y) 0.0) (set! (-> self target-speed) (vector-length flat-velocity)) (set! (-> self momentum-speed) (-> self target-speed)) @@ -1305,8 +1305,8 @@ nav-enemy-default-event-handler normal notice-distance gating, and enter the controller cue state." (initialize-collision self) (logior! (-> self mask) (process-mask actor-pause)) - (set! (-> self collide-info trans quad) (-> spawn-position quad)) - (set! (-> self event-param-point quad) (-> cue-point quad)) + (vector-copy! (-> self collide-info trans) spawn-position) + (vector-copy! (-> self event-param-point) cue-point) (let ((facing-direction (vector-! (new 'stack-no-clear 'vector) cue-point spawn-position))) (set! (-> facing-direction y) 0.0) (vector-normalize! facing-direction 1.0) @@ -1350,11 +1350,11 @@ nav-enemy-default-event-handler "Return true when a proposed jump destination lies inside an occupied navigation sphere relative to this enemy." (let ((saved-position (new 'stack-no-clear 'vector))) - (set! (-> saved-position quad) (-> this collide-info trans quad)) - (set! (-> this collide-info trans quad) (-> point quad)) + (vector-copy! saved-position (-> this collide-info trans)) + (vector-copy! (-> this collide-info trans) point) (let ((navigation (-> this nav))) (gather-nav-spheres! navigation (the-as collide-kind -1)) - (set! (-> this collide-info trans quad) (-> saved-position quad)) + (vector-copy! (-> this collide-info trans) saved-position) (let* ((mesh-origin (-> navigation mesh origin)) (point-offset-x (- (-> point x) (-> mesh-origin x))) (point-offset-z (- (-> point z) (-> mesh-origin z)))) diff --git a/goal_src/jak1/engine/common-obs/orb-cache.gc b/goal_src/jak1/engine/common-obs/orb-cache.gc index 481e81f31e..e3679bd5ce 100644 --- a/goal_src/jak1/engine/common-obs/orb-cache.gc +++ b/goal_src/jak1/engine/common-obs/orb-cache.gc @@ -119,8 +119,7 @@ (seek! (-> this basetrans y) (+ (-> this root-pos) target-platform-offset) (* 40960.0 (seconds-per-frame))) (if (not (= (-> this basetrans y) (+ (-> this root-pos) target-platform-offset))) (set! at-target? #f))) (dotimes (orb-index (-> this money)) - (set! (-> orb-position quad) - (-> (the-as process-drawable (handle->process (-> this money-list orb-index))) root trans quad)) + (vector-copy! orb-position (-> (the-as process-drawable (handle->process (-> this money-list orb-index))) root trans)) (seek! (-> this money-pos-actual orb-index) (-> this money-pos-list orb-index) (* 40960.0 (seconds-per-frame))) (if (not (= (-> this money-pos-actual orb-index) (-> this money-pos-list orb-index))) (set! at-target? #f)) (if (>= (-> this money-pos-actual orb-index) (+ -8192.0 (-> this root-pos))) @@ -146,7 +145,7 @@ (if initial? (set! (-> self basetrans y) (-> self platform-pos)) (sound-play "open-orb-cash")) (dotimes (i (-> self money)) (let ((spawn-position (new 'stack-no-clear 'vector))) - (set! (-> spawn-position quad) (-> self basetrans quad)) + (vector-copy! spawn-position (-> self basetrans)) (set! (-> spawn-position y) (-> self money-pos-list i)) (set! (-> self money-pos-actual i) (-> spawn-position y)) (set! (-> self money-list i) diff --git a/goal_src/jak1/engine/common-obs/plat-button.gc b/goal_src/jak1/engine/common-obs/plat-button.gc index 4f3c329ef7..77ca6b5a66 100644 --- a/goal_src/jak1/engine/common-obs/plat-button.gc +++ b/goal_src/jak1/engine/common-obs/plat-button.gc @@ -331,7 +331,7 @@ (logclear! (-> this mask) (process-mask actor-pause)) (setup-skeleton! this) (logior! (-> this skel status) (janim-status inited)) - (set! (-> this spawn-pos quad) (-> this root trans quad)) + (vector-copy! (-> this spawn-pos) (-> this root trans)) (set! (-> this path) (new 'process 'curve-control this 'path -1000000000.0)) (logior! (-> this path flags) (path-control-flag display draw-line draw-point draw-text)) (set! (-> this path-pos) 0.0) diff --git a/goal_src/jak1/engine/common-obs/plat-eco.gc b/goal_src/jak1/engine/common-obs/plat-eco.gc index 63b327205e..558ba6424b 100644 --- a/goal_src/jak1/engine/common-obs/plat-eco.gc +++ b/goal_src/jak1/engine/common-obs/plat-eco.gc @@ -108,7 +108,7 @@ (tracker-distance (vector-vector-distance (-> platform-prim world-sphere) (-> tracker-prim world-sphere)))) (when (rand-vu-percent? 0.5) (let ((glow-position (new 'stack-no-clear 'vector))) - (set! (-> glow-position quad) (-> platform-prim world-sphere quad)) + (vector-copy! glow-position (-> platform-prim world-sphere)) (dotimes (i 3) (+! (-> glow-position data i) (rand-vu-float-range -5324.8 5324.8))) (eco-blue-glow glow-position))) diff --git a/goal_src/jak1/engine/common-obs/process-drawable-h.gc b/goal_src/jak1/engine/common-obs/process-drawable-h.gc index 34d3602fd9..3b23d2a8c2 100644 --- a/goal_src/jak1/engine/common-obs/process-drawable-h.gc +++ b/goal_src/jak1/engine/common-obs/process-drawable-h.gc @@ -112,6 +112,64 @@ (define-extern process-entity-status! (function process entity-perm-status symbol int)) +#| +Joint-animation recipe for creatures +------------------------------------ + +The `ja` helpers operate on `self`'s joint controller. A channel has an animation group, an +internal frame, a frame interpolation value, and a frame-number function. Channel zero is the +ordinary whole-creature animation; use another channel only when the creature's skeleton and art +were authored for a layered animation. + +Choose the animation with `:group!`, and choose how its frame changes with `:num!`: + + (+! speed) advance once without wrapping + (-! speed) run backward + (loop! speed) advance and wrap at the end + (seek! frame speed) approach a frame and stop there + (identity frame) hold an exact frame + (chan source-channel) follow another channel's frame + min / max hold the first / last frame + +The speed defaults to 1.0. `seek!` also defaults its target to the animation's last internal +frame, so `(seek!)` is the usual one-shot. `ja-aframe` converts an artist's timeline frame to the +internal frame used by `seek!`; use it for authored contacts, anticipation poses, and handoffs. + +`ja` applies the requested changes and, when `:num!` selects a frame rule, evaluates the channel +immediately. Direct field changes such as `:group!`, `:num-func`, and `:frame-num` can be combined +to prepare a pose without advancing it. `ja-no-eval` also suppresses the evaluation attached to +`:num!`; that is useful immediately before pushing a blend, or when the caller needs to evaluate +the old stack explicitly with `ja-blend-eval`. + +`ja-play` is the standard blocking one-shot: it installs the group and frame rule without an +initial evaluation, then suspends once per frame and advances until a seek reaches its target. +Forms in its body run before each suspension, which is where a creature should steer, align root +motion, or evaluate the channels underneath a blend. + +For a clean transition, call `ja-channel-push!` before selecting the new group. It keeps the old +pose below a new root group and fades it out over the supplied time. During a hand-authored +transition, call `ja-blend-eval` while the new animation plays so the retained pose stays current. +Use `ja-group?` to select animation-specific handoffs rather than restarting a generic pose. + +Typical creature loops are: + + ;; A looping locomotion cycle. + (ja-channel-push! 1 (seconds 0.15)) + (ja :group! creature-run-ja :num! min) + (loop + (suspend) + (ja :num! (loop! run-speed))) + + ;; A one-shot action with steering while it plays. + (ja-channel-push! 1 (seconds 0.1)) + (ja-play :group! creature-attack-ja :num! (seek!) :frame-num 0.0 + (turn-toward-target! self)) + +Keep `:frame-num 0.0` on a newly selected one-shot unless the action deliberately joins at a +specific authored pose. A polished creature should blend into new groups, use artist frames for +visual beats, and make its locomotion speed explicit so motion and animation remain in step. +|# + (defmacro ja-group (&key (chan 0)) "Return self's frame group on chan, or #f when the channel is inactive. Channel zero is the base channel." diff --git a/goal_src/jak1/engine/common-obs/process-drawable.gc b/goal_src/jak1/engine/common-obs/process-drawable.gc index a35d87905c..ed88af325f 100644 --- a/goal_src/jak1/engine/common-obs/process-drawable.gc +++ b/goal_src/jak1/engine/common-obs/process-drawable.gc @@ -458,13 +458,13 @@ (set! (-> control-data shadow) #f) (set! (-> control-data shadow-ctrl) #f) (set! (-> control-data data-format) (the-as uint 1)) - (set! (-> control-data color-mult quad) (-> (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) quad)) - (set! (-> control-data color-emissive quad) (-> (new 'static 'vector) quad)) + (vector-copy! (-> control-data color-mult) (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + (vector-copy! (-> control-data color-emissive) (new 'static 'vector)) (set! (-> control-data level-index) (the-as uint (-> (if (-> this entity) (-> this entity extra level) (-> *level* level-default)) index))) (set! (-> control-data longest-edge) (-> skeleton-group-data longest-edge)) (set! (-> control-data ripple) #f)) - (set! (-> control bounds quad) (-> skeleton-group-data bounds quad)) + (vector-copy! (-> control bounds) (-> skeleton-group-data bounds)) (let ((shadow-index (-> skeleton-group-data shadow))) (when (and (> shadow-index 0) (< shadow-index art-element-count)) (let ((shadow-geometry (-> art-group-data data shadow-index)) @@ -897,8 +897,8 @@ (spawn-position (new 'stack-no-clear 'vector))) (if (not spawn-entity) (set! spawn-entity (-> self entity))) (if position - (set! (-> spawn-position quad) (-> position quad)) - (set! (-> spawn-position quad) (-> spawn-entity extra trans quad))) + (vector-copy! spawn-position position) + (vector-copy! spawn-position (-> spawn-entity extra trans))) (let ((task (-> spawn-entity extra perm task)) (pickup-options (new 'static 'fact-info))) (set! (-> pickup-options options) (fact-options)) diff --git a/goal_src/jak1/engine/common-obs/process-taskable.gc b/goal_src/jak1/engine/common-obs/process-taskable.gc index 5a8296b9d9..3c9db1d26f 100644 --- a/goal_src/jak1/engine/common-obs/process-taskable.gc +++ b/goal_src/jak1/engine/common-obs/process-taskable.gc @@ -56,7 +56,7 @@ (set-width! message-font (- 512 (-> this x-position))) (set-height! message-font 40) (set-scale! message-font 0.9) - (set! (-> message-font flags) (font-flags shadow kerning middle-vert large)) + (set-flags! message-font (font-flags shadow kerning middle-vert large)) (print-game-text (-> this message) message-font #f 128 22))) ;; og:preserve-this PAL patch here (cond @@ -74,7 +74,7 @@ (font-flags shadow kerning)))) (let ((v1-15 response-font)) (set! (-> v1-15 width) (the float 400))) (let ((v1-16 response-font)) (set! (-> v1-16 height) (the float 100))) - (set! (-> response-font flags) (font-flags shadow kerning large)) + (set-flags! response-font (font-flags shadow kerning large)) (print-game-text *temp-string* response-font #f 128 22)))) (else (let ((response-font (new 'stack @@ -87,7 +87,7 @@ (font-flags shadow kerning)))) (let ((v1-22 response-font)) (set! (-> v1-22 width) (the float 400))) (let ((v1-23 response-font)) (set! (-> v1-23 height) (the float 100))) - (set! (-> response-font flags) (font-flags shadow kerning large)) + (set-flags! response-font (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id confirm) #f) response-font #f 128 22)))) (cond ((!= (-> this decision) 'undecided)) @@ -554,7 +554,7 @@ (logclear! (-> self skel status) (janim-status blerc spool)) (logior! (-> self mask) (process-mask actor-pause)) (let ((entity-transform (-> self entity extra trans))) - (if entity-transform (set! (-> self root trans quad) (-> entity-transform quad)))) + (if entity-transform (vector-copy! (-> self root trans) entity-transform))) (ja-channel-set! 0)) :trans (behavior () @@ -643,7 +643,7 @@ (set-width! gp-1 440) (set-height! gp-1 60) (set-scale! gp-1 0.9) - (set! (-> gp-1 flags) (font-flags shadow kerning middle-vert large)) + (set-flags! gp-1 (font-flags shadow kerning middle-vert large)) (print-game-text (lookup-text! *common-text* (-> self talk-message) #f) gp-1 #f 128 22)) (when (and (cpad-pressed? 0 circle) (process-grab? *target*)) (logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons circle)) @@ -837,7 +837,7 @@ (when (not parent) (format #t "ERROR: othercam parent invalid~%") (deactivate self)) - (set! (-> *camera-other-root* quad) (-> (the-as process-taskable parent) root trans quad)) + (vector-copy! *camera-other-root* (-> (the-as process-taskable parent) root trans)) (let ((joint-transform (-> (the-as process-taskable parent) node-list data (-> self cam-joint-index) bone transform)) (joint-scale (-> (the-as process-taskable parent) node-list data (-> self cam-joint-index) bone scale)) (camera-forward (new 'stack-no-clear 'vector)) @@ -848,10 +848,10 @@ (when frame-ready? (when (not (-> self had-valid-frame)) (set! (-> self had-valid-frame) #t) - (set! (-> self old-pos quad) (-> camera-position quad)) - (set! (-> self old-mat-z quad) (-> camera-forward quad))) + (vector-copy! (-> self old-pos) camera-position) + (vector-copy! (-> self old-mat-z) camera-forward)) (when #t - (set! (-> *camera-other-trans* quad) (-> camera-position quad)) + (vector-copy! *camera-other-trans* camera-position) (vector-normalize-copy! (-> *camera-other-matrix* vector 0) (-> joint-transform vector 0) -1.0) (set! (-> *camera-other-matrix* vector 0 w) 0.0) (vector-normalize-copy! (-> *camera-other-matrix* vector 1) (-> joint-transform vector 1) 1.0) @@ -861,8 +861,8 @@ (vector-reset! (-> *camera-other-matrix* vector 3)) (othercam-calc (-> joint-scale x))) (set! *camera-look-through-other* 2) - (set! (-> self old-pos quad) (-> camera-position quad)) - (set! (-> self old-mat-z quad) (-> camera-forward quad))))) + (vector-copy! (-> self old-pos) camera-position) + (vector-copy! (-> self old-mat-z) camera-forward)))) (suspend) (let ((parent (-> self hand process 0))) (when (or (-> self die?) (and (not (-> self survive-anim-end?)) (ja-anim-done? parent))) diff --git a/goal_src/jak1/engine/common-obs/rigid-body.gc b/goal_src/jak1/engine/common-obs/rigid-body.gc index 1ef9e27734..24a90af03a 100644 --- a/goal_src/jak1/engine/common-obs/rigid-body.gc +++ b/goal_src/jak1/engine/common-obs/rigid-body.gc @@ -11,15 +11,15 @@ (defmethod clear-force-torque! ((this rigid-body)) "Clear the accumulated world-space force and torque for the next simulation step." - (set! (-> this force quad) (-> *null-vector* quad)) - (set! (-> this torque quad) (-> *null-vector* quad)) + (vector-copy! (-> this force) *null-vector*) + (vector-copy! (-> this torque) *null-vector*) 0 (none)) (defmethod clear-momentum! ((this rigid-body)) "Clear both linear and angular momentum." - (set! (-> this lin-momentum quad) (-> *null-vector* quad)) - (set! (-> this ang-momentum quad) (-> *null-vector* quad)) + (vector-copy! (-> this lin-momentum) *null-vector*) + (vector-copy! (-> this ang-momentum) *null-vector*) 0 (none)) @@ -43,8 +43,8 @@ (set! (-> this lin-momentum-damping-factor) linear-damping) (set! (-> this ang-momentum-damping-factor) angular-damping) (update-matrix! this) - (set! (-> this lin-velocity quad) (-> *null-vector* quad)) - (set! (-> this ang-velocity quad) (-> *null-vector* quad)) + (vector-copy! (-> this lin-velocity) *null-vector*) + (vector-copy! (-> this ang-velocity) *null-vector*) (set! (-> this inv-i-world vector 0 quad) (the-as uint128 0)) (set! (-> this inv-i-world vector 1 quad) (the-as uint128 0)) (set! (-> this inv-i-world vector 2 quad) (the-as uint128 0)) @@ -367,10 +367,10 @@ "Detect riders, sample player velocity, accumulate elapsed game time, and run fixed physics steps until less than half a step remains. Clear the per-frame contact marker afterward." (if (-> this info platform) (detect-riders! (-> this root-overlay))) - (set! (-> this player-velocity-prev quad) (-> this player-velocity quad)) + (vector-copy! (-> this player-velocity-prev) (-> this player-velocity)) (if *target* - (set! (-> this player-velocity quad) (-> *target* control transv quad)) - (set! (-> this player-velocity quad) (-> *null-vector* quad))) + (vector-copy! (-> this player-velocity) (-> *target* control transv)) + (vector-copy! (-> this player-velocity) *null-vector*)) (+! (-> this sim-time-remaining) (* 0.0033333334 (the float (- (current-time) (-> *display* old-base-frame-counter))))) (let ((fixed-step (* DISPLAY_FPS_RATIO 0.016666668)) ;; og:preserve-this changed for high fps (simulation-time (* 0.0033333334 (the float (logand #xffffff (current-time)))))) @@ -394,7 +394,7 @@ (bonk-drawable (if (and (nonzero? bonk-source) (type-type? (-> bonk-source type) process-drawable)) bonk-source))) (when bonk-drawable (set! (-> self player-impulse) #t) - (set! (-> self player-force-position quad) (-> (the-as process-drawable bonk-drawable) root trans quad)) + (vector-copy! (-> self player-force-position) (-> (the-as process-drawable bonk-drawable) root trans)) (let ((bonk-force (fmin (* 0.00012207031 (the-as float (-> block param 1)) (-> self info player-bonk-factor) (-> self info player-weight)) (-> self info player-force-clamp)))) (vector-float*! (-> self player-force) *y-vector* (- bonk-force))))))) @@ -410,7 +410,7 @@ (flop-drawable (if (and (nonzero? flop-source) (type-type? (-> flop-source type) process-drawable)) flop-source))) (when flop-drawable (set! (-> self player-impulse) #t) - (set! (-> self player-force-position quad) (-> (the-as process-drawable flop-drawable) root trans quad)) + (vector-copy! (-> self player-force-position) (-> (the-as process-drawable flop-drawable) root trans)) (let ((flop-force (fmin (* 16.0 (-> self info player-weight) (-> self info player-dive-factor)) (-> self info player-force-clamp)))) (vector-float*! (-> self player-force) *y-vector* (- flop-force))))))) ((= (-> block param 1) 'explode) @@ -418,7 +418,7 @@ (explosion-drawable (if (and (nonzero? explosion-source) (type-type? (-> explosion-source type) process-drawable)) explosion-source))) (when explosion-drawable (set! (-> self player-impulse) #t) - (set! (-> self player-force-position quad) (-> (the-as process-drawable explosion-drawable) root trans quad)) + (vector-copy! (-> self player-force-position) (-> (the-as process-drawable explosion-drawable) root trans)) (vector-! (-> self player-force) (-> self rbody position) (-> (the-as process-drawable explosion-drawable) root trans)) (vector-normalize! (-> self player-force) (-> self info explosion-force))))) (else (the-as vector #f)))))) @@ -426,15 +426,15 @@ (let ((impulse-source source)) (when (if (and (nonzero? impulse-source) (type-type? (-> impulse-source type) process-drawable)) impulse-source) (set! (-> self player-impulse) #t) - (set! (-> self player-force-position quad) (-> self rbody position quad)) + (vector-copy! (-> self player-force-position) (-> self rbody position)) (let ((force-vector (-> self player-force))) - (set! (-> force-vector quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! force-vector (the-as vector (-> block param 0))) force-vector)))) (('edge-grabbed) (let ((edge-grab-data (-> block param 0))) (when (not (-> self player-impulse)) (set! (-> self player-contact) #t) - (set! (-> self player-force-position quad) (-> (the-as vector (+ edge-grab-data 32)) quad)) + (vector-copy! (-> self player-force-position) (the-as vector (+ edge-grab-data 32))) (vector-float*! (-> self player-force) *y-vector* (* -1.0 (-> self info player-weight)))))) (('ridden) (let ((rider-handle-reference (the-as object (-> block param 0)))) @@ -443,8 +443,8 @@ (when (and rider-process (= rider-process *target*) (!= (-> *target* control mod-surface mode) 'swim)) (when (not (-> self player-impulse)) (set! (-> self player-contact) #t) - (set! (-> self player-force-position quad) (-> (the-as process-drawable rider-process) root trans quad)) - (set! (-> self player-force quad) (-> *null-vector* quad)) + (vector-copy! (-> self player-force-position) (-> (the-as process-drawable rider-process) root trans)) + (vector-copy! (-> self player-force) *null-vector*) (vector+*! (-> self player-force) (-> self player-force) *y-vector* (* -1.0 (-> self info player-weight))))))))))) (defbehavior rigid-body-platform-post rigid-body-platform () @@ -515,9 +515,9 @@ (set! (-> this player-impulse) #f) (set! (-> this player-contact) #f) (set-time! (-> this player-bonk-timeout)) - (set! (-> this player-force quad) (-> *null-vector* quad)) - (set! (-> this player-velocity quad) (-> *null-vector* quad)) - (set! (-> this player-velocity-prev quad) (-> *null-vector* quad)) + (vector-copy! (-> this player-force) *null-vector*) + (vector-copy! (-> this player-velocity) *null-vector*) + (vector-copy! (-> this player-velocity-prev) *null-vector*) (set! (-> this water-anim) (the-as water-anim (entity-actor-lookup (-> this entity) 'water-actor 0))) 0 (none)) diff --git a/goal_src/jak1/engine/common-obs/ropebridge.gc b/goal_src/jak1/engine/common-obs/ropebridge.gc index 36d3add9f8..45b44e4294 100644 --- a/goal_src/jak1/engine/common-obs/ropebridge.gc +++ b/goal_src/jak1/engine/common-obs/ropebridge.gc @@ -642,7 +642,7 @@ "Clear the per-step external force on every spring point." (let ((spring-point (the-as ropebridge-spring-point (-> this spring-point)))) (countdown (i (-> this tuning num-spring-points)) - (set! (-> spring-point extra-force quad) (the-as uint128 0)) + (vector-zero! (-> spring-point extra-force)) (nop!) (nop!) (&+! spring-point 48))) diff --git a/goal_src/jak1/engine/common-obs/sharkey.gc b/goal_src/jak1/engine/common-obs/sharkey.gc index 0bb6219fd8..5de9b5ec20 100644 --- a/goal_src/jak1/engine/common-obs/sharkey.gc +++ b/goal_src/jak1/engine/common-obs/sharkey.gc @@ -125,7 +125,7 @@ nav-enemy-default-event-handler (let ((current-y (-> this collide-info trans y))) (when (or (and (< water-height current-y) (>= water-height (-> this last-y))) (and (>= water-height current-y) (< water-height (-> this last-y)))) - (set! (-> splash-position quad) (-> this collide-info trans quad)) + (vector-copy! splash-position (-> this collide-info trans)) (set! (-> splash-position y) water-height) (create-splash (-> this water) 1.0 splash-position 1 (-> this collide-info transv))) (set! (-> this last-y) current-y))) @@ -143,13 +143,13 @@ nav-enemy-default-event-handler (defun sharkey-get-player-position ((destination vector)) "Copy the player target point at joint slot 5 into destination." - (set! (-> destination quad) (-> (target-pos 5) quad)) + (vector-copy! destination (target-pos 5)) 0 (none)) (defbehavior sharkey-reset-position sharkey () "Restore the Sharkey's position from its entity transform." - (set! (-> self collide-info trans quad) (-> self entity extra trans quad)) + (vector-copy! (-> self collide-info trans) (-> self entity extra trans)) 0 (none)) @@ -163,21 +163,21 @@ nav-enemy-default-event-handler (desired-spawn-position (new 'stack-no-clear 'vector))) (let ((player-position (-> *target* control trans))) (let ((best-distance 4096000.0)) - (set! (-> candidate-position quad) (-> self entity extra trans quad)) - (set! (-> closest-path-position quad) (-> self collide-info trans quad)) + (vector-copy! candidate-position (-> self entity extra trans)) + (vector-copy! closest-path-position (-> self collide-info trans)) (dotimes (i (-> self path curve num-cverts)) (eval-path-curve-div! (-> self path) candidate-position (the float i) 'interp) (let ((candidate-distance (vector-vector-xz-distance player-position candidate-position))) (when (< candidate-distance best-distance) (set! best-distance candidate-distance) - (set! (-> closest-path-position quad) (-> candidate-position quad)))))) + (vector-copy! closest-path-position candidate-position))))) (vector-! (-> self dir) player-position closest-path-position) (vector-normalize! (-> self dir) 1.0) (vector+*! desired-spawn-position player-position (-> self dir) (- (-> self spawn-distance)))) (project-onto-nav-mesh (-> self nav) desired-spawn-position desired-spawn-position) (set! (-> desired-spawn-position y) (-> self y-min)) - (set! (-> self spawn-point quad) (-> desired-spawn-position quad))) - (set! (-> self collide-info trans quad) (-> self spawn-point quad)) + (vector-copy! (-> self spawn-point) desired-spawn-position)) + (vector-copy! (-> self collide-info trans) (-> self spawn-point)) (forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*) (set! (-> self momentum-speed) 0.0)) @@ -284,7 +284,7 @@ nav-enemy-default-event-handler (current-time) (sound-play "bigshark-bite") (set-time! (-> self state-time)) - (set! (-> attack-start-position quad) (-> self collide-info trans quad)) + (vector-copy! attack-start-position (-> self collide-info trans)) (ja-channel-push! 1 (seconds 0.1)) (ja-play :group! sharkey-chomp-ja @@ -515,7 +515,7 @@ nav-enemy-default-event-handler (set! (-> this water flags) (water-flag active part-rings part-water)) (set! (-> this water height) (res-lump-float (-> this entity) 'water-height)) (set! (-> this water ripple-size) 20480.0) - (set! (-> this spawn-point quad) (-> this collide-info trans quad)) + (vector-copy! (-> this spawn-point) (-> this collide-info trans)) (set! (-> this collide-info nav-radius) 8192.0) (set! (-> this nav nearest-y-threshold) 4096000.0) (set! (-> this y-max) (- (-> this water height) (* 2048.0 (-> this scale)))) diff --git a/goal_src/jak1/engine/common-obs/voicebox.gc b/goal_src/jak1/engine/common-obs/voicebox.gc index 6eb8119e0e..f96dcddf52 100644 --- a/goal_src/jak1/engine/common-obs/voicebox.gc +++ b/goal_src/jak1/engine/common-obs/voicebox.gc @@ -45,8 +45,8 @@ the model from full size to zero as it enters the backpack." (let ((camera-position (new 'stack-no-clear 'vector)) (target-position (new 'stack-no-clear 'vector))) - (set! (-> camera-position quad) (-> self parent-override 0 trans quad)) - (set! (-> target-position quad) (-> (target-pos (joint-node-index eichar-lod0-jg packStrapMid)) quad)) + (vector-copy! camera-position (-> self parent-override 0 trans)) + (vector-copy! target-position (target-pos (joint-node-index eichar-lod0-jg packStrapMid))) (when *target* (let ((target-forward (vector-z-quaternion! (new-stack-vector0) (-> *target* control quat-for-control)))) ;; The offset vanishes at both endpoints: blend ignores the target position at zero, and the @@ -166,8 +166,8 @@ speaker skeleton with blend at the target-side endpoint, and enter the appearance state." (set! (-> self root) (new 'process 'trsqv)) (set! (-> self hint) hint) - (set! (-> self root trans quad) (-> position quad)) - (set! (-> self base-trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) + (vector-copy! (-> self base-trans) position) (initialize-skeleton self *voicebox-sg* '()) (set! (-> self blend) 1.0) (go-virtual enter) diff --git a/goal_src/jak1/engine/common-obs/water-anim.gc b/goal_src/jak1/engine/common-obs/water-anim.gc index 1bb49f8f85..5a1dd54b9f 100644 --- a/goal_src/jak1/engine/common-obs/water-anim.gc +++ b/goal_src/jak1/engine/common-obs/water-anim.gc @@ -584,7 +584,7 @@ (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) (case message (('move-to) - (set! (-> self root trans quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self root trans) (the-as vector (-> block param 0))) (set! (-> self water-height) (-> self root trans y)) (if (nonzero? (-> self sound)) (update-trans! (-> self sound) (-> self root trans))) (let ((updated-mask (logclear (-> self mask) (process-mask sleep-code)))) diff --git a/goal_src/jak1/engine/common-obs/water.gc b/goal_src/jak1/engine/common-obs/water.gc index 101b7e85ca..2831776824 100644 --- a/goal_src/jak1/engine/common-obs/water.gc +++ b/goal_src/jak1/engine/common-obs/water.gc @@ -594,11 +594,11 @@ ((begin ;; Track the root and selected top joint, retaining last frame's positions for surface ;; crossings. - (set! (-> this top 1 quad) (-> this top 0 quad)) + (vector-copy! (-> this top 1) (-> this top 0)) (vector<-cspace! (-> this top 0) (-> this process node-list data (-> this joint-index))) (+! (-> this top 0 y) (-> this top-y-offset)) - (set! (-> this bottom 1 quad) (-> this bottom 0 quad)) - (set! (-> this bottom 0 quad) (-> this process root trans quad)) + (vector-copy! (-> this bottom 1) (-> this bottom 0)) + (vector-copy! (-> this bottom 0) (-> this process root trans)) (logclear! (-> this flag) (water-flag wading swimming under-water head-under-water bouncing)) (set! (-> this bob-offset) (update! (-> this bob))) ;; Keep the raw sample for particles, but smooth the classification surface while the @@ -619,7 +619,7 @@ (set! (-> this ocean-offset) (lerp (-> this ocean-offset) (-> this real-ocean-offset) 0.2))) ;; TODO: ripple-position is prepared here but not consumed. (let ((ripple-position (new 'stack-no-clear 'vector))) - (set! (-> ripple-position quad) (-> this bottom 0 quad)) + (vector-copy! ripple-position (-> this bottom 0)) (set! (-> ripple-position y) ripple-height)))) (else (set! (-> this real-ocean-offset) 0.0) (set! (-> this ocean-offset) 0.0))) (if (logtest? (-> (the-as collide-shape-moving (-> this process root)) root-prim prim-core action) (collide-action racer)) @@ -639,7 +639,7 @@ (cond ((>= (-> this top 0 y) (-> this height)) (let ((surface-position (new 'stack-no-clear 'vector))) - (set! (-> surface-position quad) (-> this bottom 0 quad)) + (vector-copy! surface-position (-> this bottom 0)) (vector-xz-length (-> this process root transv)) (set! (-> surface-position y) (-> this surface-height)) (when (and (logtest? (-> this process draw status) (draw-status was-drawn)) @@ -708,7 +708,7 @@ (logtest? (-> (the-as collide-shape-moving (-> this process root)) status) (collide-status touch-surface)) (not (logtest? (water-flag jump-out) (-> this flag)))) (let ((float-position (new 'stack-no-clear 'vector))) - (set! (-> float-position quad) (-> this bottom 0 quad)) + (vector-copy! float-position (-> this bottom 0)) (set! (-> float-position y) (- (-> this height) (-> this swim-height))) (let ((floating-shape (-> this process root))) (when (and (not (logtest? (-> (the-as collide-shape-moving floating-shape) status) (collide-status touch-background))) @@ -738,7 +738,7 @@ (and (< swim-line-y (-> this bottom 0 y)) (logtest? old-flags (water-flag under-water)))) (logior! (-> this flag) (water-flag swimming)) (let ((snap-position (new 'stack-no-clear 'vector))) - (set! (-> snap-position quad) (-> this bottom 0 quad)) + (vector-copy! snap-position (-> this bottom 0)) (let ((surfacing-shape (-> this process root))) (set! (-> snap-position y) swim-line-y) (when (not (logtest? (-> (the-as collide-shape-moving surfacing-shape) root-prim prim-core action) (collide-action racer))) @@ -806,7 +806,7 @@ (when (and (< (- (-> candidate-position y) (-> this process root trans y)) (-> this drip-height)) (< (-> this height) (-> candidate-position y))) (set! (-> this drip-joint-index) candidate-joint-index) - (set! (-> this drip-old-pos quad) (-> candidate-position quad)) + (vector-copy! (-> this drip-old-pos) candidate-position) (logior! (-> this flag) (water-flag spawn-drip))))))) 0 (none))) diff --git a/goal_src/jak1/engine/debug/anim-tester.gc b/goal_src/jak1/engine/debug/anim-tester.gc index 26148f2adc..9c383305f1 100644 --- a/goal_src/jak1/engine/debug/anim-tester.gc +++ b/goal_src/jak1/engine/debug/anim-tester.gc @@ -231,24 +231,12 @@ (if (< (-> *DISP_LIST-bank* MAX_LINES) (-> ctrl numlines)) (-> *DISP_LIST-bank* MAX_LINES) (-> ctrl numlines))) ;; result unused (if (> (-> ctrl lines-to-disp) 0) (-> ctrl lines-to-disp) 1) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-sprite2d-xy dma-buff - (-> ctrl left) - (-> ctrl top) - (+ (* (-> ctrl charswide) (-> *DISP_LIST-bank* CHAR_WIDTH)) (* (-> *DISP_LIST-bank* BORDER_WIDTH) 2)) - (+ (* (+ (-> ctrl lines-to-disp) 1) (-> *DISP_LIST-bank* TV_SPACING)) (* (-> *DISP_LIST-bank* BORDER_WIDTH) 2)) - (new 'static 'rgba :a #x40)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-sprite2d-xy dma-buff + (-> ctrl left) + (-> ctrl top) + (+ (* (-> ctrl charswide) (-> *DISP_LIST-bank* CHAR_WIDTH)) (* (-> *DISP_LIST-bank* BORDER_WIDTH) 2)) + (+ (* (+ (-> ctrl lines-to-disp) 1) (-> *DISP_LIST-bank* TV_SPACING)) (* (-> *DISP_LIST-bank* BORDER_WIDTH) 2)) + (new 'static 'rgba :a #x40))) (set! (-> ctrl xpos) (+ (-> ctrl left) (-> *DISP_LIST-bank* BORDER_WIDTH))) (set! (-> ctrl ypos) (+ (-> ctrl top) (-> *DISP_LIST-bank* BORDER_HEIGHT))) ((-> ctrl listfunc) (list-control-cmd draw-title) ctrl) @@ -312,24 +300,12 @@ (+! (-> ctrl the-index) 1) (let ((node (-> ctrl the-node))) "return the next node in the list" (set! (-> ctrl the-node) (-> node next))))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "**NONE**" - dma-buff - (+ (-> ctrl left) (-> *DISP_LIST-bank* BORDER_WIDTH)) - (+ (-> ctrl top) (-> *DISP_LIST-bank* BORDER_HEIGHT) (-> *DISP_LIST-bank* TV_SPACING)) - (font-color menu) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "**NONE**" + dma-buff + (+ (-> ctrl left) (-> *DISP_LIST-bank* BORDER_WIDTH)) + (+ (-> ctrl top) (-> *DISP_LIST-bank* BORDER_HEIGHT) (-> *DISP_LIST-bank* TV_SPACING)) + (font-color menu) + (font-flags shadow kerning))))) (none)) ;; Where each of the four lists sits, and how narrow it is allowed to get. X, Y @@ -694,27 +670,15 @@ ;; this function does not work (return (the pointer #f)) (local-vars (fmt-func (function _varargs_ object))) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (cond - ((= frame -1.0) - (let ((draw-adv draw-string-adv)) (format (clear *temp-string*) "~Smin" prefix) (draw-adv *temp-string* dma-buff ctx))) - ((= frame -2.0) - (let ((draw-adv draw-string-adv)) (format (clear *temp-string*) "~Smax" prefix) (draw-adv *temp-string* dma-buff ctx))) - (else - (let ((draw-adv draw-string-adv)) - (format (clear *temp-string*) "~S~3,,0f" prefix (+ frame artist-base)) - (draw-adv *temp-string* dma-buff ctx)))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (cond + ((= frame -1.0) + (let ((draw-adv draw-string-adv)) (format (clear *temp-string*) "~Smin" prefix) (draw-adv *temp-string* dma-buff ctx))) + ((= frame -2.0) + (let ((draw-adv draw-string-adv)) (format (clear *temp-string*) "~Smax" prefix) (draw-adv *temp-string* dma-buff ctx))) + (else + (let ((draw-adv draw-string-adv)) + (format (clear *temp-string*) "~S~3,,0f" prefix (+ frame artist-base)) + (draw-adv *temp-string* dma-buff ctx)))))) (defbehavior anim-tester-standard-event-handler anim-tester ((proc process) (argc int) (message symbol) (block event-message-block)) "Handle the debug menu's requests. @@ -753,30 +717,18 @@ (cond ;; (list-control-cmd draw-line) ((zero? op) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (let ((draw-xy draw-string-xy)) - (format (clear *temp-string*) - "~S~S~S" - (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") - (if (logtest? (-> obj flags) (anim-test-obj-flags edited)) "*" " ") - (-> obj privname)) - (draw-xy *temp-string* - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) - (font-flags shadow kerning))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-xy draw-string-xy)) + (format (clear *temp-string*) + "~S~S~S" + (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") + (if (logtest? (-> obj flags) (anim-test-obj-flags edited)) "*" " ") + (-> obj privname)) + (draw-xy *temp-string* + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) + (font-flags shadow kerning))))) ((= op (list-control-cmd visible?)) (return #t)) ((= op (list-control-cmd input)) (cond @@ -805,24 +757,12 @@ (else (-> *ANIM_TESTER-bank* OBJECT_LIST_MIN_WIDTH)))) (set! (-> ctrl return-int) width))) ((= op (list-control-cmd draw-title)) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "----pick-object---" - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (font-color menu) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "----pick-object---" + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (font-color menu) + (font-flags shadow kerning)))))) #f) (defun anim-test-anim-list-handler ((cmd list-control-cmd) (ctrl list-control)) @@ -836,26 +776,14 @@ (cond ;; (list-control-cmd draw-line) ((zero? cmd) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (let ((draw-xy draw-string-xy)) - (format (clear *temp-string*) "~S~S" (if (= (-> ctrl the-index) (-> ctrl highlight-index)) "> " " ") (-> seq privname)) - (draw-xy *temp-string* - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) - (font-flags shadow kerning))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-xy draw-string-xy)) + (format (clear *temp-string*) "~S~S" (if (= (-> ctrl the-index) (-> ctrl highlight-index)) "> " " ") (-> seq privname)) + (draw-xy *temp-string* + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) + (font-flags shadow kerning))))) ((= cmd (list-control-cmd visible?)) (return (not (logtest? (-> seq flags) (anim-test-seq-flags sequence))))) ((= cmd (list-control-cmd input)) (cond @@ -910,24 +838,12 @@ (else (-> *ANIM_TESTER-bank* ANIM_LIST_MIN_WIDTH)))) (set! (-> ctrl return-int) width))) ((= cmd (list-control-cmd draw-title)) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "----pick-joint-anim----" - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (font-color menu) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "----pick-joint-anim----" + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (font-color menu) + (font-flags shadow kerning)))))) #f) (defun anim-test-sequence-list-handler ((cmd list-control-cmd) (ctrl list-control)) @@ -939,30 +855,18 @@ (cond ;; (list-control-cmd draw-line) ((zero? cmd) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (let ((draw-xy draw-string-xy)) - (format (clear *temp-string*) - "~S~S~S" - (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") - (if (logtest? (-> seq flags) (anim-test-seq-flags from-file)) "*" " ") - (-> seq privname)) - (draw-xy *temp-string* - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) - (font-flags shadow kerning))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-xy draw-string-xy)) + (format (clear *temp-string*) + "~S~S~S" + (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") + (if (logtest? (-> seq flags) (anim-test-seq-flags from-file)) "*" " ") + (-> seq privname)) + (draw-xy *temp-string* + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) + (font-flags shadow kerning))))) ((= cmd (list-control-cmd visible?)) (return (logtest? (-> seq flags) (anim-test-seq-flags sequence)))) ((= cmd (list-control-cmd input)) (cond @@ -1014,24 +918,12 @@ (else (-> *ANIM_TESTER-bank* PICK_LIST_MIN_WIDTH)))) (set! (-> ctrl return-int) width))) ((= cmd (list-control-cmd draw-title)) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "----pick-sequence---" - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (font-color menu) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "----pick-sequence---" + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (font-color menu) + (font-flags shadow kerning)))))) #f) ;; Where each editor column starts and how wide it is, in characters. The first @@ -1165,86 +1057,60 @@ (bucket-id debug) packet-start (the-as (pointer dma-tag) packet-end)))))) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (let ((draw-xy draw-string-xy)) - (let ((fmt format)) - (fmt (clear *temp-string*) - "~S~S~-27S" - (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") - (if (= (-> ctrl the-index) (-> seq playing-item)) "*" " ") - (-> item privname))) - (draw-xy *temp-string* - dma-buff - (-> ctrl xpos) - (-> ctrl ypos) - (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) - (font-flags shadow kerning))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-xy draw-string-xy)) + (let ((fmt format)) + (fmt (clear *temp-string*) + "~S~S~-27S" + (if (= (-> ctrl the-index) (-> ctrl highlight-index)) ">" " ") + (if (= (-> ctrl the-index) (-> seq playing-item)) "*" " ") + (-> item privname))) + (draw-xy *temp-string* + dma-buff + (-> ctrl xpos) + (-> ctrl ypos) + (if (= (-> ctrl the-index) (-> ctrl current-index)) (font-color menu-flag-on) (font-color menu)) + (font-flags shadow kerning)))) (when (not picking?) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (when (not (logtest? (-> item flags) (anim-test-item-flags end))) - (set-origin! font-ctx - (+ (-> ctrl xpos) (* (-> *ANIM_TESTER-bank* EDIT_STATS_X) (-> *DISP_LIST-bank* CHAR_WIDTH))) - (-> ctrl ypos)) - (cond - ((and (< (-> item speed) 0) (< -100 (-> item speed))) - (let ((draw-adv draw-string-adv)) - (let ((fmt format) - (str (clear *temp-string*)) - (fmt-str "-0.~1d") - (speed (abs (-> item speed)))) - (fmt str fmt-str (/ (mod speed 100) 10))) - (draw-adv *temp-string* dma-buff font-ctx))) - (else - (let ((draw-adv draw-string-adv)) - (let ((fmt format) - (str (clear *temp-string*)) - (fmt-str "~2d.~1d") - (whole-speed (/ (-> item speed) 100)) - (speed (abs (-> item speed)))) - (fmt str fmt-str whole-speed (/ (mod speed 100) 10))) - (draw-adv *temp-string* dma-buff font-ctx)))) - (let ((draw-adv draw-string-adv)) - (format (clear *temp-string*) " ~4d" (-> item blend)) - (draw-adv *temp-string* dma-buff font-ctx)) - (anim-tester-disp-frame-num " " (-> item first-frame) (-> item artist-base) font-ctx) - (anim-tester-disp-frame-num " " (-> item last-frame) (-> item artist-base) font-ctx) - (let ((draw-adv draw-string-adv)) - (format (clear *temp-string*) - " ~S~S~S~S" - (if (logtest? (-> item flags) (anim-test-item-flags wait-for-blend)) "B" "-") - "-" - "-" - "-") - (draw-adv *temp-string* dma-buff font-ctx))) - (let* ((field-left (-> anim-test-field-highlight-lw 9 left)) - (ctx font-ctx) - (x (+ (-> ctrl xpos) (* field-left (-> *DISP_LIST-bank* CHAR_WIDTH)))) - (y (-> ctrl ypos))) - (set! (-> ctx origin x) (the float x)) - (set! (-> ctx origin y) (the float y))) - (draw-string-adv "MID" dma-buff font-ctx) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (when (not (logtest? (-> item flags) (anim-test-item-flags end))) + (set-origin! font-ctx + (+ (-> ctrl xpos) (* (-> *ANIM_TESTER-bank* EDIT_STATS_X) (-> *DISP_LIST-bank* CHAR_WIDTH))) + (-> ctrl ypos)) + (cond + ((and (< (-> item speed) 0) (< -100 (-> item speed))) + (let ((draw-adv draw-string-adv)) + (let ((fmt format) + (str (clear *temp-string*)) + (fmt-str "-0.~1d") + (speed (abs (-> item speed)))) + (fmt str fmt-str (/ (mod speed 100) 10))) + (draw-adv *temp-string* dma-buff font-ctx))) + (else + (let ((draw-adv draw-string-adv)) + (let ((fmt format) + (str (clear *temp-string*)) + (fmt-str "~2d.~1d") + (whole-speed (/ (-> item speed) 100)) + (speed (abs (-> item speed)))) + (fmt str fmt-str whole-speed (/ (mod speed 100) 10))) + (draw-adv *temp-string* dma-buff font-ctx)))) + (let ((draw-adv draw-string-adv)) + (format (clear *temp-string*) " ~4d" (-> item blend)) + (draw-adv *temp-string* dma-buff font-ctx)) + (anim-tester-disp-frame-num " " (-> item first-frame) (-> item artist-base) font-ctx) + (anim-tester-disp-frame-num " " (-> item last-frame) (-> item artist-base) font-ctx) + (let ((draw-adv draw-string-adv)) + (format (clear *temp-string*) + " ~S~S~S~S" + (if (logtest? (-> item flags) (anim-test-item-flags wait-for-blend)) "B" "-") + "-" + "-" + "-") + (draw-adv *temp-string* dma-buff font-ctx))) (let* ((field-left (-> anim-test-field-highlight-lw 9 left)) + (ctx font-ctx) + (x (+ (-> ctrl xpos) (* field-left (-> *DISP_LIST-bank* CHAR_WIDTH)))) + (y (-> ctrl ypos))) + (set! (-> ctx origin x) (the float x)) + (set! (-> ctx origin y) (the float y))) (draw-string-adv "MID" dma-buff font-ctx))))) ((= cmd (list-control-cmd visible?)) (return #t)) ((= cmd (list-control-cmd input)) (cond @@ -1397,42 +1263,18 @@ 0))))))))))))) ((= cmd (list-control-cmd measure)) (set! (-> ctrl return-int) (-> *ANIM_TESTER-bank* EDIT_LIST_MIN_WIDTH))) ((= cmd (list-control-cmd draw-title)) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (let ((draw-xy draw-string-xy)) - (format (clear *temp-string*) "--Seq--(~-17S)--" (-> seq privname)) - (draw-xy *temp-string* dma-buff (-> ctrl xpos) (-> ctrl ypos) (font-color menu) (font-flags shadow kerning))) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-xy draw-string-xy)) + (format (clear *temp-string*) "--Seq--(~-17S)--" (-> seq privname)) + (draw-xy *temp-string* dma-buff (-> ctrl xpos) (-> ctrl ypos) (font-color menu) (font-flags shadow kerning)))) (cond (picking? (display-list-control (-> *anim-tester* 0 pick-con))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "-spd-blnd-1st-lst-flgs-mov-" - dma-buff - (+ (-> ctrl xpos) (* (-> *ANIM_TESTER-bank* EDIT_STATS_X) (-> *DISP_LIST-bank* CHAR_WIDTH))) - (-> ctrl ypos) - (font-color menu) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end))))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "-spd-blnd-1st-lst-flgs-mov-" + dma-buff + (+ (-> ctrl xpos) (* (-> *ANIM_TESTER-bank* EDIT_STATS_X) (-> *DISP_LIST-bank* CHAR_WIDTH))) + (-> ctrl ypos) + (font-color menu) + (font-flags shadow kerning)))))))) #f) (defbehavior anim-tester-interface anim-tester () @@ -1457,24 +1299,12 @@ (set! (-> obj anim-index) (-> obj list-con current-index)) (set! (-> obj anim-hindex) (-> obj list-con highlight-index))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "ERROR: current object not found" - dma-buff - (-> *ANIM_TESTER-bank* ANIM_LIST_X) - (-> *ANIM_TESTER-bank* ANIM_LIST_Y) - (font-color menu-func-bad) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "ERROR: current object not found" + dma-buff + (-> *ANIM_TESTER-bank* ANIM_LIST_X) + (-> *ANIM_TESTER-bank* ANIM_LIST_Y) + (font-color menu-func-bad) + (font-flags shadow kerning))))))) ((= mode (anim-tester-edit-mode pick-sequence)) (let ((obj (the-as anim-test-obj (glst-find-node-by-name (-> self obj-list) (-> self current-obj))))) (cond @@ -1486,24 +1316,12 @@ (set! (-> obj seq-index) (-> obj list-con current-index)) (set! (-> obj seq-hindex) (-> obj list-con highlight-index))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "ERROR: current object not found" - dma-buff - (-> *ANIM_TESTER-bank* ANIM_LIST_X) - (-> *ANIM_TESTER-bank* ANIM_LIST_Y) - (font-color menu-func-bad) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "ERROR: current object not found" + dma-buff + (-> *ANIM_TESTER-bank* ANIM_LIST_X) + (-> *ANIM_TESTER-bank* ANIM_LIST_Y) + (font-color menu-func-bad) + (font-flags shadow kerning))))))) ((= mode (anim-tester-edit-mode edit-sequence)) (let ((obj (the-as anim-test-obj (glst-find-node-by-name (-> self obj-list) (-> self current-obj))))) (cond @@ -1512,43 +1330,19 @@ (cond (seq (display-list-control (-> seq list-con))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "ERROR: current sequence not found" - dma-buff - (-> *ANIM_TESTER-bank* EDIT_LIST_X) - (-> *ANIM_TESTER-bank* EDIT_LIST_Y) - (font-color menu-func-bad) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "ERROR: current sequence not found" + dma-buff + (-> *ANIM_TESTER-bank* EDIT_LIST_X) + (-> *ANIM_TESTER-bank* EDIT_LIST_Y) + (font-color menu-func-bad) + (font-flags shadow kerning))))))) (else - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-string-xy "ERROR: current object not found" - dma-buff - (-> *ANIM_TESTER-bank* EDIT_LIST_X) - (-> *ANIM_TESTER-bank* EDIT_LIST_Y) - (font-color menu-func-bad) - (font-flags shadow kerning)) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - packet-start - (the-as (pointer dma-tag) packet-end)))))))))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy "ERROR: current object not found" + dma-buff + (-> *ANIM_TESTER-bank* EDIT_LIST_X) + (-> *ANIM_TESTER-bank* EDIT_LIST_Y) + (font-color menu-func-bad) + (font-flags shadow kerning))))))))) (set! (-> self old-mode) (-> self edit-mode)) (none)) diff --git a/goal_src/jak1/engine/debug/debug.gc b/goal_src/jak1/engine/debug/debug.gc index ebe56d9d13..674fff9284 100644 --- a/goal_src/jak1/engine/debug/debug.gc +++ b/goal_src/jak1/engine/debug/debug.gc @@ -298,8 +298,8 @@ (let ((line (get-debug-line))) (when line (set! (-> line bucket) bucket) - (set! (-> line v1 quad) (-> p0 quad)) - (set! (-> line v2 quad) (-> p1 quad)) + (vector-copy! (-> line v1) p0) + (vector-copy! (-> line v2) p1) (set! (-> line color) color) (set! (-> line color2) color2) (set! (-> line mode) mode)))) @@ -403,7 +403,7 @@ (when buffered-text (set! (-> buffered-text flags) 0) (set! (-> buffered-text bucket) bucket) - (set! (-> buffered-text pos quad) (-> location quad)) + (vector-copy! (-> buffered-text pos) location) (cond (offset (set! (-> buffered-text offset x) (-> offset x)) (set! (-> buffered-text offset y) (-> offset y))) (else (set! (-> buffered-text offset x) 0) (set! (-> buffered-text offset y) 0) 0)) @@ -653,20 +653,7 @@ "Draw a 255-pixel background bar and a ten-pixel-high colored fill at screen position x,y. The fill width is 255 times fraction." (if (not enable-draw) (return #f)) - (let* ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) - (packet-start (-> dma-buff base))) - (draw-sprite2d-xy dma-buff x y 255 14 (new 'static 'rgba :a #x40)) - (draw-sprite2d-xy dma-buff x (+ y 2) (the int (* 255.0 fraction)) 10 color) - (let ((packet-end (-> dma-buff base))) - (let ((packet (the-as dma-packet (-> dma-buff base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> dma-buff base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - bucket - packet-start - (the-as (pointer dma-tag) packet-end)))) + (with-dma-buffer-add-bucket ((dma-buff (-> *display* frames (-> *display* on-screen) frame debug-buf)) bucket) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-sprite2d-xy dma-buff x y 255 14 (new 'static 'rgba :a #x40)) (draw-sprite2d-xy dma-buff x (+ y 2) (the int (* 255.0 fraction)) 10 color)) #f) (defun-debug debug-pad-display ((pad cpad-info)) @@ -801,7 +788,7 @@ (if (and draw-enabled (not (-> history points))) (set! (-> history points) (the-as (inline-array vector) (malloc 'debug (* (-> history num-points) 16))))) (when (-> history points) - (set! (-> history points (-> history h-first) quad) (-> position quad)) + (vector-copy! (-> history points (-> history h-first)) position) (+! (-> history h-first) 1) (when (>= (-> history h-first) (-> history num-points)) (set! (-> history h-first) 0) diff --git a/goal_src/jak1/engine/debug/default-menu.gc b/goal_src/jak1/engine/debug/default-menu.gc index 0f9c4044ab..ee8309cd8d 100644 --- a/goal_src/jak1/engine/debug/default-menu.gc +++ b/goal_src/jak1/engine/debug/default-menu.gc @@ -2714,7 +2714,7 @@ ,(lambda () (when *target* (position-in-front-of-camera! (target-pos 0) (meters 10) (meters 1)) - (set! (-> *target* control transv quad) (the-as uint128 0)) + (vector-zero! (-> *target* control transv)) (quaternion-identity! (-> *target* control quat)) (quaternion-identity! (-> *target* control quat-for-control)) (quaternion-identity! (-> *target* control dir-targ))))) @@ -2723,7 +2723,7 @@ ,(lambda () (when *target* (set-vector! (-> *target* control trans) 0.0 (meters 40) 0.0 1.0) - (set! (-> *target* control transv quad) (the-as uint128 0)) + (vector-zero! (-> *target* control transv)) (quaternion-identity! (-> *target* control quat)) (quaternion-identity! (-> *target* control quat-for-control)) (quaternion-identity! (-> *target* control dir-targ))))) diff --git a/goal_src/jak1/engine/debug/memory-usage-h.gc b/goal_src/jak1/engine/debug/memory-usage-h.gc index f8d113c564..bc10e52e64 100644 --- a/goal_src/jak1/engine/debug/memory-usage-h.gc +++ b/goal_src/jak1/engine/debug/memory-usage-h.gc @@ -136,9 +136,9 @@ (array 81) (sprite 82) (depth-cue 83) - (debug-dma 84) - (sky-dma 85) - (pris-generic) + (debug 84) + (sky 85) + (pris-generic 86) (4k-dead-pool 87) (8k-dead-pool 88) (16k-dead-pool 89) @@ -166,4 +166,29 @@ (defmacro mem-usage-id-int (kind) `(the int (mem-usage-id ,kind))) -(defun-extern mem-size basic symbol int int) +;; Record one aligned allocation in a named memory-usage category. This variant embeds the category +;; name as a static string, matching the common form of the original macro. +(defmacro mem-usage-add! (usage kind count size) + (with-gensyms (bytes) + `(begin + (set! (-> ,usage length) (max (+ 1 (mem-usage-id-int ,kind)) (-> ,usage length))) + (set! (-> ,usage data (mem-usage-id ,kind) name) ,(symbol->string kind)) + (+! (-> ,usage data (mem-usage-id ,kind) count) ,count) + (let ((,bytes ,size)) + (+! (-> ,usage data (mem-usage-id ,kind) used) ,bytes) + (+! (-> ,usage data (mem-usage-id ,kind) total) (align16 ,bytes)))))) + +;; The drawable-container methods use the symbol's runtime string instead. Keep that distinct from +;; the static-string variant above: the text is the same, but the original expression and resulting +;; string object are not. +(defmacro mem-usage-add-symbol! (usage kind count size) + (with-gensyms (bytes) + `(begin + (set! (-> ,usage length) (max (+ 1 (mem-usage-id-int ,kind)) (-> ,usage length))) + (set! (-> ,usage data (mem-usage-id ,kind) name) (symbol->string ',kind)) + (+! (-> ,usage data (mem-usage-id ,kind) count) ,count) + (let ((,bytes ,size)) + (+! (-> ,usage data (mem-usage-id ,kind) used) ,bytes) + (+! (-> ,usage data (mem-usage-id ,kind) total) (align16 ,bytes)))))) + +(defun-extern mem-size basic symbol mem-usage-flags int) diff --git a/goal_src/jak1/engine/debug/memory-usage.gc b/goal_src/jak1/engine/debug/memory-usage.gc index 81ada9662f..d41e7d6790 100644 --- a/goal_src/jak1/engine/debug/memory-usage.gc +++ b/goal_src/jak1/engine/debug/memory-usage.gc @@ -24,7 +24,7 @@ (format #t "-------------------------------------------------------------~%") this) -(defmethod mem-usage ((this object) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this object) (usage memory-usage-block) (flags mem-usage-flags)) "Warn when a nonfalse object reaches this generic fallback. Leave usage unchanged and return the object." (if this (format #t "WARNING: mem-usage called on object, probably not what was wanted for ~A~%" this)) this) @@ -42,7 +42,7 @@ (set! (-> this data i count) 0)) this) -(defun mem-size ((value basic) (print? symbol) (flags int)) +(defun mem-size ((value basic) (print? symbol) (flags mem-usage-flags)) "Collect value's memory categories using flags, optionally print the complete category table, and return the sum of aligned total bytes." (let ((usage (new 'stack 'memory-usage-block))) @@ -56,11 +56,11 @@ (if (zero? (-> this mem-usage-block)) (set! (-> this mem-usage-block) (new 'debug 'memory-usage-block))) (set! force? (or (zero? (-> this mem-usage-block length)) force?)) (when force? - (mem-usage this (reset! (-> this mem-usage-block)) 0) + (mem-usage this (reset! (-> this mem-usage-block)) (mem-usage-flags)) (set! (-> this mem-usage) (calculate-total (-> this mem-usage-block)))) (-> this mem-usage-block)) -(defmethod mem-usage ((this process-tree) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this process-tree) (usage memory-usage-block) (flags mem-usage-flags)) "Name and optionally count the process dead pools, then account for every active process and its heap header, thread, drawable controllers, and other major heap-owned allocations. flags bit #x20 also counts objects currently resident in the dead pools." @@ -75,7 +75,7 @@ (set! (-> usage length) (max (-> usage length) name-category))) (set! (-> usage data 93 name) "*debug-dead-pool*") (set! *temp-mem-usage* usage) - (when (logtest? flags 32) + (when (logtest? flags (mem-usage-flags include-dead-pools)) (let* ((dead-category 87) (dead-pool-list *dead-pool-list*) (dead-pool-symbol (car dead-pool-list))) @@ -106,107 +106,32 @@ (else 87)))) (+! (-> usage data pool-category count) 1) (+! (-> usage data pool-category total) (logand -16 (+ (asize-of proc) 15)))) - (set! (-> usage length) (max 95 (-> usage length))) - (set! (-> usage data 94 name) "process-active") - (+! (-> usage data 94 count) 1) - (let ((process-size (asize-of proc))) - (+! (-> usage data 94 used) process-size) - (+! (-> usage data 94 total) (logand -16 (+ process-size 15)))) - (set! (-> usage length) (max 96 (-> usage length))) - (set! (-> usage data 95 name) "heap-total") - (+! (-> usage data 95 count) 1) - (let ((heap-used (+ (the-as uint (- -4 (the-as int proc))) (the-as uint (-> proc heap-cur))))) - (+! (-> usage data 95 used) heap-used) - (+! (-> usage data 95 total) (logand -16 (+ heap-used 15)))) - (set! (-> usage length) (max 97 (-> usage length))) - (set! (-> usage data 96 name) "heap-process") - (+! (-> usage data 96 count) 1) - (let ((process-data-size (- (-> proc type size) (-> proc type heap-base)))) - (+! (-> usage data 96 used) process-data-size) - (+! (-> usage data 96 total) (logand -16 (+ process-data-size 15)))) - (set! (-> usage length) (max 98 (-> usage length))) - (set! (-> usage data 97 name) "heap-header") - (+! (-> usage data 97 count) 1) - (let ((heap-header-size (-> proc type heap-base))) - (+! (-> usage data 97 used) heap-header-size) - (+! (-> usage data 97 total) (logand -16 (+ heap-header-size 15)))) - (set! (-> usage length) (max 99 (-> usage length))) - (set! (-> usage data 98 name) "heap-thread") - (+! (-> usage data 98 count) 1) - (let ((thread-size (asize-of (-> proc main-thread)))) - (+! (-> usage data 98 used) thread-size) - (+! (-> usage data 98 total) (logand -16 (+ thread-size 15)))) + (mem-usage-add! usage process-active 1 (asize-of proc)) + (mem-usage-add! usage heap-total 1 (+ (the-as uint (- -4 (the-as int proc))) (the-as uint (-> proc heap-cur)))) + (mem-usage-add! usage heap-process 1 (- (-> proc type size) (-> proc type heap-base))) + (mem-usage-add! usage heap-header 1 (-> proc type heap-base)) + (mem-usage-add! usage heap-thread 1 (asize-of (-> proc main-thread))) (when (type-type? (-> proc type) process-drawable) (when (nonzero? (-> (the-as process-drawable proc) root)) - (set! (-> usage length) (max 100 (-> usage length))) - (set! (-> usage data 99 name) "heap-root") - (+! (-> usage data 99 count) 1) - (let ((root-size (asize-of (-> (the-as process-drawable proc) root)))) - (+! (-> usage data 99 used) root-size) - (+! (-> usage data 99 total) (logand -16 (+ root-size 15)))) + (mem-usage-add! usage heap-root 1 (asize-of (-> (the-as process-drawable proc) root))) (when (type-type? (-> (the-as process-drawable proc) root type) collide-shape) - (set! (-> usage length) (max 106 (-> usage length))) - (set! (-> usage data 105 name) "heap-collide-prim") - (+! (-> usage data 105 count) 1) - (let ((root-prim-size (asize-of (-> (the-as collide-shape (-> (the-as process-drawable proc) root)) root-prim)))) - (+! (-> usage data 105 used) root-prim-size) - (+! (-> usage data 105 total) (logand -16 (+ root-prim-size 15)))))) + (mem-usage-add! usage heap-collide-prim 1 (asize-of (-> (the-as collide-shape (-> (the-as process-drawable proc) root)) root-prim))))) (when (nonzero? (-> (the-as process-drawable proc) node-list)) - (set! (-> usage length) (max 103 (-> usage length))) - (set! (-> usage data 102 name) "heap-cspace") - (+! (-> usage data 102 count) 1) - (let ((cspace-size (asize-of (-> (the-as process-drawable proc) node-list)))) - (+! (-> usage data 102 used) cspace-size) - (+! (-> usage data 102 total) (logand -16 (+ cspace-size 15))))) + (mem-usage-add! usage heap-cspace 1 (asize-of (-> (the-as process-drawable proc) node-list)))) (when (nonzero? (-> (the-as process-drawable proc) draw)) - (set! (-> usage length) (max 101 (-> usage length))) - (set! (-> usage data 100 name) "heap-draw-control") - (+! (-> usage data 100 count) 1) - (let ((draw-control-size (asize-of (-> (the-as process-drawable proc) draw)))) - (+! (-> usage data 100 used) draw-control-size) - (+! (-> usage data 100 total) (logand -16 (+ draw-control-size 15)))) + (mem-usage-add! usage heap-draw-control 1 (asize-of (-> (the-as process-drawable proc) draw))) (when (nonzero? (-> (the-as process-drawable proc) draw skeleton)) - (set! (-> usage length) (max 104 (-> usage length))) - (set! (-> usage data 103 name) "heap-bone") - (+! (-> usage data 103 count) 1) - (let ((skeleton-size (asize-of (-> (the-as process-drawable proc) draw skeleton)))) - (+! (-> usage data 103 used) skeleton-size) - (+! (-> usage data 103 total) (logand -16 (+ skeleton-size 15)))))) + (mem-usage-add! usage heap-bone 1 (asize-of (-> (the-as process-drawable proc) draw skeleton))))) (when (nonzero? (-> (the-as process-drawable proc) skel)) - (set! (-> usage length) (max 102 (-> usage length))) - (set! (-> usage data 101 name) "heap-joint-control") - (+! (-> usage data 101 count) 1) - (let ((joint-control-size (asize-of (-> (the-as process-drawable proc) skel)))) - (+! (-> usage data 101 used) joint-control-size) - (+! (-> usage data 101 total) (logand -16 (+ joint-control-size 15))))) + (mem-usage-add! usage heap-joint-control 1 (asize-of (-> (the-as process-drawable proc) skel)))) (when (nonzero? (-> (the-as process-drawable proc) part)) - (set! (-> usage length) (max 105 (-> usage length))) - (set! (-> usage data 104 name) "heap-part") - (+! (-> usage data 104 count) 1) - (let ((particle-control-size (asize-of (-> (the-as process-drawable proc) part)))) - (+! (-> usage data 104 used) particle-control-size) - (+! (-> usage data 104 total) (logand -16 (+ particle-control-size 15))))) + (mem-usage-add! usage heap-part 1 (asize-of (-> (the-as process-drawable proc) part)))) (when (nonzero? (-> (the-as process-drawable proc) nav)) - (set! (-> usage length) (max 107 (-> usage length))) - (set! (-> usage data 106 name) "heap-misc") - (+! (-> usage data 106 count) 1) - (let ((nav-size (asize-of (-> (the-as process-drawable proc) nav)))) - (+! (-> usage data 106 used) nav-size) - (+! (-> usage data 106 total) (logand -16 (+ nav-size 15))))) + (mem-usage-add! usage heap-misc 1 (asize-of (-> (the-as process-drawable proc) nav)))) (when (nonzero? (-> (the-as process-drawable proc) path)) - (set! (-> usage length) (max 107 (-> usage length))) - (set! (-> usage data 106 name) "heap-misc") - (+! (-> usage data 106 count) 1) - (let ((path-size (asize-of (-> (the-as process-drawable proc) path)))) - (+! (-> usage data 106 used) path-size) - (+! (-> usage data 106 total) (logand -16 (+ path-size 15))))) + (mem-usage-add! usage heap-misc 1 (asize-of (-> (the-as process-drawable proc) path)))) (when (nonzero? (-> (the-as process-drawable proc) vol)) - (set! (-> usage length) (max 107 (-> usage length))) - (set! (-> usage data 106 name) "heap-misc") - (+! (-> usage data 106 count) 1) - (let ((volume-size (asize-of (-> (the-as process-drawable proc) vol)))) - (+! (-> usage data 106 used) volume-size) - (+! (-> usage data 106 total) (logand -16 (+ volume-size 15))))))) + (mem-usage-add! usage heap-misc 1 (asize-of (-> (the-as process-drawable proc) vol)))))) #t) *null-kernel-context*) this) diff --git a/goal_src/jak1/engine/debug/part-tester.gc b/goal_src/jak1/engine/debug/part-tester.gc index cbfbb44550..95c2e7b15a 100644 --- a/goal_src/jak1/engine/debug/part-tester.gc +++ b/goal_src/jak1/engine/debug/part-tester.gc @@ -51,8 +51,8 @@ (when ent (let ((proc (-> ent extra process))) (if (and proc (type-type? (-> proc type) process-drawable) (nonzero? (-> (the-as process-drawable proc) root))) - (set! (-> self root trans quad) (-> (the-as process-drawable proc) root trans quad)) - (set! (-> self root trans quad) (-> ent extra trans quad)))))) + (vector-copy! (-> self root trans) (-> (the-as process-drawable proc) root trans)) + (vector-copy! (-> self root trans) (-> ent extra trans)))))) (add-debug-x #t (bucket-id debug-no-zbuf) (-> self root trans) @@ -88,7 +88,7 @@ process-drawable because part-tester's root sits where a process-drawable's does, even though part-tester is a plain process." (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> pos quad)) + (vector-copy! (-> self root trans) pos) (set! *part-tester* (the-as part-tester (process->ppointer self))) (go part-tester-idle) (none)) diff --git a/goal_src/jak1/engine/debug/viewer.gc b/goal_src/jak1/engine/debug/viewer.gc index 8220caeea4..c886b0f7b7 100644 --- a/goal_src/jak1/engine/debug/viewer.gc +++ b/goal_src/jak1/engine/debug/viewer.gc @@ -142,7 +142,7 @@ encoded source of optional -ja-NAME and -geo-NAME selectors." (set! *viewer* self) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-identity! (-> self root quat)) (set-vector! (-> self root scale) 1.0 1.0 1.0 1.0) (actor-get-arg! viewer-ja-name "ja" art-name) diff --git a/goal_src/jak1/engine/draw/draw-node.gc b/goal_src/jak1/engine/draw/draw-node.gc index cfbb0b6025..d1b98266ea 100644 --- a/goal_src/jak1/engine/draw/draw-node.gc +++ b/goal_src/jak1/engine/draw/draw-node.gc @@ -71,15 +71,10 @@ (format #t "~T [~D] ~A~%" i (-> this data i))) this) -(defmethod mem-usage ((this drawable-inline-array-node) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-node) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this inline array's draw-node storage without counting memory owned by the nodes' children." - (set! (-> usage length) (max 62 (-> usage length))) - (set! (-> usage data 61 name) "draw-node") - (+! (-> usage data 61 count) (-> this length)) - (let ((byte-size (asize-of this))) - (+! (-> usage data 61 used) byte-size) - (+! (-> usage data 61 total) (logand -16 (+ byte-size 15)))) + (mem-usage-add! usage draw-node (-> this length) (asize-of this)) this) (defmethod asize-of ((this drawable-inline-array-node)) diff --git a/goal_src/jak1/engine/draw/drawable-group.gc b/goal_src/jak1/engine/draw/drawable-group.gc index 225faa15d6..6a51bfd91d 100644 --- a/goal_src/jak1/engine/draw/drawable-group.gc +++ b/goal_src/jak1/engine/draw/drawable-group.gc @@ -35,15 +35,10 @@ "Return the allocation size of this variable-length drawable group." (the-as int (+ (-> drawable-group size) (* (+ (-> this length) -1) 4)))) -(defmethod mem-usage ((this drawable-group) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-group) (usage memory-usage-block) (flags mem-usage-flags)) "Record this group's allocation in usage, then recursively collect memory use from every child. flags is forwarded unchanged to each child." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) "drawable-group") - (+! (-> usage data 0 count) 1) - (let ((allocated-size (asize-of this))) - (+! (-> usage data 0 used) allocated-size) - (+! (-> usage data 0 total) (logand -16 (+ allocated-size 15)))) + (mem-usage-add! usage drawable-group 1 (asize-of this)) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) diff --git a/goal_src/jak1/engine/draw/drawable.gc b/goal_src/jak1/engine/draw/drawable.gc index bd1e712780..fd631c3e1a 100644 --- a/goal_src/jak1/engine/draw/drawable.gc +++ b/goal_src/jak1/engine/draw/drawable.gc @@ -371,14 +371,15 @@ (v1-16 s4-1)) (t9-3 a0-4 a1-0 - (logior (cond - ((= v1-16 1) 4) - ((= v1-16 2) 8) - ((= v1-16 3) 16) - (else 0)) - 2))))) + (the-as mem-usage-flags + (logior (cond + ((= v1-16 1) 4) + ((= v1-16 2) 8) + ((= v1-16 3) 16) + (else 0)) + 2)))))) (set! geometry-bytes (+ (calculate-total *instance-mem-usage*) 580)))) - (mem-usage prototype (reset! *instance-mem-usage*) 0) + (mem-usage prototype (reset! *instance-mem-usage*) (mem-usage-flags)) (let ((prototype-bytes (calculate-total *instance-mem-usage*))) (format output "~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%" @@ -712,13 +713,13 @@ (when (not (logtest? (-> control status) (draw-status hidden no-anim no-skeleton-update))) (let ((scratch-lights (the-as vu-lights (+ 64 (scratchpad-object int)))) (hud-lights *hud-lights*)) - (set! (-> scratch-lights direction 0 quad) (-> hud-lights direction 0 quad)) - (set! (-> scratch-lights direction 1 quad) (-> hud-lights direction 1 quad)) - (set! (-> scratch-lights direction 2 quad) (-> hud-lights direction 2 quad)) - (set! (-> scratch-lights color 0 quad) (-> hud-lights color 0 quad)) - (set! (-> scratch-lights color 1 quad) (-> hud-lights color 1 quad)) - (set! (-> scratch-lights color 2 quad) (-> hud-lights color 2 quad)) - (set! (-> scratch-lights ambient quad) (-> hud-lights ambient quad))) + (vector-copy! (-> scratch-lights direction 0) (-> hud-lights direction 0)) + (vector-copy! (-> scratch-lights direction 1) (-> hud-lights direction 1)) + (vector-copy! (-> scratch-lights direction 2) (-> hud-lights direction 2)) + (vector-copy! (-> scratch-lights color 0) (-> hud-lights color 0)) + (vector-copy! (-> scratch-lights color 1) (-> hud-lights color 1)) + (vector-copy! (-> scratch-lights color 2) (-> hud-lights color 2)) + (vector-copy! (-> scratch-lights ambient) (-> hud-lights ambient))) (lod-set! control 0) (logior! (-> control status) (draw-status was-drawn)) (draw-bones-hud control dma-buf)) @@ -944,7 +945,7 @@ ;; draw the background! (with-profiler "background" (init-background) - (execute-connections *background-draw-engine* (-> *display* frames (-> *display* on-screen) frame)) + (execute-connections *background-draw-engine* (current-frame)) ;; finish bg (most of the work is here) (reset! (-> *perf-stats* data 3)) (finish-background) @@ -964,11 +965,11 @@ ;; draw the foreground engines. (with-profiler "foreground-engines" (foreground-engine-execute (-> *level* level-default foreground-draw-engine 0) - (-> *display* frames (-> *display* on-screen) frame) + (current-frame) 2 0) (foreground-engine-execute (-> *level* level-default foreground-draw-engine 1) - (-> *display* frames (-> *display* on-screen) frame) + (current-frame) 2 1)) ;; handle extra processing for foreground @@ -1017,33 +1018,19 @@ ;; The packet sends three qwords through VIF DIRECT: an A+D GIF tag followed by ZBUF_1 and ;; TEST_1 register writes. Its NEXT tail is inserted into the selected debug bucket so later ;; debug geometry inherits these depth settings. - (let* ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (segment-start (-> global-buf base))) - (let ((packet-head (the-as object (-> global-buf base)))) - (set! (-> (the-as dma-packet packet-head) dma) (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet packet-head) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet packet-head) vif1) (new 'static 'vif-tag :imm #x3 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> global-buf base) (&+ (the-as pointer packet-head) 16))) - (let ((gif-head (the-as object (-> global-buf base)))) - (set! (-> (the-as gs-gif-tag gif-head) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x2)) - (set! (-> (the-as gs-gif-tag gif-head) regs) GIF_REGS_ALL_AD) - (set! (-> global-buf base) (&+ (the-as pointer gif-head) 16))) - (let ((register-data (-> global-buf base))) - (set! (-> (the-as (pointer gs-zbuf) register-data) 0) zbuf) - (set! (-> (the-as (pointer gs-reg64) register-data) 1) (gs-reg64 zbuf-1)) - (set! (-> (the-as (pointer gs-test) register-data) 2) test) - (set! (-> (the-as (pointer gs-reg64) register-data) 3) (gs-reg64 test-1)) - (set! (-> global-buf base) (&+ register-data 32))) - (let ((tail-tag (-> global-buf base))) - (let ((tail-packet (the-as object (-> global-buf base)))) - (set! (-> (the-as dma-packet tail-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet tail-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet tail-packet) vif1) (new 'static 'vif-tag)) - (set! (-> global-buf base) (&+ (the-as pointer tail-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - debug-bucket - segment-start - (the-as (pointer dma-tag) tail-tag)))) + (with-dma-buffer-add-bucket ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) debug-bucket) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((packet-head (the-as object (-> global-buf base)))) + (set! (-> (the-as dma-packet packet-head) dma) (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet packet-head) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet packet-head) vif1) (new 'static 'vif-tag :imm #x3 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> global-buf base) (&+ (the-as pointer packet-head) 16))) (let ((gif-head (the-as object (-> global-buf base)))) + (set! (-> (the-as gs-gif-tag gif-head) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x2)) + (set! (-> (the-as gs-gif-tag gif-head) regs) GIF_REGS_ALL_AD) + (set! (-> global-buf base) (&+ (the-as pointer gif-head) 16))) (let ((register-data (-> global-buf base))) + (set! (-> (the-as (pointer gs-zbuf) register-data) 0) zbuf) + (set! (-> (the-as (pointer gs-reg64) register-data) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) register-data) 2) test) + (set! (-> (the-as (pointer gs-reg64) register-data) 3) (gs-reg64 test-1)) + (set! (-> global-buf base) (&+ register-data 32)))) (none)) (define *screen-shot* #f) @@ -1184,26 +1171,14 @@ ;; one rendering stage into the following stage. ;; iterate through all buckets and append a final GS state reset. (dotimes (bucket-idx BUCKET_COUNT) - (let* ((this-global-buf (-> this-frame global-buf)) - (a2-0 (-> this-global-buf base))) - ;; clear GS state after the bucket - (let* ((a0-3 this-global-buf) - (t0-0 *default-regs-buffer*) - (a1-0 (the-as object (-> a0-3 base)))) - (set! (-> (the-as dma-packet a1-0) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr (the-as int (-> t0-0 data)))) - (set! (-> (the-as dma-packet a1-0) vif0) (new 'static 'vif-tag :irq #x1)) - (set! (-> (the-as dma-packet a1-0) vif1) (new 'static 'vif-tag)) - (set! (-> a0-3 base) (&+ (the-as pointer a1-0) 16))) - (let ((a3-4 (-> this-global-buf base))) - (let ((a0-4 (the-as object (-> this-global-buf base)))) - (set! (-> (the-as dma-packet a0-4) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet a0-4) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet a0-4) vif1) (new 'static 'vif-tag)) - (set! (-> this-global-buf base) (&+ (the-as pointer a0-4) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id bucket-idx) - a2-0 - (the-as (pointer dma-tag) a3-4))))) + ;; clear GS state after the bucket + (with-dma-buffer-add-bucket ((this-global-buf (-> this-frame global-buf)) (the-as bucket-id bucket-idx)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let* ((a0-3 this-global-buf) + (t0-0 *default-regs-buffer*) + (a1-0 (the-as object (-> a0-3 base)))) + (set! (-> (the-as dma-packet a1-0) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr (the-as int (-> t0-0 data)))) + (set! (-> (the-as dma-packet a1-0) vif0) (new 'static 'vif-tag :irq #x1)) + (set! (-> (the-as dma-packet a1-0) vif1) (new 'static 'vif-tag)) + (set! (-> a0-3 base) (&+ (the-as pointer a1-0) 16))))) ;; append a FLUSHE and IRQ to end the calc-buf (let* ((v1-14 this-calc-buf) (a0-10 (the-as object (-> v1-14 base)))) diff --git a/goal_src/jak1/engine/engine/connect.gc b/goal_src/jak1/engine/engine/connect.gc index 778605dd1a..8ec0d40c79 100644 --- a/goal_src/jak1/engine/engine/connect.gc +++ b/goal_src/jak1/engine/engine/connect.gc @@ -169,6 +169,17 @@ "Return node's next link in an engine list." (-> node next0)) +;; Walk an engine's live connections in forward order. Cache next before running body so body may +;; unlink the current connection without breaking the traversal. +(defmacro iterate-engine-connections (bindings &rest body) + (with-gensyms (next) + `(let* ((,(car bindings) (-> ,(cadr bindings) alive-list next0)) + (,next (-> ,(car bindings) next0))) + (while (!= ,(car bindings) (-> ,(cadr bindings) alive-list-end)) + ,@body + (set! ,(car bindings) ,next) + (set! ,next (-> ,next next0)))))) + (defmethod new engine ((allocation symbol) (type-to-make type) (name basic) (capacity int)) "Allocate a fixed-capacity engine and link every connection slot into its dead list." (local-vars (this engine) (i int) (last-interior-index int)) @@ -251,13 +262,8 @@ (defmethod apply-to-connections ((this engine) (f (function connectable none))) "Apply f to every live connection in forward order, caching the next node so f may remove the current one." - (let* ((current (-> this alive-list next0)) - ;; Save this before the callback in case it removes current. - (next (-> current next0))) - (while (!= current (-> this alive-list-end)) - (f current) - (set! current next) - (set! next (-> next next0)))) + ;; Save this before the callback in case it removes current. + (iterate-engine-connections (current this) (f current)) 0) (defmethod apply-to-connections-reverse ((this engine) (f (function connectable none))) @@ -403,22 +409,14 @@ (defmethod remove-by-param1 ((this engine) (p1-value object)) "Move every live connection whose param1 equals value to the dead list." - (let* ((current (-> this alive-list next0)) - (next (-> current next0))) - (while (!= current (-> this alive-list-end)) - (if (= (-> (the-as connection current) param1) p1-value) - ((method-of-type connection move-to-dead) (the-as connection current))) - (set! current next) - (set! next (-> next next0)))) + (iterate-engine-connections (current this) + (if (= (-> (the-as connection current) param1) p1-value) + ((method-of-type connection move-to-dead) (the-as connection current)))) 0) (defmethod remove-by-param2 ((this engine) (p2-value int)) "Move every live connection whose param2 equals value to the dead list." - (let* ((current (-> this alive-list next0)) - (next (-> current next0))) - (while (!= current (-> this alive-list-end)) - (if (= (-> (the-as connection current) param2) p2-value) - ((method-of-type connection move-to-dead) (the-as connection current))) - (set! current next) - (set! next (-> next next0)))) + (iterate-engine-connections (current this) + (if (= (-> (the-as connection current) param2) p2-value) + ((method-of-type connection move-to-dead) (the-as connection current)))) 0) diff --git a/goal_src/jak1/engine/entity/ambient.gc b/goal_src/jak1/engine/entity/ambient.gc index 3d8a85fd04..9a1d1a7960 100644 --- a/goal_src/jak1/engine/entity/ambient.gc +++ b/goal_src/jak1/engine/entity/ambient.gc @@ -11,25 +11,15 @@ ;; DECOMP BEGINS -(defmethod mem-usage ((this drawable-ambient) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-ambient) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this wrapper and its referenced ambient entity in the ambient memory category." - (set! (-> usage length) (max 50 (-> usage length))) - (set! (-> usage data 49 name) "ambient") - (+! (-> usage data 49 count) 1) - (let ((object-size (asize-of this))) - (+! (-> usage data 49 used) object-size) - (+! (-> usage data 49 total) (logand -16 (+ object-size 15)))) - (mem-usage (-> this ambient) usage (logior flags 128)) + (mem-usage-add! usage ambient 1 (asize-of this)) + (mem-usage (-> this ambient) usage (logior flags (mem-usage-flags resource-ambient))) (the-as drawable-ambient 0)) -(defmethod mem-usage ((this drawable-inline-array-ambient) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-ambient) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this array header and each inline ambient wrapper it contains." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-size 32)) - (+! (-> usage data 0 used) header-size) - (+! (-> usage data 0 total) (logand -16 (+ header-size 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) (the-as drawable-inline-array-ambient 0)) @@ -242,7 +232,7 @@ (let ((text-context (new 'stack 'font-context *font-default-matrix* 56 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! text-context 400) (set-height! text-context 96) - (set! (-> text-context flags) (font-flags shadow kerning middle large)) + (set-flags! text-context (font-flags shadow kerning middle large)) (print-game-text (lookup-text! *common-text* (-> this text-id-to-display) #f) text-context #f 128 22))) 0 (none)) @@ -428,7 +418,7 @@ (let ((text-context (new 'stack 'font-context *font-default-matrix* 56 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! text-context 400) (set-height! text-context 96) - (set! (-> text-context flags) (font-flags shadow kerning middle)) + (set-flags! text-context (font-flags shadow kerning middle)) (let ((draw-text print-game-text)) (format (clear *temp-string*) "~S~S" prefix suffix) (draw-text *temp-string* text-context #f 128 22))))) @@ -476,7 +466,7 @@ (let ((text-context (new 'stack 'font-context *font-default-matrix* 56 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! text-context 400) (set-height! text-context 96) - (set! (-> text-context flags) (font-flags shadow kerning middle large)) + (set-flags! text-context (font-flags shadow kerning middle large)) (print-game-text "AS: UNKNOWN ID" text-context #f 128 22)))) ((!= resolved-text-id -1) (kill-current-level-hint '() '() 'exit) diff --git a/goal_src/jak1/engine/entity/entity.gc b/goal_src/jak1/engine/entity/entity.gc index d860d8fe52..0270e5d158 100644 --- a/goal_src/jak1/engine/entity/entity.gc +++ b/goal_src/jak1/engine/entity/entity.gc @@ -24,26 +24,16 @@ ;; entity basic methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defmethod mem-usage ((this drawable-actor) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-actor) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this drawable wrapper and delegate to its entity actor in the entity category." - (set! (-> usage length) (max 44 (-> usage length))) - (set! (-> usage data 43 name) "entity") - (+! (-> usage data 43 count) 1) - (let ((allocation-size (asize-of this))) - (+! (-> usage data 43 used) allocation-size) - (+! (-> usage data 43 total) (logand -16 (+ allocation-size 15)))) + (mem-usage-add! usage entity 1 (asize-of this)) ;; Attribute the actor's resource lump and referenced data to the entity category. - (mem-usage (-> this actor) usage (logior flags 64)) + (mem-usage (-> this actor) usage (logior flags (mem-usage-flags resource-entity))) (the-as drawable-actor 0)) -(defmethod mem-usage ((this drawable-inline-array-actor) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-actor) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the drawable-group header and every active inline actor wrapper." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-size 32)) - (+! (-> usage data 0 used) header-size) - (+! (-> usage data 0 total) (logand -16 (+ header-size 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) (the-as drawable-inline-array-actor 0)) @@ -962,7 +952,7 @@ "Mark proc as actor-pausable and initialize its root translation, rotation, and unit scale from actor." (logior! (-> proc mask) (process-mask actor-pause)) - (set! (-> proc root trans quad) (-> actor extra trans quad)) + (vector-copy! (-> proc root trans) (-> actor extra trans)) (quaternion-copy! (-> proc root quat) (-> actor quat)) (vector-identity! (-> proc root scale)) (none)) diff --git a/goal_src/jak1/engine/entity/res.gc b/goal_src/jak1/engine/entity/res.gc index 0efa8d2016..0515d55d14 100644 --- a/goal_src/jak1/engine/entity/res.gc +++ b/goal_src/jak1/engine/entity/res.gc @@ -506,16 +506,16 @@ This system grew out of the Crash 2 entity resource system. (declare-type collide-mesh basic) -(defmethod mem-usage ((this res-lump) (block memory-usage-block) (flags int)) +(defmethod mem-usage ((this res-lump) (block memory-usage-block) (flags mem-usage-flags)) "Add the lump and its referenced objects to the selected memory-usage category." ;; get the name and ID (let ((mem-use-id (mem-usage-id res)) (mem-use-name "res")) (cond - ((logtest? flags 256) (set! mem-use-id (mem-usage-id camera)) (set! mem-use-name "camera")) - ((logtest? flags 64) (set! mem-use-id (mem-usage-id entity)) (set! mem-use-name "entity")) - ((logtest? flags 128) (set! mem-use-id (mem-usage-id ambient)) (set! mem-use-name "ambient")) - ((logtest? flags 512) (set! mem-use-id (mem-usage-id art-joint-geo)) (set! mem-use-name "art-joint-geo"))) + ((logtest? flags (mem-usage-flags resource-camera)) (set! mem-use-id (mem-usage-id camera)) (set! mem-use-name "camera")) + ((logtest? flags (mem-usage-flags resource-entity)) (set! mem-use-id (mem-usage-id entity)) (set! mem-use-name "entity")) + ((logtest? flags (mem-usage-flags resource-ambient)) (set! mem-use-id (mem-usage-id ambient)) (set! mem-use-name "ambient")) + ((logtest? flags (mem-usage-flags resource-joint-geo)) (set! mem-use-id (mem-usage-id art-joint-geo)) (set! mem-use-name "art-joint-geo"))) ;; set up the block (set! (-> block length) (max (-> block length) (+ mem-use-id 1))) (set! (-> block data mem-use-id name) mem-use-name) diff --git a/goal_src/jak1/engine/game/game-save.gc b/goal_src/jak1/engine/game/game-save.gc index eeb68f403c..e0ac4559a2 100644 --- a/goal_src/jak1/engine/game/game-save.gc +++ b/goal_src/jak1/engine/game/game-save.gc @@ -847,7 +847,7 @@ (let ((debug-context (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! debug-context 440) (set-height! debug-context 80) - (set! (-> debug-context flags) (font-flags shadow kerning)) + (set-flags! debug-context (font-flags shadow kerning)) (format (clear *temp-string*) "~S / ~S ~D~%" (-> self mode) (-> self state name) (-> self which)) (print-game-text *temp-string* debug-context #f 128 22))) ;; auto-save drawing @@ -856,7 +856,7 @@ (set-scale! save-context 0.8) (set-width! save-context 472) (set-height! save-context 20) - (set! (-> save-context flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! save-context (font-flags shadow kerning middle middle-vert large)) ;; if this is the first time saving, display a warning. (when (zero? (-> *game-info* auto-save-count)) (print-game-text (lookup-text! *common-text* (text-id saving-data) #f) save-context #f 128 22) diff --git a/goal_src/jak1/engine/game/projectiles.gc b/goal_src/jak1/engine/game/projectiles.gc index 8cc445479b..fbdd6b2213 100644 --- a/goal_src/jak1/engine/game/projectiles.gc +++ b/goal_src/jak1/engine/game/projectiles.gc @@ -39,13 +39,13 @@ angle-range of 65536 disables the cone test." (let ((search *search-info*)) (set! (-> search match) #f) - (set! (-> search point quad) (-> search-point quad)) + (vector-copy! (-> search point) search-point) (set! (-> search radius) search-radius) (set! (-> search best) search-radius) (set! (-> search rating) (the-as uint 0)) (set! (-> search require) required-rating) (set! (-> search mask) rating-mask) - (set! (-> search rot-base quad) (-> forward-direction quad)) + (vector-copy! (-> search rot-base) forward-direction) (set! (-> search rot-range) (if (= angle-range 65536.0) -2.0 (cos angle-range))) (iterate-process-tree *entity-pool* (lambda ((candidate-process process)) @@ -102,7 +102,7 @@ (let ((separation (vector-float*! (new 'stack-no-clear 'vector) contact-normal 32.0))) (move-by-vector! cshape separation))) (set! (-> cshape surface-normal quad) (-> contact-normal quad)) - (set! (-> cshape poly-normal quad) (-> isect best-tri normal quad)) + (vector-copy! (-> cshape poly-normal) (-> isect best-tri normal)) (set! (-> cshape surface-angle) (vector-dot contact-normal (-> cshape dynam gravity-normal))) (set! (-> cshape poly-angle) (vector-dot (-> cshape poly-normal) (-> cshape dynam gravity-normal))) (set! (-> cshape touch-angle) @@ -122,10 +122,10 @@ (vector-reflect-flat-above! vel-out (the-as vector velocity-copy) contact-normal) (when (and (not wall?) (>= (-> cshape coverage) 0.9)) (logior! status-mask (collide-status on-ground)) - (set! (-> cshape ground-poly-normal quad) (-> cshape poly-normal quad)) + (vector-copy! (-> cshape ground-poly-normal) (-> cshape poly-normal)) (when (!= (-> cshape poly-pat mode) (pat-mode wall)) (set! (-> cshape ground-pat) (-> cshape poly-pat)) - (set! (-> cshape ground-touch-point quad) (-> isect best-tri intersect quad))))) + (vector-copy! (-> cshape ground-touch-point) (-> isect best-tri intersect))))) (logior! (-> cshape status) status-mask) (the-as collide-status status-mask))) @@ -582,7 +582,7 @@ ((< target-distance 20480.0) (seek! (-> self tween) 1.0 (* 3.0 (seconds-per-frame)))) ((< target-distance 40960.0) (seek! (-> self tween) 1.0 (seconds-per-frame)))))) (let ((previous-position (new 'stack-no-clear 'vector))) - (set! (-> previous-position quad) (-> self root trans quad)) + (vector-copy! previous-position (-> self root trans)) (fill-cache-integrate-and-collide! (-> self root) (-> self root transv) (-> self root root-prim collide-with)) (set! (-> self old-dist (-> self old-dist-count)) (* 0.0625 (vector-vector-distance previous-position (-> self root trans))))) @@ -744,16 +744,16 @@ (set! (-> self root dynam gravity y) 1228800.0) (set! (-> self root dynam gravity-length) 1228800.0) (set! (-> self root dynam gravity-max) 1228800.0) - (set! (-> self root trans quad) (-> launch-position quad)) - (set! (-> self base-trans quad) (-> launch-position quad)) - (set! (-> self parent-base quad) (-> launch-position quad)) + (vector-copy! (-> self root trans) launch-position) + (vector-copy! (-> self base-trans) launch-position) + (vector-copy! (-> self parent-base) launch-position) (quaternion-copy! (-> self root quat) (-> (the-as process-drawable (-> self parent 0)) root quat)) (quaternion-copy! (-> self parent-quat) (-> (the-as process-drawable (-> self parent 0)) root quat)) (vector-identity! (-> self root scale)) - (set! (-> self root transv quad) (-> initial-velocity quad)) + (vector-copy! (-> self root transv) initial-velocity) (vector-normalize-copy! (-> self base-vector) initial-velocity 1.0) (vector+float*! (-> self target) (-> self root trans) (-> self root transv) 2.0) - (set! (-> self target-base quad) (-> self target quad)) + (vector-copy! (-> self target-base) (-> self target)) (init-projectile-settings! self) (update-projectile-effects! self) (when (not (type-type? (-> self type) projectile-blue)) @@ -778,10 +778,10 @@ (set! (-> this tween) 0.05) (logior! (-> this options) 2) (let ((launcher-position (new 'stack-no-clear 'vector))) - (set! (-> launcher-position quad) (-> this root trans quad)) + (vector-copy! launcher-position (-> this root trans)) (+! (-> this root trans y) -5324.8) (vector+float*! (-> this target) (-> this root trans) (-> this root transv) 2.0) - (set! (-> this target-base quad) (-> this target quad)) + (vector-copy! (-> this target-base) (-> this target)) (let ((launch-angle (the float (sar (shl (the int (y-angle (-> this root))) 48) 48)))) (set! (-> this mask) (the-as process-mask (logior (process-mask projectile) (-> this mask)))) (if (logtest? (-> this options) 16) (set! (-> this max-hits) 1)) @@ -902,12 +902,12 @@ (if near-match (set! best-match near-match))) (set! (-> this last-target) (process->handle best-match)) (when best-match - (set! (-> this target quad) (-> (the-as collide-shape (-> best-match root)) root-prim prim-core world-sphere quad)) + (vector-copy! (-> this target) (-> (the-as collide-shape (-> best-match root)) root-prim prim-core world-sphere)) (if (= (-> best-match type symbol) 'mother-spider) (logand! (-> this options) -2))))) - (else (set! (-> this target quad) (-> this target-base quad))))) + (else (vector-copy! (-> this target) (-> this target-base))))) (else (let ((target-process (handle->process (-> this last-target)))) - (set! (-> this target quad) (-> (the-as target target-process) control root-prim prim-core world-sphere quad))) + (vector-copy! (-> this target) (-> (the-as target target-process) control root-prim prim-core world-sphere))) (if (and (< (vector-vector-xz-distance (-> this root trans) (-> this target)) 20480.0) (< 24576.0 (fabs (- (-> this target y) (-> this root trans y))))) (set! (-> this last-target) (the-as handle #f))))) @@ -926,7 +926,7 @@ (set! (-> this update-velocity) projectile-update-velocity-space-wars) (+! (-> this root trans y) -5324.8) (vector+float*! (-> this target) (-> this root trans) (-> this root transv) 2.0) - (set! (-> this target-base quad) (-> this target quad)) + (vector-copy! (-> this target-base) (-> this target)) (set! (-> this mask) (the-as process-mask (logior (process-mask ambient) (-> this mask)))) (set! (-> this part) (create-launch-control group-eco-blue this)) (set! (-> this root root-prim collide-with) (collide-kind background)) diff --git a/goal_src/jak1/engine/geometry/cylinder.gc b/goal_src/jak1/engine/geometry/cylinder.gc index 47a5e73bba..c307cb3055 100644 --- a/goal_src/jak1/engine/geometry/cylinder.gc +++ b/goal_src/jak1/engine/geometry/cylinder.gc @@ -161,12 +161,12 @@ (let ((origin-cap-fraction (ray-arbitrary-circle-intersect probe-origin probe-displacement (-> this origin) (-> this axis) (-> this radius)))) (when (and (>= origin-cap-fraction 0.0) (or (< contact-fraction 0.0) (< origin-cap-fraction contact-fraction))) (set! contact-fraction origin-cap-fraction) - (set! (-> axis-point quad) (-> this origin quad)))) + (vector-copy! axis-point (-> this origin)))) (vector+float*! end-center (-> this origin) (-> this axis) (-> this length)) (let ((end-cap-fraction (ray-arbitrary-circle-intersect probe-origin probe-displacement end-center (-> this axis) (-> this radius)))) (when (and (>= end-cap-fraction 0.0) (or (< contact-fraction 0.0) (< end-cap-fraction contact-fraction))) (set! contact-fraction end-cap-fraction) - (set! (-> axis-point quad) (-> end-center quad)))) + (vector-copy! axis-point end-center))) contact-fraction))) ;; debug draw for cylinder flat. @@ -211,7 +211,7 @@ (vector+! (-> vertices vert (+ i 1)) (-> this origin) radial) (vector+float*! (-> vertices vert (+ i 1)) (-> vertices vert (+ i 1)) axis-step (the float i)) (+! i 1)) - (set! (-> vertices vert 0 quad) (-> this origin quad)) + (vector-copy! (-> vertices vert 0) (-> this origin)) (vector+float*! (-> vertices vert 9) (-> this origin) (-> this axis) (-> this length)) (dotimes (rotation-index 16) (dotimes (vertex-index 10) diff --git a/goal_src/jak1/engine/geometry/geometry.gc b/goal_src/jak1/engine/geometry/geometry.gc index f528571f32..fd12a91b39 100644 --- a/goal_src/jak1/engine/geometry/geometry.gc +++ b/goal_src/jak1/engine/geometry/geometry.gc @@ -568,8 +568,8 @@ copies to's whole quad and so is discontinuous with the interior unless the two magnitudes already agree. dst may alias either input." (cond - ((>= 0.0 t) (set! (-> dst quad) (-> from quad)) dst) - ((>= t 1.0) (set! (-> dst quad) (-> to quad)) dst) + ((>= 0.0 t) (vector-copy! dst from) dst) + ((>= t 1.0) (vector-copy! dst to) dst) (else (let ((step (new-stack-matrix0))) (let ((from-unit (vector-normalize-copy! (new 'stack-no-clear 'vector) from 1.0)) @@ -584,8 +584,8 @@ the endpoints. dst may alias any input." (local-vars (lerp-fn (function float float float float))) (cond - ((>= 0.0 t) (set! (-> dst quad) (-> from quad))) - ((>= t 1.0) (set! (-> dst quad) (-> to quad))) + ((>= 0.0 t) (vector-copy! dst from)) + ((>= t 1.0) (vector-copy! dst to)) (else (let* ((from-unit (vector-normalize-copy! (new 'stack-no-clear 'vector) from 1.0)) (to-unit (vector-normalize-copy! (new 'stack-no-clear 'vector) to 1.0)) @@ -764,7 +764,7 @@ (let ((first-distance (vector-segment-distance-point! point (-> triangle vector 1) (the-as vector (-> triangle vector)) dst)) (second-point (new 'stack-no-clear 'vector))) (if (< (vector-segment-distance-point! point (-> triangle vector 1) (-> triangle vector 2) second-point) first-distance) - (set! (-> dst quad) (-> second-point quad)))) + (vector-copy! dst second-point))) (goto closest-point-done) (label test-edge-20) (b! (nonzero? mask-minus-4) test-vertex-0 :delay (set! mask-minus-5 (the-as uint (+ mask-minus-4 -1)))) @@ -775,13 +775,13 @@ (let ((first-distance (vector-segment-distance-point! point (the-as vector (-> triangle vector)) (-> triangle vector 1) dst)) (second-point (new 'stack-no-clear 'vector))) (if (< (vector-segment-distance-point! point (the-as vector (-> triangle vector)) (-> triangle vector 2) second-point) first-distance) - (set! (-> dst quad) (-> second-point quad)))) + (vector-copy! dst second-point))) (goto closest-point-done) (label vertex-2-region) (let ((first-distance (vector-segment-distance-point! point (-> triangle vector 2) (the-as vector (-> triangle vector)) dst)) (second-point (new 'stack-no-clear 'vector))) (if (< (vector-segment-distance-point! point (-> triangle vector 2) (-> triangle vector 1) second-point) first-distance) - (set! (-> dst quad) (-> second-point quad)))) + (vector-copy! dst second-point))) (label closest-point-done) 0 (none))) diff --git a/goal_src/jak1/engine/geometry/path.gc b/goal_src/jak1/engine/geometry/path.gc index 865fe90ffd..79ea25f196 100644 --- a/goal_src/jak1/engine/geometry/path.gc +++ b/goal_src/jak1/engine/geometry/path.gc @@ -98,7 +98,7 @@ (else (format #t "WARNING: method get-random-point called on a path-control object with no vertices.~%") (if pp (format #t "current process is ~A~%" (-> pp name))) - (set! (-> result quad) (-> *null-vector* quad)))) + (vector-copy! result *null-vector*))) result)) (defmethod eval-path-curve! ((this path-control) (result vector) (percent float) (mode symbol)) @@ -205,12 +205,12 @@ (closest-distance 4096000000.0) (closest-progress 0.0)) (let ((closest-point (new 'stack-no-clear 'vector))) - (set! (-> target-point quad) (-> (target-pos 0) quad)) + (vector-copy! target-point (target-pos 0)) (set! (-> target-point y) 0.0) (eval-path-curve-div! this segment-end 0.0 'interp) (set! (-> segment-end y) 0.0) (dotimes (i (+ (-> this curve num-cverts) -1)) - (set! (-> segment-start quad) (-> segment-end quad)) + (vector-copy! segment-start segment-end) (eval-path-curve-div! this segment-end (the float (+ i 1)) 'interp) (set! (-> segment-end y) 0.0) (let ((distance (vector-segment-distance-point! target-point segment-start segment-end closest-point))) diff --git a/goal_src/jak1/engine/gfx/background/prototype.gc b/goal_src/jak1/engine/gfx/background/prototype.gc index 6a7cbdf14b..a76ffb6071 100644 --- a/goal_src/jak1/engine/gfx/background/prototype.gc +++ b/goal_src/jak1/engine/gfx/background/prototype.gc @@ -36,70 +36,41 @@ (let ((geometry (-> prototype geometry geometry-index))) (if (nonzero? geometry) (login geometry)))))) this) -(defmethod mem-usage ((this prototype-array-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-array-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this array in the drawable-group category, then account for every TIE prototype it contains." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((array-bytes (asize-of this))) - (+! (-> usage data 0 used) array-bytes) - (+! (-> usage data 0 total) (logand -16 (+ array-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 (asize-of this)) (dotimes (i (-> this length)) (mem-usage (-> this array-data i) usage flags)) this) -(defmethod mem-usage ((this prototype-bucket-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-bucket-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this TIE prototype's four populated geometry slots as prototype-owned data, its name string, optional time-of-day palette, and optional collision fragments." (dotimes (geometry-index 4) (let ((geometry (-> this geometry geometry-index))) - (if (nonzero? geometry) (mem-usage geometry usage (logior flags 1))))) - (set! (-> usage length) (max 81 (-> usage length))) - (set! (-> usage data 80 name) "string") - (+! (-> usage data 80 count) 1) - (let ((name-bytes (asize-of (-> this name)))) - (+! (-> usage data 80 used) name-bytes) - (+! (-> usage data 80 total) (logand -16 (+ name-bytes 15)))) + (if (nonzero? geometry) (mem-usage geometry usage (logior flags (mem-usage-flags prototype-data)))))) + (mem-usage-add! usage string 1 (asize-of (-> this name))) (when (nonzero? (-> this tie-colors)) - (set! (-> usage length) (max 17 (-> usage length))) - (set! (-> usage data 16 name) "tie-pal") - (+! (-> usage data 16 count) 1) - (let ((palette-bytes (asize-of (-> this tie-colors)))) - (+! (-> usage data 16 used) palette-bytes) - (+! (-> usage data 16 total) (logand -16 (+ palette-bytes 15))))) - (if (nonzero? (-> this collide-frag)) (mem-usage (-> this collide-frag) usage (logior flags 1))) + (mem-usage-add! usage tie-pal 1 (asize-of (-> this tie-colors)))) + (if (nonzero? (-> this collide-frag)) + (mem-usage (-> this collide-frag) usage (logior flags (mem-usage-flags prototype-data)))) this) -(defmethod mem-usage ((this prototype-inline-array-shrub) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-inline-array-shrub) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this inline prototype array in the drawable-group category, then account for every shrub prototype it contains." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((array-bytes (asize-of this))) - (+! (-> usage data 0 used) array-bytes) - (+! (-> usage data 0 total) (logand -16 (+ array-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 (asize-of this)) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) -(defmethod mem-usage ((this prototype-bucket-shrub) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-bucket-shrub) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this 112-byte shrub prototype, its four populated geometry slots as prototype-owned data, and its name string." - (set! (-> usage length) (max 25 (-> usage length))) - (set! (-> usage data 24 name) "prototype-bucket-shrub") - (+! (-> usage data 24 count) 1) - (let ((prototype-bytes 112)) - (+! (-> usage data 24 used) prototype-bytes) - (+! (-> usage data 24 total) (logand -16 (+ prototype-bytes 15)))) + (mem-usage-add! usage prototype-bucket-shrub 1 112) (dotimes (geometry-index 4) (let ((geometry (-> this geometry geometry-index))) - (if (nonzero? geometry) (mem-usage geometry usage (logior flags 1))))) - (set! (-> usage length) (max 81 (-> usage length))) - (set! (-> usage data 80 name) "string") - (+! (-> usage data 80 count) 1) - (let ((name-bytes (asize-of (-> this name)))) - (+! (-> usage data 80 used) name-bytes) - (+! (-> usage data 80 total) (logand -16 (+ name-bytes 15)))) + (if (nonzero? geometry) (mem-usage geometry usage (logior flags (mem-usage-flags prototype-data)))))) + (mem-usage-add! usage string 1 (asize-of (-> this name))) this) diff --git a/goal_src/jak1/engine/gfx/foreground/eye.gc b/goal_src/jak1/engine/gfx/foreground/eye.gc index 2d6fb49d6b..1d99602d69 100644 --- a/goal_src/jak1/engine/gfx/foreground/eye.gc +++ b/goal_src/jak1/engine/gfx/foreground/eye.gc @@ -647,152 +647,107 @@ ;; offset at (32, 32) and depth writes off. The alpha test is then set to pass everything, because ;; the pupil pass inside render-eyes leaves it configured to fail and each bucket has to start from ;; a known state. These three blocks are identical apart from the bucket they land in. - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-test) reg-out) 0) - (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id pris-tex0)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id pris-tex0) - bucket-start - (the-as (pointer dma-tag) next-tag)))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-test) reg-out) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) + (set! (-> buf base) (&+ reg-out 16)))) ;; Setup GS for level 1 eyes - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-test) reg-out) 0) - (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id pris-tex1)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id pris-tex1) - bucket-start - (the-as (pointer dma-tag) next-tag)))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-test) reg-out) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) + (set! (-> buf base) (&+ reg-out 16)))) ;; Setup GS for common eyes - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-test) reg-out) 0) - (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id eyes)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-display-gs-state-offset dma-buf *eyes-base-page* 64 352 0 0 32 32) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id eyes) - bucket-start - (the-as (pointer dma-tag) next-tag)))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-test) reg-out) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 test-1)) + (set! (-> buf base) (&+ reg-out 16)))) ;; rendering of eyes. (dotimes (slot 11) ;; grab the eye and the process @@ -835,177 +790,108 @@ (cond ((>= (the-as uint 1) (-> ctrl level)) ;; level eyes - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (render-eyes dma-buf ctrl slot) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id (if (zero? (-> ctrl level)) (bucket-id pris-tex0) (bucket-id pris-tex1))) - bucket-start - (the-as (pointer dma-tag) next-tag))))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id (if (zero? (-> ctrl level)) (bucket-id pris-tex0) (bucket-id pris-tex1)))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (render-eyes dma-buf ctrl slot))) (else - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (render-eyes dma-buf ctrl slot) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id eyes) - bucket-start - (the-as (pointer dma-tag) next-tag)))))))))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id eyes)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (render-eyes dma-buf ctrl slot)))))))) ;; Restore the game framebuffer at the tail of each of the same three buckets. reset-display-gs-state ;; does not touch ALPHA_1, which the eyelid pass repointed, so the ordinary source-over equation is ;; written back by hand. These three blocks are identical apart from the bucket. - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (reset-display-gs-state *display* dma-buf *oddeven*) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id pris-tex0)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (reset-display-gs-state *display* dma-buf *oddeven*) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id pris-tex0) - bucket-start - (the-as (pointer dma-tag) next-tag)))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (reset-display-gs-state *display* dma-buf *oddeven*) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) + (set! (-> buf base) (&+ reg-out 16)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id pris-tex1)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (reset-display-gs-state *display* dma-buf *oddeven*) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id pris-tex1) - bucket-start - (the-as (pointer dma-tag) next-tag)))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (reset-display-gs-state *display* dma-buf *oddeven*) - (let* ((buf dma-buf) - (dma-out (the-as object (-> buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) - (let* ((buf dma-buf) - (gif-out (the-as object (-> buf base)))) - (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag gif-out) regs) - (new 'static - 'gif-tag-regs - :regs0 (gif-reg-id a+d) - :regs1 (gif-reg-id a+d) - :regs2 (gif-reg-id a+d) - :regs3 (gif-reg-id a+d) - :regs4 (gif-reg-id a+d) - :regs5 (gif-reg-id a+d) - :regs6 (gif-reg-id a+d) - :regs7 (gif-reg-id a+d) - :regs8 (gif-reg-id a+d) - :regs9 (gif-reg-id a+d) - :regs10 (gif-reg-id a+d) - :regs11 (gif-reg-id a+d) - :regs12 (gif-reg-id a+d) - :regs13 (gif-reg-id a+d) - :regs14 (gif-reg-id a+d) - :regs15 (gif-reg-id a+d))) - (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) - (let* ((buf dma-buf) - (reg-out (-> buf base))) - (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) - (set! (-> buf base) (&+ reg-out 16))) - (let ((next-tag (-> dma-buf base))) - (let ((dma-out (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) + (set! (-> buf base) (&+ reg-out 16)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id eyes)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (reset-display-gs-state *display* dma-buf *oddeven*) (let* ((buf dma-buf) + (dma-out (the-as object (-> buf base)))) + (set! (-> (the-as dma-packet dma-out) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) (set! (-> (the-as dma-packet dma-out) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer dma-out) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id eyes) - bucket-start - (the-as (pointer dma-tag) next-tag)))) + (set! (-> (the-as dma-packet dma-out) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> buf base) (&+ (the-as pointer dma-out) 16))) (let* ((buf dma-buf) + (gif-out (the-as object (-> buf base)))) + (set! (-> (the-as gs-gif-tag gif-out) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag gif-out) regs) + (new 'static + 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d))) + (set! (-> buf base) (&+ (the-as pointer gif-out) 16))) (let* ((buf dma-buf) + (reg-out (-> buf base))) + (set! (-> (the-as (pointer gs-alpha) reg-out) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) reg-out) 1) (gs-reg64 alpha-1)) + (set! (-> buf base) (&+ reg-out 16)))) 0 (none)) diff --git a/goal_src/jak1/engine/gfx/generic/generic-effect.gc b/goal_src/jak1/engine/gfx/generic/generic-effect.gc index 56cdf93fd0..35605cd918 100644 --- a/goal_src/jak1/engine/gfx/generic/generic-effect.gc +++ b/goal_src/jak1/engine/gfx/generic/generic-effect.gc @@ -183,19 +183,13 @@ sink. The Generic VU0 block is loaded at program address zero." (upload-vu0-program generic-vu0-block (the-as pointer #x70000064)) (let (;(a2-0 (+ #x2e20 (the-as int (the-as terrain-context #x70000000)))) - (work-matrix (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts matrix)) - (right (-> camera-transform vector 0 quad)) - (up (-> camera-transform vector 1 quad)) - (forward (-> camera-transform vector 2 quad)) - (translation (-> camera-transform vector 3 quad))) + (work-matrix (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts matrix))) ;;(set! (-> (the-as (pointer uint128) work-matrix)) right) - (set! (-> work-matrix vector 0 quad) right) + (matrix-copy! work-matrix camera-transform) ;;(s.q! (+ work-matrix 16) up) - (set! (-> work-matrix vector 1 quad) up) ;; (s.q! (+ work-matrix 32) forward) - (set! (-> work-matrix vector 2 quad) forward) ;;(s.q! (+ work-matrix 48) translation) - (set! (-> work-matrix vector 3 quad) translation)) + ) (if lights ;;(quad-copy! (the-as pointer (+ #x3190 #x70000000)) (the-as pointer lights) 7) (quad-copy! (the pointer (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work lights)) @@ -210,15 +204,7 @@ (generic-work-init sink) (generic-upload-vu0) ;;(let ((a2-1 (+ #x2e20 (the-as int #x70000000))) - (let ((work-matrix (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts matrix)) - (right (-> camera-transform vector 0 quad)) - (up (-> camera-transform vector 1 quad)) - (forward (-> camera-transform vector 2 quad)) - (translation (-> camera-transform vector 3 quad))) - (set! (-> work-matrix vector 0 quad) right) - (set! (-> work-matrix vector 1 quad) up) - (set! (-> work-matrix vector 2 quad) forward) - (set! (-> work-matrix vector 3 quad) translation)) + (matrix-copy! (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work consts matrix) camera-transform) (if lights (quad-copy! (the-as pointer (-> (scratchpad-object terrain-context) work foreground generic-work fx-buf work lights)) (the-as pointer lights) diff --git a/goal_src/jak1/engine/gfx/generic/generic-merc.gc b/goal_src/jak1/engine/gfx/generic/generic-merc.gc index 57f5ddb2f0..4e04a7c4be 100644 --- a/goal_src/jak1/engine/gfx/generic/generic-merc.gc +++ b/goal_src/jak1/engine/gfx/generic/generic-merc.gc @@ -3309,44 +3309,29 @@ (set! *merc-globals* (-> *merc-global-array* globals i)) (let ((sink (-> *merc-globals* sink))) (when (nonzero? (-> *merc-globals* first)) - (let* ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (chain-start (-> global-buf base))) - (generic-work-init sink) - (set! (-> (scratchpad-object terrain-context) work foreground generic-work saves basep) - (the-as uint (-> global-buf base))) - (generic-merc-execute-asm) - (set! (-> global-buf base) - (the-as pointer - (-> (scratchpad-object terrain-context) work foreground generic-work saves basep))) - ;; todo: this part might be important... - ; (let ((v1-36 (the-as object #x1000d000)) - ; (a0-19 (the-as object #x7000006c)) - ; ) - ; (b! (zero? (logand (-> (the-as terrain-context v1-36) bsp lev-index) 256)) cfg-9 :delay (nop!)) - ; (let ((a1-6 (-> (the-as generic-envmap-saves a0-19) index-mask x))) - ; (nop!) - ; (let ((a2-1 (-> (the-as (pointer int32) v1-36) 0))) - ; (nop!) - ; (let ((a2-2 (logand a2-1 256)) - ; (a1-7 (+ a1-6 1)) - ; ) - ; (b! (nonzero? a2-2) cfg-8 :delay (s.w! (the-as int a0-19) a1-7)) - ; ) - ; ) - ; ) - ; ) - ; (label cfg-9) - ; 0 - (let ((chain-tail (-> global-buf base))) - (let ((next-tag (the-as dma-packet (-> global-buf base)))) - (set! (-> next-tag dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> next-tag vif0) (new 'static 'vif-tag)) - (set! (-> next-tag vif1) (new 'static 'vif-tag)) - (set! (-> global-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (-> sink bucket) - chain-start - (the-as (pointer dma-tag) chain-tail)))) + ;; todo: this part might be important... + ; (let ((v1-36 (the-as object #x1000d000)) + ; (a0-19 (the-as object #x7000006c)) + ; ) + ; (b! (zero? (logand (-> (the-as terrain-context v1-36) bsp lev-index) 256)) cfg-9 :delay (nop!)) + ; (let ((a1-6 (-> (the-as generic-envmap-saves a0-19) index-mask x))) + ; (nop!) + ; (let ((a2-1 (-> (the-as (pointer int32) v1-36) 0))) + ; (nop!) + ; (let ((a2-2 (logand a2-1 256)) + ; (a1-7 (+ a1-6 1)) + ; ) + ; (b! (nonzero? a2-2) cfg-8 :delay (s.w! (the-as int a0-19) a1-7)) + ; ) + ; ) + ; ) + ; ) + ; (label cfg-9) + ; 0 + (with-dma-buffer-add-bucket ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (-> sink bucket)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (generic-work-init sink) (set! (-> (scratchpad-object terrain-context) work foreground generic-work saves basep) + (the-as uint (-> global-buf base))) (generic-merc-execute-asm) (set! (-> global-buf base) + (the-as pointer + (-> (scratchpad-object terrain-context) work foreground generic-work saves basep)))) ; (let ((v1-44 (-> dma-buf base))) ; (.sync.l) ; (.cache dxwbin v1-44 0) diff --git a/goal_src/jak1/engine/gfx/generic/generic-vu1.gc b/goal_src/jak1/engine/gfx/generic/generic-vu1.gc index 76e3e41131..d57e2e79bc 100644 --- a/goal_src/jak1/engine/gfx/generic/generic-vu1.gc +++ b/goal_src/jak1/engine/gfx/generic/generic-vu1.gc @@ -1345,10 +1345,10 @@ :abe alpha-blend))) (set! (-> constants giftag regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))) - (set! (-> constants hvdf-offset quad) (-> *math-camera* hvdf-off quad)) - (set! (-> constants hmge-scale quad) (-> *math-camera* hmge-scale quad)) - (set! (-> constants invh-scale quad) (-> *math-camera* inv-hmge-scale quad)) - (set! (-> constants guard quad) (-> *math-camera* guard quad)) + (vector-copy! (-> constants hvdf-offset) (-> *math-camera* hvdf-off)) + (vector-copy! (-> constants hmge-scale) (-> *math-camera* hmge-scale)) + (vector-copy! (-> constants invh-scale) (-> *math-camera* inv-hmge-scale)) + (vector-copy! (-> constants guard) (-> *math-camera* guard)) (set! (-> constants adnop dword 0) (the-as uint #x5026b)) (set! (-> constants adnop dword 1) (the-as uint 71)) (set! (-> constants flush dword 0) (the-as uint #x3f80000080808080)) diff --git a/goal_src/jak1/engine/gfx/math-camera.gc b/goal_src/jak1/engine/gfx/math-camera.gc index bdf65daf9b..d97c92e05c 100644 --- a/goal_src/jak1/engine/gfx/math-camera.gc +++ b/goal_src/jak1/engine/gfx/math-camera.gc @@ -215,7 +215,7 @@ (set-vector! (-> math-cam sprite-2d vector 1) 0.0 (- (* (/ persp-yy persp-xx) persp-x)) 0.0 0.0) (set-vector! (-> math-cam sprite-2d vector 2) 0.0 0.0 (- persp-x) 0.0) (set-vector! (-> math-cam sprite-2d vector 3) 0.0 0.0 (* 500000000.0 persp-x) (* 60.0 persp-x (-> math-cam pfog0)))) - (set! (-> math-cam sprite-2d-hvdf quad) (-> math-cam hvdf-off quad)) + (vector-copy! (-> math-cam sprite-2d-hvdf) (-> math-cam hvdf-off)) (set! (-> math-cam sprite-2d-hvdf x) 2048.0) (set! (-> math-cam sprite-2d-hvdf y) 2048.0) (set! (-> math-cam sprite-2d-hvdf z) (-> math-cam hvdf-off z)) diff --git a/goal_src/jak1/engine/gfx/merc/merc.gc b/goal_src/jak1/engine/gfx/merc/merc.gc index e97d431b2e..8dd9539930 100644 --- a/goal_src/jak1/engine/gfx/merc/merc.gc +++ b/goal_src/jak1/engine/gfx/merc/merc.gc @@ -118,7 +118,7 @@ (inspect (-> this effect effect-index))) this) -(defmethod mem-usage ((this merc-ctrl) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this merc-ctrl) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the base art data, packed fragment control and geometry, blend targets, and eye animation owned by this MERC asset." ;; do extra @@ -135,11 +135,7 @@ (* (-> fctrl fp-qwc) 16) (asize-of fctrl))) (set! fctrl (the-as merc-fragment-control (&+ (the-as pointer fctrl) (asize-of fctrl))))))) - (set! (-> usage length) (max 76 (-> usage length))) - (set! (-> usage data 75 name) "merc-ctrl") - (+! (-> usage data 75 count) 1) - (+! (-> usage data 75 used) ctrl-mem) - (+! (-> usage data 75 total) (logand -16 (+ ctrl-mem 15)))) + (mem-usage-add! usage merc-ctrl 1 ctrl-mem)) ;; do effect blend shapes (let ((effect-mem 0)) (dotimes (effect-idx2 (the-as int (-> this header effect-count))) @@ -153,20 +149,11 @@ (set! effect-mem (the-as int (+ (-> this header blend-target-count) 2 size-through-target-data)))) (set! bctrl (the-as merc-blend-ctrl (&+ (the-as pointer bctrl) (+ (-> this header blend-target-count) 2)))))))) (when (nonzero? effect-mem) - (set! (-> usage length) (max 78 (-> usage length))) - (set! (-> usage data 77 name) "blend-shape") - (+! (-> usage data 77 count) 1) - (+! (-> usage data 77 used) effect-mem) - (+! (-> usage data 77 total) (logand -16 (+ effect-mem 15))))) + (mem-usage-add! usage blend-shape 1 effect-mem))) ;; do eyes. (when (nonzero? (-> this header eye-ctrl)) (let ((eye-ctrl (-> this header eye-ctrl))) - (set! (-> usage length) (max 109 (-> usage length))) - (set! (-> usage data 108 name) "eye-anim") - (+! (-> usage data 108 count) 1) - (let ((eye-bytes (asize-of eye-ctrl))) - (+! (-> usage data 108 used) eye-bytes) - (+! (-> usage data 108 total) (logand -16 (+ eye-bytes 15)))))) + (mem-usage-add! usage eye-anim 1 (asize-of eye-ctrl)))) this) (defmethod login ((this merc-ctrl)) @@ -315,7 +302,7 @@ (set! (-> low-memory tri-strip-gif word 3) (shr (make-u128 0 (shl #x303e4000 32)) 32)) (set! (-> low-memory ad-gif tag) (new 'static 'gif-tag64 :nloop #x5 :nreg #x1)) (set! (-> low-memory ad-gif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) - (set! (-> low-memory hvdf-offset quad) (-> *math-camera* hvdf-off quad)) + (vector-copy! (-> low-memory hvdf-offset) (-> *math-camera* hvdf-off)) (quad-copy! (-> low-memory perspective) (the-as pointer (-> *math-camera* perspective)) 4) (set-vector! (-> low-memory fog) (-> *math-camera* pfog0) (-> *math-camera* fog-min) (-> *math-camera* fog-max) 0.0)) ;; Run the per-frame initialization entry after the constants arrive. diff --git a/goal_src/jak1/engine/gfx/mood/mood.gc b/goal_src/jak1/engine/gfx/mood/mood.gc index 9380ebba07..9c3b5a8eff 100644 --- a/goal_src/jak1/engine/gfx/mood/mood.gc +++ b/goal_src/jak1/engine/gfx/mood/mood.gc @@ -18,7 +18,7 @@ (defun update-light-kit ((group light-group) (source-light light) (level float)) "Copy source-light's color into group's ambient light and apply level to its intensity." - (set! (-> group ambi color quad) (-> source-light color quad)) + (vector-copy! (-> group ambi color) (-> source-light color)) (set! (-> group ambi levels x) (* (-> source-light levels x) level)) (none)) @@ -264,7 +264,7 @@ (set! (-> context current-prt-color w) (* 0.5 (+ (-> ambient-color w) (* 0.5 (+ (-> ambient-color w) (-> directional-color w))))))) (let ((shadow-color (-> context current-shadow-color))) - (set! (-> shadow-color quad) (-> context current-prt-color quad)) + (vector-copy! shadow-color (-> context current-prt-color)) shadow-color)) (defun update-mood-palette ((context mood-context) (hour float) (level-index int)) @@ -291,10 +291,10 @@ ((= snapshot-a-index snapshot-b-index) (let ((snapshot (-> context mood-lights-table data snapshot-a-index))) (set! (-> context times snapshot-a-index w) 1.0) - (set! (-> context current-prt-color quad) (-> snapshot prt-color quad)) + (vector-copy! (-> context current-prt-color) (-> snapshot prt-color)) (set! (-> groups 0 ambi color quad) (-> snapshot amb-color quad)) (set! (-> groups 0 ambi levels x) 1.0) - (set! (-> context current-shadow quad) (-> snapshot shadow quad)) + (vector-copy! (-> context current-shadow) (-> snapshot shadow)) (let ((color-level (+ (* 2.0 (-> snapshot lgt-color x)) (* 4.0 (-> snapshot lgt-color y)) (-> snapshot lgt-color z)))) (set! (-> groups 0 dir0 direction quad) (-> snapshot direction quad)) (set! (-> groups 0 dir0 color quad) (-> snapshot lgt-color quad)) @@ -352,7 +352,7 @@ (cond ((= snapshot-a-index snapshot-b-index) (set! (-> context sky-times snapshot-a-index) 1.0) - (set! (-> context current-sun sun-color quad) (-> context mood-sun-table data snapshot-a-index sun-color quad)) + (vector-copy! (-> context current-sun sun-color) (-> context mood-sun-table data snapshot-a-index sun-color)) (let ((environment-color (-> context current-sun env-color))) (set! (-> environment-color quad) (-> (the-as (pointer uint128) (+ (the-as uint (-> context mood-sun-table data 0 env-color)) (* snapshot-a-index 32))))) @@ -394,14 +394,14 @@ sky-index, and light-index select their respective tables; level-index selects the active level's time-of-day mask." (let ((groups (-> context light-group))) - (set! (-> context current-fog fog-color quad) (-> context mood-fog-table data fog-index fog-color quad)) + (vector-copy! (-> context current-fog fog-color) (-> context mood-fog-table data fog-index fog-color)) (set! (-> context current-fog fog-dists quad) (-> (the-as (pointer uint128) (+ (the-as uint (-> context mood-fog-table data 0 fog-dists)) (* 48 fog-index))))) (set! (-> context current-fog erase-color quad) (-> (the-as (pointer uint128) (+ (the-as uint (-> context mood-fog-table data 0 erase-color)) (* 48 fog-index))))) (set! (-> context current-prt-color quad) (-> (the-as (pointer uint128) (+ (the-as uint (-> context mood-lights-table data 0 prt-color)) (* 80 light-index))))) - (set! (-> context current-sun sun-color quad) (-> context mood-sun-table data sky-index sun-color quad)) + (vector-copy! (-> context current-sun sun-color) (-> context mood-sun-table data sky-index sun-color)) (set! (-> context current-sun env-color quad) (-> (the-as (pointer uint128) (+ (the-as uint (-> context mood-sun-table data 0 env-color)) (* sky-index 32))))) (set! (-> context current-shadow quad) @@ -429,24 +429,24 @@ writing result. Exact endpoints are copied directly." (cond ((= blend 0.0) - (set! (-> result current-fog fog-color quad) (-> context-a current-fog fog-color quad)) - (set! (-> result current-fog fog-dists quad) (-> context-a current-fog fog-dists quad)) - (set! (-> result current-fog erase-color quad) (-> context-a current-fog erase-color quad)) - (set! (-> result current-prt-color quad) (-> context-a current-prt-color quad)) - (set! (-> result current-sun sun-color quad) (-> context-a current-sun sun-color quad)) - (set! (-> result current-sun env-color quad) (-> context-a current-sun env-color quad)) - (set! (-> result current-shadow quad) (-> context-a current-shadow quad)) - (set! (-> result current-shadow-color quad) (-> context-a current-shadow-color quad)) + (vector-copy! (-> result current-fog fog-color) (-> context-a current-fog fog-color)) + (vector-copy! (-> result current-fog fog-dists) (-> context-a current-fog fog-dists)) + (vector-copy! (-> result current-fog erase-color) (-> context-a current-fog erase-color)) + (vector-copy! (-> result current-prt-color) (-> context-a current-prt-color)) + (vector-copy! (-> result current-sun sun-color) (-> context-a current-sun sun-color)) + (vector-copy! (-> result current-sun env-color) (-> context-a current-sun env-color)) + (vector-copy! (-> result current-shadow) (-> context-a current-shadow)) + (vector-copy! (-> result current-shadow-color) (-> context-a current-shadow-color)) (quad-copy! (the-as pointer (-> result light-group)) (the-as pointer (-> context-a light-group)) 12)) ((= blend 1.0) - (set! (-> result current-fog fog-color quad) (-> context-b current-fog fog-color quad)) - (set! (-> result current-fog fog-dists quad) (-> context-b current-fog fog-dists quad)) - (set! (-> result current-fog erase-color quad) (-> context-b current-fog erase-color quad)) - (set! (-> result current-prt-color quad) (-> context-b current-prt-color quad)) - (set! (-> result current-sun sun-color quad) (-> context-b current-sun sun-color quad)) - (set! (-> result current-sun env-color quad) (-> context-b current-sun env-color quad)) - (set! (-> result current-shadow quad) (-> context-b current-shadow quad)) - (set! (-> result current-shadow-color quad) (-> context-b current-shadow-color quad)) + (vector-copy! (-> result current-fog fog-color) (-> context-b current-fog fog-color)) + (vector-copy! (-> result current-fog fog-dists) (-> context-b current-fog fog-dists)) + (vector-copy! (-> result current-fog erase-color) (-> context-b current-fog erase-color)) + (vector-copy! (-> result current-prt-color) (-> context-b current-prt-color)) + (vector-copy! (-> result current-sun sun-color) (-> context-b current-sun sun-color)) + (vector-copy! (-> result current-sun env-color) (-> context-b current-sun env-color)) + (vector-copy! (-> result current-shadow) (-> context-b current-shadow)) + (vector-copy! (-> result current-shadow-color) (-> context-b current-shadow-color)) (quad-copy! (the-as pointer (-> result light-group)) (the-as pointer (-> context-b light-group)) 12)) (else (vector4-lerp! (-> result current-fog fog-color) @@ -644,8 +644,8 @@ (let* ((snapshot (-> context mood-lights-table data light-slot)) (directional (-> context light-group 0 dir2)) (color-level (* (+ (* 2.0 (-> snapshot lgt-color x)) (* 4.0 (-> snapshot lgt-color y)) (-> snapshot lgt-color z)) brightness))) - (set! (-> directional direction quad) (-> snapshot direction quad)) - (set! (-> directional color quad) (-> snapshot lgt-color quad)) + (vector-copy! (-> directional direction) (-> snapshot direction)) + (vector-copy! (-> directional color) (-> snapshot lgt-color)) (set! (-> directional levels x) brightness) (set! (-> directional levels y) color-level)) (set! *lightning-realtime-done* #t)))) @@ -871,8 +871,8 @@ (let ((group (-> context light-group 1))) (update-light-kit group (-> context light-group 0 ambi) 0.9)) (let ((group (-> context light-group 2))) (update-light-kit group (-> context light-group 0 ambi) 1.0) - (set! (-> group dir2 direction quad) (-> context light-group 0 dir2 direction quad)) - (set! (-> group dir2 color quad) (-> context light-group 0 dir2 color quad)) + (vector-copy! (-> group dir2 direction) (-> context light-group 0 dir2 direction)) + (vector-copy! (-> group dir2 color) (-> context light-group 0 dir2 color)) (set! (-> group dir2 levels x) (-> context light-group 0 dir2 levels x))) (let ((group (-> context light-group 3))) (update-light-kit group (-> context light-group 0 ambi) 1.0) @@ -891,13 +891,13 @@ (set-vector! direction 1212416.0 110592.0 -6680576.0 0.0) (vector-! direction direction target-position) (vector-normalize! direction 1.0) - (set! (-> local-group dir0 direction quad) (-> direction quad)) + (vector-copy! (-> local-group dir0 direction) direction) (set! (-> local-group dir0 levels x) (+ 0.666 (* 0.333 (-> context times 4 w)))) (set-vector! direction 1384448.0 (-> target-position y) -6688768.0 0.0) (let ((distance (vector-vector-distance direction target-position))) (vector-! direction direction target-position) (vector-normalize! direction 1.0) - (set! (-> local-group dir1 direction quad) (-> direction quad)) + (vector-copy! (-> local-group dir1 direction) direction) (when (< distance 180224.0) (new 'stack-no-clear 'vector) (let ((fade (* 0.0000110973015 (+ -90112.0 distance)))) @@ -1122,7 +1122,7 @@ (update-mood-quick context 0 0 0 level-index) (let ((group (-> context light-group 1))) (quad-copy! (the-as pointer group) (the-as pointer (-> context light-group)) 12) - (set! (-> group dir2 color quad) (the-as uint128 0)) + (vector-zero! (-> group dir2 color)) (set! (-> group dir2 levels x) 0.0)) (let ((group (-> context light-group 2))) (quad-copy! (the-as pointer group) (the-as pointer (-> context light-group)) 12) @@ -1477,7 +1477,7 @@ (warm-ambient (new 'static 'vector :y 1.0 :z 0.5 :w 1.0)) (base-ambient (new 'static 'vector :x 0.3 :y 0.4 :z 0.5 :w 1.0))) (vector-lerp! (-> context mood-lights-table data 0 amb-color) base-ambient warm-ambient ambient-blend)) - (set! (-> context mood-lights-table data 0 prt-color quad) (-> context mood-lights-table data 0 amb-color quad)) + (vector-copy! (-> context mood-lights-table data 0 prt-color) (-> context mood-lights-table data 0 amb-color)) (vector-normalize! light-direction 1.0) (let ((shadow-direction (-> context mood-lights-table data 0 shadow))) (set! (-> shadow-direction x) (- (-> light-direction x))) @@ -1778,7 +1778,7 @@ (set! (-> groups 0 ambi direction quad) (-> phase-groups 0 ambi direction quad)) (set! (-> groups 0 ambi color quad) (-> phase-groups 0 ambi color quad)) (set! (-> groups 0 ambi levels quad) (-> phase-groups 0 ambi levels quad)) - (set! (-> context current-shadow quad) (-> *ogre2-mood* current-shadow quad))) + (vector-copy! (-> context current-shadow) (-> *ogre2-mood* current-shadow))) (else (vector4-lerp! (the-as vector (-> groups 0)) (the-as vector (-> phase-groups 0)) @@ -1816,10 +1816,10 @@ (set! (-> groups 0 ambi direction quad) (-> phase-groups 0 ambi direction quad)) (set! (-> groups 0 ambi color quad) (-> phase-groups 0 ambi color quad)) (set! (-> groups 0 ambi levels quad) (-> phase-groups 0 ambi levels quad)) - (set! (-> context current-shadow quad) (-> *ogre3-mood* current-shadow quad)) - (set! (-> context current-fog fog-color quad) (-> *ogre3-mood* current-fog fog-color quad)) - (set! (-> context current-fog fog-dists quad) (-> *ogre3-mood* current-fog fog-dists quad)) - (set! (-> context current-fog erase-color quad) (-> *ogre3-mood* current-fog erase-color quad))) + (vector-copy! (-> context current-shadow) (-> *ogre3-mood* current-shadow)) + (vector-copy! (-> context current-fog fog-color) (-> *ogre3-mood* current-fog fog-color)) + (vector-copy! (-> context current-fog fog-dists) (-> *ogre3-mood* current-fog fog-dists)) + (vector-copy! (-> context current-fog erase-color) (-> *ogre3-mood* current-fog erase-color))) (else (vector4-lerp! (the-as vector (-> groups 0)) (the-as vector (-> phase-groups 0)) diff --git a/goal_src/jak1/engine/gfx/mood/time-of-day.gc b/goal_src/jak1/engine/gfx/mood/time-of-day.gc index e14e881047..72e6dd1957 100644 --- a/goal_src/jak1/engine/gfx/mood/time-of-day.gc +++ b/goal_src/jak1/engine/gfx/mood/time-of-day.gc @@ -658,14 +658,14 @@ ;; Exact endpoints can copy the complete mood directly. ((= current-blend 0.0) (let ((level0-fog (-> context moods 0 current-fog))) - (set! (-> current-fog fog-color quad) (-> level0-fog fog-color quad)) - (set! (-> current-fog fog-dists quad) (-> level0-fog fog-dists quad)) - (set! (-> current-fog erase-color quad) (-> level0-fog erase-color quad))) - (set! (-> context current-prt-color quad) (-> context moods 0 current-prt-color quad)) - (set! (-> context current-sun sun-color quad) (-> context moods 0 current-sun sun-color quad)) - (set! (-> context current-sun env-color quad) (-> context moods 0 current-sun env-color quad)) - (set! (-> context current-shadow quad) (-> context moods 0 current-shadow quad)) - (set! (-> context current-shadow-color quad) (-> context moods 0 current-shadow-color quad)) + (vector-copy! (-> current-fog fog-color) (-> level0-fog fog-color)) + (vector-copy! (-> current-fog fog-dists) (-> level0-fog fog-dists)) + (vector-copy! (-> current-fog erase-color) (-> level0-fog erase-color))) + (vector-copy! (-> context current-prt-color) (-> context moods 0 current-prt-color)) + (vector-copy! (-> context current-sun sun-color) (-> context moods 0 current-sun sun-color)) + (vector-copy! (-> context current-sun env-color) (-> context moods 0 current-sun env-color)) + (vector-copy! (-> context current-shadow) (-> context moods 0 current-shadow)) + (vector-copy! (-> context current-shadow-color) (-> context moods 0 current-shadow-color)) (dotimes (group-index 8) (quad-copy! (the-as pointer (-> context light-group group-index)) (the-as pointer (-> context moods 0 light-group group-index)) @@ -674,14 +674,14 @@ (set! (-> context sun-fade) (-> *level* level0 info sun-fade))) ((= current-blend 1.0) (let ((level1-fog (-> context moods 1 current-fog))) - (set! (-> current-fog fog-color quad) (-> level1-fog fog-color quad)) - (set! (-> current-fog fog-dists quad) (-> level1-fog fog-dists quad)) - (set! (-> current-fog erase-color quad) (-> level1-fog erase-color quad))) - (set! (-> context current-prt-color quad) (-> context moods 1 current-prt-color quad)) - (set! (-> context current-sun sun-color quad) (-> context moods 1 current-sun sun-color quad)) - (set! (-> context current-sun env-color quad) (-> context moods 1 current-sun env-color quad)) - (set! (-> context current-shadow quad) (-> context moods 1 current-shadow quad)) - (set! (-> context current-shadow-color quad) (-> context moods 1 current-shadow-color quad)) + (vector-copy! (-> current-fog fog-color) (-> level1-fog fog-color)) + (vector-copy! (-> current-fog fog-dists) (-> level1-fog fog-dists)) + (vector-copy! (-> current-fog erase-color) (-> level1-fog erase-color))) + (vector-copy! (-> context current-prt-color) (-> context moods 1 current-prt-color)) + (vector-copy! (-> context current-sun sun-color) (-> context moods 1 current-sun sun-color)) + (vector-copy! (-> context current-sun env-color) (-> context moods 1 current-sun env-color)) + (vector-copy! (-> context current-shadow) (-> context moods 1 current-shadow)) + (vector-copy! (-> context current-shadow-color) (-> context moods 1 current-shadow-color)) (dotimes (group-index 8) (quad-copy! (the-as pointer (-> context light-group group-index)) (the-as pointer (-> context moods 1 light-group group-index)) @@ -762,18 +762,18 @@ ;; the current erase color so it meets the clear without a seam. (dotimes (i 2) (make-sky-textures context i)) - (set! (-> sky-base-polygons 0 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 1 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 2 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 3 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 4 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 5 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 6 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 7 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 8 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 9 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 10 col quad) (-> current-fog erase-color quad)) - (set! (-> sky-base-polygons 11 col quad) (-> current-fog erase-color quad))))) + (vector-copy! (-> sky-base-polygons 0 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 1 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 2 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 3 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 4 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 5 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 6 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 7 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 8 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 9 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 10 col) (-> current-fog erase-color)) + (vector-copy! (-> sky-base-polygons 11 col) (-> current-fog erase-color))))) ;; The GS treats 128 as a 1.0 texture-modulation component. Convert the authored 0..255 ;; environment color into that scale before it is packed for rendering. @@ -859,7 +859,7 @@ ((and (>= index 0) (< index 8)) (let ((control (-> this control index))) (when (< actor-distance (-> control actor-dist)) - (if trans (set! (-> control trans quad) (-> trans quad))) + (if trans (vector-copy! (-> control trans) trans)) (set! (-> control fade) (fmax 0.0 (fmin 1.993 fade))) (set! (-> control actor-dist) actor-distance)))) (else (format 0 "ERROR: Bogus palette-fade-control index!~%")))) diff --git a/goal_src/jak1/engine/gfx/ocean/ocean-mid.gc b/goal_src/jak1/engine/gfx/ocean/ocean-mid.gc index 67e83dec71..2660d68081 100644 --- a/goal_src/jak1/engine/gfx/ocean/ocean-mid.gc +++ b/goal_src/jak1/engine/gfx/ocean/ocean-mid.gc @@ -163,9 +163,9 @@ wireframe and 2 draws untextured Gouraud shading." ;; the usual camera math (let ((math-cam *math-camera*)) - (set! (-> dst hmge-scale quad) (-> math-cam hmge-scale quad)) - (set! (-> dst inv-hmge-scale quad) (-> math-cam inv-hmge-scale quad)) - (set! (-> dst hvdf-offset quad) (-> math-cam hvdf-off quad)) + (vector-copy! (-> dst hmge-scale) (-> math-cam hmge-scale)) + (vector-copy! (-> dst inv-hmge-scale) (-> math-cam inv-hmge-scale)) + (vector-copy! (-> dst hvdf-offset) (-> math-cam hvdf-off)) (set-vector! (-> dst fog) (-> math-cam pfog0) (-> math-cam fog-min) (-> math-cam fog-max) 3072.0)) ;; xy scale and offset for the environment-map texture coordinates, and the cell size the ;; microprogram steps the corner lattice by. @@ -376,7 +376,7 @@ :nreg #x3))))) (set! (-> dst env-strip regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))) - (set! (-> dst env-color quad) (-> *time-of-day-context* current-sun env-color quad)) + (vector-copy! (-> dst env-color) (-> *time-of-day-context* current-sun env-color)) ;; Per-row VU addresses for the eight strips of a block, ordered from the last row back to the ;; first. The middle lane steps by the twelve-quadword color row. (set-vector! (-> dst index-table 0) 63 84 66 0) @@ -504,16 +504,7 @@ qwc)) (set! (-> buf base) (&+ (the-as pointer packet) 16))) (let ((rot-dst (-> dma-buf base))) - (let* ((rot-mat (the-as object rot-dst)) - (cam-rot (-> *math-camera* camera-rot)) - (row0 (-> cam-rot vector 0 quad)) - (row1 (-> cam-rot vector 1 quad)) - (row2 (-> cam-rot vector 2 quad)) - (row3 (-> cam-rot vector 3 quad))) - (set! (-> (the-as matrix rot-mat) vector 0 quad) row0) - (set! (-> (the-as matrix rot-mat) vector 1 quad) row1) - (set! (-> (the-as matrix rot-mat) vector 2 quad) row2) - (set! (-> (the-as matrix rot-mat) vector 3 quad) row3)) + (matrix-copy! (the-as matrix rot-dst) (-> *math-camera* camera-rot)) ;; only xyz of the translation row is replaced; its w stays as the camera rotation had it. (let ((rot-trans (the-as object (&+ rot-dst 48)))) (vector-matrix*! origin-cam origin (-> *math-camera* camera-rot)) diff --git a/goal_src/jak1/engine/gfx/ocean/ocean-near.gc b/goal_src/jak1/engine/gfx/ocean/ocean-near.gc index b6cd5a8991..a3f61fa086 100644 --- a/goal_src/jak1/engine/gfx/ocean/ocean-near.gc +++ b/goal_src/jak1/engine/gfx/ocean/ocean-near.gc @@ -97,9 +97,9 @@ addresses come from *ocean-base-page* and *ocean-base-block*, so the ocean's VRAM must already be allocated." (let ((camera *math-camera*)) - (set! (-> consts hmge-scale quad) (-> camera hmge-scale quad)) - (set! (-> consts inv-hmge-scale quad) (-> camera inv-hmge-scale quad)) - (set! (-> consts hvdf-offset quad) (-> camera hvdf-off quad)) + (vector-copy! (-> consts hmge-scale) (-> camera hmge-scale)) + (vector-copy! (-> consts inv-hmge-scale) (-> camera inv-hmge-scale)) + (vector-copy! (-> consts hvdf-offset) (-> camera hvdf-off)) (set-vector! (-> consts fog) (-> camera pfog0) (-> camera fog-min) (-> camera fog-max) 3072.0)) ;; w is 1 / (meters 24): a position inside a cell as a fraction of the cell. (set-vector! (-> consts constants) 0.5 0.5 0.0 0.000010172526) @@ -308,7 +308,7 @@ :nreg #x3))))) (set! (-> consts env-strip regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))) - (set! (-> consts env-color quad) (-> *time-of-day-context* current-sun env-color quad)) + (vector-copy! (-> consts env-color) (-> *time-of-day-context* current-sun env-color)) (set! (-> consts drw2-adgif tag) (new 'static 'gif-tag64 :nloop #x2 :eop #x1 :nreg #x1)) (set! (-> consts drw2-adgif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) ;; The second draw pass writes only the framebuffer alpha, so its TEX0 and FRAME @@ -429,16 +429,7 @@ (set! (-> (the-as dma-packet packet) vif1) (new 'static 'vif-tag :imm #x8000 :cmd (vif-cmd unpack-v4-32) :num qwc)) (set! (-> buf base) (the-as pointer (&+ (the-as vector packet) 16)))) (let ((rot (the-as object (-> dma-buf base)))) - (let* ((rot-rows (the-as matrix rot)) - (camera-rot (-> *math-camera* camera-rot)) - (row0 (-> camera-rot vector 0 quad)) - (row1 (-> camera-rot vector 1 quad)) - (row2 (-> camera-rot vector 2 quad)) - (row3 (-> camera-rot vector 3 quad))) - (set! (-> rot-rows vector 0 quad) row0) - (set! (-> rot-rows vector 1 quad) row1) - (set! (-> rot-rows vector 2 quad) row2) - (set! (-> rot-rows vector 3 quad) row3)) + (matrix-copy! (the-as matrix rot) (-> *math-camera* camera-rot)) (let ((rot-trans (the-as object (&+ (the-as pointer rot) 48)))) (vector-matrix*! origin-in-camera cell-origin (-> *math-camera* camera-rot)) (set! (-> (the-as vector rot-trans) x) (-> origin-in-camera x)) diff --git a/goal_src/jak1/engine/gfx/ocean/ocean-transition.gc b/goal_src/jak1/engine/gfx/ocean/ocean-transition.gc index 75d22bc6d2..898b1ef7da 100644 --- a/goal_src/jak1/engine/gfx/ocean/ocean-transition.gc +++ b/goal_src/jak1/engine/gfx/ocean/ocean-transition.gc @@ -412,10 +412,10 @@ (let ((vu-data (the-as (inline-array vector) (-> buf base)))) ;; A strip spans the whole mid cell, so it takes the unit square and the cell's four ;; corner colors unblended; the weight list interpolates them. - (set! (-> vu-data 0 quad) (-> *ocean-trans-st-table* 0 quad)) - (set! (-> vu-data 1 quad) (-> *ocean-trans-st-table* 1 quad)) - (set! (-> vu-data 2 quad) (-> *ocean-trans-st-table* 2 quad)) - (set! (-> vu-data 3 quad) (-> *ocean-trans-st-table* 3 quad)) + (vector-copy! (-> vu-data 0) (-> *ocean-trans-st-table* 0)) + (vector-copy! (-> vu-data 1) (-> *ocean-trans-st-table* 1)) + (vector-copy! (-> vu-data 2) (-> *ocean-trans-st-table* 2)) + (vector-copy! (-> vu-data 3) (-> *ocean-trans-st-table* 3)) (let ((corner-color-0 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ (* OCEAN-COLOR-ROW-STRIDE (the-as int mid-z)) mid-x)))) (corner-color-1 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ mid-x 1 (* OCEAN-COLOR-ROW-STRIDE (the-as int mid-z)))))) (corner-color-2 (the-as uint128 (-> *ocean-map* ocean-colors colors (+ (* OCEAN-COLOR-ROW-STRIDE (the-as int (+ mid-z 1))) mid-x)))) diff --git a/goal_src/jak1/engine/gfx/ocean/ocean.gc b/goal_src/jak1/engine/gfx/ocean/ocean.gc index c2573666c1..24bbf8e1c3 100644 --- a/goal_src/jak1/engine/gfx/ocean/ocean.gc +++ b/goal_src/jak1/engine/gfx/ocean/ocean.gc @@ -575,42 +575,12 @@ (else (set! (-> *ocean-map* start-corner y) (meters -24))))) (when (not *ocean-off*) (when (logtest? *vu1-enable-user* (vu1-renderer-mask ocean)) - (let* ((mid-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (mid-chain-start (-> mid-buf base))) - (draw-ocean-texture mid-buf *ocean-verts* #t) - (ocean-init-buffer mid-buf) - (draw-ocean-far mid-buf) - (when (not *ocean-mid-off*) - (draw-ocean-mid mid-buf)) - (ocean-end-buffer mid-buf) - (let ((mid-chain-end (-> mid-buf base))) - (let ((next-tag (the-as object (-> mid-buf base)))) - (set! (-> (the-as dma-packet next-tag) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-tag) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-tag) vif1) (new 'static 'vif-tag)) - (set! (-> mid-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id ocean-mid-and-far) - mid-chain-start - (the-as (pointer dma-tag) mid-chain-end)))) + (with-dma-buffer-add-bucket ((mid-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id ocean-mid-and-far)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-ocean-texture mid-buf *ocean-verts* #t) (ocean-init-buffer mid-buf) (draw-ocean-far mid-buf) (when (not *ocean-mid-off*) + (draw-ocean-mid mid-buf)) (ocean-end-buffer mid-buf)) ;; The near grid is only worth building from close to the surface, and it inherits the mid ;; grid's suppression masks, so it also goes away when the mid grid is off. (when (not (or *ocean-near-off* (or *ocean-mid-off* (< (meters 48) (fabs (-> *math-camera* trans y)))))) - (let* ((near-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (near-chain-start (-> near-buf base))) - (draw-ocean-texture near-buf *ocean-verts* #f) - (draw-ocean-near near-buf) - (ocean-end-buffer near-buf) - (let ((near-chain-end (-> near-buf base))) - (let ((next-tag (the-as object (-> near-buf base)))) - (set! (-> (the-as dma-packet next-tag) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-tag) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-tag) vif1) (new 'static 'vif-tag)) - (set! (-> near-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id ocean-near) - near-chain-start - (the-as (pointer dma-tag) near-chain-end)))))))) + (with-dma-buffer-add-bucket ((near-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id ocean-near)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-ocean-texture near-buf *ocean-verts* #f) (draw-ocean-near near-buf) (ocean-end-buffer near-buf)))))) (when (not (paused?)) (set! *ocean-off* #f) (set! *ocean-mid-off* #f) diff --git a/goal_src/jak1/engine/gfx/shadow/shadow-cpu.gc b/goal_src/jak1/engine/gfx/shadow/shadow-cpu.gc index dd20dd0342..e6edd86957 100644 --- a/goal_src/jak1/engine/gfx/shadow/shadow-cpu.gc +++ b/goal_src/jak1/engine/gfx/shadow/shadow-cpu.gc @@ -162,14 +162,9 @@ "Return the complete packed shadow geometry size." (the-as int (-> this total-size))) -(defmethod mem-usage ((this shadow-geo) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this shadow-geo) (usage memory-usage-block) (flags mem-usage-flags)) "Charge this packed shadow geometry's used and 16-byte-aligned sizes to usage." - (set! (-> usage length) (max 108 (-> usage length))) - (set! (-> usage data 107 name) "shadow-geo") - (+! (-> usage data 107 count) 1) - (let ((byte-size (-> this total-size))) - (+! (-> usage data 107 used) byte-size) - (+! (-> usage data 107 total) (logand -16 (+ byte-size 15)))) + (mem-usage-add! usage shadow-geo 1 (-> this total-size)) this) (define *shadow-data* @@ -2926,32 +2921,14 @@ (if (nonzero? (-> queue run i first)) (set! has-shadow? #t))) (when has-shadow? (shadow-vu0-upload) - (let* ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (chain-start (-> global-buf base))) - (shadow-vu1-init-buffer global-buf) - (flush-cache 0) - (let ((workspace (the-as shadow-dcache *gsf-buffer*))) - (set! (-> workspace stats num-single-tris) (the-as uint 0)) - (set! (-> workspace stats num-double-tris) (the-as uint 0)) - (set! (-> workspace stats num-single-edges) (the-as uint 0)) - (set! (-> workspace stats num-double-edges) (the-as uint 0))) - 0 - (shadow-dma-init global-buf) - (dotimes (i (the-as int (-> queue cur-run))) - (let ((run (-> queue run i))) - (if (nonzero? (-> run first)) - (set! (-> global-buf base) (shadow-execute (the-as shadow-dma-packet (-> run first)) (-> global-buf base)))))) - (shadow-dma-end global-buf) - (let ((chain-tail (-> global-buf base))) - (let ((next-tag (the-as object (-> global-buf base)))) - (set! (-> (the-as dma-packet next-tag) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-tag) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-tag) vif1) (new 'static 'vif-tag)) - (set! (-> global-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id shadow) - chain-start - (the-as (pointer dma-tag) chain-tail)))))) + (with-dma-buffer-add-bucket ((global-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id shadow)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (shadow-vu1-init-buffer global-buf) (flush-cache 0) (let ((workspace (the-as shadow-dcache *gsf-buffer*))) + (set! (-> workspace stats num-single-tris) (the-as uint 0)) + (set! (-> workspace stats num-double-tris) (the-as uint 0)) + (set! (-> workspace stats num-single-edges) (the-as uint 0)) + (set! (-> workspace stats num-double-edges) (the-as uint 0))) 0 (shadow-dma-init global-buf) (dotimes (i (the-as int (-> queue cur-run))) + (let ((run (-> queue run i))) + (if (nonzero? (-> run first)) + (set! (-> global-buf base) (shadow-execute (the-as shadow-dma-packet (-> run first)) (-> global-buf base)))))) (shadow-dma-end global-buf)))) (when #f (let ((workspace (the-as structure *gsf-buffer*))) (format *stdcon* "#single tris : ~4d~%" (-> (the-as shadow-dcache workspace) stats num-single-tris)) @@ -2982,7 +2959,7 @@ (let ((hit (new 'stack-no-clear 'collide-tri-result)) (ray-start (new 'stack-no-clear 'vector)) (ray (new 'stack-no-clear 'vector))) - (set! (-> ray-start quad) (-> origin quad)) + (vector-copy! ray-start origin) (set! (-> ray-start y) (+ 4096.0 (-> ray-start y))) (set-vector! ray 0.0 (- cast-length) 0.0 1.0) (cond diff --git a/goal_src/jak1/engine/gfx/shadow/shadow-vu1.gc b/goal_src/jak1/engine/gfx/shadow/shadow-vu1.gc index 9fa3579d3c..321cbaed1b 100644 --- a/goal_src/jak1/engine/gfx/shadow/shadow-vu1.gc +++ b/goal_src/jak1/engine/gfx/shadow/shadow-vu1.gc @@ -1097,14 +1097,14 @@ (camera *math-camera*) (shadow-state *shadow-data*) (tri-template *shadow-vu1-tri-template*)) - (set! (-> (the-as shadow-vu1-constants constants) hmgescale quad) (-> camera hmge-scale quad)) - (set! (-> (the-as shadow-vu1-constants constants) invhscale quad) (-> camera inv-hmge-scale quad)) - (set! (-> (the-as shadow-vu1-constants constants) texoffset quad) (-> shadow-state texoffset quad)) - (set! (-> (the-as shadow-vu1-constants constants) texscale quad) (-> shadow-state texscale quad)) - (set! (-> (the-as shadow-vu1-constants constants) hvdfoff quad) (-> camera hvdf-off quad)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) hmgescale) (-> camera hmge-scale)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) invhscale) (-> camera inv-hmge-scale)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) texoffset) (-> shadow-state texoffset)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) texscale) (-> shadow-state texscale)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) hvdfoff) (-> camera hvdf-off)) (set! (-> (the-as shadow-vu1-constants constants) fog x) (-> camera pfog0)) - (set! (-> (the-as shadow-vu1-constants constants) clrs 0 quad) (-> shadow-state clrs 0 quad)) - (set! (-> (the-as shadow-vu1-constants constants) clrs 1 quad) (-> shadow-state clrs 1 quad)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) clrs 0) (-> shadow-state clrs 0)) + (vector-copy! (-> (the-as shadow-vu1-constants constants) clrs 1) (-> shadow-state clrs 1)) (set! (-> (the-as shadow-vu1-constants constants) adgif qword) (-> tri-template adgif qword)) (set! (-> (the-as shadow-vu1-constants constants) texflush quad) (-> tri-template ad quad)) (set! (-> (the-as shadow-vu1-constants constants) flush quad) (-> tri-template flush quad)) @@ -1151,14 +1151,7 @@ (set! (-> (the-as dma-packet upload-packet) vif1) (new 'static 'vif-tag :cmd (vif-cmd unpack-v4-32) :num qwc)) (set! (-> packet-buffer base) (the-as pointer (&+ (the-as dma-packet upload-packet) 16))))) (let ((matrix-out (the-as object (-> dma-buf base)))) - (let ((right (-> camera perspective vector 0 quad)) - (up (-> camera perspective vector 1 quad)) - (forward (-> camera perspective vector 2 quad)) - (translation (-> camera perspective vector 3 quad))) - (set! (-> (the-as matrix matrix-out) vector 0 quad) right) - (set! (-> (the-as matrix matrix-out) vector 1 quad) up) - (set! (-> (the-as matrix matrix-out) vector 2 quad) forward) - (set! (-> (the-as matrix matrix-out) vector 3 quad) translation)) + (matrix-copy! (the-as matrix matrix-out) (-> camera perspective)) (set! (-> dma-buf base) (the-as pointer (&+ (the-as matrix matrix-out) 64)))) (none)) diff --git a/goal_src/jak1/engine/gfx/shadow/shadow.gc b/goal_src/jak1/engine/gfx/shadow/shadow.gc index feef97b5cb..a9345c50f7 100644 --- a/goal_src/jak1/engine/gfx/shadow/shadow.gc +++ b/goal_src/jak1/engine/gfx/shadow/shadow.gc @@ -142,7 +142,7 @@ a caster over water keeps the reference point it already had, and it is placed at the bottom of the probe range when nothing was hit at all." (let ((probe-origin (new 'stack-no-clear 'vector))) - (set! (-> probe-origin quad) (-> pos quad)) + (vector-copy! probe-origin pos) ;; a second stack vector is reserved here and never used (new 'stack-no-clear 'vector) (+! (-> probe-origin y) probe-y-offset) @@ -164,7 +164,7 @@ probe-length (the-as float 0))) (if (and ground-pos (!= (-> hit pat material) (pat-material waterbottom))) - (set! (-> ground-pos quad) (-> hit intersect quad)))) + (vector-copy! ground-pos (-> hit intersect)))) (else (if ground-pos (vector+float*! ground-pos pos (-> *standard-dynamics* gravity-normal) (- probe-length))))))) 0 (none)) @@ -179,7 +179,7 @@ (!= (-> self control mod-surface mode) 'dive) (!= (-> self next-state name) 'target-flop) (not (logtest? (-> self draw status) (draw-status hidden no-anim skip-bones)))) - (set! (-> self control shadow-pos quad) (-> self control trans quad)) + (vector-copy! (-> self control shadow-pos) (-> self control trans)) (find-ground-and-draw-shadow (-> self control trans) (-> self control shadow-pos) 0.0 diff --git a/goal_src/jak1/engine/gfx/shrub/shrub-work.gc b/goal_src/jak1/engine/gfx/shrub/shrub-work.gc index 080e8f33c8..072a35d4e6 100644 --- a/goal_src/jak1/engine/gfx/shrub/shrub-work.gc +++ b/goal_src/jak1/engine/gfx/shrub/shrub-work.gc @@ -525,16 +525,7 @@ (set! (-> (the-as dma-packet matrix-packet) vif1) (new 'static 'vif-tag :num #x6 :cmd (vif-cmd unpack-v4-32) :imm (shr (shl matrix-vu-address 54) 54))) (set! (-> dma-state base) (&+ (the-as pointer matrix-packet) 16))) - (let* ((matrix-dst (the-as matrix (-> dma-buf base))) - (camera-temp (-> *math-camera* camera-temp)) - (row-0 (-> camera-temp vector 0 quad)) - (row-1 (-> camera-temp vector 1 quad)) - (row-2 (-> camera-temp vector 2 quad)) - (row-3 (-> camera-temp vector 3 quad))) - (set! (-> matrix-dst vector 0 quad) row-0) - (set! (-> matrix-dst vector 1 quad) row-1) - (set! (-> matrix-dst vector 2 quad) row-2) - (set! (-> matrix-dst vector 3 quad) row-3)) + (matrix-copy! (the-as matrix (-> dma-buf base)) (-> *math-camera* camera-temp)) (&+! (-> dma-buf base) 64) ;; Entry 10 expects the camera rows followed by (1, 1, 1, 128) and ;; (vertex-count, 0, 0, 0). diff --git a/goal_src/jak1/engine/gfx/shrub/shrubbery.gc b/goal_src/jak1/engine/gfx/shrub/shrubbery.gc index d84454822a..32b044e794 100644 --- a/goal_src/jak1/engine/gfx/shrub/shrubbery.gc +++ b/goal_src/jak1/engine/gfx/shrub/shrubbery.gc @@ -99,25 +99,15 @@ (adgif-shader-login (-> this flat)) this) -(defmethod mem-usage ((this billboard) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this billboard) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this billboard's inline storage." - (set! (-> usage length) (max 34 (-> usage length))) - (set! (-> usage data 33 name) "billboard") - (+! (-> usage data 33 count) 1) - (let ((byte-size (asize-of this))) - (+! (-> usage data 33 used) byte-size) - (+! (-> usage data 33 total) (logand -16 (+ byte-size 15)))) + (mem-usage-add! usage billboard 1 (asize-of this)) this) -(defun-recursive mem-usage-shrub-walk draw-node ((nodes draw-node) (node-count int) (usage memory-usage-block) (flags int)) +(defun-recursive mem-usage-shrub-walk draw-node ((nodes draw-node) (node-count int) (usage memory-usage-block) (flags mem-usage-flags)) "Recursively account for node storage and leaf instance-shrubbery records across node-count contiguous shrub BVH roots. flags is forwarded for the memory-usage traversal." - (set! (-> usage length) (max 62 (-> usage length))) - (set! (-> usage data 61 name) "draw-node") - (+! (-> usage data 61 count) node-count) - (let ((node-bytes (* node-count 32))) - (+! (-> usage data 61 used) node-bytes) - (+! (-> usage data 61 total) (logand -16 (+ node-bytes 15)))) + (mem-usage-add! usage draw-node node-count (* node-count 32)) (let ((node nodes)) (dotimes (i node-count) (let ((child-count (-> node child-count))) @@ -125,38 +115,23 @@ ((logtest? (-> node flags) (draw-node-flags children-are-draw-nodes)) (mem-usage-shrub-walk (the-as draw-node (-> node child)) (the-as int child-count) usage flags)) (else - (set! (-> usage length) (max 35 (-> usage length))) - (set! (-> usage data 34 name) "instance-shrubbery") - (+! (-> usage data 34 count) child-count) - (let ((instance-bytes (* (the-as uint 80) child-count))) - (+! (-> usage data 34 used) instance-bytes) - (+! (-> usage data 34 total) (logand -16 (+ instance-bytes 15))))))) + (mem-usage-add! usage instance-shrubbery child-count (* (the-as uint 80) child-count))))) (&+! node 32))) nodes) -(defmethod mem-usage ((this drawable-tree-instance-shrub) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-tree-instance-shrub) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the tree header, optional time-of-day palette, recursive draw-node hierarchy, and prototype array." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((tree-header-bytes 32)) - (+! (-> usage data 0 used) tree-header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ tree-header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) ;; Time-of-day colors are allocated separately from the tree. (when (nonzero? (-> this colors-added)) - (set! (-> usage length) (max 33 (-> usage length))) - (set! (-> usage data 32 name) "shrubbery-pal") - (+! (-> usage data 32 count) 1) - (let ((palette-bytes (asize-of (-> this colors-added)))) - (+! (-> usage data 32 used) palette-bytes) - (+! (-> usage data 32 total) (logand -16 (+ palette-bytes 15))))) + (mem-usage-add! usage shrubbery-pal 1 (asize-of (-> this colors-added)))) ;; Account recursively for the instance hierarchy, then for its prototype geometry. (mem-usage-shrub-walk (the-as draw-node (&+ (-> this data 0) 32)) (-> (the-as drawable-group (-> this data 0)) length) usage flags) - (mem-usage (-> this info prototype-inline-array-shrub) usage (logior flags 1)) + (mem-usage (-> this info prototype-inline-array-shrub) usage (logior flags (mem-usage-flags prototype-data))) this) (defmethod login ((this generic-shrub-fragment)) @@ -166,21 +141,12 @@ (adgif-shader-login-no-remap (-> this textures i)))) this) -(defmethod mem-usage ((this generic-shrub-fragment) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this generic-shrub-fragment) (usage memory-usage-block) (flags mem-usage-flags)) "Account separately for this fragment header and its referenced control, vertex, color, and texture-coordinate streams." - (set! (-> usage length) (max 27 (-> usage length))) - (set! (-> usage data 25 name) "generic-shrub") - (+! (-> usage data 25 count) 1) ;; The fragment header and referenced packed streams are separate allocations. - (let ((header-bytes (asize-of this))) - (+! (-> usage data 25 used) header-bytes) - (+! (-> usage data 25 total) (logand -16 (+ header-bytes 15)))) - (set! (-> usage data 26 name) "generic-shrub-data") - (+! (-> usage data 26 count) 1) - (let ((stream-bytes (* (+ (-> this cnt-qwc) (-> this vtx-qwc) (-> this col-qwc) (-> this stq-qwc)) 16))) - (+! (-> usage data 26 used) stream-bytes) - (+! (-> usage data 26 total) (logand -16 (+ stream-bytes 15)))) + (mem-usage-add! usage generic-shrub 1 (asize-of this)) + (mem-usage-add! usage generic-shrub-data 1 (* (+ (-> this cnt-qwc) (-> this vtx-qwc) (-> this col-qwc) (-> this stq-qwc)) 16)) this) (defmethod inspect ((this prototype-shrubbery)) @@ -191,14 +157,9 @@ (format #t "~T [~D] ~A~%" i (-> this data i))) this) -(defmethod mem-usage ((this prototype-shrubbery) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-shrubbery) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the prototype-array header and each inline shrubbery fragment." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) @@ -227,39 +188,14 @@ (shrubbery-login-post-texture this) this) -(defmethod mem-usage ((this shrubbery) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this shrubbery) (usage memory-usage-block) (flags mem-usage-flags)) "Account separately for the shrub header and its object, vertex, color, and texture-coordinate streams." - (set! (-> usage length) (max 28 (-> usage length))) - (set! (-> usage data 27 name) "shrubbery") - (+! (-> usage data 27 count) 1) - (let ((header-bytes (asize-of this))) - (+! (-> usage data 27 used) header-bytes) - (+! (-> usage data 27 total) (logand -16 (+ header-bytes 15)))) - (set! (-> usage length) (max 30 (-> usage length))) - (set! (-> usage data 29 name) "shrubbery-vertex") - (+! (-> usage data 29 count) 1) - (let ((vertex-bytes (* (-> this vtx-qwc) 16))) - (+! (-> usage data 29 used) vertex-bytes) - (+! (-> usage data 29 total) (logand -16 (+ vertex-bytes 15)))) - (set! (-> usage length) (max 31 (-> usage length))) - (set! (-> usage data 30 name) "shrubbery-color") - (+! (-> usage data 30 count) 1) - (let ((color-bytes (* (-> this col-qwc) 16))) - (+! (-> usage data 30 used) color-bytes) - (+! (-> usage data 30 total) (logand -16 (+ color-bytes 15)))) - (set! (-> usage length) (max 29 (-> usage length))) - (set! (-> usage data 28 name) "shrubbery-object") - (+! (-> usage data 28 count) 1) - (let ((object-bytes (* (-> this obj-qwc) 16))) - (+! (-> usage data 28 used) object-bytes) - (+! (-> usage data 28 total) (logand -16 (+ object-bytes 15)))) - (set! (-> usage length) (max 32 (-> usage length))) - (set! (-> usage data 31 name) "shrubbery-stq") - (+! (-> usage data 31 count) 1) - (let ((stq-bytes (* (-> this stq-qwc) 16))) - (+! (-> usage data 31 used) stq-bytes) - (+! (-> usage data 31 total) (logand -16 (+ stq-bytes 15)))) + (mem-usage-add! usage shrubbery 1 (asize-of this)) + (mem-usage-add! usage shrubbery-vertex 1 (* (-> this vtx-qwc) 16)) + (mem-usage-add! usage shrubbery-color 1 (* (-> this col-qwc) 16)) + (mem-usage-add! usage shrubbery-object 1 (* (-> this obj-qwc) 16)) + (mem-usage-add! usage shrubbery-stq 1 (* (-> this stq-qwc) 16)) this) (defmethod login ((this drawable-tree-instance-shrub)) @@ -1134,16 +1070,7 @@ (defun shrub-make-perspective-matrix ((out matrix)) "Copy the current camera transform to out, divide its homogeneous coefficients by pfog0, and fold the horizontal, vertical, depth, and fog offsets into the first three components." - (let* ((out-matrix out) - (camera-temp (-> *math-camera* camera-temp)) - (row-0 (-> camera-temp vector 0 quad)) - (row-1 (-> camera-temp vector 1 quad)) - (row-2 (-> camera-temp vector 2 quad)) - (row-3 (-> camera-temp vector 3 quad))) - (set! (-> out-matrix vector 0 quad) row-0) - (set! (-> out-matrix vector 1 quad) row-1) - (set! (-> out-matrix vector 2 quad) row-2) - (set! (-> out-matrix vector 3 quad) row-3)) + (matrix-copy! out (-> *math-camera* camera-temp)) (let ((inverse-pfog0 (/ 1.0 (-> *math-camera* pfog0)))) (set! (-> out vector 0 w) (* (-> out vector 0 w) inverse-pfog0)) (set! (-> out vector 1 w) (* (-> out vector 1 w) inverse-pfog0)) @@ -2491,51 +2418,35 @@ (when (logtest? *vu1-enable-user* (vu1-renderer-mask shrub-near)) (when (nonzero? (-> *instance-shrub-work* near-count)) (let ((dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (chain-start (-> dma-buf base))) - (generic-init-buf dma-buf 0 (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24))) - (let* ((dma-state dma-buf) - (direct-packet (the-as object (-> dma-state base)))) - (set! (-> (the-as dma-packet direct-packet) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet direct-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet direct-packet) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> dma-state base) (&+ (the-as pointer direct-packet) 16))) - (let* ((dma-state dma-buf) - (giftag (the-as object (-> dma-state base)))) - (set! (-> (the-as gs-gif-tag giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag giftag) regs) GIF_REGS_ALL_AD) - (set! (-> dma-state base) (&+ (the-as pointer giftag) 16))) - (let* ((dma-state dma-buf) - (test-packet (-> dma-state base))) - (set! (-> (the-as (pointer gs-test) test-packet) 0) - (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal))) - (set! (-> (the-as (pointer gs-reg64) test-packet) 1) (gs-reg64 test-1)) - (set! (-> dma-state base) (&+ test-packet 16))) - (let ((near-packet (+ (+ (-> *instance-shrub-work* current-shrub-near-packet) 5152) (the-as uint *instance-shrub-work*))) - (output-matrix (the-as object (-> dma-buf base))) - (near-chain-tail (+ (-> *instance-shrub-work* near-last) 176))) - (let ((patched-init-tag (logior (logand (l.d (+ near-packet 96)) (the-as uint #x80000000ffffffff)) - (shr (shl (-> *instance-shrub-work* near-next) 33) 1)))) - (s.d! (+ near-packet 96) patched-init-tag)) - (let ((init-tag (l.q (+ near-packet 96))) - (init-data-0 (l.q (+ near-packet 112))) - (init-data-1 (l.q (+ near-packet 128)))) - (set! (-> (the-as matrix3 output-matrix) vector 0 quad) init-tag) - (set! (-> (the-as matrix3 output-matrix) vector 1 quad) init-data-0) - (set! (-> (the-as matrix3 output-matrix) vector 2 quad) init-data-1)) - (let ((after-matrix (&+ (the-as pointer output-matrix) 48))) - (s.w! (+ near-chain-tail 4) after-matrix) - (set! (-> dma-buf base) after-matrix))) - (let ((chain-end (-> dma-buf base))) - (let ((end-packet (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet end-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet end-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet end-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer end-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) (bucket-id shrub-generic0) (bucket-id shrub-generic1)) - chain-start - (the-as (pointer dma-tag) chain-end)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub-generic0) (bucket-id shrub-generic1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (generic-init-buf dma-buf 0 (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24))) (let* ((dma-state dma-buf) + (direct-packet (the-as object (-> dma-state base)))) + (set! (-> (the-as dma-packet direct-packet) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet direct-packet) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet direct-packet) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> dma-state base) (&+ (the-as pointer direct-packet) 16))) (let* ((dma-state dma-buf) + (giftag (the-as object (-> dma-state base)))) + (set! (-> (the-as gs-gif-tag giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag giftag) regs) GIF_REGS_ALL_AD) + (set! (-> dma-state base) (&+ (the-as pointer giftag) 16))) (let* ((dma-state dma-buf) + (test-packet (-> dma-state base))) + (set! (-> (the-as (pointer gs-test) test-packet) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal))) + (set! (-> (the-as (pointer gs-reg64) test-packet) 1) (gs-reg64 test-1)) + (set! (-> dma-state base) (&+ test-packet 16))) (let ((near-packet (+ (+ (-> *instance-shrub-work* current-shrub-near-packet) 5152) (the-as uint *instance-shrub-work*))) + (output-matrix (the-as object (-> dma-buf base))) + (near-chain-tail (+ (-> *instance-shrub-work* near-last) 176))) + (let ((patched-init-tag (logior (logand (l.d (+ near-packet 96)) (the-as uint #x80000000ffffffff)) + (shr (shl (-> *instance-shrub-work* near-next) 33) 1)))) + (s.d! (+ near-packet 96) patched-init-tag)) + (let ((init-tag (l.q (+ near-packet 96))) + (init-data-0 (l.q (+ near-packet 112))) + (init-data-1 (l.q (+ near-packet 128)))) + (set! (-> (the-as matrix3 output-matrix) vector 0 quad) init-tag) + (set! (-> (the-as matrix3 output-matrix) vector 1 quad) init-data-0) + (set! (-> (the-as matrix3 output-matrix) vector 2 quad) init-data-1)) + (let ((after-matrix (&+ (the-as pointer output-matrix) 48))) + (s.w! (+ near-chain-tail 4) after-matrix) + (set! (-> dma-buf base) after-matrix)))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 28 (-> usage length))) @@ -2549,40 +2460,27 @@ ;; fragment once, then CALL the instance chain accumulated for that prototype. (when (logtest? *vu1-enable-user* (vu1-renderer-mask shrubbery)) (let ((dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (chain-start (-> dma-buf base))) - (shrub-init-frame dma-buf - (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal))) - (let ((bucket (the-as prototype-bucket-shrub buckets))) - (countdown (i prototype-count) - (when (nonzero? (-> bucket count 1)) - (let ((geometry (-> bucket geometry 1))) - (set! opaque-chain (-> bucket next 1)) - (set! opaque-fragment (&+ geometry 32)) - (set! opaque-fragments-left (-> (the-as drawable-group geometry) length))) - (while (nonzero? opaque-fragments-left) - (+! opaque-fragments-left -1) - (shrub-upload-model (the-as shrubbery opaque-fragment) - dma-buf - (the-as int (-> *instance-shrub-work* start-bank (-> bucket mod-count 1)))) - (let* ((dma-state dma-buf) - (call-packet (the-as object (-> dma-state base)))) - (set! (-> (the-as dma-packet call-packet) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr opaque-chain)) - (set! (-> (the-as dma-packet call-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet call-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-state base) (&+ (the-as pointer call-packet) 16))) - (&+! opaque-fragment 32))) - (&+! bucket 112))) - (let ((chain-end (-> dma-buf base))) - (let ((end-packet (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet end-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet end-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet end-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer end-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) (bucket-id shrub0) (bucket-id shrub1)) - chain-start - (the-as (pointer dma-tag) chain-end)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub0) (bucket-id shrub1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (shrub-init-frame dma-buf + (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal))) (let ((bucket (the-as prototype-bucket-shrub buckets))) + (countdown (i prototype-count) + (when (nonzero? (-> bucket count 1)) + (let ((geometry (-> bucket geometry 1))) + (set! opaque-chain (-> bucket next 1)) + (set! opaque-fragment (&+ geometry 32)) + (set! opaque-fragments-left (-> (the-as drawable-group geometry) length))) + (while (nonzero? opaque-fragments-left) + (+! opaque-fragments-left -1) + (shrub-upload-model (the-as shrubbery opaque-fragment) + dma-buf + (the-as int (-> *instance-shrub-work* start-bank (-> bucket mod-count 1)))) + (let* ((dma-state dma-buf) + (call-packet (the-as object (-> dma-state base)))) + (set! (-> (the-as dma-packet call-packet) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr opaque-chain)) + (set! (-> (the-as dma-packet call-packet) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet call-packet) vif1) (new 'static 'vif-tag)) + (set! (-> dma-state base) (&+ (the-as pointer call-packet) 16))) + (&+! opaque-fragment 32))) + (&+! bucket 112)))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 28 (-> usage length))) @@ -2593,47 +2491,34 @@ (set! (-> usage data 27 total) (-> usage data 27 used)))))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask trans-shrubbery)) (let ((dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (chain-start (-> dma-buf base))) - (shrub-init-frame dma-buf - (new 'static - 'gs-test - :ate #x1 - :atst (gs-atest greater-equal) - :aref #x26 - :afail #x1 - :zte #x1 - :ztst (gs-ztest greater-equal))) - (let ((bucket (the-as prototype-bucket-shrub buckets))) - (countdown (i prototype-count) - (when (nonzero? (-> bucket count 2)) - (let ((geometry (-> bucket geometry 2))) - (set! translucent-chain (-> bucket next 2)) - (set! translucent-fragment (&+ geometry 32)) - (set! translucent-fragments-left (-> (the-as drawable-group geometry) length))) - (while (nonzero? translucent-fragments-left) - (+! translucent-fragments-left -1) - (shrub-upload-model (the-as shrubbery translucent-fragment) - dma-buf - (the-as int (-> *instance-shrub-work* start-bank (-> bucket mod-count 2)))) - (let* ((dma-state dma-buf) - (call-packet (the-as object (-> dma-state base)))) - (set! (-> (the-as dma-packet call-packet) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr translucent-chain)) - (set! (-> (the-as dma-packet call-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet call-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-state base) (&+ (the-as pointer call-packet) 16))) - (&+! translucent-fragment 32))) - (&+! bucket 112))) - (let ((chain-end (-> dma-buf base))) - (let ((end-packet (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet end-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet end-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet end-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer end-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) (bucket-id shrub-trans0) (bucket-id shrub-trans1)) - chain-start - (the-as (pointer dma-tag) chain-end)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub-trans0) (bucket-id shrub-trans1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (shrub-init-frame dma-buf + (new 'static + 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x26 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal))) (let ((bucket (the-as prototype-bucket-shrub buckets))) + (countdown (i prototype-count) + (when (nonzero? (-> bucket count 2)) + (let ((geometry (-> bucket geometry 2))) + (set! translucent-chain (-> bucket next 2)) + (set! translucent-fragment (&+ geometry 32)) + (set! translucent-fragments-left (-> (the-as drawable-group geometry) length))) + (while (nonzero? translucent-fragments-left) + (+! translucent-fragments-left -1) + (shrub-upload-model (the-as shrubbery translucent-fragment) + dma-buf + (the-as int (-> *instance-shrub-work* start-bank (-> bucket mod-count 2)))) + (let* ((dma-state dma-buf) + (call-packet (the-as object (-> dma-state base)))) + (set! (-> (the-as dma-packet call-packet) dma) (new 'static 'dma-tag :id (dma-tag-id call) :addr translucent-chain)) + (set! (-> (the-as dma-packet call-packet) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet call-packet) vif1) (new 'static 'vif-tag)) + (set! (-> dma-state base) (&+ (the-as pointer call-packet) 16))) + (&+! translucent-fragment 32))) + (&+! bucket 112)))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 28 (-> usage length))) @@ -2688,7 +2573,7 @@ (set! (-> end-packet vif1) (new 'static 'vif-tag)) (set! (-> dma-buf base) (the-as pointer (&+ end-packet 16)))) (let ((insert-result (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) (bucket-id shrub-billboard0) (bucket-id shrub-billboard1)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub-billboard0) (bucket-id shrub-billboard1)) chain-start (the-as (pointer dma-tag) chain-end)))) (let ((usage *dma-mem-usage*)) @@ -2739,20 +2624,8 @@ ;; NOTE: this part is completely rewritten for PC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (when (logtest? *vu1-enable-user* (vu1-renderer-mask shrubbery)) - (let* ((pc-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (pc-chain-start (-> pc-dma-buf base))) - (add-pc-tfrag3-data pc-dma-buf (-> *level* data (-> (scratchpad-object terrain-context) bsp lev-index))) - (let ((pc-chain-end (-> pc-dma-buf base))) - (let ((end-packet (the-as object (-> pc-dma-buf base)))) - (set! (-> (the-as dma-packet end-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet end-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet end-packet) vif1) (new 'static 'vif-tag)) - (set! (-> pc-dma-buf base) (&+ (the-as pointer end-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id - (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub0) (bucket-id shrub1))) - pc-chain-start - (the-as (pointer dma-tag) pc-chain-end))))) + (with-dma-buffer-add-bucket ((pc-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id shrub0) (bucket-id shrub1)))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (add-pc-tfrag3-data pc-dma-buf (-> *level* data (-> (scratchpad-object terrain-context) bsp lev-index))))) (read! (-> *perf-stats* data (perf-stat-bucket inst-shrub))) (reset! (-> *perf-stats* data (perf-stat-bucket proto-shrub))) ; (draw-prototype-inline-array-shrub prototype-count buckets) diff --git a/goal_src/jak1/engine/gfx/sky/sky-tng.gc b/goal_src/jak1/engine/gfx/sky/sky-tng.gc index 5f85a3a540..0888f00796 100644 --- a/goal_src/jak1/engine/gfx/sky/sky-tng.gc +++ b/goal_src/jak1/engine/gfx/sky/sky-tng.gc @@ -1451,138 +1451,119 @@ 'draw (new 'static 'rgba :r #x40 :b #x40 :a #x80))) (let ((usage-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> dma-buf base))) - (let* ((state-buffer dma-buf) - (state-header (the-as object (-> state-buffer base)))) - (set! (-> (the-as dma-packet state-header) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet state-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet state-header) vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> state-buffer base) (&+ (the-as pointer state-header) 16))) - (let* ((state-buffer dma-buf) - (state-giftag (the-as object (-> state-buffer base)))) - (set! (-> (the-as gs-gif-tag state-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) - (set! (-> (the-as gs-gif-tag state-giftag) regs) GIF_REGS_ALL_AD) - (set! (-> state-buffer base) (&+ (the-as pointer state-giftag) 16))) - (let* ((state-buffer dma-buf) - (state-registers (-> state-buffer base))) - (set! (-> (the-as (pointer gs-zbuf) state-registers) 0) (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24))) - (set! (-> (the-as (pointer gs-reg64) state-registers) 1) (gs-reg64 zbuf-1)) - (set! (-> (the-as (pointer gs-test) state-registers) 2) - (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) - (set! (-> (the-as (pointer gs-reg64) state-registers) 3) (gs-reg64 test-1)) - (set! (-> (the-as (pointer gs-alpha) state-registers) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) state-registers) 5) (gs-reg64 alpha-1)) - (set! (-> state-buffer base) (&+ state-registers 48))) - (init-sky-regs) - (#unless PC_PORT - (m! vf27 (-> *sky-tng-data* giftag-roof qword))) - (#when PC_PORT - (set-sky-vf27 (&-> *sky-tng-data* giftag-roof qword))) - (when *sky-drawn* - (let* ((roof-buffer dma-buf) - (roof-header (the-as object (-> roof-buffer base)))) - (set! (-> (the-as dma-packet roof-header) dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet roof-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet roof-header) vif1) (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> roof-buffer base) (&+ (the-as pointer roof-header) 16))) - (let* ((roof-buffer dma-buf) - (roof-giftag (the-as object (-> roof-buffer base)))) - (set! (-> (the-as gs-gif-tag roof-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x4)) - (set! (-> (the-as gs-gif-tag roof-giftag) regs) GIF_REGS_ALL_AD) - (set! (-> roof-buffer base) (&+ (the-as pointer roof-giftag) 16))) - (let* ((roof-state-buffer dma-buf) - (roof-state (-> roof-state-buffer base))) - (set! (-> (the-as (pointer gs-tex0) roof-state) 0) - (new 'static 'gs-tex0 :tbw #x1 :th (log2 32) :tw (log2 32) :tbp0 *sky-base-block*)) - (set! (-> (the-as (pointer gs-reg64) roof-state) 1) (gs-reg64 tex0-1)) - (set! (-> (the-as (pointer gs-tex1) roof-state) 2) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) - (set! (-> (the-as (pointer gs-reg64) roof-state) 3) (gs-reg64 tex1-1)) - (set! (-> (the-as (pointer gs-clamp) roof-state) 4) - (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) - (set! (-> (the-as (pointer gs-reg64) roof-state) 5) (gs-reg64 clamp-1)) - (set! (-> (the-as (pointer uint64) roof-state) 6) (the-as uint 0)) - (set! (-> (the-as (pointer gs-reg64) roof-state) 7) (gs-reg64 texflush)) - (set! (-> roof-state-buffer base) (&+ roof-state 64))) - (let ((roof-packet-start (the-as object (-> dma-buf base)))) - (&+! (-> dma-buf base) 16) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) dma-buf) - (close-sky-buffer dma-buf) - (let ((roof-qwc (/ (the-as int (+ (- -16 (the-as int roof-packet-start)) (the-as int (-> dma-buf base)))) 16))) - (set! (-> (the-as dma-packet roof-packet-start) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc roof-qwc)) - (set! (-> (the-as dma-packet roof-packet-start) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet roof-packet-start) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm roof-qwc))))) - (when *cloud-drawn* - (let* ((cloud-buffer dma-buf) - (cloud-header (the-as object (-> cloud-buffer base)))) - (set! (-> (the-as dma-packet cloud-header) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet cloud-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet cloud-header) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> cloud-buffer base) (&+ (the-as pointer cloud-header) 16))) - (let* ((cloud-buffer dma-buf) - (cloud-giftag (the-as object (-> cloud-buffer base)))) - (set! (-> (the-as gs-gif-tag cloud-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) - (set! (-> (the-as gs-gif-tag cloud-giftag) regs) GIF_REGS_ALL_AD) - (set! (-> cloud-buffer base) (&+ (the-as pointer cloud-giftag) 16))) - (let* ((cloud-state-buffer dma-buf) - (cloud-state (-> cloud-state-buffer base))) - (set! (-> (the-as (pointer gs-alpha) cloud-state) 0) (new 'static 'gs-alpha :b #x2 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) cloud-state) 1) (gs-reg64 alpha-1)) - (set! (-> (the-as (pointer gs-tex0) cloud-state) 2) - (new 'static 'gs-tex0 :tbw #x1 :th (log2 64) :tw (log2 64) :tbp0 (+ *sky-base-block* 32))) - (set! (-> (the-as (pointer gs-reg64) cloud-state) 3) (gs-reg64 tex0-1)) - (set! (-> (the-as (pointer gs-tex1) cloud-state) 4) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) - (set! (-> (the-as (pointer gs-reg64) cloud-state) 5) (gs-reg64 tex1-1)) - (set! (-> (the-as (pointer gs-clamp) cloud-state) 6) (new 'static 'gs-clamp)) - (set! (-> (the-as (pointer gs-reg64) cloud-state) 7) (gs-reg64 clamp-1)) - (set! (-> (the-as (pointer int64) cloud-state) 8) 0) - (set! (-> (the-as (pointer gs-reg64) cloud-state) 9) (gs-reg64 texflush)) - (set! (-> cloud-state-buffer base) (&+ cloud-state 80))) - (let ((cloud-packet-start (the-as object (-> dma-buf base)))) - (&+! (-> dma-buf base) 16) - (init-sky-regs) - (let ((vertices (the-as object (-> sky-cloud-polygons 0)))) - (set-tex-offset (the-as int (-> *sky-tng-data* off-s-0)) (the-as int (-> *sky-tng-data* off-t-0))) - ;; first cloud layer - (dotimes (i 9) - (render-sky-quad (the-as (inline-array sky-vertex) vertices) dma-buf) - (set! vertices (-> (the-as (inline-array sky-vertex) vertices) 4))) - (set-tex-offset (the-as int (-> *sky-tng-data* off-s-1)) (the-as int (-> *sky-tng-data* off-t-1))) - ;; second cloud layer - (dotimes (i 9) - (render-sky-quad (the-as (inline-array sky-vertex) vertices) dma-buf) - (set! vertices (-> (the-as (inline-array sky-vertex) vertices) 4)))) - ;; The untextured base triangles fill the region below the roof at GS layer depth 256. - (#unless PC_PORT - (m! vf27 (-> *sky-tng-data* giftag-base qword)) - (let ((base-depth-bits #x43800000)) (m vf23 base-depth-bits)) - (m base-depth vf23)) - (#when PC_PORT - (set-sky-vf27 (&-> *sky-tng-data* giftag-base qword)) - (set-sky-vf23-value #x43800000)) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) dma-buf) - (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) dma-buf) - (close-sky-buffer dma-buf) - (let ((cloud-qwc (/ (the-as int (+ (- -16 (the-as int cloud-packet-start)) (the-as int (-> dma-buf base)))) 16))) - (set! (-> (the-as dma-packet cloud-packet-start) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc cloud-qwc)) - (set! (-> (the-as dma-packet cloud-packet-start) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet cloud-packet-start) vif1) - (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm cloud-qwc))))) - (let ((end-tag (-> dma-buf base))) - (let ((next-tag (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet next-tag) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-tag) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-tag) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id sky-draw) - bucket-start - (the-as (pointer dma-tag) end-tag)))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id sky-draw)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let* ((state-buffer dma-buf) + (state-header (the-as object (-> state-buffer base)))) + (set! (-> (the-as dma-packet state-header) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet state-header) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet state-header) vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> state-buffer base) (&+ (the-as pointer state-header) 16))) (let* ((state-buffer dma-buf) + (state-giftag (the-as object (-> state-buffer base)))) + (set! (-> (the-as gs-gif-tag state-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> (the-as gs-gif-tag state-giftag) regs) GIF_REGS_ALL_AD) + (set! (-> state-buffer base) (&+ (the-as pointer state-giftag) 16))) (let* ((state-buffer dma-buf) + (state-registers (-> state-buffer base))) + (set! (-> (the-as (pointer gs-zbuf) state-registers) 0) (new 'static 'gs-zbuf :zbp #x1c0 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) state-registers) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) state-registers) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always))) + (set! (-> (the-as (pointer gs-reg64) state-registers) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) state-registers) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) state-registers) 5) (gs-reg64 alpha-1)) + (set! (-> state-buffer base) (&+ state-registers 48))) (init-sky-regs) (#unless PC_PORT + (m! vf27 (-> *sky-tng-data* giftag-roof qword))) (#when PC_PORT + (set-sky-vf27 (&-> *sky-tng-data* giftag-roof qword))) (when *sky-drawn* + (let* ((roof-buffer dma-buf) + (roof-header (the-as object (-> roof-buffer base)))) + (set! (-> (the-as dma-packet roof-header) dma) (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet roof-header) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet roof-header) vif1) (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> roof-buffer base) (&+ (the-as pointer roof-header) 16))) + (let* ((roof-buffer dma-buf) + (roof-giftag (the-as object (-> roof-buffer base)))) + (set! (-> (the-as gs-gif-tag roof-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x4)) + (set! (-> (the-as gs-gif-tag roof-giftag) regs) GIF_REGS_ALL_AD) + (set! (-> roof-buffer base) (&+ (the-as pointer roof-giftag) 16))) + (let* ((roof-state-buffer dma-buf) + (roof-state (-> roof-state-buffer base))) + (set! (-> (the-as (pointer gs-tex0) roof-state) 0) + (new 'static 'gs-tex0 :tbw #x1 :th (log2 32) :tw (log2 32) :tbp0 *sky-base-block*)) + (set! (-> (the-as (pointer gs-reg64) roof-state) 1) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) roof-state) 2) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) roof-state) 3) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) roof-state) 4) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) + (set! (-> (the-as (pointer gs-reg64) roof-state) 5) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer uint64) roof-state) 6) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) roof-state) 7) (gs-reg64 texflush)) + (set! (-> roof-state-buffer base) (&+ roof-state 64))) + (let ((roof-packet-start (the-as object (-> dma-buf base)))) + (&+! (-> dma-buf base) 16) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) dma-buf) + (close-sky-buffer dma-buf) + (let ((roof-qwc (/ (the-as int (+ (- -16 (the-as int roof-packet-start)) (the-as int (-> dma-buf base)))) 16))) + (set! (-> (the-as dma-packet roof-packet-start) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc roof-qwc)) + (set! (-> (the-as dma-packet roof-packet-start) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet roof-packet-start) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm roof-qwc))))) (when *cloud-drawn* + (let* ((cloud-buffer dma-buf) + (cloud-header (the-as object (-> cloud-buffer base)))) + (set! (-> (the-as dma-packet cloud-header) dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet cloud-header) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet cloud-header) vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> cloud-buffer base) (&+ (the-as pointer cloud-header) 16))) + (let* ((cloud-buffer dma-buf) + (cloud-giftag (the-as object (-> cloud-buffer base)))) + (set! (-> (the-as gs-gif-tag cloud-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) + (set! (-> (the-as gs-gif-tag cloud-giftag) regs) GIF_REGS_ALL_AD) + (set! (-> cloud-buffer base) (&+ (the-as pointer cloud-giftag) 16))) + (let* ((cloud-state-buffer dma-buf) + (cloud-state (-> cloud-state-buffer base))) + (set! (-> (the-as (pointer gs-alpha) cloud-state) 0) (new 'static 'gs-alpha :b #x2 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) cloud-state) 1) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) cloud-state) 2) + (new 'static 'gs-tex0 :tbw #x1 :th (log2 64) :tw (log2 64) :tbp0 (+ *sky-base-block* 32))) + (set! (-> (the-as (pointer gs-reg64) cloud-state) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) cloud-state) 4) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) cloud-state) 5) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) cloud-state) 6) (new 'static 'gs-clamp)) + (set! (-> (the-as (pointer gs-reg64) cloud-state) 7) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer int64) cloud-state) 8) 0) + (set! (-> (the-as (pointer gs-reg64) cloud-state) 9) (gs-reg64 texflush)) + (set! (-> cloud-state-buffer base) (&+ cloud-state 80))) + (let ((cloud-packet-start (the-as object (-> dma-buf base)))) + (&+! (-> dma-buf base) 16) + (init-sky-regs) + (let ((vertices (the-as object (-> sky-cloud-polygons 0)))) + (set-tex-offset (the-as int (-> *sky-tng-data* off-s-0)) (the-as int (-> *sky-tng-data* off-t-0))) + ;; first cloud layer + (dotimes (i 9) + (render-sky-quad (the-as (inline-array sky-vertex) vertices) dma-buf) + (set! vertices (-> (the-as (inline-array sky-vertex) vertices) 4))) + (set-tex-offset (the-as int (-> *sky-tng-data* off-s-1)) (the-as int (-> *sky-tng-data* off-t-1))) + ;; second cloud layer + (dotimes (i 9) + (render-sky-quad (the-as (inline-array sky-vertex) vertices) dma-buf) + (set! vertices (-> (the-as (inline-array sky-vertex) vertices) 4)))) + ;; The untextured base triangles fill the region below the roof at GS layer depth 256. + (#unless PC_PORT + (m! vf27 (-> *sky-tng-data* giftag-base qword)) + (let ((base-depth-bits #x43800000)) (m vf23 base-depth-bits)) + (m base-depth vf23)) + (#when PC_PORT + (set-sky-vf27 (&-> *sky-tng-data* giftag-base qword)) + (set-sky-vf23-value #x43800000)) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) dma-buf) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) dma-buf) + (close-sky-buffer dma-buf) + (let ((cloud-qwc (/ (the-as int (+ (- -16 (the-as int cloud-packet-start)) (the-as int (-> dma-buf base)))) 16))) + (set! (-> (the-as dma-packet cloud-packet-start) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc cloud-qwc)) + (set! (-> (the-as dma-packet cloud-packet-start) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet cloud-packet-start) vif1) + (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm cloud-qwc)))))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 86 (-> usage length))) @@ -1671,39 +1652,21 @@ (let ((blend-bucket (if (zero? level-index) (the-as bucket-id (bucket-id tfrag-trans-0)) (the-as bucket-id (bucket-id tfrag-trans-1)))) (adgifs (-> *level* level level-index bsp adgifs))) (when (nonzero? adgifs) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (packet-start (-> dma-buf base))) - (set-display-gs-state dma-buf *sky-base-page* 64 96 0 0) - (dotimes (texture-index 8) - (let ((texture-weight (* (-> context moods level-index sky-times texture-index) level-weight))) - (if (!= texture-weight 0.0) (copy-sky-texture dma-buf (-> adgifs data texture-index) texture-weight)))) - (copy-cloud-texture dma-buf (-> adgifs data 8) level-weight) - (let* ((finish-buffer dma-buf) - (finish-header (the-as object (-> finish-buffer base)))) - (set! (-> (the-as dma-packet finish-header) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) - (set! (-> (the-as dma-packet finish-header) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet finish-header) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) - (set! (-> finish-buffer base) (&+ (the-as pointer finish-header) 16))) - (let* ((finish-buffer dma-buf) - (finish-giftag (the-as object (-> finish-buffer base)))) - (set! (-> (the-as gs-gif-tag finish-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) - (set! (-> (the-as gs-gif-tag finish-giftag) regs) GIF_REGS_ALL_AD) - (set! (-> finish-buffer base) (&+ (the-as pointer finish-giftag) 16))) - (let* ((finish-buffer dma-buf) - (finish-alpha (-> finish-buffer base))) - (set! (-> (the-as (pointer gs-alpha) finish-alpha) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) - (set! (-> (the-as (pointer gs-reg64) finish-alpha) 1) (gs-reg64 alpha-1)) - (set! (-> finish-buffer base) (&+ finish-alpha 16))) - (reset-display-gs-state *display* dma-buf *oddeven*) - (let ((end-tag (-> dma-buf base))) - (let ((next-tag (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet next-tag) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet next-tag) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet next-tag) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer next-tag) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id blend-bucket) - packet-start - (the-as (pointer dma-tag) end-tag))))))))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id blend-bucket)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-display-gs-state dma-buf *sky-base-page* 64 96 0 0) (dotimes (texture-index 8) + (let ((texture-weight (* (-> context moods level-index sky-times texture-index) level-weight))) + (if (!= texture-weight 0.0) (copy-sky-texture dma-buf (-> adgifs data texture-index) texture-weight)))) (copy-cloud-texture dma-buf (-> adgifs data 8) level-weight) (let* ((finish-buffer dma-buf) + (finish-header (the-as object (-> finish-buffer base)))) + (set! (-> (the-as dma-packet finish-header) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet finish-header) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet finish-header) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> finish-buffer base) (&+ (the-as pointer finish-header) 16))) (let* ((finish-buffer dma-buf) + (finish-giftag (the-as object (-> finish-buffer base)))) + (set! (-> (the-as gs-gif-tag finish-giftag) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag finish-giftag) regs) GIF_REGS_ALL_AD) + (set! (-> finish-buffer base) (&+ (the-as pointer finish-giftag) 16))) (let* ((finish-buffer dma-buf) + (finish-alpha (-> finish-buffer base))) + (set! (-> (the-as (pointer gs-alpha) finish-alpha) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) finish-alpha) 1) (gs-reg64 alpha-1)) + (set! (-> finish-buffer base) (&+ finish-alpha 16))) (reset-display-gs-state *display* dma-buf *oddeven*))))))) 0 (none)) diff --git a/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle-launcher.gc b/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle-launcher.gc index 970c461204..c9280d7aec 100644 --- a/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle-launcher.gc +++ b/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle-launcher.gc @@ -615,7 +615,7 @@ (let ((entry (-> queue queue (-> queue in-use)))) (set! (-> entry sp-system) sys) (set! (-> entry sp-launcher) launcher) - (set! (-> entry pos quad) (-> pos quad))) + (vector-copy! (-> entry pos) pos)) (let ((new-count (+ (-> queue in-use) 1))) (set! (-> queue in-use) new-count) new-count))) (defun sp-adjust-launch ((launchinfo sparticle-launchinfo) (cpuinfo sparticle-cpuinfo) (init-specs (inline-array sp-field-init-spec))) @@ -1668,7 +1668,7 @@ For periodic items (period != 0), [offset .. offset+length) within each period is the active window; the periodic path computes how much of the elapsed interval overlapped that window. Items are suppressed by hour-mask (time of day) and by fade-after (camera distance)." - (set! (-> this center quad) (-> pos quad)) + (vector-copy! (-> this center) pos) ;; og:preserve-this ;; check if we are visible (remove this check to force particles to be drawn.) (if (not (or (is-visible? this pos) (logtest? (-> this group flags) (sp-group-flag always-draw screen-space)))) diff --git a/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle.gc b/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle.gc index 36c06892e3..0bb1868ab3 100644 --- a/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle.gc +++ b/goal_src/jak1/engine/gfx/sprite/sparticle/sparticle.gc @@ -23,10 +23,10 @@ (let ((color (-> src sprite color quad))) (set! (-> dst sprite color quad) color)) (dotimes (i 10) (set! (-> dst adgif prims i) (-> src adgif prims i))) - (set! (-> dst vel-sxvel quad) (-> src vel-sxvel quad)) - (set! (-> dst rot-syvel quad) (-> src rot-syvel quad)) - (set! (-> dst fade quad) (-> src fade quad)) - (set! (-> dst acc quad) (-> src acc quad)) + (vector-copy! (-> dst vel-sxvel) (-> src vel-sxvel)) + (vector-copy! (-> dst rot-syvel) (-> src rot-syvel)) + (vector-copy! (-> dst fade) (-> src fade)) + (vector-copy! (-> dst acc) (-> src acc)) (set! (-> dst friction) (-> src friction)) (set! (-> dst timer) (-> src timer)) (set! (-> dst flags) (-> src flags)) diff --git a/goal_src/jak1/engine/gfx/sprite/sprite.gc b/goal_src/jak1/engine/gfx/sprite/sprite.gc index 57f980b52f..1b79e9ace9 100644 --- a/goal_src/jak1/engine/gfx/sprite/sprite.gc +++ b/goal_src/jak1/engine/gfx/sprite/sprite.gc @@ -190,8 +190,8 @@ (defun sprite-setup-frame-data ((data sprite-frame-data) (tbp-offset int)) "Build the VU1 sprite constants for this frame: GIF tags, texture state, sine and cosine coefficients, camera scales, unit-quad templates, perspective correction, color, and fog." - (set! (-> data hmge-scale quad) (-> *math-camera* hmge-scale quad)) - (set! (-> data inv-hmge-scale quad) (-> *math-camera* inv-hmge-scale quad)) + (vector-copy! (-> data hmge-scale) (-> *math-camera* hmge-scale)) + (vector-copy! (-> data inv-hmge-scale) (-> *math-camera* inv-hmge-scale)) (set! (-> data pfog0) (-> *math-camera* pfog0)) (set! (-> data deg-to-rad) 0.000095873795) ;; the adgif-giftag sets GS registers according to the adgif shader using @@ -336,12 +336,12 @@ (set! (-> data sincos-67 w) -0.0013636408) (set! (-> data sincos-89 w) 0.000020170546) ;; math camera stuff - (set! (-> data basis-x quad) (the-as uint128 0)) + (vector-zero! (-> data basis-x)) (set! (-> data basis-x x) (- (-> *math-camera* perspective vector 0 x))) (with-pc (when (pc-cheats? (-> *pc-settings* cheats) mirror) (*! (-> data basis-x x) -1.0))) - (set! (-> data basis-y quad) (the-as uint128 0)) + (vector-zero! (-> data basis-y)) (set! (-> data basis-y y) (- (-> *math-camera* perspective vector 1 y))) (set! (-> data min-scale) (sqrtf (* (/ 1.0 (-> data basis-x x)) (/ 1.0 (-> data basis-y y))))) (set! (-> data inv-area) (/ 1.0 (* (-> data min-scale) (-> data min-scale)))) @@ -493,16 +493,7 @@ (new 'static 'vif-unpack-imm :addr vu-address))) ;; sent the camera-temp matrix ;; these weren't done through the usual macros which is strange - (let* ((mtx (the-as matrix (-> dma-buff base))) - (camera-matrix (-> *math-camera* camera-temp)) - (camera-row-0 (-> camera-matrix vector 0 quad)) - (camera-row-1 (-> camera-matrix vector 1 quad)) - (camera-row-2 (-> camera-matrix vector 2 quad)) - (camera-row-3 (-> camera-matrix vector 3 quad))) - (set! (-> mtx vector 0 quad) camera-row-0) - (set! (-> mtx vector 1 quad) camera-row-1) - (set! (-> mtx vector 2 quad) camera-row-2) - (set! (-> mtx vector 3 quad) camera-row-3)) + (matrix-copy! (the-as matrix (-> dma-buff base)) (-> *math-camera* camera-temp)) (&+! (-> dma-buff base) 64) ;; The fifth quadword is the camera's homogeneous divide and fog offset. (let ((v1-1 (+ vu-address 4))) @@ -544,7 +535,7 @@ (&+! (-> dma-buff base) 64) (let ((v1-2 (+ vu-address 4))) (let ((screen-offset (the-as vector (-> dma-buff base)))) - (set! (-> screen-offset quad) (-> *math-camera* hvdf-off quad)) + (vector-copy! screen-offset (-> *math-camera* hvdf-off)) (set! (-> screen-offset x) 2048.0) (set! (-> screen-offset y) 2048.0) (set! (-> screen-offset z) (-> *math-camera* hvdf-off z))) diff --git a/goal_src/jak1/engine/gfx/texture/texture.gc b/goal_src/jak1/engine/gfx/texture/texture.gc index 742137106d..559c4a10a4 100644 --- a/goal_src/jak1/engine/gfx/texture/texture.gc +++ b/goal_src/jak1/engine/gfx/texture/texture.gc @@ -121,7 +121,7 @@ "Get the size in memory of a texture page object, not including the actual texture objects or texture data" (the-as int (+ (-> this type size) (the-as uint (shl (-> this length) 2))))) -(defmethod mem-usage ((this texture-page) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this texture-page) (usage memory-usage-block) (flags mem-usage-flags)) "Charge this page's texture records and retained image data to texture memory usage." ;; some setup for texture memory usage. (set! (-> usage length) (max (+ 1 (mem-usage-id-int texture)) (-> usage length))) diff --git a/goal_src/jak1/engine/gfx/tfrag/tfrag-methods.gc b/goal_src/jak1/engine/gfx/tfrag/tfrag-methods.gc index 48c1a6981b..1cf662f58d 100644 --- a/goal_src/jak1/engine/gfx/tfrag/tfrag-methods.gc +++ b/goal_src/jak1/engine/gfx/tfrag/tfrag-methods.gc @@ -65,8 +65,8 @@ (child-array (-> tree arrays (+ depth-index 1))) (parent-vis-byte-index (/ (-> (the-as drawable-inline-array-node parent-array) data 0 id) 8)) (child-vis-byte-index (/ (-> (the-as drawable-inline-array-node child-array) data 0 id) 8)) - (parent-visibility (&-> (the-as terrain-context #x70000000) work background vis-list parent-vis-byte-index)) - (child-visibility (&-> (the-as terrain-context #x70000000) work background vis-list child-vis-byte-index))) + (parent-visibility (&-> (scratchpad-object terrain-context) work background vis-list parent-vis-byte-index)) + (child-visibility (&-> (scratchpad-object terrain-context) work background vis-list child-vis-byte-index))) (draw-node-cull child-visibility parent-visibility (-> (the-as drawable-inline-array-node parent-array) data) @@ -74,13 +74,13 @@ (let* ((fragment-array (the-as drawable-inline-array-tfrag (-> tree arrays last-array-index))) (fragments (-> fragment-array data)) (fragment-count (-> fragment-array length))) - (set! visibility-bits (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> fragments 0 id) 8))) + (set! visibility-bits (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> fragments 0 id) 8))) (let ((dma-start (-> (current-frame) global-buf base))) ;; Far and near are two passes over the same fragment array into two buckets. Both open a ;; chain in the global buffer, end it with a next tag and hand the span to the bucket ;; system, which patches the chains together before the DMA goes out. (with-dma-buffer-add-bucket ((far-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-0) (bucket-id tfrag-1))) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) @@ -97,7 +97,7 @@ (-> *tfrag-work* wait-from-spr)) (tfrag-end-buffer far-dma-buf)) (with-dma-buffer-add-bucket ((near-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-near-0) (bucket-id tfrag-near-1))) (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) @@ -166,40 +166,22 @@ (let ((s5-1 (-> *display* frames (-> *display* on-screen) frame global-buf base))) ;; (format *stdcon* " #x~X~%" s5-1) ;; DMA for TFRAG - (let* ((s1-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s2-0 (-> s1-0 base))) - ;; clear stats - (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) - ;; initialize dma buffer - (tfrag-init-buffer s1-0 - (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal)) - 0 - lev) - ;; do the draw! - (reset! (-> *perf-stats* data 5)) - ;;(format 0 "DRAW: ~D~%" s3-0) - ;; (draw-inline-array-tfrag sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-0) - (read! (-> *perf-stats* data 5)) - ;; update stats for the draw - (update-wait-stats (-> *perf-stats* data 5) - (the-as uint 0) - (-> *tfrag-work* wait-to-spr) - (-> *tfrag-work* wait-from-spr)) - ;; finish dma buffer - (tfrag-end-buffer s1-0) - ;; close dma packet - (let ((a3-3 (-> s1-0 base))) - (let ((v1-38 (the-as object (-> s1-0 base)))) - (set! (-> (the-as dma-packet v1-38) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-38) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-38) vif1) (new 'static 'vif-tag)) - (set! (-> s1-0 base) (&+ (the-as pointer v1-38) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id - (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-0) (bucket-id tfrag-1))) - s2-0 - (the-as (pointer dma-tag) a3-3)))) + ;; clear stats + ;; initialize dma buffer + ;; do the draw! + ;;(format 0 "DRAW: ~D~%" s3-0) + ;; (draw-inline-array-tfrag sv-16 (the-as drawable-inline-array s4-1) s3-0 s1-0) + ;; update stats for the draw + ;; finish dma buffer + ;; close dma packet + (with-dma-buffer-add-bucket ((s1-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-0) (bucket-id tfrag-1)))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (tfrag-init-buffer s1-0 + (new 'static 'gs-test :ate #x1 :atst (gs-atest greater-equal) :aref #x26 :zte #x1 :ztst (gs-ztest greater-equal)) + 0 + lev) (reset! (-> *perf-stats* data 5)) (read! (-> *perf-stats* data 5)) (update-wait-stats (-> *perf-stats* data 5) + (the-as uint 0) + (-> *tfrag-work* wait-to-spr) + (-> *tfrag-work* wait-from-spr)) (tfrag-end-buffer s1-0)) ;; (format *stdcon* " #x~X~%" (-> *display* frames (-> *display* on-screen) frame global-buf base)) ;; DMA for TFRAG NEAR ; (let* ((s1-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) @@ -260,8 +242,8 @@ (child-array (-> tree arrays (+ depth-index 1))) (parent-vis-byte-index (/ (-> (the-as drawable-inline-array-node parent-array) data 0 id) 8)) (child-vis-byte-index (/ (-> (the-as drawable-inline-array-node child-array) data 0 id) 8)) - (parent-visibility (&-> (the-as terrain-context #x70000000) work background vis-list parent-vis-byte-index)) - (child-visibility (&-> (the-as terrain-context #x70000000) work background vis-list child-vis-byte-index))) + (parent-visibility (&-> (scratchpad-object terrain-context) work background vis-list parent-vis-byte-index)) + (child-visibility (&-> (scratchpad-object terrain-context) work background vis-list child-vis-byte-index))) (draw-node-cull child-visibility parent-visibility (-> (the-as drawable-inline-array-node parent-array) data) @@ -269,9 +251,9 @@ (let* ((fragment-array (-> tree arrays last-array-index)) (fragments (&+ fragment-array 32)) (fragment-count (-> fragment-array length))) - (set! visibility-bits (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> fragments id) 8))) + (set! visibility-bits (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> fragments id) 8))) (with-dma-buffer-add-bucket ((far-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-trans-0) (bucket-id tfrag-trans-1))) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) @@ -295,7 +277,7 @@ (read! (-> *perf-stats* data 5)) (tfrag-end-buffer far-dma-buf)) (with-dma-buffer-add-bucket ((near-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-trans-near-0) (bucket-id tfrag-trans-near-1))) (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) @@ -351,40 +333,22 @@ (s5-1 (&+ v1-13 32)) (s4-1 (-> v1-13 length))) (set! sv-16 (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> s5-1 id) 8))) - (let* ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s3-0 (-> s2-0 base))) - (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) - (tfrag-init-buffer s2-0 - (new 'static - 'gs-test - :ate #x1 - :atst (gs-atest greater-equal) - :aref #x7e - :afail #x1 - :zte #x1 - :ztst (gs-ztest greater-equal)) - 1 - lev) - (reset! (-> *perf-stats* data 5)) - ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) - (update-wait-stats (-> *perf-stats* data 5) - (the-as uint 0) - (-> *tfrag-work* wait-to-spr) - (-> *tfrag-work* wait-from-spr)) - (read! (-> *perf-stats* data 5)) - (tfrag-end-buffer s2-0) - (let ((a3-3 (-> s2-0 base))) - (let ((v1-34 (the-as object (-> s2-0 base)))) - (set! (-> (the-as dma-packet v1-34) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-34) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-34) vif1) (new 'static 'vif-tag)) - (set! (-> s2-0 base) (&+ (the-as pointer v1-34) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id - (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-trans-0) (bucket-id tfrag-trans-1))) - s3-0 - (the-as (pointer dma-tag) a3-3)))) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + (with-dma-buffer-add-bucket ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-trans-0) (bucket-id tfrag-trans-1)))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (tfrag-init-buffer s2-0 + (new 'static + 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x7e + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal)) + 1 + lev) (reset! (-> *perf-stats* data 5)) (update-wait-stats (-> *perf-stats* data 5) + (the-as uint 0) + (-> *tfrag-work* wait-to-spr) + (-> *tfrag-work* wait-from-spr)) (read! (-> *perf-stats* data 5)) (tfrag-end-buffer s2-0)) #| TODO (let* @@ -486,8 +450,8 @@ (child-array (-> tree arrays (+ depth-index 1))) (parent-vis-byte-index (/ (-> (the-as drawable-inline-array-node parent-array) data 0 id) 8)) (child-vis-byte-index (/ (-> (the-as drawable-inline-array-node child-array) data 0 id) 8)) - (parent-visibility (&-> (the-as terrain-context #x70000000) work background vis-list parent-vis-byte-index)) - (child-visibility (&-> (the-as terrain-context #x70000000) work background vis-list child-vis-byte-index))) + (parent-visibility (&-> (scratchpad-object terrain-context) work background vis-list parent-vis-byte-index)) + (child-visibility (&-> (scratchpad-object terrain-context) work background vis-list child-vis-byte-index))) (draw-node-cull child-visibility parent-visibility (-> (the-as drawable-inline-array-node parent-array) data) @@ -495,9 +459,9 @@ (let* ((fragment-array (-> tree arrays last-array-index)) (fragments (&+ fragment-array 32)) (fragment-count (-> fragment-array length))) - (set! visibility-bits (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> fragments id) 8))) + (set! visibility-bits (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> fragments id) 8))) (with-dma-buffer-add-bucket ((far-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-dirt-0) (bucket-id tfrag-dirt-1))) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) @@ -512,7 +476,7 @@ (read! (-> *perf-stats* data 5)) (tfrag-end-buffer far-dma-buf)) (with-dma-buffer-add-bucket ((near-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-dirt-near-0) (bucket-id tfrag-dirt-near-1))) (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) @@ -575,29 +539,11 @@ (s5-1 (&+ v1-13 32)) (s4-1 (-> v1-13 length))) (set! sv-16 (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> s5-1 id) 8))) - (let* ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s3-0 (-> s2-0 base))) - (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) - (tfrag-init-buffer s2-0 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) 1 lev) - (reset! (-> *perf-stats* data 5)) - ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) - (update-wait-stats (-> *perf-stats* data 5) - (the-as uint 0) - (-> *tfrag-work* wait-to-spr) - (-> *tfrag-work* wait-from-spr)) - (read! (-> *perf-stats* data 5)) - (tfrag-end-buffer s2-0) - (let ((a3-3 (-> s2-0 base))) - (let ((v1-34 (the-as object (-> s2-0 base)))) - (set! (-> (the-as dma-packet v1-34) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-34) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-34) vif1) (new 'static 'vif-tag)) - (set! (-> s2-0 base) (&+ (the-as pointer v1-34) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-dirt-0) (bucket-id tfrag-dirt-1)) - s3-0 - (the-as (pointer dma-tag) a3-3)))) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + (with-dma-buffer-add-bucket ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-dirt-0) (bucket-id tfrag-dirt-1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (tfrag-init-buffer s2-0 (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) 1 lev) (reset! (-> *perf-stats* data 5)) (update-wait-stats (-> *perf-stats* data 5) + (the-as uint 0) + (-> *tfrag-work* wait-to-spr) + (-> *tfrag-work* wait-from-spr)) (read! (-> *perf-stats* data 5)) (tfrag-end-buffer s2-0)) #| (let* ((s2-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) @@ -696,8 +642,8 @@ (child-array (-> tree arrays (+ depth-index 1))) (parent-vis-byte-index (/ (-> (the-as drawable-inline-array-node parent-array) data 0 id) 8)) (child-vis-byte-index (/ (-> (the-as drawable-inline-array-node child-array) data 0 id) 8)) - (parent-visibility (&-> (the-as terrain-context #x70000000) work background vis-list parent-vis-byte-index)) - (child-visibility (&-> (the-as terrain-context #x70000000) work background vis-list child-vis-byte-index))) + (parent-visibility (&-> (scratchpad-object terrain-context) work background vis-list parent-vis-byte-index)) + (child-visibility (&-> (scratchpad-object terrain-context) work background vis-list child-vis-byte-index))) (draw-node-cull child-visibility parent-visibility (-> (the-as drawable-inline-array-node parent-array) data) @@ -705,9 +651,9 @@ (let* ((fragment-array (-> tree arrays last-array-index)) (fragments (&+ fragment-array 32)) (fragment-count (-> fragment-array length))) - (set! visibility-bits (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> fragments id) 8))) + (set! visibility-bits (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> fragments id) 8))) (with-dma-buffer-add-bucket ((far-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-ice-0) (bucket-id tfrag-ice-1))) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) @@ -724,7 +670,7 @@ (read! (-> *perf-stats* data 5)) (tfrag-end-buffer far-dma-buf)) (with-dma-buffer-add-bucket ((near-dma-buf (-> (current-frame) global-buf)) - (if (zero? (-> (the-as terrain-context #x70000000) bsp lev-index)) + (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) (bucket-id tfrag-ice-near-0) (bucket-id tfrag-ice-near-1))) (set! (-> *tfrag-work* near-wait-to-spr) (the-as uint 0)) @@ -773,32 +719,14 @@ (s5-1 (&+ v1-13 32)) (s4-1 (-> v1-13 length))) (set! sv-16 (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> s5-1 id) 8))) - (let* ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s3-0 (-> s2-0 base))) - (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) - (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) - (tfrag-init-buffer s2-0 - (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) - 1 - lev) - (reset! (-> *perf-stats* data 5)) - ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) - (update-wait-stats (-> *perf-stats* data 5) - (the-as uint 0) - (-> *tfrag-work* wait-to-spr) - (-> *tfrag-work* wait-from-spr)) - (read! (-> *perf-stats* data 5)) - (tfrag-end-buffer s2-0) - (let ((a3-3 (-> s2-0 base))) - (let ((v1-34 (the-as object (-> s2-0 base)))) - (set! (-> (the-as dma-packet v1-34) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-34) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-34) vif1) (new 'static 'vif-tag)) - (set! (-> s2-0 base) (&+ (the-as pointer v1-34) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (the-as bucket-id (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) 36 43)) - s3-0 - (the-as (pointer dma-tag) a3-3)))) + ;; (draw-inline-array-tfrag sv-16 s5-1 s4-1 s2-0) + (with-dma-buffer-add-bucket ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) (the-as bucket-id (if (zero? (-> (scratchpad-object terrain-context) bsp lev-index)) 36 43))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *tfrag-work* wait-to-spr) (the-as uint 0)) (set! (-> *tfrag-work* wait-from-spr) (the-as uint 0)) (tfrag-init-buffer s2-0 + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) + 1 + lev) (reset! (-> *perf-stats* data 5)) (update-wait-stats (-> *perf-stats* data 5) + (the-as uint 0) + (-> *tfrag-work* wait-to-spr) + (-> *tfrag-work* wait-from-spr)) (read! (-> *perf-stats* data 5)) (tfrag-end-buffer s2-0)) #| (let* ((s2-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) diff --git a/goal_src/jak1/engine/gfx/tfrag/tfrag.gc b/goal_src/jak1/engine/gfx/tfrag/tfrag.gc index d208b8d681..3839ee6426 100644 --- a/goal_src/jak1/engine/gfx/tfrag/tfrag.gc +++ b/goal_src/jak1/engine/gfx/tfrag/tfrag.gc @@ -113,12 +113,12 @@ (adgif-shader-login-no-remap (-> this shader i))) this) -(defmethod mem-usage ((this tfragment) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this tfragment) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the fragment header, overlapping base/common/LOD DMA streams, colors, and debug data. With the color-only flag, record only the packed per-LOD colors; the separate-prototype-data flag excludes those colors from the ordinary total." ;; The color-only pass keeps its packed-color total in category 19. - (when (logtest? flags 2) + (when (logtest? flags (mem-usage-flags instance-colors)) (+! (-> usage data 19 count) 1) (let ((color-bytes (+ (-> this num-base-colors) (-> this num-level0-colors) (-> this num-level1-colors)))) (+! (-> usage data 19 used) color-bytes) @@ -166,7 +166,7 @@ ;; Packed time-of-day colors. (set! (-> usage data (+ category 5) name) "tfragment-color") (+! (-> usage data (+ category 5) count) 1) - (let ((packed-color-bytes (if (logtest? flags 1) + (let ((packed-color-bytes (if (logtest? flags (mem-usage-flags prototype-data)) 0 (the-as int (* (+ (-> this num-base-colors) (-> this num-level0-colors) (-> this num-level1-colors)) 2))))) (+! (-> usage data (+ category 5) used) packed-color-bytes) @@ -193,33 +193,18 @@ (login (-> this data i))) this) -(defmethod mem-usage ((this drawable-inline-array-tfrag) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-tfrag) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the inline-array header and delegate to every terrain fragment." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) -(defmethod mem-usage ((this drawable-tree-tfrag) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-tree-tfrag) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the tree header, optional time-of-day palette, and every inline fragment array." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) "drawable-group") - (+! (-> usage data 0 count) 1) - (let ((header-bytes (asize-of this))) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add! usage drawable-group 1 (asize-of this)) (when (nonzero? (-> this time-of-day-pal)) - (set! (-> usage length) (max 9 (-> usage length))) - (set! (-> usage data 8 name) "tfragment-pal") - (+! (-> usage data 8 count) 1) - (let ((palette-bytes (asize-of (-> this time-of-day-pal)))) - (+! (-> usage data 8 used) palette-bytes) - (+! (-> usage data 8 total) (logand -16 (+ palette-bytes 15))))) + (mem-usage-add! usage tfragment-pal 1 (asize-of (-> this time-of-day-pal)))) (dotimes (i (-> this length)) (mem-usage (-> this arrays i) usage flags)) this) @@ -3035,10 +3020,10 @@ (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2))) (set! (-> data adgif tag) (new 'static 'gif-tag64 :nloop #x5 :nreg #x1)) (set! (-> data adgif regs) (new 'static 'gif-tag-regs :regs0 (gif-reg-id a+d))) - (set! (-> data hvdf-offset quad) (-> camera hvdf-off quad)) - (set! (-> data hmge-scale quad) (-> camera hmge-scale quad)) - (set! (-> data invh-scale quad) (-> camera inv-hmge-scale quad)) - (set! (-> data guard quad) (-> camera guard quad))) + (vector-copy! (-> data hvdf-offset) (-> camera hvdf-off)) + (vector-copy! (-> data hmge-scale) (-> camera hmge-scale)) + (vector-copy! (-> data invh-scale) (-> camera inv-hmge-scale)) + (vector-copy! (-> data guard) (-> camera guard))) (set-tfrag-dists! (-> data dists)) (none)) diff --git a/goal_src/jak1/engine/gfx/tie/tie-methods.gc b/goal_src/jak1/engine/gfx/tie/tie-methods.gc index 9a03ba8141..f822749146 100644 --- a/goal_src/jak1/engine/gfx/tie/tie-methods.gc +++ b/goal_src/jak1/engine/gfx/tie/tie-methods.gc @@ -2369,7 +2369,7 @@ (set! (-> prototype generic-next-clear) (the-as uint128 0))) 0) (let* ((instances (-> (the-as drawable-inline-array-instance-tie instance-array) data)) - (visibility (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> instances 0 id) 8))) + (visibility (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> instances 0 id) 8))) (dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf))) (set! instance-count (-> (the-as drawable-inline-array-node instance-array) length)) (when (nonzero? instance-count) @@ -2424,27 +2424,10 @@ (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie)) (let ((tie-dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie)) - (let* ((tie-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (tie-packet-start (-> tie-dma-buf base))) - (set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0)) - (set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0)) - (reset! (-> *perf-stats* data 11)) - (draw-inline-array-prototype-tie-asm tie-dma-buf prototype-count prototypes) - (read! (-> *perf-stats* data 11)) - (update-wait-stats (-> *perf-stats* data 11) - (the-as uint 0) - (-> *prototype-tie-work* wait-to-spr) - (-> *prototype-tie-work* wait-from-spr)) - (let ((tie-packet-end (-> tie-dma-buf base))) - (let ((tie-next-packet (the-as object (-> tie-dma-buf base)))) - (set! (-> (the-as dma-packet tie-next-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet tie-next-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet tie-next-packet) vif1) (new 'static 'vif-tag)) - (set! (-> tie-dma-buf base) (&+ (the-as pointer tie-next-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> lev index)) (bucket-id tie-0) (bucket-id tie-1)) - tie-packet-start - (the-as (pointer dma-tag) tie-packet-end))))) + (with-dma-buffer-add-bucket ((tie-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> lev index)) (bucket-id tie-0) (bucket-id tie-1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0)) (set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0)) (reset! (-> *perf-stats* data 11)) (draw-inline-array-prototype-tie-asm tie-dma-buf prototype-count prototypes) (read! (-> *perf-stats* data 11)) (update-wait-stats (-> *perf-stats* data 11) + (the-as uint 0) + (-> *prototype-tie-work* wait-to-spr) + (-> *prototype-tie-work* wait-from-spr)))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 10 (-> usage length))) @@ -2455,27 +2438,10 @@ (set! (-> usage data 9 total) (-> usage data 9 used)))))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near)) (let ((near-dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) - (let* ((near-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (near-packet-start (-> near-dma-buf base))) - (set! (-> *prototype-tie-work* near-wait-to-spr) (the-as uint 0)) - (set! (-> *prototype-tie-work* near-wait-from-spr) (the-as uint 0)) - (reset! (-> *perf-stats* data 12)) - (draw-inline-array-prototype-tie-near-asm near-dma-buf prototype-count prototypes) - (read! (-> *perf-stats* data 12)) - (update-wait-stats (-> *perf-stats* data 12) - (the-as uint 0) - (-> *prototype-tie-work* near-wait-to-spr) - (-> *prototype-tie-work* near-wait-from-spr)) - (let ((near-packet-end (-> near-dma-buf base))) - (let ((near-next-packet (the-as object (-> near-dma-buf base)))) - (set! (-> (the-as dma-packet near-next-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet near-next-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet near-next-packet) vif1) (new 'static 'vif-tag)) - (set! (-> near-dma-buf base) (&+ (the-as pointer near-next-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> lev index)) (bucket-id tie-near-0) (bucket-id tie-near-1)) - near-packet-start - (the-as (pointer dma-tag) near-packet-end)))) + (with-dma-buffer-add-bucket ((near-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> lev index)) (bucket-id tie-near-0) (bucket-id tie-near-1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *prototype-tie-work* near-wait-to-spr) (the-as uint 0)) (set! (-> *prototype-tie-work* near-wait-from-spr) (the-as uint 0)) (reset! (-> *perf-stats* data 12)) (draw-inline-array-prototype-tie-near-asm near-dma-buf prototype-count prototypes) (read! (-> *perf-stats* data 12)) (update-wait-stats (-> *perf-stats* data 12) + (the-as uint 0) + (-> *prototype-tie-work* near-wait-to-spr) + (-> *prototype-tie-work* near-wait-from-spr))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 16 (-> usage length))) @@ -2614,31 +2580,12 @@ (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie)) (let ((tie-dma-start (-> *display* frames (-> *display* on-screen) frame global-buf base))) (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie)) - (let* ((tie-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (tie-packet-start (-> tie-dma-buf base))) - (set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0)) - (set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0)) - (reset! (-> *perf-stats* data 11)) - ;;(draw-inline-array-prototype-tie-asm tie-dma-buf prototype-count prototypes) - (add-pc-tfrag3-data tie-dma-buf (-> *level* data (-> (scratchpad-object terrain-context) bsp lev-index))) - (add-pc-wind-data tie-dma-buf) - (pc-add-tie-envmap-info tie-dma-buf) - (read! (-> *perf-stats* data 11)) - (update-wait-stats (-> *perf-stats* data 11) - (the-as uint 0) - (-> *prototype-tie-work* wait-to-spr) - (-> *prototype-tie-work* wait-from-spr)) - ;; this actually generates real drawing DMA, so add it to the appropriate bucket. - (let ((tie-packet-end (-> tie-dma-buf base))) - (let ((tie-next-packet (the-as object (-> tie-dma-buf base)))) - (set! (-> (the-as dma-packet tie-next-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet tie-next-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet tie-next-packet) vif1) (new 'static 'vif-tag)) - (set! (-> tie-dma-buf base) (&+ (the-as pointer tie-next-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (if (zero? (-> lev index)) (bucket-id tie-0) (bucket-id tie-1)) - tie-packet-start - (the-as (pointer dma-tag) tie-packet-end))))) + ;;(draw-inline-array-prototype-tie-asm tie-dma-buf prototype-count prototypes) + ;; this actually generates real drawing DMA, so add it to the appropriate bucket. + (with-dma-buffer-add-bucket ((tie-dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (if (zero? (-> lev index)) (bucket-id tie-0) (bucket-id tie-1))) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0)) (set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0)) (reset! (-> *perf-stats* data 11)) (add-pc-tfrag3-data tie-dma-buf (-> *level* data (-> (scratchpad-object terrain-context) bsp lev-index))) (add-pc-wind-data tie-dma-buf) (pc-add-tie-envmap-info tie-dma-buf) (read! (-> *perf-stats* data 11)) (update-wait-stats (-> *perf-stats* data 11) + (the-as uint 0) + (-> *prototype-tie-work* wait-to-spr) + (-> *prototype-tie-work* wait-from-spr)))) (let ((usage *dma-mem-usage*)) (when (nonzero? usage) (set! (-> usage length) (max 10 (-> usage length))) diff --git a/goal_src/jak1/engine/gfx/tie/tie-near.gc b/goal_src/jak1/engine/gfx/tie/tie-near.gc index 94dcc32246..5404263b26 100644 --- a/goal_src/jak1/engine/gfx/tie/tie-near.gc +++ b/goal_src/jak1/engine/gfx/tie/tie-near.gc @@ -2148,9 +2148,9 @@ (set! (-> consts clrbufs vector4w z) 198) (set! (-> consts clrbufs vector4w w) 242) (let ((camera *math-camera*)) - (set! (-> consts invhscale quad) (-> camera inv-hmge-scale quad)) - (set! (-> consts hvdfoffs quad) (-> camera hvdf-off quad)) - (set! (-> consts guard quad) (-> camera guard quad))) + (vector-copy! (-> consts invhscale) (-> camera inv-hmge-scale)) + (vector-copy! (-> consts hvdfoffs) (-> camera hvdf-off)) + (vector-copy! (-> consts guard) (-> camera guard))) (none)) (defun tie-near-init-engine ((dma-buf dma-buffer) (test-state gs-test) (alpha-blend int)) diff --git a/goal_src/jak1/engine/gfx/tie/tie.gc b/goal_src/jak1/engine/gfx/tie/tie.gc index da5cb2d96b..45650d670f 100644 --- a/goal_src/jak1/engine/gfx/tie/tie.gc +++ b/goal_src/jak1/engine/gfx/tie/tie.gc @@ -164,31 +164,26 @@ (login (-> this data i))) this) -(defmethod mem-usage ((this drawable-tree-instance-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-tree-instance-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the tree header, its child drawables, and its prototype array. The prototype pass is marked so fragments are not charged as independent allocations a second time." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) ;; Bit 0 marks the prototype walk. Bits 1 through 4 are passed through to select instance-color ;; accounting and its geometry category. - (mem-usage (-> this prototypes prototype-array-tie) usage (logior flags 1)) + (mem-usage (-> this prototypes prototype-array-tie) usage (logior flags (mem-usage-flags prototype-data))) this) -(defmethod mem-usage ((this tie-fragment) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this tie-fragment) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this prototype's header and referenced shader, point, draw-point, generic, and debug data. With the instance-color flag, account only for one instance's packed color table in the geometry-selected color category." - (when (logtest? flags 2) + (when (logtest? flags (mem-usage-flags instance-colors)) (let ((color-bytes (* (-> this color-count) 4)) (color-category (cond - ((logtest? flags 4) 20) - ((logtest? flags 8) 21) + ((logtest? flags (mem-usage-flags tie-geometry-1)) 20) + ((logtest? flags (mem-usage-flags tie-geometry-2)) 21) (else 22)))) (+! (-> usage data color-category count) 1) (+! (-> usage data color-category used) color-bytes) @@ -235,15 +230,10 @@ (label cfg-13) this) -(defmethod mem-usage ((this instance-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this instance-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this instance and, when it owns color overrides, ask each available geometry prototype to account for the corresponding packed instance-color table." - (set! (-> usage length) (max 19 (-> usage length))) - (set! (-> usage data 18 name) "instance-tie") - (+! (-> usage data 18 count) 1) - (let ((instance-bytes (asize-of this))) - (+! (-> usage data 18 used) instance-bytes) - (+! (-> usage data 18 total) (logand -16 (+ instance-bytes 15)))) + (mem-usage-add! usage instance-tie 1 (asize-of this)) (when (nonzero? (-> this error)) (set! (-> usage length) (max 24 (-> usage length))) (set! (-> usage data 23 name) "instance-tie-colors*") @@ -263,35 +253,27 @@ (geometry-index i)) (t9-1 geometry a1-2 - (logior (logior (cond - ((= geometry-index 1) 4) - ((= geometry-index 2) 8) - ((= geometry-index 3) 16) - (else 0)) - 2) - flags)))))))) + (the-as mem-usage-flags + (logior (the-as mem-usage-flags + (logior (cond + ((= geometry-index 1) 4) + ((= geometry-index 2) 8) + ((= geometry-index 3) 16) + (else 0)) + 2)) + flags))))))))) this) -(defmethod mem-usage ((this drawable-inline-array-instance-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this drawable-inline-array-instance-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the inline-array header and every active TIE instance." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) -(defmethod mem-usage ((this prototype-tie) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this prototype-tie) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the prototype-array header and every inline TIE fragment." - (set! (-> usage length) (max 1 (-> usage length))) - (set! (-> usage data 0 name) (symbol->string 'drawable-group)) - (+! (-> usage data 0 count) 1) - (let ((header-bytes 32)) - (+! (-> usage data 0 used) header-bytes) - (+! (-> usage data 0 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add-symbol! usage drawable-group 1 32) (dotimes (i (-> this length)) (mem-usage (-> this data i) usage flags)) this) diff --git a/goal_src/jak1/engine/level/bsp.gc b/goal_src/jak1/engine/level/bsp.gc index b64bf2421f..d38f0eed50 100644 --- a/goal_src/jak1/engine/level/bsp.gc +++ b/goal_src/jak1/engine/level/bsp.gc @@ -13,7 +13,7 @@ ;; memory use ;;;;;;;;;;;;;;; -(defun-recursive mem-usage-bsp-tree none ((header bsp-header) (node bsp-node) (mem-use memory-usage-block) (flags int)) +(defun-recursive mem-usage-bsp-tree none ((header bsp-header) (node bsp-node) (mem-use memory-usage-block) (flags mem-usage-flags)) "Recursively count the 32-byte internal nodes reachable from node in the BSP-node memory category. Nonpositive terminal children are not followed; header and flags are unused." (cond @@ -27,19 +27,14 @@ (if (> (-> node back) 0) (mem-usage-bsp-tree header (the-as bsp-node (-> node back)) mem-use flags)))) (none)) -(defmethod mem-usage ((this bsp-header) (mem-use memory-usage-block) (flags int)) +(defmethod mem-usage ((this bsp-header) (mem-use memory-usage-block) (flags mem-usage-flags)) "Account for this header's owned level data and delegate memory accounting to its drawable trees and cameras." ;; start off by setting the current bsp (set! (-> mem-use work-bsp) this) ;; this seems slightly wrong, we count the file-info toward array. (when (nonzero? (-> this info)) - (set! (-> mem-use length) (max 82 (-> mem-use length))) - (set! (-> mem-use data 81 name) "array") - (+! (-> mem-use data 81 count) 1) - (let ((file-info-bytes (asize-of (-> this info)))) - (+! (-> mem-use data 81 used) file-info-bytes) - (+! (-> mem-use data 81 total) (logand -16 (+ file-info-bytes 15))))) + (mem-usage-add! mem-use array 1 (asize-of (-> this info)))) ;; measure the drawable trees. (if (nonzero? (-> this drawable-trees)) (mem-usage (-> this drawable-trees) mem-use flags)) ;; add stuff @@ -48,75 +43,30 @@ (set! (-> mem-use data 44 name) "camera") (set! (-> mem-use data 62 name) "pat") (set! (-> mem-use data 58 name) "bsp-node") - (set! (-> mem-use length) (max 57 (-> mem-use length))) ;; add the bsp-header itself - (set! (-> mem-use data 56 name) "bsp-main") - (+! (-> mem-use data 56 count) 1) - (let ((header-bytes 400)) - (+! (-> mem-use data 56 used) header-bytes) - (+! (-> mem-use data 56 total) (logand -16 (+ header-bytes 15)))) + (mem-usage-add! mem-use bsp-main 1 400) ;; add the visible list - (set! (-> mem-use length) (max 60 (-> mem-use length))) - (set! (-> mem-use data 59 name) "bsp-leaf-vis-self") - (+! (-> mem-use data 59 count) 1) - (let ((visibility-bytes (-> this visible-list-length))) - (+! (-> mem-use data 59 used) visibility-bytes) - (+! (-> mem-use data 59 total) (logand -16 (+ visibility-bytes 15)))) + (mem-usage-add! mem-use bsp-leaf-vis-self 1 (-> this visible-list-length)) ;; add the unk-data-0 - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((texture-remap-bytes (* (-> this texture-remap-table-len) 8))) - (+! (-> mem-use data 57 used) texture-remap-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ texture-remap-bytes 15)))) + (mem-usage-add! mem-use bsp-misc 1 (* (-> this texture-remap-table-len) 8)) ;; add the unk-data-1 - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((texture-id-bytes (* (-> this texture-page-count) 4))) - (+! (-> mem-use data 57 used) texture-id-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ texture-id-bytes 15)))) + (mem-usage-add! mem-use bsp-misc 1 (* (-> this texture-page-count) 4)) ;; add unk-zero-0 (when (nonzero? (-> this unk-zero-0)) - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((unknown-array-bytes (asize-of (-> this unk-zero-0)))) - (+! (-> mem-use data 57 used) unknown-array-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ unknown-array-bytes 15))))) + (mem-usage-add! mem-use bsp-misc 1 (asize-of (-> this unk-zero-0)))) ;; add adgifs (when (nonzero? (-> this adgifs)) - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((adgif-bytes (asize-of (-> this adgifs)))) - (+! (-> mem-use data 57 used) adgif-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ adgif-bytes 15))))) + (mem-usage-add! mem-use bsp-misc 1 (asize-of (-> this adgifs)))) ;; add boxes (when (nonzero? (-> this boxes)) - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((box-bytes (asize-of (-> this boxes)))) - (+! (-> mem-use data 57 used) box-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ box-bytes 15)))) + (mem-usage-add! mem-use bsp-misc 1 (asize-of (-> this boxes))) ;; add box indices (when (nonzero? (-> this split-box-indices)) - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) - (let ((split-box-index-bytes (* (-> this boxes length) 2))) - (+! (-> mem-use data 57 used) split-box-index-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ split-box-index-bytes 15)))))) + (mem-usage-add! mem-use bsp-misc 1 (* (-> this boxes length) 2)))) ;; add actor-birth-order (when (nonzero? (-> this actor-birth-order)) - (set! (-> mem-use length) (max 58 (-> mem-use length))) - (set! (-> mem-use data 57 name) "bsp-misc") - (+! (-> mem-use data 57 count) 1) ;; add actors - (let ((actor-index-bytes (* (-> this actors length) 4))) - (+! (-> mem-use data 57 used) actor-index-bytes) - (+! (-> mem-use data 57 total) (logand -16 (+ actor-index-bytes 15))))) + (mem-usage-add! mem-use bsp-misc 1 (* (-> this actors length) 4))) ;; add pat (+! (-> mem-use data 62 count) (-> this pat-length)) (let ((pat-bytes (* (-> this pat-length) 4))) @@ -126,7 +76,7 @@ (let ((cameras (-> this cameras))) (when (nonzero? cameras) (dotimes (i (-> cameras length)) - (mem-usage (-> cameras i) mem-use (logior flags 256))))) + (mem-usage (-> cameras i) mem-use (logior flags (mem-usage-flags resource-camera)))))) ;; add the tree itself (mem-usage-bsp-tree this (the-as bsp-node (-> this nodes)) mem-use flags) this) @@ -220,7 +170,7 @@ (new 'static 'rgba :r #x80 :g #xc0 :a #x80)))) ;; run the foreground system (0 check added) (when (nonzero? foreground-engine-execute) - (let ((frame (-> *display* frames (-> *display* on-screen) frame))) + (let ((frame (current-frame))) ;; 0 (foreground-engine-execute (-> this level foreground-draw-engine 0) frame diff --git a/goal_src/jak1/engine/level/level.gc b/goal_src/jak1/engine/level/level.gc index 228d6f00ef..d9f38ff0b5 100644 --- a/goal_src/jak1/engine/level/level.gc +++ b/goal_src/jak1/engine/level/level.gc @@ -796,16 +796,11 @@ 0 (none)) -(defmethod mem-usage ((this level) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this level) (usage memory-usage-block) (flags mem-usage-flags)) "Account for this active level's entity and ambient links, art, code, texture pages, visibility records, and BSP data." (when (= (-> this status) 'active) - (set! (-> usage length) (max 65 (-> usage length))) - (set! (-> usage data 64 name) "entity-links") - (+! (-> usage data 64 count) (-> this entity length)) - (let ((entity-bytes (asize-of (-> this entity)))) - (+! (-> usage data 64 used) entity-bytes) - (+! (-> usage data 64 total) (logand -16 (+ entity-bytes 15)))) + (mem-usage-add! usage entity-links (-> this entity length) (asize-of (-> this entity))) (set! (-> usage length) (max 65 (-> usage length))) (set! (-> usage data 64 name) "ambient-links") (+! (-> usage data 64 count) (-> this ambient length)) @@ -813,12 +808,7 @@ (+! (-> usage data 64 used) ambient-bytes) (+! (-> usage data 64 total) (logand -16 (+ ambient-bytes 15)))) (mem-usage (-> this art-group) usage flags) - (set! (-> usage length) (max 64 (-> usage length))) - (set! (-> usage data 63 name) "level-code") - (+! (-> usage data 63 count) 1) - (let ((code-bytes (&- (-> this code-memory-end) (the-as uint (-> this code-memory-start))))) - (+! (-> usage data 63 used) code-bytes) - (+! (-> usage data 63 total) (logand -16 (+ code-bytes 15)))) + (mem-usage-add! usage level-code 1 (&- (-> this code-memory-end) (the-as uint (-> this code-memory-start)))) (countdown (i (-> this loaded-texture-page-count)) (mem-usage (-> this loaded-texture-page i) usage flags)) (countdown (vis-index 8) @@ -826,19 +816,9 @@ (when vis-record (cond ((zero? vis-index) - (set! (-> usage length) (max 60 (-> usage length))) - (set! (-> usage data 59 name) "bsp-leaf-vis-self") - (+! (-> usage data 59 count) 1) - (let ((vis-bytes (asize-of vis-record))) - (+! (-> usage data 59 used) vis-bytes) - (+! (-> usage data 59 total) (logand -16 (+ vis-bytes 15))))) + (mem-usage-add! usage bsp-leaf-vis-self 1 (asize-of vis-record))) (else - (set! (-> usage length) (max 61 (-> usage length))) - (set! (-> usage data 60 name) "bsp-leaf-vis-adj") - (+! (-> usage data 60 count) 1) - (let ((vis-bytes (+ (asize-of vis-record) (the-as int (-> vis-record allocated-length))))) - (+! (-> usage data 60 used) vis-bytes) - (+! (-> usage data 60 total) (logand -16 (+ vis-bytes 15))))))))) + (mem-usage-add! usage bsp-leaf-vis-adj 1 (+ (asize-of vis-record) (the-as int (-> vis-record allocated-length))))))))) (mem-usage (-> this bsp) usage flags)) this) @@ -962,7 +942,7 @@ (set! (-> this load-commands) load-commands) load-commands) -(defmethod mem-usage ((this level-group) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this level-group) (usage memory-usage-block) (flags mem-usage-flags)) "Account for every allocated level slot." ;; get memory usage of each level (dotimes (i (-> this length)) diff --git a/goal_src/jak1/engine/load/loader.gc b/goal_src/jak1/engine/load/loader.gc index 86a83736ad..0ef36845c4 100644 --- a/goal_src/jak1/engine/load/loader.gc +++ b/goal_src/jak1/engine/load/loader.gc @@ -25,30 +25,15 @@ i (-> this string-array i) (-> this data-array i) - (mem-size (-> this data-array i) #f 0))) + (mem-size (-> this data-array i) #f (mem-usage-flags)))) this) -(defmethod mem-usage ((this load-dir) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this load-dir) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the directory and both parallel arrays in the array memory category, then add the memory owned by every loaded data object. Pass flags through to each child." - (set! (-> usage length) (max 82 (-> usage length))) - (set! (-> usage data 81 name) "array") - (+! (-> usage data 81 count) 1) - (let ((directory-size (asize-of this))) - (+! (-> usage data 81 used) directory-size) - (+! (-> usage data 81 total) (logand -16 (+ directory-size 15)))) - (set! (-> usage length) (max 82 (-> usage length))) - (set! (-> usage data 81 name) "array") - (set! (-> usage data 81 count) (-> usage data 81 count)) - (let ((name-array-size (asize-of (-> this string-array)))) - (+! (-> usage data 81 used) name-array-size) - (+! (-> usage data 81 total) (logand -16 (+ name-array-size 15)))) - (set! (-> usage length) (max 82 (-> usage length))) - (set! (-> usage data 81 name) "array") - (set! (-> usage data 81 count) (-> usage data 81 count)) - (let ((data-array-size (asize-of (-> this data-array)))) - (+! (-> usage data 81 used) data-array-size) - (+! (-> usage data 81 total) (logand -16 (+ data-array-size 15)))) + (mem-usage-add! usage array 1 (asize-of this)) + (mem-usage-add! usage array 0 (asize-of (-> this string-array))) + (mem-usage-add! usage array 0 (asize-of (-> this data-array))) (dotimes (i (-> this data-array length)) (mem-usage (-> this data-array i) usage flags)) (the-as load-dir #f)) diff --git a/goal_src/jak1/engine/math/euler.gc b/goal_src/jak1/engine/math/euler.gc index a17f6b5efe..3714284f64 100644 --- a/goal_src/jak1/engine/math/euler.gc +++ b/goal_src/jak1/engine/math/euler.gc @@ -24,7 +24,7 @@ (matrix-identity! dst-mat) (let ((working-angles (new 'stack-no-clear 'vector))) ;; copy to temp storage. - (set! (-> working-angles quad) (-> src quad)) + (vector-copy! working-angles src) (if (= (logand (the int (-> working-angles data 3)) 1) 1) (let ((angle-swap (-> working-angles data 0))) (set! (-> working-angles data 0) (-> working-angles data 2)) diff --git a/goal_src/jak1/engine/math/matrix-h.gc b/goal_src/jak1/engine/math/matrix-h.gc index d942004682..05b8b7c8a3 100644 --- a/goal_src/jak1/engine/math/matrix-h.gc +++ b/goal_src/jak1/engine/math/matrix-h.gc @@ -30,6 +30,7 @@ (defun matrix-copy! ((dst matrix) (src matrix)) "Copy all four aligned rows from src to dst and return dst." + (declare (inline)) (let ((row0 (-> src vector 0 quad)) (row1 (-> src vector 1 quad)) (row2 (-> src vector 2 quad)) diff --git a/goal_src/jak1/engine/math/matrix.gc b/goal_src/jak1/engine/math/matrix.gc index 98c56bf1dc..606e9c3188 100644 --- a/goal_src/jak1/engine/math/matrix.gc +++ b/goal_src/jak1/engine/math/matrix.gc @@ -243,10 +243,7 @@ a time when matrix*! wasn't safe to use in place. This is unused." (let ((temp-mat (new-stack-matrix0))) (matrix*! temp-mat src1 src2) - (set! (-> dst vector 0 quad) (-> temp-mat vector 0 quad)) - (set! (-> dst vector 1 quad) (-> temp-mat vector 1 quad)) - (set! (-> dst vector 2 quad) (-> temp-mat vector 2 quad)) - (set! (-> dst vector 3 quad) (-> temp-mat vector 3 quad))) + (matrix-copy! dst temp-mat)) dst) (defun vector-matrix*! ((dst vector) (vec vector) (mat matrix)) diff --git a/goal_src/jak1/engine/math/transformq.gc b/goal_src/jak1/engine/math/transformq.gc index b443286372..82918116d7 100644 --- a/goal_src/jak1/engine/math/transformq.gc +++ b/goal_src/jak1/engine/math/transformq.gc @@ -164,9 +164,9 @@ (defun transformq-copy! ((dst transformq) (src transformq)) "Copy translation, quaternion rotation, and scale from src to dst." - (set! (-> dst trans quad) (-> src trans quad)) - (set! (-> dst rot quad) (-> src rot quad)) - (set! (-> dst scale quad) (-> src scale quad)) + (vector-copy! (-> dst trans) (-> src trans)) + (vector-copy! (-> dst rot) (-> src rot)) + (vector-copy! (-> dst scale) (-> src scale)) dst) (defun matrix<-transformq! ((dst matrix) (src transformq)) diff --git a/goal_src/jak1/engine/math/vector.gc b/goal_src/jak1/engine/math/vector.gc index 1d824eb072..13afc424e6 100644 --- a/goal_src/jak1/engine/math/vector.gc +++ b/goal_src/jak1/engine/math/vector.gc @@ -662,7 +662,7 @@ "Scale value.xyz to the requested length into out, copy zero vectors unchanged, and set out.w to 1." (let ((old-length (vector-length value))) (if (= old-length 0.0) - (set! (-> out quad) (-> value quad)) + (vector-copy! out value) (let ((scale (/ target-length old-length))) (set! (-> out x) (* (-> value x) scale)) (set! (-> out y) (* (-> value y) scale)) @@ -706,7 +706,7 @@ (x (-> value x)) (cosine (cos angle)) (sine (sin angle))) - (set! (-> out quad) (-> value quad)) + (vector-copy! out value) (set! (-> out z) (- (* z cosine) (* x sine))) (set! (-> out x) (+ (* z sine) (* x cosine)))) out) @@ -778,8 +778,8 @@ (vf4 :class vf)) (init-vf0-vector) (cond - ((>= 0.0 alpha) (set! (-> out quad) (-> a quad))) - ((>= alpha 1.0) (set! (-> out quad) (-> b quad))) + ((>= 0.0 alpha) (vector-copy! out a)) + ((>= alpha 1.0) (vector-copy! out b)) (else (let ((v1-2 out)) (let ((f0-2 alpha)) (.lvf vf1 (&-> a quad)) (.lvf vf2 (&-> b quad)) (let ((a1-1 f0-2)) (.mov vf4 a1-1))) @@ -812,8 +812,8 @@ (vf3 :class vf) (vf4 :class vf)) (cond - ((>= 0.0 alpha) (set! (-> out quad) (-> a quad))) - ((>= alpha 1.0) (set! (-> out quad) (-> b quad))) + ((>= 0.0 alpha) (vector-copy! out a)) + ((>= alpha 1.0) (vector-copy! out b)) (else (let ((v1-2 out)) (let ((f0-2 alpha)) (.lvf vf1 (&-> a quad)) (.lvf vf2 (&-> b quad)) (let ((a1-1 f0-2)) (.mov vf4 a1-1))) @@ -885,8 +885,8 @@ (defun vector-deg-lerp-clamp! ((out vector) (minimum vector) (maximum vector) (amount float)) "Apply clamped shortest-angle interpolation to three lanes and set out.w to 1." (cond - ((>= 0.0 amount) (set! (-> out quad) (-> minimum quad))) - ((>= amount 1.0) (set! (-> out quad) (-> maximum quad))) + ((>= 0.0 amount) (vector-copy! out minimum)) + ((>= amount 1.0) (vector-copy! out maximum)) (else (set! (-> out x) (deg-lerp-clamp (-> minimum x) (-> maximum x) amount)) (set! (-> out y) (deg-lerp-clamp (-> minimum y) (-> maximum y) amount)) @@ -955,12 +955,12 @@ (defun sphere<-vector! ((out sphere) (center vector)) "Copy center.xyz into out while preserving its radius." - (let ((f0-0 (-> out w))) (set! (-> out quad) (-> center quad)) (set! (-> out w) f0-0)) + (let ((f0-0 (-> out w))) (vector-copy! out center) (set! (-> out w) f0-0)) out) (defun sphere<-vector+r! ((out sphere) (center vector) (radius float)) "Copy center.xyz and radius into out." - (set! (-> out quad) (-> center quad)) + (vector-copy! out center) (set! (-> out w) radius) out) diff --git a/goal_src/jak1/engine/nav/navigate.gc b/goal_src/jak1/engine/nav/navigate.gc index c4e649a891..0a029474ed 100644 --- a/goal_src/jak1/engine/nav/navigate.gc +++ b/goal_src/jak1/engine/nav/navigate.gc @@ -323,16 +323,14 @@ (distance (vector-segment-distance-point! point edge-start (-> vertices (-> poly vertex (mod (+ i 1) 3))) candidate))) (when (< distance closest-distance) (set! closest-distance distance) - (set! (-> closest-point quad) (-> candidate quad)))))) - (set! (-> result quad) (-> closest-point quad))) + (vector-copy! closest-point candidate))))) + (vector-copy! result closest-point)) result) (defmethod project-point-into-tri-2d ((this nav-mesh) (poly nav-poly) (result vector) (point vector)) "Store point when it lies inside poly in XZ, otherwise store the closest point on the perimeter." - (if (point-in-poly? this poly point) - (set! (-> result quad) (-> point quad)) - (closest-point-on-boundary this poly result point)) + (if (point-in-poly? this poly point) (vector-copy! result point) (closest-point-on-boundary this poly result point)) result) (defun point-inside-rect? ((node nav-node) (point vector) (y-threshold float)) @@ -1105,7 +1103,7 @@ (edge-end-vertex nav-vertex)) (let ((vertices (-> this vertex)) (clipped-edge -1)) - (set! (-> result-travel quad) (-> desired-travel quad)) + (vector-copy! result-travel desired-travel) (dotimes (edge-index 3) (let* ((edge-start (-> vertices (-> poly vertex (-> *edge-vert0-table* edge-index)))) (edge-end (-> vertices (-> poly vertex (-> *edge-vert1-table* edge-index)))) @@ -1165,7 +1163,7 @@ (find-flags 0) (poly (find-poly mesh point-local (-> this nearest-y-threshold) (the-as (pointer nav-control-flags) (& find-flags))))) (cond - ((logtest? #x100000 find-flags) (set! (-> result quad) (-> point quad))) + ((logtest? #x100000 find-flags) (vector-copy! result point)) (else (closest-point-on-boundary mesh poly result point-local) (vector+! result result (-> mesh origin))))) result) @@ -1332,33 +1330,13 @@ 0)) (none)) -(defmethod mem-usage ((this nav-mesh) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this nav-mesh) (usage memory-usage-block) (flags mem-usage-flags)) "Add the mesh object, vertex array, triangle array, and packed route table allocations to the navigation memory-usage bucket." - (set! (-> usage length) (max 46 (-> usage length))) - (set! (-> usage data 45 name) "nav-mesh") - (+! (-> usage data 45 count) 1) - (let ((object-bytes (asize-of this))) - (+! (-> usage data 45 used) object-bytes) - (+! (-> usage data 45 total) (logand -16 (+ object-bytes 15)))) - (set! (-> usage length) (max 46 (-> usage length))) - (set! (-> usage data 45 name) "nav-mesh") - (+! (-> usage data 45 count) 1) - (let ((vertex-bytes (* (-> this vertex-count) 16))) - (+! (-> usage data 45 used) vertex-bytes) - (+! (-> usage data 45 total) (logand -16 (+ vertex-bytes 15)))) - (set! (-> usage length) (max 46 (-> usage length))) - (set! (-> usage data 45 name) "nav-mesh") - (+! (-> usage data 45 count) 1) - (let ((poly-bytes (* (-> this poly-count) 8))) - (+! (-> usage data 45 used) poly-bytes) - (+! (-> usage data 45 total) (logand -16 (+ poly-bytes 15)))) - (set! (-> usage length) (max 46 (-> usage length))) - (set! (-> usage data 45 name) "nav-mesh") - (+! (-> usage data 45 count) 1) - (let ((route-bytes (/ (* (* (-> this poly-count) (-> this poly-count)) 2) 8))) - (+! (-> usage data 45 used) route-bytes) - (+! (-> usage data 45 total) (logand -16 (+ route-bytes 15)))) + (mem-usage-add! usage nav-mesh 1 (asize-of this)) + (mem-usage-add! usage nav-mesh 1 (* (-> this vertex-count) 16)) + (mem-usage-add! usage nav-mesh 1 (* (-> this poly-count) 8)) + (mem-usage-add! usage nav-mesh 1 (/ (* (* (-> this poly-count) (-> this poly-count)) 2) 8)) (the-as nav-mesh 0)) (defmethod set-current-poly! ((this nav-control) (poly nav-poly)) @@ -1404,7 +1382,7 @@ "Append shape's enabled body and extra navigation spheres to control, combining each radius with the navigating body's radius and rejecting spheres beyond the ten-meter cull range." (when (logtest? (-> shape nav-flags) (nav-flags avoid-body)) - (set! (-> body-sphere quad) (-> shape root-prim prim-core world-sphere quad)) + (vector-copy! body-sphere (-> shape root-prim prim-core world-sphere)) (set! (-> body-sphere w) (-> shape nav-radius)) (let ((body-control control) (body-sphere-input body-sphere)) @@ -1448,7 +1426,7 @@ (target-control (-> *target* control))) (let ((player-body-sphere candidate-sphere)) (when (logtest? (-> target-control nav-flags) (nav-flags avoid-body)) - (set! (-> player-body-sphere quad) (-> target-control root-prim prim-core world-sphere quad)) + (vector-copy! player-body-sphere (-> target-control root-prim prim-core world-sphere)) (set! (-> player-body-sphere w) (-> target-control nav-radius)) (let ((player-destination-control player-nav)) (when (< (-> player-destination-control num-spheres) (-> player-destination-control max-spheres)) @@ -1484,40 +1462,36 @@ (set! (-> static-destination w) static-combined-radius) (+! (-> static-destination-control num-spheres) 1))))) 0)) - (let* ((user-connection (-> user-list alive-list next0)) - (next-connection (-> user-connection next0))) - (while (!= user-connection (-> user-list alive-list-end)) - (let ((other-shape (the-as collide-shape (-> (the-as connection user-connection) param3)))) - (when (not (or (= other-shape (-> this shape)) (not (logtest? collision-mask (-> other-shape root-prim prim-core collide-as))))) - (let ((other-nav this)) - (let ((sv-112 candidate-sphere)) - (when (logtest? (-> other-shape nav-flags) (nav-flags avoid-body)) - (set! (-> sv-112 quad) (-> other-shape root-prim prim-core world-sphere quad)) - (set! (-> sv-112 w) (-> other-shape nav-radius)) - (let ((sv-80 other-nav)) - (when (< (-> sv-80 num-spheres) (-> sv-80 max-spheres)) - (let ((sv-96 (-> sv-80 sphere (-> sv-80 num-spheres))) - (f1-3 (vector-vector-xz-distance-squared sv-112 (-> sv-80 shape trans))) - (f0-9 (+ (-> sv-112 w) (-> sv-80 shape nav-radius)))) - ;; og:preserve-this added a NaN check here. it seems like some enemies have bogus positions (maybe on their first frame?) - (when (and (< f1-3 (square (+ 40960.0 f0-9))) (not (is-nan? (-> sv-112 x)))) - (vector-! (the-as vector sv-96) sv-112 (-> sv-80 mesh origin)) - (set! (-> sv-96 w) f0-9) - (+! (-> sv-80 num-spheres) 1))))) - 0)) - (when (logtest? (-> other-shape nav-flags) (nav-flags avoid-extra-sphere)) - (let ((other-extra-sphere (-> other-shape process nav extra-nav-sphere))) - (when (< (-> other-nav num-spheres) (-> other-nav max-spheres)) - (let ((other-extra-destination (-> other-nav sphere (-> other-nav num-spheres))) - (other-extra-distance-squared (vector-vector-xz-distance-squared other-extra-sphere (-> other-nav shape trans))) - (other-extra-combined-radius (+ (-> other-extra-sphere w) (-> other-nav shape nav-radius)))) - (when (< other-extra-distance-squared (square (+ 40960.0 other-extra-combined-radius))) - (vector-! (the-as vector other-extra-destination) other-extra-sphere (-> other-nav mesh origin)) - (set! (-> other-extra-destination w) other-extra-combined-radius) - (+! (-> other-nav num-spheres) 1))))) - 0)))) - (set! user-connection next-connection) - (set! next-connection (-> next-connection next0))))) + (iterate-engine-connections (user-connection user-list) + (let ((other-shape (the-as collide-shape (-> (the-as connection user-connection) param3)))) + (when (not (or (= other-shape (-> this shape)) (not (logtest? collision-mask (-> other-shape root-prim prim-core collide-as))))) + (let ((other-nav this)) + (let ((sv-112 candidate-sphere)) + (when (logtest? (-> other-shape nav-flags) (nav-flags avoid-body)) + (vector-copy! sv-112 (-> other-shape root-prim prim-core world-sphere)) + (set! (-> sv-112 w) (-> other-shape nav-radius)) + (let ((sv-80 other-nav)) + (when (< (-> sv-80 num-spheres) (-> sv-80 max-spheres)) + (let ((sv-96 (-> sv-80 sphere (-> sv-80 num-spheres))) + (f1-3 (vector-vector-xz-distance-squared sv-112 (-> sv-80 shape trans))) + (f0-9 (+ (-> sv-112 w) (-> sv-80 shape nav-radius)))) + ;; og:preserve-this added a NaN check here. it seems like some enemies have bogus positions (maybe on their first frame?) + (when (and (< f1-3 (square (+ 40960.0 f0-9))) (not (is-nan? (-> sv-112 x)))) + (vector-! (the-as vector sv-96) sv-112 (-> sv-80 mesh origin)) + (set! (-> sv-96 w) f0-9) + (+! (-> sv-80 num-spheres) 1))))) + 0)) + (when (logtest? (-> other-shape nav-flags) (nav-flags avoid-extra-sphere)) + (let ((other-extra-sphere (-> other-shape process nav extra-nav-sphere))) + (when (< (-> other-nav num-spheres) (-> other-nav max-spheres)) + (let ((other-extra-destination (-> other-nav sphere (-> other-nav num-spheres))) + (other-extra-distance-squared (vector-vector-xz-distance-squared other-extra-sphere (-> other-nav shape trans))) + (other-extra-combined-radius (+ (-> other-extra-sphere w) (-> other-nav shape nav-radius)))) + (when (< other-extra-distance-squared (square (+ 40960.0 other-extra-combined-radius))) + (vector-! (the-as vector other-extra-destination) other-extra-sphere (-> other-nav mesh origin)) + (set! (-> other-extra-destination w) other-extra-combined-radius) + (+! (-> other-nav num-spheres) 1))))) + 0)))))) 0 (none)) @@ -1581,7 +1555,7 @@ (vector-! to-center circle-center point) (set! (-> to-center y) 0.0) (vector-normalize-copy! center-direction to-center 1.0) - (set! (-> perpendicular-direction quad) (-> center-direction quad)) + (vector-copy! perpendicular-direction center-direction) (set! (-> perpendicular-direction x) (-> center-direction z)) (set! (-> perpendicular-direction z) (- (-> center-direction x))) (let ((radius (-> circle-center w)) @@ -1643,15 +1617,15 @@ fallback direction. Return #t when travel was deflected." (local-vars (deflected symbol) (hit-sphere int) (right-dot-sign int) (tangent-right-dot-sign int)) (let ((work (new 'stack-no-clear 'nav-control-cfs-work))) - (set! (-> work in-dir quad) (-> desired-travel quad)) + (vector-copy! (-> work in-dir) desired-travel) (set! (-> work in-dir y) 0.0) (vector-normalize! (-> work in-dir) 1.0) (set! (-> work travel-len) (vector-dot (-> work in-dir) desired-travel)) - (set! (-> work right-dir quad) (-> work in-dir quad)) + (vector-copy! (-> work right-dir) (-> work in-dir)) (set! (-> work right-dir x) (- (-> work in-dir z))) (set! (-> work right-dir z) (-> work in-dir x)) - (set! (-> work best-dir 0 quad) (-> work in-dir quad)) - (set! (-> work best-dir 1 quad) (-> work in-dir quad)) + (vector-copy! (-> work best-dir 0) (-> work in-dir)) + (vector-copy! (-> work best-dir 1) (-> work in-dir)) (set! (-> work best-dir-angle 0) 0.0) (set! (-> work best-dir-angle 1) 0.0) (set! (-> work initial-ignore-mask) (the-as uint 0)) @@ -1676,7 +1650,7 @@ (-> this sphere) (the-as int (-> work initial-ignore-mask)))) (when (= (-> work i-first-sphere) -1) - (set! (-> result-travel quad) (-> desired-travel quad)) + (vector-copy! result-travel desired-travel) (set! deflected #f) (b! #t cfg-46 :delay (nop!)) (the-as none 0)) @@ -1688,7 +1662,7 @@ (shift-arith-right-32 right-dot-sign right-dot-bits 31)) (let ((candidate-side (logand right-dot-sign 1)) (turn-cost (- 1.0 (vector-dot (-> work in-dir) (-> work temp-dir i))))) - (set! (-> work best-dir candidate-side quad) (-> work temp-dir i quad)) + (vector-copy! (-> work best-dir candidate-side) (-> work temp-dir i)) (set! (-> work best-dir-angle candidate-side) turn-cost))) 0 (set! (-> work sign) 1.0) @@ -1712,7 +1686,7 @@ (let ((candidate-turn-cost (* side-sign (* (-> sign-selector data (logand tangent-right-dot-sign 1)) (- 1.0 (vector-dot tangent-direction input-direction)))))) (when (< (-> work best-dir-angle side) candidate-turn-cost) - (set! (-> work best-dir side quad) (-> work temp-dir j quad)) + (vector-copy! (-> work best-dir side) (-> work temp-dir j)) (set! (-> work best-dir-angle side) candidate-turn-cost) (set! (-> work dir-update) #t))))) (label cfg-31) @@ -1818,7 +1792,7 @@ (cond ((or (vector= goal (-> this target-pos)) (< (fabs angle-difference) 364.0889)) (logior! (-> this flags) (nav-control-flags heading-aligned)) - (set! (-> result-position quad) (-> goal quad))) + (vector-copy! result-position goal)) (else (let ((new-direction (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> body quat)))) (vector-rotate-y! new-direction new-direction (fmax (fmin angle-difference max-turn) (- max-turn))) @@ -1830,7 +1804,7 @@ (not (logtest? (-> this flags) (nav-control-flags gradual-turn-to-target)))) (logior! (-> this flags) (nav-control-flags heading-aligned)) (vector-! (-> this travel) goal (-> body trans)) - (set! (-> result-position quad) (-> goal quad)))))) + (vector-copy! result-position goal))))) (none)) (defmethod find-poly-fast-from-world ((this nav-control) (world-point vector)) @@ -2072,7 +2046,7 @@ (portal (new 'stack-no-clear 'nav-route-portal)) (in-corridor (the-as symbol #f))) (vector-! body-local (-> this shape trans) (-> this mesh origin)) - (set! (-> current-position quad) (-> body-local quad)) + (vector-copy! current-position body-local) (let ((target-local (new 'stack-no-clear 'vector))) (vector-! target-local destination (-> this mesh origin)) (set! (-> this target-poly) (find-poly (-> this mesh) target-local (-> this nearest-y-threshold) (&-> this flags))) diff --git a/goal_src/jak1/engine/physics/trajectory.gc b/goal_src/jak1/engine/physics/trajectory.gc index af2ba33109..1e57fa02a6 100644 --- a/goal_src/jak1/engine/physics/trajectory.gc +++ b/goal_src/jak1/engine/physics/trajectory.gc @@ -10,7 +10,7 @@ (defmethod eval-position! ((this trajectory) (elapsed-time float) (result vector)) "Evaluate position after elapsed-time game-time ticks into result. Vertical motion includes one half gravity times time squared; evaluation is not clamped to the solved flight duration." - (set! (-> result quad) (-> this initial-position quad)) + (vector-copy! result (-> this initial-position)) (+! (-> result x) (* elapsed-time (-> this initial-velocity x))) (+! (-> result y) (* elapsed-time (-> this initial-velocity y))) (+! (-> result z) (* elapsed-time (-> this initial-velocity z))) @@ -20,7 +20,7 @@ (defmethod eval-velocity! ((this trajectory) (elapsed-time float) (result vector)) "Evaluate velocity after elapsed-time game-time ticks into result. Only the vertical component changes under gravity." - (set! (-> result quad) (-> this initial-velocity quad)) + (vector-copy! result (-> this initial-velocity)) (+! (-> result y) (* elapsed-time (-> this gravity))) result) @@ -28,7 +28,7 @@ "Solve the initial velocity that moves from start to destination in duration game-time ticks under constant vertical gravity. Store the supplied duration; callers must provide a positive, nonzero duration." - (set! (-> this initial-position quad) (-> start quad)) + (vector-copy! (-> this initial-position) start) (set! (-> this gravity) gravity) (set! (-> this time) duration) (let ((xz-speed (/ (vector-vector-xz-distance destination start) duration))) @@ -79,9 +79,9 @@ (let ((previous-position (new 'stack-no-clear 'vector)) (position (new 'stack-no-clear 'vector)) (num-segments 10)) - (set! (-> position quad) (-> this initial-position quad)) + (vector-copy! position (-> this initial-position)) (dotimes (i num-segments) - (set! (-> previous-position quad) (-> position quad)) + (vector-copy! previous-position position) (let ((sample-time (* (-> this time) (/ (+ 1.0 (the float i)) (the float num-segments))))) (eval-position! this sample-time position)) (add-debug-line #t diff --git a/goal_src/jak1/engine/target/collide-reaction-target.gc b/goal_src/jak1/engine/target/collide-reaction-target.gc index 0599c788f7..4ae7072198 100644 --- a/goal_src/jak1/engine/target/collide-reaction-target.gc +++ b/goal_src/jak1/engine/target/collide-reaction-target.gc @@ -14,7 +14,7 @@ "Record surface-normal and its dot against gravity-normal as surface-angle, record the equivalent dot for the unadjusted polygon normal as poly-angle, and retain the largest head-on contact angle observed this frame. velocity supplies the direction opposite the contact normal for that test." - (set! (-> cshape surface-normal quad) (-> surface-normal quad)) + (vector-copy! (-> cshape surface-normal) surface-normal) (set! (-> cshape surface-angle) (vector-dot surface-normal (-> cshape dynam gravity-normal))) (set! (-> cshape poly-angle) (vector-dot (-> cshape poly-normal) (-> cshape dynam gravity-normal))) (set! (-> cshape touch-angle) @@ -117,7 +117,7 @@ (vector-dot (-> control dynam gravity-normal) (vector-! (new 'stack-no-clear 'vector) (-> intersection best-tri intersect) (-> probe-result intersect)))) (set! (-> control low-coverage-probe1-pat) (the-as float (-> probe-result pat))) - (set! (-> control low-coverage-probe1-normal quad) (-> probe-result normal quad)) + (vector-copy! (-> control low-coverage-probe1-normal) (-> probe-result normal)) 0)) ;; Probe the near side. Start 0.2 m above and 0.2 m behind the contact, then sweep five meters ;; down and one meter farther inward. A nearby non-wall hit confirms that there is supporting @@ -140,7 +140,7 @@ 0.0) (set! (-> control low-coverage-probe2-dist) (vector-vector-distance probe2-start (-> probe-result intersect))) (set! (-> control low-coverage-probe2-pat) (the-as uint (-> probe-result pat))) - (set! (-> control low-coverage-probe2-normal quad) (-> probe-result normal quad)) + (vector-copy! (-> control low-coverage-probe2-normal) (-> probe-result normal)) 0)) ;; A ledge needs a nonvertical edge, a large drop (or wall) beyond it, and a close standable ;; surface behind it. Distances scale with the intersecting primitive's sphere radius. @@ -232,7 +232,7 @@ (if (logtest? (-> control mod-surface flags) (surface-flags jump)) (logior! reaction-flags (cshape-reaction-flags air-mode))) (let ((primitive-center (new 'stack-no-clear 'vector))) - (set! (-> primitive-center quad) (-> intersection best-from-prim prim-core world-sphere quad)) + (vector-copy! primitive-center (-> intersection best-from-prim prim-core world-sphere)) (vector-! contact-direction primitive-center (-> intersection best-tri intersect))) (vector-normalize! contact-direction 1.0) ;; Coverage is how directly the primitive center-to-contact direction agrees with the triangle @@ -243,10 +243,10 @@ (vector-flatten! contact-direction contact-direction (-> intersection best-tri normal)) (vector-normalize! contact-direction 1.0)) (if (< (-> control coverage) 0.9999) (logior! reaction-flags (cshape-reaction-flags low-coverage glancing))) - (set! (-> contact-normal quad) (-> contact-direction quad)) + (vector-copy! contact-normal contact-direction) (if (= (-> intersection best-u) 0.0) (move-by-vector! control (vector-normalize-copy! (new-stack-vector0) contact-normal 3.0))) - (set! (-> control poly-normal quad) (-> intersection best-tri normal quad)) + (vector-copy! (-> control poly-normal) (-> intersection best-tri normal)) (collide-shape-moving-angle-set! control contact-normal (-> velocities vector 0)) ;; poly-angle is a cosine against gravity: any negative value faces downward, while values below ;; -0.2 are strong ceiling contacts. @@ -284,8 +284,8 @@ (cond ((-> intersection best-to-prim) (logior! status (collide-status touch-actor)) - (set! (-> control actor-contact-pt quad) (-> intersection best-tri intersect quad)) - (set! (-> control actor-contact-normal quad) (-> control poly-normal quad)) + (vector-copy! (-> control actor-contact-pt) (-> intersection best-tri intersect)) + (vector-copy! (-> control actor-contact-normal) (-> control poly-normal)) (set! (-> control actor-contact-handle) (process->handle (-> intersection best-to-prim cshape process)))) ((= (-> control poly-pat material) (pat-material waterbottom))) (else (logior! status (collide-status touch-background)))) @@ -294,9 +294,9 @@ (logior! reaction-flags (cshape-reaction-flags hit-wall)) (logior! status (collide-status touch-wall)) (set! (-> control cur-pat mode) 1) - (set! (-> control wall-contact-pt quad) (-> intersection best-tri intersect quad)) - (set! (-> control wall-contact-poly-normal quad) (-> control poly-normal quad)) - (set! (-> control wall-contact-normal quad) (-> contact-normal quad)) + (vector-copy! (-> control wall-contact-pt) (-> intersection best-tri intersect)) + (vector-copy! (-> control wall-contact-poly-normal) (-> control poly-normal)) + (vector-copy! (-> control wall-contact-normal) contact-normal) (set! (-> control wall-pat) (-> intersection best-tri pat)) ;; This read is intentionally dead. The disabled branch below is an old wall-bounce experiment; ;; normal wall response projects the incoming velocity onto the wall plane. @@ -328,7 +328,7 @@ ;; target from sinking into the surface. (logior! status (collide-status on-surface)) (set! (-> control cur-pat mode) 0) - (if (= (-> intersection best-from-prim prim-id) 6) (set! (-> control local-normal quad) (-> contact-normal quad))) + (if (= (-> intersection best-from-prim prim-id) 6) (vector-copy! (-> control local-normal) contact-normal)) (vector-reflect-flat! velocity-out (-> velocities vector 0) contact-normal) (vector+! velocity-out velocity-out contact-normal) (set! (-> control ground-touch-point w) 0.0) @@ -337,13 +337,13 @@ (when (not (or (logtest? reaction-flags (cshape-reaction-flags wall-by-pat wall-by-angle hit-wall low-coverage)) (nonzero? (-> control poly-pat event)))) (logior! status (collide-status on-ground)) - (set! (-> control ground-poly-normal quad) (-> control poly-normal quad)) - (set! (-> control ground-contact-normal quad) (-> contact-normal quad)) + (vector-copy! (-> control ground-poly-normal) (-> control poly-normal)) + (vector-copy! (-> control ground-contact-normal) contact-normal) (set! (-> control ground-local-norm-dot-grav) (vector-dot contact-normal (-> control dynam gravity-normal))) (set-time! (-> control last-time-on-ground)) (set! (-> control ground-pat) (-> control poly-pat)) - (set! (-> control ground-touch-point quad) (-> intersection best-tri intersect quad)) - (set! (-> control ground-contact-sphere-center quad) (-> intersection best-from-prim prim-core world-sphere quad)) + (vector-copy! (-> control ground-touch-point) (-> intersection best-tri intersect)) + (vector-copy! (-> control ground-contact-sphere-center) (-> intersection best-from-prim prim-core world-sphere)) (logior! reaction-flags (cshape-reaction-flags on-ground)) (if (= (-> control poly-pat material) (pat-material waterbottom)) (logior! status (collide-status on-water)))))) (logior! (-> control status) status) diff --git a/goal_src/jak1/engine/target/logic-target.gc b/goal_src/jak1/engine/target/logic-target.gc index 7ec37853b0..ff47109198 100644 --- a/goal_src/jak1/engine/target/logic-target.gc +++ b/goal_src/jak1/engine/target/logic-target.gc @@ -31,9 +31,9 @@ (forward-up-nopitch->inv-matrix (-> self control c-R-w) forward (-> self control local-normal))) (matrix-transpose! (-> self control w-R-c) (-> self control c-R-w)) (vector-matrix*! (-> self control transv-ctrl) world-velocity (-> self control w-R-c)) - (set! (-> self control last-gravity-normal quad) (-> self control gravity-normal quad)) + (vector-copy! (-> self control last-gravity-normal) (-> self control gravity-normal)) (let ((gravity-normal (-> self control gravity-normal))) - (set! (-> gravity-normal quad) (-> self control dynam gravity-normal quad)) + (vector-copy! gravity-normal (-> self control dynam gravity-normal)) gravity-normal)) (defbehavior vector-turn-to target ((new-direction vector)) @@ -295,14 +295,14 @@ "Read the movement stick into a camera-relative world XZ direction, cache the current and previous direction and magnitude once per display frame, and return the direction in the supplied vector." (when (!= (-> self control time-of-last-pad-read) (-> *display* real-frame-counter)) - (set! (-> self control last-pad-xz-dir quad) (-> self control pad-xz-dir quad)) + (vector-copy! (-> self control last-pad-xz-dir) (-> self control pad-xz-dir)) (set! (-> self control last-pad-magnitude) (-> self control pad-magnitude)) (set! (-> self control time-of-last-pad-read) (-> *display* real-frame-counter))) (set! (-> direction-out x) (sin (-> self control cpad stick0-dir))) (set! (-> direction-out y) 0.0) (set! (-> direction-out z) (cos (-> self control cpad stick0-dir))) (set! (-> direction-out w) 0.0) - (set! (-> self control pad-xz-dir quad) (-> direction-out quad)) + (vector-copy! (-> self control pad-xz-dir) direction-out) (set! (-> self control pad-magnitude) (-> self control cpad stick0-speed)) (vector-matrix*! direction-out direction-out (matrix-local->world #t #f))) @@ -393,20 +393,19 @@ (warp-vector-into-surface! surface-heading heading (-> self control local-normal)) (set! (-> self control last-turn-to-magnitude) (-> self control turn-to-magnitude)) (set! (-> self control last-turn-to-angle) (-> self control turn-to-angle)) - (set! (-> self control last-to-target-pt-xz quad) (-> self control to-target-pt-xz quad)) - (set! (-> self control last-turn-to-target quad) (-> self control turn-to-target quad)) + (vector-copy! (-> self control last-to-target-pt-xz) (-> self control to-target-pt-xz)) + (vector-copy! (-> self control last-turn-to-target) (-> self control turn-to-target)) (vector-float*! (-> self control turn-to-target) surface-heading magnitude) (if (< 0.0 magnitude) (warp-vector-into-surface! (-> self control to-target-pt-xz) heading *up-vector*)) ;; push the newest turn direction (in the control frame) onto the 8-entry rolling turn history. (dotimes (i 7) - (set! (-> self control turn-history-ctrl (+ i 1) quad) (-> self control turn-history-ctrl i quad))) - (set! (-> self control turn-history-ctrl 0 quad) - (-> (vector-matrix*! surface-heading surface-heading (-> self control w-R-c)) quad)) + (vector-copy! (-> self control turn-history-ctrl (+ i 1)) (-> self control turn-history-ctrl i))) + (vector-copy! (-> self control turn-history-ctrl 0) (vector-matrix*! surface-heading surface-heading (-> self control w-R-c))) (let ((turn-angle (atan (-> surface-heading x) (-> surface-heading z)))) (set! (-> self control turn-to-magnitude) magnitude) (set! (-> self control turn-to-angle) turn-angle)) (let ((target-speed (* magnitude (-> self control current-surface target-speed)))) - (set! (-> self control target-transv quad) (-> (vector-normalize! surface-heading target-speed) quad)))) + (vector-copy! (-> self control target-transv) (vector-normalize! surface-heading target-speed)))) (let ((mark-position (new-stack-vector0))) (vector-matrix*! mark-position (-> self control target-transv) (-> self control c-R-w)) (vector-float*! mark-position mark-position 0.5) @@ -425,7 +424,7 @@ (let ((desired-velocity (-> self control target-transv)) (velocity (-> self control transv-ctrl))) (let ((original-target (new 'stack-no-clear 'vector))) - (set! (-> original-target quad) (-> self control target-transv quad)) + (vector-copy! original-target (-> self control target-transv)) ;; downhill-local = the downhill direction of the standing surface (down = negated gravity ;; normal, flattened into the surface plane), in the control frame; its length encodes how ;; steep the slope is (zero on flat ground). @@ -682,22 +681,22 @@ surface hooks, handle look-around and debug flight input, arm eligible edge grabs, and trigger an endless-fall death below the level floor." (level-setup) - (set! (-> self control last-transv quad) (-> self control transv quad)) + (vector-copy! (-> self control last-transv) (-> self control transv)) ((-> self control current-surface active-hook)) (cond ((logtest? (-> self control status) (collide-status on-surface)) (set-time! (-> self control last-time-on-surface)) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)) (if (and (>= (-> self control coverage) 1.0) (not (logtest? (-> self control status) (collide-status touch-actor on-water))) (logtest? (-> self control status) (collide-status on-ground))) - (set! (-> self control last-known-safe-ground quad) (-> self control trans quad))) + (vector-copy! (-> self control last-known-safe-ground) (-> self control trans))) ((-> self control current-surface touch-hook))) (else (let ((position (-> self control trans))) (when (logtest? (-> self control old-status) (collide-status on-surface)) - (set! (-> self control last-trans-leaving-surf quad) (-> self control last-trans-any-surf quad)) - (set! (-> self control highest-jump-mark quad) (-> self control last-trans-any-surf quad))) + (vector-copy! (-> self control last-trans-leaving-surf) (-> self control last-trans-any-surf)) + (vector-copy! (-> self control highest-jump-mark) (-> self control last-trans-any-surf))) ;; track the apex: xz always follows Jak; y only moves up (reset if he got above the mark). (set! (-> self control highest-jump-mark x) (-> position x)) (set! (-> self control highest-jump-mark z) (-> position z)) @@ -736,7 +735,7 @@ (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) zero-vertical-speed) (vector-float*! lateral-velocity lateral-velocity (/ lateral-speed lateral-speed-copy))))) (let ((flight-position (new 'stack-no-clear 'vector))) - (set! (-> flight-position quad) (-> self control trans quad)) + (vector-copy! flight-position (-> self control trans)) (let ((lateral-position (new-stack-vector0)) (height (vector-dot (-> self control dynam gravity-normal) flight-position))) 0.0 @@ -808,7 +807,7 @@ (vector-float*! (-> self control dynam gravity) (-> self control dynam gravity-normal) (the-as float (-> self control dynam gravity-length))) - (set! (-> self control dynam gravity-normal quad) (-> self control standard-dynamics gravity-normal quad)) + (vector-copy! (-> self control dynam gravity-normal) (-> self control standard-dynamics gravity-normal)) (vector-float*! (-> self control dynam gravity) (-> self control dynam gravity-normal) (the-as float (-> self control dynam gravity-length))) @@ -873,7 +872,7 @@ (set-time! (-> self control rider-time)) (move-to-point! (-> self control) hands-position)) (set! (-> self control hand-to-edge-dist) 0.0) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)) (set-time! (-> self control last-successful-compute-edge-time))))) (forward-up-nopitch->quaternion (-> self control dir-targ) facing-direction (-> self control dynam gravity-normal)))) (set-quaternion! (-> self control) (-> self control dir-targ)) @@ -905,7 +904,7 @@ pole while preserving the approached side." (let* ((pole-process (handle->process (-> self control swingpole-handle))) (pole-direction (-> (the-as swingpole pole-process) dir))) - (set! (-> self control edge-grab-edge-dir quad) (-> pole-direction quad)) + (vector-copy! (-> self control edge-grab-edge-dir) pole-direction) (let ((closest-point (new 'stack-no-clear 'vector))) (let ((end-a (vector+float*! (new 'stack-no-clear 'vector) (-> (the-as swingpole pole-process) root trans) @@ -945,7 +944,7 @@ (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int #t)) (move-to-point! (-> self control) (vector-! (new 'stack-no-clear 'vector) closest-point (-> self control ctrl-to-hands-offset))) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)))))) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)))))) (let ((facing-direction (vector-cross! (-> self control edge-grab-across-edge-dir) pole-direction (-> self control dynam gravity-normal)))) ;; Pick the pole perpendicular on the same side as the current facing. When the first direction ;; already agrees, the conditional and unconditional negations cancel; otherwise the final @@ -970,7 +969,7 @@ (vector<-cspace! clone-position (joint-node eichar-lod0-jg main)) (+! (-> clone-position y) -5896.192) (< (fabs (- (-> clone-position y) (-> self control trans y))) 8192.0))) - (set! (-> self control camera-pos quad) (-> clone-position quad))) + (vector-copy! (-> self control camera-pos) clone-position)) (else (let ((water-flags (-> self water flags))) (cond @@ -984,11 +983,11 @@ (vector<-cspace! (-> self control camera-pos) (-> self node-list data 0)) (set! (-> self control camera-pos y) (-> self water base-height))) ((logtest? (-> self control root-prim prim-core action) (collide-action racer)) - (set! (-> self control camera-pos quad) (-> self control trans quad))) + (vector-copy! (-> self control camera-pos) (-> self control trans))) ((logtest? (-> self control root-prim prim-core action) (collide-action tube)) - (set! (-> self control camera-pos quad) (-> self control shadow-pos quad))) + (vector-copy! (-> self control camera-pos) (-> self control shadow-pos))) ((logtest? (-> self draw status) (draw-status hidden no-anim)) - (set! (-> self control camera-pos quad) (-> self control trans quad))) + (vector-copy! (-> self control camera-pos) (-> self control trans))) (else (vector<-cspace! (-> self control camera-pos) (-> self node-list data 0)))))))) 0 (none)) @@ -1240,7 +1239,7 @@ ;; note: (the int pad-magnitude) truncates the 0..1 float, then integer-divides by 2 -- ;; the result is 0 for any deflection, so stick magnitude contributes nothing here. (turn-to-vector stick-direction (the-as float (/ (the int (-> self control pad-magnitude)) 2)))) - (set! (-> self control to-target-pt-xz quad) (-> (vector-negate! downhill downhill) quad))) + (vector-copy! (-> self control to-target-pt-xz) (vector-negate! downhill downhill))) (set! (-> self control turn-to-magnitude) 1.0) (add-thrust) (add-gravity) @@ -1292,14 +1291,14 @@ (quaternion-identity! (-> self control quat)) (quaternion-identity! (-> self control quat-for-control)) (quaternion-identity! (-> self control dir-targ)) - (set! (-> self control transv quad) (the-as uint128 0)) - (set! (-> self control camera-pos quad) (-> self control trans quad))) + (vector-zero! (-> self control transv)) + (vector-copy! (-> self control camera-pos) (-> self control trans))) (target-exit) (target-timed-invulnerable-off self) (set! (-> self control status) (collide-status)) (set! (-> self control standard-dynamics) *standard-dynamics*) (set! (-> self control surf) *standard-ground-surface*) - (set! (-> self control bent-gravity-normal quad) (-> self control standard-dynamics gravity-normal quad)) + (vector-copy! (-> self control bent-gravity-normal) (-> self control standard-dynamics gravity-normal)) (quaternion-identity! (-> self control override-quat)) (set! (-> self control override-quat-alpha) 0.0) (set-time! (-> self control last-time-on-surface)) @@ -1375,7 +1374,7 @@ (backup-collide-with-as (-> self control)) (set! (-> self game) *game-info*) (move-to-point! (-> self control) (-> cont trans)) - (set! (-> self control camera-pos quad) (-> cont trans quad)) + (vector-copy! (-> self control camera-pos) (-> cont trans)) (set! (-> self control cpad) (-> *cpad-list* cpads 0)) (set! (-> self control current-surface) (new 'process 'surface)) (set! (-> self control current-surface name) 'current) @@ -1409,7 +1408,7 @@ (set! (-> self water) (new 'process 'water-control self 9 0.0 8192.0 2048.0)) (set! (-> self water flags) (water-flag swim-ground part-splash part-drip wt07 part-rings)) (reset-target-state #t) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)) (+! (-> self control last-trans-any-surf y) -819200.0) (set! (-> self align) (new 'process 'align-control self)) (set! (-> self sidekick) (process-spawn sidekick :init init-sidekick :from *16k-dead-pool* :to self)) diff --git a/goal_src/jak1/engine/target/target-death.gc b/goal_src/jak1/engine/target/target-death.gc index e6a2ecc239..b04825228f 100644 --- a/goal_src/jak1/engine/target/target-death.gc +++ b/goal_src/jak1/engine/target/target-death.gc @@ -91,7 +91,7 @@ (quaternion-copy! (-> self control quat-for-control) (-> cont quat)) (move-to-point! (-> self control) (-> cont trans)) (rot->dir-targ! (-> self control)) - (set! (-> self control camera-pos quad) (-> self control trans quad)) + (vector-copy! (-> self control camera-pos) (-> self control trans)) (cond ((not (string= (-> cont name) "default")) (set! *external-cam-mode* #f) (cam-stop) (suspend) 0) (else (send-event *camera* 'clear-entity) (send-event *camera* 'change-state cam-fixed 0) (suspend) 0)) @@ -129,7 +129,7 @@ (cam-start #t) (suspend) (suspend) - (set! (-> *camera-combiner* trans quad) (-> cont camera-trans quad)) + (vector-copy! (-> *camera-combiner* trans) (-> cont camera-trans)) (let ((inv-rot (-> *camera-combiner* inv-camera-rot)) (cam-rot (-> cont camera-rot))) (matrix-identity! inv-rot) @@ -213,7 +213,7 @@ (let ((warp-pos (new 'static 'vector))) (cond ((string= (-> cont name) "village1-warp") - (set! (-> warp-pos quad) (-> (entity-by-name "villagea-part-1") extra trans quad)) + (vector-copy! warp-pos (-> (entity-by-name "villagea-part-1") extra trans)) (suspend) (let ((s4-2 (new 'stack-no-clear 'event-message-block))) (set! (-> s4-2 from) self) @@ -233,10 +233,10 @@ ((or (string= (-> cont name) "training-warp") (string= (-> cont name) "game-start")) (if (logtest? (-> cont flags) (continue-flags game-start)) (close-specific-task! (game-task intro) (task-status need-resolution))) - (set! (-> warp-pos quad) (-> (entity-by-name "training-part-1") extra trans quad)) + (vector-copy! warp-pos (-> (entity-by-name "training-part-1") extra trans)) (set-continue! *game-info* "training-start")) ((string= (-> cont name) "village2-warp") - (set! (-> warp-pos quad) (-> (entity-by-name "villageb-part-55") extra trans quad)) + (vector-copy! warp-pos (-> (entity-by-name "villageb-part-55") extra trans)) (when (task-closed? (game-task village2-levitator) (task-status need-hint)) (suspend) (let ((s4-6 (new 'stack-no-clear 'event-message-block))) @@ -262,7 +262,7 @@ (s3-4 (if v1-209 (-> v1-209 extra process)) s4-8)))) (set-continue! *game-info* "village2-start")) ((string= (-> cont name) "village3-warp") - (set! (-> warp-pos quad) (-> (entity-by-name "villagec-part-32") extra trans quad)) + (vector-copy! warp-pos (-> (entity-by-name "villagec-part-32") extra trans)) (when (task-closed? (game-task village3-button) (task-status need-hint)) (suspend) (let ((s4-10 (new 'stack-no-clear 'event-message-block))) @@ -281,7 +281,7 @@ (s3-6 (if v1-224 (-> v1-224 extra process)) s4-11)))) (set-continue! *game-info* "village3-start")) ((string= (-> cont name) "citadel-warp") - (set! (-> warp-pos quad) (-> (entity-by-name "citb-part-1") extra trans quad)) + (vector-copy! warp-pos (-> (entity-by-name "citb-part-1") extra trans)) (when (task-closed? (game-task village4-button) (task-status need-hint)) (suspend) (let ((s4-13 (new 'stack-no-clear 'event-message-block))) @@ -405,7 +405,7 @@ (let* ((cur-trans (-> self control trans)) (to-target (vector-! (new 'stack-no-clear 'vector) target-pt cur-trans))) (set! (-> to-target y) 0.0) - (set! (-> self control force-turn-to-direction quad) (-> to-target quad)) + (vector-copy! (-> self control force-turn-to-direction) to-target) (vector-xz-normalize! (-> self control force-turn-to-direction) (the-as float 1.0)) (set! (-> self control force-turn-to-magnitude) 1.0) (set! (-> self control force-turn-to-target-speed) speed) @@ -564,7 +564,7 @@ (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) up-vel) (vector-float*! flat-vel flat-vel (/ f0-2 f1-1))))) (let ((hit-origin (new 'stack-no-clear 'vector))) - (set! (-> hit-origin quad) (-> self control trans quad)) + (vector-copy! hit-origin (-> self control trans)) (let ((push-rot (matrix-rotate-y! (new 'stack-no-clear 'matrix) (+ 32768.0 (vector-y-angle (-> attack vector))))) (push-dist 0.0)) (set-quaternion! (-> self control) (-> self control dir-targ)) @@ -629,7 +629,7 @@ (set! (-> v1-4 shove-back) 6144.0) (set! (-> v1-4 shove-up) 4915.2) (set! (-> v1-4 angle) #f) - (set! (-> v1-4 trans quad) (-> self control trans quad)) + (vector-copy! (-> v1-4 trans) (-> self control trans)) (set! (-> v1-4 control) 0.0) (set! (-> v1-4 invinc-time) (-> *TARGET-bank* hit-invulnerable-timeout))) (case mode @@ -643,7 +643,7 @@ (vector-z-quaternion! (-> info vector) (-> self control quat-for-control)) (vector-xz-normalize! (-> info vector) (- (fabs (-> info shove-back)))) (set! (-> info vector y) (-> info shove-up))) - (set! (-> attack-dir quad) (-> info vector quad)) + (vector-copy! attack-dir (-> info vector)) (let ((facing-dot (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) attack-dir (the-as float 1.0)) (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self control quat-for-control))))) (if (not (-> self attack-info angle)) (set! (-> self attack-info angle) (if (>= 0.0 facing-dot) 'front 'back)))) @@ -791,7 +791,7 @@ ;; freeze enemies/platforms/projectiles while the death sequence plays (set-setting! 'process-mask 'set 0.0 (process-mask enemy platform projectile death)) (apply-settings *setting-control*) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (logior! (-> self state-flags) (state-flags dying)) (case death-mode (('none 'instant-death)) @@ -964,16 +964,9 @@ (while (and (handle->process boss-attacker) (not (-> self control state-spool-anim)) (-> self control did-move-to-pole-or-max-jump-height)) - (let* ((boss-bone-mat (-> (the-as process-drawable (handle->process boss-attacker)) node-list data joint-idx bone transform)) - (my-bone-mat (-> self node-list data 0 bone transform)) - (a0-106 (-> boss-bone-mat vector 0 quad)) - (a1-47 (-> boss-bone-mat vector 1 quad)) - (a2-26 (-> boss-bone-mat vector 2 quad)) - (v1-206 (-> boss-bone-mat vector 3 quad))) - (set! (-> my-bone-mat vector 0 quad) a0-106) - (set! (-> my-bone-mat vector 1 quad) a1-47) - (set! (-> my-bone-mat vector 2 quad) a2-26) - (set! (-> my-bone-mat vector 3 quad) v1-206)) + (matrix-copy! + (-> self node-list data 0 bone transform) + (-> (the-as process-drawable (handle->process boss-attacker)) node-list data joint-idx bone transform)) (clone-anim-once boss-attacker 33 #f "") (suspend) 0)))) @@ -1040,7 +1033,7 @@ (send-event (ppointer->process (-> self sidekick)) 'shadow #t) (suspend) 0)))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (initialize! (-> self game) 'dead (the-as game-save #f) (the-as string #f)) (set-time! (-> self state-time)) (anim-loop)) diff --git a/goal_src/jak1/engine/target/target-handler.gc b/goal_src/jak1/engine/target/target-handler.gc index 4215493966..7d62ce4aae 100644 --- a/goal_src/jak1/engine/target/target-handler.gc +++ b/goal_src/jak1/engine/target/target-handler.gc @@ -66,7 +66,7 @@ (('trans) (case (-> block param 0) (('save) - (set! (-> self alt-cam-pos quad) (-> self control trans quad)) + (vector-copy! (-> self alt-cam-pos) (-> self control trans)) (logior! (-> self state-flags) (state-flags has-saved-position)) (mem-copy! (the-as pointer (-> block param 1)) (the-as pointer (-> self control trans)) 48)) (('restore) @@ -95,7 +95,7 @@ (cond ((-> block param 1) (logior! (-> self state-flags) (state-flags looking-at-enemy)) - (set! (-> self alt-neck-pos quad) (-> (the-as vector (-> block param 1)) quad)) + (vector-copy! (-> self alt-neck-pos) (the-as vector (-> block param 1))) (look-at-enemy! (-> self neck) (-> self alt-neck-pos) 'force proc)) (else (set! result (logclear (-> self state-flags) (state-flags looking-at-enemy))) @@ -150,7 +150,7 @@ (if (= (-> *cpad-list* cpads (-> self control cpad number) stick0-speed) 0.0) (rot->dir-targ! (-> self control)))) (('touched) (send-event proc 'touch (-> block param 0))) (('dry) (set! (-> self water drip-wetness) 0.0)) - (('reset-height) (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) #f) + (('reset-height) (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)) #f) (('draw) (if (-> block param 0) (logclear! (-> self draw status) (draw-status skip-bones)) @@ -566,7 +566,7 @@ (-> self control target-attack-id) (-> self control attack-count)) (not (logtest? (-> self state-flags) (state-flags being-attacked dying)))) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad)) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans)) (target-timed-invulnerable (seconds 0.1) self) (go target-jump (-> *TARGET-bank* jump-height-min) (-> *TARGET-bank* jump-height-max) (the-as surface #f))))) #f) @@ -600,10 +600,10 @@ target-standard-event-handler properties and animation offsets, clear temporary turn, bend, water, neck, draw, spool, and collision flags, and make the attack spheres harmless." (set! (-> self control mod-surface) *walk-mods*) - (set! (-> self control anim-collide-offset-local quad) (the-as uint128 0)) - (set! (-> self control anim-collide-offset-world quad) (the-as uint128 0)) - (set! (-> self control old-anim-collide-offset-world quad) (the-as uint128 0)) - (set! (-> self control draw-offset quad) (the-as uint128 0)) + (vector-zero! (-> self control anim-collide-offset-local)) + (vector-zero! (-> self control anim-collide-offset-world)) + (vector-zero! (-> self control old-anim-collide-offset-world)) + (vector-zero! (-> self control draw-offset)) (set! (-> self control force-turn-to-strength) 0.0) (set! (-> self control bend-target) 0.0) (logclear! (-> self state-flags) diff --git a/goal_src/jak1/engine/target/target-part.gc b/goal_src/jak1/engine/target/target-part.gc index bd17f5e816..b8873cf287 100644 --- a/goal_src/jak1/engine/target/target-part.gc +++ b/goal_src/jak1/engine/target/target-part.gc @@ -44,7 +44,7 @@ (vf2 :class vf)) (init-vf0-vector) (let ((probe-position (new 'stack-no-clear 'vector))) - (set! (-> probe-position quad) (-> launch-info launchrot quad)) + (vector-copy! probe-position (-> launch-info launchrot)) (let ((hit (new 'stack-no-clear 'collide-tri-result)) (target-process *target*)) (+! (-> probe-position y) 4096.0) @@ -2150,7 +2150,7 @@ (let ((original-color (new 'stack 'rgbaf)) (start-time (current-time)) (parent (-> self parent))) - (set! (-> original-color quad) (-> (the-as process-drawable (-> parent 0)) draw color-mult quad)) + (vector-copy! original-color (-> (the-as process-drawable (-> parent 0)) draw color-mult)) (let ((black (vector-float*! (the-as vector (new 'stack 'rgbaf)) (the-as vector original-color) 0.0))) (while (not (time-elapsed? start-time duration)) (let ((elapsed (- (current-time) start-time))) @@ -2167,7 +2167,7 @@ (launch-particles (-> *part-id-table* 2002) spawn-position :rate (the-as float 1.0))) (suspend) 0)) - (set! (-> (the-as process-drawable (-> parent 0)) draw color-mult quad) (-> original-color quad))) + (vector-copy! (-> (the-as process-drawable (-> parent 0)) draw color-mult) original-color)) (none)) ;; frost spray decal at Jak's toes while skating fast on ice (target-powerup-process, powerups.gc). diff --git a/goal_src/jak1/engine/target/target-util.gc b/goal_src/jak1/engine/target/target-util.gc index e453294b24..6f88c7173c 100644 --- a/goal_src/jak1/engine/target/target-util.gc +++ b/goal_src/jak1/engine/target/target-util.gc @@ -556,7 +556,7 @@ components are rebuilt from animation translation, per-axis scale, frame rate, and gravity; the rotation option postmultiplies and normalizes the root quaternion." (let ((velocity-scale (new 'stack-no-clear 'vector))) - (set! (-> velocity-scale quad) (-> scale quad)) + (vector-copy! velocity-scale scale) (set! (-> velocity-scale z) (target-align-vel-z-adjust (-> velocity-scale z))) (when (logtest? options (align-opts adjust-x-vel adjust-y-vel adjust-xz-vel)) (let* ((control-to-world (-> this control c-R-w)) @@ -822,7 +822,7 @@ (if (logtest? mask (attack-mask shove-up)) (set! (-> this shove-up) (-> incoming shove-up))) (if (logtest? mask (attack-mask invinc-time)) (set! (-> this invinc-time) (-> incoming invinc-time))) (if (logtest? mask (attack-mask rotate-to)) (set! (-> this rotate-to) (-> incoming rotate-to))) - (if (logtest? mask (attack-mask intersection)) (set! (-> this intersection quad) (-> incoming intersection quad))) + (if (logtest? mask (attack-mask intersection)) (vector-copy! (-> this intersection) (-> incoming intersection))) (cond ((not (logtest? mask (attack-mask vector))) ;; Derive knockback from the attacker toward the process being hit. @@ -830,7 +830,7 @@ (attacker-process (handle->process (-> this attacker))) (attacker-drawable (if (and (nonzero? attacker-process) (type-type? (-> attacker-process type) process-drawable)) attacker-process))) (when attacker-drawable - (set! (-> this trans quad) (-> (the-as process-drawable attacker-drawable) root trans quad)) + (vector-copy! (-> this trans) (-> (the-as process-drawable attacker-drawable) root trans)) (vector-! (-> this vector) (-> (the-as process-drawable receiver-process) root trans) (-> (the-as process-drawable attacker-drawable) root trans)) @@ -841,12 +841,12 @@ (supplied-attacker-drawable (if (and (nonzero? supplied-attacker-process) (type-type? (-> supplied-attacker-process type) process-drawable)) supplied-attacker-process))) (if supplied-attacker-drawable - (set! (-> this trans quad) (-> (the-as process-drawable supplied-attacker-drawable) root trans quad)))) - (set! (-> this vector quad) (-> incoming vector quad)) + (vector-copy! (-> this trans) (-> (the-as process-drawable supplied-attacker-drawable) root trans)))) + (vector-copy! (-> this vector) (-> incoming vector)) (if (not (logtest? mask (attack-mask shove-back))) (set! (-> this shove-back) (vector-xz-length (-> this vector)))) (if (not (logtest? mask (attack-mask shove-up))) (set! (-> this shove-up) (-> this vector y))))) (if (not (logtest? (-> this mask) (attack-mask dist))) (set! (-> this dist) (fabs (-> this shove-back)))) - (if (logtest? mask (attack-mask trans)) (set! (-> this trans quad) (-> incoming trans quad)))) + (if (logtest? mask (attack-mask trans)) (vector-copy! (-> this trans) (-> incoming trans)))) (none))) (defbehavior ground-tween-initialize target ((info ground-tween-info) @@ -924,7 +924,7 @@ (-> target-process alt-cam-pos)) ((logtest? (state-flags falling-into-pool-of-bad) (-> target-process state-flags)) (let ((position (new 'static 'vector))) - (set! (-> position quad) (-> target-process control camera-pos quad)) + (vector-copy! position (-> target-process control camera-pos)) (set! (-> position y) (fmax (-> position y) (-> target-process alt-cam-pos y))) (add-debug-sphere *display-camera-marks* (bucket-id debug-no-zbuf) position 819.2 (new 'static 'rgba :r #xff :a #x80)) position)) diff --git a/goal_src/jak1/engine/target/target.gc b/goal_src/jak1/engine/target/target.gc index d8bfae2900..69f52066d0 100644 --- a/goal_src/jak1/engine/target/target.gc +++ b/goal_src/jak1/engine/target/target.gc @@ -456,7 +456,7 @@ (if (and (recently-pressed? circle) (can-feet?)) (go target-attack)) (if (can-hands? #t) (go target-running-attack)) (when (and (turn-around?) (time-elapsed? (-> self state-time) (seconds 0.3))) - (set! (-> self control transv quad) (-> self control transv-history (-> self control idx-of-fastest-xz-vel) quad)) + (vector-copy! (-> self control transv) (-> self control transv-history (-> self control idx-of-fastest-xz-vel))) (set! (-> self control transv w) 1.0) (go target-turn-around)) (slide-down-test) @@ -766,7 +766,7 @@ (vector+! vel (vector-float*! vel (-> self control dynam gravity-normal) launch-speed) (vector-float*! lateral-vel lateral-vel (/ lateral-speed new-lateral-speed)))))) - (let ((start-pos (-> self control state-vector0))) (set! (-> start-pos quad) (-> self control trans quad)) start-pos)) + (let ((start-pos (-> self control state-vector0))) (vector-copy! start-pos (-> self control trans)) start-pos)) ;; The "hold X to jump higher" logic, run every frame of a rising jump. jump-held? is "is X still held". ;; hold-frac is jump time in 30ths of a second (0..1 over the first ~1s). While X is held and we're inside @@ -816,7 +816,7 @@ (let ((anim-offset (res-lump-struct (-> (ja-group) extra) 'collide-offset vector :time (ja-frame-num 0)))) (cond (anim-offset (set! v0-2 (-> self control anim-collide-offset-local)) (set! (-> v0-2 quad) (-> anim-offset quad))) - (else (set! v0-2 (-> self control anim-collide-offset-local)) (set! (-> v0-2 quad) (the-as uint128 0))))) + (else (set! v0-2 (-> self control anim-collide-offset-local)) (vector-zero! v0-2)))) v0-2)) ;; Crouched and stationary (L1+R1 held). Shrinks the collision to the 'duck shape and sets @@ -956,7 +956,7 @@ (let ((height (-> self control launch-height)) (camera-state (-> self control launch-camera-state)) (dest (-> self control state-vector0))) - (set! (-> dest quad) (-> (the-as vector (-> self control launch-dest)) quad)) + (vector-copy! dest (the-as vector (-> self control launch-dest))) (go target-launch (the-as float height) (the-as symbol camera-state) dest (-> self control launch-tracking-time)))) (set-time! (-> self state-time)) (sound-play "jump" :vol 70) @@ -1070,7 +1070,7 @@ (let ((height (-> self control launch-height)) (camera-state (-> self control launch-camera-state)) (dest (-> self control state-vector0))) - (set! (-> dest quad) (-> (the-as vector (-> self control launch-dest)) quad)) + (vector-copy! dest (the-as vector (-> self control launch-dest))) (go target-launch (the-as float height) (the-as symbol camera-state) dest (-> self control launch-tracking-time)))) (set-time! (-> self state-time)) (init-var-jump min-height max-height #t #t (-> self control transv)) @@ -1122,7 +1122,7 @@ (let ((height (-> self control launch-height)) (camera-state (-> self control launch-camera-state)) (dest (-> self control state-vector0))) - (set! (-> dest quad) (-> (the-as vector (-> self control launch-dest)) quad)) + (vector-copy! dest (the-as vector (-> self control launch-dest))) (go target-launch (the-as float height) (the-as symbol camera-state) dest (-> self control launch-tracking-time)))) (set! (-> self control state-var2) (the-as uint kind)) (if (or (= kind 'duck) (= kind 'launch)) (go target-duck-high-jump min-height max-height (the-as symbol kind))) @@ -1616,7 +1616,7 @@ (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f2-7) (vector-float*! gp-2 gp-2 (/ f0-9 f1-11))))))))) (set! (-> self control dynam gravity-length) 122880.0) - (set! (-> self control last-trans-any-surf quad) (-> self control trans quad))) + (vector-copy! (-> self control last-trans-any-surf) (-> self control trans))) :exit (behavior () (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) @@ -1827,7 +1827,7 @@ (target-danger-set! 'harmless #f) (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) - (set! (-> self control dynam gravity quad) (-> self control standard-dynamics gravity quad))) + (vector-copy! (-> self control dynam gravity) (-> self control standard-dynamics gravity))) :trans (behavior () (delete-back-vel) @@ -1884,7 +1884,7 @@ (the-as float 0.0) (the-as float 40960.0)))) (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) - (set! (-> self control dynam gravity quad) (-> self control standard-dynamics gravity quad)) + (vector-copy! (-> self control dynam gravity) (-> self control standard-dynamics gravity)) (target-danger-set! 'flop-down #f) (ja :group! eichar-flop-down-loop-ja :num! min) (ja :chan 1 :group! eichar-moving-flop-down-loop-ja :num! min) diff --git a/goal_src/jak1/engine/target/target2.gc b/goal_src/jak1/engine/target/target2.gc index 3b1e892356..cc333b4e50 100644 --- a/goal_src/jak1/engine/target/target2.gc +++ b/goal_src/jak1/engine/target/target2.gc @@ -463,7 +463,7 @@ (suspend)) ;; then hide Jak's model (no anim channels) and idle until the mode ends (ja-channel-set! 0) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (loop (if (!= (-> self cam-user-mode) 'look-around) (go target-stance-look-around)) (suspend))) @@ -543,7 +543,7 @@ :code (behavior () (ja-channel-set! 0) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (anim-loop)) :post target-no-move-post) @@ -657,7 +657,7 @@ :post (behavior () (if (logtest? (-> self control status) (collide-status on-surface)) - (set! (-> self control transv quad) (the-as uint128 0))) + (vector-zero! (-> self control transv))) (target-no-stick-post))) ;; Hanging/swinging on a swingpole. The pole process (kept in swingpole-handle) pulls Jak @@ -678,8 +678,8 @@ (logior! (-> self control root-prim prim-core action) (collide-action swingpole-active)) (target-collide-set! 'pole (the-as float 0.0)) ;; save the incoming velocity in state-vector0 so :code can pick a mount anim from it - (set! (-> self control state-vector0 quad) (-> self control transv quad)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-copy! (-> self control state-vector0) (-> self control transv)) + (vector-zero! (-> self control transv)) (send-event *camera* 'ease-in) (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int #f))) :exit @@ -693,7 +693,7 @@ (when (and (recently-pressed? x) (not (logtest? (-> self state-flags) (state-flags prevent-jump))) (time-elapsed? (-> self state-time) (seconds 0.1))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (cond ;; past aframe 44 (back of the swing): let go backwards, dropping fast ((< 44.0 (ja-aframe-num 0)) @@ -853,8 +853,8 @@ (set-time! (-> self control edge-grab-start-time)) (logior! (-> self control root-prim prim-core action) (collide-action edgegrab-active edgegrab-cam)) ;; save the incoming velocity in state-vector0 so :code can pick a swing anim from it - (set! (-> self control state-vector0 quad) (-> self control transv quad)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-copy! (-> self control state-vector0) (-> self control transv)) + (vector-zero! (-> self control transv)) (send-event *camera* 'ease-in)) :exit (behavior () @@ -936,7 +936,7 @@ (ja-channel-set! 1) (set-quaternion! (-> self control) (-> self control dir-targ)) (logclear! (-> self control root-prim prim-core action) (collide-action edgegrab-active edgegrab-cam)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (let ((align-move (new 'stack-no-clear 'vector))) (ja-no-eval :group! eichar-edge-grab-to-jump-ja :num! (seek!) :frame-num 0.0) (until (ja-done? 0) @@ -948,7 +948,7 @@ (move-by-vector! (-> self control) align-move)) (suspend) (ja :num! (seek!)))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control time-of-last-clear-wall-in-jump) 0) (set-forward-vel (the-as float 16384.0)) ;; 4 m/s up over the lip (send-event *camera* 'damp-up) @@ -977,7 +977,7 @@ (move-by-vector! (-> self control) align-move)) (suspend) (ja :num! (seek! (ja-aframe (the-as float 191.0) 0))))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (logclear! (-> self control root-prim prim-core action) (collide-action edgegrab-active edgegrab-cam)) ;; push away from the ledge at 10 m/s (vector-float*! (-> self control transv) (-> self control edge-grab-across-edge-dir) -40960.0) @@ -1990,7 +1990,7 @@ :enter (behavior ((clone-source handle)) (set! (-> self control swingpole-handle) clone-source) - (set! (-> self control state-vector0 quad) (-> self control trans quad)) + (vector-copy! (-> self control state-vector0) (-> self control trans)) (set! (-> self control state-var0) (the-as uint #t)) (quaternion-copy! (the-as quaternion (-> self control state-vector1)) (-> self control quat)) (logior! (-> self state-flags) (state-flags grabbed)) diff --git a/goal_src/jak1/engine/ui/credits.gc b/goal_src/jak1/engine/ui/credits.gc index 7bccb40aec..b345f3bbd4 100644 --- a/goal_src/jak1/engine/ui/credits.gc +++ b/goal_src/jak1/engine/ui/credits.gc @@ -39,7 +39,7 @@ 1.0 (set-width! font 600) (set-height! font 10) - (set! (-> font flags) (font-flags kerning middle large)) + (set-flags! font (font-flags kerning middle large)) (let* ((group-start (- timeline-index (mod timeline-index 3))) (group-phase (- timeline-position (the float group-start)))) (when (and (>= group-start 0) (< group-start timeline-length)) @@ -86,7 +86,7 @@ (set-width! font 450) (set-height! font 10) (set-scale! font 1.0) - (set! (-> font flags) (font-flags shadow kerning middle large)) + (set-flags! font (font-flags shadow kerning middle large)) (while (or first-line? (and (< y (- skip-line-height)) (< (the-as uint text-index) (the-as uint 3262)))) (+! y skip-line-height) (+! text-index 1) diff --git a/goal_src/jak1/engine/ui/hud-classes.gc b/goal_src/jak1/engine/ui/hud-classes.gc index 1f5b9780b7..de10dee7f6 100644 --- a/goal_src/jak1/engine/ui/hud-classes.gc +++ b/goal_src/jak1/engine/ui/hud-classes.gc @@ -412,7 +412,7 @@ (set-width! level-name-context 228) (set-height! level-name-context 45) (set-scale! level-name-context 0.6) - (set! (-> level-name-context flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! level-name-context (font-flags shadow kerning middle middle-vert large)) (print-game-text (lookup-text! *common-text* (-> *level-task-data* (-> this level-index) level-name-id) #f) level-name-context #f diff --git a/goal_src/jak1/engine/ui/progress/progress-draw.gc b/goal_src/jak1/engine/ui/progress/progress-draw.gc index 523e47bd95..6de08d5919 100644 --- a/goal_src/jak1/engine/ui/progress/progress-draw.gc +++ b/goal_src/jak1/engine/ui/progress/progress-draw.gc @@ -93,7 +93,7 @@ (set-width! task-font 328) (set-height! task-font 50) (set-scale! task-font 0.7) - (set! (-> task-font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! task-font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (-> level-record task-info (-> this task-index) task-name selected-text-index) #f) opacity task-font @@ -101,7 +101,7 @@ (when selected-task-complete? (set! (-> task-font origin x) (the float (- (+ horizontal-offset 32) (-> this left-x-offset)))) (set! (-> task-font origin y) (the float (+ (/ vertical-offset 2) 175))) - (let ((completion-font task-font)) (set! (-> completion-font color) (font-color progress-blue))) + (set-color! task-font (font-color progress-blue)) (set-height! task-font 15) (set-scale! task-font 0.5) (print-game-text-scaled (lookup-text! *common-text* (text-id task-completed) #f) @@ -141,7 +141,7 @@ (font-flags shadow kerning)))) (set-width! font 328) (set-height! font 70) - (set! (-> font flags) (font-flags shadow kerning large)) + (set-flags! font (font-flags shadow kerning large)) (let ((print-level-count print-game-text-scaled)) (format (clear *temp-string*) "~D/~D" @@ -151,7 +151,7 @@ (set-width! font 428) (+! (-> font origin x) -220.0) (+! (-> font origin y) 40.0) - (set! (-> font flags) (font-flags shadow kerning middle large)) + (set-flags! font (font-flags shadow kerning middle large)) (print-game-text-scaled (lookup-text! *common-text* (text-id total-collected) #f) (* 0.7 opacity) font @@ -193,14 +193,14 @@ (font-flags shadow kerning)))) (set-width! font 328) (set-height! font 70) - (set! (-> font flags) (font-flags shadow kerning large)) + (set-flags! font (font-flags shadow kerning large)) (let ((print-level-count print-game-text-scaled)) (format (clear *temp-string*) "~D/~D" level-count (-> *game-counts* data level-index buzzer-count)) (print-level-count *temp-string* opacity font (the int (* 128.0 opacity)))) (set-width! font 428) (+! (-> font origin x) -220.0) (+! (-> font origin y) 40.0) - (set! (-> font flags) (font-flags shadow kerning middle large)) + (set-flags! font (font-flags shadow kerning middle large)) (print-game-text-scaled (lookup-text! *common-text* (text-id total-collected) #f) (* 0.7 opacity) font @@ -218,7 +218,7 @@ (set-scale! font 0.55) (set-width! font 265) (set-height! font 55) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (let ((title-id (text-id memcard-not-formatted-title))) (case (-> this display-state) (((progress-screen memcard-no-space)) (set! title-id (text-id memcard-no-space))) @@ -256,7 +256,7 @@ (set-scale! font 0.55) (set-width! font 265) (set-height! font 55) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (let ((print-title print-game-text-scaled)) (format (clear *temp-string*) (lookup-text! *common-text* (text-id memcard-not-formatted-title) #f) 1) (print-title *temp-string* (-> this transition-percentage-invert) font 128)) @@ -282,7 +282,7 @@ "Draw the warning that the selected memory-card slot already contains save data and ask whether it should be overwritten." (set-scale! font 0.65) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 20 (-> this left-x-offset)))) (set! (-> font origin y) 55.0) (set-width! font 365) @@ -304,7 +304,7 @@ (defmethod draw-memcard-no-data ((this progress) (font font-context)) "Draw the notice that no save data exists and ask whether a new save should be created." (set-scale! font 0.65) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 20 (-> this left-x-offset)))) (set! (-> font origin y) 40.0) (set-width! font 365) @@ -326,7 +326,7 @@ "Draw the blinking loading, saving, formatting, or creating status for the active memory-card operation, followed by the do-not-remove warning." (set-scale! font 1.0) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 20 (-> this left-x-offset)))) (set! (-> font origin y) 35.0) (set-width! font 365) @@ -339,7 +339,7 @@ (((progress-screen memcard-creating)) (set! status-text-id (text-id creating-save-data)))) (print-game-text-scaled (lookup-text! *common-text* status-text-id #f) (-> this transition-percentage-invert) font 128))) (set-scale! font 0.65) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 15 (-> this left-x-offset)))) (set! (-> font origin y) 100.0) (set-width! font 370) @@ -354,7 +354,7 @@ "Ask the player to insert a memory card or go back. The Japanese missing-card case adds a separate not-inserted warning above the ordinary prompt." (set-scale! font 0.65) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 50 (-> this left-x-offset)))) (set! (-> font origin y) 35.0) (set-width! font 310) @@ -398,7 +398,7 @@ (if (< opacity 0.0) (set! opacity 0.0)) (let ((alpha (the int (* 128.0 opacity)))) (set-scale! font 0.5) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 102 (-> this left-x-offset)))) (set! (-> font origin y) 5.0) (set-width! font 200) @@ -416,8 +416,8 @@ (particle-index 23)) (dotimes (slot-index 4) (set! (-> font origin x) (the float (- 41 (-> this left-x-offset)))) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) - (let ((default-color-font font)) (set! (-> default-color-font color) (font-color default))) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) + (set-color! font (font-color default)) (set-width! font 320) (cond ((and card-info (= (-> card-info formatted) 1) (= (-> card-info inited) 1) (= (-> card-info file slot-index present) 1)) @@ -433,7 +433,7 @@ alpha 22) (print-game-text "OLD SAVE GAME" font #f alpha 22)) - (let ((card-color-font font)) (set! (-> card-color-font color) (font-color progress-memcard))) + (set-color! font (font-color progress-memcard)) (cond ((or (>= (seconds 2) (- (-> *display* real-frame-counter) (-> this last-option-index-change))) (or (< (mod (- (-> *display* real-frame-counter) (-> this last-option-index-change)) 1200) 600) @@ -441,7 +441,7 @@ (-> this in-transition))) (set-scale! font 0.5) (+! (-> font origin y) 16.0) - (set! (-> font flags) (font-flags shadow kerning middle large)) + (set-flags! font (font-flags shadow kerning middle large)) (set! (-> font origin x) (the float (- -73 (-> this left-x-offset)))) (set-width! font 350) (let ((print-cell-count print-game-text)) @@ -457,7 +457,7 @@ (print-scout-fly-count *temp-string* font #f alpha 22)) (+! (-> font origin y) 1.0) (set-scale! font 1.0) - (set! (-> font flags) (font-flags shadow kerning right large)) + (set-flags! font (font-flags shadow kerning right large)) (set! (-> font origin x) (the float (- 352 (-> this left-x-offset)))) (let ((print-completion print-game-text)) (format (clear *temp-string*) "~D%" (the int (-> card-info file slot-index completion-percentage))) @@ -466,8 +466,8 @@ (+! (-> font origin y) 9.0) ;; og:preserve-this add 'middle' flag when custom-aspect to snap totals with counts (if (-> *pc-settings* use-vis?) - (set! (-> font flags) (font-flags shadow kerning large)) - (set! (-> font flags) (font-flags shadow kerning middle large))) + (set-flags! font (font-flags shadow kerning large)) + (set-flags! font (font-flags shadow kerning middle large))) ;; og:preserve-this when custom-aspect use same offsets from counts for totals (set! (-> font origin x) (the float (- (if (-> *pc-settings* use-vis?) 85 -73) (-> this left-x-offset)))) (let ((print-cell-total print-game-text)) @@ -491,7 +491,7 @@ (+! (-> font origin y) 18.0) (set! (-> font origin x) (the float (- 28 (-> this left-x-offset)))) (set-scale! font 0.8) - (set! (-> font flags) (font-flags shadow kerning middle large)) + (set-flags! font (font-flags shadow kerning middle large)) (set-width! font 350) ;; og:preserve-this pc port stuff here, added YMD (case (scf-get-territory) @@ -544,7 +544,7 @@ "Draw the save error, card check, and autosave-disabled messages, followed by the continue prompt." (set-scale! font 0.6) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 70 (-> this left-x-offset)))) (set! (-> font origin y) 5.0) (set-width! font 265) @@ -588,7 +588,7 @@ "Warn that the memory card was removed and autosave has been disabled, then draw the continue prompt." (set-scale! font 0.6) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (set! (-> font origin x) (the float (- 70 (-> this left-x-offset)))) (set! (-> font origin y) 10.0) (set-width! font 265) @@ -628,7 +628,7 @@ (set-scale! font 0.7) (set-width! font 265) (set-height! font 55) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (let ((title-id (text-id error-loading))) (case (-> this display-state) (((progress-screen memcard-error-saving)) (set! title-id (text-id error-saving))) @@ -662,7 +662,7 @@ (set-scale! font 0.6) (set-width! font 330) (set-height! font 60) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id autosave-warn-title) #f) (-> this transition-percentage-invert) font @@ -697,7 +697,7 @@ (set-scale! font 0.6) (set-width! font 300) (set-height! font 40) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id screen-change-to-60hz) #f) (-> this transition-percentage-invert) font @@ -733,7 +733,7 @@ (set-scale! font 0.6) (set-width! font 300) (set-height! font 40) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id no-disc-title) #f) (-> this transition-percentage-invert) font @@ -764,7 +764,7 @@ (set-scale! font 0.6) (set-width! font 300) (set-height! font 40) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id bad-disc-title) #f) (-> this transition-percentage-invert) font @@ -794,7 +794,7 @@ (set-scale! font 0.6) (set-width! font 300) (set-height! font 40) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id quit?) #f) (-> this transition-percentage-invert) font 128) 0 (none)) @@ -806,7 +806,7 @@ (set-scale! font 0.6) (set-width! font 300) (set-height! font 50) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (text-id screen-now-60hz) #f) (-> this transition-percentage-invert) font @@ -883,7 +883,7 @@ font (the int (* 128.0 opacity)))) (set! (-> font origin x) (- (-> font origin x) (the float signed-offset)))) - (set! (-> font color) (font-color default)) + (set-color! font (font-color default)) font) (defmethod draw-options ((this progress) (base-y int) (row-spacing int) (base-scale float)) @@ -899,7 +899,7 @@ (font (new 'stack 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! font 350) (set-height! font 25) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (dotimes (i (length options)) (let ((option-text (the string #f)) (x-offset 27) @@ -1054,42 +1054,28 @@ (let ((hud-x (+ -409.0 (-> this particles 2 init-pos x) (* 0.8 (the float (-> this left-x-offset))))) (transition-offset (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 0 (-> this transition-offset)))) (let ((opacity (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 1.0 (-> this transition-percentage-invert)))) - (let* ((packet-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) - (bucket-start (-> packet-buffer base))) - (let ((draw-money draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game money)))) - (draw-money *temp-string* - packet-buffer - (the int (+ 428.0 (the float transition-offset) hud-x)) - (- 12 (the int (/ hud-x 6))) - (font-color default) - (font-flags shadow kerning large))) - (let ((draw-power-cells draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game fuel)))) - (draw-power-cells *temp-string* + (with-dma-buffer-add-bucket ((packet-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-money draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game money)))) + (draw-money *temp-string* packet-buffer - (the int (+ 456.0 (the float (adjust-pos transition-offset 50)) hud-x)) - (- 48 (the int (/ hud-x 8))) + (the int (+ 428.0 (the float transition-offset) hud-x)) + (- 12 (the int (/ hud-x 6))) (font-color default) - (font-flags shadow kerning large))) - (let ((draw-scout-flies draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* fact buzzer)))) - (draw-scout-flies *temp-string* - packet-buffer - (the int (+ 469.0 (the float (adjust-pos transition-offset 100)) hud-x)) - 89 - (font-color default) - (font-flags shadow kerning large))) - (let ((bucket-tail (-> packet-buffer base))) - (let ((packet (the-as dma-packet (-> packet-buffer base)))) - (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag)) - (set! (-> packet-buffer base) (&+ (the-as pointer packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - bucket-start - (the-as (pointer dma-tag) bucket-tail)))) + (font-flags shadow kerning large))) (let ((draw-power-cells draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game fuel)))) + (draw-power-cells *temp-string* + packet-buffer + (the int (+ 456.0 (the float (adjust-pos transition-offset 50)) hud-x)) + (- 48 (the int (/ hud-x 8))) + (font-color default) + (font-flags shadow kerning large))) (let ((draw-scout-flies draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* fact buzzer)))) + (draw-scout-flies *temp-string* + packet-buffer + (the int (+ 469.0 (the float (adjust-pos transition-offset 100)) hud-x)) + 89 + (font-color default) + (font-flags shadow kerning large)))) (let ((font (new 'stack 'font-context *font-default-matrix* @@ -1101,16 +1087,16 @@ (set-width! font 100) (set-height! font 15) (set-scale! font 0.5) - (set! (-> font flags) (font-flags shadow kerning large)) + (set-flags! font (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id options) #f) font #f 128 22) (set-width! font 160) (set-height! font 22) (set-scale! font 1.3) - (let ((percent-font font)) (set! (-> percent-font color) (font-color progress-percent))) + (set-color! font (font-color progress-percent)) (set! (-> font origin x) (+ (- 435.0 (the float (if (< (-> *progress-process* 0 completion-percentage) 10.0) 93 80))) hud-x)) (set! (-> font origin y) 180.0) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) (let ((print-percent print-game-text)) (format (clear *temp-string*) "~2D%" (the int (-> *progress-process* 0 completion-percentage))) (print-percent *temp-string* font #f (the int (* 128.0 opacity)) 22)))) @@ -1143,24 +1129,12 @@ (when *cheat-mode* (let ((autosave-text "AUTO SAVE OFF")) (if (-> *setting-control* current auto-save) (set! autosave-text "AUTO SAVE ON")) - (let* ((debug-packet-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) - (debug-bucket-start (-> debug-packet-buffer base))) - (draw-string-xy autosave-text - debug-packet-buffer - (the int (+ 430.0 hud-x)) - 200 - (font-color progress-memcard) - (font-flags shadow kerning middle)) - (let ((debug-bucket-tail (-> debug-packet-buffer base))) - (let ((debug-packet (the-as dma-packet (-> debug-packet-buffer base)))) - (set! (-> debug-packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> debug-packet vif0) (new 'static 'vif-tag)) - (set! (-> debug-packet vif1) (new 'static 'vif-tag)) - (set! (-> debug-packet-buffer base) (&+ (the-as pointer debug-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - debug-bucket-start - (the-as (pointer dma-tag) debug-bucket-tail)))))) + (with-dma-buffer-add-bucket ((debug-packet-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy autosave-text + debug-packet-buffer + (the int (+ 430.0 hud-x)) + 200 + (font-color progress-memcard) + (font-flags shadow kerning middle))))) (let ((small-orb-root (-> this icons 5 icon 0 root))) (set-yaw-angle-clear-roll-pitch! small-orb-root (- (y-angle small-orb-root) (* 182.04445 (* 4.0 (-> *display* time-adjust-ratio)))))) diff --git a/goal_src/jak1/engine/ui/progress/progress.gc b/goal_src/jak1/engine/ui/progress/progress.gc index b4928f6cc8..dbf0b9ccca 100644 --- a/goal_src/jak1/engine/ui/progress/progress.gc +++ b/goal_src/jak1/engine/ui/progress/progress.gc @@ -1439,7 +1439,7 @@ (font-flags shadow kerning)))) (set-width! title-font 328) (set-height! title-font 45) - (set! (-> title-font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! title-font (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (-> level-tasks level-name-id) #f) title-opacity title-font @@ -1532,36 +1532,24 @@ (suspend))) :post (behavior () - (let* ((header-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) - (header-bucket-start (-> header-buffer base))) - (let ((draw-header draw-string-xy)) - (let ((format-header format) - (header-text (clear *temp-string*)) - (header-template "TEXT DEBUG: LANGUAGE ~S ID 0x~X") - (language (-> *setting-control* current language))) - (format-header header-text - header-template - (cond - ((= language (language-enum uk-english)) "uk-english") - ((= language (language-enum japanese)) "japanese") - ((= language (language-enum italian)) "italian") - ((= language (language-enum spanish)) "spanish") - ((= language (language-enum german)) "german") - ((= language (language-enum french)) "french") - ((= language (language-enum english)) "english") - (else "*unknown*")) - (-> *common-text* data (-> self current-debug-string) id))) - (draw-header *temp-string* header-buffer 40 40 (font-color default) (font-flags shadow kerning))) - (let ((header-bucket-tail (-> header-buffer base))) - (let ((header-packet (the-as dma-packet (-> header-buffer base)))) - (set! (-> header-packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> header-packet vif0) (new 'static 'vif-tag)) - (set! (-> header-packet vif1) (new 'static 'vif-tag)) - (set! (-> header-buffer base) (&+ (the-as pointer header-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - header-bucket-start - (the-as (pointer dma-tag) header-bucket-tail)))) + (with-dma-buffer-add-bucket ((header-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((draw-header draw-string-xy)) + (let ((format-header format) + (header-text (clear *temp-string*)) + (header-template "TEXT DEBUG: LANGUAGE ~S ID 0x~X") + (language (-> *setting-control* current language))) + (format-header header-text + header-template + (cond + ((= language (language-enum uk-english)) "uk-english") + ((= language (language-enum japanese)) "japanese") + ((= language (language-enum italian)) "italian") + ((= language (language-enum spanish)) "spanish") + ((= language (language-enum german)) "german") + ((= language (language-enum french)) "french") + ((= language (language-enum english)) "english") + (else "*unknown*")) + (-> *common-text* data (-> self current-debug-string) id))) + (draw-header *temp-string* header-buffer 40 40 (font-color default) (font-flags shadow kerning)))) (let* ((string-help-buffer (-> *display* frames (-> *display* on-screen) frame global-buf)) (string-help-bucket-start (-> string-help-buffer base))) (let ((draw-string-help draw-string-xy)) diff --git a/goal_src/jak1/engine/ui/text.gc b/goal_src/jak1/engine/ui/text.gc index a18ac5a257..0dfef03626 100644 --- a/goal_src/jak1/engine/ui/text.gc +++ b/goal_src/jak1/engine/ui/text.gc @@ -46,21 +46,11 @@ (format '#t "~T [~D] #x~X ~A~%" i (-> this data i id) (-> this data i text))) this) -(defmethod mem-usage ((this game-text-info) (usage memory-usage-block) (flags int)) +(defmethod mem-usage ((this game-text-info) (usage memory-usage-block) (flags mem-usage-flags)) "Account for the game-text-info allocation and every string owned by its records." - (set! (-> usage length) (max 81 (-> usage length))) - (set! (-> usage data 80 name) "string") - (+! (-> usage data 80 count) 1) - (let ((info-bytes (asize-of this))) - (+! (-> usage data 80 used) info-bytes) - (+! (-> usage data 80 total) (logand -16 (+ info-bytes 15)))) + (mem-usage-add! usage string 1 (asize-of this)) (dotimes (i (-> this length)) - (set! (-> usage length) (max 81 (-> usage length))) - (set! (-> usage data 80 name) "string") - (+! (-> usage data 80 count) 1) - (let ((string-bytes (asize-of (-> this data i text)))) - (+! (-> usage data 80 used) string-bytes) - (+! (-> usage data 80 total) (logand -16 (+ string-bytes 15))))) + (mem-usage-add! usage string 1 (asize-of (-> this data i text)))) this) ;; og:preserve-this extracted implementation out so that callers of `lookup-text!` were uneffected @@ -386,22 +376,7 @@ 0) (if (nonzero? (-> *game-text-line* data 0)) (set! line-count (+ line-count 1))) (when (not no-draw) - (let* ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) - (dma-start (-> dma-buf base))) - (set-font-color-alpha (-> font-ctxt color) alpha) - (draw-string *game-text-line* dma-buf layout-context) - (set-font-color-alpha (-> font-ctxt color) 128) - (set! (-> layout-context color) (-> *font-work* last-color)) - (let ((dma-end (-> dma-buf base))) - (let ((end-tag-packet (the-as object (-> dma-buf base)))) - (set! (-> (the-as dma-packet end-tag-packet) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet end-tag-packet) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet end-tag-packet) vif1) (new 'static 'vif-tag)) - (set! (-> dma-buf base) (&+ (the-as pointer end-tag-packet) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - dma-start - (the-as (pointer dma-tag) dma-end))))) + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-font-color-alpha (-> font-ctxt color) alpha) (draw-string *game-text-line* dma-buf layout-context) (set-font-color-alpha (-> font-ctxt color) 128) (set! (-> layout-context color) (-> *font-work* last-color)))) (set! (-> layout-context origin y) next-line-y))) (set! line-index (+ line-index 1)) (set! (-> *game-text-line* data 0) (the-as uint 0)) diff --git a/goal_src/jak1/engine/util/sync-info.gc b/goal_src/jak1/engine/util/sync-info.gc index 88a55037de..13e548b60b 100644 --- a/goal_src/jak1/engine/util/sync-info.gc +++ b/goal_src/jak1/engine/util/sync-info.gc @@ -376,7 +376,7 @@ velocity and set the spring gain, speed limit, and retained damping fraction. A damping value of zero prevents movement, while one applies no damping and permits continued oscillation." (cond - (initial-value (set! (-> this value quad) (-> initial-value quad)) (set! (-> this target quad) (-> initial-value quad))) + (initial-value (vector-copy! (-> this value) initial-value) (vector-copy! (-> this target) initial-value)) (else (vector-reset! (-> this value)) (vector-reset! (-> this target)))) (vector-reset! (-> this vel)) (set! (-> this max-vel) max-vel) diff --git a/goal_src/jak1/levels/beach/air.gc b/goal_src/jak1/levels/beach/air.gc index 38ef4aafff..4952ddddab 100644 --- a/goal_src/jak1/levels/beach/air.gc +++ b/goal_src/jak1/levels/beach/air.gc @@ -91,7 +91,7 @@ (set! (-> corner-b x) (+ (-> air-volume x-pos) (* (-> air-volume cos-angle) (-> air-volume x-length)))) (set! (-> corner-b z) (+ (-> air-volume z-pos) (* (-> air-volume sin-angle) (-> air-volume x-length)))) (add-debug-line #t bucket corner-a corner-b (the-as rgba color) #f (the-as rgba -1)) - (set! (-> corner-a quad) (-> corner-b quad)) + (vector-copy! corner-a corner-b) (set! (-> corner-b x) (+ (-> corner-a x) (* (- (-> air-volume sin-angle)) (-> air-volume z-length)))) (set! (-> corner-b z) (+ (-> corner-a z) (* (-> air-volume cos-angle) (-> air-volume z-length)))) (add-debug-line #t bucket corner-a corner-b (the-as rgba color) #f (the-as rgba -1)) diff --git a/goal_src/jak1/levels/beach/beach-obs.gc b/goal_src/jak1/levels/beach/beach-obs.gc index 8bf931f2cb..0aed01c1b1 100644 --- a/goal_src/jak1/levels/beach/beach-obs.gc +++ b/goal_src/jak1/levels/beach/beach-obs.gc @@ -693,7 +693,7 @@ (set! (-> root-shape nav-radius) (* 0.75 (-> root-shape root-prim local-sphere w))) (backup-collide-with-as root-shape) (set! (-> self root) root-shape)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-vector! (-> self root scale) scale scale scale 1.0) (let ((tumble-axis (new-stack-vector0))) (set-vector! tumble-axis @@ -705,7 +705,7 @@ (quaternion-vector-angle! (-> self tumble) tumble-axis (rand-vu-float-range 0.0 1820.4445))) (quaternion-axis-angle! (-> self root quat) 0.0 1.0 0.0 (rand-vu-float-range 0.0 65536.0)) (initialize-skeleton self *kickrock-sg* '()) - (set! (-> self root transv quad) (-> velocity quad)) + (vector-copy! (-> self root transv) velocity) (go flying-rock-rolling) (none)) @@ -1042,7 +1042,7 @@ (process-drawable-from-entity! this source-entity) (initialize-skeleton this *flutflutegg-sg* '()) (vector-z-quaternion! (-> this dir) (-> this root quat)) - (set! (-> this start quad) (-> this root trans quad)) + (vector-copy! (-> this start) (-> this root trans)) (set! (-> this fall-dist) 20480.0) (set-yaw-angle-clear-roll-pitch! (-> this root) (+ -16384.0 (y-angle (-> this root)))) (set! (-> this pos) 0.0) diff --git a/goal_src/jak1/levels/beach/beach-rocks.gc b/goal_src/jak1/levels/beach/beach-rocks.gc index 0ba1c1917c..94817f6f46 100644 --- a/goal_src/jak1/levels/beach/beach-rocks.gc +++ b/goal_src/jak1/levels/beach/beach-rocks.gc @@ -292,7 +292,7 @@ (let ((anim-frame (ja-aframe-num 0))) (when (and (< -50.0 anim-frame) (< anim-frame 158.0)) (let ((particle-pos (new 'stack-no-clear 'vector))) - (set! (-> particle-pos quad) (-> self root trans quad)) + (vector-copy! particle-pos (-> self root trans)) (spawn (-> self part) particle-pos) (+! (-> particle-pos x) 122880.0) (+! (-> particle-pos z) 102400.0) @@ -348,7 +348,7 @@ (ja :group! lrocklrg-fallen-ja) (compute-alignment! (-> self align)) (let ((alignment-transform (first-transform (-> self align)))) - (set! (-> self root trans quad) (-> self entity extra trans quad)) + (vector-copy! (-> self root trans) (-> self entity extra trans)) (+! (-> self root trans y) (-> alignment-transform trans y))) (suspend) (update-transforms! (-> self root)) diff --git a/goal_src/jak1/levels/beach/pelican.gc b/goal_src/jak1/levels/beach/pelican.gc index a9ba4f7c16..d70308bf74 100644 --- a/goal_src/jak1/levels/beach/pelican.gc +++ b/goal_src/jak1/levels/beach/pelican.gc @@ -354,7 +354,7 @@ (behavior () (let ((nest-pos (-> self state-vector)) (next-pos (new 'stack-no-clear 'vector))) - (set! (-> next-pos quad) (-> self root trans quad)) + (vector-copy! next-pos (-> self root trans)) (vector-seek! next-pos nest-pos (* (-> self state-float 0) (seconds-per-frame))) (move-to-point! (-> self root) next-pos)) (do-push-aways! (-> self root)) @@ -490,7 +490,7 @@ (set! (-> self path-pos) 0.0) (set! (-> self path-max) (the float (+ (-> self path curve num-cverts) -1))) (set! (-> self path-speed) (/ (* 300.0 (-> self path-max)) (the float travel-time))) - (set! (-> self state-vector quad) (-> self root trans quad)) + (vector-copy! (-> self state-vector) (-> self root trans)) (set! (-> self state-float 0) 0.0) (let ((path-start (new 'stack-no-clear 'vector))) (eval-path-curve-div! (-> self path) path-start 0.0 'interp) diff --git a/goal_src/jak1/levels/beach/seagull.gc b/goal_src/jak1/levels/beach/seagull.gc index 1ee07b06c5..31e461ed1d 100644 --- a/goal_src/jak1/levels/beach/seagull.gc +++ b/goal_src/jak1/levels/beach/seagull.gc @@ -734,7 +734,7 @@ 0.0 (let ((landing-move (new 'stack-no-clear 'vector))) (set! (-> self root transv y) (* 4096.0 (- descent-speed))) - (set! (-> landing-move quad) (-> self root transv quad)) + (vector-copy! landing-move (-> self root transv)) (let ((time-to-ground (fill-and-probe-using-line-sphere *collide-cache* (-> self root trans) landing-move @@ -861,7 +861,7 @@ (set! (-> root-shape nav-radius) (* 0.75 (-> root-shape root-prim local-sphere w))) (backup-collide-with-as root-shape) (set! (-> self root) root-shape)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (initialize-skeleton self *seagull-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (set! (-> self index) index) @@ -977,7 +977,7 @@ (set! (-> this link) (new 'process 'actor-link-info this)) (set! (-> this targetnum) (+ (-> source-entity extra perm user-int8 0) 1)) (eval-path-curve-div! (-> this path) (-> this trans) (the float (+ (-> this targetnum) -1)) 'interp) - (set! (-> this target quad) (-> this trans quad)) + (vector-copy! (-> this target) (-> this trans)) (set! (-> this max-lift) 20480.0) (set! (-> this birds) 0) (dotimes (i SEAGULLFLOCK_MAX) diff --git a/goal_src/jak1/levels/citadel/citadel-sages.gc b/goal_src/jak1/levels/citadel/citadel-sages.gc index 918a88e9ee..2753e309ea 100644 --- a/goal_src/jak1/levels/citadel/citadel-sages.gc +++ b/goal_src/jak1/levels/citadel/citadel-sages.gc @@ -275,7 +275,7 @@ Sages." (if (not (the-as entity-actor linked-actor)) (set! linked-actor (entity-by-name "citb-robotboss-1"))) (set! (-> this alt-actor) (the-as entity-actor linked-actor)) (set! (-> this spawn-pos quad) (-> this root trans quad)) - (set! (-> target-anchor quad) (-> linked-actor extra trans quad)) + (vector-copy! target-anchor (-> linked-actor extra trans)) (+! (-> target-anchor y) 81920.0) (vector-! outward (-> this spawn-pos) target-anchor) (set! (-> outward y) 0.0) diff --git a/goal_src/jak1/levels/citadel/citb-drop-plat.gc b/goal_src/jak1/levels/citadel/citb-drop-plat.gc index 8ee819edc5..bec69ef269 100644 --- a/goal_src/jak1/levels/citadel/citb-drop-plat.gc +++ b/goal_src/jak1/levels/citadel/citb-drop-plat.gc @@ -130,7 +130,7 @@ (set! (-> self root trans y) (+ -204800.0 (-> (the-as process-drawable (-> self parent 0)) root trans y))) (let ((sound-position (new 'stack-no-clear 'vector)) (played-sound? #f)) - (set! (-> sound-position quad) (-> self root trans quad)) + (vector-copy! sound-position (-> self root trans)) (set! (-> sound-position y) (-> (the-as process-drawable (-> self parent 0)) root trans y)) (loop (set! (-> self interp) (square (fmax 0.0 (- 1.0 (* 0.0033333334 (the float (- (current-time) (-> self state-time)))))))) @@ -237,7 +237,7 @@ (set! (-> self delay) delay) (set! (-> self duration) duration) (setup-collision! self) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (vector-identity! (-> self root scale)) (quaternion-copy! (-> self root quat) (-> (the-as process-drawable (-> self parent 0)) root quat)) (init-skeleton-and-spin! self) diff --git a/goal_src/jak1/levels/citadel/citb-plat.gc b/goal_src/jak1/levels/citadel/citb-plat.gc index 416acba3c2..254dcc18d8 100644 --- a/goal_src/jak1/levels/citadel/citb-plat.gc +++ b/goal_src/jak1/levels/citadel/citb-plat.gc @@ -449,7 +449,7 @@ the rigid body there, then return to the blue-eco waiting state." (let ((start-position (new 'stack-no-clear 'vector)) (start-rotation (new 'stack-no-clear 'quaternion))) - (set! (-> start-position quad) (-> self root-overlay trans quad)) + (vector-copy! start-position (-> self root-overlay trans)) (quaternion-copy! start-rotation (-> self root-overlay quat)) (set-time! (-> self state-time)) (while (not (time-elapsed? (-> self state-time) (seconds 0.25))) @@ -907,7 +907,7 @@ "Run the parent movement transition, then apply the platform displacement and radial correction to Jak." (let ((previous-position (new 'stack-no-clear 'vector))) - (set! (-> previous-position quad) (-> self root trans quad)) + (vector-copy! previous-position (-> self root trans)) (let ((parent-transition (-> (the-as (state plat-button) (find-parent-state)) trans))) (if parent-transition (parent-transition))) (citb-exit-plat-move-player previous-position))) @@ -920,7 +920,7 @@ "Run the parent movement transition, then apply the platform displacement and radial correction to Jak." (let ((previous-position (new 'stack-no-clear 'vector))) - (set! (-> previous-position quad) (-> self root trans quad)) + (vector-copy! previous-position (-> self root trans)) (let ((parent-transition (-> (the-as (state plat-button) (find-parent-state)) trans))) (if parent-transition (parent-transition))) (citb-exit-plat-move-player previous-position))) diff --git a/goal_src/jak1/levels/finalboss/final-door.gc b/goal_src/jak1/levels/finalboss/final-door.gc index e80e1e1454..566052c9e5 100644 --- a/goal_src/jak1/levels/finalboss/final-door.gc +++ b/goal_src/jak1/levels/finalboss/final-door.gc @@ -221,7 +221,7 @@ (set! (-> collision nav-radius) (* 0.75 (-> collision root-prim local-sphere w))) (backup-collide-with-as collision) (set! (-> self root) collision)) - (set! (-> self root trans quad) (-> start-position quad)) + (vector-copy! (-> self root trans) start-position) (set! (-> self jump-pos quad) (-> jump-position quad)) (set-vector! (-> self root scale) 0.5 0.5 0.5 1.0) (set! (-> self index) joint-index) diff --git a/goal_src/jak1/levels/finalboss/green-eco-lurker.gc b/goal_src/jak1/levels/finalboss/green-eco-lurker.gc index d2ae93f11c..e739ae8f74 100644 --- a/goal_src/jak1/levels/finalboss/green-eco-lurker.gc +++ b/goal_src/jak1/levels/finalboss/green-eco-lurker.gc @@ -316,7 +316,7 @@ and attacks Jak on contact." "Return whether a candidate path point is far enough from Jak and unblocked for appearance." (when (or (not *target*) (>= (vector-vector-xz-distance candidate-point (target-pos 0)) 36864.0)) (let ((test-sphere (new 'stack-no-clear 'vector))) - (set! (-> test-sphere quad) (-> candidate-point quad)) + (vector-copy! test-sphere candidate-point) (set! (-> test-sphere w) (-> this collide-info root-prim local-sphere w))) (if (not (jump-dest-blocked? this candidate-point)) (return #t))) #f) @@ -391,7 +391,7 @@ and attacks Jak on contact." (set! (-> self nav extra-nav-sphere w) 8192.0) (setup-from-to-duration! (-> self traj) (-> self collide-info trans) (-> self appear-dest) 225.0 -9.102222) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self collide-info trans quad)) + (vector-copy! gp-0 (-> self collide-info trans)) (+! (-> gp-0 y) 8192.0) (process-spawn part-tracker :init part-tracker-init group-green-eco-lurker-death -1 #f #f #f gp-0 :to *entity-pool*)) (let ((gp-1 (new 'stack-no-clear 'vector))) @@ -611,7 +611,7 @@ and attacks Jak on contact." (defbehavior green-eco-lurker-init-by-other green-eco-lurker ((unused-entity entity-actor) (controller green-eco-lurker-gen) (position vector)) "Initialize one blob at the requested position and enter its hidden appearance search." (initialize-collision self) - (set! (-> self collide-info trans quad) (-> position quad)) + (vector-copy! (-> self collide-info trans) position) (vector-identity! (-> self collide-info scale)) (quaternion-identity! (-> self collide-info quat)) (set! (-> self entity) (-> controller entity)) @@ -637,7 +637,7 @@ and attacks Jak on contact." (until (time-elapsed? (-> self state-time) (seconds 1)) (suspend))) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self root trans quad)) + (vector-copy! gp-0 (-> self root trans)) (+! (-> gp-0 y) -16384.0) (process-spawn green-eco-lurker (-> self entity) self gp-0 :to self)) (+! (-> self num-spawned) 1) @@ -658,7 +658,7 @@ and attacks Jak on contact." (set! (-> self num-alive) 0) (set! (-> self entity) source-entity) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (vector-identity! (-> self root scale)) (quaternion-identity! (-> self root quat)) (logclear! (-> self mask) (process-mask actor-pause)) diff --git a/goal_src/jak1/levels/finalboss/light-eco.gc b/goal_src/jak1/levels/finalboss/light-eco.gc index d8b5a4e213..f8b98bf976 100644 --- a/goal_src/jak1/levels/finalboss/light-eco.gc +++ b/goal_src/jak1/levels/finalboss/light-eco.gc @@ -379,7 +379,7 @@ (vector-normalize! gp-1 92610.56) (vector+! gp-1 gp-1 (-> (the-as light-eco-mother (-> self parent 0)) root trans)) (set! (-> gp-1 y) (-> self root trans y)) - (set! (-> self root trans quad) (-> gp-1 quad))))) + (vector-copy! (-> self root trans) gp-1)))) (common-trans self)) :code (behavior () @@ -446,7 +446,7 @@ (set! (-> collision nav-radius) (* 0.75 (-> collision root-prim local-sphere w))) (backup-collide-with-as collision) (set! (-> self root) collision)) - (set! (-> self root trans quad) (-> start quad)) + (vector-copy! (-> self root trans) start) (set-vector! (-> self root scale) 2.0 2.0 2.0 1.0) (quaternion-identity! (-> self root quat)) (setup-from-to-height! (-> self traj) (-> self root trans) destination 4096.0 -4.551111) @@ -593,7 +593,7 @@ (set! (-> self angle-mask) 0) (set! (-> self player-got-eco?) #f) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (vector-reset! (-> self root scale)) (quaternion-identity! (-> self root quat)) (logclear! (-> self mask) (process-mask actor-pause)) diff --git a/goal_src/jak1/levels/finalboss/robotboss-misc.gc b/goal_src/jak1/levels/finalboss/robotboss-misc.gc index 6b9222a81b..d635b9b8cd 100644 --- a/goal_src/jak1/levels/finalboss/robotboss-misc.gc +++ b/goal_src/jak1/levels/finalboss/robotboss-misc.gc @@ -23,7 +23,7 @@ (case message (('set-pivot) (let ((v0-0 (the-as object (-> self pivot-pt)))) - (set! (-> (the-as vector v0-0) quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (the-as vector v0-0) (the-as vector (-> block param 0))) v0-0)) (('teleport) #f) (else (cam-standard-event-handler proc argc message block)))) @@ -33,7 +33,7 @@ ((-> self enter-has-run)) (else (set! *camera-base-mode* cam-robotboss) - (set! (-> self circular-follow quad) (-> *camera* tpos-curr-adj quad)) + (vector-copy! (-> self circular-follow) (-> *camera* tpos-curr-adj)) (set! (-> self pivot-rad) 73728.0) (set! (-> self blend-from-type) (the-as uint 2)) (set! (-> self blend-to-type) (the-as uint 2))))) diff --git a/goal_src/jak1/levels/finalboss/robotboss-weapon.gc b/goal_src/jak1/levels/finalboss/robotboss-weapon.gc index a5d974c9ea..7a2e5fe9df 100644 --- a/goal_src/jak1/levels/finalboss/robotboss-weapon.gc +++ b/goal_src/jak1/levels/finalboss/robotboss-weapon.gc @@ -122,8 +122,8 @@ arcing-shot-debug-trajectory)) (defbehavior arcing-shot-setup arcing-shot ((arg0 vector) (arg1 vector) (arg2 float)) - (set! (-> self from quad) (-> arg0 quad)) - (set! (-> self to quad) (-> arg1 quad)) + (vector-copy! (-> self from) arg0) + (vector-copy! (-> self to) arg1) (let ((v1-2 (fmax 1.0 arg2))) (if (< (-> arg0 y) (-> arg1 y)) (set! v1-2 (+ v1-2 (- (-> arg1 y) (-> arg0 y))))) (let ((f0-6 (* -4.0 v1-2)) @@ -141,11 +141,11 @@ (defbehavior arcing-shot-draw arcing-shot () (let ((gp-0 (new 'stack-no-clear 'vector)) (s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self from quad)) + (vector-copy! s5-0 (-> self from)) (dotimes (s4-0 30) (arcing-shot-calculate gp-0 (* 0.033333335 (the float (+ s4-0 1)))) (camera-line gp-0 s5-0 (new 'static 'vector4w :x #xff :y #xff :w #x80)) - (set! (-> s5-0 quad) (-> gp-0 quad)))) + (vector-copy! s5-0 gp-0))) #f) (defstate arcing-shot-debug-trajectory (arcing-shot) @@ -334,7 +334,7 @@ (set! (-> s1-0 nav-radius) (* 0.75 (-> s1-0 root-prim local-sphere w))) (backup-collide-with-as s1-0) (set! (-> self root) s1-0)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *darkecobomb-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (set! (-> self part) (create-launch-control group-robotboss-darkecobomb-glow self)) @@ -390,7 +390,7 @@ (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w))) (backup-collide-with-as s2-0) (set! (-> self root) s2-0)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *greenshot-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (arcing-shot-setup arg0 arg1 arg2) @@ -553,7 +553,7 @@ (set! (-> s0-0 nav-radius) (* 0.75 (-> s0-0 root-prim local-sphere w))) (backup-collide-with-as s0-0) (set! (-> self root) s0-0)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *redring-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (arcing-shot-setup arg0 arg1 arg2) @@ -613,7 +613,7 @@ (set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w))) (backup-collide-with-as s2-0) (set! (-> self root) s2-0)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *redring-sg* '()) (logior! (-> self draw status) (draw-status hidden)) (arcing-shot-setup arg0 arg1 arg2) diff --git a/goal_src/jak1/levels/finalboss/robotboss.gc b/goal_src/jak1/levels/finalboss/robotboss.gc index e6e60da566..570ec9fa6c 100644 --- a/goal_src/jak1/levels/finalboss/robotboss.gc +++ b/goal_src/jak1/levels/finalboss/robotboss.gc @@ -53,12 +53,12 @@ (else (logior! (-> self skel status) (janim-status inited)) (process-grab? *target*) - (set! (-> *camera-other-root* quad) (-> self root trans quad)) + (vector-copy! *camera-other-root* (-> self root trans)) (let ((s5-1 (-> self node-list data 88 bone transform)) (gp-1 (-> self node-list data 88 bone scale))) (let ((s4-1 (new 'stack-no-clear 'vector))) (vector<-cspace! s4-1 (joint-node robotboss-basic-lod0-jg camera)) - (set! (-> *camera-other-trans* quad) (-> s4-1 quad))) + (vector-copy! *camera-other-trans* s4-1)) (vector-normalize-copy! (-> *camera-other-matrix* vector 0) (-> s5-1 vector 0) (the-as float -1.0)) (set! (-> *camera-other-matrix* vector 0 w) 0.0) (vector-normalize-copy! (-> *camera-other-matrix* vector 1) (-> s5-1 vector 1) (the-as float 1.0)) @@ -239,7 +239,7 @@ (f0-10 (+ (-> self entity extra trans y) (-> self desired-pool-y)))) (when a0-16 (let ((v1-23 (new 'stack-no-clear 'vector))) - (set! (-> v1-23 quad) (-> (the-as process-drawable a0-16) root trans quad)) + (vector-copy! v1-23 (-> (the-as process-drawable a0-16) root trans)) (cond ((< (-> v1-23 y) (+ -204.8 f0-10)) (+! (-> v1-23 y) 20.48)) ((< (+ 204.8 f0-10) (-> v1-23 y)) (+! (-> v1-23 y) -20.48))) @@ -251,7 +251,7 @@ (let ((gp-0 (new 'stack-no-clear 'vector))) (let ((s4-0 (new 'stack-no-clear 'vector))) (vector<-cspace! gp-0 (joint-node robotboss-basic-lod0-jg darkbombD)) - (set! (-> s4-0 quad) (-> self entity extra trans quad)) + (vector-copy! s4-0 (-> self entity extra trans)) (vector+! s4-0 s4-0 destination-offset) (process-spawn darkecobomb gp-0 s4-0 61440.0 300 flight-time :to self)) (process-spawn part-tracker @@ -451,7 +451,7 @@ (when (and (< (-> self children-spawned) 1) (time-elapsed? (-> self state-time) (seconds 0.95))) (+! (-> self children-spawned) 1) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self entity extra trans quad)) + (vector-copy! gp-0 (-> self entity extra trans)) (+! (-> gp-0 y) 81920.0) (set! (-> self white-eco) (ppointer->handle (process-spawn light-eco-mother (-> self entity) gp-0 :to self)))))) :code @@ -583,7 +583,7 @@ (let ((s5-0 (new 'stack-no-clear 'vector))) (vector<-cspace! gp-0 (joint-node robotboss-basic-lod0-jg Lyellow_ecoBarrell)) (set! (-> gp-0 y) 1972633.6) - (if *target* (set! (-> s5-0 quad) (-> (target-pos 0) quad)) (set! (-> s5-0 quad) (-> self entity extra trans quad))) + (if *target* (vector-copy! s5-0 (target-pos 0)) (vector-copy! s5-0 (-> self entity extra trans))) (set! (-> s5-0 y) (+ 8192.0 (-> self entity extra trans y))) (vector-! s5-0 s5-0 gp-0) (vector-normalize! s5-0 (the-as float 819200.0)) @@ -1255,7 +1255,7 @@ (let ((gp-0 (new 'stack-no-clear 'vector))) (let ((s2-0 (new 'stack-no-clear 'vector))) (vector<-cspace! gp-0 (joint-node robotboss-basic-lod0-jg green_eco)) - (set! (-> s2-0 quad) (-> self entity extra trans quad)) + (vector-copy! s2-0 (-> self entity extra trans)) (+! (-> s2-0 y) -40960.0) (vector+! s2-0 s2-0 destination-offset) (process-spawn greenshot gp-0 s2-0 arc-height flight-time :to self)) @@ -1522,7 +1522,7 @@ (let ((s4-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'vector))) (let ((s3-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self entity extra trans quad)) + (vector-copy! gp-0 (-> self entity extra trans)) (vector<-cspace! s4-0 (-> self node-list data joint-index)) (vector-! s3-0 gp-0 s4-0) (let ((f30-0 (vector-y-angle s3-0)) diff --git a/goal_src/jak1/levels/finalboss/sage-finalboss.gc b/goal_src/jak1/levels/finalboss/sage-finalboss.gc index 7e7766faee..8fd046849f 100644 --- a/goal_src/jak1/levels/finalboss/sage-finalboss.gc +++ b/goal_src/jak1/levels/finalboss/sage-finalboss.gc @@ -297,8 +297,7 @@ (ppointer->handle (manipy-spawn (-> this root trans) (-> this entity) *plat-eco-finalboss-lit-sg* #f :to this))) (send-event (handle->process (-> this robotplat)) 'anim-mode 'clone-anim) (send-event (handle->process (-> this robotplat)) 'origin-joint-index 3) - (set! (-> this old-target-pos trans quad) - (-> (new 'static 'vector :x 11368946.0 :y 2215900.2 :z -19405602.0 :w 1.0) quad)) + (vector-copy! (-> this old-target-pos trans) (new 'static 'vector :x 11368946.0 :y 2215900.2 :z -19405602.0 :w 1.0)) (quaternion-copy! (-> this old-target-pos quat) (new 'static 'quaternion :y -0.8472 :w 0.5312)) (set-setting! 'music #f 0.0 0) (set-setting! 'sfx-volume 'abs 0.0 0) @@ -535,7 +534,7 @@ (t9-4 (if v1-27 (-> v1-27 extra process)) a1-2)))))) (when (and *target* (-> self particle 0 active)) (let ((a1-3 (new 'stack-no-clear 'vector))) - (set! (-> a1-3 quad) (-> *target* draw origin quad)) + (vector-copy! a1-3 (-> *target* draw origin)) (set! (-> a1-3 y) 1970176.0) (spawn (-> self particle 0 part) a1-3))) (when (and (handle->process (-> self jak-white)) (-> self particle 1 active)) diff --git a/goal_src/jak1/levels/firecanyon/assistant-firecanyon.gc b/goal_src/jak1/levels/firecanyon/assistant-firecanyon.gc index 3209bde605..3d788c6e7b 100644 --- a/goal_src/jak1/levels/firecanyon/assistant-firecanyon.gc +++ b/goal_src/jak1/levels/firecanyon/assistant-firecanyon.gc @@ -78,7 +78,7 @@ (set-width! gp-0 448) (set-height! gp-0 80) (set-scale! gp-0 0.8) - (set! (-> gp-0 flags) (font-flags shadow kerning middle large)) + (set-flags! gp-0 (font-flags shadow kerning middle large)) (print-game-text (lookup-text! *common-text* (text-id firecanyon-need-cells-text) #f) gp-0 #f 128 22))) (level-hint-spawn (text-id firecanyon-need-cells) "asstvb09" (the-as entity #f) *entity-pool* (game-task none))))) diff --git a/goal_src/jak1/levels/flut_common/flutflut.gc b/goal_src/jak1/levels/flut_common/flutflut.gc index cfe613110d..c12dc25b4e 100644 --- a/goal_src/jak1/levels/flut_common/flutflut.gc +++ b/goal_src/jak1/levels/flut_common/flutflut.gc @@ -153,7 +153,7 @@ (let ((gp-0 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! gp-0 440) (set-height! gp-0 80) - (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (set-flags! gp-0 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) gp-0 #f 128 22)) (if (and (cpad-pressed? 0 circle) (send-event *target* 'change-mode 'flut self)) (go-virtual pickup (method-of-object self wait-for-return))))) diff --git a/goal_src/jak1/levels/flut_common/target-flut.gc b/goal_src/jak1/levels/flut_common/target-flut.gc index eec6809dc3..596917061a 100644 --- a/goal_src/jak1/levels/flut_common/target-flut.gc +++ b/goal_src/jak1/levels/flut_common/target-flut.gc @@ -174,7 +174,7 @@ (defbehavior target-flut-post-post target () (vector+! (-> self flut flut-trans) (-> self control trans) (-> self control cspace-offset)) (quaternion-copy! (the-as quaternion (-> self flut flut-quat)) (-> self control quat)) - (set! (-> self flut flut-scale quad) (-> self control scale quad)) + (vector-copy! (-> self flut flut-scale) (-> self control scale)) (let ((v1-8 (-> *target-shadow-control* settings shadow-dir quad))) (set! (-> *flutflut-shadow-control* settings shadow-dir quad) v1-8)) 0 @@ -322,7 +322,7 @@ (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) (target-collide-set! 'normal (the-as float 0.0)) (set! (-> self control reaction) target-collision-reaction) - (set! (-> self control cspace-offset quad) (the-as uint128 0)) + (vector-zero! (-> self control cspace-offset)) (remove-setting! 'sound-flava) (target-exit))) :code @@ -337,7 +337,7 @@ (set! (-> self flut entity) #f) (let ((v1-11 (handle->process arg0))) (if v1-11 (set! (-> self flut entity) (-> v1-11 entity)))) (target-collide-set! 'flut (the-as float 0.0)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control ctrl-xz-vel) 0.0) (logior! (-> self control root-prim prim-core action) (collide-action flut)) (let ((s5-0 (-> self entity))) @@ -938,7 +938,7 @@ (target-danger-set! 'harmless #f) (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) - (set! (-> self control dynam gravity quad) (-> self control standard-dynamics gravity quad))) + (vector-copy! (-> self control dynam gravity) (-> self control standard-dynamics gravity))) :trans (behavior () (let ((s5-0 (new-stack-vector0))) @@ -1060,7 +1060,7 @@ (set! (-> v1-2 shove-back) 10240.0) (set! (-> v1-2 shove-up) 9011.2) (set! (-> v1-2 angle) #f) - (set! (-> v1-2 trans quad) (-> self control trans quad)) + (vector-copy! (-> v1-2 trans) (-> self control trans)) (set! (-> v1-2 control) 0.0) (set! (-> v1-2 invinc-time) (-> *TARGET-bank* hit-invulnerable-timeout))) (case arg0 @@ -1074,7 +1074,7 @@ (vector-z-quaternion! (-> gp-0 vector) (-> self control quat-for-control)) (vector-xz-normalize! (-> gp-0 vector) (- (fabs (-> gp-0 shove-back)))) (set! (-> gp-0 vector y) (-> gp-0 shove-up))) - (set! (-> s5-0 quad) (-> gp-0 vector quad)) + (vector-copy! s5-0 (-> gp-0 vector)) (let ((f0-10 (vector-dot (vector-normalize-copy! (new 'stack-no-clear 'vector) s5-0 (the-as float 1.0)) (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self control quat-for-control))))) (if (not (-> self attack-info angle)) (set! (-> self attack-info angle) (if (>= 0.0 f0-10) 'front 'back)))) @@ -1090,7 +1090,7 @@ (ja-channel-set! 0) (suspend-for (seconds 1)) (move-to-point! (-> self control) s4-1)) - (set! (-> self control camera-pos quad) (-> self control trans quad)) + (vector-copy! (-> self control camera-pos) (-> self control trans)) (send-event *camera* 'teleport) (go target-flut-stance)) (else @@ -1143,7 +1143,7 @@ (target-timed-invulnerable-off self) (add-setting! 'process-mask 'set 0.0 (process-mask enemy platform projectile death)) (apply-settings *setting-control*) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (cond ((or (= arg0 'none) (= arg0 'water-vol) (= arg0 'sharkey))) ((= arg0 'endlessfall) @@ -1192,7 +1192,7 @@ (vector-float*! (-> self control transv) gp-5 (-> *display* frames-per-second)))) (suspend) (ja :num! (seek!))))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (initialize! (-> self game) 'dead (the-as game-save #f) (the-as string #f)) (set-time! (-> self state-time)) (until v1-104 @@ -1208,28 +1208,28 @@ exit) :code (behavior ((arg0 handle)) - (set! (-> self control transv quad) (the-as uint128 0)) - (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (vector-zero! (-> self control transv)) + (vector-copy! (-> self alt-cam-pos) (-> self control camera-pos)) (logior! (-> self state-flags) (state-flags use-alt-cam-pos)) (set-time! (-> self state-time)) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self control trans quad)) + (vector-copy! gp-0 (-> self control trans)) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self control trans quad)) + (vector-copy! s5-0 (-> self control trans)) (quaternion-copy! (-> self control mount-start-quat) (-> self control quat)) (quaternion-copy! (-> self control mount-end-quat) (-> self control quat-for-control)) (set! (-> self control state-var0) (the-as uint (-> self control draw-offset y))) (let* ((s3-0 (handle->process arg0)) (s4-1 (if (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) s3-0))) (when s4-1 - (set! (-> s5-0 quad) (-> (the-as process-drawable s4-1) root trans quad)) + (vector-copy! s5-0 (-> (the-as process-drawable s4-1) root trans)) (quaternion-copy! (-> self control mount-end-quat) (-> (the-as process-drawable s4-1) root quat)) (send-event s4-1 'trans (-> self flut flut-trans)) (quaternion-copy! (the-as quaternion (-> self flut flut-quat)) (-> (the-as process-drawable s4-1) root quat)) - (set! (-> self flut flut-scale quad) (-> (the-as process-drawable s4-1) root scale quad)) + (vector-copy! (-> self flut flut-scale) (-> (the-as process-drawable s4-1) root scale)) (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int (-> self flut flut-trans y))))) - (set! (-> self control state-vector0 quad) (-> gp-0 quad)) - (set! (-> self control state-vector1 quad) (-> s5-0 quad)))) + (vector-copy! (-> self control state-vector0) gp-0) + (vector-copy! (-> self control state-vector1) s5-0))) (let ((gp-1 #f)) (sound-play "uppercut") (ja-channel-push! 1 (seconds 0.05)) @@ -1238,12 +1238,12 @@ (when (and (not gp-1) (= (-> self skel root-channel 0) (-> self skel channel))) (send-event (ppointer->process (-> self manipy)) 'anim-mode 'clone-anim) (set! gp-1 #t)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (suspend) (ja :num! (seek! (ja-aframe (the-as float 24.0) 0))))) (sound-play "flut-coo") (logclear! (-> self state-flags) (state-flags use-alt-cam-pos)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (quaternion-copy! (-> self control quat) (-> self control quat-for-control)) (rot->dir-targ! (-> self control)) (go target-flut-stance)) @@ -1290,26 +1290,26 @@ :code (behavior ((arg0 handle)) (set-time! (-> self state-time)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self control trans quad)) + (vector-copy! gp-0 (-> self control trans)) (let ((s4-0 (new 'stack-no-clear 'vector))) - (set! (-> s4-0 quad) (-> self control trans quad)) + (vector-copy! s4-0 (-> self control trans)) (quaternion-copy! (-> self control mount-start-quat) (-> self control quat)) (quaternion-copy! (-> self control mount-end-quat) (-> self control quat-for-control)) (set! (-> self control state-var0) (the-as uint (-> self control draw-offset y))) (let* ((s2-0 (handle->process arg0)) (s3-0 (if (and (nonzero? s2-0) (type-type? (-> s2-0 type) process-drawable)) s2-0))) (when s3-0 - (set! (-> s4-0 quad) (-> (the-as process-drawable s3-0) root trans quad)) + (vector-copy! s4-0 (-> (the-as process-drawable s3-0) root trans)) (set-yaw-angle-clear-roll-pitch! (-> (the-as process-drawable s3-0) root) (quaternion-y-angle (-> self control quat))) (quaternion-copy! (-> self control mount-end-quat) (-> (the-as process-drawable s3-0) root quat)) (send-event s3-0 'trans (-> self flut flut-trans)) (quaternion-copy! (the-as quaternion (-> self flut flut-quat)) (-> (the-as process-drawable s3-0) root quat)) - (set! (-> self flut flut-scale quad) (-> (the-as process-drawable s3-0) root scale quad)) + (vector-copy! (-> self flut flut-scale) (-> (the-as process-drawable s3-0) root scale)) (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int (-> self flut flut-trans y))))) - (set! (-> self control state-vector0 quad) (-> gp-0 quad)) - (set! (-> self control state-vector1 quad) (-> s4-0 quad))) + (vector-copy! (-> self control state-vector0) gp-0) + (vector-copy! (-> self control state-vector1) s4-0)) (sound-play "flut-coo" :vol 90 :pitch -0.5) (ja-channel-push! 1 (seconds 0.05)) (ja-no-eval :group! eichar-flut-get-off-ja :num! (seek!) :frame-num 0.0) @@ -1343,7 +1343,7 @@ f30-0)) (vector+! (-> self flut flut-trans) (-> self control trans) (-> self control cspace-offset)) (quaternion-copy! (the-as quaternion (-> self flut flut-quat)) (-> self control quat)) - (set! (-> self flut flut-scale quad) (-> self control scale quad)) + (vector-copy! (-> self flut flut-scale) (-> self control scale)) (target-no-move-post))) (defstate target-flut-get-off-hit-ground (target) diff --git a/goal_src/jak1/levels/jungle/fisher.gc b/goal_src/jak1/levels/jungle/fisher.gc index 0d0c84dd1c..57a1106649 100644 --- a/goal_src/jak1/levels/jungle/fisher.gc +++ b/goal_src/jak1/levels/jungle/fisher.gc @@ -773,7 +773,7 @@ (defbehavior fisher-fish-water fisher-fish ((arg0 vector) (arg1 float)) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> arg0 quad)) + (vector-copy! gp-0 arg0) (set! (-> gp-0 y) (ocean-get-height gp-0)) (set! (-> *part-id-table* 118 init-specs 4 initial-valuef) (+ 24576.0 arg1)) (set! (-> *part-id-table* 118 init-specs 19 initial-valuef) (+ 49152.0 arg1)) @@ -930,7 +930,7 @@ (set-width! s5-0 200) (set-height! s5-0 30) (set-scale! s5-0 0.7) - (set! (-> s5-0 flags) (font-flags shadow kerning right large)) + (set-flags! s5-0 (font-flags shadow kerning right large)) (print-game-text (lookup-text! *common-text* (text-id caught) #f) s5-0 #f 128 22) (set! (-> s5-0 origin x) 488.0) (let ((s4-1 print-game-text)) (format (clear *temp-string*) "~3D" (-> arg0 caught)) (s4-1 *temp-string* s5-0 #f 128 22)) @@ -1116,7 +1116,7 @@ (let ((gp-0 (new 'stack 'font-context *font-default-matrix* 56 100 0.0 (font-color red) (font-flags shadow kerning)))) (let ((v1-10 gp-0)) (set! (-> v1-10 width) (the float 400))) (let ((v1-11 gp-0)) (set! (-> v1-11 height) (the float 50))) - (set! (-> gp-0 flags) (font-flags shadow kerning middle large)) + (set-flags! gp-0 (font-flags shadow kerning middle large)) (print-game-text (lookup-text! *common-text* (text-id lose!) #f) gp-0 #f 128 22))) (fisher-draw-display self) (let ((gp-1 (get-response (-> self query)))) @@ -1231,19 +1231,10 @@ :exit (behavior () (remove-setting! 'ambient-volume) - (let* ((v1-2 *camera-other-matrix*) - (a3-0 (-> *camera-combiner* inv-camera-rot)) - (a0-2 (-> a3-0 vector 0 quad)) - (a1-1 (-> a3-0 vector 1 quad)) - (a2-1 (-> a3-0 vector 2 quad)) - (a3-1 (-> a3-0 vector 3 quad))) - (set! (-> v1-2 vector 0 quad) a0-2) - (set! (-> v1-2 vector 1 quad) a1-1) - (set! (-> v1-2 vector 2 quad) a2-1) - (set! (-> v1-2 vector 3 quad) a3-1)) + (matrix-copy! *camera-other-matrix* (-> *camera-combiner* inv-camera-rot)) (set! (-> *camera-other-fov* data) (-> *camera-combiner* fov)) - (set! (-> *camera-other-trans* quad) (-> *camera-combiner* trans quad)) - (set! (-> *camera-other-root* quad) (-> self root trans quad)) + (vector-copy! *camera-other-trans* (-> *camera-combiner* trans)) + (vector-copy! *camera-other-root* (-> self root trans)) (restore-collide-with-as (-> self root)) (send-event *camera* 'blend-from-as-fixed) (send-event *camera* 'change-state *camera-base-mode* 0) diff --git a/goal_src/jak1/levels/jungle/hopper.gc b/goal_src/jak1/levels/jungle/hopper.gc index c4ac018316..94f17b1a5b 100644 --- a/goal_src/jak1/levels/jungle/hopper.gc +++ b/goal_src/jak1/levels/jungle/hopper.gc @@ -35,7 +35,7 @@ nav-enemy-default-event-handler (let ((probe-point (new 'stack-no-clear 'vector))) (let ((hit (new 'stack-no-clear 'collide-tri-result)) (probe-distance 61440.0)) - (set! (-> probe-point quad) (-> point quad)) + (vector-copy! probe-point point) (+! (-> probe-point y) 20480.0) (let ((hit-fraction (fill-and-probe-using-y-probe *collide-cache* probe-point @@ -46,12 +46,12 @@ nav-enemy-default-event-handler (new 'static 'pat-surface :noentity #x1)))) (if (< hit-fraction 0.0) (return (the-as object #f))) (set! (-> probe-point y) (- (-> probe-point y) (* hit-fraction probe-distance))))) - (set! (-> point quad) (-> probe-point quad))) + (vector-copy! point probe-point)) 0) (defbehavior hopper-jump-to hopper ((destination vector)) "Ground the destination, execute a custom jump, and keep the shadow floor below the arc." - (set! (-> self jump-dest quad) (-> destination quad)) + (vector-copy! (-> self jump-dest) destination) (hopper-find-ground (-> self jump-dest)) (set! (-> self shadow-min-y) (+ (fmin (-> self collide-info trans y) (-> self jump-dest y)) (-> self nav-info shadow-min-y))) diff --git a/goal_src/jak1/levels/jungle/jungle-elevator.gc b/goal_src/jak1/levels/jungle/jungle-elevator.gc index 5aac1d994b..30c6235c8f 100644 --- a/goal_src/jak1/levels/jungle/jungle-elevator.gc +++ b/goal_src/jak1/levels/jungle/jungle-elevator.gc @@ -32,7 +32,7 @@ (behavior () (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self root trans quad)) + (vector-copy! s5-0 (-> self root trans)) (call-parent-state-handler trans) (vector-! gp-0 (-> self root trans) s5-0) (when (< (-> self path-pos) 0.9) diff --git a/goal_src/jak1/levels/jungle/jungle-mirrors.gc b/goal_src/jak1/levels/jungle/jungle-mirrors.gc index 3732436560..e99c4db3dd 100644 --- a/goal_src/jak1/levels/jungle/jungle-mirrors.gc +++ b/goal_src/jak1/levels/jungle/jungle-mirrors.gc @@ -644,7 +644,7 @@ (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) (backup-collide-with-as s5-0) (set! (-> self root) s5-0)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *periscope-mirror-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (go reflector-idle) @@ -733,7 +733,7 @@ (let ((s4-5 (new 'stack-no-clear 'vector)) (s3-2 (new 'stack-no-clear 'vector)) (s5-4 (new 'stack-no-clear 'vector))) - (set! (-> s4-5 quad) (-> (camera-pos) quad)) + (vector-copy! s4-5 (camera-pos)) (vector-! s3-2 (-> self prev-reflector-trans) s4-5) (vector-normalize! s3-2 1.0) (vector+*! s5-4 s4-5 s3-2 20480.0) @@ -797,7 +797,7 @@ (gp-0 (new 'stack-no-clear 'vector)) (s5-0 (new 'stack-no-clear 'vector))) (when a0-0 - (set! (-> gp-0 quad) (-> a0-0 extra trans quad)) + (vector-copy! gp-0 (-> a0-0 extra trans)) (+! (-> gp-0 y) (res-lump-float a0-0 'height-info)) (vector-! s5-0 gp-0 (-> self reflector-trans)) (vector-normalize! s5-0 1.0) @@ -812,11 +812,11 @@ (gp-0 (new 'stack-no-clear 'vector)) (s4-0 (new 'stack-no-clear 'vector))) (when (and s2-0 a0-0) - (set! (-> s3-0 quad) (-> a0-0 extra trans quad)) + (vector-copy! s3-0 (-> a0-0 extra trans)) (+! (-> s3-0 y) (res-lump-float a0-0 'height-info)) (vector-! s5-0 s3-0 (-> self reflector-trans)) (vector-normalize! s5-0 1.0) - (set! (-> s3-0 quad) (-> s2-0 extra trans quad)) + (vector-copy! s3-0 (-> s2-0 extra trans)) (+! (-> s3-0 y) (res-lump-float s2-0 'height-info)) (vector-! gp-0 s3-0 (-> self reflector-trans)) (vector-normalize! gp-0 1.0) @@ -1071,7 +1071,7 @@ (let ((s2-2 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! s2-2 440) (set-height! s2-2 80) - (set! (-> s2-2 flags) (font-flags shadow kerning large)) + (set-flags! s2-2 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) s2-2 #f 128 22)) (when (cpad-pressed? 0 circle) (set! (-> self grips-moving?) #f) @@ -1181,16 +1181,7 @@ (set! (-> *part-id-table* 809 init-specs 3 initial-valuef) -8601.6) (set! (-> *part-id-table* 810 init-specs 2 initial-valuef) 11878.4) (set! (-> *part-id-table* 810 init-specs 3 initial-valuef) -8601.6))) - (let* ((gp-0 (-> self old-camera-matrix)) - (a2-1 (matrix-local->world #f #f)) - (v1-191 (-> a2-1 vector 0 quad)) - (a0-8 (-> a2-1 vector 1 quad)) - (a1-3 (-> a2-1 vector 2 quad)) - (a2-2 (-> a2-1 vector 3 quad))) - (set! (-> gp-0 vector 0 quad) v1-191) - (set! (-> gp-0 vector 1 quad) a0-8) - (set! (-> gp-0 vector 2 quad) a1-3) - (set! (-> gp-0 vector 3 quad) a2-2)) + (matrix-copy! (-> self old-camera-matrix) (matrix-local->world #f #f)) (send-event *camera* 'change-state cam-periscope 0) (logior! (-> self reflector 0 draw status) (draw-status hidden)) (suspend) diff --git a/goal_src/jak1/levels/jungle/junglesnake.gc b/goal_src/jak1/levels/jungle/junglesnake.gc index 9037f7b2e7..2b8158d2ad 100644 --- a/goal_src/jak1/levels/jungle/junglesnake.gc +++ b/goal_src/jak1/levels/jungle/junglesnake.gc @@ -192,16 +192,7 @@ junglesnake-default-event-handler (set! (-> s4-3 vector 0 y) f28-1) (set! (-> s4-3 vector 1 x) (- f28-1)) (set! (-> s4-3 vector 1 y) f30-2) - (let* ((a2-9 s3-5) - (a3-1 s4-3) - (v1-47 (-> a3-1 vector 0 quad)) - (a0-36 (-> a3-1 vector 1 quad)) - (a1-20 (-> a3-1 vector 2 quad)) - (a3-2 (-> a3-1 vector 3 quad))) - (set! (-> a2-9 vector 0 quad) v1-47) - (set! (-> a2-9 vector 1 quad) a0-36) - (set! (-> a2-9 vector 2 quad) a1-20) - (set! (-> a2-9 vector 3 quad) a3-2)) + (matrix-copy! s3-5 s4-3) (set! (-> s3-5 vector 0 y) (- (-> s3-5 vector 0 y))) (set! (-> s3-5 vector 1 x) (- (-> s3-5 vector 1 x))) (dotimes (s2-2 3) @@ -360,8 +351,8 @@ junglesnake-default-event-handler (ja-channel-push! 1 (seconds 0.1)) (let ((gp-0 (new 'stack-no-clear 'vector))) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self root trans quad)) - (set! (-> s5-0 quad) (-> gp-0 quad)) + (vector-copy! gp-0 (-> self root trans)) + (vector-copy! s5-0 gp-0) (+! (-> s5-0 y) 131072.0) (ja-no-eval :group! junglesnake-give-up-ja :num! (seek! max 0.5) :frame-num 0.0) (until (ja-done? 0) diff --git a/goal_src/jak1/levels/jungleb/aphid.gc b/goal_src/jak1/levels/jungleb/aphid.gc index 407a5c1ad3..0a45897adf 100644 --- a/goal_src/jak1/levels/jungleb/aphid.gc +++ b/goal_src/jak1/levels/jungleb/aphid.gc @@ -215,8 +215,8 @@ "Initialize an aphid spawned by another enemy, face its target, and begin chasing." (initialize-collision self) (logior! (-> self mask) (process-mask actor-pause)) - (set! (-> self collide-info trans quad) (-> spawn-position quad)) - (set! (-> self event-param-point quad) (-> target-position quad)) + (vector-copy! (-> self collide-info trans) spawn-position) + (vector-copy! (-> self event-param-point) target-position) (let ((facing (vector-! (new 'stack-no-clear 'vector) target-position spawn-position))) (set! (-> facing y) 0.0) (vector-normalize! facing 1.0) diff --git a/goal_src/jak1/levels/jungleb/plant-boss.gc b/goal_src/jak1/levels/jungleb/plant-boss.gc index 4f0ee1dbf2..b4d3ee4cbc 100644 --- a/goal_src/jak1/levels/jungleb/plant-boss.gc +++ b/goal_src/jak1/levels/jungleb/plant-boss.gc @@ -431,7 +431,7 @@ (set! (-> s3-0 nav-radius) (* 0.75 (-> s3-0 root-prim local-sphere w))) (backup-collide-with-as s3-0) (set! (-> self root) s3-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-yaw-angle-clear-roll-pitch! (-> self root) yaw) (set! (-> self side) side) (initialize-skeleton self *plant-boss-arm-sg* '()) @@ -467,7 +467,7 @@ (set! (-> s3-0 nav-radius) (* 0.75 (-> s3-0 root-prim local-sphere w))) (backup-collide-with-as s3-0) (set! (-> self root) s3-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-yaw-angle-clear-roll-pitch! (-> self root) yaw) (set! (-> self side) side) (initialize-skeleton self *plant-boss-back-arms-sg* '()) @@ -480,7 +480,7 @@ (stack-size-set! (-> self main-thread) 128) (set! (-> self root) (the-as collide-shape (new 'process 'trsqv))) (set-vector! (-> self root scale) scale scale scale 1.0) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-zxy! (-> self root quat) rotation) (set! (-> self side) side) (initialize-skeleton self *plant-boss-vine-sg* '()) @@ -491,8 +491,8 @@ "Place, orient, and scale a boss root, then enter its idle state." (stack-size-set! (-> self main-thread) 128) (set! (-> self root) (the-as collide-shape (new 'process 'trsqv))) - (set! (-> self root scale quad) (-> scale quad)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root scale) scale) + (vector-copy! (-> self root trans) position) (quaternion-zxy! (-> self root quat) rotation) (set! (-> self side) side) (initialize-skeleton self *plant-boss-root-sg* '()) @@ -669,7 +669,7 @@ (set! (-> s3-0 nav-radius) (* 0.75 (-> s3-0 root-prim local-sphere w))) (backup-collide-with-as s3-0) (set! (-> self root) s3-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-yaw-angle-clear-roll-pitch! (-> self root) yaw) (set! (-> self side) side) (initialize-skeleton self *plant-boss-leaf-sg* '()) diff --git a/goal_src/jak1/levels/lavatube/assistant-lavatube.gc b/goal_src/jak1/levels/lavatube/assistant-lavatube.gc index 2d9400cea2..79b6f1f219 100644 --- a/goal_src/jak1/levels/lavatube/assistant-lavatube.gc +++ b/goal_src/jak1/levels/lavatube/assistant-lavatube.gc @@ -64,7 +64,7 @@ (set-width! font-context 448) (set-height! font-context 80) (set-scale! font-context 0.8) - (set! (-> font-context flags) (font-flags shadow kerning middle large)) + (set-flags! font-context (font-flags shadow kerning middle large)) (print-game-text (lookup-text! *common-text* (text-id assistant-lavatube-need-cells-text) #f) font-context #f 128 22))) (level-hint-spawn (text-id assistant-lavatube-need-cells) "asstva74" (the-as entity #f) *entity-pool* (game-task none))))) diff --git a/goal_src/jak1/levels/lavatube/lavatube-energy.gc b/goal_src/jak1/levels/lavatube/lavatube-energy.gc index c76a204132..9ce0ec2734 100644 --- a/goal_src/jak1/levels/lavatube/lavatube-energy.gc +++ b/goal_src/jak1/levels/lavatube/lavatube-energy.gc @@ -652,7 +652,7 @@ (defbehavior energyball-init-by-other energyball ((position vector)) "Initialize an energy ball at the supplied position and start its idle state." (energyball-init self) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (initialize-skeleton self *energyball-sg* '()) (set! (-> self part) (create-launch-control group-energyball-always self)) (go energyball-idle) @@ -830,7 +830,7 @@ (if a0-3 (set! (-> self root trans quad) (-> a0-3 root trans quad)))) (initialize-skeleton self *energyarm-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) - (set! (-> self offset quad) (-> offset quad)) + (vector-copy! (-> self offset) offset) (set! (-> self y-rotation) y-rotation) (set-params! (-> self x-rotation) 0.0 1.0 0.0 0.7 0.08 0.1 0.97) (set-params! (-> self x-fall-rotation) 0.0 1.0 0.0 0.7 0.005 0.08 0.97) diff --git a/goal_src/jak1/levels/lavatube/lavatube-obs.gc b/goal_src/jak1/levels/lavatube/lavatube-obs.gc index 532a0b4e0b..db6d549b86 100644 --- a/goal_src/jak1/levels/lavatube/lavatube-obs.gc +++ b/goal_src/jak1/levels/lavatube/lavatube-obs.gc @@ -373,7 +373,7 @@ (gp-0 (new 'stack-no-clear 'matrix))) (let ((s4-0 (new 'stack-no-clear 'vector))) (get-tangent-at-percent! (-> self path) s5-0 f30-0) - (set! (-> s4-0 quad) (-> self down value quad)) + (vector-copy! s4-0 (-> self down value)) (set! (-> s4-0 y) -1.0) (vector-normalize! s4-0 1.0) (forward-down-nopitch->inv-matrix gp-0 s5-0 s4-0)) @@ -401,7 +401,7 @@ (ja-post) (sound-play "dcrate-break") (let ((gp-1 (new 'stack-no-clear 'vector))) - (set! (-> gp-1 quad) (-> self root trans quad)) + (vector-copy! gp-1 (-> self root trans)) (+! (-> gp-1 y) -49152.0) (process-spawn part-tracker :init part-tracker-init group-darkecobarrel-explode 600 #f #f #f gp-1 :to *entity-pool*)) (suspend) @@ -439,11 +439,11 @@ (cond (v1-17 (vector-! gp-1 (-> (the-as process-drawable v1-17) root trans) (-> self root trans)) - (set! (-> self leak (+ (-> self hits) -1) offset quad) (-> gp-1 quad)) + (vector-copy! (-> self leak (+ (-> self hits) -1) offset) gp-1) (vector-normalize! gp-1 -0.04) - (let ((v0-0 (the-as object (-> self down vel)))) (set! (-> (the-as vector v0-0) quad) (-> gp-1 quad)) v0-0)) + (let ((v0-0 (the-as object (-> self down vel)))) (vector-copy! (the-as vector v0-0) gp-1) v0-0)) (else - (set! (-> self leak (+ (-> self hits) -1) offset quad) (-> self root trans quad)) + (vector-copy! (-> self leak (+ (-> self hits) -1) offset) (-> self root trans)) (set! (-> self leak (+ (-> self hits) -1) offset y) (+ -49152.0 (-> self leak (+ (-> self hits) -1) offset y))))))))))))))) :trans (behavior () @@ -781,7 +781,7 @@ (ja-post) (sound-play "dcrate-break") (let ((gp-1 (new 'stack-no-clear 'vector))) - (set! (-> gp-1 quad) (-> self root trans quad)) + (vector-copy! gp-1 (-> self root trans)) (+! (-> gp-1 y) -73728.0) (process-spawn part-tracker :init part-tracker-init group-chainmine-explode 600 #f #f #f gp-1 :to *entity-pool*)) (suspend) diff --git a/goal_src/jak1/levels/maincave/baby-spider.gc b/goal_src/jak1/levels/maincave/baby-spider.gc index bf0a59b198..f4d69e5a5d 100644 --- a/goal_src/jak1/levels/maincave/baby-spider.gc +++ b/goal_src/jak1/levels/maincave/baby-spider.gc @@ -285,9 +285,9 @@ baby-spider-default-event-handler :enter (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self collide-info trans quad)) + (vector-copy! gp-0 (-> self collide-info trans)) (let ((t9-0 (-> (method-of-type nav-enemy nav-enemy-idle) enter))) (if t9-0 (t9-0))) - (if (-> self hack-move-above-ground?) (set! (-> self collide-info trans quad) (-> gp-0 quad))))) + (if (-> self hack-move-above-ground?) (vector-copy! (-> self collide-info trans) gp-0)))) :trans (behavior () (if (nav-enemy-method-53 self) (go baby-spider-die-fast)) @@ -488,7 +488,7 @@ baby-spider-default-event-handler (set! (-> this wiggle-factor) 1.5) (set! (-> this reaction-time) (rand-vu-int-range (seconds 0.1) (seconds 0.8))) (set! (-> this chase-rest-time) (seconds 1)) - (set! (-> this up-vector quad) (-> *y-vector* quad)) + (vector-copy! (-> this up-vector) *y-vector*) 0 (none)) @@ -500,7 +500,7 @@ baby-spider-default-event-handler (set! (-> self delay-before-dying-if-not-visible) (-> spawn-params delay-before-dying-if-not-visible)) (initialize-collision self) (logior! (-> self mask) (process-mask actor-pause)) - (set! (-> self collide-info trans quad) (-> position quad)) + (vector-copy! (-> self collide-info trans) position) (forward-up->quaternion (-> self collide-info quat) heading *up-vector*) (vector-float*! (-> self collide-info scale) *identity-vector* 0.63) (vector-float*! (-> self collide-info transv) heading 8192.0) diff --git a/goal_src/jak1/levels/maincave/cavecrystal-light.gc b/goal_src/jak1/levels/maincave/cavecrystal-light.gc index e2194df782..6ae946d816 100644 --- a/goal_src/jak1/levels/maincave/cavecrystal-light.gc +++ b/goal_src/jak1/levels/maincave/cavecrystal-light.gc @@ -39,7 +39,7 @@ (let ((v1-1 (-> drawable-pointer 0 node-list))) (if (and (>= joint-index 0) (nonzero? v1-1)) (vector<-cspace! s5-0 (-> v1-1 data joint-index)) - (set! (-> s5-0 quad) (-> drawable-pointer 0 root trans quad)))) + (vector-copy! s5-0 (-> drawable-pointer 0 root trans)))) (set! (-> s5-0 w) radius) (let ((f0-1 (light-intensity-at *cavecrystal-light-control* s5-0)) (a2-2 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) @@ -120,7 +120,7 @@ (+! (-> this active-count) 1) (set! (-> crystal intensity) intensity) (set! (-> crystal crystal-handle) (process->handle source-process)) - (set! (-> crystal trans quad) (-> source-process root trans quad)) + (vector-copy! (-> crystal trans) (-> source-process root trans)) (inc-intensities! this)) ((and (>= 0.0 intensity) (< 0.0 (-> crystal intensity))) (+! (-> this active-count) -1) diff --git a/goal_src/jak1/levels/maincave/dark-crystal.gc b/goal_src/jak1/levels/maincave/dark-crystal.gc index 49d9552531..e3873546cc 100644 --- a/goal_src/jak1/levels/maincave/dark-crystal.gc +++ b/goal_src/jak1/levels/maincave/dark-crystal.gc @@ -415,13 +415,13 @@ (logclear! (-> self mask) (process-mask actor-pause)) (dotimes (gp-0 (-> *dark-crystal-flash-delays* length)) (sound-play "warning") - (set! (-> self draw color-mult quad) (-> self lit-color-mult quad)) - (set! (-> self draw color-emissive quad) (-> self lit-color-emissive quad)) + (vector-copy! (-> self draw color-mult) (-> self lit-color-mult)) + (vector-copy! (-> self draw color-emissive) (-> self lit-color-emissive)) (set-time! (-> self state-time)) (until (time-elapsed? (-> self state-time) (seconds 0.1)) (suspend)) - (set! (-> self draw color-mult quad) (-> self unlit-color-mult quad)) - (set! (-> self draw color-emissive quad) (-> self unlit-color-emissive quad)) + (vector-copy! (-> self draw color-mult) (-> self unlit-color-mult)) + (vector-copy! (-> self draw color-emissive) (-> self unlit-color-emissive)) (set-time! (-> self state-time)) (let ((s5-1 (-> *dark-crystal-flash-delays* gp-0))) (until (time-elapsed? (-> self state-time) s5-1) (suspend)))) (go dark-crystal-explode))) @@ -494,9 +494,9 @@ (let ((blast-pos (new 'stack-no-clear 'vector)) (jak-pos (new 'stack-no-clear 'vector)) (to-target (new 'stack-no-clear 'vector))) - (set! (-> blast-pos quad) (-> this root trans quad)) + (vector-copy! blast-pos (-> this root trans)) (+! (-> blast-pos y) 6144.0) - (set! (-> jak-pos quad) (-> (target-pos 0) quad)) + (vector-copy! jak-pos (target-pos 0)) (+! (-> jak-pos y) 6144.0) (when (>= (-> this explode-danger-radius) (vector-vector-distance blast-pos jak-pos)) (vector-! to-target jak-pos blast-pos) @@ -549,8 +549,8 @@ (process-drawable-from-entity! this source-entity) (initialize-skeleton this *dark-crystal-sg* '()) (logior! (-> this mask) (process-mask attackable)) - (set! (-> this draw color-mult quad) (-> this unlit-color-mult quad)) - (set! (-> this draw color-emissive quad) (-> this unlit-color-emissive quad)) + (vector-copy! (-> this draw color-mult) (-> this unlit-color-mult)) + (vector-copy! (-> this draw color-emissive) (-> this unlit-color-emissive)) (set! (-> this underwater?) (= (res-lump-value source-entity 'mode uint128) 1)) (set! (-> this explode-danger-radius) (res-lump-float source-entity 'extra-radius :default 28672.0)) (set! (-> this crystal-num) (res-lump-value source-entity 'extra-id int)) diff --git a/goal_src/jak1/levels/maincave/driller-lurker.gc b/goal_src/jak1/levels/maincave/driller-lurker.gc index 615867f414..8b0611d268 100644 --- a/goal_src/jak1/levels/maincave/driller-lurker.gc +++ b/goal_src/jak1/levels/maincave/driller-lurker.gc @@ -277,7 +277,7 @@ (else (set! f0-6 1.0) (set! (-> this path-speed) 0.0))))) (set! (-> this path-u) f0-6) (let ((s3-1 (new 'stack-no-clear 'vector))) - (set! (-> s3-1 quad) (-> this root-overeride trans quad)) + (vector-copy! s3-1 (-> this root-overeride trans)) (eval-path-curve! (-> this path) (-> this root-overeride trans) f0-6 'interp) (when s4-0 (let ((f0-7 (vector-vector-xz-distance s3-1 (-> this root-overeride trans)))) diff --git a/goal_src/jak1/levels/maincave/gnawer.gc b/goal_src/jak1/levels/maincave/gnawer.gc index 34fcbef8a7..79ffbeca87 100644 --- a/goal_src/jak1/levels/maincave/gnawer.gc +++ b/goal_src/jak1/levels/maincave/gnawer.gc @@ -305,7 +305,7 @@ (set! (-> self entity) (-> gnawer-owner entity)) (logior! (-> self mask) (process-mask enemy)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (vector-identity! (-> self root scale)) (let ((s5-1 (new 'stack-no-clear 'vector))) (let ((s4-0 (new 'stack-no-clear 'vector))) @@ -340,10 +340,10 @@ (logior! (-> this draw status) (draw-status hidden)) (logclear! (-> this mask) (process-mask attackable)) (set! (-> this skel postbind-function) #f) - (set! (-> this root trans quad) (-> this post-trans quad)) + (vector-copy! (-> this root trans) (-> this post-trans)) (clear-collide-with-as (-> this root)) (dotimes (v1-12 10) - (set! (-> this segments v1-12 world-pos quad) (-> this post-trans quad))) + (vector-copy! (-> this segments v1-12 world-pos) (-> this post-trans))) (set-vector! (-> this draw bounds) 0.0 0.0 0.0 12288.0)) (none)) @@ -449,7 +449,7 @@ (set! (-> a0-3 w) f0-15) (vector-reset! (-> v1-21 local-sphere)) (set! (-> v1-21 local-sphere w) f0-15) - (set! (-> v1-21 prim-core world-sphere quad) (-> this root trans quad)) + (vector-copy! (-> v1-21 prim-core world-sphere) (-> this root trans)) (set! (-> v1-21 prim-core world-sphere w) f0-15)) gp-0)) @@ -477,7 +477,7 @@ (set! (-> gp-0 world-pos y) (-> this route dest-pt-offset y)) (vector+! (-> gp-0 world-pos) (-> gp-0 world-pos) (-> this post-trans))))) (cond - (first? (set! (-> bounds min quad) (-> gp-0 world-pos quad)) (set! (-> bounds max quad) (-> gp-0 world-pos quad))) + (first? (vector-copy! (-> bounds min) (-> gp-0 world-pos)) (vector-copy! (-> bounds max) (-> gp-0 world-pos))) (else (add-point! bounds (the-as vector3s (-> gp-0 world-pos))))) (let ((s4-1 (new 'stack-no-clear 'vector))) (vector-! s4-1 (-> gp-0 world-pos) (-> this post-trans)) @@ -498,17 +498,9 @@ "Copy the previous segment's world position and orientation into this segment." (let ((v1-3 (-> this segments segment-index)) (a0-1 (-> this segments (+ segment-index -1)))) - (set! (-> v1-3 world-pos quad) (-> a0-1 world-pos quad)) + (vector-copy! (-> v1-3 world-pos) (-> a0-1 world-pos)) (let ((v0-0 (-> v1-3 orient-mat))) - (let* ((a2-3 (-> a0-1 orient-mat)) - (v1-4 (-> a2-3 vector 0 quad)) - (a0-2 (-> a2-3 vector 1 quad)) - (a1-5 (-> a2-3 vector 2 quad)) - (a2-4 (-> a2-3 vector 3 quad))) - (set! (-> v0-0 vector 0 quad) v1-4) - (set! (-> v0-0 vector 1 quad) a0-2) - (set! (-> v0-0 vector 2 quad) a1-5) - (set! (-> v0-0 vector 3 quad) a2-4)) + (matrix-copy! v0-0 (-> a0-1 orient-mat)) v0-0))) (defmethod take-damage! ((this gnawer)) @@ -779,7 +771,7 @@ (behavior () (+! (-> self root transv y) (* -409600.0 (seconds-per-frame))) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self fall-trans quad)) + (vector-copy! gp-0 (-> self fall-trans)) (vector-v+! (-> self fall-trans) (-> self fall-trans) (-> self root transv)) (vector-! gp-0 (-> self fall-trans) gp-0) (dotimes (v1-6 10) @@ -1038,7 +1030,7 @@ (quaternion-identity! (-> this root quat)) (initialize-skeleton this *gnawer-sg* '()) (set! (-> this draw origin-joint-index) (the-as uint 8)) - (set! (-> this post-trans quad) (-> this root trans quad)) + (vector-copy! (-> this post-trans) (-> this root trans)) (let ((f0-40 (res-lump-float (-> this entity) 'rotoffset))) (quaternion-rotate-y! (-> this root quat) (-> this root quat) f0-40)) (+! (-> this root trans y) -2048.0) @@ -1076,7 +1068,7 @@ (dotimes (v1-110 10) (let ((a0-59 (-> this segments v1-110))) (set! (-> a0-59 place) v1-110) - (set! (-> a0-59 world-pos quad) (-> this post-trans quad)) + (vector-copy! (-> a0-59 world-pos) (-> this post-trans)) (vector-reset! (-> a0-59 anim-to-local-trans-offset)) (+! (-> a0-59 anim-to-local-trans-offset z) (* 5447.68 (the float v1-110))))) (logior! (-> this skel status) (janim-status inited)) diff --git a/goal_src/jak1/levels/maincave/maincave-obs.gc b/goal_src/jak1/levels/maincave/maincave-obs.gc index 04f24cb90e..dbee27cd0d 100644 --- a/goal_src/jak1/levels/maincave/maincave-obs.gc +++ b/goal_src/jak1/levels/maincave/maincave-obs.gc @@ -620,7 +620,7 @@ (let ((v1-1 (-> elevator-pointer 0 node-list))) (if (and (>= joint-index 0) (nonzero? v1-1)) (vector<-cspace! s5-0 (-> v1-1 data joint-index)) - (set! (-> s5-0 quad) (-> elevator-pointer 0 root trans quad)))) + (vector-copy! s5-0 (-> elevator-pointer 0 root trans)))) (set! (-> s5-0 w) radius) (let ((f0-1 (light-intensity-at *cavecrystal-light-control* s5-0)) (a2-2 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) @@ -634,7 +634,7 @@ (set! (-> this last-update-bounce-time) now) (when (!= (-> this smush amp) 0.0) (let ((bounced-pos (new 'stack-no-clear 'vector))) - (set! (-> bounced-pos quad) (-> this orig-trans quad)) + (vector-copy! bounced-pos (-> this orig-trans)) (+! (-> bounced-pos y) (* 819.2 (update! (-> this smush)))) (move-to-point! (-> this root) bounced-pos))))) (none)) @@ -827,7 +827,7 @@ (+! (-> this root trans x) (-> v1-28 0)) (+! (-> this root trans y) (-> v1-28 1)) (+! (-> this root trans z) (-> v1-28 2)))) - (set! (-> this orig-trans quad) (-> this root trans quad)) + (vector-copy! (-> this orig-trans) (-> this root trans)) (let ((f0-13 (res-lump-float (-> this entity) 'rotoffset))) (if (!= f0-13 0.0) (quaternion-rotate-y! (-> this root quat) (-> this root quat) f0-13))) (let ((f0-14 (quaternion-y-angle (-> this root quat)))) (matrix-rotate-y! (-> this wheel-ry-mat) f0-14)) diff --git a/goal_src/jak1/levels/maincave/mother-spider-egg.gc b/goal_src/jak1/levels/maincave/mother-spider-egg.gc index 44045010a3..cf52e2e525 100644 --- a/goal_src/jak1/levels/maincave/mother-spider-egg.gc +++ b/goal_src/jak1/levels/maincave/mother-spider-egg.gc @@ -150,7 +150,7 @@ (let ((hit (new 'stack-no-clear 'collide-tri-result)) (probe-origin (new 'stack-no-clear 'vector)) (probe-direction (new 'stack-no-clear 'vector))) - (set! (-> probe-origin quad) (-> this root trans quad)) + (vector-copy! probe-origin (-> this root trans)) (+! (-> probe-origin y) 1228.8) (set-vector! probe-direction 0.0 -61440.0 0.0 1.0) (cond @@ -208,7 +208,7 @@ :enter (behavior () (set-time! (-> self state-time)) - (if (not (draw-egg-shadow self (-> self shadow-pos) #t)) (set! (-> self shadow-pos quad) (-> self fall-dest quad)))) + (if (not (draw-egg-shadow self (-> self shadow-pos) #t)) (vector-copy! (-> self shadow-pos) (-> self fall-dest)))) :trans (behavior () (if (time-elapsed? (-> self state-time) (seconds 2)) (go mother-spider-egg-hatch)) @@ -222,7 +222,7 @@ (s4-0 (new 'stack-no-clear 'vector))) (quaternion-copy! gp-0 (-> self root quat)) (set-vector! s4-0 0.0 1.0 0.0 1.0) - (set! (-> s3-0 quad) (-> self fall-dest-normal quad)) + (vector-copy! s3-0 (-> self fall-dest-normal)) (vector-normalize! s3-0 1.0) (quaternion-from-two-vectors! s5-0 s4-0 s3-0)) (quaternion*! s5-0 s5-0 gp-0) @@ -244,7 +244,7 @@ (behavior () (when (and (zero? (-> self draw cur-lod)) (logtest? (-> self draw status) (draw-status was-drawn))) (let ((a1-0 (new 'stack-no-clear 'vector))) - (set! (-> a1-0 quad) (-> self fall-dest quad)) + (vector-copy! a1-0 (-> self fall-dest)) (compute-and-draw-shadow (-> self root trans) a1-0 (-> self fall-dest-normal) @@ -345,8 +345,8 @@ (set! (-> self entity) source-entity) (set! (-> self anim-speed) (rand-vu-float-range 0.8 1.2)) (set-time! (-> self falling-start-time)) - (set! (-> self fall-dest quad) (-> fall-dest quad)) - (set! (-> self fall-dest-normal quad) (-> landing-normal quad)) + (vector-copy! (-> self fall-dest) fall-dest) + (vector-copy! (-> self fall-dest-normal) landing-normal) (let ((s4-1 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player)))) (set! (-> s4-1 dynam) (copy *standard-dynamics* 'process)) (set! (-> s4-1 reaction) default-collision-reaction) @@ -361,7 +361,7 @@ (set! (-> s4-1 nav-radius) 4096.0) (backup-collide-with-as s4-1) (set! (-> self root) s4-1)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set-vector! (-> self root scale) 0.3 0.3 0.3 1.0) (quaternion-copy! (-> self root quat) (-> self parent-override 0 root quat)) (logior! (-> self mask) (process-mask actor-pause)) diff --git a/goal_src/jak1/levels/maincave/mother-spider-proj.gc b/goal_src/jak1/levels/maincave/mother-spider-proj.gc index cc7e2dbc93..777eb576ee 100644 --- a/goal_src/jak1/levels/maincave/mother-spider-proj.gc +++ b/goal_src/jak1/levels/maincave/mother-spider-proj.gc @@ -289,9 +289,9 @@ (set! (-> this tween) 0.02) (set! (-> this attack-mode) 'mother-spider-proj) (set! (-> this timeout) (seconds 4)) - (set! (-> this target quad) (-> (target-pos 0) quad)) + (vector-copy! (-> this target) (target-pos 0)) (+! (-> this target y) 4915.2) - (set! (-> this target-base quad) (-> this target quad)) + (vector-copy! (-> this target-base) (-> this target)) (set! (-> this sound-id) (sound-play "mother-track")) (sound-play "mother-fire") (none)) @@ -302,12 +302,12 @@ (not (logtest? (-> *target* state-flags) (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)))) (let ((gp-0 (-> this target))) - (set! (-> gp-0 quad) (-> (target-pos 0) quad)) + (vector-copy! gp-0 (target-pos 0)) (+! (-> gp-0 y) 4915.2) (let ((f0-2 (vector-vector-distance gp-0 (-> this root trans))) (a2-0 (new 'stack-no-clear 'vector))) (if (>= 0.0 f0-2) (set! f0-2 409.6)) - (set! (-> a2-0 quad) (-> *target* control transv quad)) + (vector-copy! a2-0 (-> *target* control transv)) (set! (-> a2-0 y) 0.0) (let ((f0-3 (/ f0-2 (* 32768.0 (seconds-per-frame))))) (vector+float*! gp-0 gp-0 a2-0 (* f0-3 (seconds-per-frame))))))) (none)) diff --git a/goal_src/jak1/levels/maincave/mother-spider.gc b/goal_src/jak1/levels/maincave/mother-spider.gc index f8477b5f19..6e0d728193 100644 --- a/goal_src/jak1/levels/maincave/mother-spider.gc +++ b/goal_src/jak1/levels/maincave/mother-spider.gc @@ -154,7 +154,7 @@ (set! (-> self entity) (-> spider entity)) (logior! (-> self mask) (process-mask enemy)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (vector-identity! (-> self root scale)) (set-heading-vec-clear-roll-pitch! (-> self root) leg-direction) (vector-float*! (-> self transv) launch-direction (rand-vu-float-range 10240.0 30720.0)) @@ -304,7 +304,7 @@ (let ((s5-0 (new 'stack-no-clear 'collide-tri-result)) (a1-0 (new 'stack-no-clear 'vector)) (a2-0 (new 'stack-no-clear 'vector))) - (set! (-> a1-0 quad) (-> this root trans quad)) + (vector-copy! a1-0 (-> this root trans)) (set-vector! a2-0 0.0 -81920.0 0.0 1.0) (+! (-> a1-0 y) -8192.0) (cond @@ -500,7 +500,7 @@ (vector-v+! (-> this swing-base-pos) (-> this swing-base-pos) (-> this swing-vel)) 0) (else (vector-reset! (-> this swing-vel))))))) - (set! (-> this swing-pos quad) (-> this swing-base-pos quad)) + (vector-copy! (-> this swing-pos) (-> this swing-base-pos)) (let ((f30-1 (the float (- (current-time) (-> this spawned-time))))) (+! (-> this swing-pos x) (* 1024.0 (cos (* 54.613335 f30-1)))) (+! (-> this swing-pos z) (* 1024.0 (cos (* 81.817726 f30-1))))) @@ -514,7 +514,7 @@ (vector-rotate-around-y! (-> this root trans) (-> this root trans) f0-36)) (vector+! (-> this root trans) (-> this root trans) (-> this anchor-trans))) (else - (set! (-> this root trans quad) (-> this anchor-trans quad)) + (vector-copy! (-> this root trans) (-> this anchor-trans)) (set! (-> this root trans y) (- (-> this root trans y) (-> this dist-from-anchor)))))) (let ((v1-51 (-> this draw bounds))) (vector+! v1-51 (-> this root trans) (-> this anchor-trans)) @@ -698,11 +698,11 @@ (>= (-> self max-spit-xz-dist) (vector-vector-xz-distance (-> self root trans) (target-pos 0)))) (let ((gp-2 (new 'stack-no-clear 'vector)) (s5-2 (new 'stack-no-clear 'vector))) - (set! (-> gp-2 quad) (-> self root trans quad)) + (vector-copy! gp-2 (-> self root trans)) (set! (-> gp-2 w) 4096.0) (when (sphere-in-view-frustum? (the-as sphere gp-2)) (vector<-cspace! gp-2 (joint-node mother-spider-lod0-jg jaw)) - (set! (-> s5-2 quad) (-> (target-pos 0) quad)) + (vector-copy! s5-2 (target-pos 0)) (+! (-> s5-2 y) 4915.2) (cond ((< 24576.0 (vector-vector-distance gp-2 s5-2)) (go mother-spider-spit)) @@ -770,7 +770,7 @@ (s5-0 (new 'stack-no-clear 'vector)) (s2-0 (new 'stack-no-clear 'vector))) (vector<-cspace! s4-0 (joint-node mother-spider-lod0-jg jaw)) - (set! (-> s5-0 quad) (-> (target-pos 0) quad)) + (vector-copy! s5-0 (target-pos 0)) (+! (-> s5-0 y) 4915.2) (when (< 24576.0 (vector-vector-distance s5-0 s4-0)) (let ((a2-1 (-> self node-list data 19 bone transform))) @@ -900,14 +900,14 @@ (new 'static 'pat-surface :noentity #x1)) 0.0) (set! (-> landing-pos y) (-> s2-2 intersect y)) - (set! (-> landing-normal quad) (-> s2-2 normal quad)) + (vector-copy! landing-normal (-> s2-2 normal)) (return #t)) (else 0)))) (else 0))) (project-onto-nav-mesh (-> this nav) landing-pos (-> this root trans)) (let ((a1-12 (new 'stack-no-clear 'vector)) (s3-2 (new 'stack-no-clear 'collide-tri-result))) - (set! (-> a1-12 quad) (-> landing-pos quad)) + (vector-copy! a1-12 landing-pos) (+! (-> a1-12 y) 8192.0) (cond ((>= (fill-and-probe-using-line-sphere *collide-cache* @@ -920,7 +920,7 @@ (new 'static 'pat-surface :noentity #x1)) 0.0) (set! (-> landing-pos y) (-> s3-2 intersect y)) - (set! (-> landing-normal quad) (-> s3-2 normal quad)) + (vector-copy! landing-normal (-> s3-2 normal)) (return #t)) (else 0))) #f) @@ -970,7 +970,7 @@ (vector<-cspace! s2-0 (-> self node-list data (-> s0-0 joint-index1))) (vector-! s2-0 s2-0 s3-0) (vector-normalize! s2-0 1.0) - (set! (-> s1-0 quad) (-> s2-0 quad)) + (vector-copy! s1-0 s2-0) (+! (-> s1-0 y) 0.3) (vector-normalize! s1-0 1.0) (process-spawn mother-spider-leg self s3-0 s2-0 s1-0 :to self)) @@ -1216,8 +1216,8 @@ (set! (-> v0-30 ear) (the-as uint 0)) (set! (-> v0-30 max-dist) 102400.0) (set! (-> v0-30 ignore-angle) 16384.0)) - (set! (-> this thread-min-trans quad) (-> this root trans quad)) - (set! (-> this anchor-trans quad) (-> this root trans quad)) + (vector-copy! (-> this thread-min-trans) (-> this root trans)) + (vector-copy! (-> this anchor-trans) (-> this root trans)) (set! (-> this max-swing-radius) 73728.0) (set! (-> this max-baby-count) 4) (let ((s4-1 #f)) @@ -1245,7 +1245,7 @@ (set! (-> this max-dist-from-anchor) (- (-> this anchor-trans y) (-> this thread-min-trans y))) (set! (-> this player-sticky-dist-from-anchor) (-> this max-dist-from-anchor)) (set! (-> this targ-dist-from-anchor) (-> this idle-dist-from-anchor)) - (set! (-> this root trans quad) (-> this anchor-trans quad)) + (vector-copy! (-> this root trans) (-> this anchor-trans)) (set! (-> this root trans y) (- (-> this root trans y) (-> this idle-dist-from-anchor))) (set-vector! (-> this orient-rot) 0.0 0.0 0.0 1.0) (quaternion-zxy! (-> this root quat) (-> this orient-rot)) diff --git a/goal_src/jak1/levels/misty/babak-with-cannon.gc b/goal_src/jak1/levels/misty/babak-with-cannon.gc index 708414287c..df21d66f52 100644 --- a/goal_src/jak1/levels/misty/babak-with-cannon.gc +++ b/goal_src/jak1/levels/misty/babak-with-cannon.gc @@ -92,7 +92,7 @@ nav-enemy-default-event-handler (defun babak-with-cannon-compute-ride-point ((cannon mistycannon) (output vector)) "Transform Babak's fixed local riding offset by the cannon's main joint matrix and write the resulting world position to output." - (set! (-> output quad) (-> cannon root trans quad)) + (vector-copy! output (-> cannon root trans)) (let ((ride-offset (new 'static 'vector :y 18149.377 :z -17289.217 :w 1.0)) (main-joint (-> cannon node-list data 3 bone transform))) (vector-matrix*! output ride-offset main-joint)) diff --git a/goal_src/jak1/levels/misty/balloonlurker.gc b/goal_src/jak1/levels/misty/balloonlurker.gc index 89c26bf093..8e87251163 100644 --- a/goal_src/jak1/levels/misty/balloonlurker.gc +++ b/goal_src/jak1/levels/misty/balloonlurker.gc @@ -336,7 +336,7 @@ (let ((position (new 'stack-no-clear 'vector)) (tangent (new 'stack-no-clear 'vector))) (eval-path-curve-div! (-> self path) position (the float index) 'interp) - (set! (-> self root-overlay trans quad) (-> position quad)) + (vector-copy! (-> self root-overlay trans) position) (get-tangent-at-vertex! (-> self path) tangent (the float index)) (set! (-> tangent y) 0.0) (vector-normalize! tangent 1.0) @@ -362,7 +362,7 @@ "Record the force needed to match Jak's velocity at his contact point." (when *target* (set! (-> self player-impulse) #t) - (set! (-> self player-force-position quad) (-> *target* control trans quad)) + (vector-copy! (-> self player-force-position) (-> *target* control trans)) (vector-! (-> self player-force) (-> self player-velocity) (-> *target* control transv)) (vector-float*! (-> self player-force) (-> self player-force) (-> *BALLOONLURKER-bank* player-mass)))) @@ -533,7 +533,7 @@ (update-transforms! (-> self root-overlay)) (ja-post)) (else - (set! (-> self draw origin quad) (-> self root-overlay trans quad)) + (vector-copy! (-> self draw origin) (-> self root-overlay trans)) (logior! (-> self draw status) (draw-status skip-bones))))) (none)) @@ -710,9 +710,9 @@ (balloonlurker-pilot-method-20 self) (logclear! (-> self mask) (process-mask actor-pause)) (set! (-> self fact) (new 'process 'fact-info-enemy self (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))) - (set! (-> self root trans quad) (-> balloon root-overlay trans quad)) + (vector-copy! (-> self root trans) (-> balloon root-overlay trans)) (set! (-> self root quat vec quad) (-> balloon root-overlay quat vec quad)) - (set! (-> self root scale quad) (-> balloon root-overlay scale quad)) + (vector-copy! (-> self root scale) (-> balloon root-overlay scale)) (balloonlurker-pilot-method-21 self) (go balloonlurker-pilot-idle) (none)) @@ -816,8 +816,8 @@ (set! (-> this explosion-joint-index-bytes 1) 7) (set! (-> this engine-sound-id) (new 'static 'sound-id)) (set! (-> this pedal-sound-id) (new 'static 'sound-id)) - (set! (-> this player-force quad) (-> *null-vector* quad)) - (set! (-> this player-velocity quad) (-> *null-vector* quad)) + (vector-copy! (-> this player-force) *null-vector*) + (vector-copy! (-> this player-velocity) *null-vector*) 0 (none)) diff --git a/goal_src/jak1/levels/misty/misty-conveyor.gc b/goal_src/jak1/levels/misty/misty-conveyor.gc index b68457d157..57b670ee57 100644 --- a/goal_src/jak1/levels/misty/misty-conveyor.gc +++ b/goal_src/jak1/levels/misty/misty-conveyor.gc @@ -311,7 +311,7 @@ (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) (backup-collide-with-as s4-0) (set! (-> self root) s4-0)) - (set! (-> self root trans quad) (-> source root trans quad)) + (vector-copy! (-> self root trans) (-> source root trans)) (initialize-skeleton self *keg-sg* '()) (set! (-> self draw shadow-ctrl) (new 'process 'shadow-control 0.0 0.0 614400.0 (the-as float 60) 245760.0)) (let ((v1-25 (-> self draw shadow-ctrl))) (logior! (-> v1-25 settings flags) (shadow-flags disable-draw))) @@ -407,9 +407,9 @@ (set! (-> self root) s5-0)) (set! (-> self path) (new 'process 'curve-control self 'path -1000000000.0)) (logior! (-> self path flags) (path-control-flag display draw-line draw-point draw-text)) - (set! (-> self root trans quad) (-> source root trans quad)) + (vector-copy! (-> self root trans) (-> source root trans)) (set! (-> self root quat vec quad) (-> source root quat vec quad)) - (set! (-> self root scale quad) (-> source root scale quad)) + (vector-copy! (-> self root scale) (-> source root scale)) (initialize-skeleton self *keg-conveyor-paddle-sg* '()) (setup-params! (-> self sync) (the-as uint 4800) 0.0 0.15 0.15) (logclear! (-> self mask) (process-mask actor-pause enemy)) diff --git a/goal_src/jak1/levels/misty/mistycannon.gc b/goal_src/jak1/levels/misty/mistycannon.gc index bfa1015ead..ff78863710 100644 --- a/goal_src/jak1/levels/misty/mistycannon.gc +++ b/goal_src/jak1/levels/misty/mistycannon.gc @@ -795,14 +795,14 @@ (set! (-> moving-shape event-self) 'touched) (set! (-> moving-shape max-iteration-count) (the-as uint 4)) (set! (-> self root) moving-shape)) - (set! (-> self root trans quad) (-> init-data pos quad)) + (vector-copy! (-> self root trans) (-> init-data pos)) (set-vector! (-> self root scale) 0.0 0.0 0.0 1.0) (set! (-> self muzzle-time) (-> init-data muzzle-time)) (quaternion-axis-angle! (-> self root quat) 0.0 1.0 0.0 (-> init-data rotate)) (let ((tumble-per-frame (/ 655360.0 (the float (the int (* 300.0 (-> init-data flight-time))))))) (quaternion-axis-angle! (-> self tumble-quat) 1.0 0.0 0.0 tumble-per-frame)) (initialize-skeleton self *mistycannon-missile-sg* '()) - (set! (-> self root transv quad) (-> init-data vel quad)) + (vector-copy! (-> self root transv) (-> init-data vel)) (set! (-> self blast-radius) (-> init-data blast-radius)) (set! (-> self water-height) (res-lump-float (-> self entity) 'water-height :default -4096000.0)) (set! (-> self part) (create-launch-control group-beach-sack-fuse self)) @@ -1001,7 +1001,7 @@ (let ((camera-position (new 'stack-no-clear 'vector))) (set-vector! camera-position 0.0 53248.0 -4096.0 1.0) (vector-matrix*! camera-position camera-position (-> cannon node-list data 3 bone transform)) - (set! (-> cannon goggles quad) (-> camera-position quad))) + (vector-copy! (-> cannon goggles) camera-position)) (set! (-> cannon postbindinfo-ok) #t) 0 (none)) @@ -1197,7 +1197,7 @@ (let ((prompt-font (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! prompt-font 440) (set-height! prompt-font 80) - (set! (-> prompt-font flags) (font-flags shadow kerning large)) + (set-flags! prompt-font (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) prompt-font #f 128 22)) (when (cpad-pressed? 0 circle) (loop @@ -1221,7 +1221,7 @@ (behavior () (loop (let ((cannon-handle (-> self change-event-from))) - (set! (-> self trans quad) (-> (the-as mistycannon (-> cannon-handle 0)) goggles quad)) + (vector-copy! (-> self trans) (-> (the-as mistycannon (-> cannon-handle 0)) goggles)) (let ((rotate-camera! matrix-rotate-yx!) (tracking (-> self tracking)) (yaw-tracker (-> (the-as mistycannon (-> cannon-handle 0)) rotate))) @@ -1370,7 +1370,7 @@ (set! (-> this center-point w) (res-lump-float source-entity 'center-radius)) (cond ((= (-> this center-point w) 0.0) - (set! (-> this center-point quad) (-> this root trans quad)) + (vector-copy! (-> this center-point) (-> this root trans)) (set! (-> this center-point w) (-> this fact idle-distance))) (else (let* ((center-x-tag (new 'static 'res-tag)) diff --git a/goal_src/jak1/levels/ogre/flying-lurker.gc b/goal_src/jak1/levels/ogre/flying-lurker.gc index b95c2b421f..415a75ff72 100644 --- a/goal_src/jak1/levels/ogre/flying-lurker.gc +++ b/goal_src/jak1/levels/ogre/flying-lurker.gc @@ -249,7 +249,7 @@ (let ((probe-result (new 'stack-no-clear 'collide-tri-result)) (probe-start (new 'stack-no-clear 'vector)) (probe-direction (new 'stack-no-clear 'vector))) - (set! (-> probe-start quad) (-> this root trans quad)) + (vector-copy! probe-start (-> this root trans)) (+! (-> probe-start y) -8192.0) (set-vector! probe-direction 0.0 -81920.0 0.0 1.0) (when (>= (fill-and-probe-using-line-sphere *collide-cache* @@ -290,7 +290,7 @@ (when (not shadow-valid?) (logior! (-> shadow-ctrl settings flags) (shadow-flags disable-draw)) 0 - (set! (-> this draw bounds quad) (-> this default-bounds quad)) + (vector-copy! (-> this draw bounds) (-> this default-bounds)) (set! (-> this draw origin-joint-index) (the-as uint 4)))) (none))) @@ -332,7 +332,7 @@ maximum speeds. The two distance arguments are retained by the interface but unused here." (let ((target-offset (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans))) (path-tangent (new 'stack-no-clear 'vector))) - (set! (-> path-tangent quad) (-> self tangent quad)) + (vector-copy! path-tangent (-> self tangent)) 0.0 (let ((target-distance (vector-length target-offset))) (set! (-> target-offset y) 0.0) @@ -810,7 +810,7 @@ (set! (-> this draw shadow-joint-index) (the-as uint 4)) (set! (-> this take-off) #f) (set-vector! (-> this default-bounds) 0.0 8192.0 0.0 24576.0) - (set! (-> this draw bounds quad) (-> this default-bounds quad)) + (vector-copy! (-> this draw bounds) (-> this default-bounds)) (set! (-> this draw shadow-ctrl) (new 'process 'shadow-control 131072.0 151552.0 614400.0 (the-as float 60) 409600.0)) (let ((v1-27 (-> this draw shadow-ctrl))) (logclear! (-> v1-27 settings flags) (shadow-flags disable-draw))) 0 diff --git a/goal_src/jak1/levels/ogre/ogre-obs.gc b/goal_src/jak1/levels/ogre/ogre-obs.gc index 11e91de4ed..79cfd12306 100644 --- a/goal_src/jak1/levels/ogre/ogre-obs.gc +++ b/goal_src/jak1/levels/ogre/ogre-obs.gc @@ -488,7 +488,7 @@ (set! (-> point local-pos y) 0.0) (set! (-> point local-pos z) (* radius (cos angle)))) (set! (-> point local-pos w) 1.0)))) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) (set! (-> this active) #f) (set! (-> this triggered) #f) 0 diff --git a/goal_src/jak1/levels/ogre/ogreboss.gc b/goal_src/jak1/levels/ogre/ogreboss.gc index df08970425..251c0b74f0 100644 --- a/goal_src/jak1/levels/ogre/ogreboss.gc +++ b/goal_src/jak1/levels/ogre/ogreboss.gc @@ -128,7 +128,7 @@ (new 'static 'pat-surface :noentity #x1)))) (cond ((>= f0-2 0.0) (vector+*! (-> self root trans) (-> self root trans) s5-0 f0-2) (go ogreboss-missile-impact)) - (else (set! (-> self root trans quad) (-> gp-0 quad)) 0))) + (else (vector-copy! (-> self root trans) gp-0) 0))) (quaternion*! (-> self root quat) (-> self root quat) (-> self tumble-quat)) (spawn (-> self part) (-> self root trans)) (suspend))) @@ -157,7 +157,7 @@ (new 'static 'pat-surface :noentity #x1)))) (cond ((>= f0-2 0.0) (vector+*! (-> self root trans) (-> self root trans) s5-0 f0-2) (go ogreboss-missile-impact)) - (else (set! (-> self root trans quad) (-> gp-0 quad)) 0))) + (else (vector-copy! (-> self root trans) gp-0) 0))) (spawn (-> self part) (-> self root trans)) (suspend))) (cleanup-for-death self)) @@ -230,7 +230,7 @@ (s3-0 (new 'stack-no-clear 'vector)) (t2-0 (new 'stack-no-clear 'collide-tri-result))) 0.0 - (set! (-> s4-1 quad) (-> (the-as target t1-0) control trans quad)) + (vector-copy! s4-1 (-> (the-as target t1-0) control trans)) (+! (-> s4-1 y) 4096.0) (set-vector! s3-0 0.0 (- 118784.0 (-> s4-1 y)) 0.0 1.0) (let ((f30-0 (fill-and-probe-using-line-sphere *collide-cache* @@ -302,9 +302,9 @@ (backup-collide-with-as s5-0) (set! (-> s5-0 event-self) 'touched) (set! (-> self root) s5-0)) - (set! (-> self root trans quad) (-> arg0 src quad)) - (set! (-> self src-pos quad) (-> arg0 src quad)) - (set! (-> self dest-pos quad) (-> arg0 dest quad)) + (vector-copy! (-> self root trans) (-> arg0 src)) + (vector-copy! (-> self src-pos) (-> arg0 src)) + (vector-copy! (-> self dest-pos) (-> arg0 dest)) (set! (-> self root quat vec quad) (-> self parent-override 0 root quat vec quad)) (vector-identity! (-> self root scale)) (initialize-skeleton self *ogreboss-shoot-boulder-sg* '()) @@ -428,7 +428,7 @@ (none)) (defbehavior ogreboss-super-boulder-play-hit-anim ogreboss-super-boulder () - (set! (-> self src-pos quad) (-> self root trans quad)) + (vector-copy! (-> self src-pos) (-> self root trans)) (ja-no-eval :group! ogreboss-super-boulder-hit-ja :num! (seek!) :frame-num 0.0) (until (ja-done? 0) (seek! (-> self joint blend) (the-as float 0.0) (* 5.0 (seconds-per-frame))) @@ -445,7 +445,7 @@ :code (behavior () (set! (-> self hit-boss) #f) - (set! (-> self src-pos quad) (-> self root trans quad)) + (vector-copy! (-> self src-pos) (-> self root trans)) (ja-no-eval :group! ogreboss-super-boulder-throw-ja :num! (seek!) :frame-num 0.0) (until (ja-done? 0) (seek! (-> self joint blend) (the-as float 0.0) (* 5.0 (seconds-per-frame))) @@ -485,7 +485,7 @@ :event ogreboss-super-boulder-event-handler :code (behavior () - (set! (-> self root trans quad) (-> self orig-pos quad)) + (vector-copy! (-> self root trans) (-> self orig-pos)) (ogreboss-super-boulder-impact-effect) (set! (-> self joint enable) #f) (ja-no-eval :group! ogreboss-super-boulder-roll-ja :num! (seek! (ja-aframe (the-as float 100.0) 0)) :frame-num 0.0) @@ -576,8 +576,8 @@ (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) (backup-collide-with-as s4-0) (set! (-> self root) s4-0)) - (set! (-> self orig-pos quad) (-> arg0 quad)) - (set! (-> self root trans quad) (-> self parent-override 0 root trans quad)) + (vector-copy! (-> self orig-pos) arg0) + (vector-copy! (-> self root trans) (-> self parent-override 0 root trans)) (set! (-> self root quat vec quad) (-> self parent-override 0 root quat vec quad)) (vector-identity! (-> self root scale)) (initialize-skeleton self *ogreboss-super-boulder-sg* '()) @@ -675,10 +675,10 @@ (backup-collide-with-as s5-0) (set! (-> self root) s5-0)) (set! (-> self boulder-type) arg0) - (set! (-> self root trans quad) (-> self parent-override 0 root trans quad)) + (vector-copy! (-> self root trans) (-> self parent-override 0 root trans)) (set! (-> self root quat vec quad) (-> self parent-override 0 root quat vec quad)) (vector-identity! (-> self root scale)) - (set! (-> self src-pos quad) (-> self root trans quad)) + (vector-copy! (-> self src-pos) (-> self root trans)) (set! (-> self side-pos) 0.0) (set! (-> self dest-pos) (the-as float @@ -915,8 +915,8 @@ (let* ((a0-3 (-> self target-actor-array v1-10)) (a1-0 (if a0-3 (-> a0-3 extra process)))) (if a1-0 - (set! (-> s5-0 quad) (-> (the-as process-drawable a1-0) root trans quad)) - (set! (-> s5-0 quad) (-> self root trans quad)))) + (vector-copy! s5-0 (-> (the-as process-drawable a1-0) root trans)) + (vector-copy! s5-0 (-> self root trans)))) (vector+! s5-0 s5-0 (-> self target-offset-array v1-10)) (set! (-> gp-0 blast-radius) (-> self target-blast-radius-array v1-10)))) (else (vector+*! s5-0 (-> self root trans) *z-vector* (the-as float 409600.0)))) @@ -1006,7 +1006,7 @@ (when (not (-> self at-near-spot)) (ogreboss-submerge arg0 arg1) (set! (-> self at-near-spot) #t) - (set! (-> self root trans quad) (-> self near-pos quad)) + (vector-copy! (-> self root trans) (-> self near-pos)) (ogreboss-emerge arg1)) 0 (none)) @@ -1015,7 +1015,7 @@ (when (-> self at-near-spot) (ogreboss-submerge arg0 arg1) (set! (-> self at-near-spot) #f) - (set! (-> self root trans quad) (-> self far-pos quad)) + (vector-copy! (-> self root trans) (-> self far-pos)) (ogreboss-emerge arg1)) 0 (none)) @@ -1128,7 +1128,7 @@ (defbehavior ogreboss-update-super-boulder ogreboss () (let ((a1-0 (handle->process (-> self boulder)))) - (if a1-0 (set! (-> (the-as ogreboss-super-boulder a1-0) root trans quad) (-> self root trans quad)))) + (if a1-0 (vector-copy! (-> (the-as ogreboss-super-boulder a1-0) root trans) (-> self root trans)))) 0 (none)) @@ -1379,7 +1379,7 @@ (let ((gp-1 (new 'stack-no-clear 'vector))) (let ((a0-9 (entity-actor-lookup (-> self entity) 'trigger-actor 2))) (if (not a0-9) (set! a0-9 (-> self entity))) - (set! (-> gp-1 quad) (-> a0-9 extra trans quad))) + (vector-copy! gp-1 (-> a0-9 extra trans))) (label cfg-6) (birth-pickup-at-point gp-1 (pickup-type fuel-cell) @@ -1490,12 +1490,12 @@ (vector-z-quaternion! (-> this z-plane) (-> this root quat)) (set! (-> this z-plane w) (- (vector-dot (-> this z-plane) (-> this root trans)))) (vector-x-quaternion! (-> this side-dir) (-> this root quat)) - (set! (-> this far-pos quad) (-> this root trans quad)) + (vector-copy! (-> this far-pos) (-> this root trans)) (let ((f0-38 1.0)) (set-vector! (-> this root scale) f0-38 f0-38 f0-38 1.0)) (vector+*! (-> this near-pos) (-> this far-pos) (-> this z-plane) (the-as float 348160.0)) (set! (-> this at-near-spot) #t) (set! (-> this try-counted) #f) - (set! (-> this root trans quad) (-> this near-pos quad)) + (vector-copy! (-> this root trans) (-> this near-pos)) (if (and (-> this entity) (logtest? (-> this entity extra perm status) (entity-perm-status complete))) (go ogreboss-dead) (go ogreboss-idle)) diff --git a/goal_src/jak1/levels/racer_common/collide-reaction-racer.gc b/goal_src/jak1/levels/racer_common/collide-reaction-racer.gc index 209d3ca8c8..adc5288ca7 100644 --- a/goal_src/jak1/levels/racer_common/collide-reaction-racer.gc +++ b/goal_src/jak1/levels/racer_common/collide-reaction-racer.gc @@ -10,7 +10,7 @@ (sv-84 (new-stack-vector0)) (v1-2 (new 'stack-no-clear 'inline-array 'vector 2))) (dotimes (a0-1 2) - (set! (-> v1-2 a0-1 quad) (the-as uint128 0))) + (vector-zero! (-> v1-2 a0-1))) (let ((sv-88 v1-2) (sv-96 0)) (let ((sv-104 0)) @@ -23,7 +23,7 @@ (if (= (-> arg0 poly-pat mode) (pat-mode wall)) (logior! sv-104 1)) (if (= (-> arg0 mod-surface mode) 'air) (logior! sv-104 32)) (let ((v1-21 (new 'stack-no-clear 'vector))) - (set! (-> v1-21 quad) (-> arg1 best-from-prim prim-core world-sphere quad)) + (vector-copy! v1-21 (-> arg1 best-from-prim prim-core world-sphere)) (vector-! sv-80 v1-21 (-> arg1 best-tri intersect))) (vector-normalize! sv-80 1.0) (set! (-> arg0 coverage) (vector-dot sv-80 (-> arg1 best-tri normal))) @@ -34,7 +34,7 @@ (if (< (-> arg0 coverage) 0.9999) (logior! sv-104 24)) (set! (-> sv-84 quad) (-> sv-80 quad)) (if (= (-> arg1 best-u) 0.0) (move-by-vector! arg0 (vector-normalize-copy! (new-stack-vector0) sv-84 3.0))) - (set! (-> arg0 poly-normal quad) (-> arg1 best-tri normal quad)) + (vector-copy! (-> arg0 poly-normal) (-> arg1 best-tri normal)) (collide-shape-moving-angle-set! arg0 sv-84 (-> sv-88 0)) (if (< (-> arg0 poly-angle) -0.2) (logior! sv-96 16)) (let ((s3-1 (< (fabs (-> arg0 surface-angle)) (-> *pat-mode-info* (-> arg0 cur-pat mode) wall-angle)))) @@ -59,8 +59,8 @@ (cond ((-> arg1 best-to-prim) (logior! sv-96 32) - (set! (-> arg0 actor-contact-pt quad) (-> arg1 best-tri intersect quad)) - (set! (-> arg0 actor-contact-normal quad) (-> arg0 poly-normal quad)) + (vector-copy! (-> arg0 actor-contact-pt) (-> arg1 best-tri intersect)) + (vector-copy! (-> arg0 actor-contact-normal) (-> arg0 poly-normal)) (set! (-> arg0 actor-contact-handle) (process->handle (-> arg1 best-to-prim cshape process)))) ((= (-> arg0 poly-pat material) (pat-material waterbottom))) (else (logior! sv-96 4096))) @@ -70,8 +70,8 @@ (logior! sv-104 4) (logior! sv-96 8) (set! (-> arg0 cur-pat mode) 1) - (set! (-> arg0 wall-contact-pt quad) (-> arg1 best-tri intersect quad)) - (set! (-> arg0 wall-contact-poly-normal quad) (-> arg0 poly-normal quad)) + (vector-copy! (-> arg0 wall-contact-pt) (-> arg1 best-tri intersect)) + (vector-copy! (-> arg0 wall-contact-poly-normal) (-> arg0 poly-normal)) (set! (-> arg0 wall-pat) (-> arg1 best-tri pat)) (vector-reflect-flat-above! arg2 (-> sv-88 0) sv-84) (cond @@ -109,12 +109,12 @@ (set! (-> arg0 ground-touch-point w) 0.0) (when (not (logtest? sv-104 15)) (logior! sv-96 2) - (set! (-> arg0 ground-poly-normal quad) (-> arg0 poly-normal quad)) + (vector-copy! (-> arg0 ground-poly-normal) (-> arg0 poly-normal)) (set! (-> arg0 ground-contact-normal quad) (-> sv-84 quad)) (set! (-> arg0 ground-local-norm-dot-grav) (vector-dot sv-84 (-> arg0 dynam gravity-normal))) (set-time! (-> arg0 last-time-on-ground)) (set! (-> arg0 ground-pat) (-> arg0 poly-pat)) - (set! (-> arg0 ground-touch-point quad) (-> arg1 best-tri intersect quad)) + (vector-copy! (-> arg0 ground-touch-point) (-> arg1 best-tri intersect)) (logior! sv-104 2048) (if (= (-> arg0 poly-pat material) (pat-material waterbottom)) (logior! sv-96 1024)))))) (logior! (-> arg0 status) sv-96) diff --git a/goal_src/jak1/levels/racer_common/racer-states.gc b/goal_src/jak1/levels/racer_common/racer-states.gc index 05883aac8c..7817859a61 100644 --- a/goal_src/jak1/levels/racer_common/racer-states.gc +++ b/goal_src/jak1/levels/racer_common/racer-states.gc @@ -97,7 +97,7 @@ (set! (-> self control reaction) target-collision-reaction) (sound-stop (-> self racer engine-sound-id)) (set! (-> self racer engine-sound-id) (new 'static 'sound-id)) - (set! (-> self control cspace-offset quad) (the-as uint128 0)) + (vector-zero! (-> self control cspace-offset)) (remove-setting! 'sound-flava) (target-exit))) :code @@ -133,7 +133,7 @@ (vector-reset! (-> self racer rot)) (set! (-> self racer rot y) (y-angle (-> self control))) (target-collide-set! 'racer 0.0) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control ctrl-xz-vel) 0.0) (logior! (-> self control root-prim prim-core action) (collide-action racer)) (set! (-> self control mod-surface) *racer-mods*) @@ -227,7 +227,7 @@ (< (-> self control surface-angle) 0.5) (let ((gp-1 (vector-! (new 'stack-no-clear 'vector) (-> self control wall-contact-pt) (-> self control trans))) (s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self control last-transv quad)) + (vector-copy! s5-0 (-> self control last-transv)) (set! (-> gp-1 y) 0.0) (set! (-> s5-0 y) 0.0) (vector-xz-normalize! gp-1 1.0) @@ -541,7 +541,7 @@ (set! (-> v1-0 shove-back) 6144.0) (set! (-> v1-0 shove-up) 4915.2) (set! (-> v1-0 angle) #f)) - (set! (-> self attack-info trans quad) (the-as uint128 0)) + (vector-zero! (-> self attack-info trans)) (combine! (-> self attack-info) arg1) (case (-> self attack-info mode) (('endlessfall 'death 'explode 'water-vol 'heat 'melt 'instant-death) @@ -572,7 +572,7 @@ (('endlessfall)) (('darkeco) (let ((s5-1 (new 'stack-no-clear 'vector))) - (set! (-> s5-1 quad) (-> self control transv quad)) + (vector-copy! s5-1 (-> self control transv)) (let ((a2-3 (vector-xz-normalize! (vector-! (new 'stack-no-clear 'vector) (-> self control trans) (-> self attack-info intersection)) 1.0))) (set! (-> a2-3 y) 0.0) @@ -745,7 +745,7 @@ (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f28-0) (vector-float*! s5-3 s5-3 (/ f0-38 f1-12))))))) (camera-change-to (the-as string 'base) 0 #f))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control ctrl-xz-vel) 0.0) (set! (-> self post-hook) target-no-stick-post) (initialize! (-> self game) 'dead (the-as game-save #f) (the-as string #f)) @@ -765,28 +765,28 @@ exit) :code (behavior ((arg0 handle)) - (set! (-> self control transv quad) (the-as uint128 0)) - (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (vector-zero! (-> self control transv)) + (vector-copy! (-> self alt-cam-pos) (-> self control camera-pos)) (logior! (-> self state-flags) (state-flags use-alt-cam-pos)) (set-time! (-> self state-time)) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self control trans quad)) + (vector-copy! gp-0 (-> self control trans)) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self control trans quad)) + (vector-copy! s5-0 (-> self control trans)) (quaternion-copy! (-> self control mount-start-quat) (-> self control quat)) (quaternion-copy! (-> self control mount-end-quat) (-> self control quat-for-control)) (set! (-> self control state-var0) (the-as uint (-> self control draw-offset y))) (let* ((s3-0 (handle->process arg0)) (s4-1 (if (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) (the-as racer s3-0)))) (when s4-1 - (set! (-> s5-0 quad) (-> s4-1 root trans quad)) + (vector-copy! s5-0 (-> s4-1 root trans)) (quaternion-copy! (-> self control mount-end-quat) (-> s4-1 root quat)) (send-event s4-1 'trans (-> self racer bike-trans)) (quaternion-copy! (the-as quaternion (-> self racer bike-quat)) (-> s4-1 root quat)) (set! (-> self racer bike-scale quad) (-> s4-1 root scale quad)) (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int (-> self racer bike-trans y))))) - (set! (-> self control state-vector0 quad) (-> gp-0 quad)) - (set! (-> self control state-vector1 quad) (-> s5-0 quad)))) + (vector-copy! (-> self control state-vector0) gp-0) + (vector-copy! (-> self control state-vector1) s5-0))) (let ((s5-1 #f) (gp-1 #f)) (ja-channel-push! 1 (seconds 0.05)) @@ -795,7 +795,7 @@ (when (and (not s5-1) (= (-> self skel root-channel 0) (-> self skel channel))) (send-event (ppointer->process (-> self manipy)) 'anim-mode 'clone-anim) (set! s5-1 #t)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (when (< 50.0 (ja-aframe-num 0)) (when (not gp-1) (sound-play "zoomer-start") @@ -810,7 +810,7 @@ (ja :num! (seek! (ja-aframe 77.0 0))))) (logclear! (-> self state-flags) (state-flags use-alt-cam-pos)) (send-event *camera* 'set-slave-option #x6000) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (quaternion-copy! (-> self control quat) (-> self control quat-for-control)) (rot->dir-targ! (-> self control)) (set! (-> self racer rot y) (y-angle (-> self control))) @@ -885,26 +885,26 @@ (behavior ((arg0 handle)) (sound-play "zoomer-stop") (set-time! (-> self state-time)) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (let ((gp-1 (new 'stack-no-clear 'vector))) - (set! (-> gp-1 quad) (-> self control trans quad)) + (vector-copy! gp-1 (-> self control trans)) (let ((s4-1 (new 'stack-no-clear 'vector))) - (set! (-> s4-1 quad) (-> self control trans quad)) + (vector-copy! s4-1 (-> self control trans)) (quaternion-copy! (-> self control mount-start-quat) (-> self control quat)) (quaternion-copy! (-> self control mount-end-quat) (-> self control quat-for-control)) (set! (-> self control state-var0) (the-as uint (-> self control draw-offset y))) (let* ((s2-0 (handle->process arg0)) (s3-0 (if (and (nonzero? s2-0) (type-type? (-> s2-0 type) process-drawable)) (the-as racer s2-0)))) (when s3-0 - (set! (-> s4-1 quad) (-> s3-0 root trans quad)) + (vector-copy! s4-1 (-> s3-0 root trans)) (set-yaw-angle-clear-roll-pitch! (-> s3-0 root) (quaternion-y-angle (-> self control quat))) (quaternion-copy! (-> self control mount-end-quat) (-> s3-0 root quat)) (send-event s3-0 'trans (-> self racer bike-trans)) (quaternion-copy! (the-as quaternion (-> self racer bike-quat)) (-> s3-0 root quat)) (set! (-> self racer bike-scale quad) (-> s3-0 root scale quad)) (set! (-> self control did-move-to-pole-or-max-jump-height) (the-as int (-> self racer bike-trans y))))) - (set! (-> self control state-vector0 quad) (-> gp-1 quad)) - (set! (-> self control state-vector1 quad) (-> s4-1 quad))) + (vector-copy! (-> self control state-vector0) gp-1) + (vector-copy! (-> self control state-vector1) s4-1)) (ja-channel-push! 1 (seconds 0.05)) (ja-no-eval :group! eichar-racer-get-off-ja :num! (seek!) :frame-num 0.0) (until (ja-done? 0) diff --git a/goal_src/jak1/levels/racer_common/racer.gc b/goal_src/jak1/levels/racer_common/racer.gc index cb8355f911..b13a4d1aa1 100644 --- a/goal_src/jak1/levels/racer_common/racer.gc +++ b/goal_src/jak1/levels/racer_common/racer.gc @@ -175,7 +175,7 @@ (let ((gp-0 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! gp-0 440) (set-height! gp-0 80) - (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (set-flags! gp-0 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) gp-0 #f 128 22)) (if (and (or (cpad-pressed? 0 circle) (= (-> self condition) 4)) (send-event *target* 'change-mode 'racing self)) (go-virtual pickup (the-as (state collectable) (method-of-object self wait-for-return)))))) diff --git a/goal_src/jak1/levels/racer_common/target-racer.gc b/goal_src/jak1/levels/racer_common/target-racer.gc index 3df742c1a8..8fde7f2aa3 100644 --- a/goal_src/jak1/levels/racer_common/target-racer.gc +++ b/goal_src/jak1/levels/racer_common/target-racer.gc @@ -244,7 +244,7 @@ (defbehavior racer-collision target () (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self control transv quad)) + (vector-copy! gp-0 (-> self control transv)) (let ((f30-0 0.8)) (fill-cache-integrate-and-collide! (-> self control) (-> self control transv) (-> self control root-prim collide-with)) (+! (-> self racer shock-offsetv) (* (- (-> gp-0 y) (-> self control transv y)) f30-0)) diff --git a/goal_src/jak1/levels/robocave/cave-trap.gc b/goal_src/jak1/levels/robocave/cave-trap.gc index a2212260b9..861c565cb9 100644 --- a/goal_src/jak1/levels/robocave/cave-trap.gc +++ b/goal_src/jak1/levels/robocave/cave-trap.gc @@ -89,7 +89,7 @@ (when (or (< (-> any-slot index) 0) (< distance (-> any-slot dist))) (set! (-> any-slot index) actor-index) (set! (-> any-slot dist) distance))) - (set! (-> bounds quad) (-> (the-as process-drawable candidate) root trans quad)) + (vector-copy! bounds (-> (the-as process-drawable candidate) root trans)) (set! (-> bounds w) 4096.0) (when (sphere-in-view-frustum? bounds) (let ((visible-slot (-> work best 2))) diff --git a/goal_src/jak1/levels/robocave/spider-egg.gc b/goal_src/jak1/levels/robocave/spider-egg.gc index 196abfcae3..43fc83a869 100644 --- a/goal_src/jak1/levels/robocave/spider-egg.gc +++ b/goal_src/jak1/levels/robocave/spider-egg.gc @@ -162,7 +162,7 @@ (go process-drawable-art-error "no ground")) (+! (-> this root trans y) -409.6) (let ((tilt-axis (new 'stack-no-clear 'vector))) - (set! (-> tilt-axis quad) (-> this root surface-normal quad)) + (vector-copy! tilt-axis (-> this root surface-normal)) (+! (-> tilt-axis x) (rand-vu-float-range -0.2 0.2)) (+! (-> tilt-axis z) (rand-vu-float-range -0.2 0.2)) (vector-normalize! tilt-axis 1.0) diff --git a/goal_src/jak1/levels/rolling/rolling-lightning-mole.gc b/goal_src/jak1/levels/rolling/rolling-lightning-mole.gc index 44b6e3897a..8016d98ea0 100644 --- a/goal_src/jak1/levels/rolling/rolling-lightning-mole.gc +++ b/goal_src/jak1/levels/rolling/rolling-lightning-mole.gc @@ -160,7 +160,7 @@ (vector-! s0-0 (-> s2-0 intersection) (-> enemy collide-info trans)) (set! (-> enemy nav travel quad) (-> s0-0 quad)) (let ((f28-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) - (set! (-> s0-0 quad) (-> desired-travel quad)) + (vector-copy! s0-0 desired-travel) (set! (-> s0-0 y) 0.0) (vector-normalize! s0-0 1.0) (let ((f30-0 (vector-dot s0-0 (-> s2-0 boundary-normal)))) @@ -175,7 +175,7 @@ (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) (vector-normalize! s3-0 (sin f28-1)) (vector+float*! s3-0 s3-0 (-> s2-0 boundary-normal) (cos f28-1))) - (else (let ((v1-15 s3-0)) (set! (-> v1-15 quad) (-> s0-0 quad)) v1-15))))) + (else (let ((v1-15 s3-0)) (vector-copy! v1-15 s0-0) v1-15))))) ((< (cos (-> enemy flee-info min-reflect-angle)) f30-0) (vector--float*! s3-0 s0-0 (-> s2-0 boundary-normal) f30-0) (vector-normalize! s3-0 (sin (-> enemy flee-info min-reflect-angle))) @@ -197,9 +197,9 @@ (let ((s3-0 (new 'stack-no-clear 'matrix)) (s4-0 (new 'stack-no-clear 'vector))) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s4-0 quad) (-> enemy saved-travel quad)) + (vector-copy! s4-0 (-> enemy saved-travel)) (set! (-> s4-0 y) 0.0) - (set! (-> s5-0 quad) (-> enemy desired-travel quad)) + (vector-copy! s5-0 (-> enemy desired-travel)) (set! (-> s5-0 y) 0.0) (vector-normalize! s4-0 1.0) (vector-normalize! s5-0 1.0) @@ -234,11 +234,11 @@ (let ((s3-0 (new 'stack-no-clear 'matrix)) (s5-2 (new 'stack-no-clear 'vector))) (let ((s4-1 (new 'stack-no-clear 'vector))) - (set! (-> s5-2 quad) (-> self desired-travel quad)) + (vector-copy! s5-2 (-> self desired-travel)) (set! (-> s5-2 y) 0.0) - (set! (-> s4-1 quad) (-> gp-0 quad)) + (vector-copy! s4-1 gp-0) (set! (-> s4-1 y) 0.0) - (if (= (vector-normalize-ret-len! s5-2 1.0) 0.0) (set! (-> s5-2 quad) (-> s4-1 quad))) + (if (= (vector-normalize-ret-len! s5-2 1.0) 0.0) (vector-copy! s5-2 s4-1)) (vector-normalize-ret-len! s4-1 1.0) (matrix-from-two-vectors-max-angle-partial! s3-0 s5-2 s4-1 (-> self flee-info max-flee-rotation) 0.25)) (vector-matrix*! s5-2 s5-2 s3-0) @@ -438,7 +438,7 @@ (behavior () (set! (-> self speed-adjust) 1.0) (set-vector! (-> self debug-vector) 0.0 0.0 1.0 1.0) - (set! (-> self saved-travel quad) (-> self debug-vector quad)) + (vector-copy! (-> self saved-travel) (-> self debug-vector)) ((-> (method-of-type nav-enemy nav-enemy-chase) enter))) :trans (behavior () @@ -459,13 +459,13 @@ (vector-matrix*! (-> self debug-vector) (-> self debug-vector) s5-0)) (vector-normalize! (-> self debug-vector) (-> self flee-info deflection-max-dist)) (camera-line-rel (-> self collide-info trans) (-> self debug-vector) (new 'static 'vector4w :x #x80 :y #x80 :w #x80)) - (set! (-> gp-0 quad) (-> self debug-vector quad)) + (vector-copy! gp-0 (-> self debug-vector)) (set! (-> self target-speed) (-> self nav-info run-travel-speed)) (format *stdcon* "tgt-speed ~M defmd ~M~%" (-> self target-speed) (-> self flee-info deflection-max-dist)) (if (time-elapsed? (-> self last-reflection-time) (-> self flee-info reflection-time)) (vector-normalize-copy! (-> self desired-travel) gp-0 (-> self flee-info deflection-max-dist)))) (if (fleeing-nav-enemy-clip-travel self (-> self desired-travel)) (set-time! (-> self last-reflection-time))) - (set! (-> self debug-vector quad) (-> self desired-travel quad)) + (vector-copy! (-> self debug-vector) (-> self desired-travel)) (fleeing-nav-enemy-adjust-travel self (-> self desired-travel)) (fleeing-nav-enemy-chase-post-func) (camera-line-rel (-> self collide-info trans) (-> self desired-travel) (new 'static 'vector4w :x #x80 :w #x80)) @@ -528,8 +528,8 @@ (vector-! s5-0 *lightning-mole-hole* gp-0) (vector-normalize! s5-0 1.0) (forward-down->inv-matrix *camera-other-matrix* s5-0 (-> *camera* local-down))) - (set! (-> *camera-other-trans* quad) (-> gp-0 quad)) - (set! (-> *camera-other-root* quad) (-> *lightning-mole-hole* quad)) + (vector-copy! *camera-other-trans* gp-0) + (vector-copy! *camera-other-root* *lightning-mole-hole*) (set! *camera-look-through-other* 2))) (lightning-mole-task-complete?) (if *target* (logclear! (-> *target* mask) (process-mask sleep))) diff --git a/goal_src/jak1/levels/rolling/rolling-obs.gc b/goal_src/jak1/levels/rolling/rolling-obs.gc index 4cd4ca19a2..cf62f1f8a1 100644 --- a/goal_src/jak1/levels/rolling/rolling-obs.gc +++ b/goal_src/jak1/levels/rolling/rolling-obs.gc @@ -92,7 +92,7 @@ (initialize-skeleton this *pusher-sg* '()) (load-params! (-> this sync) this (the-as uint 1500) 0.0 0.15 0.15) (set! (-> this max-frame) (res-lump-float source-entity 'max-frame :default (the float (ja-num-frames 0)))) - (set! (-> this cyl origin quad) (-> this root trans quad)) + (vector-copy! (-> this cyl origin) (-> this root trans)) (vector-x-quaternion! (-> this cyl axis) (-> this root quat)) (vector-negate! (-> this cyl axis) (-> this cyl axis)) (set! (-> this cyl length) 36864.0) @@ -589,7 +589,7 @@ (defbehavior rolling-start-init-by-other rolling-start ((arg0 vector) (arg1 float)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (initialize-skeleton self *rolling-start-whole-sg* '()) (setup-lods! (-> self whole-look) *rolling-start-whole-sg* (-> self draw art-group) (-> self entity)) (setup-lods! (-> self broken-look) *rolling-start-broken-sg* (-> self draw art-group) (-> self entity)) @@ -672,7 +672,7 @@ (defbehavior gorge-abort-init-by-other gorge-abort ((arg0 vector) (arg1 vector) (arg2 float)) (set! (-> self root) (the-as collide-shape-moving (new 'process 'trsqv))) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (gorge-init arg0 arg1 arg2 8192.0) (go gorge-abort-idle) (none)) @@ -687,7 +687,7 @@ (defbehavior gorge-finish-init-by-other gorge-finish ((arg0 vector) (arg1 vector) (arg2 float)) (set! (-> self root) (the-as collide-shape-moving (new 'process 'trsqv))) - (set! (-> self root trans quad) (-> arg0 quad)) + (vector-copy! (-> self root trans) arg0) (gorge-init arg0 arg1 arg2 20480.0) (go gorge-finish-idle) (none)) @@ -715,17 +715,17 @@ (set-scale! gp-0 0.7) (set! (-> gp-0 origin x) (the float (+ (-> self timer-pos-offset) 392))) (set! (-> gp-0 origin y) (the float (- 10 (-> self timer-pos-offset)))) - (set! (-> gp-0 flags) (font-flags shadow kerning right large)) + (set-flags! gp-0 (font-flags shadow kerning right large)) (print-game-text (lookup-text! *common-text* (text-id time) #f) gp-0 #f 128 22) (+! (-> gp-0 origin x) 10.0) - (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (set-flags! gp-0 (font-flags shadow kerning large)) (print-game-text (race-time->string (-> self this-time)) gp-0 #f 128 22) (+! (-> gp-0 origin x) -10.0) (+! (-> gp-0 origin y) 15.0) - (set! (-> gp-0 flags) (font-flags shadow kerning right large)) + (set-flags! gp-0 (font-flags shadow kerning right large)) (print-game-text (lookup-text! *common-text* (text-id record) #f) gp-0 #f 128 22) (+! (-> gp-0 origin x) 10.0) - (set! (-> gp-0 flags) (font-flags shadow kerning large)) + (set-flags! gp-0 (font-flags shadow kerning large)) (print-game-text (race-time->string (-> self record-time)) gp-0 #f 128 22) (cond ((not arg0)) @@ -734,8 +734,8 @@ (set-scale! gp-0 1.0) (set! (-> gp-0 origin x) 156.0) (set! (-> gp-0 origin y) 80.0) - (set! (-> gp-0 flags) (font-flags shadow kerning middle middle-vert large)) - (let ((a0-15 gp-0)) (set! (-> a0-15 color) (font-color red))) + (set-flags! gp-0 (font-flags shadow kerning middle middle-vert large)) + (set-color! gp-0 (font-color red)) (print-game-text (lookup-text! *common-text* (text-id new-record) #f) gp-0 #f 128 22)) (when arg1 (close-specific-task! (-> self entity extra perm task) (task-status need-reminder)) @@ -747,8 +747,8 @@ (set-scale! gp-0 1.0) (set! (-> gp-0 origin x) 156.0) (set! (-> gp-0 origin y) 80.0) - (set! (-> gp-0 flags) (font-flags shadow kerning middle middle-vert large)) - (let ((a0-23 gp-0)) (set! (-> a0-23 color) (font-color red))) + (set-flags! gp-0 (font-flags shadow kerning middle middle-vert large)) + (set-color! gp-0 (font-color red)) (print-game-text (lookup-text! *common-text* (text-id try-again) #f) gp-0 #f 128 22))))) (none)) @@ -757,7 +757,7 @@ (when (task-closed? (game-task rolling-race) (task-status need-introduction)) (when (not (handle->process (-> self start-banner))) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self root trans quad)) + (vector-copy! gp-0 (-> self root trans)) (let ((v0-1 (ppointer->handle (process-spawn rolling-start gp-0 0.0 :to self)))) (set! (-> self start-banner) (the-as handle v0-1)) v0-1)))))) @@ -797,7 +797,7 @@ (let ((gp-0 (new 'stack 'font-context *font-default-matrix* 156 80 0.0 (font-color red) (font-flags shadow kerning)))) (set-width! gp-0 200) (set-height! gp-0 50) - (set! (-> gp-0 flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! gp-0 (font-flags shadow kerning middle middle-vert large)) (print-game-text (lookup-text! *common-text* (text-id race-aborted) #f) gp-0 #f 128 22))) (suspend) (if (gorge-in-front self) (go gorge-start-ready))) @@ -920,7 +920,7 @@ (set! (-> this root) (the-as collide-shape-moving (new 'process 'trsqv))) (process-drawable-from-entity! this source-entity) (let ((a0-3 (new 'stack-no-clear 'vector))) - (set! (-> a0-3 quad) (-> this root trans quad)) + (vector-copy! a0-3 (-> this root trans)) (+! (-> a0-3 y) -8192.0) (gorge-init a0-3 (new 'static 'vector :z 1.0) 102400.0 40960.0)) (set! (-> this tasks) (get-task-control (-> this entity extra perm task))) diff --git a/goal_src/jak1/levels/rolling/rolling-race-ring.gc b/goal_src/jak1/levels/rolling/rolling-race-ring.gc index 49e3f5a9a0..c83315788c 100644 --- a/goal_src/jak1/levels/rolling/rolling-race-ring.gc +++ b/goal_src/jak1/levels/rolling/rolling-race-ring.gc @@ -567,7 +567,7 @@ (-> self root trans) :to self)))) - (set! (-> self old-hips quad) (-> (target-pos 26) quad)) + (vector-copy! (-> self old-hips) (target-pos 26)) (+! (-> self old-hips x) 1.0) (set! (-> self state-time) (-> *display* game-frame-counter))) :exit @@ -662,8 +662,8 @@ (go race-ring-idle))) (when *target* (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self old-hips quad)) - (set! (-> self old-hips quad) (-> (target-pos 26) quad)) + (vector-copy! gp-0 (-> self old-hips)) + (vector-copy! (-> self old-hips) (target-pos 26)) (vector-! gp-0 gp-0 (-> self old-hips)) (when (>= (ray-flat-cyl-intersect (-> self cyl) (-> self old-hips) gp-0) 0.0) (level-hint-spawn (text-id rolling-ring-chase-1-hint) "sksp0119" (the-as entity #f) *entity-pool* (game-task none)) diff --git a/goal_src/jak1/levels/rolling/rolling-robber.gc b/goal_src/jak1/levels/rolling/rolling-robber.gc index 324785e6af..2ea08207d2 100644 --- a/goal_src/jak1/levels/rolling/rolling-robber.gc +++ b/goal_src/jak1/levels/rolling/rolling-robber.gc @@ -17,8 +17,8 @@ (hide-hud-quick) (set! *camera-look-through-other* 2) (set! (-> *camera-other-fov* data) 11650.845) - (set! (-> *camera-other-trans* quad) (-> *math-camera* trans quad)) - (set! (-> *camera-other-root* quad) (-> *math-camera* trans quad)) + (vector-copy! *camera-other-trans* (-> *math-camera* trans)) + (vector-copy! *camera-other-root* (-> *math-camera* trans)) (set-time! (-> self state-time)) (loop (*! arg2 (- 1.0 (* 0.05 (-> *display* time-adjust-ratio)))) ;; og:preserve-this changed for high fps @@ -32,7 +32,7 @@ (eval-path-curve! (-> self path) (-> self root trans) arg1 'interp) (+! (-> self root trans y) 8192.0) (set! (-> self root trans y) (fmax 106496.0 (-> self root trans y))) - (set! (-> self base quad) (-> self root trans quad)) + (vector-copy! (-> self base) (-> self root trans)) (transform-post) (animate self) (let ((s4-0 (new 'stack-no-clear 'vector))) @@ -116,7 +116,7 @@ "Probe for ground below the robber and set its desired hover offset when the surface is safely separated from the water." (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self root trans quad)) + (vector-copy! gp-0 (-> self root trans)) (let ((t2-0 (new 'stack-no-clear 'collide-tri-result))) (+! (-> gp-0 y) 8192.0) (let ((f0-2 (fill-and-probe-using-line-sphere *collide-cache* @@ -128,7 +128,7 @@ t2-0 (new 'static 'pat-surface :noentity #x1))) (v1-5 (new 'stack-no-clear 'vector))) - (set! (-> v1-5 quad) (-> self root trans quad)) + (vector-copy! v1-5 (-> self root trans)) (set! (-> v1-5 y) (+ (-> gp-0 y) (* -81920.0 f0-2))) (cond ((and (>= f0-2 0.0) (< 204.8 (fabs (- (-> v1-5 y) (-> self water-height))))) @@ -145,7 +145,7 @@ (cond ((and face-jak *target*) (vector-! gp-0 (-> self root trans) (target-pos 0)) (vector-normalize! gp-0 1.0)) ((< (-> self speed) 0.0) (vector-negate! gp-0 (-> self tangent))) - (else (set! (-> gp-0 quad) (-> self tangent quad)))) + (else (vector-copy! gp-0 (-> self tangent)))) (matrix-from-two-vectors-max-angle-partial! s5-0 (-> self facing) gp-0 max-angle 0.25) (vector-matrix*! gp-0 (-> self facing) s5-0) (vector-normalize! gp-0 1.0) @@ -155,7 +155,7 @@ (set! (-> self run-blend-interp) (* 0.0002746582 (-> self run-blend-interp))) (if (< (vector-dot (-> self facing) (-> s5-0 vector 0)) 0.0) (set! (-> self run-blend-interp) (- (-> self run-blend-interp)))) - (let ((v0-10 (-> self facing))) (set! (-> v0-10 quad) (-> gp-0 quad)) v0-10))) + (let ((v0-10 (-> self facing))) (vector-copy! v0-10 gp-0) v0-10))) (defbehavior robber-move robber () "Advance and wrap the robber's curve position, evaluate its new position, and ease its vertical @@ -485,7 +485,7 @@ (set! (-> this curve-position) (res-lump-float (-> this entity) 'initial-spline-pos)) (eval-path-curve! (-> this path) (-> this root trans) (-> this curve-position) 'interp) (get-tangent-at-percent! (-> this path) (-> this tangent) (-> this curve-position)) - (set! (-> this facing quad) (-> this tangent quad)) + (vector-copy! (-> this facing) (-> this tangent)) (let ((s4-1 (new 'stack-no-clear 'matrix))) (forward-down->inv-matrix s4-1 (-> this facing) (new 'static 'vector :y -1.0)) (matrix->quaternion (-> this root quat) s4-1)) diff --git a/goal_src/jak1/levels/snow/ice-cube.gc b/goal_src/jak1/levels/snow/ice-cube.gc index 64991f42b7..4608672aa1 100644 --- a/goal_src/jak1/levels/snow/ice-cube.gc +++ b/goal_src/jak1/levels/snow/ice-cube.gc @@ -538,7 +538,7 @@ error is within the facing threshold." (let ((to-target (new 'stack-no-clear 'vector))) (when (-> this tracking-player?) - (if (and *target* update-target?) (set! (-> this target-pt quad) (-> (target-pos 0) quad)))) + (if (and *target* update-target?) (vector-copy! (-> this target-pt) (target-pos 0)))) (vector-! to-target (-> this target-pt) (-> this collide-info trans)) (seek-toward-heading-vec! (-> this collide-info) to-target 524288.0 (seconds 0.1)) (let ((facing-target? (< (fabs (deg- (quaternion-y-angle (-> this collide-info quat)) (vector-y-angle to-target))) 364.0889))) @@ -555,7 +555,7 @@ (let* ((probe-result (new 'stack-no-clear 'collide-tri-result)) (probe-offset 40960.0) (probe-length (+ probe-offset 40960.0))) - (set! (-> probe-point quad) (-> input-point quad)) + (vector-copy! probe-point input-point) (+! (-> probe-point y) probe-offset) (let ((hit-fraction (fill-and-probe-using-y-probe *collide-cache* probe-point @@ -567,7 +567,7 @@ ;; og:preserve-this yes this is bugged (if (or (< hit-fraction 0.0) (= (logand #b111000 (the-as int (-> probe-result pat))) 8)) (return #f)) (set! (-> probe-point y) (- (-> probe-point y) (* hit-fraction probe-length))))) - (set! (-> output-point quad) (-> probe-point quad))) + (vector-copy! output-point probe-point)) #t) (defmethod valid-appear-point? ((this ice-cube) (candidate-point vector)) @@ -577,7 +577,7 @@ (let ((target-distance (vector-vector-xz-distance candidate-point (target-pos 0)))) (when (and (>= target-distance 40960.0) (>= 81920.0 target-distance) (not (jump-dest-blocked? this candidate-point))) (let ((bounds (new 'stack-no-clear 'vector))) - (set! (-> bounds quad) (-> candidate-point quad)) + (vector-copy! bounds candidate-point) (set! (-> bounds w) (-> this collide-info root-prim local-sphere w)) (if (sphere-in-view-frustum? (the-as sphere bounds)) (return #t)))))) #f) @@ -596,7 +596,7 @@ (when (valid-appear-point? this output-position) (let ((a1-3 (new 'stack-no-clear 'vector)) (s3-1 (new 'stack-no-clear 'collide-tri-result))) - (set! (-> a1-3 quad) (-> output-position quad)) + (vector-copy! a1-3 output-position) (+! (-> a1-3 y) 16384.0) (if (>= (fill-and-probe-using-line-sphere *collide-cache* a1-3 @@ -607,7 +607,7 @@ s3-1 (new 'static 'pat-surface :noentity #x1)) 0.0) - (set! (-> output-position quad) (-> s3-1 intersect quad)))) + (vector-copy! output-position (-> s3-1 intersect)))) (cond (*target* (vector-! output-facing (target-pos 0) output-position) (set! (-> output-facing y) 0.0)) (else @@ -636,7 +636,7 @@ (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'vector))) (when (pick-appear-point-and-facing self s5-0 gp-0) - (set! (-> self collide-info trans quad) (-> s5-0 quad)) + (vector-copy! (-> self collide-info trans) s5-0) (forward-up->quaternion (-> self collide-info quat) gp-0 *up-vector*) (set-spikes-retracted-collision! self) (go ice-cube-appear))))) @@ -655,13 +655,13 @@ (spawn (-> self part) (-> self collide-info trans)) (set-current-poly! (-> self nav) (find-poly-fast-from-world (-> self nav) (-> self collide-info trans))) (+! (-> self collide-info trans y) -12288.0) - (set! (-> self collide-info transv quad) (-> *null-vector* quad)) + (vector-copy! (-> self collide-info transv) *null-vector*) (set! (-> self collide-info transv y) (rand-vu-float-range 102400.0 114688.0))) :trans (behavior () (when (and (< (-> self collide-info trans y) (-> self ground-y)) (< (-> self collide-info transv y) 0.0)) (set! (-> self collide-info trans y) (-> self ground-y)) - (set! (-> self collide-info transv quad) (-> *null-vector* quad)) + (vector-copy! (-> self collide-info transv) *null-vector*) (go ice-cube-appear-land)) (let* ((s5-0 (-> self node-list)) (a0-2 (-> s5-0 length)) @@ -745,7 +745,7 @@ (not (nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos)))) (go-virtual nav-enemy-patrol)) (set! (-> self tracking-player?) #t) - (set! (-> self target-pt quad) (-> (target-pos 0) quad)) + (vector-copy! (-> self target-pt) (target-pos 0)) (nav-enemy-neck-control-look-at) (set-vector! (-> self collide-info transv) 0.0 114688.0 0.0 1.0)) :code @@ -827,7 +827,7 @@ (eval-path-curve-div! (-> this path) s5-0 (the float s2-0) 'interp) (when (>= (vector-vector-xz-distance s5-0 (-> this collide-info trans)) 32768.0) (when (snap-point-to-ground this s5-0 s5-0) - (set! (-> this target-pt quad) (-> s5-0 quad)) + (vector-copy! (-> this target-pt) s5-0) (return #t))) (set! s2-0 (mod (+ s2-0 1) s4-0)))) #f) @@ -845,7 +845,7 @@ (not (nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos)))) (go ice-cube-retract-spikes)) (set! (-> self tracking-player?) #t) - (set! (-> self target-pt quad) (-> (target-pos 0) quad)) + (vector-copy! (-> self target-pt) (target-pos 0)) (nav-enemy-neck-control-look-at) (set-vector! (-> self collide-info transv) 0.0 114688.0 0.0 1.0)) :code @@ -919,7 +919,7 @@ (set! (-> self slow-down?) #f) (set! (-> self speed) 81920.0) (set! (-> self prev-charge-angle-diff) 0.0) - (let ((a0-6 (-> self collide-info trans))) (set! (-> self starting-pos quad) (-> a0-6 quad))) + (let ((a0-6 (-> self collide-info trans))) (vector-copy! (-> self starting-pos) a0-6)) (set! (-> self charge-angle) (quaternion-y-angle (-> self collide-info quat)))) :exit (behavior () @@ -931,7 +931,7 @@ (cond ((= (-> self speed) 0.0) (go ice-cube-mean-charge-done)) (else (set! (-> self slow-down?) #t) (set! (-> self track-target?) #f) (set! (-> self tracking-player?) #f)))) - (if (-> self tracking-player?) (set! (-> self target-pt quad) (-> (target-pos 0) quad))) + (if (-> self tracking-player?) (vector-copy! (-> self target-pt) (target-pos 0))) (let ((gp-1 (new 'stack-no-clear 'vector)) (s5-0 (new 'stack-no-clear 'vector))) (vector-! gp-1 (-> self target-pt) (-> self starting-pos)) @@ -1071,7 +1071,7 @@ (let ((gp-1 (new 'stack 'joint-exploder-tuning 1))) (set! (-> gp-1 duration) (seconds 3)) (set! (-> gp-1 gravity) -327680.0) - (set! (-> gp-1 fountain-rand-transv-lo quad) (-> (target-pos 0) quad)) + (vector-copy! (-> gp-1 fountain-rand-transv-lo) (target-pos 0)) (process-spawn joint-exploder *ice-cube-break-sg* 2 diff --git a/goal_src/jak1/levels/snow/snow-ball.gc b/goal_src/jak1/levels/snow/snow-ball.gc index 530607a529..0a5cf6147d 100644 --- a/goal_src/jak1/levels/snow/snow-ball.gc +++ b/goal_src/jak1/levels/snow/snow-ball.gc @@ -88,7 +88,7 @@ (defstate snow-ball-shadow-idle (snow-ball-shadow) :trans (behavior () - (set! (-> self root trans quad) (-> (the-as process-drawable (-> self parent 0)) root trans quad)) + (vector-copy! (-> self root trans) (-> (the-as process-drawable (-> self parent 0)) root trans)) (update-direction-from-time-of-day (-> self draw shadow-ctrl)) 0) :code @@ -102,7 +102,7 @@ (stack-size-set! (-> self main-thread) 128) (logclear! (-> self mask) (process-mask actor-pause movie enemy platform projectile)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> (the-as process-drawable (-> self parent 0)) root trans quad)) + (vector-copy! (-> self root trans) (-> (the-as process-drawable (-> self parent 0)) root trans)) (quaternion-identity! (-> self root quat)) (vector-identity! (-> self root scale)) (initialize-skeleton self *snow-ball-shadow-sg* '()) @@ -123,7 +123,7 @@ (let ((path-info (-> this path-info))) (set! (-> path-info hug-path?) #f) (let ((previous-path-position (new 'stack-no-clear 'vector))) - (set! (-> previous-path-position quad) (-> path-info path-pos quad)) + (vector-copy! previous-path-position (-> path-info path-pos)) (eval-path-curve! (-> this path) (-> path-info path-pos) (-> this path-u) 'interp) (let ((emerge-end (-> this path-coming-out-u))) (when (< (-> this path-u) emerge-end) @@ -157,7 +157,7 @@ (let ((f30-0 (+ f0-0 (* (-> self root transv y) (seconds-per-frame))))) (follow-path self) (let ((a1-0 (new 'stack-no-clear 'vector))) - (let ((a0-1 (-> self path-info))) (set! (-> a1-0 quad) (-> a0-1 path-pos quad))) + (let ((a0-1 (-> self path-info))) (vector-copy! a1-0 (-> a0-1 path-pos))) (+! (-> a1-0 y) 9216.0) (cond ((-> self path-info hug-path?) (move-to-point! (-> self root) a1-0) (set! (-> self root transv y) 0.0)) diff --git a/goal_src/jak1/levels/snow/snow-bunny.gc b/goal_src/jak1/levels/snow/snow-bunny.gc index bacf79ef5e..f456e65d4f 100644 --- a/goal_src/jak1/levels/snow/snow-bunny.gc +++ b/goal_src/jak1/levels/snow/snow-bunny.gc @@ -114,7 +114,7 @@ close and approaching." (let ((jump-destination (the-as object (-> block param 0)))) (set! (-> self got-jump-event?) #t) (let ((stored-destination (the-as object (-> self jump-event-dest)))) - (set! (-> (the-as vector stored-destination) quad) (-> (the-as vector jump-destination) quad)) + (vector-copy! (the-as vector stored-destination) (the-as vector jump-destination)) stored-destination))))) (defmethod set-shadow-airborne! ((this snow-bunny) (airborne? symbol)) @@ -370,7 +370,7 @@ close and approaching." (let* ((triangle (new 'stack-no-clear 'collide-tri-result)) (ground-popup (-> this gnd-popup)) (probe-distance (+ ground-popup 40960.0))) - (set! (-> probe-position quad) (-> in-point quad)) + (vector-copy! probe-position in-point) (+! (-> probe-position y) ground-popup) (let ((hit-fraction (fill-and-probe-using-y-probe *collide-cache* probe-position @@ -382,7 +382,7 @@ close and approaching." ;; og:preserve-this yes this is bugged... again (if (or (< hit-fraction 0.0) (= (logand #b111000 (the-as int (-> triangle pat))) 8)) (return #f)) (set! (-> probe-position y) (- (-> probe-position y) (* hit-fraction probe-distance))))) - (set! (-> out-point quad) (-> probe-position quad))) + (vector-copy! out-point probe-position)) #t) (defmethod nav-enemy-method-53 ((this snow-bunny)) diff --git a/goal_src/jak1/levels/snow/snow-flutflut-obs.gc b/goal_src/jak1/levels/snow/snow-flutflut-obs.gc index f7cd9442e1..ffcd92fa54 100644 --- a/goal_src/jak1/levels/snow/snow-flutflut-obs.gc +++ b/goal_src/jak1/levels/snow/snow-flutflut-obs.gc @@ -369,8 +369,8 @@ (get-current-phase (-> this sync)) (get-current-phase-with-mirror (-> this sync))) 'interp)) - (else (set! (-> this appear-trans-top quad) (-> this root trans quad)))) - (set! (-> this appear-trans-bottom quad) (-> this appear-trans-top quad)) + (else (vector-copy! (-> this appear-trans-top) (-> this root trans)))) + (vector-copy! (-> this appear-trans-bottom) (-> this appear-trans-top)) (+! (-> this appear-trans-bottom y) -286720.0) (quaternion-copy! (-> this appear-quat-top) (-> this root quat)) (let ((v1-33 (res-lump-value (-> this entity) 'extra-id uint128))) @@ -404,7 +404,7 @@ ((and (= (-> self plat-type) 1) (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))) - (set! (-> self basetrans quad) (-> self appear-trans-top quad)) + (vector-copy! (-> self basetrans) (-> self appear-trans-top)) (go elevator-idle-at-cave)) ((or (= (-> self plat-type) 1) (= (-> self plat-type) 2)) (let* ((v1-11 (-> self flutflut-button)) @@ -425,7 +425,7 @@ (behavior () (logior! (-> self draw status) (draw-status hidden)) (clear-collide-with-as (-> self root)) - (set! (-> self root trans quad) (-> self appear-trans-top quad)) + (vector-copy! (-> self root trans) (-> self appear-trans-top)) (transform-post) (logior! (-> self mask) (process-mask sleep-code)) (suspend) @@ -442,7 +442,7 @@ (logclear! (-> self mask) (process-mask actor-pause)) (logclear! (-> self draw status) (draw-status hidden)) (restore-collide-with-as (-> self root)) - (set! (-> self basetrans quad) (-> self appear-trans-bottom quad)) + (vector-copy! (-> self basetrans) (-> self appear-trans-bottom)) (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'quaternion))) (let ((f30-0 (rand-vu-float-range 0.0 65536.0))) (set-vector! s5-0 (cos f30-0) 0.0 (sin f30-0) 1.0)) @@ -526,7 +526,7 @@ (set-time! (-> self state-time)) (logclear! (-> self mask) (process-mask actor-pause)) (logclear! (-> self root root-prim prim-core action) (collide-action rider-plat-sticky)) - (set! (-> self start-trans quad) (-> self root trans quad)) + (vector-copy! (-> self start-trans) (-> self root trans)) (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'quaternion))) (let ((f30-0 (rand-vu-float-range 0.0 65536.0))) (set-vector! s5-0 (cos f30-0) 0.0 (sin f30-0) 1.0)) diff --git a/goal_src/jak1/levels/snow/snow-obs.gc b/goal_src/jak1/levels/snow/snow-obs.gc index 03779ad176..2e88a7ad63 100644 --- a/goal_src/jak1/levels/snow/snow-obs.gc +++ b/goal_src/jak1/levels/snow/snow-obs.gc @@ -325,7 +325,7 @@ (process-drawable-from-entity! this source-entity) (initialize-skeleton this *snow-eggtop-sg* '()) (logior! (-> this skel status) (janim-status inited)) - (set! (-> this spawn-trans quad) (-> this root trans quad)) + (vector-copy! (-> this spawn-trans) (-> this root trans)) (+! (-> this root trans y) -2662.4) (update-transforms! (-> this root)) (set! (-> this part) (create-launch-control group-snow-yellow-eco-room-open this)) @@ -334,7 +334,7 @@ ((task-complete? *game-info* (-> this entity extra perm task)) (go snow-eggtop-idle-down)) (else (let ((a0-17 (new 'stack-no-clear 'vector))) - (set! (-> a0-17 quad) (-> this root trans quad)) + (vector-copy! a0-17 (-> this root trans)) (+! (-> a0-17 y) 3072.0) (birth-pickup-at-point a0-17 (pickup-type fuel-cell) @@ -687,7 +687,7 @@ :code (behavior () (ja :group! snow-fort-gate-idle-ja :num! min) - (set! (-> self root trans quad) (-> self closed-trans quad)) + (vector-copy! (-> self root trans) (-> self closed-trans)) (transform-post) (suspend) (loop @@ -707,17 +707,17 @@ (let ((gp-0 #f)) (loop (let ((a1-0 (new 'stack-no-clear 'vector))) - (set! (-> a1-0 quad) (-> self closed-trans quad)) + (vector-copy! a1-0 (-> self closed-trans)) (+! (-> a1-0 y) -12288.0) (+! (-> a1-0 z) -12288.0) (spawn (-> self part) a1-0)) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self root trans quad)) + (vector-copy! s5-0 (-> self root trans)) (let ((f30-0 (vector-vector-distance-squared s5-0 (-> self open-trans)))) (when (and (not gp-0) (>= 1048576.0 f30-0)) (set! gp-0 #t) (let ((a1-2 (new 'stack-no-clear 'vector))) - (set! (-> a1-2 quad) (-> self open-trans quad)) + (vector-copy! a1-2 (-> self open-trans)) (+! (-> a1-2 y) -26624.0) (+! (-> a1-2 z) -3072.0) (spawn (-> self part2) a1-2))) @@ -728,7 +728,7 @@ (vector-seek-3d-smooth! s5-0 (-> self open-trans) (* 16384.0 (seconds-per-frame)) 0.9) (move-to-point! (-> self root) s5-0)) (let ((a1-7 (new 'stack-no-clear 'vector))) - (set! (-> a1-7 quad) (-> self root trans quad)) + (vector-copy! a1-7 (-> self root trans)) (+! (-> a1-7 x) 20480.0) (+! (-> a1-7 y) 106496.0) (+! (-> a1-7 z) -32768.0) @@ -741,7 +741,7 @@ :code (behavior () (ja :group! snow-fort-gate-idle-ja :num! min) - (set! (-> self root trans quad) (-> self open-trans quad)) + (vector-copy! (-> self root trans) (-> self open-trans)) (transform-post) (suspend) (transform-post) @@ -782,8 +782,8 @@ (set! (-> this part) (create-launch-control group-snow-fort-gate-coming-down this)) (set! (-> this part2) (create-launch-control group-snow-fort-gate-hits-bottom this)) (set! (-> this part3) (create-launch-control group-snow-fort-gate-snowdrops this)) - (set! (-> this open-trans quad) (-> this root trans quad)) - (set! (-> this closed-trans quad) (-> this open-trans quad)) + (vector-copy! (-> this open-trans) (-> this root trans)) + (vector-copy! (-> this closed-trans) (-> this open-trans)) (+! (-> this open-trans y) -141312.0) (+! (-> this open-trans z) 32768.0) (set! (-> this sound) (new 'process 'ambient-sound (static-sound-spec "lodge-door-mov" :fo-max 80) (-> this open-trans))) @@ -793,10 +793,10 @@ (set! (-> s5-1 frame-num) 0.0)) (cond ((task-complete? *game-info* (game-task snow-ball)) - (set! (-> this root trans quad) (-> this open-trans quad)) + (vector-copy! (-> this root trans) (-> this open-trans)) (transform-post) (go snow-fort-gate-idle-open)) - (else (set! (-> this root trans quad) (-> this closed-trans quad)) (transform-post) (go snow-fort-gate-idle-closed))) + (else (vector-copy! (-> this root trans) (-> this closed-trans)) (transform-post) (go snow-fort-gate-idle-closed))) (none)) (deftype snow-gears (process-drawable) () @@ -877,7 +877,7 @@ (defmethod spawn-drip-particles ((this snow-gears)) "Spawn the dripping-water particle group above the gears each frame while they are running." (let ((spawn-position (new 'stack-no-clear 'vector))) - (set! (-> spawn-position quad) (-> this root trans quad)) + (vector-copy! spawn-position (-> this root trans)) (+! (-> spawn-position y) 61440.0) (spawn (-> this part) spawn-position)) (none)) @@ -1025,7 +1025,7 @@ (loop (let ((s5-1 (new 'stack-no-clear 'vector)) (f0-1 (+ -1433.6 (-> self orig-trans y)))) - (set! (-> s5-1 quad) (-> self root trans quad)) + (vector-copy! s5-1 (-> self root trans)) (cond ((= (-> s5-1 y) f0-1) (when (not gp-2) (set! gp-2 #t) (send-to-all (-> self link) 'notice))) (else @@ -1039,7 +1039,7 @@ :code (behavior () (set! (-> self pressed?) #t) - (set! (-> self root trans quad) (-> self orig-trans quad)) + (vector-copy! (-> self root trans) (-> self orig-trans)) (+! (-> self root trans y) -1433.6) (transform-post) (loop @@ -1076,12 +1076,12 @@ (joint-control-channel-group-eval! s5-1 (the-as art-joint-anim (-> this draw art-group data 2)) num-func-identity) (set! (-> s5-1 frame-num) 0.0)) (transform-post) - (set! (-> this orig-trans quad) (-> this root trans quad)) + (vector-copy! (-> this orig-trans) (-> this root trans)) (let ((s5-2 (task-complete? *game-info* (game-task snow-ball)))) (set! (-> this pressed?) s5-2) (when (not s5-2) (let ((a0-17 (new 'stack-no-clear 'vector))) - (set! (-> a0-17 quad) (-> this orig-trans quad)) + (vector-copy! a0-17 (-> this orig-trans)) (+! (-> a0-17 y) 12288.0) (set! (-> this fcell-handle) (ppointer->handle (birth-pickup-at-point a0-17 @@ -1299,7 +1299,7 @@ :event snow-log-button-event-handler :code (behavior () - (set! (-> self root trans quad) (-> self orig-trans quad)) + (vector-copy! (-> self root trans) (-> self orig-trans)) (+! (-> self root trans y) -1433.6) (transform-post) (loop @@ -1333,7 +1333,7 @@ (joint-control-channel-group-eval! s4-1 (the-as art-joint-anim (-> this draw art-group data 2)) num-func-identity) (set! (-> s4-1 frame-num) 0.0)) (transform-post) - (set! (-> this orig-trans quad) (-> this root trans quad)) + (vector-copy! (-> this orig-trans) (-> this root trans)) (set! (-> this log) (entity-actor-lookup source-entity 'alt-actor 0)) (if (and (-> this entity) (logtest? (-> this entity extra perm status) (entity-perm-status complete))) (go snow-log-button-idle-down) diff --git a/goal_src/jak1/levels/snow/snow-ram-boss.gc b/goal_src/jak1/levels/snow/snow-ram-boss.gc index 5e9ff2fa99..8ced049408 100644 --- a/goal_src/jak1/levels/snow/snow-ram-boss.gc +++ b/goal_src/jak1/levels/snow/snow-ram-boss.gc @@ -547,12 +547,12 @@ (not (logtest? (-> *target* state-flags) (state-flags being-attacked invulnerable timed-invulnerable invuln-powerup do-not-notice dying)))) (let ((target-point (-> this target))) - (set! (-> target-point quad) (-> (target-pos 0) quad)) + (vector-copy! target-point (target-pos 0)) (+! (-> target-point y) 4915.2) (let ((distance (vector-vector-distance target-point (-> this root trans))) (player-velocity (new 'stack-no-clear 'vector))) (if (>= 0.0 distance) (set! distance 409.6)) - (set! (-> player-velocity quad) (-> *target* control transv quad)) + (vector-copy! player-velocity (-> *target* control transv)) (set! (-> player-velocity y) 0.0) (let ((lead-scale (/ distance (* 40960.0 (seconds-per-frame))))) (vector+float*! target-point target-point player-velocity (* lead-scale (seconds-per-frame))))))) @@ -604,9 +604,9 @@ (logior! (-> self root root-prim prim-core action) (collide-action solid)) (set-time! (-> self launch-time)) (vector-float*! (-> self root transv) (-> self parent-override 0 proj-launch-vec) 40960.0) - (set! (-> self target quad) (-> (target-pos 0) quad)) + (vector-copy! (-> self target) (target-pos 0)) (+! (-> self target y) 4915.2) - (set! (-> self target-base quad) (-> self target quad)) + (vector-copy! (-> self target-base) (-> self target)) (go-virtual projectile-moving))) (defstate projectile-impact (ram-boss-proj) @@ -929,7 +929,7 @@ (init-jm! this *ram-boss-nav-enemy-info-no-shield*) (let ((shield-mod (-> this shield-jmod))) (set! (-> shield-mod enable) #t) - (set! (-> shield-mod transform scale quad) (the-as uint128 0)))) + (vector-zero! (-> shield-mod transform scale)))) (set! (-> this neck up) (the-as uint 1)) (set! (-> this neck nose) (the-as uint 2)) (set! (-> this neck ear) (the-as uint 0)) @@ -948,7 +948,7 @@ (initialize-collision self) (set! (-> self entity) (-> parent entity)) (post-init-setup! self) - (set! (-> self collide-info trans quad) (-> parent collide-info trans quad)) + (vector-copy! (-> self collide-info trans) (-> parent collide-info trans)) (set-vector! (-> self collide-info scale) 1.0 1.0 1.0 1.0) (let ((t9-2 quaternion-copy!) (a0-6 (-> self collide-info quat))) @@ -970,9 +970,9 @@ (if (not *target*) (return #f)) (let ((eye-position (new 'stack-no-clear 'vector)) (to-target (new 'stack-no-clear 'vector))) - (set! (-> eye-position quad) (-> this collide-info trans quad)) + (vector-copy! eye-position (-> this collide-info trans)) (+! (-> eye-position y) 8192.0) - (set! (-> to-target quad) (-> (target-pos 0) quad)) + (vector-copy! to-target (target-pos 0)) (+! (-> to-target y) 4915.2) (vector-! to-target to-target eye-position) (let* ((probe-result (new 'stack-no-clear 'collide-tri-result)) @@ -1264,7 +1264,7 @@ (let ((gp-2 (new 'stack-no-clear 'vector)) (s5-2 (new 'stack-no-clear 'vector))) (get-throw-point! self s5-2) - (set! (-> gp-2 quad) (-> (target-pos 0) quad)) + (vector-copy! gp-2 (target-pos 0)) (+! (-> gp-2 y) 4915.2) (vector-! (-> self proj-launch-vec) gp-2 s5-2)) (vector-normalize! (-> self proj-launch-vec) 1.0) @@ -1393,7 +1393,7 @@ (let ((v1-2 (-> self entity extra perm))) (logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage)) (set! (-> v1-2 user-int8 1) 1)) - (let ((v1-3 (-> self shield-jmod))) (set! (-> v1-3 enable) #t) (set! (-> v1-3 transform scale quad) (the-as uint128 0)))) + (let ((v1-3 (-> self shield-jmod))) (set! (-> v1-3 enable) #t) (vector-zero! (-> v1-3 transform scale)))) :code (behavior () (let ((gp-0 (new 'stack-no-clear 'vector))) diff --git a/goal_src/jak1/levels/snow/target-snowball.gc b/goal_src/jak1/levels/snow/target-snowball.gc index b99f98f56f..ad6be45520 100644 --- a/goal_src/jak1/levels/snow/target-snowball.gc +++ b/goal_src/jak1/levels/snow/target-snowball.gc @@ -63,7 +63,7 @@ (set! (-> self snowball entity) #f) (let ((a0-2 (handle->process arg0))) (if a0-2 (set! (-> self snowball entity) (-> a0-2 entity)))) (reset-target-state #t) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control ctrl-xz-vel) 0.0) (move-by-vector! (-> self control) (new 'static 'vector :y 4096.0 :w 1.0)) (logior! (-> self control root-prim prim-core action) (collide-action snowball)) diff --git a/goal_src/jak1/levels/snow/yeti.gc b/goal_src/jak1/levels/snow/yeti.gc index 2e59e1fa44..ca0bcef45c 100644 --- a/goal_src/jak1/levels/snow/yeti.gc +++ b/goal_src/jak1/levels/snow/yeti.gc @@ -197,13 +197,13 @@ (set! (-> self ground-y) (-> self collide-info trans y)) (spawn (-> self part) (-> self collide-info trans)) (+! (-> self collide-info trans y) -12288.0) - (set! (-> self collide-info transv quad) (-> *null-vector* quad)) + (vector-copy! (-> self collide-info transv) *null-vector*) (set! (-> self collide-info transv y) (rand-vu-float-range 102400.0 114688.0))) :trans (behavior () (when (and (< (-> self collide-info trans y) (-> self ground-y)) (< (-> self collide-info transv y) 0.0)) (set! (-> self collide-info trans y) (-> self ground-y)) - (set! (-> self collide-info transv quad) (-> *null-vector* quad)) + (vector-copy! (-> self collide-info transv) *null-vector*) (go yeti-slave-appear-land)) (let* ((s5-0 (-> self node-list)) (a0-2 (-> s5-0 length)) @@ -416,7 +416,7 @@ (set! (-> self part) (create-launch-control group-yeti-slave-appear1 self)) (set! (-> self part2) (create-launch-control group-yeti-slave-appear2 self)) (initialize-collision self) - (set! (-> self collide-info trans quad) (-> spawn-position quad)) + (vector-copy! (-> self collide-info trans) spawn-position) (vector-identity! (-> self collide-info scale)) (forward-up->quaternion (-> self collide-info quat) spawn-direction *up-vector*) (set! (-> self entity) (-> parent entity)) diff --git a/goal_src/jak1/levels/sunken/bully.gc b/goal_src/jak1/levels/sunken/bully.gc index 40bc2aa767..be36aebc80 100644 --- a/goal_src/jak1/levels/sunken/bully.gc +++ b/goal_src/jak1/levels/sunken/bully.gc @@ -211,9 +211,9 @@ "Initialize the detached cage visual from its bully parent and play the explosion." (set! (-> self entity) source-entity) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> self parent-override 0 root trans quad)) + (vector-copy! (-> self root trans) (-> self parent-override 0 root trans)) (quaternion-copy! (-> self root quat) (-> self parent-override 0 root quat)) - (set! (-> self root scale quad) (-> self parent-override 0 root scale quad)) + (vector-copy! (-> self root scale) (-> self parent-override 0 root scale)) (initialize-skeleton self *bully-broken-cage-sg* '()) (go bully-broken-cage-explode) (none)) diff --git a/goal_src/jak1/levels/sunken/double-lurker.gc b/goal_src/jak1/levels/sunken/double-lurker.gc index b206d77342..ea89c0d11a 100644 --- a/goal_src/jak1/levels/sunken/double-lurker.gc +++ b/goal_src/jak1/levels/sunken/double-lurker.gc @@ -262,7 +262,7 @@ (set! (-> self nav extra-nav-sphere quad) (-> self fall-dest quad)) (set! (-> self nav extra-nav-sphere w) 9011.2) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self collide-info trans quad)) + (vector-copy! gp-0 (-> self collide-info trans)) (ja-channel-push! 1 (seconds 0.1)) (ja-play :group! double-lurker-top-both-break-apart-ja @@ -383,7 +383,7 @@ (set! (-> this draw origin-joint-index) (the-as uint 3)) (init-defaults! this *double-lurker-top-nav-enemy-info*) (let ((v1-5 (-> this parent-process))) - (set! (-> this collide-info trans quad) (-> v1-5 0 collide-info trans quad)) + (vector-copy! (-> this collide-info trans) (-> v1-5 0 collide-info trans)) (set-vector! (-> this collide-info scale) 1.0 1.0 1.0 1.0) (quaternion-copy! (-> this collide-info quat) (-> v1-5 0 collide-info quat))) (logclear! (-> this collide-info nav-flags) (nav-flags avoid-body)) @@ -395,7 +395,7 @@ (initialize-collision self) (set! (-> self entity) (-> parent entity)) (post-init-setup! self) - (set! (-> self collide-info trans quad) (-> spawn-position quad)) + (vector-copy! (-> self collide-info trans) spawn-position) (cond (on-shoulders? (ja-channel-set! 1) @@ -589,7 +589,7 @@ (vector+! landing-point (-> this collide-info trans) (-> this nav travel)) (let ((probe-start (new 'stack-no-clear 'vector)) (probe-result (new 'stack-no-clear 'collide-tri-result))) - (set! (-> probe-start quad) (-> landing-point quad)) + (vector-copy! probe-start landing-point) (+! (-> probe-start y) 8192.0) (when (>= (fill-and-probe-using-line-sphere *collide-cache* probe-start @@ -828,7 +828,7 @@ (logior! (-> v1-29 status) (entity-perm-status user-set-from-cstage)) (set! (-> v1-29 user-int8 2) 0)) 0)) - (if (-> this buddy-on-shoulders?) (set! (-> buddy-spawn-point quad) (-> this collide-info trans quad))) + (if (-> this buddy-on-shoulders?) (vector-copy! buddy-spawn-point (-> this collide-info trans))) (set! (-> this buddy-handle) (ppointer->handle (process-spawn double-lurker-top (-> this entity) this (-> this buddy-on-shoulders?) buddy-spawn-point :to this))))) (when (and (not (-> this dead?)) (not (-> this buddy-on-shoulders?))) diff --git a/goal_src/jak1/levels/sunken/floating-launcher.gc b/goal_src/jak1/levels/sunken/floating-launcher.gc index 105e23287e..c1f452016d 100644 --- a/goal_src/jak1/levels/sunken/floating-launcher.gc +++ b/goal_src/jak1/levels/sunken/floating-launcher.gc @@ -50,11 +50,11 @@ (while (!= f30-0 0.0) (set! f30-0 (seek f30-0 0.0 (seconds-per-frame))) (eval-path-curve-div! (-> self path) (-> self basetrans) f30-0 'interp) - (set! (-> self launcher 0 root trans quad) (-> self basetrans quad)) + (vector-copy! (-> self launcher 0 root trans) (-> self basetrans)) (update-transforms! (-> self launcher 0 root)) (suspend))) (eval-path-curve-div! (-> self path) (-> self basetrans) 0.0 'interp) - (set! (-> self launcher 0 root trans quad) (-> self basetrans quad)) + (vector-copy! (-> self launcher 0 root trans) (-> self basetrans)) (update-transforms! (-> self launcher 0 root)) (go floating-launcher-ready)) :post plat-post) diff --git a/goal_src/jak1/levels/sunken/helix-water.gc b/goal_src/jak1/levels/sunken/helix-water.gc index 08f300ec5b..5739982a81 100644 --- a/goal_src/jak1/levels/sunken/helix-water.gc +++ b/goal_src/jak1/levels/sunken/helix-water.gc @@ -151,7 +151,7 @@ (behavior () (when (not (task-complete? *game-info* (game-task sunken-slide))) (let ((a0-1 (new 'stack-no-clear 'vector))) - (set! (-> a0-1 quad) (-> self root trans quad)) + (vector-copy! a0-1 (-> self root trans)) (+! (-> a0-1 y) 30720.0) (let ((v1-7 (birth-pickup-at-point a0-1 (pickup-type fuel-cell) (the float (-> self entity extra perm task)) #f self (-> self fact)))) (set! (-> self fcell-handle) (ppointer->handle v1-7)) @@ -221,7 +221,7 @@ (level-hint-spawn (text-id sunken-helix-hint) "sksp0124" (the-as entity #f) *entity-pool* (game-task none)) (send-event *target* 'play-anim 'shock-in) (sound-play "prec-button8") - (set! (-> self root transv quad) (the-as uint128 0)) + (vector-zero! (-> self root transv)) (let ((gp-3 5)) (until (<= gp-3 0) (let ((f1-0 (-> self root transv y)) @@ -234,7 +234,7 @@ (set! f1-1 (* 0.65 (- f1-1))) (+! gp-3 -1)) (set! (-> self root transv y) f1-1) - (set! (-> a1-11 quad) (-> self root trans quad)) + (vector-copy! a1-11 (-> self root trans)) (set! (-> a1-11 y) f0-3)) (move-to-point! (-> self root) a1-11)) (suspend))) @@ -297,7 +297,7 @@ (let ((t9-6 send-event-function) (v1-11 (-> self my-water))) (t9-6 (if v1-11 (-> v1-11 extra process)) a1-4))) - (set! (-> self root transv quad) (the-as uint128 0)) + (vector-zero! (-> self root transv)) (let ((gp-2 5)) (until (<= gp-2 0) (let ((f1-0 (-> self root transv y)) @@ -310,7 +310,7 @@ (set! f1-1 (* 0.65 (- f1-1))) (+! gp-2 -1)) (set! (-> self root transv y) f1-1) - (set! (-> a1-5 quad) (-> self root trans quad)) + (vector-copy! a1-5 (-> self root trans)) (set! (-> a1-5 y) f0-1)) (move-to-point! (-> self root) a1-5)) (suspend))) @@ -355,7 +355,7 @@ (the-as art-joint-anim (-> this draw art-group data 2)) num-func-identity) (set! (-> root-channel frame-num) 0.0)) - (set! (-> this spawn-trans quad) (-> this root trans quad)) + (vector-copy! (-> this spawn-trans) (-> this root trans)) (+! (-> this root trans y) -26624.0) (set! (-> this down-y) (+ -6553.6 (-> this root trans y))) (set! (-> this fact) (new 'process 'fact-info this (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))) diff --git a/goal_src/jak1/levels/sunken/orbit-plat.gc b/goal_src/jak1/levels/sunken/orbit-plat.gc index ccfad17d29..08cedeb4d6 100644 --- a/goal_src/jak1/levels/sunken/orbit-plat.gc +++ b/goal_src/jak1/levels/sunken/orbit-plat.gc @@ -135,7 +135,7 @@ :code (behavior () (loop - (set! (-> self root trans quad) (-> self parent-override 0 root trans quad)) + (vector-copy! (-> self root trans) (-> self parent-override 0 root trans)) (+! (-> self root trans y) -5324.8) (spawn (-> self part2) (-> self root trans)) (let* ((a0-6 (-> self parent-override 0 other)) @@ -163,9 +163,9 @@ (let ((gp-1 (new 'stack-no-clear 'vector)) (s5-0 (new 'stack-no-clear 'vector))) (let ((s4-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-1 quad) (-> self root trans quad)) + (vector-copy! gp-1 (-> self root trans)) (+! (-> gp-1 y) -2048.0) - (set! (-> s5-0 quad) (-> (the-as orbit-plat v1-32) root trans quad)) + (vector-copy! s5-0 (-> (the-as orbit-plat v1-32) root trans)) (+! (-> s5-0 y) -7372.8) (vector-! s4-0 s5-0 gp-1) (vector-normalize! s4-0 1.0) @@ -191,9 +191,9 @@ (set! (-> self entity) source-entity) (logior! (-> self mask) (process-mask platform)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> parent-platform root trans quad)) + (vector-copy! (-> self root trans) (-> parent-platform root trans)) (quaternion-copy! (-> self root quat) (-> parent-platform root quat)) - (set! (-> self root scale quad) (-> parent-platform root scale quad)) + (vector-copy! (-> self root scale) (-> parent-platform root scale)) (+! (-> self root trans y) -5324.8) (set! (-> self part) (create-launch-control group-orbit-plat-jet self)) (set! (-> self part2) (create-launch-control group-standard-plat self)) @@ -359,7 +359,7 @@ (s5-0 (new 'stack-no-clear 'vector))) (let ((v1-1 gp-0) (a1-0 (-> self other))) - (set! (-> v1-1 quad) (-> (the-as orbit-plat (if a1-0 (-> a1-0 extra process))) root trans quad))) + (vector-copy! v1-1 (-> (the-as orbit-plat (if a1-0 (-> a1-0 extra process))) root trans))) (vector-! a0-0 (-> self basetrans) gp-0) (let ((f30-0 (vector-length a0-0))) (set! (-> self reset-length) f30-0) @@ -368,7 +368,7 @@ (dotimes (s4-0 2) (get-rotate-point! s5-0 gp-0 (-> self basetrans) (the-as vector f30-0) (-> self rot-dir) 40960.0) (b! (not (find-poly-fast-from-world (-> self nav) s5-0)) cfg-6 :delay (empty-form)) - (set! (-> self basetrans quad) (-> s5-0 quad)) + (vector-copy! (-> self basetrans) s5-0) (b! #t cfg-9 :delay (nop!)) (label cfg-6) (set! (-> self rot-dir) (- (-> self rot-dir))))))) @@ -405,16 +405,16 @@ (s5-1 (new 'stack-no-clear 'vector))) (let ((v1-9 s4-0) (a1-5 (-> this other))) - (set! (-> v1-9 quad) (-> (the-as orbit-plat (if a1-5 (-> a1-5 extra process))) root trans quad))) + (vector-copy! v1-9 (-> (the-as orbit-plat (if a1-5 (-> a1-5 extra process))) root trans))) (vector-! a0-7 (-> this basetrans) s4-0) (let ((f30-2 (vector-length a0-7))) (get-rotate-point! s5-1 s4-0 (-> this basetrans) (the-as vector f30-2) (-> this rot-dir) 40960.0) (cond - ((find-poly-fast-from-world (-> this nav) s5-1) (set! (-> this basetrans quad) (-> s5-1 quad))) + ((find-poly-fast-from-world (-> this nav) s5-1) (vector-copy! (-> this basetrans) s5-1)) (else (set! (-> this rot-dir) (- (-> this rot-dir))) (get-rotate-point! s5-1 s4-0 (-> this basetrans) (the-as vector f30-2) (-> this rot-dir) 40960.0) - (if (find-poly-fast-from-world (-> this nav) s5-1) (set! (-> this basetrans quad) (-> s5-1 quad)))))))) + (if (find-poly-fast-from-world (-> this nav) s5-1) (vector-copy! (-> this basetrans) s5-1))))))) (when (>= 614.4 (vector-vector-xz-distance (-> this basetrans) (-> this reset-trans))) (set! v0-11 (logior (nav-control-flags reached-destination) (-> this nav flags))) (set! (-> this nav flags) (the-as nav-control-flags v0-11)) @@ -425,7 +425,7 @@ (get-nav-point! s5-2 this (-> this reset-trans) 40960.0) (let ((v1-20 s4-1) (a0-19 (-> this other))) - (set! (-> v1-20 quad) (-> (the-as orbit-plat (if a0-19 (-> a0-19 extra process))) root trans quad))) + (vector-copy! v1-20 (-> (the-as orbit-plat (if a0-19 (-> a0-19 extra process))) root trans))) (set! (-> s5-2 y) (-> s4-1 y)) (vector-! s5-2 s5-2 s4-1) (vector-normalize! s5-2 (-> this reset-length)) @@ -440,11 +440,11 @@ (get-rotate-point! s5-2 s4-1 (-> this basetrans) (the-as vector (-> this reset-length)) (-> this rot-dir) 40960.0))))) (set! (-> s5-2 y) (-> this basetrans y)) (set! v0-11 (-> this basetrans)) - (set! (-> (the-as vector v0-11) quad) (-> s5-2 quad))) + (vector-copy! (the-as vector v0-11) s5-2)) v0-11))) (else (let ((s5-3 (new 'stack-no-clear 'vector))) - (set! (-> s5-3 quad) (-> this basetrans quad)) + (vector-copy! s5-3 (-> this basetrans)) (get-nav-point! (-> this basetrans) this (-> this reset-trans) 40960.0) (set! (-> this basetrans y) (-> s5-3 y)))))))) @@ -527,7 +527,7 @@ (let ((f0-7 (res-lump-float source-entity 'scale :default 1.0))) (set-vector! (-> this root scale) f0-7 f0-7 f0-7 1.0)) (set! (-> this timeout) (res-lump-float source-entity 'timeout :default 10.0)) (set! (-> this rot-dir) 1.0) - (set! (-> this reset-trans quad) (-> this basetrans quad)) + (vector-copy! (-> this reset-trans) (-> this basetrans)) (set! (-> this is-reset?) #t) (process-spawn orbit-plat-bottom (-> this entity) this :to this) (go orbit-plat-wait-for-other) diff --git a/goal_src/jak1/levels/sunken/puffer.gc b/goal_src/jak1/levels/sunken/puffer.gc index ff0a7c7236..bf2de0ecb3 100644 --- a/goal_src/jak1/levels/sunken/puffer.gc +++ b/goal_src/jak1/levels/sunken/puffer.gc @@ -117,7 +117,7 @@ (let ((s5-0 (new 'stack-no-clear 'collide-tri-result)) (a1-0 (new 'stack-no-clear 'vector)) (a2-0 (new 'stack-no-clear 'vector))) - (set! (-> a1-0 quad) (-> this root trans quad)) + (vector-copy! a1-0 (-> this root trans)) (set-vector! a2-0 0.0 -40960.0 0.0 1.0) (cond ((>= (fill-and-probe-using-line-sphere *collide-cache* @@ -221,7 +221,7 @@ (+! s3-1 -1) (eval-path-curve-div! (-> this path) s4-1 (the float s5-1) 'interp) (when (>= (vector-vector-xz-distance s4-1 (-> this root trans)) 10240.0) - (set! (-> this dest-pos quad) (-> s4-1 quad)) + (vector-copy! (-> this dest-pos) s4-1) (set! (-> this dest-pos y) (-> this root trans y)) (set! (-> this path-index) s5-1) (return #t)))))) diff --git a/goal_src/jak1/levels/sunken/qbert-plat.gc b/goal_src/jak1/levels/sunken/qbert-plat.gc index 907c90e7cb..5c61b0ae2f 100644 --- a/goal_src/jak1/levels/sunken/qbert-plat.gc +++ b/goal_src/jak1/levels/sunken/qbert-plat.gc @@ -107,9 +107,9 @@ (set! (-> self entity) source-entity) (logior! (-> self mask) (process-mask platform)) (set! (-> self root-overlay) (the-as collide-shape-moving (new 'process 'trsqv))) - (set! (-> self root-overlay trans quad) (-> parent-platform root-overlay trans quad)) + (vector-copy! (-> self root-overlay trans) (-> parent-platform root-overlay trans)) (quaternion-copy! (-> self root-overlay quat) (-> parent-platform root-overlay quat)) - (set! (-> self root-overlay scale quad) (-> parent-platform root-overlay scale quad)) + (vector-copy! (-> self root-overlay scale) (-> parent-platform root-overlay scale)) (initialize-skeleton self *qbert-plat-on-sg* '()) (logior! (-> self skel status) (janim-status inited)) (ja-channel-set! 1) @@ -230,7 +230,7 @@ "Initialize the skeleton and physics constants, place the four corner control points, and link the puzzle master." (initialize-skeleton this *qbert-plat-sg* '()) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) (logior! (-> this skel status) (janim-status inited)) (update-transforms! (-> this root-overlay)) (setup-from-constants! this *qbert-plat-constants*) diff --git a/goal_src/jak1/levels/sunken/square-platform.gc b/goal_src/jak1/levels/sunken/square-platform.gc index 95ef6f7f7d..b6a19c78ec 100644 --- a/goal_src/jak1/levels/sunken/square-platform.gc +++ b/goal_src/jak1/levels/sunken/square-platform.gc @@ -151,7 +151,7 @@ crosses the linked water surface." (local-vars (v0-3 sound-id)) (let ((probe-position (new 'stack-no-clear 'vector))) - (set! (-> probe-position quad) (-> this root trans quad)) + (vector-copy! probe-position (-> this root trans)) (+! (-> probe-position y) -20480.0) (let* ((water-entity (-> this water-entity)) (water-process (if water-entity (-> water-entity extra process)))) @@ -162,7 +162,7 @@ (when (the-as water-vol water-process) (let ((surface-y (get-ripple-height (the-as water-vol water-process) probe-position)) (surface-position (new 'stack-no-clear 'vector))) - (set! (-> surface-position quad) (-> probe-position quad)) + (vector-copy! surface-position probe-position) (set! (-> surface-position y) surface-y) (if (zero? (-> this start-splash-time)) (set! v0-3 @@ -321,12 +321,12 @@ (sv-32 (new 'static 'res-tag)) (v1-35 (res-lump-data (-> this entity) 'distance pointer :tag-ptr (& sv-32))) (f0-10 (if (and v1-35 (< 1 (the-as int (-> sv-32 elt-count)))) (-> (the-as (pointer float) v1-35) 1) 16384.0))) - (set! (-> this down-pos quad) (-> this root trans quad)) + (vector-copy! (-> this down-pos) (-> this root trans)) (+! (-> this down-pos y) f30-0) - (set! (-> this up-pos quad) (-> this root trans quad)) + (vector-copy! (-> this up-pos) (-> this root trans)) (+! (-> this up-pos y) f0-10)) - (set! (-> this basetrans quad) (-> this down-pos quad)) - (set! (-> this root trans quad) (-> this basetrans quad)) + (vector-copy! (-> this basetrans) (-> this down-pos)) + (vector-copy! (-> this root trans) (-> this basetrans)) (set! (-> this part2) (create-launch-control group-square-platform-breach-splash this)) (set! (-> this part3) (create-launch-control group-square-platform-submerge-bubbles this)) (set! (-> this part4) (create-launch-control group-square-platform-submerge-splash this)) diff --git a/goal_src/jak1/levels/sunken/steam-cap.gc b/goal_src/jak1/levels/sunken/steam-cap.gc index ae180a1d08..aaf3cee152 100644 --- a/goal_src/jak1/levels/sunken/steam-cap.gc +++ b/goal_src/jak1/levels/sunken/steam-cap.gc @@ -444,7 +444,7 @@ (when (< down-fraction 0.94) (spawn (-> this part2) (-> this down)) (let ((spread-position (new 'stack-no-clear 'vector))) - (set! (-> spread-position quad) (-> this root trans quad)) + (vector-copy! spread-position (-> this root trans)) (+! (-> spread-position y) -3072.0) (spawn (-> this part3) spread-position))))) (else @@ -455,7 +455,7 @@ (dotimes (control-index 3) (let ((control-point (-> this control-pt control-index)) (new-position (new 'stack-no-clear 'vector))) - (set! (-> new-position quad) (-> control-point trans quad)) + (vector-copy! new-position (-> control-point trans)) (cond (going-down? (+! (-> control-point transv y) (* -819200.0 (seconds-per-frame))) @@ -506,13 +506,13 @@ (when (< 40960.0 (fabs overshoot-velocity)) (if (>= overshoot-velocity 0.0) (set! (-> control-point transv y) 40960.0) (set! (-> control-point transv y) -40960.0)))) (set! (-> control-point transv y) (* 0.8 (-> control-point transv y)))))))) - (set! (-> control-point trans quad) (-> new-position quad)))) + (vector-copy! (-> control-point trans) new-position))) (let ((y-sum 0.0)) (dotimes (i 3) (+! y-sum (-> this control-pt i trans y))) (let ((average-y (/ y-sum 3)) (root-position (new 'stack-no-clear 'vector))) - (set! (-> root-position quad) (-> this root trans quad)) + (vector-copy! root-position (-> this root trans)) (set! (-> root-position y) average-y) (move-to-point! (-> this root) root-position))) (let ((edge0 (new 'stack-no-clear 'vector)) @@ -600,8 +600,8 @@ (set! travel-up-phase 0.9)))) (set! (-> this begin-travel-up) travel-up-phase) (set! (-> this begin-travel-down) travel-down-phase)) - (set! (-> this down quad) (-> this root trans quad)) - (set! (-> this up quad) (-> this root trans quad)) + (vector-copy! (-> this down) (-> this root trans)) + (vector-copy! (-> this up) (-> this root trans)) (+! (-> this up y) 40960.0) (set! (-> this part) (create-launch-control group-steam-cap-sides this)) (set! (-> this part2) (create-launch-control group-steam-cap-plume this)) diff --git a/goal_src/jak1/levels/sunken/sun-exit-chamber.gc b/goal_src/jak1/levels/sunken/sun-exit-chamber.gc index acc78f00c0..47da1f79ba 100644 --- a/goal_src/jak1/levels/sunken/sun-exit-chamber.gc +++ b/goal_src/jak1/levels/sunken/sun-exit-chamber.gc @@ -163,7 +163,7 @@ (defstate blue-eco-charger-orb-idle (blue-eco-charger-orb) :code (behavior () - (set! (-> self root trans quad) (-> self rest-pos quad)) + (vector-copy! (-> self root trans) (-> self rest-pos)) (loop (let ((f0-0 (-> self parent-process 0 open-level))) (if (< 0.0 f0-0) (go blue-eco-charger-orb-active))) (suspend))) @@ -232,11 +232,11 @@ "Initialize the orbiting blue-eco visual attached to parent-charger." (set! (-> self entity) source-entity) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> parent-charger root trans quad)) + (vector-copy! (-> self root trans) (-> parent-charger root trans)) (quaternion-copy! (-> self root quat) (-> parent-charger root quat)) - (set! (-> self root scale quad) (-> parent-charger root scale quad)) + (vector-copy! (-> self root scale) (-> parent-charger root scale)) (+! (-> self root trans y) 14069.76) - (set! (-> self rest-pos quad) (-> self root trans quad)) + (vector-copy! (-> self rest-pos) (-> self root trans)) (initialize-skeleton self *blue-eco-charger-orb-sg* '()) (ja-channel-set! 1) (ja :group! blue-eco-charger-orb-idle-ja :num! min) @@ -441,7 +441,7 @@ (let ((offset (new 'stack-no-clear 'vector))) (vector<-cspace! (-> this last-pos) (-> this node-list data 3)) (vector-! offset (-> this last-pos) (-> this root trans)) - (set! (-> this draw bounds quad) (-> offset quad))) + (vector-copy! (-> this draw bounds) offset)) (+! (-> this draw bounds y) 16384.0) (set! (-> this draw bounds w) 67584.0) (let ((items (new 'stack-no-clear 'exit-chamber-items))) @@ -450,7 +450,7 @@ (send-event (ppointer->process (-> this button)) 'move-to (-> items button-pos) (-> items button-quat))) (when (and *target* (-> this move-player?)) (let ((player-position (new 'stack-no-clear 'vector))) - (set! (-> player-position quad) (-> items button-pos quad)) + (vector-copy! player-position (-> items button-pos)) (+! (-> player-position y) 2662.4) (move-to-point! (-> *target* control) player-position)) (vector-reset! (-> *target* control transv))) @@ -597,7 +597,7 @@ (bob-on-waves! self (-> self wave-scale)) (if (and (-> self move-player?) (>= (ja-aframe-num 0) 310.0)) (set! (-> self move-player?) #f)) (let ((a0-36 (new 'stack-no-clear 'vector))) - (set! (-> a0-36 quad) (-> self last-pos quad)) + (vector-copy! a0-36 (-> self last-pos)) (+! (-> a0-36 y) 51814.4) (when (>= (-> a0-36 y) (ocean-get-height a0-36)) (if (not gp-2) (set! gp-2 #t)) @@ -718,7 +718,7 @@ (send-event (ppointer->process (-> self door)) 'untrigger)) (when (+ (current-time) (seconds -0.1)) (let ((a0-9 (new 'stack-no-clear 'vector))) - (set! (-> a0-9 quad) (-> self last-pos quad)) + (vector-copy! a0-9 (-> self last-pos)) (+! (-> a0-9 y) 64102.4) (when (< (-> a0-9 y) (+ 12288.0 (ocean-get-height a0-9))) (if (not s5-0) (set! s5-0 #t)))) @@ -833,8 +833,8 @@ #f this (the-as fact-info #f))))))) - (set! (-> this orig-trans quad) (-> this root trans quad)) - (set! (-> this last-pos quad) (-> this root trans quad)) + (vector-copy! (-> this orig-trans) (-> this root trans)) + (vector-copy! (-> this last-pos) (-> this root trans)) (set! (-> this move-player?) #f) (reposition-items! this #t) (set! (-> this move-player?) #f) diff --git a/goal_src/jak1/levels/sunken/sun-iris-door.gc b/goal_src/jak1/levels/sunken/sun-iris-door.gc index 3f623e15b2..bcf6aaa5c1 100644 --- a/goal_src/jak1/levels/sunken/sun-iris-door.gc +++ b/goal_src/jak1/levels/sunken/sun-iris-door.gc @@ -61,7 +61,7 @@ (('trigger) (go sun-iris-door-opening)) (('move-to) (set! (-> self move-to?) #t) - (set! (-> self move-to-pos quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self move-to-pos) (the-as vector (-> block param 0))) (quaternion-copy! (-> self move-to-quat) (the-as quaternion (-> block param 1)))))) :trans (behavior () @@ -87,7 +87,7 @@ (('untrigger) (go sun-iris-door-closing)) (('move-to) (set! (-> self move-to?) #t) - (set! (-> self move-to-pos quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self move-to-pos) (the-as vector (-> block param 0))) (quaternion-copy! (-> self move-to-quat) (the-as quaternion (-> block param 1)))))) :code (behavior () @@ -148,7 +148,7 @@ (('untrigger) (go sun-iris-door-closing)) (('move-to) (set! (-> self move-to?) #t) - (set! (-> self move-to-pos quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self move-to-pos) (the-as vector (-> block param 0))) (quaternion-copy! (-> self move-to-quat) (the-as quaternion (-> block param 1)))))) :enter (behavior () @@ -185,7 +185,7 @@ (('trigger) (go sun-iris-door-opening)) (('move-to) (set! (-> self move-to?) #t) - (set! (-> self move-to-pos quad) (-> (the-as vector (-> block param 0)) quad)) + (vector-copy! (-> self move-to-pos) (the-as vector (-> block param 0))) (quaternion-copy! (-> self move-to-quat) (the-as quaternion (-> block param 1)))))) :code (behavior () @@ -271,7 +271,7 @@ (set! (-> s3-0 nav-radius) (* 0.75 (-> s3-0 root-prim local-sphere w))) (backup-collide-with-as s3-0) (set! (-> self root) s3-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (quaternion-copy! (-> self root quat) orientation) (initialize-skeleton self *sun-iris-door-sg* '()) (set! (-> self close-dist) 49152.0) diff --git a/goal_src/jak1/levels/sunken/sunken-fish.gc b/goal_src/jak1/levels/sunken/sunken-fish.gc index ab5387bf91..43cd72af30 100644 --- a/goal_src/jak1/levels/sunken/sunken-fish.gc +++ b/goal_src/jak1/levels/sunken/sunken-fish.gc @@ -148,7 +148,7 @@ (let ((gp-0 (new 'stack-no-clear 'vector))) (evaluate-swim-position! self gp-0 (-> self path-u) (-> self local-path-offset)) (vector-! (-> self root transv) gp-0 (-> self root trans)) - (set! (-> self root trans quad) (-> gp-0 quad))) + (vector-copy! (-> self root trans) gp-0)) (let ((v1-16 (-> self root transv))) (.lvf vf1 (&-> (-> self root transv) quad)) (let ((f0-1 (-> *display* frames-per-second))) (.mov at-0 f0-1)) @@ -195,7 +195,7 @@ (rand-vu-float-range (- (-> this max-local-path-offset x)) (-> this max-local-path-offset x))) (set! (-> this local-path-offset y) (rand-vu-float-range (- (-> this max-local-path-offset y)) (-> this max-local-path-offset y))) - (set! (-> this targ-local-path-offset quad) (-> this local-path-offset quad)) + (vector-copy! (-> this targ-local-path-offset) (-> this local-path-offset)) (set! (-> this targ-local-path-offset x) (rand-vu-float-range (- (-> this max-local-path-offset x)) (-> this max-local-path-offset x))) (set! (-> this targ-local-path-offset y) diff --git a/goal_src/jak1/levels/sunken/sunken-pipegame.gc b/goal_src/jak1/levels/sunken/sunken-pipegame.gc index 7b34b7328d..51706a4769 100644 --- a/goal_src/jak1/levels/sunken/sunken-pipegame.gc +++ b/goal_src/jak1/levels/sunken/sunken-pipegame.gc @@ -531,7 +531,7 @@ (spawn (-> s5-5 blown-out-part) (-> s5-5 blown-out-far-part-pos)) (set! f28-1 (seek f28-1 20480.0 (* 81920.0 (seconds-per-frame)))) (let ((s4-0 (new 'stack-no-clear 'vector))) - (set! (-> s4-0 quad) (-> s5-5 jar-pos quad)) + (vector-copy! s4-0 (-> s5-5 jar-pos)) (let* ((f26-0 (-> s4-0 y)) (v1-65 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) (v1-66 (the-as number (logior #x3f800000 v1-65)))) @@ -558,7 +558,7 @@ (spawn (-> gp-1 sucked-up-part) (-> gp-1 sucked-up-jar-part-pos)) (spawn (-> gp-1 blown-out-part) (-> gp-1 blown-out-far-part-pos)) (let ((v1-96 (new 'stack-no-clear 'vector))) - (set! (-> v1-96 quad) (-> gp-1 far-pos quad)) + (vector-copy! v1-96 (-> gp-1 far-pos)) (+! (-> v1-96 y) f30-1) (let ((a1-32 (new 'stack-no-clear 'event-message-block))) (set! (-> a1-32 from) self) @@ -593,7 +593,7 @@ (spawn (-> gp-2 blown-out-part) (-> gp-2 blown-out-jar-part-pos)) (+! f30-2 (* 1024.0 (seconds-per-frame))) (let ((s5-7 (new 'stack-no-clear 'vector))) - (set! (-> s5-7 quad) (-> gp-2 far-pos quad)) + (vector-copy! s5-7 (-> gp-2 far-pos)) (let* ((f28-2 (-> s5-7 y)) (v1-146 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) (v1-147 (the-as number (logior #x3f800000 v1-146)))) @@ -614,7 +614,7 @@ (spawn (-> gp-3 blown-out-part) (-> gp-3 blown-out-jar-part-pos)) (set! f28-3 (seek f28-3 20480.0 (* 81920.0 (seconds-per-frame)))) (let ((s5-8 (new 'stack-no-clear 'vector))) - (set! (-> s5-8 quad) (-> gp-3 far-pos quad)) + (vector-copy! s5-8 (-> gp-3 far-pos)) (let* ((f26-1 (-> s5-8 y)) (v1-169 (/ (the-as int (rand-uint31-gen *random-generator*)) 256)) (v1-170 (the-as number (logior #x3f800000 v1-169)))) @@ -632,7 +632,7 @@ (set! (-> self abort-audio-if-beaten?) #f) (let ((v1-184 (-> self prize (-> self challenge))) (a0-109 (new 'stack-no-clear 'vector))) - (set! (-> a0-109 quad) (-> v1-184 jar-pos quad)) + (vector-copy! a0-109 (-> v1-184 jar-pos)) (+! (-> a0-109 y) 40960.0) (send-event (handle->process (-> v1-184 actor-handle)) 'trans a0-109)) (set-time! (-> self state-time)) @@ -756,11 +756,11 @@ (s1-1 (logtest? v1-17 (-> this challenges-mask)))) (eval-path-curve-div! (-> this path) (-> s0-0 jar-pos) (the float (* s2-0 2)) 'interp) (eval-path-curve-div! (-> this path) (-> s0-0 far-pos) (the float (+ (* s2-0 2) 1)) 'interp) - (set! (-> s0-0 sucked-up-jar-part-pos quad) (-> s0-0 jar-pos quad)) - (set! (-> s0-0 sucked-up-far-part-pos quad) (-> s0-0 far-pos quad)) - (set! (-> s0-0 blown-out-jar-part-pos quad) (-> s0-0 jar-pos quad)) + (vector-copy! (-> s0-0 sucked-up-jar-part-pos) (-> s0-0 jar-pos)) + (vector-copy! (-> s0-0 sucked-up-far-part-pos) (-> s0-0 far-pos)) + (vector-copy! (-> s0-0 blown-out-jar-part-pos) (-> s0-0 jar-pos)) (+! (-> s0-0 blown-out-jar-part-pos y) 24576.0) - (set! (-> s0-0 blown-out-far-part-pos quad) (-> s0-0 far-pos quad)) + (vector-copy! (-> s0-0 blown-out-far-part-pos) (-> s0-0 far-pos)) (+! (-> s0-0 blown-out-far-part-pos y) 28672.0) (let ((v1-30 s2-0)) (cond diff --git a/goal_src/jak1/levels/sunken/sunken-water.gc b/goal_src/jak1/levels/sunken/sunken-water.gc index 0d48ebb4d5..17332ddc4d 100644 --- a/goal_src/jak1/levels/sunken/sunken-water.gc +++ b/goal_src/jak1/levels/sunken/sunken-water.gc @@ -161,12 +161,12 @@ (set! (-> this play-ambient-sound?) #f) (cond ((logtest? (water-flag deadly) (-> this flag)) - (set! (-> this draw color-mult quad) (-> this deadly-color-mult quad)) - (set! (-> this draw color-emissive quad) (-> this deadly-color-emissive quad)) + (vector-copy! (-> this draw color-mult) (-> this deadly-color-mult)) + (vector-copy! (-> this draw color-emissive) (-> this deadly-color-emissive)) (set! (-> this deadly-fade) 1.0)) (else - (set! (-> this draw color-mult quad) (-> this safe-color-mult quad)) - (set! (-> this draw color-emissive quad) (-> this safe-color-emissive quad)) + (vector-copy! (-> this draw color-mult) (-> this safe-color-mult)) + (vector-copy! (-> this draw color-emissive) (-> this safe-color-emissive)) (set! (-> this deadly-fade) 0.0))) (let ((ripple (new 'process 'ripple-control))) (set! (-> this draw ripple) ripple) diff --git a/goal_src/jak1/levels/sunken/target-tube.gc b/goal_src/jak1/levels/sunken/target-tube.gc index 4afe16c5a7..107c7dacce 100644 --- a/goal_src/jak1/levels/sunken/target-tube.gc +++ b/goal_src/jak1/levels/sunken/target-tube.gc @@ -196,12 +196,12 @@ (vector+! s4-1 (vector-float*! s4-1 (-> self tube downtube) f2-5) (vector-float*! s2-1 s2-1 (/ f0-12 f1-2)))))) (vector-matrix*! s4-1 s4-1 (-> self control w-R-c)) (let ((f0-14 (-> self control transv-ctrl y))) - (set! (-> self control transv-ctrl quad) (-> s4-1 quad)) + (vector-copy! (-> self control transv-ctrl) s4-1) (set! (-> self control transv-ctrl y) f0-14)))) (let ((s4-2 (new 'stack-no-clear 'vector))) - (set! (-> s4-2 quad) (-> self tube downtube quad)) + (vector-copy! s4-2 (-> self tube downtube)) (let ((s3-1 (new 'stack-no-clear 'vector))) - (set! (-> s3-1 quad) (-> self tube sidetube quad)) + (vector-copy! s3-1 (-> self tube sidetube)) (vector-flatten! s3-1 s3-1 (-> self control local-normal)) (add-debug-vector *display-target-marks* (bucket-id debug-no-zbuf) @@ -268,7 +268,7 @@ (set-time-ratios *display* 1.0) (countdown (s5-0 gp-0) (set! (-> self control remaining-ctrl-iterations) s5-0) - (set! (-> self tube old-transv quad) (-> self control transv quad)) + (vector-copy! (-> self tube old-transv) (-> self control transv)) (flag-setup) (build-conversions (-> self control transv)) (if (logtest? (-> self state-flags) (state-flags timed-invulnerable)) @@ -376,7 +376,7 @@ (set! (-> self tube tube-sound-id) (new-sound-id)) (set! (-> self tube tube-sound-vol) 0.0) (target-collide-set! 'tube 0.0) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control ctrl-xz-vel) 0.0) (logior! (-> self control root-prim prim-core action) (collide-action tube)) (remove-exit) @@ -556,7 +556,7 @@ (set! (-> v1-30 shove-back) 6144.0) (set! (-> v1-30 shove-up) 12288.0) (set! (-> v1-30 angle) #f) - (set! (-> v1-30 trans quad) (-> self control trans quad)) + (vector-copy! (-> v1-30 trans) (-> self control trans)) (set! (-> v1-30 control) 0.0) (set! (-> v1-30 invinc-time) (-> *TARGET-bank* hit-invulnerable-timeout))) (combine! gp-0 arg1) @@ -604,7 +604,7 @@ (target-timed-invulnerable-off self) (add-setting! 'process-mask 'set 0.0 (process-mask enemy platform projectile death)) (apply-settings *setting-control*) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (set! (-> self control mod-surface) *neutral-mods*) (ja-channel-push! 1 (seconds 0.1)) (ja-no-eval :group! eichar-deatha-ja :num! (seek! (ja-aframe 134.0 0)) :frame-num 0.0) @@ -616,7 +616,7 @@ (vector-float*! (-> self control transv) gp-2 (-> *display* frames-per-second)))) (suspend) (ja :num! (seek! (ja-aframe 134.0 0)))) - (set! (-> self control transv quad) (the-as uint128 0)) + (vector-zero! (-> self control transv)) (initialize! (-> self game) 'dead (the-as game-save #f) (the-as string #f)) (set-time! (-> self state-time)) (until v1-40 @@ -669,9 +669,9 @@ (set! f30-0 f28-0)) (set! f28-0 (+ 0.01 f28-0))) (distance-from-tangent (-> self path) f30-0 s4-0 s5-0 gp-0 target-position) - (set! (-> self trans quad) (-> s4-0 quad)) - (set! (-> self rot quad) (-> s5-0 quad)) - (set! (-> self side quad) (-> gp-0 quad)) + (vector-copy! (-> self trans) s4-0) + (vector-copy! (-> self rot) s5-0) + (vector-copy! (-> self side) gp-0) (set! (-> self pos) f30-0))) (-> self pos)) @@ -701,9 +701,9 @@ (let* ((s4-0 proc) (gp-0 (if (and (nonzero? s4-0) (type-type? (-> s4-0 type) process-drawable)) s4-0))) (if gp-0 (find-target-point (-> (the-as process-drawable gp-0) root trans))) - (set! (-> (the-as vector (-> block param 0)) quad) (-> self trans quad)) - (set! (-> (the-as vector (-> block param 1)) quad) (-> self rot quad)) - (set! (-> (the-as vector (-> block param 2)) quad) (-> self side quad)) + (vector-copy! (the-as vector (-> block param 0)) (-> self trans)) + (vector-copy! (the-as vector (-> block param 1)) (-> self rot)) + (vector-copy! (the-as vector (-> block param 2)) (-> self side)) (eval-path-curve-div! (-> self path) (the-as vector (-> block param 3)) (+ 0.2 (-> self pos)) 'interp) (if (>= (-> self pos) (+ -0.2 (the float (+ (-> self path curve num-cverts) -1)))) (send-event gp-0 'end-mode))) (-> self pos)))) diff --git a/goal_src/jak1/levels/sunken/wedge-plats.gc b/goal_src/jak1/levels/sunken/wedge-plats.gc index c3adb1b931..1fbd6020e2 100644 --- a/goal_src/jak1/levels/sunken/wedge-plats.gc +++ b/goal_src/jak1/levels/sunken/wedge-plats.gc @@ -31,7 +31,7 @@ (defmethod init-from-entity! ((this wedge-plat-master) (source-entity entity-actor)) "Initialize the shared center and counter-rotating inner and outer platform angles." (logior! (-> this mask) (process-mask platform)) - (set! (-> this center quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this center) (-> source-entity extra trans)) (+! (-> this center y) 819.2) (set! (-> this rotspeed) (res-lump-float source-entity 'rotspeed)) (set! (-> this rotate-inner) 0.0) diff --git a/goal_src/jak1/levels/sunken/whirlpool.gc b/goal_src/jak1/levels/sunken/whirlpool.gc index 89a4878038..930a89068c 100644 --- a/goal_src/jak1/levels/sunken/whirlpool.gc +++ b/goal_src/jak1/levels/sunken/whirlpool.gc @@ -302,7 +302,7 @@ (let ((f30-0 (+ (* (get-current-phase-with-mirror (-> self sync)) (-> self spin-speed-delta)) (-> self spin-speed-idle)))) (when (>= (fabs f30-0) 45511.11) (let ((a1-0 (new 'stack-no-clear 'vector))) - (set! (-> a1-0 quad) (-> self root trans quad)) + (vector-copy! a1-0 (-> self root trans)) (+! (-> a1-0 y) -8192.0) (spawn (-> self part) a1-0))) (+! (-> self spin-ry) (* f30-0 (seconds-per-frame))) diff --git a/goal_src/jak1/levels/swamp/billy.gc b/goal_src/jak1/levels/swamp/billy.gc index 1e88ec7754..1c534c7f02 100644 --- a/goal_src/jak1/levels/swamp/billy.gc +++ b/goal_src/jak1/levels/swamp/billy.gc @@ -68,7 +68,7 @@ (defbehavior billy-snack-init-by-other billy-snack ((position vector)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (initialize-skeleton self *farthy-snack-sg* '()) (set! (-> self num-rats) 0) (go billy-snack-idle) @@ -167,7 +167,7 @@ (defbehavior billy-rat-init-by-other billy-rat ((game billy) (position vector) (destination vector)) (set! (-> self billy) (the-as (pointer billy) (process->ppointer game))) - (set! (-> self destination quad) (-> destination quad)) + (vector-copy! (-> self destination) destination) (set! (-> self dest-type) (the-as uint 1)) (let ((s4-0 (new 'stack-no-clear 'vector))) (vector-! s4-0 destination position) @@ -570,7 +570,7 @@ (set! (-> self offending-rat) (process->handle gp-0)) (set! (-> gp-0 dest-type) (the-as uint 3)) (let ((v0-1 (the-as object (-> gp-0 destination)))) - (set! (-> (the-as vector v0-1) quad) (-> (the-as billy-snack (-> gp-0 snack process 0)) root trans quad)) + (vector-copy! (the-as vector v0-1) (-> (the-as billy-snack (-> gp-0 snack process 0)) root trans)) v0-1)) ((or (= (-> gp-0 dest-type) 2) (= (-> gp-0 dest-type) 3) (<= (-> self num-snacks) 0)) (set! (-> gp-0 dest-type) (the-as uint 1)) @@ -597,7 +597,7 @@ (set! (-> gp-0 snack) (process->handle (the-as billy-snack s5-1))) (+! (-> (the-as billy-snack s5-1) num-rats) 1) (set! (-> gp-0 dest-type) (the-as uint 2)) - (set! (-> gp-0 destination quad) (-> (the-as billy-snack s5-1) root trans quad)) + (vector-copy! (-> gp-0 destination) (-> (the-as billy-snack s5-1) root trans)) (set! (-> gp-0 destination x) (+ 6799.36 (-> gp-0 destination x))))))))))))) :enter (behavior () diff --git a/goal_src/jak1/levels/swamp/kermit.gc b/goal_src/jak1/levels/swamp/kermit.gc index 773950d610..b18593f336 100644 --- a/goal_src/jak1/levels/swamp/kermit.gc +++ b/goal_src/jak1/levels/swamp/kermit.gc @@ -517,7 +517,7 @@ (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) (backup-collide-with-as s5-0) (set! (-> self root) s5-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (set! (-> self root quat vec quad) (-> self parent-override 0 collide-info quat vec quad)) (vector-identity! (-> self root scale)) (vector-reset! (-> self root transv)) @@ -606,7 +606,7 @@ (defun kermit-get-tongue-target-callback ((out vector)) "Copy the player's tongue target into out." - (set! (-> out quad) (-> (kermit-player-target-pos) quad)) + (vector-copy! out (kermit-player-target-pos)) out) (defbehavior kermit-check-tongue-is-clear? kermit () @@ -719,7 +719,7 @@ nav-enemy-default-event-handler #f #f) (nav-enemy-common-post)) - (else (set! (-> self collide-info transv quad) (-> *null-vector* quad)) (kermit-simple-post))) + (else (vector-copy! (-> self collide-info transv) *null-vector*) (kermit-simple-post))) (none)) (defbehavior kermit-get-new-patrol-point kermit () @@ -846,7 +846,7 @@ nav-enemy-default-event-handler (kermit-set-rotate-dir-to-player) (if (nav-enemy-test-point-in-nav-mesh? (target-pos 0)) (set-time! (-> self state-time))) (kermit-tongue-pos self) - (let ((v1-5 (kermit-player-target-pos))) (set! (-> self tongue-control target-pos quad) (-> v1-5 quad))) + (let ((v1-5 (kermit-player-target-pos))) (vector-copy! (-> self tongue-control target-pos) v1-5)) (when (not (-> self airborne)) (if (or (not *target*) (< (-> self enemy-info idle-distance) (vector-vector-distance (-> self collide-info trans) (-> *target* control trans)))) @@ -878,7 +878,7 @@ nav-enemy-default-event-handler kermit-lash-ja :num! (seek!) :frame-num 0.0 - (set! (-> self tongue-control target-pos quad) (-> (kermit-player-target-pos) quad)) + (vector-copy! (-> self tongue-control target-pos) (kermit-player-target-pos)) (when (and (not s5-0) (>= (ja-aframe-num 0) 14.0)) (set! s5-0 #t) (set! gp-0 (kermit-check-to-hit-player? 3640.889)) diff --git a/goal_src/jak1/levels/swamp/swamp-bat.gc b/goal_src/jak1/levels/swamp/swamp-bat.gc index 5d5186d437..90f951a548 100644 --- a/goal_src/jak1/levels/swamp/swamp-bat.gc +++ b/goal_src/jak1/levels/swamp/swamp-bat.gc @@ -20,7 +20,7 @@ (defmethod eval-point! ((this swamp-bat-idle-path) (out-position vector) (path-param float)) "Write the point at path-param around this elliptical idle path to out-position." (let ((angle (* 65536.0 path-param))) - (set! (-> out-position quad) (-> this origin quad)) + (vector-copy! out-position (-> this origin)) (vector+*! out-position out-position (-> this x-axis) (cos angle)) (vector+*! out-position out-position (-> this y-axis) (sin angle))) out-position) @@ -113,7 +113,7 @@ swamp-bat-slave-event-handler (defbehavior swamp-bat-slave-get-new-path swamp-bat-slave () (set! (-> self path-select) (-> self parent-process 0 path-select)) - (set! (-> self idle-path origin quad) (-> self parent-process 0 path-origin quad)) + (vector-copy! (-> self idle-path origin) (-> self parent-process 0 path-origin)) (let* ((f28-0 (-> self parent-process 0 idle-position-angle (-> self idle-position-index))) (f30-0 (cos f28-0)) (f26-0 (sin f28-0)) @@ -140,7 +140,7 @@ swamp-bat-slave-event-handler (ja-channel-push! 1 (seconds 0.165)) (ja :group! swamp-bat-idle-ja) (let ((s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> self root trans quad)) + (vector-copy! s5-0 (-> self root trans)) (let ((s4-0 (quaternion-copy! (new 'stack-no-clear 'quaternion) (-> self root quat))) (gp-0 (new-stack-quaternion0))) (let ((s2-0 (get-tangent-at-vertex! (-> self parent-process 0 path-list (-> self path-select)) (new 'stack-no-clear 'vector) 0.1))) @@ -164,7 +164,7 @@ swamp-bat-slave-event-handler (suspend) 0))) (label cfg-10) - (set! (-> self root trans quad) (-> self idle-position quad)) + (vector-copy! (-> self root trans) (-> self idle-position)) (quaternion-copy! (-> self root quat) gp-0))) (set! (-> self launch-ready) #t) (logior! (-> self mask) (process-mask actor-pause)) @@ -172,7 +172,7 @@ swamp-bat-slave-event-handler (loop (let ((f26-0 (cos f30-2)) (f28-0 (sin f30-2))) - (set! (-> self root trans quad) (-> self idle-path origin quad)) + (vector-copy! (-> self root trans) (-> self idle-path origin)) (vector+*! (-> self root trans) (-> self root trans) (-> self idle-path x-axis) f26-0) (vector+*! (-> self root trans) (-> self root trans) (-> self idle-path y-axis) f28-0)) (ja :num! (loop! (-> self idle-anim-speed))) @@ -296,7 +296,7 @@ swamp-bat-slave-event-handler (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w))) (backup-collide-with-as s4-0) (set! (-> self root) s4-0)) - (set! (-> self root trans quad) (-> arg0 root trans quad)) + (vector-copy! (-> self root trans) (-> arg0 root trans)) (set! (-> self root quat vec quad) (-> arg0 root quat vec quad)) (vector-float*! (-> self root scale) *identity-vector* 2.0) (set! (-> self root pause-adjust-distance) 286720.0) @@ -306,7 +306,7 @@ swamp-bat-slave-event-handler (set! (-> self strafe-envelope) 0.0) (set! (-> self idle-position-index) arg1) (swamp-bat-slave-get-new-path) - (set! (-> self root trans quad) (-> self idle-position quad)) + (vector-copy! (-> self root trans) (-> self idle-position)) (setup-params! (-> self sync) (the-as uint 1200) 0.0 0.15 0.15) (initialize-skeleton self *swamp-bat-slave-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) diff --git a/goal_src/jak1/levels/swamp/swamp-obs.gc b/goal_src/jak1/levels/swamp/swamp-obs.gc index 1e65017447..d4ca1022cb 100644 --- a/goal_src/jak1/levels/swamp/swamp-obs.gc +++ b/goal_src/jak1/levels/swamp/swamp-obs.gc @@ -566,7 +566,7 @@ (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) (backup-collide-with-as s5-0) (set! (-> self root) s5-0)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (initialize-skeleton self *swamp-rock-sg* '()) (nav-mesh-connect self (-> self root) (the-as nav-control #f)) (set! (-> self part) (create-launch-control group-swamp-rock-explosion self)) @@ -696,7 +696,7 @@ (set! (-> s3-0 local-pos z) (fmax (fmin (* f28-0 (cos f26-0)) f30-0) (- f30-0)))) (set! (-> s3-0 local-pos w) 1.0)))) (nav-mesh-connect this (-> this root-overlay) (the-as nav-control #f)) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) 0 (none)) diff --git a/goal_src/jak1/levels/swamp/swamp-rat-nest.gc b/goal_src/jak1/levels/swamp/swamp-rat-nest.gc index cae543feaa..539eecf99e 100644 --- a/goal_src/jak1/levels/swamp/swamp-rat-nest.gc +++ b/goal_src/jak1/levels/swamp/swamp-rat-nest.gc @@ -681,7 +681,7 @@ (logior! (-> self mask) (process-mask enemy)) (init-collision-and-skeleton! self) (process-drawable-from-entity! self gp-0) - (set! (-> self top-sphere quad) (-> self root trans quad)) + (vector-copy! (-> self top-sphere) (-> self root trans)) (+! (-> self top-sphere y) 24576.0) (set! (-> self top-sphere w) 18432.0) (set! (-> self entity) gp-0)) diff --git a/goal_src/jak1/levels/swamp/swamp-rat.gc b/goal_src/jak1/levels/swamp/swamp-rat.gc index 91ca241d4d..136bd2e7e6 100644 --- a/goal_src/jak1/levels/swamp/swamp-rat.gc +++ b/goal_src/jak1/levels/swamp/swamp-rat.gc @@ -74,7 +74,7 @@ swamp-rat-default-event-handler #f) (when (< (-> this collide-info trans y) (-> this min-height)) (let ((clamped-position (new 'stack-no-clear 'vector))) - (set! (-> clamped-position quad) (-> this collide-info trans quad)) + (vector-copy! clamped-position (-> this collide-info trans)) (set! (-> clamped-position y) (-> this min-height)) (move-to-ground-point! (-> this collide-info) clamped-position (-> this collide-info transv) *y-vector*))) 0 @@ -248,7 +248,7 @@ swamp-rat-default-event-handler (suspend)))) (label cfg-13) (if (< (-> self collide-info trans y) (-> self min-height)) (set! (-> self collide-info trans y) (-> self min-height))) - (set! (-> self collide-info transv quad) (-> *null-vector* quad)) + (vector-copy! (-> self collide-info transv) *null-vector*) (vector-float*! (-> self collide-info scale) *identity-vector* 1.5) (ja-play :group! swamp-rat-bounce-ja :num! (seek!) :frame-num 0.0) (if (target-in-range? self (-> self nav-info stop-chase-distance)) (go-virtual nav-enemy-chase) (go-virtual nav-enemy-idle))) @@ -345,14 +345,14 @@ swamp-rat-default-event-handler (set! (-> this water height) (res-lump-float (-> this entity) 'water-height)) (set! (-> this water ripple-size) 12288.0) (set! (-> this min-height) (+ -2048.0 (-> this water height))) - (set! (-> this up-vector quad) (-> *y-vector* quad)) + (vector-copy! (-> this up-vector) *y-vector*) 0 (none)) (defbehavior swamp-rat-init-by-other swamp-rat ((arg0 billy) (arg1 vector) (arg2 vector) (arg3 pickup-type) (arg4 symbol)) (initialize-collision self) (if arg4 (logclear! (-> self mask) (process-mask actor-pause)) (logior! (-> self mask) (process-mask actor-pause))) - (set! (-> self collide-info trans quad) (-> arg1 quad)) + (vector-copy! (-> self collide-info trans) arg1) (forward-up->quaternion (-> self collide-info quat) arg2 *up-vector*) (vector-float*! (-> self collide-info scale) *identity-vector* 1.5) (vector-float*! (-> self collide-info transv) arg2 49152.0) diff --git a/goal_src/jak1/levels/title/title-obs.gc b/goal_src/jak1/levels/title/title-obs.gc index efe8916eca..1b939b23b4 100644 --- a/goal_src/jak1/levels/title/title-obs.gc +++ b/goal_src/jak1/levels/title/title-obs.gc @@ -425,7 +425,7 @@ (logclear! (-> self mask) (process-mask progress)) (set! (-> self entity) entity-record) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (case mode (('logo) (set! (-> *time-of-day-context* title-light-group dir1 levels x) 0.0) @@ -667,7 +667,7 @@ (let ((font-context (new 'stack 'font-context *font-default-matrix* 80 170 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! font-context 352) (set-height! font-context 40) - (set! (-> font-context flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font-context (font-flags shadow kerning middle middle-vert large)) (print-game-text (lookup-text! *common-text* (text-id press-start) #f) font-context #f 128 22)))) :code anim-loop :post target-no-move-post) diff --git a/goal_src/jak1/levels/training/training-obs.gc b/goal_src/jak1/levels/training/training-obs.gc index b9263ce2de..142ab44eb7 100644 --- a/goal_src/jak1/levels/training/training-obs.gc +++ b/goal_src/jak1/levels/training/training-obs.gc @@ -145,7 +145,7 @@ "Initialize the hint trigger position, range, and hint index from its placed entity." (logior! (-> this mask) (process-mask actor-pause)) (set! (-> this root) (new 'process 'trsq)) - (set! (-> this root trans quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this root trans) (-> source-entity extra trans)) (quaternion-copy! (-> this root quat) (-> source-entity quat)) (vector-identity! (-> this root scale)) (set! (-> this range) (res-lump-float source-entity 'cam-notice-dist :default 81920.0)) @@ -253,7 +253,7 @@ (set! (-> v1-12 local-pos y) 0.0) (set! (-> v1-12 local-pos z) 12083.2) (set! (-> v1-12 local-pos w) 1.0)) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) (nav-mesh-connect this (-> this root-overlay) (the-as nav-control #f)) 0 (none)) @@ -548,7 +548,7 @@ (set! (-> s5-2 fountain-rand-transv-hi y) 81920.0) (set! (-> s5-2 fountain-rand-transv-hi z) 20480.0) (set! (-> s5-2 fountain-rand-transv-hi w) 49152.0) - (set! (-> s5-2 fountain-rand-transv-lo quad) (-> arg1 quad)) + (vector-copy! (-> s5-2 fountain-rand-transv-lo) arg1) (process-spawn joint-exploder *scarecrow-a-break-sg* 5 @@ -658,7 +658,7 @@ (set! (-> s5-2 fountain-rand-transv-hi y) 81920.0) (set! (-> s5-2 fountain-rand-transv-hi z) 40960.0) (set! (-> s5-2 fountain-rand-transv-hi w) 102400.0) - (set! (-> s5-2 fountain-rand-transv-lo quad) (-> arg1 quad)) + (vector-copy! (-> s5-2 fountain-rand-transv-lo) arg1) (process-spawn joint-exploder *scarecrow-b-break-sg* 5 diff --git a/goal_src/jak1/levels/village1/fishermans-boat.gc b/goal_src/jak1/levels/village1/fishermans-boat.gc index 393b32101d..ce41f053a4 100644 --- a/goal_src/jak1/levels/village1/fishermans-boat.gc +++ b/goal_src/jak1/levels/village1/fishermans-boat.gc @@ -58,7 +58,7 @@ (defmethod nth-point ((this vehicle-path) (index int) (result vector)) "Copy point index into result and return result." - (set! (-> result quad) (-> this point-array index quad)) + (vector-copy! result (-> this point-array index)) result) (defmethod distance-to-next-point ((this vehicle-path) (index int) (result vector)) @@ -89,8 +89,8 @@ (set! (-> s5-0 w) 1.0) (dotimes (s2-0 (-> this point-count)) (let ((v1-1 (mod (+ s2-0 1) (-> this point-count)))) - (set! (-> s4-0 quad) (-> this point-array s2-0 quad)) - (set! (-> s3-0 quad) (-> this point-array v1-1 quad))) + (vector-copy! s4-0 (-> this point-array s2-0)) + (vector-copy! s3-0 (-> this point-array v1-1))) (let ((f30-0 (-> s4-0 y)) (f28-0 (-> s4-0 w))) (set! (-> s5-0 x) (* f30-0 (cos f28-0))) @@ -233,7 +233,7 @@ (let ((s5-1 (new 'stack-no-clear 'vector))) (let ((s3-0 (new 'stack-no-clear 'vector))) (vector-! s3-0 (-> this path-dest-point) cur-pos) - (set! (-> s5-1 quad) (-> this path-dest-velocity quad)) + (vector-copy! s5-1 (-> this path-dest-velocity)) (set! (-> s5-1 x) (-> this path-dest-velocity z)) (set! (-> s5-1 z) (- (-> this path-dest-velocity x))) (vector-xz-normalize! s5-1 1.0) @@ -269,7 +269,7 @@ (let* ((f0-9 (sqrtf (- (square f30-0) (square f28-0)))) (f28-1 (/ (* f28-0 f0-9) f30-0))) (let ((f0-12 (/ (square f0-9) f30-0))) - (set! (-> arg1 quad) (-> arg0 quad)) + (vector-copy! arg1 arg0) (vector+*! arg1 (-> this target-point) s5-0 f0-12)) (vector+*! arg1 (-> this target-point) s3-0 f28-1)))) 0 @@ -280,7 +280,7 @@ (compute-target-point this (-> arg0 trans) (-> this target-point)) (let ((s3-0 (new 'stack-no-clear 'vector)) (s4-0 (new 'stack-no-clear 'vector))) - (set! (-> s3-0 quad) (-> this path-dest-velocity quad)) + (vector-copy! s3-0 (-> this path-dest-velocity)) (vector-xz-normalize! s3-0 1.0) (vector-! s4-0 (-> this path-dest-point) (-> arg0 trans)) (let ((f30-0 (vector-dot s3-0 s4-0))) @@ -318,7 +318,7 @@ (defmethod record-turning-sample! ((this vehicle-controller) (arg0 vector) (arg1 float) (arg2 int)) "Measure one speed sample's turn radius and store its radius and throttle." (let ((s3-0 (new 'stack-no-clear 'vector))) - (set! (-> s3-0 quad) (-> arg0 quad)) + (vector-copy! s3-0 arg0) (set! (-> s3-0 y) 0.0) (vector-xz-normalize! s3-0 1.0) (cond @@ -335,7 +335,7 @@ (else (set! (-> this sample-index) arg2) (set-time! (-> this sample-time)) - (set! (-> this sample-dir quad) (-> s3-0 quad))))) + (vector-copy! (-> this sample-dir) s3-0)))) 0 (none)) @@ -535,7 +535,7 @@ (defbehavior fishermans-boat-wave fishermans-boat ((arg0 vector) (arg1 float) (arg2 float)) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> arg0 quad)) + (vector-copy! gp-0 arg0) (set! (-> gp-0 y) (ocean-get-height arg0)) (set! (-> *part-id-table* 2896 init-specs 4 initial-valuef) (+ 24576.0 arg1)) (set! (-> *part-id-table* 2896 init-specs 19 initial-valuef) (+ 49152.0 arg1)) @@ -646,7 +646,7 @@ (let ((s5-1 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! s5-1 440) (set-height! s5-1 80) - (set! (-> s5-1 flags) (font-flags shadow kerning large)) + (set-flags! s5-1 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) s5-1 #f 128 22)) (when (and (cpad-pressed? 0 circle) (process-grab? *target*)) (set! (-> self waiting-for-player) #f) @@ -1000,7 +1000,7 @@ (if (= (-> *game-info* current-continue level) 'misty) (fishermans-boat-set-dock-point 4) (fishermans-boat-set-dock-point 0)) (fishermans-boat-set-path-point (-> this dock-point-index)) (fishermans-boat-next-path-point) - (set! (-> this root-overlay trans quad) (-> this dock-point quad)) + (vector-copy! (-> this root-overlay trans) (-> this dock-point)) (set! (-> this root-overlay trans y) 0.0) (forward-up-nopitch->quaternion (-> this root-overlay quat) (-> this dest-dir) *up-vector*) (setup-from-constants! this *fishermans-boat-constants*) @@ -1083,7 +1083,7 @@ (behavior () (set! (-> self propeller enable) #f) (quaternion-identity! (-> self root-overlay quat)) - (set! (-> self root-overlay trans quad) (-> self entity extra trans quad)) + (vector-copy! (-> self root-overlay trans) (-> self entity extra trans)) (set! (-> self player-riding) #f) (set! (-> self auto-pilot) #f) (when (send-event *target* 'clone-anim self) @@ -1163,7 +1163,7 @@ (set! (-> self evilbro) (the-as handle #f)) (set! (-> self evilsis) (the-as handle #f)) (quaternion-identity! (-> self root-overlay quat)) - (set! (-> self root-overlay trans quad) (-> self entity extra trans quad)) + (vector-copy! (-> self root-overlay trans) (-> self entity extra trans)) (set! (-> self player-riding) #f) (set! (-> self auto-pilot) #f) (when (send-event *target* 'clone-anim self) diff --git a/goal_src/jak1/levels/village1/village-obs.gc b/goal_src/jak1/levels/village1/village-obs.gc index ad1323b77f..1c8369d1c6 100644 --- a/goal_src/jak1/levels/village1/village-obs.gc +++ b/goal_src/jak1/levels/village1/village-obs.gc @@ -496,11 +496,11 @@ (initialize-skeleton this *reflector-middle-sg* '()) (logclear! (-> this mask) (process-mask actor-pause)) (set! (-> this link) (new 'process 'actor-link-info this)) - (set! (-> this reflector-trans quad) (-> this root trans quad)) + (vector-copy! (-> this reflector-trans) (-> this root trans)) (+! (-> this reflector-trans y) (res-lump-float source-entity 'height-info)) (let ((a0-10 (-> this link next))) (when a0-10 - (set! (-> this next-reflector-trans quad) (-> a0-10 extra trans quad)) + (vector-copy! (-> this next-reflector-trans) (-> a0-10 extra trans)) (+! (-> this next-reflector-trans y) (res-lump-float a0-10 'height-info)))) (logior! (-> this draw status) (draw-status do-not-check-distance)) (go reflector-middle-idle) @@ -655,7 +655,7 @@ "Initialize a spawned starfish from its parent and requested position." (initialize-collision self) (logior! (-> self mask) (process-mask actor-pause)) - (set! (-> self collide-info trans quad) (-> position quad)) + (vector-copy! (-> self collide-info trans) position) (quaternion-copy! (-> self collide-info quat) (-> parent collide-info quat)) (vector-identity! (-> self collide-info scale)) (set! (-> self entity) (-> parent entity)) diff --git a/goal_src/jak1/levels/village1/yakow.gc b/goal_src/jak1/levels/village1/yakow.gc index f0e6e8e5c2..fe8376cffb 100644 --- a/goal_src/jak1/levels/village1/yakow.gc +++ b/goal_src/jak1/levels/village1/yakow.gc @@ -199,7 +199,7 @@ yakow-default-event-handler (set! (-> self root transv z) (-> v1-24 z))) (vector-v++! (-> self root transv) (compute-acc-due-to-gravity (-> self root) (new-stack-vector0) 0.0)) (let ((gp-2 (new 'stack-no-clear 'vector))) - (set! (-> gp-2 quad) (-> self root trans quad)) + (vector-copy! gp-2 (-> self root trans)) (integrate-for-enemy-with-move-to-ground! (-> self root) (-> self root transv) (collide-kind background) @@ -231,7 +231,7 @@ yakow-default-event-handler (set! (-> gp-1 quad) (-> self nav travel quad)) (let ((f30-0 (vector-length gp-1))) (vector-normalize! gp-1 1.0) - (if (and (< 409.6 f30-0) (>= (vector-dot s5-1 gp-1) (cos 10922.667))) (set! (-> s5-1 quad) (-> gp-1 quad)))) + (if (and (< 409.6 f30-0) (>= (vector-dot s5-1 gp-1) (cos 10922.667))) (vector-copy! s5-1 gp-1))) (set! (-> self nav travel quad) (-> s5-1 quad)) (vector-normalize! (-> self nav travel) 409600.0) (clip-travel-to-mesh (-> self nav) 204.8 (the-as clip-travel-vector-to-mesh-return-info #f)) @@ -287,7 +287,7 @@ yakow-default-event-handler (defbehavior yakow-facing-direction? yakow ((arg0 vector) (arg1 float)) (let ((s4-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) (-> self root quat))) (s5-0 (new 'stack-no-clear 'vector))) - (set! (-> s5-0 quad) (-> arg0 quad)) + (vector-copy! s5-0 arg0) (set! (-> s5-0 y) 0.0) (vector-normalize! s5-0 1.0) (>= (vector-dot s4-0 s5-0) (cos arg1)))) diff --git a/goal_src/jak1/levels/village2/assistant-village2.gc b/goal_src/jak1/levels/village2/assistant-village2.gc index 0dd8bb4fa4..d7724e307d 100644 --- a/goal_src/jak1/levels/village2/assistant-village2.gc +++ b/goal_src/jak1/levels/village2/assistant-village2.gc @@ -955,7 +955,7 @@ (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'vector))) (let ((s4-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self boulder extra trans quad)) + (vector-copy! gp-0 (-> self boulder extra trans)) (let ((v1-3 (-> self boulder extra process))) (if v1-3 (vector<-cspace! gp-0 (-> (the-as fireboulder v1-3) node-list data 4)))) (set-vector! s5-0 -49152.0 10240.0 5529.6 1.0) @@ -1073,7 +1073,7 @@ (set-width! gp-0 448) (set-height! gp-0 80) (set-scale! gp-0 0.8) - (set! (-> gp-0 flags) (font-flags shadow kerning middle large)) + (set-flags! gp-0 (font-flags shadow kerning middle large)) (print-game-text (lookup-text! *common-text* (text-id village2-levitator-need-cells-text) #f) gp-0 #f 128 22))) (level-hint-spawn (text-id village2-levitator-need-cells) "asstvb71" (the-as entity #f) *entity-pool* (game-task none))))) diff --git a/goal_src/jak1/levels/village2/sunken-elevator.gc b/goal_src/jak1/levels/village2/sunken-elevator.gc index c1642f4d88..ee0bf4b612 100644 --- a/goal_src/jak1/levels/village2/sunken-elevator.gc +++ b/goal_src/jak1/levels/village2/sunken-elevator.gc @@ -101,7 +101,7 @@ (let ((s5-0 (new 'stack-no-clear 'vector)) (gp-0 (new 'stack-no-clear 'vector))) (set! *teleport* #t) - (set! (-> s5-0 quad) (-> self root trans quad)) + (vector-copy! s5-0 (-> self root trans)) (call-parent-state-handler trans) (vector-! gp-0 (-> self root trans) s5-0) (when (< (-> self path-pos) 0.9) diff --git a/goal_src/jak1/levels/village2/swamp-blimp.gc b/goal_src/jak1/levels/village2/swamp-blimp.gc index ee76f63648..a9bd5aaae0 100644 --- a/goal_src/jak1/levels/village2/swamp-blimp.gc +++ b/goal_src/jak1/levels/village2/swamp-blimp.gc @@ -370,8 +370,8 @@ "Initialize a damped vector oscillator at its target." (cond (initial-value - (set! (-> this target quad) (-> initial-value quad)) - (set! (-> this value quad) (-> initial-value quad))) + (vector-copy! (-> this target) initial-value) + (vector-copy! (-> this value) initial-value)) (else (vector-reset! (-> this target)) (vector-reset! (-> this value)))) (vector-reset! (-> this vel)) (set! (-> this accel) accel) @@ -528,7 +528,7 @@ (cam-slave-get-vector-with-offset (the-as entity-actor s5-1) *camera-other-trans* 'trans) (cam-slave-get-rot (the-as entity-actor s5-1) *camera-other-matrix*) (set! (-> *camera-other-fov* data) (cam-slave-get-fov s5-1))) - (set! (-> *camera-other-root* quad) (-> self root trans quad)) + (vector-copy! *camera-other-root* (-> self root trans)) (set-time! (-> self state-time)) (until (time-elapsed? (-> self state-time) (seconds 0.6)) (set! *camera-look-through-other* 2) @@ -577,7 +577,7 @@ (cam-slave-get-vector-with-offset (the-as entity-actor gp-1) *camera-other-trans* 'trans) (cam-slave-get-rot (the-as entity-actor gp-1) *camera-other-matrix*) (set! (-> *camera-other-fov* data) (cam-slave-get-fov gp-1))) - (set! (-> *camera-other-root* quad) (-> self root trans quad)) + (vector-copy! *camera-other-root* (-> self root trans)) (set-time! (-> self state-time)) (until (time-elapsed? (-> self state-time) (seconds 5)) (set! *camera-look-through-other* 2) @@ -753,7 +753,7 @@ (matrix->quaternion (-> self root quat) gp-0)) (when (< (vector-vector-distance (-> self root trans) (camera-pos)) 204800.0) (let ((a2-1 (new 'static 'vector))) - (set! (-> a2-1 quad) (-> self root trans quad)) + (vector-copy! a2-1 (-> self root trans)) (set! (-> a2-1 y) 0.0) (launch-particles :system *sp-particle-system-3d* (-> *part-id-table* 2017) a2-1)))) :code @@ -828,7 +828,7 @@ (let ((a0-0 (new 'stack-no-clear 'vector))) (vector-! a0-0 (-> self other-pos) (-> self root trans)) (vector-float*! a0-0 a0-0 0.5) - (set! (-> self draw bounds quad) (-> a0-0 quad)) + (vector-copy! (-> self draw bounds) a0-0) (set! (-> self draw bounds w) (vector-length a0-0))) 0 (none)) @@ -897,7 +897,7 @@ (ja-play :group! swamp-rope-swing-ja :num! (seek! max f30-3) :frame-num 0.0 (swamp-rope-break-code))))) :post (behavior () - (set! (-> self other-pos quad) (-> self root trans quad)) + (vector-copy! (-> self other-pos) (-> self root trans)) (+! (-> self other-pos y) -245760.0) (swamp-rope-post))) @@ -942,7 +942,7 @@ (a0-4 (if v1-6 (-> v1-6 extra process)))) (when a0-4 (set! (-> (the-as swamp-rope a0-4) parent-rp) (the-as int (-> self frame value))) - (set! (-> (the-as swamp-rope a0-4) frame vector-overlay quad) (-> self root trans quad)))) + (vector-copy! (-> (the-as swamp-rope a0-4) frame vector-overlay) (-> self root trans)))) (ja :num-func num-func-identity :frame-num (* (-> self frame value) (the float (ja-num-frames 0)))) (suspend))) :post swamp-rope-post) @@ -963,12 +963,12 @@ (defbehavior swamp-rope-init-by-other swamp-rope ((origin vector) (other-entity entity-actor)) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> origin quad)) + (vector-copy! (-> self root trans) origin) (initialize-skeleton self *swamp-rope-sg* '()) (logclear! (-> self mask) (process-mask actor-pause)) (set! (-> self other-entity) other-entity) (when (-> self other-entity) - (set! (-> self other-pos quad) (-> self other-entity extra trans quad)) + (vector-copy! (-> self other-pos) (-> self other-entity extra trans)) (let ((gp-1 (tetherrock-get-info (-> self other-entity)))) (init! (-> self frame) 0.0 0.002 0.02 (-> gp-1 damping)) (set! (-> self parent-rp) (-> gp-1 blimp-rp)) @@ -1138,7 +1138,7 @@ (initialize-skeleton this *swamp-blimp-sg* '()) (quaternion-copy! (-> this rot-at-init) (-> this root quat)) (set! (-> this arm-timer) 0) - (set! (-> this trans-at-init quad) (-> this root trans quad)) + (vector-copy! (-> this trans-at-init) (-> this root trans)) (set! (-> this y-vel) 0.0) (set! (-> this y-offset) 0.0) (set! (-> this y-offset-target) 0.0) diff --git a/goal_src/jak1/levels/village2/village2-obs.gc b/goal_src/jak1/levels/village2/village2-obs.gc index 4094396b98..3d41f1c298 100644 --- a/goal_src/jak1/levels/village2/village2-obs.gc +++ b/goal_src/jak1/levels/village2/village2-obs.gc @@ -260,7 +260,7 @@ (set! (-> v1-12 local-pos y) 0.0) (set! (-> v1-12 local-pos z) 12083.2) (set! (-> v1-12 local-pos w) 1.0)) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) (nav-mesh-connect this (-> this root-overlay) (the-as nav-control #f)) 0 (none)) @@ -313,7 +313,7 @@ (set! (-> v1-12 local-pos y) 0.0) (set! (-> v1-12 local-pos z) 10035.2) (set! (-> v1-12 local-pos w) 1.0)) - (set! (-> this anchor-point quad) (-> this root-overlay trans quad)) + (vector-copy! (-> this anchor-point) (-> this root-overlay trans)) (nav-mesh-connect this (-> this root-overlay) (the-as nav-control #f)) 0 (none)) @@ -485,7 +485,7 @@ (let ((v1-6 (-> (the-as (pointer part-tracker) (-> self tracker process)) 0))) (set-time! (-> v1-6 start-time)) (set! v0-1 (-> v1-6 root trans))) - (set! (-> (the-as vector v0-1) quad) (-> gp-0 quad))) + (vector-copy! (the-as vector v0-1) gp-0)) (else (let ((gp-1 (get-process *default-dead-pool* part-tracker #x4000))) (set! v0-1 @@ -504,7 +504,7 @@ (ja-channel-set! 1) (ja :group! fireboulder-hover-ja) (logclear! (-> self draw status) (draw-status hidden)) - (set! (-> self root trans quad) (-> self entity extra trans quad)) + (vector-copy! (-> self root trans) (-> self entity extra trans)) (vector-reset! (-> self draw origin)) (logior! (-> self skel status) (janim-status inited)) (ja-post) @@ -687,7 +687,7 @@ (suspend)) (when (and (not (task-complete? *game-info* (game-task sunken-room))) (not (-> self child))) (let ((a0-3 (new 'stack-no-clear 'vector))) - (set! (-> a0-3 quad) (-> self root trans quad)) + (vector-copy! a0-3 (-> self root trans)) (+! (-> a0-3 y) 67584.0) (let ((v1-12 (birth-pickup-at-point a0-3 (pickup-type fuel-cell) 47.0 #f self (the-as fact-info #f)))) (set! (-> self fcell-handle) (ppointer->handle v1-12)) @@ -706,7 +706,7 @@ (let ((a0-7 (handle->process (-> self fcell-handle)))) (when a0-7 (let ((v1-14 (new 'stack-no-clear 'vector))) - (set! (-> v1-14 quad) (-> self root trans quad)) + (vector-copy! v1-14 (-> self root trans)) (+! (-> v1-14 y) 67584.0) (send-event a0-7 'trans v1-14)))) (suspend))) @@ -722,7 +722,7 @@ (process-drawable-from-entity! this source-entity) (logclear! (-> this mask) (process-mask actor-pause)) (+! (-> this root trans y) 24576.0) - (set! (-> this orig-trans quad) (-> this root trans quad)) + (vector-copy! (-> this orig-trans) (-> this root trans)) (initialize-skeleton this *exit-chamber-dummy-sg* '()) (ja-channel-set! 1) (let ((s5-1 (-> this skel root-channel 0))) @@ -925,7 +925,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 82.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "boulder-splash") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-splash -1 #f #f #f gp-0 :to *entity-pool*)) @@ -938,7 +938,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 120.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "boulder-splash") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-splash -1 #f #f #f gp-0 :to *entity-pool*)) @@ -951,7 +951,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 82.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "v2ogre-boulder") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-hit-wall -1 #f #f #f gp-0 :to *entity-pool*)) @@ -964,7 +964,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 131.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "boulder-splash") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-splash -1 #f #f #f gp-0 :to *entity-pool*)) @@ -977,7 +977,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 80.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "v2ogre-boulder") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-hit-wall -1 #f #f #f gp-0 :to *entity-pool*)) @@ -990,7 +990,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 152.4) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "boulder-splash") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-splash -1 #f #f #f gp-0 :to *entity-pool*)) @@ -1003,7 +1003,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 116.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "v2ogre-boulder") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-hit-wall -1 #f #f #f gp-0 :to *entity-pool*)) @@ -1016,7 +1016,7 @@ (spawn (-> self part) (-> self draw origin)) (when (>= (ja-aframe-num 0) 74.0) (let ((gp-0 (new 'stack-no-clear 'vector))) - (set! (-> gp-0 quad) (-> self draw origin quad)) + (vector-copy! gp-0 (-> self draw origin)) (+! (-> gp-0 y) 2048.0) (sound-play "v2ogre-boulder") (process-spawn part-tracker :init part-tracker-init group-ogreboulder-hit-wall -1 #f #f #f gp-0 :to *entity-pool*)) diff --git a/goal_src/jak1/levels/village3/village3-obs.gc b/goal_src/jak1/levels/village3/village3-obs.gc index 28bbcb4e40..b69212a545 100644 --- a/goal_src/jak1/levels/village3/village3-obs.gc +++ b/goal_src/jak1/levels/village3/village3-obs.gc @@ -183,7 +183,7 @@ (let ((s5-2 (new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning)))) (set-width! s5-2 440) (set-height! s5-2 80) - (set! (-> s5-2 flags) (font-flags shadow kerning large)) + (set-flags! s5-2 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) s5-2 #f 128 22)) (when (and (cpad-pressed? 0 circle) (process-grab? *target*)) (if arg0 (go-virtual ride-down) (go-virtual ride-up)))))))) diff --git a/goal_src/jak1/levels/village_common/villagep-obs.gc b/goal_src/jak1/levels/village_common/villagep-obs.gc index 5ce0fb6eb3..210899cfd5 100644 --- a/goal_src/jak1/levels/village_common/villagep-obs.gc +++ b/goal_src/jak1/levels/village_common/villagep-obs.gc @@ -102,7 +102,7 @@ (set-width! prompt-context 440) (set-height! prompt-context 80) (set-scale! prompt-context 0.9) - (set! (-> prompt-context flags) (font-flags shadow kerning large)) + (set-flags! prompt-context (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id press-to-use) #f) prompt-context #f 128 22)))) (suspend)))) @@ -135,7 +135,7 @@ context (the int (* 128.0 intensity)))) (set! (-> context origin x) (- (-> context origin x) (the float signed-offset)))) - (set! (-> context color) (font-color default)) + (set-color! context (font-color default)) context) ;; Hold Jak facing the gate while the destination carousel is open. The centred entry commits @@ -204,11 +204,11 @@ (set-scale! menu-context 0.7) (set-width! menu-context 500) (set-height! menu-context 55) - (set! (-> menu-context flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! menu-context (font-flags shadow kerning middle middle-vert large)) (print-game-text (lookup-text! *common-text* (text-id warp-gate-use-dpad) #f) menu-context #f 128 22) (+! (-> menu-context origin y) 35.0) (set-height! menu-context 40) - (let ((blue-context menu-context)) (set! (-> blue-context color) (font-color progress-blue))) + (set-color! menu-context (font-color progress-blue)) 0 (let* ((next-slot (get-next-slot-up self selected-slot)) (previous-slot (get-next-slot-down self selected-slot)) @@ -235,7 +235,7 @@ (let ((outgoing-next-distance (- 300 (+ scroll-distance 150)))) (print-level-name next-slot menu-context outgoing-next-distance (the-as int #t)))))) (when (not scrolling?) - (let ((selected-context menu-context)) (set! (-> selected-context color) (font-color progress-yellow)))) + (set-color! menu-context (font-color progress-yellow))) (print-level-name selected-slot menu-context scroll-distance (the-as int scrolling-left?)) (+! (-> menu-context origin y) 20.0) (print-game-text (lookup-text! *common-text* (text-id press-to-warp) #f) menu-context #f 128 22) @@ -252,7 +252,7 @@ destinations only through the furthest unlocked village gate." (stack-size-set! (-> self main-thread) 512) (set! (-> self root) (new 'process 'trsqv)) - (set! (-> self root trans quad) (-> position quad)) + (vector-copy! (-> self root trans) position) (logior! (-> self mask) (process-mask actor-pause)) (set! (-> self level) (-> self entity extra level name)) (set! (-> self min-slot) 0) @@ -678,7 +678,7 @@ process pause with actors, and enter the hint-camera state." (logior! (-> this mask) (process-mask actor-pause)) (set! (-> this root-override) (new 'process 'trsq)) - (set! (-> this root-override trans quad) (-> source-entity extra trans quad)) + (vector-copy! (-> this root-override trans) (-> source-entity extra trans)) (quaternion-copy! (-> this root-override quat) (-> source-entity quat)) (vector-identity! (-> this root-override scale)) (set! (-> this range) (res-lump-float source-entity 'cam-notice-dist :default 81920.0)) diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index 4d66265a54..93726be738 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -1409,7 +1409,7 @@ (let ((f30-0 (- 1.0 (* 0.0033333334 (the float arg2))))) (print-game-text-scaled (lookup-text! *common-text* arg0 #f) f30-0 arg1 (the int (* 128.0 f30-0)))) (set! (-> arg1 origin x) (- (-> arg1 origin x) (the float s5-0)))) - (set! (-> arg1 color) (font-color default)) + (set-color! arg1 (font-color default)) arg1) (defun progress-draw-carousell-from-string-list ((options (array text-id)) (font font-context) (y-off int) (new-val int)) @@ -1904,42 +1904,28 @@ (let ((f30-0 (+ -409.0 (-> this particles 2 init-pos x) (* 0.8 (the float (-> this left-x-offset))))) (s5-0 (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 0 (-> this transition-offset)))) (let ((f28-0 (if (or (-> this stat-transition) (nonzero? (-> this level-transition))) 1.0 (-> this transition-percentage-invert)))) - (let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s4-0 (-> s3-0 base))) - (let ((s2-0 draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game money)))) - (s2-0 *temp-string* - s3-0 - (the int (+ *PC-ORB-TEXT-X-ADJUST* 428.0 (the float s5-0) f30-0)) - (- 12 (the int (* 0.16666667 f30-0))) - (font-color default) - (font-flags shadow kerning large))) - (let ((s2-1 draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game fuel)))) - (s2-1 *temp-string* - s3-0 - (the int (+ *PC-CELL-TEXT-X-ADJUST* 456.0 (the float (adjust-pos s5-0 50)) f30-0)) - (- 48 (the int (* 0.125 f30-0))) - (font-color default) - (font-flags shadow kerning large))) - (let ((s2-2 draw-string-xy)) - (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* fact buzzer)))) - (s2-2 *temp-string* - s3-0 - (the int (+ *PC-BUZZER-TEXT-X-ADJUST* 469.0 (the float (adjust-pos s5-0 100)) f30-0)) - 89 - (font-color default) - (font-flags shadow kerning large))) - (let ((a3-4 (-> s3-0 base))) - (let ((v1-20 (the-as object (-> s3-0 base)))) - (set! (-> (the-as dma-packet v1-20) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-20) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-20) vif1) (new 'static 'vif-tag)) - (set! (-> s3-0 base) (&+ (the-as pointer v1-20) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - s4-0 - (the-as (pointer dma-tag) a3-4)))) + (with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (let ((s2-0 draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game money)))) + (s2-0 *temp-string* + s3-0 + (the int (+ *PC-ORB-TEXT-X-ADJUST* 428.0 (the float s5-0) f30-0)) + (- 12 (the int (* 0.16666667 f30-0))) + (font-color default) + (font-flags shadow kerning large))) (let ((s2-1 draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* game fuel)))) + (s2-1 *temp-string* + s3-0 + (the int (+ *PC-CELL-TEXT-X-ADJUST* 456.0 (the float (adjust-pos s5-0 50)) f30-0)) + (- 48 (the int (* 0.125 f30-0))) + (font-color default) + (font-flags shadow kerning large))) (let ((s2-2 draw-string-xy)) + (format (clear *temp-string*) "~D" (the int (+ 0.5 (-> *target* fact buzzer)))) + (s2-2 *temp-string* + s3-0 + (the int (+ *PC-BUZZER-TEXT-X-ADJUST* 469.0 (the float (adjust-pos s5-0 100)) f30-0)) + 89 + (font-color default) + (font-flags shadow kerning large)))) (let ((s4-2 (new 'stack 'font-context *font-default-matrix* @@ -1955,18 +1941,18 @@ (let ((v1-29 s4-2)) (set! (-> v1-29 width) (the float 100))) (let ((v1-30 s4-2)) (set! (-> v1-30 height) (the float 15))) (let ((v1-31 s4-2)) (set! (-> v1-31 scale) 0.5)) - (set! (-> s4-2 flags) (font-flags shadow kerning large)) + (set-flags! s4-2 (font-flags shadow kerning large)) (print-game-text (lookup-text! *common-text* (text-id options) #f) s4-2 #f 128 22) (let ((v1-34 s4-2)) (set! (-> v1-34 width) (the float 160))) (let ((v1-35 s4-2)) (set! (-> v1-35 height) (the float 22))) (let ((v1-36 s4-2)) (set! (-> v1-36 scale) 1.3)) - (let ((a0-31 s4-2)) (set! (-> a0-31 color) (font-color progress-percent))) + (set-color! s4-2 (font-color progress-percent)) (set! (-> s4-2 origin x) (+ *PC-PERCENT-X-ADJUST* (- 435.0 (the float (if (< (-> *progress-process* 0 completion-percentage) 10.0) 93 80))) f30-0)) (set! (-> s4-2 origin y) 180.0) - (set! (-> s4-2 flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! s4-2 (font-flags shadow kerning middle middle-vert large)) (let ((s3-3 print-game-text)) (format (clear *temp-string*) "~2D%" (the int (-> *progress-process* 0 completion-percentage))) (s3-3 *temp-string* s4-2 #f (the int (* 128.0 f28-0)) 22)))) @@ -1995,24 +1981,12 @@ (when *cheat-mode* (let ((a0-46 "AUTO SAVE OFF")) (if (-> *setting-control* current auto-save) (set! a0-46 "AUTO SAVE ON")) - (let* ((s3-5 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s4-4 (-> s3-5 base))) - (draw-string-xy a0-46 - s3-5 - (the int (+ *PC-AUTOSAVE-X-ADJUST* 430.0 f30-0)) - 200 - (font-color progress-memcard) - (font-flags shadow kerning middle)) - (let ((a3-9 (-> s3-5 base))) - (let ((v1-81 (the-as object (-> s3-5 base)))) - (set! (-> (the-as dma-packet v1-81) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-81) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-81) vif1) (new 'static 'vif-tag)) - (set! (-> s3-5 base) (&+ (the-as pointer v1-81) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id debug) - s4-4 - (the-as (pointer dma-tag) a3-9)))))) + (with-dma-buffer-add-bucket ((s3-5 (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id debug)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (draw-string-xy a0-46 + s3-5 + (the int (+ *PC-AUTOSAVE-X-ADJUST* 430.0 f30-0)) + 200 + (font-color progress-memcard) + (font-flags shadow kerning middle))))) (let ((a0-52 (-> this icons 5 icon 0 root))) (set-yaw-angle-clear-roll-pitch! a0-52 (- (y-angle a0-52) (* 182.04445 (* 4.0 (-> *display* time-adjust-ratio)))))) (let* ((f28-2 (* 0.00024414062 (the float (-> *progress-process* 0 in-out-position)))) @@ -2973,7 +2947,7 @@ ;; set the common params for the text drawing (set-width! font 370) (set-height! font 25) - (set! (-> font flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! font (font-flags shadow kerning middle middle-vert large)) ;; set scroll arrow sprite vertical position right now (set! (-> obj particles 32 init-pos y) (the float (* 2 (- y-off 20)))) ;; when scrolling we draw an extra line @@ -3544,7 +3518,7 @@ (font-flags shadow kerning)))) (set-width! s5-1 328) (set-height! s5-1 45) - (set! (-> s5-1 flags) (font-flags shadow kerning middle middle-vert large)) + (set-flags! s5-1 (font-flags shadow kerning middle middle-vert large)) (print-game-text-scaled (lookup-text! *common-text* (-> gp-0 level-name-id) #f) f30-0 s5-1 (the int (* 128.0 f30-0)))))) (case (-> self display-state) (((progress-screen fuel-cell) (progress-screen money) (progress-screen buzzer)) (draw-progress self))) diff --git a/goal_src/jak1/pc/subtitle.gc b/goal_src/jak1/pc/subtitle.gc index c5aef895a0..bdb492b72c 100644 --- a/goal_src/jak1/pc/subtitle.gc +++ b/goal_src/jak1/pc/subtitle.gc @@ -344,22 +344,7 @@ 0) (if (nonzero? (-> *game-text-line* data 0)) (set! sv-168 (+ sv-168 1))) (when (not no-draw) - (let* ((s1-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) - (s2-1 (-> s1-1 base))) - (set-font-color-alpha (-> font-ctxt color) alpha) - (draw-string *game-text-line* s1-1 gp-0) - (set-font-color-alpha (-> font-ctxt color) 128) - (set! (-> gp-0 color) (-> *font-work* last-color)) - (let ((a3-3 (-> s1-1 base))) - (let ((v1-127 (the-as object (-> s1-1 base)))) - (set! (-> (the-as dma-packet v1-127) dma) (new 'static 'dma-tag :id (dma-tag-id next))) - (set! (-> (the-as dma-packet v1-127) vif0) (new 'static 'vif-tag)) - (set! (-> (the-as dma-packet v1-127) vif1) (new 'static 'vif-tag)) - (set! (-> s1-1 base) (&+ (the-as pointer v1-127) 16))) - (dma-bucket-insert-tag (-> *display* frames (-> *display* on-screen) frame bucket-group) - (bucket-id subtitle) - s2-1 - (the-as (pointer dma-tag) a3-3))))) + (with-dma-buffer-add-bucket ((s1-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) (bucket-id subtitle)) :bucket-group (-> *display* frames (-> *display* on-screen) frame bucket-group) (set-font-color-alpha (-> font-ctxt color) alpha) (draw-string *game-text-line* s1-1 gp-0) (set-font-color-alpha (-> font-ctxt color) 128) (set! (-> gp-0 color) (-> *font-work* last-color)))) (set! (-> gp-0 origin y) f30-2))) (set! sv-200 (+ sv-200 1)) (set! (-> *game-text-line* data 0) (the-as uint 0)) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 991fb4132b..1fa4b4a21c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(goalc-test ${CMAKE_CURRENT_LIST_DIR}/test_math.cpp ${CMAKE_CURRENT_LIST_DIR}/test_zstd.cpp ${CMAKE_CURRENT_LIST_DIR}/test_zydis.cpp + ${CMAKE_CURRENT_LIST_DIR}/common/test_demacro.cpp ${CMAKE_CURRENT_LIST_DIR}/decompiler/FormRegressionTest.cpp ${CMAKE_CURRENT_LIST_DIR}/decompiler/test_AtomicOpBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/decompiler/test_FormBeforeExpressions.cpp diff --git a/test/common/test_demacro.cpp b/test/common/test_demacro.cpp new file mode 100644 index 0000000000..2b29412abb --- /dev/null +++ b/test/common/test_demacro.cpp @@ -0,0 +1,256 @@ +#include "common/demacro/demacro.h" + +#include "gtest/gtest.h" + +TEST(Demacro, CapturesAndSequences) { + const auto rules = demacro::parse_rules(R"RULES( + { + "rules": [ + { + "name": "two-sets", + "match": [ + "(set! (-> $dst x) (-> $src x))", + "(set! (-> $dst y) (-> $src y))" + ], + "rewrite": "(copy-xy! $dst $src)" + } + ] + } + )RULES"); + const std::string source = R"((defun test ((a foo) (b foo)) + (set! (-> a x) (-> b x)) + (set! (-> a y) (-> b y)) + a) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 1); + EXPECT_EQ(result.source, R"((defun test ((a foo) (b foo)) + (copy-xy! a b) + a) +)"); +} + +TEST(Demacro, RestCapturesHandleMergedLets) { + const auto rules = demacro::parse_rules(R"RULES( + { + "rules": [ + { + "name": "merged-let", + "match": "(let ($*before ($temp $value) $*after) $*body-before (use $temp) $*body-after)", + "rewrite": "(let ($*before $*after) $*body-before (use-macro $value) $*body-after)" + } + ] + } + )RULES"); + const auto result = demacro::rewrite( + "(let ((keep value) (temp (compute)) (later other)) (first keep) (use temp) (last later))", + rules); + EXPECT_EQ(result.rewrite_count(), 1); + EXPECT_EQ(result.source, + "(let ((keep value) (later other)) (first keep) (use-macro (compute)) (last later))"); +} + +TEST(Demacro, PreservesCommentsInsideReplacementRange) { + const auto rules = demacro::parse_rules(R"RULES( + { + "rules": [ + { + "name": "two-sets", + "match": ["(set! $dst 1)", "(set! $dst 2)"], + "rewrite": "(set-twice! $dst)" + } + ] + } + )RULES"); + const std::string source = R"((begin + (set! value 1) + ;; Keep this explanation. + (set! value 2)) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 1); + EXPECT_EQ(result.source, R"((begin + ;; Keep this explanation. + (set-twice! value)) +)"); +} + +TEST(Demacro, RepeatedCapturesMustAgree) { + const auto rules = demacro::parse_rules(R"RULES( + { + "rules": [ + { + "name": "two-sets", + "match": ["(set! $dst 1)", "(set! $dst 2)"], + "rewrite": "(set-twice! $dst)" + } + ] + } + )RULES"); + const auto result = demacro::rewrite("(begin (set! a 1) (set! b 2))", rules); + EXPECT_EQ(result.rewrite_count(), 0); +} + +TEST(Demacro, ExpandsPatternTables) { + const auto rules = demacro::parse_rules(R"RULES( + { + "tables": { + "kind": [ + {"value": "0", "symbol": "first"}, + {"value": "1", "symbol": "second"} + ] + }, + "rules": [ + { + "name": "kind-{{symbol}}", + "for_each": "kind", + "match": "(expanded-kind {{value}})", + "rewrite": "(kind {{symbol}})" + } + ] + } + )RULES"); + const auto result = + demacro::rewrite("(begin (expanded-kind 0) (expanded-kind 1))", rules); + EXPECT_EQ(result.rewrite_count(), 2); + EXPECT_EQ(result.source, "(begin (kind first) (kind second))"); +} + +TEST(Demacro, Jak1PreservesMemUsageNameSemantics) { + const auto rules = demacro::load_rules( + file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"})); + const std::string source = R"((begin + (set! (-> usage length) (max 1 (-> usage length))) + (set! (-> usage data 0 name) "drawable-group") + (+! (-> usage data 0 count) 2) + (let ((literal-bytes 32)) + (+! (-> usage data 0 used) literal-bytes) + (+! (-> usage data 0 total) (logand -16 (+ literal-bytes 15)))) + (set! (-> other length) (max 1 (-> other length))) + (set! (-> other data 0 name) (symbol->string 'drawable-group)) + (+! (-> other data 0 count) 3) + (let ((symbol-bytes 48)) + (+! (-> other data 0 used) symbol-bytes) + (+! (-> other data 0 total) (logand -16 (+ symbol-bytes 15))))) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 2); + EXPECT_EQ(result.source, R"((begin + (mem-usage-add! usage drawable-group 2 32) + (mem-usage-add-symbol! other drawable-group 3 48)) +)"); +} + +TEST(Demacro, Jak1RecognizesCachedEngineIteration) { + const auto rules = demacro::load_rules( + file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"})); + const std::string source = R"((let ((node (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((next-node (-> node next0))) + (while (!= node (-> *collide-player-list* alive-list-end)) + ;; Body comments must survive the collapsed traversal. + (visit (-> (the-as connection node) param1)) + (set! node next-node) + *collide-player-list* + (set! next-node (-> next-node next0))))) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 1); + EXPECT_EQ(result.source, R"(;; Body comments must survive the collapsed traversal. +(iterate-engine-connections (node *collide-player-list*) (visit (-> (the-as connection node) param1))) +)"); +} + +TEST(Demacro, Jak1RecognizesMergedCachedEngineIterations) { + const auto rules = demacro::load_rules( + file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"})); + const std::string source = R"((begin + (let ((node (-> first-engine alive-list next0))) + first-engine + (let ((next-node (-> node next0))) + (while (!= node (-> first-engine alive-list-end)) + (visit-first node) + (set! node next-node) + first-engine + (set! next-node (-> next-node next0))) + (set! node (-> second-engine alive-list next0)) + second-engine + (set! next-node (-> node next0)) + (while (!= node (-> second-engine alive-list-end)) + (visit-second node) + (set! node next-node) + second-engine + (set! next-node (-> next-node next0))))) + (set! node (-> assigned-engine alive-list next0)) + assigned-engine + (set! next-node (-> node next0)) + (while (!= node (-> assigned-engine alive-list-end)) + (visit-assigned node) + (set! node next-node) + assigned-engine + (set! next-node (-> next-node next0))) + (let ((keep value) + (node (-> bound-engine alive-list next0))) + bound-engine + (let ((next-node (-> node next0))) + (while (!= node (-> bound-engine alive-list-end)) + (visit-bound node) + (set! node next-node) + bound-engine + (set! next-node (-> next-node next0)))))) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 4); + EXPECT_EQ(result.source, R"((begin + (iterate-engine-connections (node first-engine) (visit-first node)) + (iterate-engine-connections (node second-engine) (visit-second node)) + (iterate-engine-connections (node assigned-engine) (visit-assigned node)) + (let ((keep value)) (iterate-engine-connections (node bound-engine) (visit-bound node)))) +)"); +} + +TEST(Demacro, Jak1RecognizesDmaBucketConstruction) { + const auto rules = demacro::load_rules( + file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"})); + const std::string source = R"((let* ((buf (-> (current-frame) debug-buf)) + (start (-> buf base))) + ;; Keep the packet-building body. + (emit-packet buf) + (let ((edge (-> buf base))) + (let ((packet (the-as dma-packet (-> buf base)))) + (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> packet vif0) (new 'static 'vif-tag)) + (set! (-> packet vif1) (new 'static 'vif-tag)) + (set! (-> buf base) (&+ (the-as pointer packet) 16))) + (dma-bucket-insert-tag buckets bucket start (the-as (pointer dma-tag) edge)))) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 1); + EXPECT_EQ(result.source, R"(;; Keep the packet-building body. +(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) bucket) :bucket-group buckets (emit-packet buf)) +)"); +} + +TEST(Demacro, Jak1RecognizesInlinedFontEnumSetters) { + const auto rules = demacro::load_rules( + file_util::get_file_path({"decompiler/config/jak1/demacro.jsonc"})); + const std::string source = R"((begin + (set! (-> font flags) (font-flags shadow kerning large)) + ;; Keep the color choice with its reconstructed call. + (let ((selected-font font)) + (set! (-> selected-font color) (font-color progress-selected))) + (let ((option-font font)) + (set! (-> option-font color) + (if selected? (font-color progress-selected) (font-color default)))) + (set! (-> water flags) (water-flag active))) +)"; + const auto result = demacro::rewrite(source, rules); + EXPECT_EQ(result.rewrite_count(), 3); + EXPECT_EQ(result.source, R"((begin + (set-flags! font (font-flags shadow kerning large)) + ;; Keep the color choice with its reconstructed call. + (set-color! font (font-color progress-selected)) + (set-color! font (if selected? (font-color progress-selected) (font-color default))) + (set! (-> water flags) (water-flag active))) +)"); +} diff --git a/test/test_type_system.cpp b/test/test_type_system.cpp index 7a6541b9da..102467dbae 100644 --- a/test/test_type_system.cpp +++ b/test/test_type_system.cpp @@ -41,6 +41,34 @@ TEST(TypeSystem, DefaultMethods) { ts.assert_method_id("function", "mem-usage", GOAL_MEMUSAGE_METHOD); } +TEST(TypeSystem, Jak1MemUsageFlags) { + TypeSystem jak1; + jak1.add_builtin_types(GameVersion::Jak1); + + auto* flags = jak1.try_enum_lookup("mem-usage-flags"); + ASSERT_NE(flags, nullptr); + EXPECT_TRUE(flags->is_bitfield()); + EXPECT_EQ(flags->get_runtime_name(), "uint32"); + EXPECT_EQ(flags->entries().at("prototype-data"), 0); + EXPECT_EQ(flags->entries().at("instance-colors"), 1); + EXPECT_EQ(flags->entries().at("tie-geometry-1"), 2); + EXPECT_EQ(flags->entries().at("tie-geometry-2"), 3); + EXPECT_EQ(flags->entries().at("tie-geometry-3"), 4); + EXPECT_EQ(flags->entries().at("include-dead-pools"), 5); + EXPECT_EQ(flags->entries().at("resource-entity"), 6); + EXPECT_EQ(flags->entries().at("resource-ambient"), 7); + EXPECT_EQ(flags->entries().at("resource-camera"), 8); + EXPECT_EQ(flags->entries().at("resource-joint-geo"), 9); + EXPECT_EQ(jak1.lookup_method("object", "mem-usage").type.print(), + "(function _type_ memory-usage-block mem-usage-flags _type_)"); + + TypeSystem jak2; + jak2.add_builtin_types(GameVersion::Jak2); + EXPECT_EQ(jak2.try_enum_lookup("mem-usage-flags"), nullptr); + EXPECT_EQ(jak2.lookup_method("object", "mem-usage").type.print(), + "(function _type_ memory-usage-block int _type_)"); +} + TEST(TypeSystemReverse, NestedInlineWeird) { // tests the case where we're accessing nested inline arrays, with a dynamic inner access // and constant outer access, which will be constant propagated by the GOAL compiler. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 499c2ebd39..ce71bd55d8 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -19,3 +19,7 @@ target_link_libraries(type_searcher common decomp) add_executable(formatter formatter/main.cpp) target_link_libraries(formatter common tree-sitter) + +add_executable(demacro + demacro/main.cpp) +target_link_libraries(demacro common tree-sitter) diff --git a/tools/demacro/main.cpp b/tools/demacro/main.cpp new file mode 100644 index 0000000000..7655476b22 --- /dev/null +++ b/tools/demacro/main.cpp @@ -0,0 +1,74 @@ +#include +#include + +#include "common/demacro/demacro.h" +#include "common/log/log.h" +#include "common/util/FileUtil.h" +#include "common/util/term_util.h" +#include "common/util/unicode_util.h" + +#include "third-party/CLI11.hpp" + +int main(int argc, char** argv) { + ArgumentGuard u8_guard(argc, argv); + + std::string input_path; + std::string pattern_path; + bool check = false; + bool report = false; + bool write = false; + + lg::initialize(); + + CLI::App app{"Recognize expanded OpenGOAL macros using configurable LISP-form patterns"}; + app.add_option("-f,--file", input_path, "OpenGOAL .gc file to transform")->required(); + app.add_option("-p,--patterns", pattern_path, "Demacro JSONC pattern file")->required(); + app.add_flag("-w,--write", write, "Write the transformed source back to --file"); + app.add_flag("-c,--check", check, + "Do not print source; return failure when the file contains recognized expansions"); + app.add_flag("-r,--report", report, "Report rewrite counts by rule"); + app.validate_positionals(); + define_common_cli_arguments(app); + CLI11_PARSE(app, argc, argv); + + if (_cli_flag_disable_ansi) { + lg::disable_ansi_colors(); + } + if (write && check) { + lg::error("--write and --check cannot be used together"); + return 2; + } + + try { + const auto source = file_util::read_text_file(input_path); + const auto result = demacro::rewrite(source, fs::path(pattern_path)); + if (report) { + for (const auto& stat : result.stats) { + if (stat.rewrites) { + lg::info("{}: {}", stat.name, stat.rewrites); + } + } + } + if (check) { + if (result.rewrite_count() != 0) { + lg::error("{} contains {} recognized macro expansion(s)", input_path, + result.rewrite_count()); + return 1; + } + return 0; + } + + if (write) { + if (result.source != source) { + file_util::write_binary_file(input_path, result.source.data(), result.source.size()); + } + lg::info("Rewrote {} macro expansion(s) in {}", result.rewrite_count(), input_path); + } else { + std::cout << result.source; + } + return 0; + } catch (const std::exception& e) { + lg::error("Demacro failed: {}", e.what()); + return 1; + } +}