From 3d4dfb2077a4153a96451d32a9372bbed65c1113 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 8 Oct 2022 13:33:03 -0400 Subject: [PATCH] [decomp] Decompile some time-of-day stuff, support new style Jak 2 time of day (#1943) - Add "tfrag-water" tfrag tree support (may just be the same as Jak 1's 'dirt' for the settings) - Add "tfrag-trans" tfrag tree support, reusing "trans-tfrag" from jak 1. - Add a hack to `LinkedObjectFileCreation` to handle `oracle`, which is accidentally multiply defined as a type leftover from jak 1 (an entity in village1), and level info for jak 2. - Add `VI1.DGO` - add `time-of-day.gc`, and a few other stub functions so it works - Set up some time of day stuff in GOAL for jak 2/PC renderers - Clean up time of day in c++ renderers, support the more complicated weight system used by jak 2 (backward compatible with jak 1, thankfully) The mood functions now run, so this could cause problems if they rely on stuff we don't have yet. But it seems fine for ctysluma and prison for now. ![image](https://user-images.githubusercontent.com/48171810/194719441-d185f59c-19dc-4cd3-a5c4-00b0cfe1d6c3.png) ![image](https://user-images.githubusercontent.com/48171810/194719449-6e051bf3-0750-42e5-a654-901313dbe479.png) ![image](https://user-images.githubusercontent.com/48171810/194719455-3ca6793e-873a-449a-8e85-9c20ffeb4da3.png) ![image](https://user-images.githubusercontent.com/48171810/194719461-8f27af17-4434-4492-96cd-8c5eec6eafdf.png) ![image](https://user-images.githubusercontent.com/48171810/194719468-720715b9-985a-4acf-928c-eab948cfcb03.png) ![image](https://user-images.githubusercontent.com/48171810/194719486-bfb91e83-f6ca-4585-80ad-3b2c0cbbd5af.png) ![image](https://user-images.githubusercontent.com/48171810/194719492-df065d2f-cb5a-47e3-a248-f5317c42082f.png) ![image](https://user-images.githubusercontent.com/48171810/194719507-91e1f477-ecfe-4d6c-b744-5f24646255ca.png) --- common/custom_data/Tfrag3Data.h | 6 +- common/math/Vector.h | 9 + decompiler/IR2/AtomicOpTypeAnalysis.cpp | 1 - decompiler/IR2/Env.cpp | 2 +- decompiler/IR2/FormExpressionAnalysis.cpp | 2 +- .../ObjectFile/LinkedObjectFileCreation.cpp | 6 +- decompiler/config/jak2/all-types.gc | 17 +- decompiler/config/jak2/hacks.jsonc | 3 +- decompiler/config/jak2/inputs.jsonc | 6 +- decompiler/config/jak2/type_casts.jsonc | 9 +- decompiler/config/jak2_ntsc_v1.jsonc | 4 +- decompiler/level_extractor/BspHeader.cpp | 24 + decompiler/level_extractor/BspHeader.h | 15 + decompiler/level_extractor/extract_level.cpp | 9 +- decompiler/level_extractor/extract_tfrag.cpp | 18 +- decompiler/level_extractor/extract_tie.cpp | 7 +- decompiler/level_extractor/extract_tie.h | 3 +- decompiler/types2/ForwardProp.cpp | 2 - decompiler/util/DecompilerTypeSystem.cpp | 2 +- decompiler/util/data_decompile.cpp | 5 +- .../opengl_renderer/OpenGLRenderer.cpp | 3 + .../opengl_renderer/background/Shrub.cpp | 7 +- .../opengl_renderer/background/TFragment.cpp | 19 +- .../opengl_renderer/background/TFragment.h | 2 - .../opengl_renderer/background/Tfrag3.cpp | 4 +- .../opengl_renderer/background/Tie3.cpp | 16 +- .../background/background_common.cpp | 165 ++--- .../background/background_common.h | 9 +- game/graphics/opengl_renderer/buckets.h | 1 + game/kernel/jak2/kscheme.cpp | 6 +- game/mips2c/jak2_functions/debug.cpp | 1 - game/mips2c/jak2_functions/texture.cpp | 1 - goal_src/jak2/dgos/vi1.gd | 21 + goal_src/jak2/engine/common_objs/base-plat.gc | 2 +- goal_src/jak2/engine/draw/drawable.gc | 16 +- goal_src/jak2/engine/game/main.gc | 2 +- .../jak2/engine/gfx/background/background.gc | 18 +- goal_src/jak2/engine/gfx/mood/mood.gc | 60 +- goal_src/jak2/engine/gfx/mood/time-of-day.gc | 692 ++++++++++++++++- goal_src/jak2/engine/gfx/mood/weather-part.gc | 53 ++ goal_src/jak2/engine/gfx/sky/sky-h.gc | 8 +- goal_src/jak2/engine/gfx/sky/sky-tng.gc | 63 ++ .../sprite/particles/sparticle-launcher-h.gc | 3 +- .../sprite/particles/sparticle-launcher.gc | 10 +- .../jak2/engine/gfx/texture/texture-anim-h.gc | 32 +- .../engine/gfx/texture/texture-anim-tables.gc | 10 +- .../jak2/engine/target/board/target-board.gc | 2 +- goal_src/jak2/game.gp | 29 +- goal_src/jak2/kernel/gstate.gc | 4 +- goal_src/jak2/levels/common/elec-gate.gc | 4 +- scripts/decomp_progress.py | 7 +- .../jak2/engine/common_objs/base-plat_REF.gc | 2 +- .../jak2/engine/gfx/mood/time-of-day_REF.gc | 697 ++++++++++++++++++ .../jak2/engine/gfx/sky/sky-h_REF.gc | 4 +- .../particles/sparticle-launcher-h_REF.gc | 2 +- .../particles/sparticle-launcher_REF.gc | 197 ++++- .../engine/gfx/texture/texture-anim-h_REF.gc | 36 +- .../engine/target/board/target-board_REF.gc | 2 +- .../jak2/levels/common/elec-gate_REF.gc | 4 +- test/offline/config/jak2/config.jsonc | 1 + 60 files changed, 2076 insertions(+), 289 deletions(-) create mode 100644 goal_src/jak2/dgos/vi1.gd create mode 100644 test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc diff --git a/common/custom_data/Tfrag3Data.h b/common/custom_data/Tfrag3Data.h index 930e0163c7..9243fc3016 100644 --- a/common/custom_data/Tfrag3Data.h +++ b/common/custom_data/Tfrag3Data.h @@ -259,10 +259,10 @@ struct Texture { }; // Tfrag trees have several kinds: -enum class TFragmentTreeKind { NORMAL, TRANS, DIRT, ICE, LOWRES, LOWRES_TRANS, INVALID }; +enum class TFragmentTreeKind { NORMAL, TRANS, DIRT, ICE, LOWRES, LOWRES_TRANS, WATER, INVALID }; -constexpr const char* tfrag_tree_names[] = {"normal", "trans", "dirt", "ice", - "lowres", "lowres-trans", "invalid"}; +constexpr const char* tfrag_tree_names[] = {"normal", "trans", "dirt", "ice", + "lowres", "lowres-trans", "water", "invalid"}; // A tfrag model struct TfragTree { diff --git a/common/math/Vector.h b/common/math/Vector.h index e79c1149ef..01bd3c21b2 100644 --- a/common/math/Vector.h +++ b/common/math/Vector.h @@ -225,6 +225,15 @@ class Vector { return result + "]"; } + std::string to_string_hex_word() const { + std::string result = "["; + for (auto x : m_data) { + result.append(fmt::format("0x{:08x} ", x)); + } + result.pop_back(); + return result + "]"; + } + T* data() { return m_data; } const T* data() const { return m_data; } diff --git a/decompiler/IR2/AtomicOpTypeAnalysis.cpp b/decompiler/IR2/AtomicOpTypeAnalysis.cpp index 01a46fd86a..49e92d6880 100644 --- a/decompiler/IR2/AtomicOpTypeAnalysis.cpp +++ b/decompiler/IR2/AtomicOpTypeAnalysis.cpp @@ -1428,7 +1428,6 @@ TypeState CallOp::propagate_types_internal(const TypeState& input, in_type.last_arg() == TypeSpec("array")) { // array new: auto& a2 = input.get(Register(Reg::GPR, arg_regs[2])); // elt type - auto& a1 = input.get(Register(Reg::GPR, arg_regs[1])); // array auto& a0 = input.get(Register(Reg::GPR, arg_regs[0])); // allocation if (a2.kind == TP_Type::Kind::TYPE_OF_TYPE_NO_VIRTUAL && diff --git a/decompiler/IR2/Env.cpp b/decompiler/IR2/Env.cpp index 08b8c565dc..382c81d12f 100644 --- a/decompiler/IR2/Env.cpp +++ b/decompiler/IR2/Env.cpp @@ -35,7 +35,7 @@ void Env::set_remap_for_function(const Function& func) { } int nargs = func.type.arg_count() - 1; for (int i = 0; i < nargs; i++) { - if (default_arg_names.size() > i) { + if ((int)default_arg_names.size() > i) { m_var_remap[get_reg_name(i)] = default_arg_names.at(i); } else { m_var_remap[get_reg_name(i)] = ("arg" + std::to_string(i)); diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 49dc5980b1..509d66b571 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -1052,7 +1052,7 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env, // try to find symbol to string stuff auto arg0_int = get_goal_integer_constant(args.at(0), env); - if (arg0_int && (*arg0_int == SYMBOL_TO_STRING_MEM_OFFSET_DECOMP[env.version]) && + if (arg0_int && ((s64)*arg0_int == SYMBOL_TO_STRING_MEM_OFFSET_DECOMP[env.version]) && allowable_base_type_for_symbol_to_string(arg1_type.typespec())) { result->push_back(pool.alloc_element(args.at(1))); return; diff --git a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp index 3931fd45e2..f7eaad5f95 100644 --- a/decompiler/ObjectFile/LinkedObjectFileCreation.cpp +++ b/decompiler/ObjectFile/LinkedObjectFileCreation.cpp @@ -126,7 +126,11 @@ static uint32_t c_symlink2(LinkedObjectFile& f, word_kind = LinkedWord::EMPTY_PTR; break; case SymbolLinkKind::TYPE: - dts.add_symbol(name, "type", {}); + // hack for jak 2: this symbol is used as a type in village 1 and also the oracle level + // level info. We'll just leave it out, as we don't really need these definitions. + if (std::string(name) != "oracle") { + dts.add_symbol(name, "type", {}); + } word_kind = LinkedWord::TYPE_PTR; break; default: diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 0b255a68bb..a25ddc6bee 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -5150,14 +5150,14 @@ (tex basic :offset-assert 12) (tex-name basic :offset-assert 16) (extra vector :inline :offset-assert 32) - (color uint32 :offset-assert 48) + (color rgba :offset-assert 48) (frame-time float :offset-assert 52) (frame-delta float :offset-assert 56) (frame-mod float :offset-assert 60) - (test uint64 :offset-assert 64) - (alpha uint64 :offset-assert 72) - (clamp uint64 :offset-assert 80) - (data uint8 :dynamic :offset-assert 88) + (test gs-test :offset-assert 64) + (alpha gs-alpha :offset-assert 72) + (clamp gs-clamp :offset-assert 80) + (data texture-anim-layer :dynamic :offset-assert 88) ) :method-count-assert 11 :size-assert #x58 @@ -9979,8 +9979,8 @@ (:methods (init-sun-data! "Sets the sun related upload data - the sun, halo and aurora" (_type_ int float float float) none 9) (init-orbit-settings! (_type_ int float float float float float float) none 10) - (sky-work-method-11 () none 11) - (sky-work-method-12 () none 12) + (update-colors-for-time (_type_ float) none 11) + (update-time-and-speed (_type_ float float) none 12) ;; update time-of-day settings (draw (_type_) none 13) (sky-work-method-14 () none 14) (sky-work-method-15 () none 15) @@ -19545,6 +19545,7 @@ (start-dead 2) (launch-asap 3) (bit6 6) + (bit7 7) ) (defenum sp-launch-state-flags @@ -19708,7 +19709,7 @@ (:methods (initialize (_type_ sparticle-launch-group process) none 9) ;; (sparticle-launch-control-method-10 (_type_ vector) symbol 10) ;; (is-visible? (_type_ vector) symbol 10) - (sparticle-launch-control-method-11 (_type_ vector) none 11) ;; TODO - CFG ;; (spawn (_type_ vector) object 11) + (spawn (_type_ vector) none 11) ;; TODO - CFG ;; (spawn (_type_ vector) object 11) (sparticle-launch-control-method-12 (_type_ matrix) none 12) (sparticle-launch-control-method-13 (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 2fae9b2c3c..61fce95ecc 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -333,7 +333,8 @@ 45 // goto 6 ], "(method 27 conveyor)": [5, 14, 22], - "(method 44 nav-graph)": [1, 3, 6, 13, 17] + "(method 44 nav-graph)": [1, 3, 6, 13, 17], + "(method 11 sparticle-launch-control)": [18, 24, 25, 28, 29, 32, 33, 34, 36, 41, 55, 58, 93, 95] }, // Sometimes the game might use format strings that are fetched dynamically, diff --git a/decompiler/config/jak2/inputs.jsonc b/decompiler/config/jak2/inputs.jsonc index 7bb4c35e26..d23d3bae87 100644 --- a/decompiler/config/jak2/inputs.jsonc +++ b/decompiler/config/jak2/inputs.jsonc @@ -154,13 +154,13 @@ // "DGO/LSACK.DGO", // "DGO/CTYASHA.DGO", // "DGO/LPRTRACE.DGO", - "DGO/LWIDEA.DGO" + "DGO/LWIDEA.DGO", // "DGO/HIPHOG.DGO", // "DGO/LSMYSBRT.DGO", // "DGO/LRACEBB.DGO", // "DGO/CASCITY.DGO", // "DGO/LYSAMSAM.DGO" //, - // "DGO/VI1.DGO" + "DGO/VI1.DGO" ], // some objects are part of STR files (streaming data). @@ -184,5 +184,5 @@ "streamed_audio_file_names": [], - "levels_to_extract": ["PRI.DGO", "CTA.DGO", "CWI.DGO", "LWIDEA.DGO"] + "levels_to_extract": ["PRI.DGO", "CTA.DGO", "CWI.DGO", "LWIDEA.DGO", "VI1.DGO"] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index 89de75f00d..aed6a3b71e 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -964,7 +964,7 @@ [5, "s5", "glst-named-node"], [6, "v1", "glst-named-node"] ], - "(event time-of-day-tick)": [[10, "v1", "float"]], + "(event time-of-day-tick)": [[10, "v1", "float"], [148, "v1", "float"]], "cam-slave-get-vector-with-offset": [[[52, 61], "s3", "vector"]], "cam-slave-get-interp-time": [[43, "f0", "float"]], "cam-standard-event-handler": [ @@ -2774,7 +2774,12 @@ [[171, 193], "s2", "(pointer uint8)"], [227, "v1", "(pointer uint8)"] ], - "unpack-comp-huf": [[[21, 23], "t3", "(pointer uint16)"]], + "set-fog-height!": [ + [2, "v1", "(array texture-anim)"] + ], + "unpack-comp-huf": [ + [[21,23], "t3", "(pointer uint16)"] + ], "(method 10 elec-gate)": [[13, "t9", "(function process-drawable none)"]], "(method 11 elec-gate)": [ [180, "a0", "vector"], diff --git a/decompiler/config/jak2_ntsc_v1.jsonc b/decompiler/config/jak2_ntsc_v1.jsonc index 4caca241f7..711a924837 100644 --- a/decompiler/config/jak2_ntsc_v1.jsonc +++ b/decompiler/config/jak2_ntsc_v1.jsonc @@ -7,8 +7,8 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. - "allowed_objects": ["region"], - "banned_objects": ["effect-control", "time-of-day", "target-util", "ctywide-scenes"], + "allowed_objects": ["mood"], + "banned_objects": ["effect-control", "target-util", "ctywide-scenes"], //////////////////////////// // CODE ANALYSIS OPTIONS diff --git a/decompiler/level_extractor/BspHeader.cpp b/decompiler/level_extractor/BspHeader.cpp index d3063b7276..7088bf1e8d 100644 --- a/decompiler/level_extractor/BspHeader.cpp +++ b/decompiler/level_extractor/BspHeader.cpp @@ -781,6 +781,18 @@ std::unique_ptr make_drawable_inline_array( return result; } + if (ref.type->get_name() == "drawable-inline-array-tfrag-trans") { + auto result = std::make_unique(); + result->read_from_file(ref, dts, stats, version); + return result; + } + + if (ref.type->get_name() == "drawable-inline-array-tfrag-water") { + auto result = std::make_unique(); + result->read_from_file(ref, dts, stats, version); + return result; + } + if (ref.type->get_name() == "drawable-inline-array-instance-tie") { auto result = std::make_unique(); result->read_from_file(ref, dts, stats, version); @@ -1773,6 +1785,18 @@ std::unique_ptr make_drawable_tree(TypedRef ref, return tree; } + if (ref.type->get_name() == "drawable-tree-tfrag-trans") { + auto tree = std::make_unique(); + tree->read_from_file(ref, dts, stats, version); + return tree; + } + + if (ref.type->get_name() == "drawable-tree-tfrag-water") { + auto tree = std::make_unique(); + tree->read_from_file(ref, dts, stats, version); + return tree; + } + if (ref.type->get_name() == "drawable-tree-actor") { auto tree = std::make_unique(); tree->read_from_file(ref, dts, stats, version); diff --git a/decompiler/level_extractor/BspHeader.h b/decompiler/level_extractor/BspHeader.h index 625f1884f4..c0a0d5e734 100644 --- a/decompiler/level_extractor/BspHeader.h +++ b/decompiler/level_extractor/BspHeader.h @@ -363,6 +363,21 @@ struct DrawableInlineArrayTransTFrag : public DrawableInlineArrayTFrag { std::string my_type() const override { return "drawable-inline-array-trans-tfrag"; } }; +struct DrawableInlineArrayTFragTrans : public DrawableInlineArrayTFrag { + std::string my_type() const override { return "drawable-inline-array-tfrag-trans"; } +}; + +struct DrawableInlineArrayTFragWater : public DrawableInlineArrayTFrag { + std::string my_type() const override { return "drawable-inline-array-tfrag-water"; } +}; + +struct DrawableTreeTfragTrans : public DrawableTreeTfrag { + std::string my_type() const override { return "drawable-tree-tfrag-trans"; } +}; + +struct DrawableTreeTfragWater : public DrawableTreeTfrag { + std::string my_type() const override { return "drawable-tree-tfrag-water"; } +}; ///////////////////// // TIE ///////////////////// diff --git a/decompiler/level_extractor/extract_level.cpp b/decompiler/level_extractor/extract_level.cpp index aa6e857c88..6417af89e9 100644 --- a/decompiler/level_extractor/extract_level.cpp +++ b/decompiler/level_extractor/extract_level.cpp @@ -145,8 +145,9 @@ std::vector extract_bsp_from_level(const ObjectFileDB */ const std::set tfrag_trees = { - "drawable-tree-tfrag", "drawable-tree-trans-tfrag", "drawable-tree-dirt-tfrag", - "drawable-tree-ice-tfrag", "drawable-tree-lowres-tfrag", "drawable-tree-lowres-trans-tfrag"}; + "drawable-tree-tfrag", "drawable-tree-trans-tfrag", "drawable-tree-tfrag-trans", + "drawable-tree-dirt-tfrag", "drawable-tree-tfrag-water", "drawable-tree-ice-tfrag", + "drawable-tree-lowres-tfrag", "drawable-tree-lowres-trans-tfrag"}; int i = 0; std::vector all_ties; @@ -174,7 +175,7 @@ std::vector extract_bsp_from_level(const ObjectFileDB auto as_tie_tree = dynamic_cast(draw_tree.get()); ASSERT(as_tie_tree); extract_tie(as_tie_tree, fmt::format("{}-{}-tie", dgo_name, i++), - bsp_header.texture_remap_table, tex_db, level_data, false); + bsp_header.texture_remap_table, tex_db, level_data, false, db.version()); } else if (draw_tree->my_type() == "drawable-tree-instance-shrub") { auto as_shrub_tree = dynamic_cast(draw_tree.get()); @@ -190,7 +191,7 @@ std::vector extract_bsp_from_level(const ObjectFileDB extract_collide_frags(as_collide_frags, all_ties, fmt::format("{}-{}-collide", dgo_name, i++), level_data, false); } else { - // lg::print(" unsupported tree {}\n", draw_tree->my_type()); + lg::print(" unsupported tree {}\n", draw_tree->my_type()); } } level_data.level_name = level_name; diff --git a/decompiler/level_extractor/extract_tfrag.cpp b/decompiler/level_extractor/extract_tfrag.cpp index 1f3d3475eb..1a45c30188 100644 --- a/decompiler/level_extractor/extract_tfrag.cpp +++ b/decompiler/level_extractor/extract_tfrag.cpp @@ -1875,6 +1875,16 @@ void process_draw_mode(std::vector& all_draws, mode.set_depth_test(GsTest::ZTest::GEQUAL); // :ztst (gs-ztest greater-equal) mode.enable_ab(); break; + case tfrag3::TFragmentTreeKind::WATER: + // (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest greater-equal)) + mode.enable_at(); + mode.set_alpha_test(DrawMode::AlphaTest::NEVER); + mode.set_alpha_fail(GsTest::AlphaFail::FB_ONLY); + mode.set_aref(0); + mode.enable_zt(); + mode.set_depth_test(GsTest::ZTest::GEQUAL); + mode.enable_ab(); + break; default: ASSERT(false); } @@ -1889,7 +1899,7 @@ void process_draw_mode(std::vector& all_draws, update_mode_from_test1(val, mode); break; case GsRegisterAddress::TEX0_1: - ASSERT(val == 0); + // ASSERT(val == 0); HACK jak 2 sets this. break; case GsRegisterAddress::TEX1_1: ASSERT(val == 0x120); // some flag @@ -1914,8 +1924,6 @@ void process_draw_mode(std::vector& all_draws, ASSERT_MSG(false, fmt::format("clamp: 0x{:x}", val)); } - // this isn't quite right, but I'm hoping it's enough! - // mode.set_clamp_enable(val == 0b101); mode.set_clamp_s_enable(val & 0b1); mode.set_clamp_t_enable(val & 0b100); break; @@ -2161,6 +2169,10 @@ void extract_tfrag(const level_tools::DrawableTreeTfrag* tree, this_tree.kind = tfrag3::TFragmentTreeKind::LOWRES; } else if (tree->my_type() == "drawable-tree-trans-tfrag") { this_tree.kind = tfrag3::TFragmentTreeKind::TRANS; + } else if (tree->my_type() == "drawable-tree-tfrag-trans") { + this_tree.kind = tfrag3::TFragmentTreeKind::TRANS; + } else if (tree->my_type() == "drawable-tree-tfrag-water") { + this_tree.kind = tfrag3::TFragmentTreeKind::WATER; } else { ASSERT_MSG(false, fmt::format("unknown tfrag tree kind: {}", tree->my_type())); } diff --git a/decompiler/level_extractor/extract_tie.cpp b/decompiler/level_extractor/extract_tie.cpp index e82796c448..a80d551698 100644 --- a/decompiler/level_extractor/extract_tie.cpp +++ b/decompiler/level_extractor/extract_tie.cpp @@ -2295,7 +2295,8 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, const std::vector& tex_map, const TextureDB& tex_db, tfrag3::Level& out, - bool dump_level) { + bool dump_level, + GameVersion version) { for (int geo = 0; geo < GEOM_MAX; ++geo) { tfrag3::TieTree this_tree; @@ -2336,7 +2337,9 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, auto info = collect_instance_info(as_instance_array, &tree->prototypes.prototype_array_tie.data, geo); update_proto_info(&info, tex_map, tex_db, tree->prototypes.prototype_array_tie.data, geo); - check_wind_vectors_zero(info, tree->prototypes.wind_vectors); + if (version != GameVersion::Jak2) { + check_wind_vectors_zero(info, tree->prototypes.wind_vectors); + } // determine draws from VU program emulate_tie_prototype_program(info); emulate_tie_instance_program(info); diff --git a/decompiler/level_extractor/extract_tie.h b/decompiler/level_extractor/extract_tie.h index 6429a775ee..c64101f57a 100644 --- a/decompiler/level_extractor/extract_tie.h +++ b/decompiler/level_extractor/extract_tie.h @@ -14,5 +14,6 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, const std::vector& tex_map, const TextureDB& tex_db, tfrag3::Level& out, - bool dump_level); + bool dump_level, + GameVersion version); } diff --git a/decompiler/types2/ForwardProp.cpp b/decompiler/types2/ForwardProp.cpp index be3ef66811..b266127423 100644 --- a/decompiler/types2/ForwardProp.cpp +++ b/decompiler/types2/ForwardProp.cpp @@ -287,7 +287,6 @@ bool backprop_tagged_type(const TP_Type& expected_type, actual_type.tag.unknown_label->selected_type == expected_type.typespec()) { return false; // no need to update } else { - auto& tag = actual_type.tag.unknown_label; actual_type.tag.unknown_label->selected_type = expected_type.typespec(); return true; } @@ -297,7 +296,6 @@ bool backprop_tagged_type(const TP_Type& expected_type, actual_type.tag.unknown_stack_structure->selected_type == expected_type.typespec()) { return false; // no need to update } else { - auto& tag = actual_type.tag.unknown_stack_structure; actual_type.tag.unknown_stack_structure->selected_type = expected_type.typespec(); return true; } diff --git a/decompiler/util/DecompilerTypeSystem.cpp b/decompiler/util/DecompilerTypeSystem.cpp index 04753bc512..ec30a41799 100644 --- a/decompiler/util/DecompilerTypeSystem.cpp +++ b/decompiler/util/DecompilerTypeSystem.cpp @@ -434,7 +434,7 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const { bool code_takes_no_arg = false; for (auto& ignored_code : code_ignore_list) { - int j = i; + size_t j = i; bool match = true; for (const char c : ignored_code) { if (j > str.length()) { diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 09c00dfe73..938d523eea 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1427,7 +1427,7 @@ goos::Object decompile_boxed_array(const DecompilerLabel& label, if (type_ptr.kind() != LinkedWord::TYPE_PTR) { throw std::runtime_error("Invalid basic in decompile_boxed_array"); } - if (type_ptr.symbol_name() == "array") { + if (type_ptr.symbol_name() == "array" || type_ptr.symbol_name() == "texture-anim-array") { auto content_type_ptr_word_idx = type_ptr_word_idx + 3; auto& content_type_ptr = words.at(label.target_segment).at(content_type_ptr_word_idx); if (content_type_ptr.kind() != LinkedWord::TYPE_PTR) { @@ -1435,7 +1435,8 @@ goos::Object decompile_boxed_array(const DecompilerLabel& label, } content_type = TypeSpec(content_type_ptr.symbol_name()); } else { - throw std::runtime_error("Wrong basic type in decompile_boxed_array"); + throw std::runtime_error( + fmt::format("Wrong basic type in decompile_boxed_array: got {}", type_ptr.symbol_name())); } } else { throw std::runtime_error("Invalid alignment in decompile_boxed_array"); diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 352c24091f..b672a7cbd4 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -100,6 +100,9 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { init_bucket_renderer("tfrag-t-l0-alpha", BucketCategory::TFRAG, BucketId::TFRAG_T_L0_ALPHA, std::vector{tfrag3::TFragmentTreeKind::TRANS}, false, 0); + init_bucket_renderer("tfrag-w-l0-alpha", BucketCategory::TFRAG, + BucketId::TFRAG_W_L0_WATER, + std::vector{tfrag3::TFragmentTreeKind::WATER}, false, 0); init_bucket_renderer("debug-no-zbuf1", BucketCategory::OTHER, BucketId::DEBUG_NO_ZBUF1, 0x8000); init_bucket_renderer("debug2", BucketCategory::OTHER, BucketId::DEBUG2, 0x8000); diff --git a/game/graphics/opengl_renderer/background/Shrub.cpp b/game/graphics/opengl_renderer/background/Shrub.cpp index 0a356ff003..501698a623 100644 --- a/game/graphics/opengl_renderer/background/Shrub.cpp +++ b/game/graphics/opengl_renderer/background/Shrub.cpp @@ -52,9 +52,8 @@ void Shrub::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProf memcpy(settings.math_camera.data(), m_pc_port_data.camera[0].data(), 64); settings.tree_idx = 0; - for (int i = 0; i < 8; i++) { - settings.time_of_day_weights[i] = - 2 * (0xff & m_pc_port_data.itimes[i / 2].data()[2 * (i % 2)]) / 127.f; + for (int i = 0; i < 4; i++) { + settings.itimes[i] = m_pc_port_data.itimes[i]; } update_render_state_from_pc_settings(render_state, m_pc_port_data); @@ -229,7 +228,7 @@ void Shrub::render_tree(int idx, } Timer interp_timer; - interp_time_of_day_fast(settings.time_of_day_weights, tree.tod_cache, m_color_result.data()); + interp_time_of_day_fast(settings.itimes, tree.tod_cache, m_color_result.data()); tree.perf.tod_time.add(interp_timer.getSeconds()); Timer setup_timer; diff --git a/game/graphics/opengl_renderer/background/TFragment.cpp b/game/graphics/opengl_renderer/background/TFragment.cpp index 1e08ba7496..60f578706f 100644 --- a/game/graphics/opengl_renderer/background/TFragment.cpp +++ b/game/graphics/opengl_renderer/background/TFragment.cpp @@ -128,17 +128,7 @@ void TFragment::render(DmaFollower& dma, for (int i = 0; i < 4; i++) { settings.planes[i] = m_pc_port_data.planes[i]; - } - - if (m_override_time_of_day) { - for (int i = 0; i < 8; i++) { - settings.time_of_day_weights[i] = m_time_of_days[i]; - } - } else { - for (int i = 0; i < 8; i++) { - settings.time_of_day_weights[i] = - 2 * (0xff & m_pc_port_data.itimes[i / 2].data()[2 * (i % 2)]) / 127.f; - } + settings.itimes[i] = m_pc_port_data.itimes[i]; } auto t3prof = prof.make_scoped_child("t3"); @@ -152,13 +142,6 @@ void TFragment::render(DmaFollower& dma, } void TFragment::draw_debug_window() { - ImGui::Checkbox("Manual Time of Day", &m_override_time_of_day); - if (m_override_time_of_day) { - for (int i = 0; i < 8; i++) { - ImGui::SliderFloat(fmt::format("{}", i).c_str(), m_time_of_days + i, 0.f, 1.f); - } - } - m_tfrag3.draw_debug_window(); } diff --git a/game/graphics/opengl_renderer/background/TFragment.h b/game/graphics/opengl_renderer/background/TFragment.h index ea48b0f63e..17adf3a8b2 100644 --- a/game/graphics/opengl_renderer/background/TFragment.h +++ b/game/graphics/opengl_renderer/background/TFragment.h @@ -48,8 +48,6 @@ class TFragment : public BucketRenderer { void handle_initialization(DmaFollower& dma); bool m_child_mode = false; - bool m_override_time_of_day = false; - float m_time_of_days[8] = {1, 0, 0, 0, 0, 0, 0, 0}; // GS setup data u8 m_test_setup[32]; diff --git a/game/graphics/opengl_renderer/background/Tfrag3.cpp b/game/graphics/opengl_renderer/background/Tfrag3.cpp index cf88268e98..fd679ecfb9 100644 --- a/game/graphics/opengl_renderer/background/Tfrag3.cpp +++ b/game/graphics/opengl_renderer/background/Tfrag3.cpp @@ -183,9 +183,9 @@ void Tfrag3::render_tree(int geom, m_color_result.resize(tree.colors->size()); } if (m_use_fast_time_of_day) { - interp_time_of_day_fast(settings.time_of_day_weights, tree.tod_cache, m_color_result.data()); + interp_time_of_day_fast(settings.itimes, tree.tod_cache, m_color_result.data()); } else { - interp_time_of_day_slow(settings.time_of_day_weights, *tree.colors, m_color_result.data()); + interp_time_of_day_slow(settings.itimes, *tree.colors, m_color_result.data()); } glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_1D, tree.time_of_day_texture); diff --git a/game/graphics/opengl_renderer/background/Tie3.cpp b/game/graphics/opengl_renderer/background/Tie3.cpp index 985c997dc4..e8a8b10446 100644 --- a/game/graphics/opengl_renderer/background/Tie3.cpp +++ b/game/graphics/opengl_renderer/background/Tie3.cpp @@ -383,17 +383,7 @@ void Tie3::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfi for (int i = 0; i < 4; i++) { settings.planes[i] = m_pc_port_data.planes[i]; - } - - if (false) { - // for (int i = 0; i < 8; i++) { - // settings.time_of_day_weights[i] = m_time_of_days[i]; - // } - } else { - for (int i = 0; i < 8; i++) { - settings.time_of_day_weights[i] = - 2 * (0xff & m_pc_port_data.itimes[i / 2].data()[2 * (i % 2)]) / 127.f; - } + settings.itimes[i] = m_pc_port_data.itimes[i]; } if (!m_override_level) { @@ -552,9 +542,9 @@ void Tie3::render_tree(int idx, Timer interp_timer; if (m_use_fast_time_of_day) { - interp_time_of_day_fast(settings.time_of_day_weights, tree.tod_cache, m_color_result.data()); + interp_time_of_day_fast(settings.itimes, tree.tod_cache, m_color_result.data()); } else { - interp_time_of_day_slow(settings.time_of_day_weights, *tree.colors, m_color_result.data()); + interp_time_of_day_slow(settings.itimes, *tree.colors, m_color_result.data()); } tree.perf.tod_time.add(interp_timer.getSeconds()); diff --git a/game/graphics/opengl_renderer/background/background_common.cpp b/game/graphics/opengl_renderer/background/background_common.cpp index 168badf275..2fe62be6e8 100644 --- a/game/graphics/opengl_renderer/background/background_common.cpp +++ b/game/graphics/opengl_renderer/background/background_common.cpp @@ -165,14 +165,32 @@ void first_tfrag_draw_setup(const TfragRenderSettings& settings, render_state->fog_intensity / 255); } -void interp_time_of_day_slow(const float weights[8], +void interp_time_of_day_slow(const math::Vector itimes[4], const std::vector& in, math::Vector* out) { // Timer interp_timer; + math::Vector4f weights[8]; + for (int component = 0; component < 8; component++) { + int quad_idx = component / 2; + int word_off = (component % 2 * 2); + for (int channel = 0; channel < 4; channel++) { + int word = word_off + (channel / 2); + int hw_off = channel % 2; + + u32 word_val = itimes[quad_idx][word]; + u32 hw_val = hw_off ? (word_val >> 16) : word_val; + hw_val = hw_val & 0xff; + weights[component][channel] = hw_val / 64.f; + } + } + for (size_t color = 0; color < in.size(); color++) { math::Vector4f result = math::Vector4f::zero(); for (int component = 0; component < 8; component++) { - result += in[color].rgba[component].cast() * weights[component]; + for (int channel = 0; channel < 4; channel++) { + result[channel] += in[color].rgba[component][channel] * weights[component][channel]; + } + // result += in[color].rgba[component].cast() * weights[component]; } result[0] = std::min(result[0], 255.f); result[1] = std::min(result[1], 255.f); @@ -229,127 +247,52 @@ SwizzledTimeOfDay swizzle_time_of_day(const std::vector& return out; } -// This does the same thing as interp_time_of_day_slow, but is faster. -// Due to using integers instead of floats, it may be a tiny bit different. -// TODO: it might be possible to reorder the loop into two blocks of loads and avoid spilling xmms. -// It's ~8x faster than the slow version. - -void interp_time_of_day_fast_avx2(const float weights[8], - const SwizzledTimeOfDay& in, - math::Vector* out) { - // even though the colors are 8 bits, we'll use 16 bits so we can saturate correctly -#ifdef __AVX2__ - // weight multipliers - __m256i weights0 = _mm256_set1_epi16(weights[0] * 64.f); - __m256i weights1 = _mm256_set1_epi16(weights[1] * 64.f); - __m256i weights2 = _mm256_set1_epi16(weights[2] * 64.f); - __m256i weights3 = _mm256_set1_epi16(weights[3] * 64.f); - __m256i weights4 = _mm256_set1_epi16(weights[4] * 64.f); - __m256i weights5 = _mm256_set1_epi16(weights[5] * 64.f); - __m256i weights6 = _mm256_set1_epi16(weights[6] * 64.f); - __m256i weights7 = _mm256_set1_epi16(weights[7] * 64.f); - - // saturation: note that alpha is saturated to 128 but the rest are 255. - // TODO: maybe we should saturate to 255 for everybody (can do this using a single packus) and - // change the shader to deal with this. - __m256i sat = _mm256_set_epi16(128, 255, 255, 255, 128, 255, 255, 255, 128, 255, 255, 255, 128, - 255, 255, 255); - - for (u32 color_quad = 0; color_quad < in.color_count / 4; color_quad++) { - // first, load colors. We put 16 bytes / register and don't touch the upper half because we - // convert u8s to u16s. - const u8* base = in.data.data() + color_quad * 128; - __m128i color0_p = _mm_loadu_si128((const __m128i*)(base + 0)); - __m128i color1_p = _mm_loadu_si128((const __m128i*)(base + 16)); - __m128i color2_p = _mm_loadu_si128((const __m128i*)(base + 32)); - __m128i color3_p = _mm_loadu_si128((const __m128i*)(base + 48)); - __m128i color4_p = _mm_loadu_si128((const __m128i*)(base + 64)); - __m128i color5_p = _mm_loadu_si128((const __m128i*)(base + 80)); - __m128i color6_p = _mm_loadu_si128((const __m128i*)(base + 96)); - __m128i color7_p = _mm_loadu_si128((const __m128i*)(base + 112)); - - // unpack to 16-bits. each has 16x 16 bit colors. - __m256i color0 = _mm256_cvtepu8_epi16(color0_p); - __m256i color1 = _mm256_cvtepu8_epi16(color1_p); - __m256i color2 = _mm256_cvtepu8_epi16(color2_p); - __m256i color3 = _mm256_cvtepu8_epi16(color3_p); - __m256i color4 = _mm256_cvtepu8_epi16(color4_p); - __m256i color5 = _mm256_cvtepu8_epi16(color5_p); - __m256i color6 = _mm256_cvtepu8_epi16(color6_p); - __m256i color7 = _mm256_cvtepu8_epi16(color7_p); - - // multiply by weights - color0 = _mm256_mullo_epi16(color0, weights0); - color1 = _mm256_mullo_epi16(color1, weights1); - color2 = _mm256_mullo_epi16(color2, weights2); - color3 = _mm256_mullo_epi16(color3, weights3); - color4 = _mm256_mullo_epi16(color4, weights4); - color5 = _mm256_mullo_epi16(color5, weights5); - color6 = _mm256_mullo_epi16(color6, weights6); - color7 = _mm256_mullo_epi16(color7, weights7); - - // add. This order minimizes dependencies. - color0 = _mm256_add_epi16(color0, color1); - color2 = _mm256_add_epi16(color2, color3); - color4 = _mm256_add_epi16(color4, color5); - color6 = _mm256_add_epi16(color6, color7); - - color0 = _mm256_add_epi16(color0, color2); - color4 = _mm256_add_epi16(color4, color6); - - color0 = _mm256_add_epi16(color0, color4); - - // divide, because we multiplied our weights by 2^7. - color0 = _mm256_srli_epi16(color0, 6); - - // saturate - color0 = _mm256_min_epu16(sat, color0); - - // back to u8s. - auto hi = _mm256_extracti128_si256(color0, 1); - auto result = _mm_packus_epi16(_mm256_castsi256_si128(color0), hi); - - // store result - _mm_storeu_si128((__m128i*)(&out[color_quad * 4]), result); - } -#else - // unreachable. - (void)weights; - (void)in; - (void)out; - ASSERT(false); -#endif -} - -void interp_time_of_day_fast(const float weights[8], - const SwizzledTimeOfDay& in, +void interp_time_of_day_fast(const math::Vector itimes[4], + const SwizzledTimeOfDay& swizzled_colors, math::Vector* out) { - // even though the colors are 8 bits, we'll use 16 bits so we can saturate correctly - if (get_cpu_info().has_avx2) { - interp_time_of_day_fast_avx2(weights, in, out); - return; + math::Vector weights[8]; + for (int component = 0; component < 8; component++) { + int quad_idx = component / 2; + int word_off = (component % 2 * 2); + for (int channel = 0; channel < 4; channel++) { + int word = word_off + (channel / 2); + int hw_off = channel % 2; + + u32 word_val = itimes[quad_idx][word]; + u32 hw_val = hw_off ? (word_val >> 16) : word_val; + hw_val = hw_val & 0xff; + weights[component][channel] = hw_val; + } } // weight multipliers - __m128i weights0 = _mm_set1_epi16(weights[0] * 64.f); - __m128i weights1 = _mm_set1_epi16(weights[1] * 64.f); - __m128i weights2 = _mm_set1_epi16(weights[2] * 64.f); - __m128i weights3 = _mm_set1_epi16(weights[3] * 64.f); - __m128i weights4 = _mm_set1_epi16(weights[4] * 64.f); - __m128i weights5 = _mm_set1_epi16(weights[5] * 64.f); - __m128i weights6 = _mm_set1_epi16(weights[6] * 64.f); - __m128i weights7 = _mm_set1_epi16(weights[7] * 64.f); + __m128i weights0 = _mm_setr_epi16(weights[0][0], weights[0][1], weights[0][2], weights[0][3], + weights[0][0], weights[0][1], weights[0][2], weights[0][3]); + __m128i weights1 = _mm_setr_epi16(weights[1][0], weights[1][1], weights[1][2], weights[1][3], + weights[1][0], weights[1][1], weights[1][2], weights[1][3]); + __m128i weights2 = _mm_setr_epi16(weights[2][0], weights[2][1], weights[2][2], weights[2][3], + weights[2][0], weights[2][1], weights[2][2], weights[2][3]); + __m128i weights3 = _mm_setr_epi16(weights[3][0], weights[3][1], weights[3][2], weights[3][3], + weights[3][0], weights[3][1], weights[3][2], weights[3][3]); + __m128i weights4 = _mm_setr_epi16(weights[4][0], weights[4][1], weights[4][2], weights[4][3], + weights[4][0], weights[4][1], weights[4][2], weights[4][3]); + __m128i weights5 = _mm_setr_epi16(weights[5][0], weights[5][1], weights[5][2], weights[5][3], + weights[5][0], weights[5][1], weights[5][2], weights[5][3]); + __m128i weights6 = _mm_setr_epi16(weights[6][0], weights[6][1], weights[6][2], weights[6][3], + weights[6][0], weights[6][1], weights[6][2], weights[6][3]); + __m128i weights7 = _mm_setr_epi16(weights[7][0], weights[7][1], weights[7][2], weights[7][3], + weights[7][0], weights[7][1], weights[7][2], weights[7][3]); // saturation: note that alpha is saturated to 128 but the rest are 255. // TODO: maybe we should saturate to 255 for everybody (can do this using a single packus) and // change the shader to deal with this. __m128i sat = _mm_set_epi16(128, 255, 255, 255, 128, 255, 255, 255); - for (u32 color_quad = 0; color_quad < in.color_count / 4; color_quad++) { + for (u32 color_quad = 0; color_quad < swizzled_colors.color_count / 4; color_quad++) { // first, load colors. We put 16 bytes / register and don't touch the upper half because we // convert u8s to u16s. { - const u8* base = in.data.data() + color_quad * 128; + const u8* base = swizzled_colors.data.data() + color_quad * 128; __m128i color0_p = _mm_loadu_si64((const __m128i*)(base + 0)); __m128i color1_p = _mm_loadu_si64((const __m128i*)(base + 16)); __m128i color2_p = _mm_loadu_si64((const __m128i*)(base + 32)); @@ -404,7 +347,7 @@ void interp_time_of_day_fast(const float weights[8], } { - const u8* base = in.data.data() + color_quad * 128 + 8; + const u8* base = swizzled_colors.data.data() + color_quad * 128 + 8; __m128i color0_p = _mm_loadu_si64((const __m128i*)(base + 0)); __m128i color1_p = _mm_loadu_si64((const __m128i*)(base + 16)); __m128i color2_p = _mm_loadu_si64((const __m128i*)(base + 32)); diff --git a/game/graphics/opengl_renderer/background/background_common.h b/game/graphics/opengl_renderer/background/background_common.h index 1218b96cfe..2f24f7646a 100644 --- a/game/graphics/opengl_renderer/background/background_common.h +++ b/game/graphics/opengl_renderer/background/background_common.h @@ -22,7 +22,7 @@ struct TfragRenderSettings { math::Vector4f hvdf_offset; math::Vector4f fog; int tree_idx; - float time_of_day_weights[8] = {0}; + math::Vector itimes[4]; math::Vector4f planes[4]; bool debug_culling = false; const u8* occlusion_culling = nullptr; @@ -42,7 +42,8 @@ DoubleDraw setup_opengl_from_draw_mode(DrawMode mode, u32 tex_unit, bool mipmap) void first_tfrag_draw_setup(const TfragRenderSettings& settings, SharedRenderState* render_state, ShaderId shader); -void interp_time_of_day_slow(const float weights[8], + +void interp_time_of_day_slow(const math::Vector itimes[4], const std::vector& in, math::Vector* out); @@ -53,8 +54,8 @@ struct SwizzledTimeOfDay { SwizzledTimeOfDay swizzle_time_of_day(const std::vector& in); -void interp_time_of_day_fast(const float weights[8], - const SwizzledTimeOfDay& in, +void interp_time_of_day_fast(const math::Vector itimes[4], + const SwizzledTimeOfDay& swizzled_colors, math::Vector* out); void cull_check_all_slow(const math::Vector4f* planes, diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index d525ef0974..69159412a2 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -89,6 +89,7 @@ enum class BucketId { SHRUB_L0_SHRUB = 74, SHRUB_L1_SHRUB = 83, TFRAG_T_L0_ALPHA = 128, + TFRAG_W_L0_WATER = 255, DEBUG_NO_ZBUF1 = 318, DEBUG2 = 324, DEBUG_NO_ZBUF2 = 325, diff --git a/game/kernel/jak2/kscheme.cpp b/game/kernel/jak2/kscheme.cpp index 35afc14031..5e41a313e5 100644 --- a/game/kernel/jak2/kscheme.cpp +++ b/game/kernel/jak2/kscheme.cpp @@ -1460,7 +1460,7 @@ int InitHeapAndSymbol() { set_fixed_symbol(FIX_SYM_ASIZE_OF_BASIC_FUNC, "asize-of-basic-func", make_function_from_c((void*)asize_of_basic).offset); set_fixed_symbol(FIX_SYM_COPY_BASIC_FUNC, "asize-of-basic-func", - make_function_from_c((void*)copy_basic).offset); + make_function_from_c((void*)copy_basic, true).offset); set_fixed_symbol(FIX_SYM_DELETE_BASIC, "delete-basic", make_function_from_c((void*)delete_basic).offset); set_fixed_symbol(FIX_SYM_GLOBAL_HEAP, "global", kglobalheap.offset); @@ -1509,7 +1509,7 @@ int InitHeapAndSymbol() { set_fixed_type(FIX_SYM_BASIC, "basic", get_fixed_type_symbol(FIX_SYM_STRUCTURE), pack_type_flag(9, 0, 4), make_function_from_c((void*)print_basic).offset, make_function_from_c((void*)inspect_basic).offset); - basic_type->new_method = make_function_from_c((void*)new_basic); + basic_type->new_method = make_function_from_c((void*)new_basic, true); basic_type->delete_method = Ptr(u32_in_fixed_sym(FIX_SYM_DELETE_BASIC)); basic_type->asize_of_method = Ptr(u32_in_fixed_sym(FIX_SYM_ASIZE_OF_BASIC_FUNC)); basic_type->copy_method = Ptr(u32_in_fixed_sym(FIX_SYM_COPY_BASIC_FUNC)); @@ -1636,7 +1636,7 @@ int InitHeapAndSymbol() { pack_type_flag(9, 0, 16), 0, 0); Ptr(u32_in_fixed_sym(FIX_SYM_OBJECT_TYPE))->new_method = - make_function_from_c((void*)alloc_heap_object); + make_function_from_c((void*)alloc_heap_object, true); make_function_symbol_from_c("string->symbol", (void*)intern); make_function_symbol_from_c("print", (void*)sprint); diff --git a/game/mips2c/jak2_functions/debug.cpp b/game/mips2c/jak2_functions/debug.cpp index 52381010a6..ad8251f75a 100644 --- a/game/mips2c/jak2_functions/debug.cpp +++ b/game/mips2c/jak2_functions/debug.cpp @@ -26,7 +26,6 @@ void qfsrv_same_mtsab_4(ExecutionContext* c, int reg) { u64 execute(void* ctxt) { auto* c = (ExecutionContext*)ctxt; bool bc = false; - u32 call_addr = 0; bool cop1_bc = false; c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) c->lqc2(vf9, 0, a2); // lqc2 vf9, 0(a2) diff --git a/game/mips2c/jak2_functions/texture.cpp b/game/mips2c/jak2_functions/texture.cpp index 2d46af7838..7ef876ed79 100644 --- a/game/mips2c/jak2_functions/texture.cpp +++ b/game/mips2c/jak2_functions/texture.cpp @@ -8,7 +8,6 @@ namespace adgif_shader_texture_with_update { u64 execute(void* ctxt) { auto* c = (ExecutionContext*)ctxt; bool bc = false; - u32 call_addr = 0; c->ld(a2, 16, a0); // ld a2, 16(a0) c->addiu(v1, r0, 256); // addiu v1, r0, 256 c->andi(a2, a2, 513); // andi a2, a2, 513 diff --git a/goal_src/jak2/dgos/vi1.gd b/goal_src/jak2/dgos/vi1.gd new file mode 100644 index 0000000000..8708b026d7 --- /dev/null +++ b/goal_src/jak2/dgos/vi1.gd @@ -0,0 +1,21 @@ +("VI1.DGO" + ("tpage-3034.go" "tpage-3034") + ("tpage-3037.go" "tpage-3037") + ("tpage-3035.go" "tpage-3035") + ("tpage-3038.go" "tpage-3038") + ("tpage-3036.go" "tpage-3036") + ("tpage-2761.go" "tpage-2761") + ("tpage-3516.go" "tpage-3516") + ("daxter-highres-ag.go" "daxter-highres") + ("darkjak-highres-ag.go" "darkjak-highres") + ("metalkor-torso-ag.go" "metalkor-torso") + ("rift-ring-ag.go" "rift-ring") + ("vil-break-support-ag.go" "vil-break-support") + ("intro-flamer-ag.go" "intro-flamer") + ("rift-rider-donut-ag.go" "rift-rider-donut") + ("vil-windmill-sail-ag.go" "vil-windmill-sail") + ("vil-windspinner-ag.go" "vil-windspinner") + ("vil-sagesail-ag.go" "vil-sagesail") + ("particleman-ag.go" "particleman") + ("village1-vis.go" "village1-vis") + ) diff --git a/goal_src/jak2/engine/common_objs/base-plat.gc b/goal_src/jak2/engine/common_objs/base-plat.gc index 1f7d9dd634..266af63c93 100644 --- a/goal_src/jak2/engine/common_objs/base-plat.gc +++ b/goal_src/jak2/engine/common_objs/base-plat.gc @@ -133,7 +133,7 @@ (defmethod execute-effects base-plat ((obj base-plat)) "Executes various ancillary tasks with the platform, such as spawning particles or playing the associated sound" (if (nonzero? (-> obj part)) - (sparticle-launch-control-method-11 (-> obj part) (-> obj root-override trans)) + (spawn (-> obj part) (-> obj root-override trans)) ) (when (nonzero? (-> obj sound)) (set! (-> obj sound trans quad) (-> obj root-override trans quad)) diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index e8f121a6da..947af10092 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -322,17 +322,17 @@ ; (foreground-initialize-engines) ;; update time of day and wind effects. - ; (let ((gp-2 (-> pp clock))) - ; (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) - ; (set! (-> pp clock) (-> *display* bg-clock)) - ; (set! (-> pp clock) (-> *display* real-clock)) - ; ) + (let ((gp-2 (-> pp clock))) + (if (= (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> pp clock) (-> *display* bg-clock)) + (set! (-> pp clock) (-> *display* real-clock)) + ) ; (if (not (paused?)) ; (update-wind *wind-work* *wind-scales*) ; ) - ; (update-time-of-day *time-of-day-context*) - ; (set! (-> pp clock) gp-2) - ; ) + (update-time-of-day *time-of-day-context*) + (set! (-> pp clock) gp-2) + ) ;; draw the sky diff --git a/goal_src/jak2/engine/game/main.gc b/goal_src/jak2/engine/game/main.gc index c9c1dbdaec..c7b467c37b 100644 --- a/goal_src/jak2/engine/game/main.gc +++ b/goal_src/jak2/engine/game/main.gc @@ -720,7 +720,7 @@ (let ((gp-1 *display*)) (set! *teleport* #t) ; (update *setting-control*) - ; (init-time-of-day-context *time-of-day-context*) + (init-time-of-day-context *time-of-day-context*) (format 0 "about to display-sync~%") (display-sync gp-1) (format 0 "about to swap-display~%") diff --git a/goal_src/jak2/engine/gfx/background/background.gc b/goal_src/jak2/engine/gfx/background/background.gc index 526ca690b7..9e99aa7702 100644 --- a/goal_src/jak2/engine/gfx/background/background.gc +++ b/goal_src/jak2/engine/gfx/background/background.gc @@ -619,20 +619,10 @@ (set! (-> data-ptr 1) (-> *math-camera* plane 1 quad)) (set! (-> data-ptr 2) (-> *math-camera* plane 2 quad)) (set! (-> data-ptr 3) (-> *math-camera* plane 3 quad)) - - ;; hack to set time of day to something. - (let ((hack-itimes (new 'stack 'vector4w))) - (dotimes (i 4) - (set! (-> hack-itimes data i) #x60) - ) - (dotimes (i 4) - (set! (-> data-ptr (+ 4 i)) (-> hack-itimes quad)) - ) - ) - ; (set! (-> data-ptr 4) (-> lev mood itimes 0 quad)) todo, time of day - ; (set! (-> data-ptr 5) (-> lev mood itimes 1 quad)) - ; (set! (-> data-ptr 6) (-> lev mood itimes 2 quad)) - ; (set! (-> data-ptr 7) (-> lev mood itimes 3 quad)) + (set! (-> data-ptr 4) (-> lev mood-context itimes 0 quad)) + (set! (-> data-ptr 5) (-> lev mood-context itimes 1 quad)) + (set! (-> data-ptr 6) (-> lev mood-context itimes 2 quad)) + (set! (-> data-ptr 7) (-> lev mood-context itimes 3 quad)) (set! (-> data-ptr 8) (-> *math-camera* camera-temp vector 0 quad)) (set! (-> data-ptr 9) (-> *math-camera* camera-temp vector 1 quad)) (set! (-> data-ptr 10) (-> *math-camera* camera-temp vector 2 quad)) diff --git a/goal_src/jak2/engine/gfx/mood/mood.gc b/goal_src/jak2/engine/gfx/mood/mood.gc index 09eec9d249..bf6f1d1a38 100644 --- a/goal_src/jak2/engine/gfx/mood/mood.gc +++ b/goal_src/jak2/engine/gfx/mood/mood.gc @@ -144,8 +144,64 @@ ) ) -;; ERROR: Expression building failed: In update-mood-direction: Failed to match non-power of two case: t3-14 - +(defun update-mood-direction ((arg0 mood-context-core3) (arg1 mood-table) (arg2 float)) + (local-vars (sv-16 light-group)) + (let* ((v1-0 (-> arg1 mood-channel-group)) + (a2-1 (-> arg1 mood-direction-table)) + (a3-0 (the int arg2)) + (t0-1 (mod (+ a3-0 1) 24)) + (f0-3 (- arg2 (the float a3-0))) + (f1-3 (- 1.0 f0-3)) + (t1-0 0) + (a1-3 (-> arg0 light-group)) + ) + (set! sv-16 (-> arg0 light-group 1)) + (set! (-> a1-3 0 ambi extra x) 1.0) + (set! (-> a1-3 0 dir0 extra x) 0.0) + (set! (-> a1-3 0 dir1 extra x) 0.0) + (set! (-> a1-3 0 dir2 extra x) 0.0) + (dotimes (t2-2 4) + (let ((f2-6 (+ (* f1-3 (-> (the-as (pointer float) (+ (+ (* a3-0 4) (* 96 t2-2)) (the-as int v1-0))))) + (* f0-3 (-> (the-as (pointer float) (+ (+ (* t0-1 4) (* 96 t2-2)) (the-as int v1-0))))) + ) + ) + ) + (when (!= f2-6 0.0) + (set! (-> a1-3 0 lights t1-0 extra x) f2-6) + (set! (-> a1-3 0 lights t1-0 mask) (the-as uint (ash 2 t2-2))) + (set! (-> a1-3 0 lights t1-0 palette-index) (+ t2-2 1)) + (set! (-> a1-3 0 lights t1-0 direction quad) (-> a2-1 data t2-2 quad)) + (set! (-> (the-as (pointer uint128) (+ (the-as uint (-> a1-3 0 dir0 color)) (* 48 t1-0)))) + (-> arg0 times (+ t2-2 1) quad) + ) + (set! (-> arg0 times (+ t2-2 1) w) f2-6) + (+! t1-0 1) + ) + ) + ) + (set! (-> a1-3 0 ambi mask) (the-as uint 1)) + (set! (-> a1-3 0 ambi palette-index) 0) + (mem-copy! (the-as pointer sv-16) (the-as pointer a1-3) 192) + ) + (let ((f0-4 1.0)) + (let ((f1-4 1.1)) + (cond + ((or (>= 6.0 arg2) (>= arg2 18.0)) + (set! f0-4 f1-4) + ) + ((and (< 6.0 arg2) (< arg2 7.0)) + (+! f0-4 (* (- f1-4 f0-4) (- 7.0 arg2))) + ) + ((and (< 17.0 arg2) (< arg2 18.0)) + (+! f0-4 (* (- f1-4 f0-4) (+ -17.0 arg2))) + ) + ) + ) + (set! (-> sv-16 dir0 extra x) (* (-> sv-16 dir0 extra x) f0-4)) + (set! (-> sv-16 dir1 extra x) (* (-> sv-16 dir1 extra x) f0-4)) + (set! (-> sv-16 dir2 extra x) (* (-> sv-16 dir2 extra x) f0-4)) + ) + ) (defun update-mood-exterior ((arg0 mood-context-core3) (arg1 mood-table) (arg2 float) (arg3 int)) (local-vars (v0-1 object) (sv-32 mood-color) (sv-48 mood-color) (sv-64 vector)) (cond diff --git a/goal_src/jak2/engine/gfx/mood/time-of-day.gc b/goal_src/jak2/engine/gfx/mood/time-of-day.gc index 71c4c73b93..20a36790b7 100644 --- a/goal_src/jak2/engine/gfx/mood/time-of-day.gc +++ b/goal_src/jak2/engine/gfx/mood/time-of-day.gc @@ -5,7 +5,697 @@ ;; name in dgo: time-of-day ;; dgos: ENGINE, GAME +(define-extern time-of-day-effect (function none)) + ;; DECOMP BEGINS +;; definition for method 5 of type time-of-day-palette +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of time-of-day-palette ((obj time-of-day-palette)) + (the-as int (+ (-> obj type size) (* (* (-> obj height) (-> obj width)) 4))) + ) + +;; definition for method 10 of type time-of-day-proc +(defmethod deactivate time-of-day-proc ((obj time-of-day-proc)) + (if (nonzero? (-> obj sun)) + (kill-and-free-particles (-> obj sun)) + ) + (if (nonzero? (-> obj green-sun)) + (kill-and-free-particles (-> obj green-sun)) + ) + (if (nonzero? (-> obj moon)) + (kill-and-free-particles (-> obj moon)) + ) + ((method-of-type process deactivate) obj) + (none) + ) + +;; failed to figure out what this is: +(if (zero? time-of-day-effect) + (set! time-of-day-effect nothing) + ) + +;; definition for function time-of-day-update +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior time-of-day-update time-of-day-proc () + (time-of-day-effect) + (let ((gp-0 #t)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-3 (-> *level* level v1-0))) + (when (= (-> a0-3 status) 'active) + (if (-> a0-3 info use-camera-other) + (set! gp-0 #f) + ) + ) + ) + ) + (when (and (-> *setting-control* user-current weather) gp-0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (v1-8 (-> *math-camera* inv-camera-rot vector 2)) + ) + (set! (-> s5-0 quad) (-> *math-camera* trans quad)) + (vector-! s4-0 s5-0 (-> *math-camera* prev-trans)) + (let ((f0-1 (vector-dot s4-0 v1-8))) + (vector+float*! s5-0 s5-0 v1-8 (* 25.0 f0-1)) + ) + ) + (set! (-> s5-0 y) (-> *math-camera* trans y)) + ) + (if (< 0.0 (-> *setting-control* user-current rain)) + (update-rain (the-as target (-> *setting-control* user-current rain))) + ) + (if (< 0.0 (-> *setting-control* user-current snow)) + (update-snow (the-as target (-> *setting-control* user-current snow))) + ) + ) + (cond + ((and (>= (-> self time-of-day) 6.25) + (and (< (-> self time-of-day) 18.75) (-> *time-of-day-context* sky) gp-0) + ) + (when (and *dproc* (zero? (-> self sun-count))) + (spawn (-> self sun) (math-camera-pos)) + (+! (-> self sun-count) 1) + ) + ) + ((> (-> self sun-count) 0) + (kill-and-free-particles (-> self sun)) + (set! (-> self sun-count) 0) + 0 + ) + ) + (cond + ((and (or (>= (-> self time-of-day) 21.75) (>= 10.25 (-> self time-of-day))) + (-> *time-of-day-context* sky) + gp-0 + ) + (when (and *dproc* (zero? (-> self green-sun-count))) + (spawn (-> self green-sun) (math-camera-pos)) + (+! (-> self green-sun-count) 1) + ) + ) + ((> (-> self green-sun-count) 0) + (kill-and-free-particles (-> self green-sun)) + (set! (-> self green-sun-count) 0) + 0 + ) + ) + (set! gp-0 (and (or (>= 7.0 (-> self time-of-day)) (>= (-> self time-of-day) 17.0)) + (and (-> *time-of-day-context* sky) gp-0) + ) + ) + (cond + (gp-0 + (when (and *dproc* (zero? (-> self moon-count))) + (spawn (-> self moon) (math-camera-pos)) + (+! (-> self moon-count) 1) + ) + ) + ((> (-> self moon-count) 0) + (kill-and-free-particles (-> self moon)) + (set! (-> self moon-count) 0) + 0 + ) + ) + ) + (update-time-and-speed *sky-work* (-> self time-of-day) (-> self time-ratio)) + 0 + (none) + ) + +;; definition for function update-counters +(defbehavior update-counters time-of-day-proc () + (let ((v1-2 (-> *display* bg-clock frame-counter))) + 0 + (let ((v1-3 (* 60 v1-2))) + (set! (-> self old-frame) (-> self current-frame)) + (set! (-> self current-frame) (the-as uint v1-3)) + (set! (-> self frames) (the-as uint v1-3)) + (set! (-> self hours) (/ v1-3 #x107ac0)) + (let ((v1-4 (- v1-3 (* #x107ac0 (-> self hours))))) + (set! (-> self minutes) (/ v1-4 #x4650)) + (let ((v1-5 (- v1-4 (* #x4650 (-> self minutes))))) + (set! (-> self seconds) (/ v1-5 300)) + (- v1-5 (* 300 (-> self seconds))) + ) + ) + ) + ) + (let ((f0-1 (* 0.0000009259259 (the float (mod (the-as int (-> self frames)) #x18b8200))))) + (set! (-> self time-of-day) f0-1) + (set! (-> *time-of-day-context* time) f0-1) + f0-1 + ) + ) + +;; failed to figure out what this is: +(defstate time-of-day-tick (time-of-day-proc) + :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((v1-0 arg2)) + (the-as + object + (cond + ((= v1-0 'change) + (case (-> arg3 param 0) + (('ratio) + (let ((a0-5 (-> *display* bg-clock)) + (f0-0 (the-as float (-> arg3 param 1))) + ) + (set! (-> self time-ratio) f0-0) + (set! (-> self dest-time-ratio) f0-0) + (update-rates! a0-5 f0-0) + ) + ) + (('hour) + (update-counters) + (let ((v1-7 (-> *display* bg-clock frame-counter)) + (a0-7 #x69780) + (a1-5 (/ (the int (* 1080000.0 (the float (-> arg3 param 1)))) 60)) + ) + (set! (-> *display* bg-clock frame-counter) (+ (- v1-7 (the-as time-frame (mod v1-7 a0-7))) a0-7 a1-5)) + ) + (update-counters) + (-> self hours) + (kill-and-free-particles (-> self sun)) + (spawn (-> self sun) (math-camera-pos)) + (set! (-> self sun-count) 1) + (kill-and-free-particles (-> self green-sun)) + (spawn (-> self green-sun) (math-camera-pos)) + (set! (-> self green-sun-count) 1) + (kill-and-free-particles (-> self moon)) + (spawn (-> self moon) (math-camera-pos)) + (let ((v0-0 (the-as number 1))) + (set! (-> self moon-count) (the-as int v0-0)) + v0-0 + ) + ) + ) + ) + ((= v1-0 'ratio) + (-> self time-ratio) + ) + ((= v1-0 'day-length) + (if (= (-> self time-ratio) 0.0) + 0 + (/ 25920000.0 (-> self time-ratio)) + ) + ) + ((= v1-0 'time-frame) + (-> self frames) + ) + ((= v1-0 'time-of-day) + (-> self time-of-day) + ) + ((= v1-0 'time-of-day-norm) + (* 0.041666668 (-> self time-of-day)) + ) + ((= v1-0 'hour) + (-> self hours) + ) + ((= v1-0 'minute) + (-> self minutes) + ) + ((= v1-0 'second) + (-> self seconds) + ) + ((= v1-0 'dest-clock-ratio-set) + (set! (-> self dest-time-ratio) (the-as float (-> arg3 param 0))) + (let ((f0-12 (-> self time-ratio)) + (f1-5 (-> self dest-time-ratio)) + (f2-1 (/ 300.0 (the float (-> arg3 param 1)))) + ) + (set! (-> self dest-time-delta) (* (fabs (- f0-12 f1-5)) f2-1 (-> *display* real-clock seconds-per-frame))) + ) + (-> self dest-time-ratio) + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (if (!= (-> self time-ratio) 0.0) + (set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ) + (when (!= (-> self time-ratio) (-> self dest-time-ratio)) + (seek! (-> self time-ratio) (-> self dest-time-ratio) (-> self dest-time-delta)) + (update-rates! (-> *display* bg-clock) (-> self time-ratio)) + ) + (update-counters) + (suspend) + ) + #f + (none) + ) + :post time-of-day-update + ) + +;; definition for function init-time-of-day +(defbehavior init-time-of-day time-of-day-proc () + (stack-size-set! (-> self main-thread) 128) + (set! (-> self hours) 0) + (set! (-> self minutes) 0) + (set! (-> self seconds) 0) + (set! (-> self frames) (the-as uint 0)) + (set! (-> self time-of-day) 0.0) + (cond + (*time-of-day-fast* + (set! (-> self time-ratio) 60.0) + (set! (-> self dest-time-ratio) 60.0) + ) + (else + (set! (-> self time-ratio) 1.0) + (set! (-> self dest-time-ratio) 1.0) + ) + ) + (update-rates! (-> *display* bg-clock) (-> self time-ratio)) + (set! (-> self sun) (create-launch-control (-> *part-group-id-table* 3) self)) + (set! (-> self green-sun) (create-launch-control (-> *part-group-id-table* 4) self)) + (set! (-> self moon) (create-launch-control (-> *part-group-id-table* 5) self)) + (set! (-> self event-hook) (-> time-of-day-tick event)) + (go time-of-day-tick) + ) + +;; definition for function start-time-of-day +;; WARN: Return type mismatch (pointer time-of-day-proc) vs (pointer process). +(defun start-time-of-day () + (kill-by-name "time-of-day-proc" *active-pool*) + (set! *time-of-day* (process-spawn time-of-day-proc :init init-time-of-day :to *bg-pool*)) + (the-as (pointer process) *time-of-day*) + ) + +;; definition for function time-of-day-setup (defun time-of-day-setup ((arg0 symbol)) - #f) \ No newline at end of file + (when arg0 + (when (= (-> *time-of-day* 0 time-ratio) 0.0) + (send-event (ppointer->process *time-of-day*) 'change 'ratio (if *time-of-day-fast* + #x42700000 + #x3f800000 + ) + ) + (set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ) + ) + (!= (-> *time-of-day* 0 time-ratio) 0.0) + ) + +;; definition for function time-of-day-interp-colors +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function time-of-day-interp-colors-scratch +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function init-time-of-day-context +(defun init-time-of-day-context ((arg0 time-of-day-context)) + (set-vector! (-> arg0 title-light-group dir0 color) 0.82 0.82 0.82 1.0) + (set-vector! (-> arg0 title-light-group dir1 color) 2.0 2.0 2.0 1.0) + (set-vector! (-> arg0 title-light-group ambi color) 0.4 0.4 0.4 1.0) + (set! (-> arg0 title-light-group dir0 extra x) 1.0) + (set! (-> arg0 title-light-group dir1 extra x) 1.0) + (set! (-> arg0 title-light-group ambi extra x) 1.0) + (set-vector! (-> arg0 filter-color) 1.0 1.0 1.0 1.0) + (set! (-> arg0 overide-enable) #f) + (when *debug-segment* + (mem-copy! (the-as pointer *overide-mood-color-table*) (the-as pointer *no-cloud-mood-color-table*) 256) + (mem-copy! (the-as pointer *overide-mood-fog-table*) (the-as pointer *no-cloud-clear-mood-fog-table*) 384) + (dotimes (v1-8 8) + (set! (-> *overide-mood-color-table* data v1-8 lgt-color w) 1.0) + (set! (-> *overide-mood-color-table* data v1-8 amb-color w) 1.0) + (set! (-> *overide-mood-fog-table* data v1-8 fog-color w) 1.0) + (set! (-> *overide-mood-fog-table* data v1-8 fog-dists x) + (* 0.00024414062 (-> *overide-mood-fog-table* data v1-8 fog-dists x)) + ) + (set! (-> *overide-mood-fog-table* data v1-8 fog-dists y) + (* 0.00024414062 (-> *overide-mood-fog-table* data v1-8 fog-dists y)) + ) + (set-vector! (-> *time-of-day-context* times v1-8) 1.0 1.0 1.0 1.0) + ) + #f + ) + ) + +;; definition for function set-filter-color! +;; WARN: Return type mismatch int vs none. +(defun set-filter-color! ((arg0 float) (arg1 float) (arg2 float)) + (set-vector! (-> *time-of-day-context* filter-color) arg0 arg1 arg2 1.0) + 0 + (none) + ) + +;; definition for function tod-madd! +(defun tod-madd! ((arg0 vector) (arg1 vector) (arg2 vector)) + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.mov vf6 arg2) + (.lvf vf4 (&-> arg0 quad)) + (.lvf vf5 (&-> arg1 quad)) + (.mul.w.vf acc vf4 vf0) + (.add.mul.x.vf vf4 vf5 vf6 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + v0-0 + ) + ) + +;; definition for function update-environment-colors +(defun update-environment-colors ((arg0 time-of-day-context)) + (let* ((v1-0 (-> arg0 light-group)) + (s4-0 (-> v1-0 0 ambi color)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (-> arg0 current-prt-color)) + (s3-0 (-> arg0 current-env-color)) + ) + (vector4-lerp! s5-0 (-> v1-0 0 dir0 color) (-> v1-0 0 dir1 color) (-> v1-0 0 dir1 extra x)) + (when (and (= (-> s2-0 x) 0.0) (= (-> s2-0 y) 0.0) (= (-> s2-0 z) 0.0)) + (set! (-> s2-0 x) (* 0.5 (+ (-> s4-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x)))))) + (set! (-> s2-0 y) (* 0.5 (+ (-> s4-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y)))))) + (set! (-> s2-0 z) (* 0.5 (+ (-> s4-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z)))))) + (set! (-> s2-0 w) 1.0) + ) + (when (and (= (-> s3-0 x) 0.0) (= (-> s3-0 y) 0.0) (= (-> s3-0 z) 0.0)) + (set! (-> s3-0 x) (* 48.0 (+ (-> s5-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x)))))) + (set! (-> s3-0 y) (* 48.0 (+ (-> s5-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y)))))) + (set! (-> s3-0 z) (* 48.0 (+ (-> s5-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z)))))) + (set! (-> s3-0 w) 128.0) + ) + ) + (let* ((f0-23 (fmax (fmax (-> s4-0 x) (-> s4-0 y)) (-> s4-0 z))) + (f2-14 (fmax (fmax (-> s5-0 x) (-> s5-0 y)) (-> s5-0 z))) + (f0-27 (fmin 0.85 (- 1.0 (/ (* 0.5 f2-14) (+ f0-23 f2-14))))) + (v0-1 (-> arg0 current-shadow-color)) + ) + (set! (-> v0-1 x) f0-27) + (set! (-> v0-1 y) f0-27) + (set! (-> v0-1 z) f0-27) + (set! (-> v0-1 w) 1.0) + v0-1 + ) + ) + ) + +;; definition for function update-time-of-day +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-time-of-day ((arg0 time-of-day-context)) + (with-pp + (set! (-> arg0 exterior-level) #f) + (init-weather! *mood-control*) + (update-colors-for-time *sky-work* (-> arg0 time)) + (cond + ((-> arg0 overide-enable) + (mem-copy! (the-as pointer (-> *overide-table* mood-fog-table)) (the-as pointer *overide-mood-fog-table*) 384) + (mem-copy! + (the-as pointer (-> *overide-table* mood-color-table)) + (the-as pointer *overide-mood-color-table*) + 256 + ) + (dotimes (v1-7 8) + (vector-float*! + (the-as vector (-> *overide-table* mood-fog-table data v1-7)) + (the-as vector (-> *overide-table* mood-fog-table data v1-7)) + (-> *overide-table* mood-fog-table data v1-7 fog-color w) + ) + (vector-float*! + (the-as vector (-> *overide-table* mood-color-table data v1-7)) + (the-as vector (-> *overide-table* mood-color-table data v1-7)) + (-> *overide-table* mood-color-table data v1-7 lgt-color w) + ) + (vector-float*! + (the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32))) + (the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32))) + (-> *overide-table* mood-color-table data v1-7 amb-color w) + ) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-color w) 128.0) + (set! (-> *overide-table* mood-color-table data v1-7 lgt-color w) 0.0) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-dists x) + (* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists x)) + ) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-dists y) + (* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists y)) + ) + ) + (let ((s5-0 (-> *level* default-level mood-context))) + (clear-mood-times s5-0) + (update-mood-exterior s5-0 *overide-table* (-> arg0 time) 6) + (update-mood-itimes s5-0) + ) + ) + (else + (let ((s5-1 *mood-control*)) + (set! (-> arg0 current-clouds cloud-min) (-> s5-1 mood-clouds cloud-min)) + (set! (-> arg0 current-clouds cloud-max) (-> s5-1 mood-clouds cloud-max)) + (let ((s4-0 (-> *level* default-level mood-context))) + (clear-mood-times s4-0) + (update-mood-exterior s4-0 s5-1 (-> arg0 time) 6) + (update-mood-itimes s4-0) + ) + ) + ) + ) + (vector-float*! (-> arg0 filter) (-> arg0 filter-color) (-> arg0 filter-color w)) + (set! (-> arg0 sky) #f) + (set! (-> arg0 use-camera-other) #f) + (set! (-> arg0 target-interp) 0.0) + (let ((f0-16 4096000.0)) + (dotimes (v1-19 (-> *level* length)) + (let ((a0-50 (-> *level* level v1-19))) + (when (= (-> a0-50 status) 'active) + (if (-> a0-50 info sky) + (set! (-> arg0 sky) #t) + ) + (if (-> a0-50 info use-camera-other) + (set! (-> arg0 use-camera-other) (the-as basic #t)) + ) + (set! f0-16 (fmin f0-16 (-> a0-50 info fog-height))) + ) + ) + ) + (set-fog-height! f0-16) + ) + (if (-> arg0 sky) + (set! (-> (&-> *level* default-level texture-anim-array 9) 0) *sky-texture-anim-array*) + (set! (-> (&-> *level* default-level texture-anim-array 9) 0) #f) + ) + (let ((s5-2 (level-get-target-inside *level*))) + (dotimes (s4-1 6) + (let ((s3-0 (-> *level* level s4-1))) + (case (-> s3-0 status) + (('active 'loaded) + (when (not (paused?)) + (cond + ((= s3-0 s5-2) + (if *teleport* + (set! (-> arg0 interp s4-1) 1.0) + (set! (-> arg0 interp s4-1) (fmin 1.0 (+ 0.0166 (-> arg0 interp s4-1)))) + ) + ) + (*teleport* + (set! (-> arg0 interp s4-1) 0.0) + ) + (else + (set! (-> arg0 interp s4-1) (fmax 0.0 (+ -0.0166 (-> arg0 interp s4-1)))) + ) + ) + ) + (let ((s2-0 (-> pp clock))) + (set! (-> pp clock) (-> *display* real-clock)) + (clear-mood-times (-> s3-0 mood-context)) + ((-> s3-0 mood-func) (-> s3-0 mood-context) (-> arg0 time) s4-1) + (when (-> arg0 overide-enable) + (let ((s1-0 (new 'stack-no-clear 'vector))) + (dotimes (s0-0 8) + (let ((a1-48 (-> s3-0 mood-context times s0-0))) + (vector-float*! (the-as vector s1-0) (-> arg0 times s0-0) (-> arg0 times s0-0 w)) + (vector4-mul! (the-as vector4 a1-48) (the-as vector4 a1-48) (the-as vector4 s1-0)) + ) + ) + ) + ) + (update-mood-itimes (-> s3-0 mood-context)) + (set! (-> pp clock) s2-0) + ) + ) + (else + (set! (-> arg0 interp s4-1) 0.0) + ) + ) + ) + ) + ) + (if (and (-> arg0 exterior-level) (!= (-> *mood-control* lightning-flash) 0.0)) + (set! (-> *display* force-sync) (the-as uint 2)) + ) + (let ((f0-27 0.0)) + (dotimes (v1-79 6) + (+! f0-27 (-> arg0 interp v1-79)) + ) + (when (!= f0-27 0.0) + (dotimes (v1-83 6) + (set! (-> arg0 interp v1-83) (/ (-> arg0 interp v1-83) f0-27)) + ) + (let ((v1-86 (-> arg0 current-fog))) + (dotimes (a0-76 103) + (set! (-> (the-as (pointer int128) (+ (* a0-76 16) (the-as int v1-86)))) (the int128 0)) + ) + ) + (let ((s5-3 (-> arg0 current-fog)) + (s4-2 (-> *mood-control* range)) + ) + (set! (-> s4-2 quad) (the-as uint128 0)) + (set! (-> arg0 max-rain) 0.0) + (set! (-> arg0 fog-mult) 0.0) + (set! (-> arg0 ocean-alpha) 0.0) + (dotimes (s3-1 6) + (let ((f30-0 (-> arg0 interp s3-1)) + (s2-1 *level*) + ) + (when (!= f30-0 0.0) + (let ((a2-20 (+ (the-as uint (-> s2-1 level0 mood-context)) (* 5232 s3-1)))) + (vector4-array-madd! + (the-as (inline-array vector4) s5-3) + (the-as (inline-array vector4) s5-3) + (the-as (inline-array vector4) a2-20) + f30-0 + 103 + ) + ) + (let ((a2-21 (-> s2-1 level s3-1 info mood-range))) + (vector4-madd! (the-as vector4 s4-2) (the-as vector4 s4-2) (the-as vector4 a2-21) f30-0) + ) + (+! (-> arg0 max-rain) (* (-> s2-1 level s3-1 info max-rain) f30-0)) + (+! (-> arg0 fog-mult) (* (-> s2-1 level s3-1 info fog-mult) f30-0)) + (+! (-> arg0 ocean-alpha) (* (-> s2-1 level s3-1 info ocean-alpha) f30-0)) + ) + ) + ) + ) + (dotimes (s5-4 8) + (dotimes (s4-3 3) + (let ((v1-119 (+ (+ (* 48 s4-3) 140 (* 192 s5-4)) (the-as int arg0)))) + (vector-normalize! (the-as vector (+ v1-119 0)) 1.0) + ) + ) + ) + ) + ) + (if (and (-> arg0 overide-enable) (!= (-> *time-of-day-context* mode) 8)) + (mem-copy! + (the-as pointer (-> arg0 current-fog)) + (the-as + pointer + (-> *overide-table* + mood-fog-table + data + (the-as uint (logand (-> *time-of-day-context* mode) (time-of-day-palette-id unk0 unk1 unk2))) + ) + ) + 48 + ) + ) + (update-environment-colors arg0) + (let ((v1-134 (-> arg0 current-fog))) + (let ((a0-87 (-> v1-134 fog-color))) + (set! *fog-color* + (new 'static 'rgba :r (the int (-> a0-87 x)) :g (the int (-> a0-87 y)) :b (the int (-> a0-87 z))) + ) + (set! (-> *fog-texture-work* color) + (the-as + uint + (logior (logior (logior (shr (shl (the int (-> a0-87 z)) 56) 40) (shr (shl (the int (-> a0-87 y)) 56) 48)) + (shr (shl (the int (-> a0-87 x)) 56) 56) + ) + (shr (shl (the int (-> a0-87 x)) 56) 56) + ) + ) + ) + ) + (let ((a0-92 (-> v1-134 erase-color))) + (set! (-> arg0 erase-color) + (new 'static 'rgba :a #x80 :b (the int (-> a0-92 z)) :g (the int (-> a0-92 y)) :r (the int (-> a0-92 x))) + ) + ) + (let ((f0-58 (-> v1-134 fog-dists x)) + (f1-18 (-> v1-134 fog-dists y)) + ) + (let ((f3-0 (-> v1-134 fog-dists z)) + (f2-2 (-> v1-134 fog-dists w)) + ) + (set! (-> *math-camera* fog-start) f0-58) + (set! (-> *math-camera* fog-end) f1-18) + (set! (-> *math-camera* fog-max) f3-0) + (set! (-> *math-camera* fog-min) f2-2) + (set! (-> *fog-texture-work* alpha-near) (* 0.003921569 (the float (- 255 (the int f3-0))))) + (set! (-> *fog-texture-work* alpha-far) (* 0.003921569 (the float (- 255 (the int f2-2))))) + ) + (set! (-> *fog-texture-work* alpha-delta) + (- (-> *fog-texture-work* alpha-far) (-> *fog-texture-work* alpha-near)) + ) + (set! (-> *fog-texture-work* fog-near) f0-58) + (set! (-> *fog-texture-work* fog-far) f1-18) + (set! (-> *fog-texture-work* fog-delta) (- f1-18 f0-58)) + ) + ) + (set-cloud-minmax! (-> arg0 current-clouds cloud-min) (-> arg0 current-clouds cloud-max)) + (reset! *palette-fade-controls*) + 0 + (none) + ) + ) + +;; definition for function calc-fade-from-fog +(defun calc-fade-from-fog ((arg0 vector)) + (let* ((f0-0 (vector-vector-distance (math-camera-pos) arg0)) + (v1-1 (-> *time-of-day-context* current-fog)) + (f1-0 (-> v1-1 fog-dists x)) + (f2-0 (-> v1-1 fog-dists y)) + (f3-1 (* 0.003921569 (-> v1-1 fog-dists w))) + (f4-2 (* 0.003921569 (-> v1-1 fog-dists z))) + ) + (+ f4-2 (* (fmax 0.0 (fmin 1.0 (/ (- f0-0 f1-0) (- f2-0 f1-0)))) (- f3-1 f4-2))) + ) + ) + +;; definition for method 10 of type palette-fade-controls +;; INFO: Used lq/sq +(defmethod set-fade! palette-fade-controls ((obj palette-fade-controls) (arg0 int) (arg1 float) (arg2 float) (arg3 vector)) + (cond + ((and (>= arg0 0) (< arg0 8)) + (let ((v1-3 (-> obj control arg0))) + (when (< arg2 (-> v1-3 actor-dist)) + (if arg3 + (set! (-> v1-3 trans quad) (-> arg3 quad)) + ) + (set! (-> v1-3 fade) (fmax 0.0 (fmin 1.993 arg1))) + (set! (-> v1-3 actor-dist) arg2) + ) + ) + ) + (else + (format 0 "ERROR: Bogus palette-fade-control index!~%") + ) + ) + ) + +;; definition for method 9 of type palette-fade-controls +;; WARN: Return type mismatch int vs none. +(defmethod reset! palette-fade-controls ((obj palette-fade-controls)) + (countdown (v1-0 8) + (let ((a1-2 (-> obj control v1-0))) + (set! (-> a1-2 fade) 0.0) + (set! (-> a1-2 actor-dist) 4096000000.0) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(start-time-of-day) diff --git a/goal_src/jak2/engine/gfx/mood/weather-part.gc b/goal_src/jak2/engine/gfx/mood/weather-part.gc index 7307116d00..8dcc745bb0 100644 --- a/goal_src/jak2/engine/gfx/mood/weather-part.gc +++ b/goal_src/jak2/engine/gfx/mood/weather-part.gc @@ -7,3 +7,56 @@ ;; DECOMP BEGINS +;; all these are stubbed out + +(defun update-rain ((a0-0 target)) + (none) + ) + +(defun update-snow ((arg target)) + (none)) + +(set! (-> *part-group-id-table* 4) + (new 'static 'sparticle-launch-group + :length 0 + :duration #xbb8 + :linger-duration #x5dc + :flags (sp-group-flag always-draw) + :name "group-green-sun" + :launcher (new 'static 'inline-array sparticle-group-item 0) + :scale-x 1.0 + :scale-y 1.0 + :scale-z 1.0 + :bounds (new 'static 'sphere :w 286720.0) + ) + ) + +(set! (-> *part-group-id-table* 3) + (new 'static 'sparticle-launch-group + :length 0 + :duration #xbb8 + :linger-duration #x5dc + :flags (sp-group-flag always-draw) + :name "group-sun" + :launcher (new 'static 'inline-array sparticle-group-item 0) + :scale-x 1.0 + :scale-y 1.0 + :scale-z 1.0 + :bounds (new 'static 'sphere :w 286720.0) + ) + ) + +(set! (-> *part-group-id-table* 5) + (new 'static 'sparticle-launch-group + :length 0 + :duration #xbb8 + :linger-duration #x5dc + :flags (sp-group-flag always-draw) + :name "group-moon" + :launcher (new 'static 'inline-array sparticle-group-item 0) + :scale-x 1.0 + :scale-y 1.0 + :scale-z 1.0 + :bounds (new 'static 'sphere :w 286720.0) + ) + ) diff --git a/goal_src/jak2/engine/gfx/sky/sky-h.gc b/goal_src/jak2/engine/gfx/sky/sky-h.gc index 8f9cfc0aaa..d628c676c4 100644 --- a/goal_src/jak2/engine/gfx/sky/sky-h.gc +++ b/goal_src/jak2/engine/gfx/sky/sky-h.gc @@ -231,8 +231,8 @@ (:methods (init-sun-data! (_type_ int float float float) none 9) (init-orbit-settings! (_type_ int float float float float float float) none 10) - (sky-work-method-11 () none 11) - (sky-work-method-12 () none 12) + (update-colors-for-time (_type_ float) none 11) + (update-time-and-speed (_type_ float float) none 12) (draw (_type_) none 13) (sky-work-method-14 () none 14) (sky-work-method-15 () none 15) @@ -263,6 +263,4 @@ 0 - - - +(define-extern *sky-work* sky-work) \ No newline at end of file diff --git a/goal_src/jak2/engine/gfx/sky/sky-tng.gc b/goal_src/jak2/engine/gfx/sky/sky-tng.gc index 712a2c422d..88513567d4 100644 --- a/goal_src/jak2/engine/gfx/sky/sky-tng.gc +++ b/goal_src/jak2/engine/gfx/sky/sky-tng.gc @@ -7,3 +7,66 @@ ;; DECOMP BEGINS + +;; TODO +(defmethod update-time-and-speed sky-work ((obj sky-work) (arg0 float) (arg1 float)) + (if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest)) + (set! arg1 (* 10.0 arg1)) + ) + (sky-make-sun-data obj 0 arg0) + (sky-make-sun-data obj 1 arg0) + (sky-make-moon-data obj arg0) + (+! (-> obj off-s) (the int (* -8.0 arg1))) + (+! (-> obj off-t) (the int (* 2.0 arg1))) + (set! (-> obj time) arg0) + 0 + (none) + ) + +(defmethod update-colors-for-time sky-work ((obj sky-work) (arg0 float)) + 0 + 0 + 0.0 + (let ((s5-0 *no-cloud-mood-color-table*)) + (let ((s3-0 (-> *level* default-level mood-context)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (let* ((v1-3 (the int arg0)) + (f0-4 (- arg0 (the float v1-3))) + (f1-3 (- 1.0 f0-4)) + (a0-3 (/ v1-3 24)) + (a1-2 (-> *mood-interp-table* hour (- v1-3 (* 24 a0-3)))) + (a0-6 (-> a1-2 snapshot1)) + (v1-7 (-> a1-2 snapshot2)) + (f0-6 (+ (* f1-3 (-> a1-2 morph-start)) (* f0-4 (-> a1-2 morph-end)))) + ) + (cond + ((= a0-6 v1-7) + (set! (-> obj sun0-color quad) (-> s5-0 data a0-6 lgt-color quad)) + ) + (else + (let ((a1-5 (-> s5-0 data a0-6)) + (v1-11 (-> s5-0 data v1-7)) + ) + (vector4-lerp! (the-as vector (-> obj sun0-color)) (-> a1-5 lgt-color) (-> v1-11 lgt-color) f0-6) + ) + ) + ) + ) + (set! (-> obj sun0-color-lower quad) (-> s3-0 times 1 quad)) + (set! (-> obj ambi-color-lower quad) (-> s3-0 times 0 quad)) + (set-vector! s4-0 1.9921875 1.9921875 1.9921875 1.0) + (vector4-lerp! + (the-as vector (-> obj ambi-color)) + (the-as vector (-> obj ambi-color-lower)) + s4-0 + (-> *mood-control* lightning-flash) + ) + ) + (set! (-> obj sun0-color quad) (-> obj sun0-color quad)) + (set! (-> obj sun1-color quad) (-> s5-0 data 7 lgt-color quad)) + (set! (-> obj moon-color quad) (-> s5-0 data 6 lgt-color quad)) + ) + 0 + (none) + ) \ No newline at end of file diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc index 2c81c626d5..1257ff51e3 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher-h.gc @@ -109,6 +109,7 @@ (start-dead 2) (launch-asap 3) (bit6 6) + (bit7 7) ) (defenum sp-launch-state-flags @@ -279,7 +280,7 @@ (:methods (initialize (_type_ sparticle-launch-group process) none 9) (sparticle-launch-control-method-10 (_type_ vector) symbol 10) - (sparticle-launch-control-method-11 (_type_ vector) none 11) + (spawn (_type_ vector) none 11) (sparticle-launch-control-method-12 (_type_ matrix) none 12) (sparticle-launch-control-method-13 (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) diff --git a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc index efc800725a..da3aabcdba 100644 --- a/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc +++ b/goal_src/jak2/engine/gfx/sprite/particles/sparticle-launcher.gc @@ -569,6 +569,11 @@ ;; ERROR: failed type prop at 32: Could not figure out load: (set! a1 (l.w (+ gp 104))) +;; TODO stub +(defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) + (none) + ) + (defmethod initialize sparticle-launch-control ((obj sparticle-launch-control) (arg0 sparticle-launch-group) (arg1 process)) (with-pp (let ((s5-0 0)) @@ -655,6 +660,7 @@ ;; WARN: Return type mismatch object vs sparticle-launch-control. (defmethod create-launch-control sparticle-launch-group ((obj sparticle-launch-group) (arg0 process)) + (format 0 "create launch control: ~A ~D~%" arg0 (-> obj length)) (let ((gp-0 (the-as object (new 'process 'sparticle-launch-control (-> obj length))))) (when (zero? (the-as sparticle-launch-control gp-0)) (go process-drawable-art-error "memory") @@ -762,7 +768,7 @@ ) ) ) - (sparticle-launch-control-method-11 obj (-> arg0 trans)) + (spawn obj (-> arg0 trans)) (none) ) @@ -808,7 +814,7 @@ ) ) ) - (sparticle-launch-control-method-11 obj (vector<-cspace! (-> obj origin trans) arg0)) + (spawn obj (vector<-cspace! (-> obj origin trans) arg0)) (none) ) diff --git a/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc b/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc index 685ad33d4a..90094ac4d0 100644 --- a/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc +++ b/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc @@ -47,22 +47,22 @@ ) (deftype texture-anim (structure) - ((num-layers uint32 :offset-assert 0) - (func basic :offset-assert 4) - (func-id basic :offset 4) - (init-func basic :offset-assert 8) - (init-func-id basic :offset 8) - (tex basic :offset-assert 12) - (tex-name basic :offset-assert 16) - (extra vector :inline :offset-assert 32) - (color uint32 :offset-assert 48) - (frame-time float :offset-assert 52) - (frame-delta float :offset-assert 56) - (frame-mod float :offset-assert 60) - (test uint64 :offset-assert 64) - (alpha uint64 :offset-assert 72) - (clamp uint64 :offset-assert 80) - (data uint8 :dynamic :offset-assert 88) + ((num-layers uint32 :offset-assert 0) + (func basic :offset-assert 4) + (func-id basic :offset 4) + (init-func basic :offset-assert 8) + (init-func-id basic :offset 8) + (tex basic :offset-assert 12) + (tex-name basic :offset-assert 16) + (extra vector :inline :offset-assert 32) + (color rgba :offset-assert 48) + (frame-time float :offset-assert 52) + (frame-delta float :offset-assert 56) + (frame-mod float :offset-assert 60) + (test gs-test :offset-assert 64) + (alpha gs-alpha :offset-assert 72) + (clamp gs-clamp :offset-assert 80) + (data texture-anim-layer :dynamic :offset-assert 88) ) :method-count-assert 11 :size-assert #x58 diff --git a/goal_src/jak2/engine/gfx/texture/texture-anim-tables.gc b/goal_src/jak2/engine/gfx/texture/texture-anim-tables.gc index dec86f7299..71bc356cd4 100644 --- a/goal_src/jak2/engine/gfx/texture/texture-anim-tables.gc +++ b/goal_src/jak2/engine/gfx/texture/texture-anim-tables.gc @@ -12,4 +12,12 @@ (define-extern *skull-gem-texture-anim-array* texture-anim-array) (define-extern *waterfall-texture-anim-array* texture-anim-array) (define-extern *waterfall-b-texture-anim-array* texture-anim-array) -(define-extern *bomb-texture-anim-array* texture-anim-array) \ No newline at end of file +(define-extern *bomb-texture-anim-array* texture-anim-array) + +(defun set-fog-height! ((arg0 float)) + (none) + ) + +(defun set-cloud-minmax! ((a0-0 float) (a1-0 float)) + (none) + ) \ No newline at end of file diff --git a/goal_src/jak2/engine/target/board/target-board.gc b/goal_src/jak2/engine/target/board/target-board.gc index 18d100a25b..e8362e7fad 100644 --- a/goal_src/jak2/engine/target/board/target-board.gc +++ b/goal_src/jak2/engine/target/board/target-board.gc @@ -1060,7 +1060,7 @@ ) ) ) - (sparticle-launch-control-method-11 (-> self board part-control) (-> self control trans)) + (spawn (-> self board part-control) (-> self control trans)) (let ((t9-26 (method-of-object (-> self skel effect) effect-control-method-10))) 'effect-board-poof 0 diff --git a/goal_src/jak2/game.gp b/goal_src/jak2/game.gp index dd0aba8c02..04c7a7a5c1 100644 --- a/goal_src/jak2/game.gp +++ b/goal_src/jak2/game.gp @@ -667,6 +667,13 @@ "fort-entry-gate-ag" ) +;;;;;;;;;;;;;;;;;;;;; +;; COMMON +;;;;;;;;;;;;;;;;;;;;; + +(copy-gos + "daxter-highres-ag") + ;;;;;;;;;;;;;;;;;;;;; ;; PRISON ;;;;;;;;;;;;;;;;;;;;; @@ -684,7 +691,6 @@ (copy-textures 1578 1950 1579 2647) (copy-gos - "daxter-highres-ag" "prsn-torture-ag" "prsn-chair-shackle-ag" "prsn-hang-cell-ag" @@ -815,6 +821,27 @@ "ctysluma-vis" ) +;;;;;;;;;;;;;;;;;;;;; +;; VILLAGE 1 +;;;;;;;;;;;;;;;;;;;;; + +(cgo "VI1.DGO" "vi1.gd") +(copy-textures 3034 3037 3035 3038 3036 2761 3516) + +(copy-gos +"darkjak-highres-ag" +"metalkor-torso-ag" +"rift-ring-ag" +"vil-break-support-ag" +"intro-flamer-ag" +"rift-rider-donut-ag" +"vil-windmill-sail-ag" +"vil-windspinner-ag" +"vil-sagesail-ag" +"particleman-ag" +"village1-vis" +) + ;;;;;;;;;;;;;;;;;;;;; ;; ISO Group ;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/jak2/kernel/gstate.gc b/goal_src/jak2/kernel/gstate.gc index 1529628934..788460e8a7 100644 --- a/goal_src/jak2/kernel/gstate.gc +++ b/goal_src/jak2/kernel/gstate.gc @@ -105,7 +105,7 @@ It type checks the arguments for the entry function. (with-gensyms (new-proc) `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size)))) (when ,new-proc - ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ,proc-type)) ,stack) + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) (run-next-time-in-process ,new-proc ,func ,@args) (the (pointer ,proc-type) (-> ,new-proc ppointer)) ) @@ -120,7 +120,7 @@ It type checks the arguments for the entry function. (with-gensyms (new-proc) `(let ((,new-proc (the-as ,proc-type (get-process ,from ,proc-type ,stack-size)))) (when ,new-proc - ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ,proc-type)) ,stack) + ((method-of-type ,proc-type activate) ,new-proc ,to ,(if name name `(symbol->string ',proc-type)) ,stack) (run-now-in-process ,new-proc ,(if init init (string->symbol (fmt #f "{}-init-by-other" proc-type))) ,@args) (the (pointer ,proc-type) (-> ,new-proc ppointer)) ) diff --git a/goal_src/jak2/levels/common/elec-gate.gc b/goal_src/jak2/levels/common/elec-gate.gc index 5c233dede1..f5d02b43eb 100644 --- a/goal_src/jak2/levels/common/elec-gate.gc +++ b/goal_src/jak2/levels/common/elec-gate.gc @@ -739,10 +739,10 @@ (defmethod spawn-particles elec-gate ((obj elec-gate) (sparticle-lc sparticle-launch-control)) "TODO - Calls [[sparticle-launch-control::11]] on `part-spawner-left` and `part-spawner-right` if they are defined" (if (-> obj part-spawner-left) - (sparticle-launch-control-method-11 sparticle-lc (the-as vector (&-> (-> obj part-spawner-left child) 8))) + (spawn sparticle-lc (the-as vector (&-> (-> obj part-spawner-left child) 8))) ) (if (-> obj part-spawner-right) - (sparticle-launch-control-method-11 sparticle-lc (the-as vector (&-> (-> obj part-spawner-right child) 8))) + (spawn sparticle-lc (the-as vector (&-> (-> obj part-spawner-right child) 8))) ) 0 (none) diff --git a/scripts/decomp_progress.py b/scripts/decomp_progress.py index 755f2b9757..899ac87fb7 100644 --- a/scripts/decomp_progress.py +++ b/scripts/decomp_progress.py @@ -4,7 +4,7 @@ import argparse ### Script to track decompilation progress. -### Example usage: python3 scripts/decomp_progress.py ~/jak-project/goal_src +### Example usage: python3 scripts/decomp_progress.py ~/jak-project/goal_src/jak2 def get_goal_files(root_dir, ext = "*.gc"): """Get all GOAL source files under root_dir.""" @@ -29,7 +29,7 @@ def print_table(stats, total_gc_files): print("-------------------------------------") print("| {: <24} | {: >6} |".format("TOTAL", total_lines)) print("-------------------------------------") - estimated_lines = 500000 + estimated_lines = 1000000 print("Progress: {}/{} lines ({:.2f}%)".format(total_lines, estimated_lines, 100. * total_lines / estimated_lines)) print("{}/{} files modified from template ({:.2f}%)".format(len(stats), total_gc_files, 100. * len(stats) / total_gc_files)) @@ -41,8 +41,7 @@ def main(): args = parser.parse_args() all_files = get_goal_files(args.goal_src) - ref_files = get_goal_files(args.goal_src + "/../test/", "*_REF.gc") - + ref_files = get_goal_files(args.goal_src + "/../../test/decompiler/reference/jak2", "*_REF.gc") ref_files_no_ext = [os.path.basename(fn)[:-7] for fn in ref_files] diff --git a/test/decompiler/reference/jak2/engine/common_objs/base-plat_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/base-plat_REF.gc index a1fcaca7e9..48f137d907 100644 --- a/test/decompiler/reference/jak2/engine/common_objs/base-plat_REF.gc +++ b/test/decompiler/reference/jak2/engine/common_objs/base-plat_REF.gc @@ -149,7 +149,7 @@ (defmethod execute-effects base-plat ((obj base-plat)) "Executes various ancillary tasks with the platform, such as spawning particles or playing the associated sound" (if (nonzero? (-> obj part)) - (sparticle-launch-control-method-11 (-> obj part) (-> obj root-override trans)) + (spawn (-> obj part) (-> obj root-override trans)) ) (when (nonzero? (-> obj sound)) (set! (-> obj sound trans quad) (-> obj root-override trans quad)) diff --git a/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc b/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc new file mode 100644 index 0000000000..1ed80206d4 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/mood/time-of-day_REF.gc @@ -0,0 +1,697 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 5 of type time-of-day-palette +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of time-of-day-palette ((obj time-of-day-palette)) + (the-as int (+ (-> obj type size) (* (* (-> obj height) (-> obj width)) 4))) + ) + +;; definition for method 10 of type time-of-day-proc +(defmethod deactivate time-of-day-proc ((obj time-of-day-proc)) + (if (nonzero? (-> obj sun)) + (kill-and-free-particles (-> obj sun)) + ) + (if (nonzero? (-> obj green-sun)) + (kill-and-free-particles (-> obj green-sun)) + ) + (if (nonzero? (-> obj moon)) + (kill-and-free-particles (-> obj moon)) + ) + ((method-of-type process deactivate) obj) + (none) + ) + +;; failed to figure out what this is: +(if (zero? time-of-day-effect) + (set! time-of-day-effect nothing) + ) + +;; definition for function time-of-day-update +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior time-of-day-update time-of-day-proc () + (time-of-day-effect) + (let ((gp-0 #t)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-3 (-> *level* level v1-0))) + (when (= (-> a0-3 status) 'active) + (if (-> a0-3 info use-camera-other) + (set! gp-0 #f) + ) + ) + ) + ) + (when (and (-> *setting-control* user-current weather) gp-0) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (let ((s4-0 (new 'stack-no-clear 'vector)) + (v1-8 (-> *math-camera* inv-camera-rot vector 2)) + ) + (set! (-> s5-0 quad) (-> *math-camera* trans quad)) + (vector-! s4-0 s5-0 (-> *math-camera* prev-trans)) + (let ((f0-1 (vector-dot s4-0 v1-8))) + (vector+float*! s5-0 s5-0 v1-8 (* 25.0 f0-1)) + ) + ) + (set! (-> s5-0 y) (-> *math-camera* trans y)) + ) + (if (< 0.0 (-> *setting-control* user-current rain)) + (update-rain (the-as target (-> *setting-control* user-current rain))) + ) + (if (< 0.0 (-> *setting-control* user-current snow)) + (update-snow (the-as target (-> *setting-control* user-current snow))) + ) + ) + (cond + ((and (>= (-> self time-of-day) 6.25) + (and (< (-> self time-of-day) 18.75) (-> *time-of-day-context* sky) gp-0) + ) + (when (and *dproc* (zero? (-> self sun-count))) + (spawn (-> self sun) (math-camera-pos)) + (+! (-> self sun-count) 1) + ) + ) + ((> (-> self sun-count) 0) + (kill-and-free-particles (-> self sun)) + (set! (-> self sun-count) 0) + 0 + ) + ) + (cond + ((and (or (>= (-> self time-of-day) 21.75) (>= 10.25 (-> self time-of-day))) + (-> *time-of-day-context* sky) + gp-0 + ) + (when (and *dproc* (zero? (-> self green-sun-count))) + (spawn (-> self green-sun) (math-camera-pos)) + (+! (-> self green-sun-count) 1) + ) + ) + ((> (-> self green-sun-count) 0) + (kill-and-free-particles (-> self green-sun)) + (set! (-> self green-sun-count) 0) + 0 + ) + ) + (set! gp-0 (and (or (>= 7.0 (-> self time-of-day)) (>= (-> self time-of-day) 17.0)) + (and (-> *time-of-day-context* sky) gp-0) + ) + ) + (cond + (gp-0 + (when (and *dproc* (zero? (-> self moon-count))) + (spawn (-> self moon) (math-camera-pos)) + (+! (-> self moon-count) 1) + ) + ) + ((> (-> self moon-count) 0) + (kill-and-free-particles (-> self moon)) + (set! (-> self moon-count) 0) + 0 + ) + ) + ) + (update-time-and-speed *sky-work* (-> self time-of-day) (-> self time-ratio)) + 0 + (none) + ) + +;; definition for function update-counters +(defbehavior update-counters time-of-day-proc () + (let ((v1-2 (-> *display* bg-clock frame-counter))) + 0 + (let ((v1-3 (* 60 v1-2))) + (set! (-> self old-frame) (-> self current-frame)) + (set! (-> self current-frame) (the-as uint v1-3)) + (set! (-> self frames) (the-as uint v1-3)) + (set! (-> self hours) (/ v1-3 #x107ac0)) + (let ((v1-4 (- v1-3 (* #x107ac0 (-> self hours))))) + (set! (-> self minutes) (/ v1-4 #x4650)) + (let ((v1-5 (- v1-4 (* #x4650 (-> self minutes))))) + (set! (-> self seconds) (/ v1-5 300)) + (- v1-5 (* 300 (-> self seconds))) + ) + ) + ) + ) + (let ((f0-1 (* 0.0000009259259 (the float (mod (the-as int (-> self frames)) #x18b8200))))) + (set! (-> self time-of-day) f0-1) + (set! (-> *time-of-day-context* time) f0-1) + f0-1 + ) + ) + +;; failed to figure out what this is: +(defstate time-of-day-tick (time-of-day-proc) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (let ((v1-0 event-type)) + (the-as + object + (cond + ((= v1-0 'change) + (case (-> event param 0) + (('ratio) + (let ((a0-5 (-> *display* bg-clock)) + (f0-0 (the-as float (-> event param 1))) + ) + (set! (-> self time-ratio) f0-0) + (set! (-> self dest-time-ratio) f0-0) + (update-rates! a0-5 f0-0) + ) + ) + (('hour) + (update-counters) + (let ((v1-7 (-> *display* bg-clock frame-counter)) + (a0-7 #x69780) + (a1-5 (/ (the int (* 1080000.0 (the float (-> event param 1)))) 60)) + ) + (set! (-> *display* bg-clock frame-counter) (+ (- v1-7 (the-as time-frame (mod v1-7 a0-7))) a0-7 a1-5)) + ) + (update-counters) + (-> self hours) + (kill-and-free-particles (-> self sun)) + (spawn (-> self sun) (math-camera-pos)) + (set! (-> self sun-count) 1) + (kill-and-free-particles (-> self green-sun)) + (spawn (-> self green-sun) (math-camera-pos)) + (set! (-> self green-sun-count) 1) + (kill-and-free-particles (-> self moon)) + (spawn (-> self moon) (math-camera-pos)) + (let ((v0-0 (the-as number 1))) + (set! (-> self moon-count) (the-as int v0-0)) + v0-0 + ) + ) + ) + ) + ((= v1-0 'ratio) + (-> self time-ratio) + ) + ((= v1-0 'day-length) + (if (= (-> self time-ratio) 0.0) + 0 + (/ 25920000.0 (-> self time-ratio)) + ) + ) + ((= v1-0 'time-frame) + (-> self frames) + ) + ((= v1-0 'time-of-day) + (-> self time-of-day) + ) + ((= v1-0 'time-of-day-norm) + (* 0.041666668 (-> self time-of-day)) + ) + ((= v1-0 'hour) + (-> self hours) + ) + ((= v1-0 'minute) + (-> self minutes) + ) + ((= v1-0 'second) + (-> self seconds) + ) + ((= v1-0 'dest-clock-ratio-set) + (set! (-> self dest-time-ratio) (the-as float (-> event param 0))) + (let ((f0-12 (-> self time-ratio)) + (f1-5 (-> self dest-time-ratio)) + (f2-1 (/ 300.0 (the float (-> event param 1)))) + ) + (set! (-> self dest-time-delta) (* (fabs (- f0-12 f1-5)) f2-1 (-> *display* real-clock seconds-per-frame))) + ) + (-> self dest-time-ratio) + ) + ) + ) + ) + ) + :code (behavior () + (until #f + (if (!= (-> self time-ratio) 0.0) + (set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ) + (when (!= (-> self time-ratio) (-> self dest-time-ratio)) + (seek! (-> self time-ratio) (-> self dest-time-ratio) (-> self dest-time-delta)) + (update-rates! (-> *display* bg-clock) (-> self time-ratio)) + ) + (update-counters) + (suspend) + ) + #f + (none) + ) + :post time-of-day-update + ) + +;; definition for function init-time-of-day +(defbehavior init-time-of-day time-of-day-proc () + (stack-size-set! (-> self main-thread) 128) + (set! (-> self hours) 0) + (set! (-> self minutes) 0) + (set! (-> self seconds) 0) + (set! (-> self frames) (the-as uint 0)) + (set! (-> self time-of-day) 0.0) + (cond + (*time-of-day-fast* + (set! (-> self time-ratio) 60.0) + (set! (-> self dest-time-ratio) 60.0) + ) + (else + (set! (-> self time-ratio) 1.0) + (set! (-> self dest-time-ratio) 1.0) + ) + ) + (update-rates! (-> *display* bg-clock) (-> self time-ratio)) + (set! (-> self sun) (create-launch-control (-> *part-group-id-table* 3) self)) + (set! (-> self green-sun) (create-launch-control (-> *part-group-id-table* 4) self)) + (set! (-> self moon) (create-launch-control (-> *part-group-id-table* 5) self)) + (set! (-> self event-hook) (-> time-of-day-tick event)) + (go time-of-day-tick) + ) + +;; definition for function start-time-of-day +;; WARN: Return type mismatch (pointer time-of-day-proc) vs (pointer process). +(defun start-time-of-day () + (kill-by-name "time-of-day-proc" *active-pool*) + (set! *time-of-day* (process-spawn time-of-day-proc :init init-time-of-day :to *bg-pool*)) + (the-as (pointer process) *time-of-day*) + ) + +;; definition for function time-of-day-setup +(defun time-of-day-setup ((arg0 symbol)) + (when arg0 + (when (= (-> *time-of-day* 0 time-ratio) 0.0) + (send-event (ppointer->process *time-of-day*) 'change 'ratio (if *time-of-day-fast* + #x42700000 + #x3f800000 + ) + ) + (set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + ) + ) + (!= (-> *time-of-day* 0 time-ratio) 0.0) + ) + +;; definition for function time-of-day-interp-colors +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function time-of-day-interp-colors-scratch +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function init-time-of-day-context +(defun init-time-of-day-context ((arg0 time-of-day-context)) + (set-vector! (-> arg0 title-light-group dir0 color) 0.82 0.82 0.82 1.0) + (set-vector! (-> arg0 title-light-group dir1 color) 2.0 2.0 2.0 1.0) + (set-vector! (-> arg0 title-light-group ambi color) 0.4 0.4 0.4 1.0) + (set! (-> arg0 title-light-group dir0 extra x) 1.0) + (set! (-> arg0 title-light-group dir1 extra x) 1.0) + (set! (-> arg0 title-light-group ambi extra x) 1.0) + (set-vector! (-> arg0 filter-color) 1.0 1.0 1.0 1.0) + (set! (-> arg0 overide-enable) #f) + (when *debug-segment* + (mem-copy! (the-as pointer *overide-mood-color-table*) (the-as pointer *no-cloud-mood-color-table*) 256) + (mem-copy! (the-as pointer *overide-mood-fog-table*) (the-as pointer *no-cloud-clear-mood-fog-table*) 384) + (dotimes (v1-8 8) + (set! (-> *overide-mood-color-table* data v1-8 lgt-color w) 1.0) + (set! (-> *overide-mood-color-table* data v1-8 amb-color w) 1.0) + (set! (-> *overide-mood-fog-table* data v1-8 fog-color w) 1.0) + (set! (-> *overide-mood-fog-table* data v1-8 fog-dists x) + (* 0.00024414062 (-> *overide-mood-fog-table* data v1-8 fog-dists x)) + ) + (set! (-> *overide-mood-fog-table* data v1-8 fog-dists y) + (* 0.00024414062 (-> *overide-mood-fog-table* data v1-8 fog-dists y)) + ) + (set-vector! (-> *time-of-day-context* times v1-8) 1.0 1.0 1.0 1.0) + ) + #f + ) + ) + +;; definition for function set-filter-color! +;; WARN: Return type mismatch int vs none. +(defun set-filter-color! ((arg0 float) (arg1 float) (arg2 float)) + (set-vector! (-> *time-of-day-context* filter-color) arg0 arg1 arg2 1.0) + 0 + (none) + ) + +;; definition for function tod-madd! +(defun tod-madd! ((arg0 vector) (arg1 vector) (arg2 vector)) + (local-vars (v0-0 float)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (.mov vf6 arg2) + (.lvf vf4 (&-> arg0 quad)) + (.lvf vf5 (&-> arg1 quad)) + (.mul.w.vf acc vf4 vf0) + (.add.mul.x.vf vf4 vf5 vf6 acc) + (.svf (&-> arg0 quad) vf4) + (.mov v0-0 vf4) + v0-0 + ) + ) + +;; definition for function update-environment-colors +(defun update-environment-colors ((arg0 time-of-day-context)) + (let* ((v1-0 (-> arg0 light-group)) + (s4-0 (-> v1-0 0 ambi color)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (-> arg0 current-prt-color)) + (s3-0 (-> arg0 current-env-color)) + ) + (vector4-lerp! s5-0 (-> v1-0 0 dir0 color) (-> v1-0 0 dir1 color) (-> v1-0 0 dir1 extra x)) + (when (and (= (-> s2-0 x) 0.0) (= (-> s2-0 y) 0.0) (= (-> s2-0 z) 0.0)) + (set! (-> s2-0 x) (* 0.5 (+ (-> s4-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x)))))) + (set! (-> s2-0 y) (* 0.5 (+ (-> s4-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y)))))) + (set! (-> s2-0 z) (* 0.5 (+ (-> s4-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z)))))) + (set! (-> s2-0 w) 1.0) + ) + (when (and (= (-> s3-0 x) 0.0) (= (-> s3-0 y) 0.0) (= (-> s3-0 z) 0.0)) + (set! (-> s3-0 x) (* 48.0 (+ (-> s5-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x)))))) + (set! (-> s3-0 y) (* 48.0 (+ (-> s5-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y)))))) + (set! (-> s3-0 z) (* 48.0 (+ (-> s5-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z)))))) + (set! (-> s3-0 w) 128.0) + ) + ) + (let* ((f0-23 (fmax (fmax (-> s4-0 x) (-> s4-0 y)) (-> s4-0 z))) + (f2-14 (fmax (fmax (-> s5-0 x) (-> s5-0 y)) (-> s5-0 z))) + (f0-27 (fmin 0.85 (- 1.0 (/ (* 0.5 f2-14) (+ f0-23 f2-14))))) + (v0-1 (-> arg0 current-shadow-color)) + ) + (set! (-> v0-1 x) f0-27) + (set! (-> v0-1 y) f0-27) + (set! (-> v0-1 z) f0-27) + (set! (-> v0-1 w) 1.0) + v0-1 + ) + ) + ) + +;; definition for function update-time-of-day +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defun update-time-of-day ((arg0 time-of-day-context)) + (with-pp + (set! (-> arg0 exterior-level) #f) + (init-weather! *mood-control*) + (update-colors-for-time *sky-work* (-> arg0 time)) + (cond + ((-> arg0 overide-enable) + (mem-copy! (the-as pointer (-> *overide-table* mood-fog-table)) (the-as pointer *overide-mood-fog-table*) 384) + (mem-copy! + (the-as pointer (-> *overide-table* mood-color-table)) + (the-as pointer *overide-mood-color-table*) + 256 + ) + (dotimes (v1-7 8) + (vector-float*! + (the-as vector (-> *overide-table* mood-fog-table data v1-7)) + (the-as vector (-> *overide-table* mood-fog-table data v1-7)) + (-> *overide-table* mood-fog-table data v1-7 fog-color w) + ) + (vector-float*! + (the-as vector (-> *overide-table* mood-color-table data v1-7)) + (the-as vector (-> *overide-table* mood-color-table data v1-7)) + (-> *overide-table* mood-color-table data v1-7 lgt-color w) + ) + (vector-float*! + (the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32))) + (the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32))) + (-> *overide-table* mood-color-table data v1-7 amb-color w) + ) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-color w) 128.0) + (set! (-> *overide-table* mood-color-table data v1-7 lgt-color w) 0.0) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-dists x) + (* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists x)) + ) + (set! (-> *overide-table* mood-fog-table data v1-7 fog-dists y) + (* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists y)) + ) + ) + (let ((s5-0 (-> *level* default-level mood-context))) + (clear-mood-times s5-0) + (update-mood-exterior s5-0 *overide-table* (-> arg0 time) 6) + (update-mood-itimes s5-0) + ) + ) + (else + (let ((s5-1 *mood-control*)) + (set! (-> arg0 current-clouds cloud-min) (-> s5-1 mood-clouds cloud-min)) + (set! (-> arg0 current-clouds cloud-max) (-> s5-1 mood-clouds cloud-max)) + (let ((s4-0 (-> *level* default-level mood-context))) + (clear-mood-times s4-0) + (update-mood-exterior s4-0 s5-1 (-> arg0 time) 6) + (update-mood-itimes s4-0) + ) + ) + ) + ) + (vector-float*! (-> arg0 filter) (-> arg0 filter-color) (-> arg0 filter-color w)) + (set! (-> arg0 sky) #f) + (set! (-> arg0 use-camera-other) #f) + (set! (-> arg0 target-interp) 0.0) + (let ((f0-16 4096000.0)) + (dotimes (v1-19 (-> *level* length)) + (let ((a0-50 (-> *level* level v1-19))) + (when (= (-> a0-50 status) 'active) + (if (-> a0-50 info sky) + (set! (-> arg0 sky) #t) + ) + (if (-> a0-50 info use-camera-other) + (set! (-> arg0 use-camera-other) (the-as basic #t)) + ) + (set! f0-16 (fmin f0-16 (-> a0-50 info fog-height))) + ) + ) + ) + (set-fog-height! f0-16) + ) + (if (-> arg0 sky) + (set! (-> (&-> *level* default-level texture-anim-array 9) 0) *sky-texture-anim-array*) + (set! (-> (&-> *level* default-level texture-anim-array 9) 0) #f) + ) + (let ((s5-2 (level-get-target-inside *level*))) + (dotimes (s4-1 6) + (let ((s3-0 (-> *level* level s4-1))) + (case (-> s3-0 status) + (('active 'loaded) + (when (not (paused?)) + (cond + ((= s3-0 s5-2) + (if *teleport* + (set! (-> arg0 interp s4-1) 1.0) + (set! (-> arg0 interp s4-1) (fmin 1.0 (+ 0.0166 (-> arg0 interp s4-1)))) + ) + ) + (*teleport* + (set! (-> arg0 interp s4-1) 0.0) + ) + (else + (set! (-> arg0 interp s4-1) (fmax 0.0 (+ -0.0166 (-> arg0 interp s4-1)))) + ) + ) + ) + (let ((s2-0 (-> pp clock))) + (set! (-> pp clock) (-> *display* real-clock)) + (clear-mood-times (-> s3-0 mood-context)) + ((-> s3-0 mood-func) (-> s3-0 mood-context) (-> arg0 time) s4-1) + (when (-> arg0 overide-enable) + (let ((s1-0 (new 'stack-no-clear 'structure))) + (dotimes (s0-0 8) + (let ((a1-48 (-> s3-0 mood-context times s0-0))) + (vector-float*! (the-as vector s1-0) (-> arg0 times s0-0) (-> arg0 times s0-0 w)) + (vector4-mul! (the-as vector4 a1-48) (the-as vector4 a1-48) (the-as vector4 s1-0)) + ) + ) + ) + ) + (update-mood-itimes (-> s3-0 mood-context)) + (set! (-> pp clock) s2-0) + ) + ) + (else + (set! (-> arg0 interp s4-1) 0.0) + ) + ) + ) + ) + ) + (if (and (-> arg0 exterior-level) (!= (-> *mood-control* lightning-flash) 0.0)) + (set! (-> *display* force-sync) (the-as uint 2)) + ) + (let ((f0-27 0.0)) + (dotimes (v1-79 6) + (+! f0-27 (-> arg0 interp v1-79)) + ) + (when (!= f0-27 0.0) + (dotimes (v1-83 6) + (set! (-> arg0 interp v1-83) (/ (-> arg0 interp v1-83) f0-27)) + ) + (let ((v1-86 (-> arg0 current-fog))) + (dotimes (a0-76 103) + (set! (-> (the-as (pointer int128) (+ (* a0-76 16) (the-as int v1-86)))) 0) + ) + ) + (let ((s5-3 (-> arg0 current-fog)) + (s4-2 (-> *mood-control* range)) + ) + (set! (-> s4-2 quad) (the-as uint128 0)) + (set! (-> arg0 max-rain) 0.0) + (set! (-> arg0 fog-mult) 0.0) + (set! (-> arg0 ocean-alpha) 0.0) + (dotimes (s3-1 6) + (let ((f30-0 (-> arg0 interp s3-1)) + (s2-1 *level*) + ) + (when (!= f30-0 0.0) + (let ((a2-20 (+ (the-as uint (-> s2-1 level0 mood-context)) (* 5232 s3-1)))) + (vector4-array-madd! + (the-as (inline-array vector4) s5-3) + (the-as (inline-array vector4) s5-3) + (the-as (inline-array vector4) a2-20) + f30-0 + 103 + ) + ) + (let ((a2-21 (-> s2-1 level s3-1 info mood-range))) + (vector4-madd! (the-as vector4 s4-2) (the-as vector4 s4-2) (the-as vector4 a2-21) f30-0) + ) + (+! (-> arg0 max-rain) (* (-> s2-1 level s3-1 info max-rain) f30-0)) + (+! (-> arg0 fog-mult) (* (-> s2-1 level s3-1 info fog-mult) f30-0)) + (+! (-> arg0 ocean-alpha) (* (-> s2-1 level s3-1 info ocean-alpha) f30-0)) + ) + ) + ) + ) + (dotimes (s5-4 8) + (dotimes (s4-3 3) + (let ((v1-119 (+ (+ (* 48 s4-3) 140 (* 192 s5-4)) (the-as int arg0)))) + (vector-normalize! (the-as vector (+ v1-119 0)) 1.0) + ) + ) + ) + ) + ) + (if (and (-> arg0 overide-enable) (!= (-> *time-of-day-context* mode) 8)) + (mem-copy! + (the-as pointer (-> arg0 current-fog)) + (the-as + pointer + (-> *overide-table* + mood-fog-table + data + (the-as uint (logand (-> *time-of-day-context* mode) (time-of-day-palette-id unk0 unk1 unk2))) + ) + ) + 48 + ) + ) + (update-environment-colors arg0) + (let ((v1-134 (-> arg0 current-fog))) + (let ((a0-87 (-> v1-134 fog-color))) + (set! *fog-color* + (new 'static 'rgba :r (the int (-> a0-87 x)) :g (the int (-> a0-87 y)) :b (the int (-> a0-87 z))) + ) + (set! (-> *fog-texture-work* color) + (the-as + uint + (logior (logior (logior (shr (shl (the int (-> a0-87 z)) 56) 40) (shr (shl (the int (-> a0-87 y)) 56) 48)) + (shr (shl (the int (-> a0-87 x)) 56) 56) + ) + (shr (shl (the int (-> a0-87 x)) 56) 56) + ) + ) + ) + ) + (let ((a0-92 (-> v1-134 erase-color))) + (set! (-> arg0 erase-color) + (new 'static 'rgba :a #x80 :b (the int (-> a0-92 z)) :g (the int (-> a0-92 y)) :r (the int (-> a0-92 x))) + ) + ) + (let ((f0-58 (-> v1-134 fog-dists x)) + (f1-18 (-> v1-134 fog-dists y)) + ) + (let ((f3-0 (-> v1-134 fog-dists z)) + (f2-2 (-> v1-134 fog-dists w)) + ) + (set! (-> *math-camera* fog-start) f0-58) + (set! (-> *math-camera* fog-end) f1-18) + (set! (-> *math-camera* fog-max) f3-0) + (set! (-> *math-camera* fog-min) f2-2) + (set! (-> *fog-texture-work* alpha-near) (* 0.003921569 (the float (- 255 (the int f3-0))))) + (set! (-> *fog-texture-work* alpha-far) (* 0.003921569 (the float (- 255 (the int f2-2))))) + ) + (set! (-> *fog-texture-work* alpha-delta) + (- (-> *fog-texture-work* alpha-far) (-> *fog-texture-work* alpha-near)) + ) + (set! (-> *fog-texture-work* fog-near) f0-58) + (set! (-> *fog-texture-work* fog-far) f1-18) + (set! (-> *fog-texture-work* fog-delta) (- f1-18 f0-58)) + ) + ) + (set-cloud-minmax! (-> arg0 current-clouds cloud-min) (-> arg0 current-clouds cloud-max)) + (reset! *palette-fade-controls*) + 0 + (none) + ) + ) + +;; definition for function calc-fade-from-fog +(defun calc-fade-from-fog ((arg0 vector)) + (let* ((f0-0 (vector-vector-distance (math-camera-pos) arg0)) + (v1-1 (-> *time-of-day-context* current-fog)) + (f1-0 (-> v1-1 fog-dists x)) + (f2-0 (-> v1-1 fog-dists y)) + (f3-1 (* 0.003921569 (-> v1-1 fog-dists w))) + (f4-2 (* 0.003921569 (-> v1-1 fog-dists z))) + ) + (+ f4-2 (* (fmax 0.0 (fmin 1.0 (/ (- f0-0 f1-0) (- f2-0 f1-0)))) (- f3-1 f4-2))) + ) + ) + +;; definition for method 10 of type palette-fade-controls +;; INFO: Used lq/sq +(defmethod set-fade! palette-fade-controls ((obj palette-fade-controls) (arg0 int) (arg1 float) (arg2 float) (arg3 vector)) + (cond + ((and (>= arg0 0) (< arg0 8)) + (let ((v1-3 (-> obj control arg0))) + (when (< arg2 (-> v1-3 actor-dist)) + (if arg3 + (set! (-> v1-3 trans quad) (-> arg3 quad)) + ) + (set! (-> v1-3 fade) (fmax 0.0 (fmin 1.993 arg1))) + (set! (-> v1-3 actor-dist) arg2) + ) + ) + ) + (else + (format 0 "ERROR: Bogus palette-fade-control index!~%") + ) + ) + ) + +;; definition for method 9 of type palette-fade-controls +;; WARN: Return type mismatch int vs none. +(defmethod reset! palette-fade-controls ((obj palette-fade-controls)) + (countdown (v1-0 8) + (let ((a1-2 (-> obj control v1-0))) + (set! (-> a1-2 fade) 0.0) + (set! (-> a1-2 actor-dist) 4096000000.0) + ) + ) + 0 + (none) + ) + +;; failed to figure out what this is: +(start-time-of-day) + + + + diff --git a/test/decompiler/reference/jak2/engine/gfx/sky/sky-h_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sky/sky-h_REF.gc index 1908fa15ba..7ee1353682 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sky/sky-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sky/sky-h_REF.gc @@ -444,8 +444,8 @@ (:methods (init-sun-data! (_type_ int float float float) none 9) (init-orbit-settings! (_type_ int float float float float float float) none 10) - (sky-work-method-11 () none 11) - (sky-work-method-12 () none 12) + (update-colors-for-time (_type_ float) none 11) + (update-time-and-speed (_type_ float float) none 12) (draw (_type_) none 13) (sky-work-method-14 () none 14) (sky-work-method-15 () none 15) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc index f42430d669..39987b36b3 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher-h_REF.gc @@ -273,7 +273,7 @@ (:methods (initialize (_type_ sparticle-launch-group process) none 9) (sparticle-launch-control-method-10 (_type_ vector) symbol 10) - (sparticle-launch-control-method-11 (_type_ vector) none 11) + (spawn (_type_ vector) none 11) (sparticle-launch-control-method-12 (_type_ matrix) none 12) (sparticle-launch-control-method-13 (_type_ cspace) none 13) (kill-and-free-particles (_type_) none 14) diff --git a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc index 31b1463ed6..edd52bf81e 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sprite/particles/sparticle-launcher_REF.gc @@ -1332,7 +1332,7 @@ ) ) ) - (sparticle-launch-control-method-11 obj (-> arg0 trans)) + (spawn obj (-> arg0 trans)) (none) ) @@ -1380,12 +1380,203 @@ ) ) ) - (sparticle-launch-control-method-11 obj (vector<-cspace! (-> obj origin trans) arg0)) + (spawn obj (vector<-cspace! (-> obj origin trans) arg0)) (none) ) ;; definition for method 11 of type sparticle-launch-control -;; ERROR: function was not converted to expressions. Cannot decompile. +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 11 sparticle-launch-control) has a return type of none, but the expression builder found a return statement. +(defmethod spawn sparticle-launch-control ((obj sparticle-launch-control) (arg0 vector)) + (with-pp + (set! (-> obj origin trans quad) (-> arg0 quad)) + (if (not (or (sparticle-launch-control-method-10 obj arg0) + (logtest? (-> obj group flags) (sp-group-flag always-draw screen-space)) + ) + ) + (return 0) + ) + (let ((s4-0 (the-as int (-> pp clock frame-counter))) + (s5-0 (-> obj last-spawn-time)) + ) + (let ((v1-10 (-> *display* real-frame-clock integral-frame-counter))) + (if (!= v1-10 (+ (-> obj last-spawn-frame) 1)) + (set! s5-0 (the-as int (- (the-as time-frame s4-0) (logand (the-as int (-> pp clock sparticle-data x)) 255)))) + ) + ) + (set! (-> obj last-spawn-frame) (the-as int (-> *display* real-frame-clock integral-frame-counter))) + (set! (-> obj last-spawn-time) s4-0) + (when (logtest? (-> obj group flags) (sp-group-flag use-local-clock)) + (set! s5-0 (-> obj local-clock)) + (+! (-> obj local-clock) (logand (the-as int (-> pp clock sparticle-data x)) 255)) + (set! s4-0 (-> obj local-clock)) + ) + (let* ((f30-0 (vector-vector-distance arg0 (math-camera-pos))) + (v1-26 1) + (a0-13 *time-of-day*) + (s3-1 (ash v1-26 (if a0-13 + (-> a0-13 0 hours) + 0 + ) + ) + ) + ) + (if (nonzero? (-> obj matrix)) + (set! f30-0 0.0) + ) + (let ((s2-1 (-> obj length))) + (b! #t cfg-95 :delay (nop!)) + (label cfg-19) + (+! s2-1 -1) + (let* ((a3-0 (-> obj data s2-1)) + (v1-33 (-> a3-0 group-item)) + (a1-4 (-> *part-id-table* (-> v1-33 launcher))) + ) + (b! + (not (and a1-4 (nonzero? a1-4) (logtest? (-> a3-0 flags) (sp-launch-state-flags launcher-active)))) + cfg-95 + :delay (empty-form) + ) + (let* ((f1-3 (if (!= (-> v1-33 falloff-to) 0.0) + (- 1.0 (/ f30-0 (-> v1-33 falloff-to))) + 1.0 + ) + ) + (f0-5 f1-3) + ) + (let ((a0-25 sparticle-launcher)) + (b! (!= (-> a1-4 type) a0-25) cfg-94 :delay (nop!)) + ) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag launch-asap))) cfg-42 :delay (nop!)) + (when (not (logtest? (-> a3-0 flags) (sp-launch-state-flags particles-active))) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (when (< 0.0 f0-5) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit7))) cfg-37 :delay (nop!)) + (let ((t9-3 sp-launch-particles-var)) + (b! (not (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d))) cfg-35 :delay (nop!)) + (let ((a0-36 *sp-particle-system-3d*)) + (b! #t cfg-36 :delay (nop!)) + (label cfg-35) + (set! a0-36 *sp-particle-system-2d*) + (label cfg-36) + (t9-3 a0-36 a1-4 (-> obj origin) a3-0 obj f0-5) + ) + ) + (b! #t cfg-41 :delay (nop!)) + (label cfg-37) + (let ((t9-4 sp-launch-particles-var) + (a0-38 (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + ) + (a2-4 *launch-matrix*) + ) + (set! (-> a2-4 trans quad) (-> a3-0 center quad)) + (t9-4 a0-38 a1-4 a2-4 a3-0 obj f0-5) + ) + ) + ) + (label cfg-41) + (b! #t cfg-93 :delay (nop!)) + (label cfg-42) + (when (or (logtest? s3-1 (-> v1-33 hour-mask)) + (not (or (= (-> v1-33 fade-after) 0.0) (< f30-0 (-> v1-33 fade-after)))) + ) + 0 + (goto cfg-93) + ) + (b! (nonzero? (-> v1-33 period)) cfg-59 :delay (empty-form)) + (if (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit6))) + (set! f0-5 (* 0.2 (the float (- s4-0 s5-0)) f0-5)) + ) + (b! #t cfg-81 :delay (nop!)) + (label cfg-59) + 0 + 0 + (let* ((a2-5 (-> v1-33 length)) + (a0-57 (-> v1-33 period)) + (t0-10 (mod (+ (- s5-0 (the-as int (-> obj data s2-1 offset))) a0-57) (the-as int a0-57))) + (a0-58 (mod (the-as uint (+ (- s4-0 (the-as int (-> obj data s2-1 offset))) a0-57)) a0-57)) + ) + (set! f0-5 (cond + ((and (< t0-10 (the-as int a2-5)) (< (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float (- s4-0 s5-0)) f0-5) + ) + ((and (< t0-10 (the-as int a2-5)) (>= (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float (- a2-5 (the-as uint t0-10))) f0-5) + ) + ((and (>= t0-10 (the-as int a2-5)) (< (the-as int a0-58) (the-as int a2-5))) + (* 0.2 (the float a0-58) f0-5) + ) + (else + (when (not (logtest? (-> v1-33 flags) (sp-group-item-flag bit1))) + 0 + (goto cfg-93) + ) + (when (< (the-as uint (- s4-0 (the-as int (-> obj data s2-1 spawn-time)))) (-> v1-33 period)) + 0 + (goto cfg-93) + ) + (set! (-> obj data s2-1 offset) (- (-> v1-33 period) a0-58)) + (* 0.2 (the float (- s4-0 s5-0)) f0-5) + ) + ) + ) + ) + (label cfg-81) + (set! (-> a3-0 spawn-time) (the-as uint s4-0)) + (logior! (-> a3-0 flags) (sp-launch-state-flags particles-active)) + (when (< 0.0 f0-5) + (if (logtest? (-> v1-33 flags) (sp-group-item-flag bit6)) + (set! f0-5 f1-3) + ) + (cond + ((logtest? (-> v1-33 flags) (sp-group-item-flag bit7)) + (sp-launch-particles-var + (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + a1-4 + (-> obj origin) + a3-0 + obj + f0-5 + ) + ) + (else + (let ((t9-6 sp-launch-particles-var) + (a0-83 (if (logtest? (-> v1-33 flags) (sp-group-item-flag is-3d)) + *sp-particle-system-3d* + *sp-particle-system-2d* + ) + ) + (a2-22 *launch-matrix*) + ) + (set! (-> a2-22 trans quad) (-> a3-0 center quad)) + (t9-6 a0-83 a1-4 a2-22 a3-0 obj f0-5) + ) + ) + ) + ) + ) + ) + (label cfg-93) + (b! #t cfg-95 :delay (nop!)) + (label cfg-94) + (format 0 "spawn called for non-sparticle-launcher~%") + (label cfg-95) + (b! (nonzero? s2-1) cfg-19 :delay (nop!)) + ) + ) + ) + 0 + (none) + ) + ) ;; definition for function execute-part-engine ;; INFO: Used lq/sq diff --git a/test/decompiler/reference/jak2/engine/gfx/texture/texture-anim-h_REF.gc b/test/decompiler/reference/jak2/engine/gfx/texture/texture-anim-h_REF.gc index 79e31cd478..f499b558b9 100644 --- a/test/decompiler/reference/jak2/engine/gfx/texture/texture-anim-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/texture/texture-anim-h_REF.gc @@ -82,22 +82,22 @@ ;; definition of type texture-anim (deftype texture-anim (structure) - ((num-layers uint32 :offset-assert 0) - (func basic :offset-assert 4) - (func-id basic :offset 4) - (init-func basic :offset-assert 8) - (init-func-id basic :offset 8) - (tex basic :offset-assert 12) - (tex-name basic :offset-assert 16) - (extra vector :inline :offset-assert 32) - (color uint32 :offset-assert 48) - (frame-time float :offset-assert 52) - (frame-delta float :offset-assert 56) - (frame-mod float :offset-assert 60) - (test uint64 :offset-assert 64) - (alpha uint64 :offset-assert 72) - (clamp uint64 :offset-assert 80) - (data uint8 :dynamic :offset-assert 88) + ((num-layers uint32 :offset-assert 0) + (func basic :offset-assert 4) + (func-id basic :offset 4) + (init-func basic :offset-assert 8) + (init-func-id basic :offset 8) + (tex basic :offset-assert 12) + (tex-name basic :offset-assert 16) + (extra vector :inline :offset-assert 32) + (color rgba :offset-assert 48) + (frame-time float :offset-assert 52) + (frame-delta float :offset-assert 56) + (frame-mod float :offset-assert 60) + (test gs-test :offset-assert 64) + (alpha gs-alpha :offset-assert 72) + (clamp gs-clamp :offset-assert 80) + (data texture-anim-layer :dynamic :offset-assert 88) ) :method-count-assert 11 :size-assert #x58 @@ -464,7 +464,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc b/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc index 53aeca4cc3..256a4481f6 100644 --- a/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/board/target-board_REF.gc @@ -1044,7 +1044,7 @@ ) ) ) - (sparticle-launch-control-method-11 (-> self board part-control) (-> self control trans)) + (spawn (-> self board part-control) (-> self control trans)) (let ((t9-26 (method-of-object (-> self skel effect) effect-control-method-10))) 'effect-board-poof 0 diff --git a/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc b/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc index f030fd69d1..7575d3c12e 100644 --- a/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc @@ -816,10 +816,10 @@ (defmethod spawn-particles elec-gate ((obj elec-gate) (sparticle-lc sparticle-launch-control)) "TODO - Calls [[sparticle-launch-control::11]] on `part-spawner-left` and `part-spawner-right` if they are defined" (if (-> obj part-spawner-left) - (sparticle-launch-control-method-11 sparticle-lc (the-as vector (&-> (-> obj part-spawner-left child) 8))) + (spawn sparticle-lc (the-as vector (&-> (-> obj part-spawner-left child) 8))) ) (if (-> obj part-spawner-right) - (sparticle-launch-control-method-11 sparticle-lc (the-as vector (&-> (-> obj part-spawner-right child) 8))) + (spawn sparticle-lc (the-as vector (&-> (-> obj part-spawner-right child) 8))) ) 0 (none) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index c7d3a562f4..90b26401c1 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -167,6 +167,7 @@ "(method 21 load-state)", "(method 16 level)", "unpack-comp-lzo", // asm mods + "update-time-of-day", "i-hopefully-will-never-exist-dont-add-anything-after-me-please" ],