From 376194a3e7f38b8c7252d3248bdcfe31b54a7f56 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 6 Apr 2024 15:09:02 -0400 Subject: [PATCH] Jak 3, fixes for animation issues, rm debug print (#3453) --- common/util/trie_with_duplicates.h | 17 +++++++++++++---- .../opengl_renderer/sprite/Sprite3_Glow.cpp | 1 - goal_src/jak3/engine/game/main.gc | 2 +- .../gfx/background/tfrag/tfrag-methods.gc | 2 -- goal_src/jak3/engine/math/math.gc | 2 +- goalc/compiler/Compiler.h | 3 ++- goalc/compiler/compilation/CompilerControl.cpp | 9 +++++---- goalc/compiler/symbol_info.cpp | 5 +++-- goalc/compiler/symbol_info.h | 3 ++- goalc/debugger/Debugger.cpp | 4 +++- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/common/util/trie_with_duplicates.h b/common/util/trie_with_duplicates.h index bc01dc9956..4134301bf3 100644 --- a/common/util/trie_with_duplicates.h +++ b/common/util/trie_with_duplicates.h @@ -37,10 +37,13 @@ class TrieWithDuplicates { return curr_node->elements.back().get(); } - std::vector retrieve_with_prefix(const std::string& prefix) const { + std::vector retrieve_with_prefix(const std::string& prefix, int max_count = -1) const { std::vector results; TrieNode* curr_node = root.get(); for (const char character : prefix) { + if (max_count >= 0 && (int)results.size() > max_count) { + return results; + } const auto& child = curr_node->children.at((uint8_t)character); if (child == nullptr) { return results; // tree ends, nothing found with that prefix @@ -48,7 +51,7 @@ class TrieWithDuplicates { curr_node = child.get(); } } - retrieve_elements(curr_node, results); + retrieve_elements(curr_node, results, max_count); return results; } @@ -107,13 +110,19 @@ class TrieWithDuplicates { } private: - void retrieve_elements(const TrieNode* node, std::vector& results) const { + void retrieve_elements(const TrieNode* node, std::vector& results, int max_count = -1) const { for (const auto& element : node->elements) { + if (max_count >= 0 && (int)results.size() > max_count) { + return; + } results.push_back(element.get()); } for (const auto& child : node->children) { + if (max_count >= 0 && (int)results.size() > max_count) { + return; + } if (child.get() != nullptr) { - retrieve_elements(child.get(), results); + retrieve_elements(child.get(), results, max_count); } } } diff --git a/game/graphics/opengl_renderer/sprite/Sprite3_Glow.cpp b/game/graphics/opengl_renderer/sprite/Sprite3_Glow.cpp index 5c36f7b619..3149af971c 100644 --- a/game/graphics/opengl_renderer/sprite/Sprite3_Glow.cpp +++ b/game/graphics/opengl_renderer/sprite/Sprite3_Glow.cpp @@ -183,7 +183,6 @@ void Sprite3::glow_dma_and_draw(DmaFollower& dma, ScopedProfilerNode& prof) { auto maybe_consts_setup = dma.read_and_advance(); if (maybe_consts_setup.size_bytes != sizeof(SpriteGlowConsts)) { - fmt::print("no consts...\n"); return; } SpriteGlowConsts consts; diff --git a/goal_src/jak3/engine/game/main.gc b/goal_src/jak3/engine/game/main.gc index 9e5bdac1cc..c52157dc55 100644 --- a/goal_src/jak3/engine/game/main.gc +++ b/goal_src/jak3/engine/game/main.gc @@ -1433,7 +1433,7 @@ (execute-math-engine) ) - ; ;; cloth simulation update + ;; cloth simulation update (execute-cloth-engine) (with-profiler 'debug *profile-debug-color* diff --git a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc index 1b4de11e38..055079e7d1 100644 --- a/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc +++ b/goal_src/jak3/engine/gfx/background/tfrag/tfrag-methods.gc @@ -346,8 +346,6 @@ (let ((s4-0 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) (when (!= s4-0 (-> s4-0 last)) - (format 0 "hello init buf (~D)~%" arg0) - (let* ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) (s2-1 (-> s3-0 base)) ) diff --git a/goal_src/jak3/engine/math/math.gc b/goal_src/jak3/engine/math/math.gc index 8c0d11c366..5dc2bbe684 100644 --- a/goal_src/jak3/engine/math/math.gc +++ b/goal_src/jak3/engine/math/math.gc @@ -572,7 +572,7 @@ More efficient than the -old version." ;; og:preserve-this ; (.mula.s f0-1 f2-3) ; (.madd.s f0-2 f1-2 f3-1) - (+ (* f0-1 f2-3) (* f1-2 f3-1)) + (set! f0-2 (+ (* f0-1 f2-3) (* f1-2 f3-1))) ) f0-2 ) diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 4329e46496..4f9ae87547 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -101,7 +101,8 @@ class Compiler { const std::string& file_path) const; std::vector lookup_symbol_info_by_prefix( const std::string& prefix) const; - std::set lookup_symbol_names_starting_with(const std::string& prefix) const; + std::set lookup_symbol_names_starting_with(const std::string& prefix, + int max_count = -1) const; std::vector lookup_exact_name_info(const std::string& name) const; std::optional lookup_typespec(const std::string& symbol_name); TypeSystem& type_system() { return m_ts; }; diff --git a/goalc/compiler/compilation/CompilerControl.cpp b/goalc/compiler/compilation/CompilerControl.cpp index 0fb7e6eb9f..f225eab41a 100644 --- a/goalc/compiler/compilation/CompilerControl.cpp +++ b/goalc/compiler/compilation/CompilerControl.cpp @@ -442,7 +442,7 @@ replxx::Replxx::completions_t Compiler::find_symbols_or_object_file_by_prefix( // the syntax const auto [token, stripped_leading_paren] = m_repl->get_current_repl_token(context); // Otherwise, look for symbols - auto possible_forms = lookup_symbol_names_starting_with(token); + auto possible_forms = lookup_symbol_names_starting_with(token, 100); for (auto& x : possible_forms) { completions.push_back(stripped_leading_paren ? "(" + x : x); @@ -459,7 +459,7 @@ replxx::Replxx::hints_t Compiler::find_hints_by_prefix(std::string const& contex (void)contextLen; (void)user_data; auto token = m_repl->get_current_repl_token(context); - auto possible_forms = lookup_symbol_names_starting_with(token.first); + auto possible_forms = lookup_symbol_names_starting_with(token.first, 100); replxx::Replxx::hints_t hints; @@ -597,9 +597,10 @@ std::vector Compiler::lookup_symbol_info_by_prefix( return m_symbol_info.lookup_symbols_starting_with(prefix); } -std::set Compiler::lookup_symbol_names_starting_with(const std::string& prefix) const { +std::set Compiler::lookup_symbol_names_starting_with(const std::string& prefix, + int max_count) const { if (m_goos.reader.check_string_is_valid(prefix)) { - return m_symbol_info.lookup_names_starting_with(prefix); + return m_symbol_info.lookup_names_starting_with(prefix, max_count); } return {}; } diff --git a/goalc/compiler/symbol_info.cpp b/goalc/compiler/symbol_info.cpp index 3b6b482013..2930ad9da7 100644 --- a/goalc/compiler/symbol_info.cpp +++ b/goalc/compiler/symbol_info.cpp @@ -290,9 +290,10 @@ std::vector SymbolInfoMap::get_all_symbols() const { return m_symbol_map.get_all_elements(); } -std::set SymbolInfoMap::lookup_names_starting_with(const std::string& prefix) const { +std::set SymbolInfoMap::lookup_names_starting_with(const std::string& prefix, + int max_count) const { std::set names; - const auto lookup = m_symbol_map.retrieve_with_prefix(prefix); + const auto lookup = m_symbol_map.retrieve_with_prefix(prefix, max_count); for (const auto& result : lookup) { names.insert(result->m_name); } diff --git a/goalc/compiler/symbol_info.h b/goalc/compiler/symbol_info.h index 5c2b3e80a0..6469ef35d6 100644 --- a/goalc/compiler/symbol_info.h +++ b/goalc/compiler/symbol_info.h @@ -159,7 +159,8 @@ class SymbolInfoMap { std::vector lookup_symbols_by_file(const std::string& file_path) const; std::vector lookup_exact_name(const std::string& name) const; std::vector lookup_symbols_starting_with(const std::string& prefix) const; - std::set lookup_names_starting_with(const std::string& prefix) const; + std::set lookup_names_starting_with(const std::string& prefix, + int max_count = -1) const; std::vector get_all_symbols() const; int symbol_count() const; // Uses the per-file index to find and evict symbols globally diff --git a/goalc/debugger/Debugger.cpp b/goalc/debugger/Debugger.cpp index 061ea375a1..279d0ee1c5 100644 --- a/goalc/debugger/Debugger.cpp +++ b/goalc/debugger/Debugger.cpp @@ -165,7 +165,9 @@ std::string Debugger::get_info_about_addr(u32 addr) { if (map_loc.empty) { return "Unknown Address"; } - std::string result = fmt::format("Object: {}\n", map_loc.obj_name); + std::string result = fmt::format("Object: {} {} (0x{:x} to 0x{:x}) offset 0x{:x}\n", + map_loc.obj_name, map_loc.seg_id, map_loc.start_addr, + map_loc.end_addr, addr - map_loc.start_addr); u64 obj_offset = addr - map_loc.start_addr; FunctionDebugInfo* info = nullptr; std::string name;