diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index fe4a46229b..94cd15997e 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3702,8 +3702,10 @@ ConstantTokenElement* DerefElement::try_as_art_const(const Env& env, FormPool& p if (elt_name) { return pool.alloc_element(*elt_name); } else { - lg::error("function {}: did not find art element {} in {}", env.func->name(), - mr.maps.ints.at(0), env.art_group()); + if (env.version != GameVersion::Jak2) { + lg::error("function {}: did not find art element {} in {}", env.func->name(), + mr.maps.ints.at(0), env.art_group()); + } } } diff --git a/decompiler/IR2/bitfields.cpp b/decompiler/IR2/bitfields.cpp index 87f994c05f..2ecfe076ec 100644 --- a/decompiler/IR2/bitfields.cpp +++ b/decompiler/IR2/bitfields.cpp @@ -4,6 +4,7 @@ #include "common/log/log.h" #include "common/util/BitUtils.h" #include "common/util/Range.h" +#include "common/util/print_float.h" #include "decompiler/Function/Function.h" #include "decompiler/IR2/Form.h" @@ -44,7 +45,12 @@ goos::Object BitfieldStaticDefElement::to_form_internal(const Env& env) const { auto def_as_atom = form_as_atom(def.value); if (def_as_atom && def_as_atom->is_int()) { u64 v = def_as_atom->get_int(); - if (def.is_signed) { + if (def.is_float) { + float vf; + memcpy(&vf, &v, 4); + result.push_back(pretty_print::to_symbol( + fmt::format(":{} {}", def.field_name, float_to_string(vf, true)))); + } else if (def.is_signed) { result.push_back(pretty_print::to_symbol(fmt::format(":{} {}", def.field_name, (s64)v))); } else { result.push_back(pretty_print::to_symbol(fmt::format(":{} #x{:x}", def.field_name, v))); @@ -709,6 +715,7 @@ BitFieldDef BitFieldDef::from_constant(const BitFieldConstantDef& constant, Form BitFieldDef bfd; bfd.field_name = constant.field_name; bfd.is_signed = constant.is_signed; + bfd.is_float = constant.is_float; if (constant.nested_field) { std::vector defs; for (auto& x : constant.nested_field->fields) { diff --git a/decompiler/IR2/bitfields.h b/decompiler/IR2/bitfields.h index ca492b904e..9c25db6516 100644 --- a/decompiler/IR2/bitfields.h +++ b/decompiler/IR2/bitfields.h @@ -119,6 +119,7 @@ class BitfieldAccessElement : public FormElement { struct BitFieldDef { bool is_signed = false; + bool is_float = false; Form* value = nullptr; std::string field_name; diff --git a/decompiler/ObjectFile/ObjectFileDB.h b/decompiler/ObjectFile/ObjectFileDB.h index 07181572a1..27f3e70bc9 100644 --- a/decompiler/ObjectFile/ObjectFileDB.h +++ b/decompiler/ObjectFile/ObjectFileDB.h @@ -67,6 +67,7 @@ struct LetRewriteStats { int case_with_else = 0; int set_vector = 0; int set_vector2 = 0; + int set_vector3 = 0; int send_event = 0; int font_context_meth = 0; int proc_new = 0; @@ -91,6 +92,7 @@ struct LetRewriteStats { out += fmt::format(" ja: {}\n", ja); out += fmt::format(" set_vector: {}\n", set_vector); out += fmt::format(" set_vector2: {}\n", set_vector2); + out += fmt::format(" set_vector3: {}\n", set_vector3); out += fmt::format(" case_no_else: {}\n", case_no_else); out += fmt::format(" case_with_else: {}\n", case_with_else); out += fmt::format(" unused: {}\n", unused); diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index 8e1af0a4dc..e2b5bb409a 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -801,6 +801,50 @@ FormElement* rewrite_set_vector(LetElement* in, const Env& env, FormPool& pool) return pool.alloc_element(op, args); } +FormElement* rewrite_set_vector_3(LetElement* in, const Env& env, FormPool& pool) { + if (in->entries().size() != 1) { + return nullptr; + } + + auto in_vec = env.get_variable_name(in->entries().at(0).dest); + + auto& body_elts = in->body()->elts(); + if (body_elts.size() != 4) { + return nullptr; + } + + std::vector sources; + for (int i = 0; i < 4; i++) { + auto elt_as_form_form = dynamic_cast(body_elts.at(i)); + if (!elt_as_form_form) { + return nullptr; + } + auto dst = elt_as_form_form->dst(); + sources.push_back(elt_as_form_form->src()); + Matcher dst_matcher = Matcher::deref(Matcher::any_reg(0), false, + {DerefTokenMatcher::string("vector4w"), + DerefTokenMatcher::string(std::string(1, "xyzw"[i]))}); + auto mr = match(dst_matcher, dst); + if (!mr.matched) { + return nullptr; + } + if (in_vec != env.get_variable_name(*mr.maps.regs.at(0))) { + return nullptr; + } + } + + std::vector args; + args.push_back(pool.form(in->entries().at(0).src, false, + DerefToken::make_field_name("vector4w"))); + for (auto& src : sources) { + args.push_back(src); + } + + auto op = GenericOperator::make_function( + pool.alloc_single_element_form(nullptr, "set-vector!")); + return pool.alloc_element(op, args); +} + FormElement* rewrite_set_vector_2(LetElement* in, const Env& env, FormPool& pool) { if (in->entries().size() != 1) { return nullptr; @@ -1737,6 +1781,12 @@ FormElement* rewrite_let(LetElement* in, const Env& env, FormPool& pool, LetRewr return as_set_vector2; } + auto as_set_vector3 = rewrite_set_vector_3(in, env, pool); + if (as_set_vector3) { + stats.set_vector3++; + return as_set_vector3; + } + auto as_abs_2 = fix_up_abs_2(in, env, pool); if (as_abs_2) { stats.abs2++; diff --git a/decompiler/analysis/mips2c.cpp b/decompiler/analysis/mips2c.cpp index e31abb7b09..10be92788c 100644 --- a/decompiler/analysis/mips2c.cpp +++ b/decompiler/analysis/mips2c.cpp @@ -1055,6 +1055,7 @@ Mips2C_Line handle_normal_instr(Mips2C_Output& output, case InstructionKind::PCGTW: case InstructionKind::PPACB: case InstructionKind::PADDW: + case InstructionKind::PADDB: case InstructionKind::PEXTUB: case InstructionKind::PMULTH: case InstructionKind::PMADDH: diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 20551ed87f..a311aee679 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -2712,7 +2712,7 @@ (bucket-2 2) (bucket-3 3) ;; blit displays (tex-lcom-sky-pre 4) ;; tex - (bucket-5 5) ;; sky + (sky-draw 5) ;; sky (bucket-6 6) ;; ocean ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -5151,7 +5151,7 @@ (func-id basic :offset 4) (init-func basic :offset-assert 8) (init-func-id basic :offset 8) - (tex basic :offset-assert 12) + (tex texture :offset-assert 12) (tex-name basic :offset-assert 16) (extra vector :inline :offset-assert 32) (color rgba :offset-assert 48) @@ -5173,7 +5173,7 @@ ) (deftype texture-anim-array (array) - ((array-data texture-anim :dynamic :inline :offset-assert 16) + ((array-data texture-anim :dynamic :offset-assert 16) ) :method-count-assert 11 :size-assert #x10 @@ -10129,7 +10129,7 @@ (vec1 vector4w :inline :offset-assert 1568) (cloud-lights cloud-lights :inline :offset-assert 1584) (haze-lights haze-lights :inline :offset-assert 1744) - (buf basic :offset-assert 1868) + (buf dma-buffer :offset-assert 1868) (draw-vortex basic :offset-assert 1872) (stars vector 512 :inline :offset-assert 1888) ) @@ -10140,31 +10140,31 @@ (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) (update-colors-for-time (_type_ float) none 11) - (update-time-and-speed (_type_ float float) none 12) ;; update time-of-day settings + (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) - (sky-work-method-16 () none 16) - (sky-work-method-17 () none 17) - (sky-work-method-18 () none 18) - (sky-work-method-19 () none 19) - (sky-work-method-20 () none 20) - (sky-work-method-21 () none 21) - (sky-work-method-22 () none 22) - (sky-work-method-23 () none 23) - (sky-work-method-24 () none 24) - (sky-work-method-25 () none 25) - (sky-work-method-26 () none 26) - (sky-work-method-27 () none 27) - (sky-work-method-28 () none 28) - (sky-work-method-29 () none 29) - (sky-work-method-30 () none 30) - (sky-work-method-31 () none 31) - (sky-work-method-32 () none 32) - (sky-work-method-33 () none 33) - (sky-work-method-34 () none 34) - (sky-work-method-35 () none 35) - (sky-work-method-36 () none 36) + (update-matrix (_type_ matrix) none 14) + (update-template-colors (_type_) none 15) + (init-regs-for-large-polygon-draw (_type_) none 16) + (init-regs-for-sky-asm (_type_) none 17) + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none 18) + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none 19) + (adjust-cloud-lighting (_type_) none 20) + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none 21) + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none 22) + (draw-clouds (_type_ dma-buffer) none 23) + (apply-haze-light (_type_ vector vector haze-lights) none 24) + (adjust-haze-lighting (_type_) none 25) + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none 26) + (draw-haze (_type_ dma-buffer) none 27) + (sun-dma (_type_ dma-buffer) none 28) + (green-sun-dma (_type_ dma-buffer) none 29) + (moon-dma (_type_ dma-buffer) none 30) + (setup-stars (_type_ matrix sky-upload-data) none 31) + (stars-transform-asm (_type_) none 32) + (stars-dma (_type_ dma-buffer) none 33) + (draw-roof (_type_ dma-buffer) none 34) + (draw-base (_type_ dma-buffer) none 35) + (draw-fog (_type_ dma-buffer) none 36) ) ) @@ -25790,10 +25790,10 @@ (define-extern sky-base-polygons (inline-array sky-vertex)) (define-extern sky-roof-polygons (inline-array sky-vertex)) (define-extern *cloud-vert-array* cloud-vert-array) -(define-extern *cloud-poly* (inline-array cloud-vertex)) +(define-extern *cloud-poly* (inline-array sky-vertex)) (define-extern init-cloud-vert-array (function symbol)) (define-extern *haze-vert-array* haze-vert-array) -(define-extern *haze-poly* (inline-array haze-vertex)) +(define-extern *haze-poly* (inline-array sky-vertex)) (define-extern init-haze-vert-array (function symbol)) (define-extern sky-make-sun-data "Initialize `upload-data` with [[sky-sun-data]] in [[*sky-work*]]" (function sky-work int float none)) (define-extern sky-make-moon-data "Initialize `upload-data` with [[sky-moon-data]] in [[*sky-work*]]" (function sky-work float none)) @@ -25802,12 +25802,12 @@ ;; sky-tng ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern set-tex-offset function) ;; (function int int none) +(define-extern set-tex-offset (function int int none)) ;; (define-extern draw-large-polygon function) ;; function ;; (define-extern clip-polygon-against-positive-hyperplane function) ;; function ;; (define-extern clip-polygon-against-negative-hyperplane function) ;; function -;; (define-extern render-sky-quad function) ;; (function int dma-buffer none) -;; (define-extern render-sky-tri function) ;; (function (inline-array sky-vertex) dma-buffer none) +(define-extern render-sky-quad (function (inline-array sky-vertex) dma-buffer none)) +(define-extern render-sky-tri (function (inline-array sky-vertex) dma-buffer none)) (define-extern close-sky-buffer (function dma-buffer none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index 9555df9a25..2ac74510f8 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -413,7 +413,18 @@ "sp-launch-particles-var", "sparticle-motion-blur", "sp-process-block-2d", - "sp-process-block-3d" + "sp-process-block-3d", + "set-tex-offset", + "draw-large-polygon", + "render-sky-quad", + "render-sky-tri", + "(method 16 sky-work)", + "(method 17 sky-work)", + "(method 32 sky-work)", + "(method 33 sky-work)", + "(method 28 sky-work)", + "(method 29 sky-work)", + "(method 30 sky-work)" ], "mips2c_jump_table_functions": {}, diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index 3578161b65..dfdba5631f 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -110,8 +110,8 @@ "sky-data": [ ["L26", "(inline-array sky-vertex)", 12], ["L25", "(inline-array sky-vertex)", 12], - ["L23", "(inline-array cloud-vertex)", 277], - ["L21", "(inline-array haze-vertex)", 144] + ["L23", "(inline-array sky-vertex)", 648], + ["L21", "(inline-array sky-vertex)", 144] ], "default-menu": [ ["L6314", "(pointer uint64)", 1], @@ -426,5 +426,16 @@ "water-anim": [ ["L63", "attack-info"], ["L62", "attack-info"] + ], + "sky-tng": [ + ["L131", "uint64", true], + ["L130", "uint64", true], + ["L129", "uint64", true], + ["L128", "uint64", true], + ["L127", "uint64", true], + ["L126", "uint64", true], + ["L125", "uint64", true], + ["L124", "uint64", true], + ["L123", "uint64", true] ] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 0cc117f017..e59b1cd934 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1021,6 +1021,12 @@ "(enter cam-circular)": [[32, "collide-query"]], "(method 26 rigid-body)": [[16, ["inline-array", "vector", 8]]], "(method 47 rigid-body-object)": [[16, "matrix"]], + "(method 16 sky-work)": [ + [16, "vector"] + ], + "(method 17 sky-work)": [ + [16, "vector"] + ], // placeholder "placeholder-do-not-add-below": [] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index c4a8b6c4eb..6bc98883df 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -3488,7 +3488,125 @@ [[268, 315], "s4", "process-drawable"], [[275,338], "s5", "sound-rpc-set-param"], [[351,375], "s5", "sound-rpc-set-param"] - + ], + "(method 13 sky-work)": [ + [[78, 170], "s4", "sky-work"], + [[162, 168], "v1", "dma-packet"], + [[221, 228], "a1", "dma-packet"], + [[230, 239], "a1", "gs-gif-tag"], + [243, "a1", "(pointer gs-zbuf)"], + [245, "a1", "(pointer gs-reg64)"], + [247, "a1", "(pointer gs-test)"], + [249, "a1", "(pointer gs-reg64)"], + [250, "a1", "(pointer gs-alpha)"], + [252, "a1", "(pointer gs-reg64)"], + [255, "a1", "(pointer gs-tex0)"], + [257, "a1", "(pointer gs-reg64)"], + [259, "a1", "(pointer gs-tex1)"], + [261, "a1", "(pointer gs-reg64)"], + [263, "a1", "(pointer gs-clamp)"], + [265, "a1", "(pointer gs-reg64)"], + [266, "a1", "(pointer uint64)"], + [268, "a1", "(pointer gs-reg64)"], + [[271, 309], "a2", "(inline-array qword)"], + [[316, 354], "t0", "(inline-array qword)"], + [[362, 369], "t1", "dma-packet"], + [[371, 380], "t1", "gs-gif-tag"], + [384, "t1", "(pointer gs-alpha)"], + [386, "t1", "(pointer gs-reg64)"], + [389, "t1", "(pointer gs-tex0)"], + [391, "t1", "(pointer gs-reg64)"], + [392, "t1", "(pointer uint64)"], + [394, "t1", "(pointer gs-reg64)"], + [[397, 429], "t0", "(inline-array qword)"], + [[437, 444], "a1", "dma-packet"], + [[446, 455], "a1", "gs-gif-tag"], + [458, "a1", "(pointer gs-alpha)"], + [460, "a1", "(pointer gs-reg64)"], + [[515, 561], "t1", "(inline-array qword)"], + [[574, 581], "a3", "dma-packet"], + [[583, 592], "a3", "gs-gif-tag"], + [596, "a3", "(pointer gs-alpha)"], + [598, "a3", "(pointer gs-reg64)"], + [601, "a3", "(pointer gs-tex0)"], + [603, "a3", "(pointer gs-reg64)"], + [604, "a3", "(pointer uint64)"], + [606, "a3", "(pointer gs-reg64)"], + [[609, 647], "v1", "(inline-array qword)"], + [[673, 680], "a1", "dma-packet"], + [[682, 691], "a1", "gs-gif-tag"], + [695, "a1", "(pointer gs-zbuf)"], + [697, "a1", "(pointer gs-reg64)"], + [699, "a1", "(pointer gs-test)"], + [701, "a1", "(pointer gs-reg64)"], + [728, "a1", "(pointer gs-rgbaq)"], + [730, "a1", "(pointer gs-reg64)"], + [[733, 738], "v1", "(inline-array qword)"], + [[741, 750], "v1", "(inline-array qword)"], + [[760, 766], "v1", "dma-packet"] + ], + "(method 33 sky-work)": [ + [42, "s5", "int"], + [46, "a2", "sky-work"], + [59, "a2", "sky-work"], + [36, "v1", "sky-work"] + ], + "(method 23 sky-work)": [ + [[3, 10], "a0", "dma-packet"], + [[12, 21], "a0", "gs-gif-tag"], + [25, "s3", "(pointer gs-test)"], + [27, "s3", "(pointer gs-reg64)"], + [42, "s3", "(pointer gs-tex0)"], + [44, "s3", "(pointer gs-reg64)"], + [46, "s3", "(pointer gs-tex1)"], + [48, "s3", "(pointer gs-reg64)"], + [49, "s3", "(pointer gs-clamp)"], + [51, "s3", "(pointer gs-reg64)"], + [53, "s3", "(pointer gs-alpha)"], + [55, "s3", "(pointer gs-reg64)"], + [56, "s3", "(pointer uint64)"], + [58, "s3", "(pointer gs-reg64)"], + [[255, 263], "s4", "dma-packet"] + ], + "(method 27 sky-work)": [ + [[5, 10], "a0", "dma-packet"], + [[12, 20], "a0", "gs-gif-tag"], + [25, "a0", "(pointer gs-alpha)"], + [27, "a0", "(pointer gs-reg64)"], + [[142, 149], "s4", "dma-packet"] + ], + "(method 34 sky-work)": [ + [[5, 10], "a0", "dma-packet"], + [[12, 20], "a0", "gs-gif-tag"], + [25, "a0", "(pointer gs-zbuf)"], + [27, "a0", "(pointer gs-reg64)"], + [29, "a0", "(pointer gs-test)"], + [31, "a0", "(pointer gs-reg64)"], + [33, "a0", "(pointer gs-alpha)"], + [35, "a0", "(pointer gs-reg64)"], + [[80, 88], "s5", "dma-packet"] + ], + "(method 35 sky-work)": [ + [[2, 9], "a1", "dma-packet"], + [[11, 20], "a1", "gs-gif-tag"], + [24, "a1", "(pointer gs-test)"], + [26, "a1", "(pointer gs-reg64)"], + [[66, 74], "s5", "dma-packet"] + ], + "(method 36 sky-work)": [ + [[7, 14], "a0", "dma-packet"], + [[16, 26], "a0", "gs-gif-tag"], + [62, "s2", "(pointer gs-tex0)"], + [64, "s2", "(pointer gs-reg64)"], + [66, "s2", "(pointer gs-tex1)"], + [68, "s2", "(pointer gs-reg64)"], + [70, "s2", "(pointer gs-test)"], + [72, "s2", "(pointer gs-reg64)"], + [74, "s2", "(pointer gs-clamp)"], + [76, "s2", "(pointer gs-reg64)"], + [78, "s2", "(pointer gs-alpha)"], + [80, "s2", "(pointer gs-reg64)"], + [[83, 177], "v1", "(inline-array qword)"] ], "draw-subtitle-image": [ [[44, 48], "a0", "dma-packet"], diff --git a/decompiler/config/jak2_ntsc_v1.jsonc b/decompiler/config/jak2_ntsc_v1.jsonc index 3516646474..ab2695a415 100644 --- a/decompiler/config/jak2_ntsc_v1.jsonc +++ b/decompiler/config/jak2_ntsc_v1.jsonc @@ -8,7 +8,7 @@ // if you want to filter to only some object names. // it will make the decompiler much faster. "allowed_objects": [], - "banned_objects": ["effect-control", "ctywide-scenes", "texture-anim-tables", "sky-tng", "traffic-engine"], + "banned_objects": ["effect-control", "ctywide-scenes", "texture-anim-tables", "traffic-engine"], //////////////////////////// // CODE ANALYSIS OPTIONS diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index cb25f98a0e..8ebeece98c 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1656,6 +1656,7 @@ std::optional> try_decompile_bitfield_from_int( def.value = bitfield_value; def.field_name = field.name(); def.is_signed = is_signed; + def.is_float = field.type().base_type() == "float"; auto enum_info = ts.try_enum_lookup(field.type()); if (enum_info && !enum_info->is_bitfield()) { auto name = decompile_int_enum_from_int(field.type(), ts, bitfield_value); diff --git a/decompiler/util/data_decompile.h b/decompiler/util/data_decompile.h index cc68bf08b2..02e7a0833e 100644 --- a/decompiler/util/data_decompile.h +++ b/decompiler/util/data_decompile.h @@ -82,6 +82,7 @@ goos::Object decompile_bitfield(const TypeSpec& type, struct BitFieldConstantDef { bool is_signed = false; + bool is_float = false; u64 value = -1; std::optional enum_constant; std::string field_name; diff --git a/game/graphics/opengl_renderer/DirectRenderer.cpp b/game/graphics/opengl_renderer/DirectRenderer.cpp index de0b76bb89..4b4fffa754 100644 --- a/game/graphics/opengl_renderer/DirectRenderer.cpp +++ b/game/graphics/opengl_renderer/DirectRenderer.cpp @@ -967,9 +967,14 @@ void DirectRenderer::handle_xyzf2_common(u32 x, auto& corner1_rgba = m_prim_building.building_rgba[0]; auto& corner2_vert = m_prim_building.building_vert[1]; auto& corner2_rgba = m_prim_building.building_rgba[1]; + auto& corner1_stq = m_prim_building.building_stq[0]; + auto& corner2_stq = m_prim_building.building_stq[1]; + // should use most recent vertex z. math::Vector corner3_vert{corner1_vert[0], corner2_vert[1], corner2_vert[2]}; math::Vector corner4_vert{corner2_vert[0], corner1_vert[1], corner2_vert[2]}; + math::Vector corner3_stq{corner1_stq[0], corner2_stq[1], corner2_stq[2]}; + math::Vector corner4_stq{corner2_stq[0], corner1_stq[1], corner2_stq[2]}; if (m_prim_gl_state.gouraud_enable) { // I'm not really sure what the GS does here. @@ -978,12 +983,12 @@ void DirectRenderer::handle_xyzf2_common(u32 x, auto& corner3_rgba = corner2_rgba; auto& corner4_rgba = corner2_rgba; - m_prim_buffer.push(corner1_rgba, corner1_vert, {}, 0, tcc, decal, fge); - m_prim_buffer.push(corner3_rgba, corner3_vert, {}, 0, tcc, decal, fge); - m_prim_buffer.push(corner2_rgba, corner2_vert, {}, 0, tcc, decal, fge); - m_prim_buffer.push(corner2_rgba, corner2_vert, {}, 0, tcc, decal, fge); - m_prim_buffer.push(corner4_rgba, corner4_vert, {}, 0, tcc, decal, fge); - m_prim_buffer.push(corner1_rgba, corner1_vert, {}, 0, tcc, decal, fge); + m_prim_buffer.push(corner1_rgba, corner1_vert, corner1_stq, 0, tcc, decal, fge); + m_prim_buffer.push(corner3_rgba, corner3_vert, corner3_stq, 0, tcc, decal, fge); + m_prim_buffer.push(corner2_rgba, corner2_vert, corner2_stq, 0, tcc, decal, fge); + m_prim_buffer.push(corner2_rgba, corner2_vert, corner2_stq, 0, tcc, decal, fge); + m_prim_buffer.push(corner4_rgba, corner4_vert, corner4_stq, 0, tcc, decal, fge); + m_prim_buffer.push(corner1_rgba, corner1_vert, corner1_stq, 0, tcc, decal, fge); m_prim_building.building_idx = 0; } } break; diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index ff7c91720a..e393b8e915 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -92,6 +92,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { init_bucket_renderer("vis", BucketCategory::OTHER, BucketId::SPECIAL_BUCKET_2); init_bucket_renderer("tex-lcom-sky-pre", BucketCategory::TEX, BucketId::TEX_LCOM_SKY_PRE); + init_bucket_renderer("sky-draw", BucketCategory::OTHER, BucketId::SKY_DRAW, 1024); init_bucket_renderer("tex-l0-tfrag", BucketCategory::TEX, BucketId::TEX_L0_TFRAG); init_bucket_renderer("tfrag-l0-tfrag", BucketCategory::TFRAG, BucketId::TFRAG_L0_TFRAG, @@ -120,6 +121,8 @@ void OpenGLRenderer::init_bucket_renderers_jak2() { // 100 // 110 // 120 + init_bucket_renderer("tex-l0-alpha", BucketCategory::TEX, + BucketId::TEX_L0_ALPHA); init_bucket_renderer("tfrag-t-l0-alpha", BucketCategory::TFRAG, BucketId::TFRAG_T_L0_ALPHA, std::vector{tfrag3::TFragmentTreeKind::TRANS}, false, 0); diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index 1217bd5221..61c676fab4 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -83,6 +83,7 @@ namespace jak2 { enum class BucketId { SPECIAL_BUCKET_2 = 2, TEX_LCOM_SKY_PRE = 4, + SKY_DRAW = 5, TEX_L0_TFRAG = 7, TFRAG_L0_TFRAG = 8, TIE_L0_TFRAG = 9, @@ -93,6 +94,7 @@ enum class BucketId { SHRUB_L0_SHRUB = 74, TEX_L1_SHRUB = 82, SHRUB_L1_SHRUB = 83, + TEX_L0_ALPHA = 127, TFRAG_T_L0_ALPHA = 128, TEX_LCOM_TFRAG = 187, TEX_LCOM_SHRUB = 191, diff --git a/game/mips2c/jak2_functions/sky.cpp b/game/mips2c/jak2_functions/sky.cpp index ad38a561b4..63c4d7325b 100644 --- a/game/mips2c/jak2_functions/sky.cpp +++ b/game/mips2c/jak2_functions/sky.cpp @@ -20,7 +20,23 @@ void link() { } } // namespace set_sky_vf27 +} // namespace Mips2C::jak2 +namespace Mips2C::jak2 { +namespace set_sky_vf23_value { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + // sky_regs_vfs.vfs[27] + u64 value = c->sgpr64(a0); + memcpy(&sky_regs_vfs.vfs[23].f[0], &value, 8); + return 0; +} + +void link() { + gLinkedFunctionTable.reg("set-sky-vf23-value", execute, 64); +} + +} // namespace set_sky_vf23_value } // namespace Mips2C::jak2 //--------------------------MIPS2C--------------------- @@ -597,3 +613,1509 @@ u64 execute(void* ctxt) { } // namespace clip_polygon_against_negative_hyperplane } // namespace Mips2C +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace set_tex_offset { +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->daddiu(v1, sp, 16); // daddiu v1, sp, 16 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->lui(a2, 14208); // lui a2, 14208 + c->mtc1(f0, a2); // mtc1 f0, a2 + c->mtc1(f1, a0); // mtc1 f1, a0 + c->cvtsw(f1, f1); // cvt.s.w f1, f1 + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->swc1(f0, 0, v1); // swc1 f0, 0(v1) + c->lui(a0, 14208); // lui a0, 14208 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->mtc1(f1, a1); // mtc1 f1, a1 + c->cvtsw(f1, f1); // cvt.s.w f1, f1 + c->muls(f0, f0, f1); // mul.s f0, f0, f1 + c->swc1(f0, 4, v1); // swc1 f0, 4(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 8, v1); // swc1 f0, 8(v1) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->lqc2(vf24, 0, v1); // lqc2 vf24, 0(v1) + c->mov128_gpr_vf(v1, vf24); // qmfc2.i v1, vf24 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + + end_of_function: + memcpy(&sky_regs_vfs.vfs[vf24].f[0], c->gprs[v1].du32, 16); + + return c->gprs[v0].du64[0]; +} + +void link() { + gLinkedFunctionTable.reg("set-tex-offset", execute, 64); +} + +} // namespace set_tex_offset +} // namespace Mips2C + +//--------------------------MIPS2C--------------------- +// clang-format off +#include "game/mips2c/mips2c_private.h" +#include "game/kernel/jak2/kscheme.h" +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace draw_large_polygon { +struct Cache { + void* clip_polygon_against_negative_hyperplane; // clip-polygon-against-negative-hyperplane + void* clip_polygon_against_positive_hyperplane; // clip-polygon-against-positive-hyperplane +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + // nop // sll r0, r0, 0 + c->daddiu(sp, sp, -8); // daddiu sp, sp, -8 + // nop // sll r0, r0, 0 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->load_symbol2(t9, cache.clip_polygon_against_positive_hyperplane);// lw t9, clip-polygon-against-positive-hyperplane(s7) + c->mov64(a2, t4); // or a2, t4, r0 + c->mov64(a3, t5); // or a3, t5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddu(t2, a2, r0); // daddu t2, a2, r0 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_positive_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L119 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->mov64(a2, t5); // or a2, t5, r0 + c->mov64(a3, t4); // or a3, t4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(t2, a2, 4); // daddiu t2, a2, 4 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_positive_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L119 + c->load_symbol2(t9, cache.clip_polygon_against_negative_hyperplane);// lw t9, clip-polygon-against-negative-hyperplane(s7) + if (bc) {goto block_7;} // branch non-likely + + c->mov64(a2, t4); // or a2, t4, r0 + c->mov64(a3, t5); // or a3, t5, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddu(t2, a2, r0); // daddu t2, a2, r0 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_negative_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L119 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->mov64(a2, t5); // or a2, t5, r0 + c->mov64(a3, t4); // or a3, t4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->daddiu(t2, a2, 4); // daddiu t2, a2, 4 + // c->jalr(call_addr); // jalr ra, t9 + clip_polygon_against_negative_hyperplane::execute(ctxt); + bc = c->sgpr64(t0) == 0; // beq t0, r0, L119 + c->lw(a3, 4, a1); // lw a3, 4(a1) + if (bc) {goto block_7;} // branch non-likely + + c->mov64(a2, t4); // or a2, t4, r0 + // nop // sll r0, r0, 0 + c->sqc2(vf27, 0, a3); // sqc2 vf27, 0(a3) + c->daddiu(a3, a3, 16); // daddiu a3, a3, 16 + c->sw(t0, -16, a3); // sw t0, -16(a3) + // nop // sll r0, r0, 0 + + block_5: + c->lqc2(vf1, 0, a2); // lqc2 vf1, 0(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf2, 16, a2); // lqc2 vf2, 16(a2) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a2); // lqc2 vf3, 32(a2) + c->vdiv(vf0, BC::w, vf1, BC::w); // vdiv Q, vf0.w, vf1.w + c->vmul(DEST::xyzw, vf1, vf1, vf26); // vmul.xyzw vf1, vf1, vf26 + // nop // sll r0, r0, 0 + c->vftoi0(DEST::xyzw, vf3, vf3); // vftoi0.xyzw vf3, vf3 + // nop // sll r0, r0, 0 + c->vadd(DEST::xyzw, vf2, vf2, vf24); // vadd.xyzw vf2, vf2, vf24 + // nop // sll r0, r0, 0 + c->vwaitq(); // vwaitq + // nop // sll r0, r0, 0 + c->vmulq(DEST::xyz, vf1, vf1); // vmulq.xyz vf1, vf1, Q + c->sqc2(vf3, 16, a3); // sqc2 vf3, 16(a3) + c->vmulq(DEST::xyzw, vf2, vf2); // vmulq.xyzw vf2, vf2, Q + c->daddiu(a2, a2, 48); // daddiu a2, a2, 48 + c->vadd(DEST::xyzw, vf1, vf1, vf25); // vadd.xyzw vf1, vf1, vf25 + c->daddiu(a3, a3, 48); // daddiu a3, a3, 48 + c->vmul_bc(DEST::z, BC::z, vf1, vf1, vf0); // vmulz.z vf1, vf1, vf0 + // nop // sll r0, r0, 0 + c->vmini_bc(DEST::w, BC::z, vf1, vf1, vf13); // vminiz.w vf1, vf1, vf13 + // nop // sll r0, r0, 0 + c->vadd_bc(DEST::z, BC::x, vf1, vf1, vf23); // vaddx.z vf1, vf1, vf23 + // nop // sll r0, r0, 0 + c->vmax_bc(DEST::w, BC::y, vf1, vf1, vf13); // vmaxy.w vf1, vf1, vf13 + // nop // sll r0, r0, 0 + c->sqc2(vf2, -48, a3); // sqc2 vf2, -48(a3) + c->daddiu(t0, t0, -1); // daddiu t0, t0, -1 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + // nop // sll r0, r0, 0 + bc = c->sgpr64(t0) != 0; // bne t0, r0, L118 + c->sqc2(vf1, -16, a3); // sqc2 vf1, -16(a3) + if (bc) {goto block_5;} // branch non-likely + + c->sw(a3, 4, a1); // sw a3, 4(a1) + // nop // sll r0, r0, 0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->daddiu(v0, s7, 4); // daddiu v0, s7, 4 + //jr ra // jr ra + c->daddiu(sp, sp, 8); // daddiu sp, sp, 8 + goto end_of_function; // return + + + block_7: + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->mov64(v0, s7); // or v0, s7, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 8); // daddiu sp, sp, 8 + goto end_of_function; // return + + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.clip_polygon_against_negative_hyperplane = intern_from_c("clip-polygon-against-negative-hyperplane").c(); + cache.clip_polygon_against_positive_hyperplane = intern_from_c("clip-polygon-against-positive-hyperplane").c(); + gLinkedFunctionTable.reg("draw-large-polygon", execute, 1024); +} + +} // namespace draw_large_polygon +} // namespace Mips2C + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace render_sky_quad { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* math_camera; // *math-camera* + void* draw_large_polygon; // draw-large-polygon +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + c->mov64(v1, a0); // or v1, a0, r0 + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1) + get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672 + c->ori(t4, t4, 12288); // ori t4, t4, 12288 + get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672 + c->ori(t5, t5, 14336); // ori t5, t5, 14336 + c->mov64(a3, t4); // or a3, t4, r0 + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->addiu(t0, r0, 4); // addiu t0, r0, 4 + c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1 + c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1 + c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1 + c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf1, vf28, vf1); // vmaddw.xyw vf1, vf28, vf1 + c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0) + c->vmove(DEST::z, vf1, vf0); // vmove.z vf1, vf0 + c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4 + c->lqc2(vf9, 128, a0); // lqc2 vf9, 128(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4 + c->lqc2(vf10, 144, a0); // lqc2 vf10, 144(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4 + c->lqc2(vf11, 160, a0); // lqc2 vf11, 160(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf4, vf28, vf4); // vmaddw.xyw vf4, vf28, vf4 + c->lqc2(vf12, 176, a0); // lqc2 vf12, 176(a0) + c->vmove(DEST::z, vf4, vf0); // vmove.z vf4, vf0 + c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7 + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7 + c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7 + c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf7, vf28, vf7); // vmaddw.xyw vf7, vf28, vf7 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->vmove(DEST::z, vf7, vf0); // vmove.z vf7, vf0 + c->sqc2(vf9, 128, a3); // sqc2 vf9, 128(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf10); // vmulax.xyzw acc, vf31, vf10 + c->sqc2(vf11, 160, a3); // sqc2 vf11, 160(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf10); // vmadday.xyzw acc, vf30, vf10 + c->sqc2(vf12, 176, a3); // sqc2 vf12, 176(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf10); // vmaddaz.xyzw acc, vf29, vf10 + c->sqc2(vf2, 208, a3); // sqc2 vf2, 208(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf10, vf28, vf10); // vmaddw.xyw vf10, vf28, vf10 + c->sqc2(vf3, 224, a3); // sqc2 vf3, 224(a3) + c->vmove(DEST::z, vf10, vf0); // vmove.z vf10, vf0 + c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf1, 192, a3); // sqc2 vf1, 192(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf10, 144, a3); // sqc2 vf10, 144(a3) + c->load_symbol2(t9, cache.draw_large_polygon); // lw t9, draw-large-polygon(s7) + draw_large_polygon::execute(ctxt); + // Unknown instr: jr t9 + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + cache.math_camera = intern_from_c("*math-camera*").c(); + cache.draw_large_polygon = intern_from_c("draw-large-polygon").c(); + gLinkedFunctionTable.reg("render-sky-quad", execute, 1024); +} + +} // namespace render_sky_quad +} // namespace Mips2C + + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace render_sky_tri { +struct Cache { + void* fake_scratchpad_data; // *fake-scratchpad-data* + void* draw_large_polygon; // draw-large-polygon +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + c->mov64(v1, a0); // or v1, a0, r0 + get_fake_spad_addr2(t4, cache.fake_scratchpad_data, 0, c);// lui t4, 28672 + c->ori(t4, t4, 12288); // ori t4, t4, 12288 + get_fake_spad_addr2(t5, cache.fake_scratchpad_data, 0, c);// lui t5, 28672 + c->ori(t5, t5, 14336); // ori t5, t5, 14336 + c->mov64(a3, t4); // or a3, t4, r0 + // nop // sll r0, r0, 0 + c->lqc2(vf1, 0, a0); // lqc2 vf1, 0(a0) + c->addiu(t0, r0, 3); // addiu t0, r0, 3 + c->lqc2(vf2, 16, a0); // lqc2 vf2, 16(a0) + // nop // sll r0, r0, 0 + c->lqc2(vf3, 32, a0); // lqc2 vf3, 32(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf1); // vmulax.xyzw acc, vf31, vf1 + c->lqc2(vf4, 48, a0); // lqc2 vf4, 48(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf1); // vmadday.xyzw acc, vf30, vf1 + c->lqc2(vf5, 64, a0); // lqc2 vf5, 64(a0) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf1); // vmaddaz.xyzw acc, vf29, vf1 + c->lqc2(vf6, 80, a0); // lqc2 vf6, 80(a0) + c->vmadd_bc(DEST::xyw, BC::w, vf1, vf28, vf1); // vmaddw.xyw vf1, vf28, vf1 + c->lqc2(vf7, 96, a0); // lqc2 vf7, 96(a0) + c->vmove(DEST::z, vf1, vf0); // vmove.z vf1, vf0 + c->lqc2(vf8, 112, a0); // lqc2 vf8, 112(a0) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf4); // vmulax.xyzw acc, vf31, vf4 + c->lqc2(vf9, 128, a0); // lqc2 vf9, 128(a0) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf4); // vmadday.xyzw acc, vf30, vf4 + c->sqc2(vf2, 16, a3); // sqc2 vf2, 16(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf4); // vmaddaz.xyzw acc, vf29, vf4 + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf4, vf28, vf4); // vmaddw.xyw vf4, vf28, vf4 + c->sqc2(vf5, 64, a3); // sqc2 vf5, 64(a3) + c->vmove(DEST::z, vf4, vf0); // vmove.z vf4, vf0 + c->sqc2(vf6, 80, a3); // sqc2 vf6, 80(a3) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf7); // vmulax.xyzw acc, vf31, vf7 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf7); // vmadday.xyzw acc, vf30, vf7 + c->sqc2(vf9, 128, a3); // sqc2 vf9, 128(a3) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf7); // vmaddaz.xyzw acc, vf29, vf7 + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->vmadd_bc(DEST::xyw, BC::w, vf7, vf28, vf7); // vmaddw.xyw vf7, vf28, vf7 + c->sqc2(vf3, 176, a3); // sqc2 vf3, 176(a3) + c->vmove(DEST::z, vf7, vf0); // vmove.z vf7, vf0 + c->sqc2(vf1, 0, a3); // sqc2 vf1, 0(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf1, 144, a3); // sqc2 vf1, 144(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf4, 48, a3); // sqc2 vf4, 48(a3) + // nop // sll r0, r0, 0 + c->sqc2(vf7, 96, a3); // sqc2 vf7, 96(a3) + c->load_symbol2(t9, cache.draw_large_polygon); // lw t9, draw-large-polygon(s7) + draw_large_polygon::execute(ctxt); + // Unknown instr: jr t9 + // nop // sll r0, r0, 0 + //jr ra // jr ra + c->daddu(sp, sp, r0); // daddu sp, sp, r0 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + return c->gprs[v0].du64[0]; +} + +void link() { + cache.fake_scratchpad_data = intern_from_c("*fake-scratchpad-data*").c(); + cache.draw_large_polygon = intern_from_c("draw-large-polygon").c(); + gLinkedFunctionTable.reg("render-sky-tri", execute, 1024); +} + +} // namespace render_sky_tri +} // namespace Mips2C + + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace method_16_sky_work { +struct Cache { + void* math_camera; // *math-camera* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + bool bc = false; + bool cop1_bc = false; + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->load_symbol2(v1, cache.math_camera); // lw v1, *math-camera*(s7) + c->daddiu(a1, sp, 16); // daddiu a1, sp, 16 + c->sq(r0, 0, a1); // sq r0, 0(a1) + c->daddiu(a2, a0, 1424); // daddiu a2, a0, 1424 + c->mov64(a3, a1); // or a3, a1, r0 + c->daddiu(t0, v1, 812); // daddiu t0, v1, 812 + c->lq(t0, 0, t0); // lq t0, 0(t0) + c->sq(t0, 0, a3); // sq t0, 0(a3) + c->mtc1(f0, r0); // mtc1 f0, r0 + c->lwc1(f1, 928, v1); // lwc1 f1, 928(v1) + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L85 + // nop // sll r0, r0, 0 + if (bc) {goto block_2;} // branch non-likely + + c->lui(a3, 17664); // lui a3, 17664 + c->ori(a3, a3, 4096); // ori a3, a3, 4096 + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 4, a1); // swc1 f0, 4(a1) + c->mfc1(a3, f0); // mfc1 a3, f0 + //beq r0, r0, L86 // beq r0, r0, L86 + // nop // sll r0, r0, 0 + goto block_3; // branch always + + + block_2: + c->lui(a3, 17663); // lui a3, 17663 + c->ori(a3, a3, 57344); // ori a3, a3, 57344 + c->mtc1(f0, a3); // mtc1 f0, a3 + c->swc1(f0, 4, a1); // swc1 f0, 4(a1) + c->mfc1(a3, f0); // mfc1 a3, f0 + + block_3: + c->daddiu(a3, a0, 1008); // daddiu a3, a0, 1008 + c->lwc1(f0, 908, v1); // lwc1 f0, 908(v1) + c->swc1(f0, 0, a3); // swc1 f0, 0(a3) + c->lwc1(f0, 128, v1); // lwc1 f0, 128(v1) + c->swc1(f0, 4, a3); // swc1 f0, 4(a3) + c->lwc1(f0, 124, v1); // lwc1 f0, 124(v1) + c->swc1(f0, 8, a3); // swc1 f0, 8(a3) + c->lui(t0, 17727); // lui t0, 17727 + c->ori(t0, t0, 61440); // ori t0, t0, 61440 + c->mtc1(f0, t0); // mtc1 f0, t0 + c->swc1(f0, 12, a3); // swc1 f0, 12(a3) + c->lqc2(vf31, 0, a2); // lqc2 vf31, 0(a2) + c->lqc2(vf30, 16, a2); // lqc2 vf30, 16(a2) + c->lqc2(vf29, 32, a2); // lqc2 vf29, 32(a2) + c->lqc2(vf28, 48, a2); // lqc2 vf28, 48(a2) + c->lqc2(vf14, 780, v1); // lqc2 vf14, 780(v1) + c->lqc2(vf26, 796, v1); // lqc2 vf26, 796(v1) + c->lqc2(vf25, 0, a1); // lqc2 vf25, 0(a1) + c->lqc2(vf13, 1008, a0); // lqc2 vf13, 1008(a0) + c->vmul(DEST::xyzw, vf31, vf31, vf14); // vmul.xyzw vf31, vf31, vf14 + c->vmul(DEST::xyzw, vf30, vf30, vf14); // vmul.xyzw vf30, vf30, vf14 + c->vmul(DEST::xyzw, vf29, vf29, vf14); // vmul.xyzw vf29, vf29, vf14 + c->vmul(DEST::xyzw, vf28, vf28, vf14); // vmul.xyzw vf28, vf28, vf14 + c->vmove(DEST::z, vf25, vf0); // vmove.z vf25, vf0 + c->vmove(DEST::xyzw, vf24, vf0); // vmove.xyzw vf24, vf0 + c->vmove(DEST::xyzw, vf23, vf0); // vmove.xyzw vf23, vf0 + c->mov128_gpr_vf(v1, vf23); // qmfc2.i v1, vf23 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c("*math-camera*").c(); + gLinkedFunctionTable.reg("(method 16 sky-work)", execute, 64); +} + +} // namespace method_16_sky_work +} // namespace Mips2C + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace method_17_sky_work { +struct Cache { + void* math_camera; // *math-camera* +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -32); // daddiu sp, sp, -32 + c->load_symbol2(a1, cache.math_camera); // lw a1, *math-camera*(s7) + c->daddiu(v1, a0, 1424); // daddiu v1, a0, 1424 + c->lqc2(vf31, 0, v1); // lqc2 vf31, 0(v1) + c->lqc2(vf30, 16, v1); // lqc2 vf30, 16(v1) + c->lqc2(vf29, 32, v1); // lqc2 vf29, 32(v1) + c->lqc2(vf28, 48, v1); // lqc2 vf28, 48(v1) + c->lqc2(vf14, 780, a1); // lqc2 vf14, 780(a1) + c->lqc2(vf25, 812, a1); // lqc2 vf25, 812(a1) + c->lqc2(vf13, 1008, a0); // lqc2 vf13, 1008(a0) + c->vmove(DEST::z, vf25, vf0); // vmove.z vf25, vf0 + c->vmove(DEST::xyzw, vf23, vf0); // vmove.xyzw vf23, vf0 + c->daddiu(v1, sp, 16); // daddiu v1, sp, 16 + c->sq(r0, 0, v1); // sq r0, 0(v1) + c->lui(a0, 16256); // lui a0, 16256 + c->mtc1(f0, a0); // mtc1 f0, a0 + c->lui(a0, 17974); // lui a0, 17974 + c->ori(a0, a0, 2913); // ori a0, a0, 2913 + c->mtc1(f1, a0); // mtc1 f1, a0 + c->lwc1(f2, 8, a1); // lwc1 f2, 8(a1) + c->divs(f1, f1, f2); // div.s f1, f1, f2 + c->mins(f0, f0, f1); // min.s f0, f0, f1 + c->swc1(f0, 12, v1); // swc1 f0, 12(v1) + c->lqc2(vf26, 0, v1); // lqc2 vf26, 0(v1) + c->mov128_gpr_vf(v1, vf26); // qmfc2.i v1, vf26 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + //jr ra // jr ra + c->daddiu(sp, sp, 32); // daddiu sp, sp, 32 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.math_camera = intern_from_c("*math-camera*").c(); + gLinkedFunctionTable.reg("(method 17 sky-work)", execute, 64); +} + +} // namespace method_17_sky_work +} // namespace Mips2C + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace method_32_sky_work { +struct Cache { + void* vector_normalize; // vector-normalize! +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -48); // daddiu sp, sp, -48 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 16, sp); // sq s5, 16(sp) + c->sq(gp, 32, sp); // sq gp, 32(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->mov64(v1, gp); // or v1, gp, r0 + c->lqc2(vf31, 1488, gp); // lqc2 vf31, 1488(gp) + c->lqc2(vf30, 1504, gp); // lqc2 vf30, 1504(gp) + c->lqc2(vf29, 1520, gp); // lqc2 vf29, 1520(gp) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + //beq r0, r0, L37 // beq r0, r0, L37 + // nop // sll r0, r0, 0 + goto block_10; // branch always + + + block_1: + c->daddiu(a2, a1, 3); // daddiu a2, a1, 3 + c->daddiu(t0, a1, 5); // daddiu t0, a1, 5 + c->daddiu(a3, a1, 7); // daddiu a3, a1, 7 + c->andi(a2, a2, 7); // andi a2, a2, 7 + c->andi(t1, t0, 7); // andi t1, t0, 7 + c->andi(t2, a3, 7); // andi t2, a3, 7 + c->dsll(a3, a1, 4); // dsll a3, a1, 4 + c->dsll(t0, a2, 4); // dsll t0, a2, 4 + c->dsll(t1, t1, 4); // dsll t1, t1, 4 + c->dsll(a2, t2, 4); // dsll a2, t2, 4 + c->daddu(t3, a3, gp); // daddu t3, a3, gp + c->daddu(t2, t0, gp); // daddu t2, t0, gp + c->daddu(a3, t1, gp); // daddu a3, t1, gp + c->lq(t0, 816, t3); // lq t0, 816(t3) + c->daddu(a2, a2, gp); // daddu a2, a2, gp + c->lq(t1, 816, t2); // lq t1, 816(t2) + c->daddiu(a1, a1, 1); // daddiu a1, a1, 1 + c->lq(a3, 816, a3); // lq a3, 816(a3) + c->paddb(t0, t0, t1); // paddb t0, t0, t1 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->paddb(a3, t0, a3); // paddb a3, t0, a3 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->andi(a1, a1, 7); // andi a1, a1, 7 + c->sq(a3, 816, a2); // sq a3, 816(a2) + c->pextlb(t0, a3, r0); // pextlb t0, a3, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextub(a2, a3, r0); // pextub a2, a3, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextuh(a3, t0, r0); // pextuh a3, t0, r0 + c->mfc1(r0, f31); // mfc1 r0, f31 + c->pextlh(t0, t0, r0); // pextlh t0, t0, r0 + c->mov128_vf_gpr(vf15, a3); // qmtc2.i vf15, a3 + c->pextuh(a3, a2, r0); // pextuh a3, a2, r0 + c->mov128_vf_gpr(vf16, t0); // qmtc2.i vf16, t0 + c->pextlh(a2, a2, r0); // pextlh a2, a2, r0 + c->mov128_vf_gpr(vf17, a3); // qmtc2.i vf17, a3 + // nop // sll r0, r0, 0 + c->mov128_vf_gpr(vf18, a2); // qmtc2.i vf18, a2 + c->vitof15(DEST::xyzw, vf15, vf15); // vitof15.xyzw vf15, vf15 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf16, vf16); // vitof15.xyzw vf16, vf16 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf17, vf17); // vitof15.xyzw vf17, vf17 + // nop // sll r0, r0, 0 + c->vitof15(DEST::xyzw, vf18, vf18); // vitof15.xyzw vf18, vf18 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf15, vf29, vf15); // vmaddz.xyzw vf15, vf29, vf15 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf16); // vmulax.xyzw acc, vf31, vf16 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf16); // vmadday.xyzw acc, vf30, vf16 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf16, vf29, vf16); // vmaddz.xyzw vf16, vf29, vf16 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf17); // vmulax.xyzw acc, vf31, vf17 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf17); // vmadday.xyzw acc, vf30, vf17 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf17, vf29, vf17); // vmaddz.xyzw vf17, vf29, vf17 + // nop // sll r0, r0, 0 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf18); // vmulax.xyzw acc, vf31, vf18 + // nop // sll r0, r0, 0 + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf18); // vmadday.xyzw acc, vf30, vf18 + // nop // sll r0, r0, 0 + c->vmadd_bc(DEST::xyzw, BC::z, vf18, vf29, vf18); // vmaddz.xyzw vf18, vf29, vf18 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a2, vf15); // qmfc2.i a2, vf15 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(a3, vf16); // qmfc2.i a3, vf16 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t0, vf17); // qmfc2.i t0, vf17 + // nop // sll r0, r0, 0 + c->mov128_gpr_vf(t1, vf18); // qmfc2.i t1, vf18 + // nop // sll r0, r0, 0 + bc = ((s64)c->sgpr64(a2)) >= 0; // bgez a2, L33 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->vsub(DEST::xyz, vf15, vf0, vf15); // vsub.xyz vf15, vf0, vf15 + // nop // sll r0, r0, 0 + + block_3: + bc = ((s64)c->sgpr64(a3)) >= 0; // bgez a3, L34 + // nop // sll r0, r0, 0 + if (bc) {goto block_5;} // branch non-likely + + c->vsub(DEST::xyz, vf16, vf0, vf16); // vsub.xyz vf16, vf0, vf16 + // nop // sll r0, r0, 0 + + block_5: + bc = ((s64)c->sgpr64(t0)) >= 0; // bgez t0, L35 + // nop // sll r0, r0, 0 + if (bc) {goto block_7;} // branch non-likely + + c->vsub(DEST::xyz, vf17, vf0, vf17); // vsub.xyz vf17, vf0, vf17 + // nop // sll r0, r0, 0 + + block_7: + bc = ((s64)c->sgpr64(t1)) >= 0; // bgez t1, L36 + // nop // sll r0, r0, 0 + if (bc) {goto block_9;} // branch non-likely + + c->vsub(DEST::xyz, vf18, vf0, vf18); // vsub.xyz vf18, vf0, vf18 + // nop // sll r0, r0, 0 + + block_9: + c->sqc2(vf15, 1888, v1); // sqc2 vf15, 1888(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf16, 1904, v1); // sqc2 vf16, 1904(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf17, 1920, v1); // sqc2 vf17, 1920(v1) + // nop // sll r0, r0, 0 + c->sqc2(vf18, 1936, v1); // sqc2 vf18, 1936(v1) + c->daddiu(v1, v1, 64); // daddiu v1, v1, 64 + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + + block_10: + c->slti(a2, a0, 128); // slti a2, a0, 128 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L32 + // nop // sll r0, r0, 0 + if (bc) {goto block_1;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->addiu(s5, r0, 0); // addiu s5, r0, 0 + //beq r0, r0, L39 // beq r0, r0, L39 + // nop // sll r0, r0, 0 + goto block_13; // branch always + + + block_12: + c->load_symbol2(t9, cache.vector_normalize); // lw t9, vector-normalize!(s7) + c->dsll(v1, s5, 4); // dsll v1, s5, 4 + c->daddiu(v1, v1, 1888); // daddiu v1, v1, 1888 + c->daddu(a0, v1, gp); // daddu a0, v1, gp + c->lui(v1, 18243); // lui v1, 18243 + c->ori(a1, v1, 20480); // ori a1, v1, 20480 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->daddiu(s5, s5, 1); // daddiu s5, s5, 1 + + block_13: + c->slti(v1, s5, 512); // slti v1, s5, 512 + bc = c->sgpr64(v1) != 0; // bne v1, r0, L38 + // nop // sll r0, r0, 0 + if (bc) {goto block_12;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 32, sp); // lq gp, 32(sp) + c->lq(s5, 16, sp); // lq s5, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 48); // daddiu sp, sp, 48 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + + return c->gprs[v0].du64[0]; +} + +void link() { + cache.vector_normalize = intern_from_c("vector-normalize!").c(); + gLinkedFunctionTable.reg("(method 32 sky-work)", execute, 128); +} + +} // namespace method_32_sky_work +} // namespace Mips2C + +using ::jak2::intern_from_c; +namespace Mips2C::jak2 { +namespace method_33_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + c->copy_vfs_from_other(&sky_regs_vfs); + bool bc = false; + u32 call_addr = 0; + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s4, 16, sp); // sq s4, 16(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(s5, a0); // or s5, a0, r0 + c->mov64(gp, a1); // or gp, a1, r0 + c->sw(gp, 1868, s5); // sw gp, 1868(s5) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 18256); // lui v1, 18256 + c->ori(a0, v1, 1280); // ori a0, v1, 1280 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->mov64(a1, v0); // or a1, v0, r0 + bc = c->sgpr64(s7) == c->sgpr64(a1); // beq s7, a1, L30 + c->mov64(a3, s7); // or a3, s7, r0 + if (bc) {goto block_15;} // branch non-likely + + c->lwu(v1, 1868, s5); // lwu v1, 1868(s5) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, s5); // lq a0, 0(s5) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, s5); // lq a0, 16(s5) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s4, v1, 32); // daddiu s4, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s4); // or a0, s4, r0 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s4); // sd v1, 64(s4) + c->lwu(v1, 1868, s5); // lwu v1, 1868(s5) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 112); // daddiu v1, v1, 112 + c->lwu(a0, 1868, s5); // lwu a0, 1868(s5) + c->sw(v1, 4, a0); // sw v1, 4(a0) + c->lw(a3, 4, gp); // lw a3, 4(gp) + c->mov64(v1, s5); // or v1, s5, r0 + c->addiu(a1, r0, 0); // addiu a1, r0, 0 + c->lqc2(vf2, 784, s5); // lqc2 vf2, 784(s5) + c->lqc2(vf5, 800, s5); // lqc2 vf5, 800(s5) + c->lqc2(vf8, 32, s5); // lqc2 vf8, 32(s5) + c->lqc2(vf11, 48, s5); // lqc2 vf11, 48(s5) + c->addiu(a0, r0, 0); // addiu a0, r0, 0 + //beq r0, r0, L29 // beq r0, r0, L29 + // nop // sll r0, r0, 0 + goto block_13; // branch always + + // nop // sll r0, r0, 0 + + block_3: + c->lqc2(vf15, 1888, v1); // lqc2 vf15, 1888(v1) + c->daddiu(v1, v1, 16); // daddiu v1, v1, 16 + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 384, s5); // lqc2 vf1, 384(s5) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 400, s5); // lqc2 vf4, 400(s5) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->daddu(a2, s5, a1); // daddu a2, s5, a1 + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf3, 528, a2); // lqc2 vf3, 528(a2) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->daddiu(a1, a1, 16); // daddiu a1, a1, 16 + c->vwaitq(); // vwaitq + c->andi(a1, a1, 255); // andi a1, a1, 255 + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1552, s5); // sqc2 vf1, 1552(s5) + c->sqc2(vf4, 1568, s5); // sqc2 vf4, 1568(s5) + c->lw(a2, 1552, s5); // lw a2, 1552(s5) + c->ori(t0, r0, 36864); // ori t0, r0, 36864 + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L27 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + + c->lw(a2, 1556, s5); // lw a2, 1556(s5) + c->ori(t0, r0, 36096); // ori t0, r0, 36096 + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L27 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + + c->addiu(a2, r0, 28672); // addiu a2, r0, 28672 + c->lw(t0, 1568, s5); // lw t0, 1568(s5) + c->slt(a2, a2, t0); // slt a2, a2, t0 + c->daddiu(t0, s7, 4); // daddiu t0, s7, 4 + c->movz(t0, s7, a2); // movz t0, s7, a2 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(t0))) {// beql s7, t0, L27 + c->mov64(a2, t0); // or a2, t0, r0 + goto block_10; + } + + c->addiu(a2, r0, 29440); // addiu a2, r0, 29440 + c->lw(t0, 1572, s5); // lw t0, 1572(s5) + c->slt(t0, a2, t0); // slt t0, a2, t0 + c->daddiu(a2, s7, 4); // daddiu a2, s7, 4 + c->movz(a2, s7, t0); // movz a2, s7, t0 + + block_10: + bc = c->sgpr64(s7) == c->sgpr64(a2); // beq s7, a2, L28 + c->mov64(a2, s7); // or a2, s7, r0 + if (bc) {goto block_12;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 0, a3); // sqc2 vf8, 0(a3) + c->sqc2(vf11, 16, a3); // sqc2 vf11, 16(a3) + c->sqc2(vf3, 32, a3); // sqc2 vf3, 32(a3) + c->sqc2(vf2, 48, a3); // sqc2 vf2, 48(a3) + c->sqc2(vf1, 64, a3); // sqc2 vf1, 64(a3) + c->sqc2(vf5, 80, a3); // sqc2 vf5, 80(a3) + c->sqc2(vf4, 96, a3); // sqc2 vf4, 96(a3) + c->daddiu(a3, a3, 112); // daddiu a3, a3, 112 + c->mov64(a2, a3); // or a2, a3, r0 + + block_12: + c->daddiu(a0, a0, 1); // daddiu a0, a0, 1 + + block_13: + c->slti(a2, a0, 512); // slti a2, a0, 512 + bc = c->sgpr64(a2) != 0; // bne a2, r0, L26 + // nop // sll r0, r0, 0 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + c->mov64(v1, s7); // or v1, s7, r0 + c->sw(a3, 4, gp); // sw a3, 4(gp) + + block_15: + c->mov64(v1, a3); // or v1, a3, r0 + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + c->lq(s5, 32, sp); // lq s5, 32(sp) + c->lq(s4, 16, sp); // lq s4, 16(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c("adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c("lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 33 sky-work)", execute, 256); +} + +} // namespace method_33_sky_work +} // namespace Mips2C + +namespace Mips2C::jak2 { +namespace method_28_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 1868, gp); // sw a1, 1868(gp) + c->lw(a3, 4, a1); // lw a3, 4(a1) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 18256); // lui v1, 18256 + c->ori(a0, v1, 1024); // ori a0, v1, 1024 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 16, sp); // sw v0, 16(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L55 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->lqc2(vf15, 1168, gp); // lqc2 vf15, 1168(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 224, gp); // lqc2 vf1, 224(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 240, gp); // lqc2 vf4, 240(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 784, gp); // lqc2 vf2, 784(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 800, gp); // lqc2 vf5, 800(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf3, 416, gp); // lqc2 vf3, 416(gp) + c->lqc2(vf6, 432, gp); // lqc2 vf6, 432(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyz, vf1, vf1); // vftoi4.xyz vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1552, gp); // sqc2 vf1, 1552(gp) + c->sqc2(vf4, 1568, gp); // sqc2 vf4, 1568(gp) + c->lw(v1, 1564, gp); // lw v1, 1564(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L53 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + + block_3: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L54 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_12; + } + + c->lw(v1, 1552, gp); // lw v1, 1552(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L54 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->lw(v1, 1556, gp); // lw v1, 1556(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L54 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1568, gp); // lw a0, 1568(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L54 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1572, gp); // lw a0, 1572(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + + block_12: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L55 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf1, 288, a3); // sqc2 vf1, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf4, 320, a3); // sqc2 vf4, 320(a3) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, gp); // lq a0, 0(gp) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, gp); // lq a0, 16(gp) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s5, v1, 32); // daddiu s5, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 336); // daddiu v1, v1, 336 + c->lwu(a0, 1868, gp); // lwu a0, 1868(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + + block_14: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + c->lq(s5, 32, sp); // lq s5, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c("adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c("lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 28 sky-work)", execute, 128); +} + +} // namespace method_28_sky_work +} // namespace Mips2C + +namespace Mips2C::jak2 { +namespace method_29_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + c->daddiu(sp, sp, -64); // daddiu sp, sp, -64 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s5, 32, sp); // sq s5, 32(sp) + c->sq(gp, 48, sp); // sq gp, 48(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 1868, gp); // sw a1, 1868(gp) + c->lw(a3, 4, a1); // lw a3, 4(a1) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 18256); // lui v1, 18256 + c->ori(a0, v1, 1024); // ori a0, v1, 1024 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 16, sp); // sw v0, 16(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L51 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->lqc2(vf15, 1232, gp); // lqc2 vf15, 1232(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 256, gp); // lqc2 vf1, 256(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 272, gp); // lqc2 vf4, 272(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 784, gp); // lqc2 vf2, 784(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 800, gp); // lqc2 vf5, 800(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf3, 448, gp); // lqc2 vf3, 448(gp) + c->lqc2(vf6, 464, gp); // lqc2 vf6, 464(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vftoi4(DEST::xyz, vf1, vf1); // vftoi4.xyz vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->sqc2(vf1, 1552, gp); // sqc2 vf1, 1552(gp) + c->sqc2(vf4, 1568, gp); // sqc2 vf4, 1568(gp) + c->lw(v1, 1564, gp); // lw v1, 1564(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L49 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_3;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + + block_3: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L50 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_12; + } + + c->lw(v1, 1552, gp); // lw v1, 1552(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L50 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->lw(v1, 1556, gp); // lw v1, 1556(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L50 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1568, gp); // lw a0, 1568(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L50 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_12; + } + + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1572, gp); // lw a0, 1572(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + + block_12: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L51 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_14;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf1, 288, a3); // sqc2 vf1, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf4, 320, a3); // sqc2 vf4, 320(a3) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->lq(a0, 0, gp); // lq a0, 0(gp) + c->sq(a0, 0, v1); // sq a0, 0(v1) + c->lq(a0, 16, gp); // lq a0, 16(gp) + c->sq(a0, 16, v1); // sq a0, 16(v1) + c->daddiu(s5, v1, 32); // daddiu s5, v1, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 336); // daddiu v1, v1, 336 + c->lwu(a0, 1868, gp); // lwu a0, 1868(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + + block_14: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 48, sp); // lq gp, 48(sp) + c->lq(s5, 32, sp); // lq s5, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 64); // daddiu sp, sp, 64 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c("adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c("lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 29 sky-work)", execute, 128); +} + +} // namespace method_29_sky_work +} // namespace Mips2C + +namespace Mips2C::jak2 { +namespace method_30_sky_work { +struct Cache { + void* adgif_shader_texture_simple; // adgif-shader<-texture-simple! + void* lookup_texture_by_id_fast; // lookup-texture-by-id-fast +} cache; + +u64 execute(void* ctxt) { + auto* c = (ExecutionContext*)ctxt; + bool bc = false; + u32 call_addr = 0; + bool cop1_bc = false; + c->copy_vfs_from_other(&sky_regs_vfs); + + c->daddiu(sp, sp, -80); // daddiu sp, sp, -80 + c->sd(ra, 0, sp); // sd ra, 0(sp) + c->sq(s4, 32, sp); // sq s4, 32(sp) + c->sq(s5, 48, sp); // sq s5, 48(sp) + c->sq(gp, 64, sp); // sq gp, 64(sp) + c->mov64(gp, a0); // or gp, a0, r0 + c->sw(a1, 1868, gp); // sw a1, 1868(gp) + c->lw(a3, 4, a1); // lw a3, 4(a1) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 18256); // lui v1, 18256 + c->ori(a0, v1, 1024); // ori a0, v1, 1024 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 16, sp); // sw v0, 16(sp) + c->load_symbol2(t9, cache.lookup_texture_by_id_fast);// lw t9, lookup-texture-by-id-fast(s7) + c->lui(v1, 18256); // lui v1, 18256 + c->ori(a0, v1, 256); // ori a0, v1, 256 + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->sw(v0, 20, sp); // sw v0, 20(sp) + c->lwu(v1, 16, sp); // lwu v1, 16(sp) + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L44 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_3; + } + + c->lwu(v1, 20, sp); // lwu v1, 20(sp) + + block_3: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L47 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_17;} // branch non-likely + + c->lqc2(vf15, 1296, gp); // lqc2 vf15, 1296(gp) + c->vmula_bc(DEST::xyzw, BC::x, vf31, vf15); // vmulax.xyzw acc, vf31, vf15 + c->lqc2(vf1, 288, gp); // lqc2 vf1, 288(gp) + c->vmadda_bc(DEST::xyzw, BC::y, vf30, vf15); // vmadday.xyzw acc, vf30, vf15 + c->lqc2(vf4, 304, gp); // lqc2 vf4, 304(gp) + c->vmadda_bc(DEST::xyzw, BC::z, vf29, vf15); // vmaddaz.xyzw acc, vf29, vf15 + c->lqc2(vf2, 784, gp); // lqc2 vf2, 784(gp) + c->vmadd_bc(DEST::xyzw, BC::w, vf15, vf28, vf0); // vmaddw.xyzw vf15, vf28, vf0 + // nop // sll r0, r0, 0 + c->vmul(DEST::xyzw, vf16, vf15, vf14); // vmul.xyzw vf16, vf15, vf14 + c->lqc2(vf5, 800, gp); // lqc2 vf5, 800(gp) + c->vdiv(vf0, BC::w, vf16, BC::w); // vdiv Q, vf0.w, vf16.w + c->lqc2(vf8, 32, gp); // lqc2 vf8, 32(gp) + c->lqc2(vf11, 48, gp); // lqc2 vf11, 48(gp) + c->lqc2(vf7, 320, gp); // lqc2 vf7, 320(gp) + c->lqc2(vf10, 336, gp); // lqc2 vf10, 336(gp) + c->lqc2(vf17, 352, gp); // lqc2 vf17, 352(gp) + c->lqc2(vf18, 368, gp); // lqc2 vf18, 368(gp) + c->lqc2(vf3, 480, gp); // lqc2 vf3, 480(gp) + c->lqc2(vf6, 496, gp); // lqc2 vf6, 496(gp) + c->lqc2(vf9, 512, gp); // lqc2 vf9, 512(gp) + c->vwaitq(); // vwaitq + c->vmulq(DEST::xyz, vf15, vf15); // vmulq.xyz vf15, vf15, Q + c->vmulq(DEST::xyzw, vf16, vf26); // vmulq.xyzw vf16, vf26, Q + c->vmul_bc(DEST::xyzw, BC::w, vf1, vf1, vf16); // vmulw.xyzw vf1, vf1, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf4, vf4, vf16); // vmulw.xyzw vf4, vf4, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf7, vf7, vf16); // vmulw.xyzw vf7, vf7, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf10, vf10, vf16); // vmulw.xyzw vf10, vf10, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf17, vf17, vf16); // vmulw.xyzw vf17, vf17, vf16 + c->vmul_bc(DEST::xyzw, BC::w, vf18, vf18, vf16); // vmulw.xyzw vf18, vf18, vf16 + c->vadd(DEST::xyzw, vf15, vf15, vf25); // vadd.xyzw vf15, vf15, vf25 + c->vadd(DEST::xyz, vf1, vf1, vf15); // vadd.xyz vf1, vf1, vf15 + c->vadd(DEST::xyz, vf4, vf4, vf15); // vadd.xyz vf4, vf4, vf15 + c->vadd(DEST::xyz, vf7, vf7, vf15); // vadd.xyz vf7, vf7, vf15 + c->vadd(DEST::xyz, vf10, vf10, vf15); // vadd.xyz vf10, vf10, vf15 + c->vadd(DEST::xyz, vf17, vf17, vf15); // vadd.xyz vf17, vf17, vf15 + c->vadd(DEST::xyz, vf18, vf18, vf15); // vadd.xyz vf18, vf18, vf15 + c->vftoi4(DEST::xyzw, vf1, vf1); // vftoi4.xyzw vf1, vf1 + c->vftoi4(DEST::xyzw, vf4, vf4); // vftoi4.xyzw vf4, vf4 + c->vftoi4(DEST::xyz, vf7, vf7); // vftoi4.xyz vf7, vf7 + c->vftoi4(DEST::xyzw, vf10, vf10); // vftoi4.xyzw vf10, vf10 + c->vftoi4(DEST::xyzw, vf17, vf17); // vftoi4.xyzw vf17, vf17 + c->vftoi4(DEST::xyzw, vf18, vf18); // vftoi4.xyzw vf18, vf18 + c->sqc2(vf7, 1552, gp); // sqc2 vf7, 1552(gp) + c->sqc2(vf10, 1568, gp); // sqc2 vf10, 1568(gp) + c->lw(v1, 1564, gp); // lw v1, 1564(gp) + c->mtc1(f0, v1); // mtc1 f0, v1 + c->mtc1(f1, r0); // mtc1 f1, r0 + cop1_bc = c->fprs[f0] < c->fprs[f1]; // c.lt.s f0, f1 + bc = !cop1_bc; // bc1f L45 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + if (bc) {goto block_6;} // branch non-likely + + c->mov64(v1, s7); // or v1, s7, r0 + + block_6: + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(v1))) {// beql s7, v1, L46 + c->mov64(v1, v1); // or v1, v1, r0 + goto block_15; + } + + c->lw(v1, 1552, gp); // lw v1, 1552(gp) + c->ori(a0, r0, 36864); // ori a0, r0, 36864 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L46 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + + c->lw(v1, 1556, gp); // lw v1, 1556(gp) + c->ori(a0, r0, 36096); // ori a0, r0, 36096 + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L46 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + + c->addiu(v1, r0, 28672); // addiu v1, r0, 28672 + c->lw(a0, 1568, gp); // lw a0, 1568(gp) + c->slt(v1, v1, a0); // slt v1, v1, a0 + c->daddiu(a0, s7, 4); // daddiu a0, s7, 4 + c->movz(a0, s7, v1); // movz a0, s7, v1 + if (((s64)c->sgpr64(s7)) == ((s64)c->sgpr64(a0))) {// beql s7, a0, L46 + c->mov64(v1, a0); // or v1, a0, r0 + goto block_15; + } + + c->addiu(v1, r0, 29440); // addiu v1, r0, 29440 + c->lw(a0, 1572, gp); // lw a0, 1572(gp) + c->slt(a0, v1, a0); // slt a0, v1, a0 + c->daddiu(v1, s7, 4); // daddiu v1, s7, 4 + c->movz(v1, s7, a0); // movz v1, s7, a0 + + block_15: + bc = c->sgpr64(s7) == c->sgpr64(v1); // beq s7, v1, L47 + c->mov64(v1, s7); // or v1, s7, r0 + if (bc) {goto block_17;} // branch non-likely + + c->vsub(DEST::z, vf1, vf0, vf0); // vsub.z vf1, vf0, vf0 + c->vsub(DEST::z, vf4, vf0, vf0); // vsub.z vf4, vf0, vf0 + c->vsub(DEST::z, vf7, vf0, vf0); // vsub.z vf7, vf0, vf0 + c->vsub(DEST::z, vf10, vf0, vf0); // vsub.z vf10, vf0, vf0 + c->vsub(DEST::z, vf17, vf0, vf0); // vsub.z vf17, vf0, vf0 + c->vsub(DEST::z, vf18, vf0, vf0); // vsub.z vf18, vf0, vf0 + c->sqc2(vf8, 112, a3); // sqc2 vf8, 112(a3) + c->sqc2(vf11, 128, a3); // sqc2 vf11, 128(a3) + c->sqc2(vf3, 144, a3); // sqc2 vf3, 144(a3) + c->sqc2(vf2, 160, a3); // sqc2 vf2, 160(a3) + c->sqc2(vf1, 176, a3); // sqc2 vf1, 176(a3) + c->sqc2(vf5, 192, a3); // sqc2 vf5, 192(a3) + c->sqc2(vf4, 208, a3); // sqc2 vf4, 208(a3) + c->sqc2(vf8, 224, a3); // sqc2 vf8, 224(a3) + c->sqc2(vf11, 240, a3); // sqc2 vf11, 240(a3) + c->sqc2(vf6, 256, a3); // sqc2 vf6, 256(a3) + c->sqc2(vf2, 272, a3); // sqc2 vf2, 272(a3) + c->sqc2(vf7, 288, a3); // sqc2 vf7, 288(a3) + c->sqc2(vf5, 304, a3); // sqc2 vf5, 304(a3) + c->sqc2(vf10, 320, a3); // sqc2 vf10, 320(a3) + c->sqc2(vf8, 448, a3); // sqc2 vf8, 448(a3) + c->sqc2(vf11, 464, a3); // sqc2 vf11, 464(a3) + c->sqc2(vf9, 480, a3); // sqc2 vf9, 480(a3) + c->sqc2(vf2, 496, a3); // sqc2 vf2, 496(a3) + c->sqc2(vf17, 512, a3); // sqc2 vf17, 512(a3) + c->sqc2(vf5, 528, a3); // sqc2 vf5, 528(a3) + c->sqc2(vf18, 544, a3); // sqc2 vf18, 544(a3) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(s5, 4, v1); // lwu s5, 4(v1) + c->lq(v1, 0, gp); // lq v1, 0(gp) + c->sq(v1, 0, s5); // sq v1, 0(s5) + c->lq(v1, 16, gp); // lq v1, 16(gp) + c->sq(v1, 16, s5); // sq v1, 16(s5) + c->daddiu(s4, s5, 32); // daddiu s4, s5, 32 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s4); // or a0, s4, r0 + c->lwu(a1, 16, sp); // lwu a1, 16(sp) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->addiu(v1, r0, 72); // addiu v1, r0, 72 + c->sd(v1, 64, s4); // sd v1, 64(s4) + c->lq(v1, 0, gp); // lq v1, 0(gp) + c->sq(v1, 336, s5); // sq v1, 336(s5) + c->lq(v1, 16, gp); // lq v1, 16(gp) + c->sq(v1, 352, s5); // sq v1, 352(s5) + c->daddiu(s5, s5, 368); // daddiu s5, s5, 368 + c->load_symbol2(t9, cache.adgif_shader_texture_simple);// lw t9, adgif-shader<-texture-simple!(s7) + c->mov64(a0, s5); // or a0, s5, r0 + c->lwu(a1, 20, sp); // lwu a1, 20(sp) + call_addr = c->gprs[t9].du32[0]; // function call: + c->sll(v0, ra, 0); // sll v0, ra, 0 + c->jalr(call_addr); // jalr ra, t9 + c->addiu(v1, r0, 68); // addiu v1, r0, 68 + c->sd(v1, 64, s5); // sd v1, 64(s5) + c->lwu(v1, 1868, gp); // lwu v1, 1868(gp) + c->lwu(v1, 4, v1); // lwu v1, 4(v1) + c->daddiu(v1, v1, 560); // daddiu v1, v1, 560 + c->lwu(a0, 1868, gp); // lwu a0, 1868(gp) + c->sw(v1, 4, a0); // sw v1, 4(a0) + + block_17: + c->gprs[v0].du64[0] = 0; // or v0, r0, r0 + c->ld(ra, 0, sp); // ld ra, 0(sp) + c->lq(gp, 64, sp); // lq gp, 64(sp) + c->lq(s5, 48, sp); // lq s5, 48(sp) + c->lq(s4, 32, sp); // lq s4, 32(sp) + //jr ra // jr ra + c->daddiu(sp, sp, 80); // daddiu sp, sp, 80 + goto end_of_function; // return + + // nop // sll r0, r0, 0 + // nop // sll r0, r0, 0 + end_of_function: + sky_regs_vfs.copy_vfs_from_other(c); + return c->gprs[v0].du64[0]; +} + +void link() { + cache.adgif_shader_texture_simple = intern_from_c("adgif-shader<-texture-simple!").c(); + cache.lookup_texture_by_id_fast = intern_from_c("lookup-texture-by-id-fast").c(); + gLinkedFunctionTable.reg("(method 30 sky-work)", execute, 128); +} + +} // namespace method_30_sky_work +} // namespace Mips2C diff --git a/game/mips2c/mips2c_private.h b/game/mips2c/mips2c_private.h index 9fc4a4ea77..ff70146b51 100644 --- a/game/mips2c/mips2c_private.h +++ b/game/mips2c/mips2c_private.h @@ -552,6 +552,14 @@ struct ExecutionContext { } } + void paddb(int rd, int rs, int rt) { + auto s = gpr_src(rs); + auto t = gpr_src(rt); + for (int i = 0; i < 16; i++) { + gprs[rd].du8[i] = s.du8[i] + t.du8[i]; + } + } + void pextub(int rd, int rs, int rt) { auto s = gpr_src(rs); auto t = gpr_src(rt); diff --git a/game/mips2c/mips2c_table.cpp b/game/mips2c/mips2c_table.cpp index 656e70b22f..1d98d3e1cc 100644 --- a/game/mips2c/mips2c_table.cpp +++ b/game/mips2c/mips2c_table.cpp @@ -128,6 +128,7 @@ namespace init_boundary_regs { extern void link(); } namespace render_boundary_tri { extern void link(); } namespace render_boundary_quad { extern void link(); } namespace set_sky_vf27 { extern void link(); } +namespace set_sky_vf23_value { extern void link(); } namespace draw_boundary_polygon { extern void link(); } namespace sp_init_fields { extern void link(); } namespace particle_adgif { extern void link(); } @@ -135,6 +136,17 @@ namespace sp_launch_particles_var { extern void link(); } namespace sparticle_motion_blur { extern void link(); } namespace sp_process_block_2d { extern void link(); } namespace sp_process_block_3d { extern void link(); } +namespace set_tex_offset { extern void link(); } +namespace draw_large_polygon { extern void link(); } +namespace render_sky_quad { extern void link(); } +namespace render_sky_tri { extern void link(); } +namespace method_16_sky_work { extern void link(); } +namespace method_17_sky_work { extern void link(); } +namespace method_32_sky_work { extern void link(); } +namespace method_33_sky_work { extern void link(); } +namespace method_28_sky_work { extern void link(); } +namespace method_29_sky_work { extern void link(); } +namespace method_30_sky_work { extern void link(); } } // clang-format on @@ -223,7 +235,13 @@ PerGameVersion>> gMips2C {"sparticle-launcher", {jak2::sp_init_fields::link, jak2::particle_adgif::link, jak2::sp_launch_particles_var::link, jak2::sparticle_motion_blur::link}}, - {"sparticle", {jak2::sp_process_block_2d::link, jak2::sp_process_block_3d::link}}}, + {"sparticle", {jak2::sp_process_block_2d::link, jak2::sp_process_block_3d::link}}, + {"sky-tng", + {jak2::set_tex_offset::link, jak2::draw_large_polygon::link, jak2::render_sky_quad::link, + jak2::render_sky_tri::link, jak2::method_16_sky_work::link, jak2::method_17_sky_work::link, + jak2::method_32_sky_work::link, jak2::method_33_sky_work::link, + jak2::method_28_sky_work::link, jak2::method_29_sky_work::link, + jak2::method_30_sky_work::link, jak2::set_sky_vf23_value::link}}}, }; void LinkedFunctionTable::reg(const std::string& name, u64 (*exec)(void*), u32 stack_size) { diff --git a/goal_src/jak2/engine/ambient/ambient.gc b/goal_src/jak2/engine/ambient/ambient.gc index d60634ae87..bf5785aacd 100644 --- a/goal_src/jak2/engine/ambient/ambient.gc +++ b/goal_src/jak2/engine/ambient/ambient.gc @@ -9,3 +9,65 @@ ;; DECOMP BEGINS +(defun kill-current-talker ((arg0 symbol) (arg1 pair) (arg2 symbol)) + (if (not (member 'daxter arg1)) + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel daxter) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (if (not (member 'voicebox arg1)) + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel voicebox) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (if (not (member 'message arg1)) + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel message) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + (when (not (member 'notice arg1)) + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel notice) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + (gui-control-method-16 + *gui-control* + (gui-action stop) + (the-as sound-id 1) + (gui-channel notice-low) + (gui-action none) + (the-as string #f) + (the-as (function gui-connection symbol) #f) + (the-as process #f) + ) + ) + 0 + (none) + ) diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index a9641b7143..a23c06cf59 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -337,10 +337,10 @@ ;; draw the sky (with-profiler 'sky *profile-sky-color* - ; (if (-> *sky-work* draw-vortex) - ; (draw-vortex) - ; (draw *sky-work*) - ; ) + (if (-> *sky-work* draw-vortex) + (format 0 "no vortex.~%");(draw-vortex) + (draw *sky-work*) + ) (flush-cache 0) ) diff --git a/goal_src/jak2/engine/gfx/sky/sky-data.gc b/goal_src/jak2/engine/gfx/sky/sky-data.gc index a33b175c4a..5f4dbc268c 100644 --- a/goal_src/jak2/engine/gfx/sky/sky-data.gc +++ b/goal_src/jak2/engine/gfx/sky/sky-data.gc @@ -252,286 +252,7 @@ (define *cloud-vert-array* (new 'static 'cloud-vert-array)) -(define *cloud-poly* (new 'static 'inline-array cloud-vertex 277 - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - ) - ) +(define *cloud-poly* (new 'static 'inline-array sky-vertex 648)) (defun init-cloud-vert-array () (let ((gp-0 *cloud-vert-array*)) @@ -573,153 +294,7 @@ (define *haze-vert-array* (new 'static 'haze-vert-array)) -(define *haze-poly* (new 'static 'inline-array haze-vertex 144 - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - ) - ) +(define *haze-poly* (new 'static 'inline-array sky-vertex 144)) (defun init-haze-vert-array () (let ((gp-0 *haze-vert-array*)) diff --git a/goal_src/jak2/engine/gfx/sky/sky-h.gc b/goal_src/jak2/engine/gfx/sky/sky-h.gc index 66cd6d016f..7eda005f34 100644 --- a/goal_src/jak2/engine/gfx/sky/sky-h.gc +++ b/goal_src/jak2/engine/gfx/sky/sky-h.gc @@ -223,7 +223,7 @@ (vec1 vector4w :inline :offset-assert 1568) (cloud-lights cloud-lights :inline :offset-assert 1584) (haze-lights haze-lights :inline :offset-assert 1744) - (buf basic :offset-assert 1868) + (buf dma-buffer :offset-assert 1868) (draw-vortex basic :offset-assert 1872) (stars vector 512 :inline :offset-assert 1888) ) @@ -236,33 +236,32 @@ (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) - (sky-work-method-16 () none 16) - (sky-work-method-17 () none 17) - (sky-work-method-18 () none 18) - (sky-work-method-19 () none 19) - (sky-work-method-20 () none 20) - (sky-work-method-21 () none 21) - (sky-work-method-22 () none 22) - (sky-work-method-23 () none 23) - (sky-work-method-24 () none 24) - (sky-work-method-25 () none 25) - (sky-work-method-26 () none 26) - (sky-work-method-27 () none 27) - (sky-work-method-28 () none 28) - (sky-work-method-29 () none 29) - (sky-work-method-30 () none 30) - (sky-work-method-31 () none 31) - (sky-work-method-32 () none 32) - (sky-work-method-33 () none 33) - (sky-work-method-34 () none 34) - (sky-work-method-35 () none 35) - (sky-work-method-36 () none 36) + (update-matrix (_type_ matrix) none 14) + (update-template-colors (_type_) none 15) + (init-regs-for-large-polygon-draw (_type_) none 16) + (init-regs-for-sky-asm (_type_) none 17) + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none 18) + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none 19) + (adjust-cloud-lighting (_type_) none 20) + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none 21) + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none 22) + (draw-clouds (_type_ dma-buffer) none 23) + (apply-haze-light (_type_ vector vector haze-lights) none 24) + (adjust-haze-lighting (_type_) none 25) + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none 26) + (draw-haze (_type_ dma-buffer) none 27) + (sun-dma (_type_ dma-buffer) none 28) + (green-sun-dma (_type_ dma-buffer) none 29) + (moon-dma (_type_ dma-buffer) none 30) + (setup-stars (_type_ matrix sky-upload-data) none 31) + (stars-transform-asm (_type_) none 32) + (stars-dma (_type_ dma-buffer) none 33) + (draw-roof (_type_ dma-buffer) none 34) + (draw-base (_type_ dma-buffer) none 35) + (draw-fog (_type_ dma-buffer) none 36) ) ) - 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 0f4703e23d..3c06d475cd 100644 --- a/goal_src/jak2/engine/gfx/sky/sky-tng.gc +++ b/goal_src/jak2/engine/gfx/sky/sky-tng.gc @@ -7,10 +7,59 @@ ;; DECOMP BEGINS +;; Sky renderer. +;; this render is much more complicated than the jak 1 version. +;; there's a lot of weird tricks to store values in the VF registers, and a lot of asm, +;; so a lot of this is in C++. -;; TODO +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Large Polygon Renderer +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; there's a special "large polygon renderer" that handles clipping +;; and ps2-specific texture perspective stuff. +;; the way it subdivides is extremely strange, and not well understood, but it works well with the +;; Direct renderer in C++. +;; this renderer is also used for drawing debug regions and some parts of the ocean near the horizon. + +;; there's a lot of state stored in vf registers, so we have to be very careful with this. + +;; VF registers for large polygon +;; vf13: fog +;; vf14: hmge +;; vf23: 0? +;; vf24: texture offset (stored in xy, zw are 0), +;; vf25: hvdf-offset +;; vf26: inv-hmge +;; vf27: giftag +;; vf28: cam 3 (premultiplied by hmge) +;; vf29: cam 2 (premultiplied by hmge) +;; vf30: cam 1 (premultiplied by hmge) +;; vf31: cam 0 (premultiplied by hmge) + +;; set the xy component of vf24 (texture offset for large poly renderer) to values / 65,536 +(def-mips2c set-tex-offset (function int int none)) + +;; added function to sneak a value into vf23. +;; the use of this value is unknown +(def-mips2c set-sky-vf23-value (function int none)) + +;; there's also a set-sky-vf27 already defined that lets us set the vf27 used by sky C++ code. + +;; draw-large-polygon is not called from GOAL directly, but it does clipping/dma generation for large polygons. + +;; clip-polygon-against-positive-hyperplane and clip-polygon-against-negative-hyperplane are both +;; helpers called by draw-large-polygon + +;; these two functions are the interface between the sky and large polygon renderer: these set up inputs to +;; draw-large-polygon and call it, sending data to the given dma-buffer. +;; these require vf registers to be set up. +(def-mips2c render-sky-quad (function (inline-array sky-vertex) dma-buffer none)) +(def-mips2c render-sky-tri (function (inline-array sky-vertex) dma-buffer none)) (defun close-sky-buffer ((arg0 dma-buffer)) + "Terminate dma from large polygon renderer. This should be called after the last + call to render-sky-tri/quad." (nop!) (let ((v1-0 #x8000) (v0-0 (-> arg0 base)) @@ -27,7 +76,53 @@ (none) ) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Sky Update +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmethod update-matrix sky-work ((obj sky-work) (arg0 matrix)) + "Update the projection matrix for sky drawing. + The input matrix should not include perepctive. + This function will apply the current math camera's perspective." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 (-> obj cam-mat))) + (let* ((a0-1 v1-0) + (t0-0 arg0) + (a1-1 (-> t0-0 vector 0 quad)) + (a2-0 (-> t0-0 vector 1 quad)) + (a3-0 (-> t0-0 vector 2 quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> a0-1 vector 0 quad) a1-1) + (set! (-> a0-1 vector 1 quad) a2-0) + (set! (-> a0-1 vector 2 quad) a3-0) + (set! (-> a0-1 trans quad) t0-1) + ) + (.svf (&-> v1-0 trans quad) vf0) + (matrix*! v1-0 v1-0 (-> *math-camera* perspective)) + ) + 0 + (none) + ) + ) + +(defmethod update-template-colors sky-work ((obj sky-work)) + "Update skybox colors from level/mood." + (let ((v1-1 (-> *time-of-day-context* current-fog erase-color)) + (a0-2 (-> *level* default-level mood-context current-sky-color)) + ) + (dotimes (a1-0 12) + (set! (-> sky-base-polygons a1-0 col quad) (-> v1-1 quad)) + (set! (-> sky-roof-polygons a1-0 col quad) (-> a0-2 quad)) + ) + ) + 0 + (none) + ) + (defmethod update-time-and-speed sky-work ((obj sky-work) (arg0 float) (arg1 float)) + "Update based on the given time. Time is used to place suns/moon at the right spot, speed is used to scroll clouds." (if (and (level-get-target-inside *level*) (= (-> (level-get-target-inside *level*) info taskname) 'nest)) (set! arg1 (* 10.0 arg1)) ) @@ -41,7 +136,114 @@ (none) ) +;; method 16 +;; init-regs-for-boundary-draw +;; set up vf registers for drawing large polygons +; (defmethod init-regs-for-large-polygon-draw sky-work ((obj sky-work)) +; (local-vars (v1-1 float)) +; (rlet ((vf0 :class vf) +; (vf13 :class vf) +; (vf14 :class vf) +; (vf23 :class vf) +; (vf24 :class vf) +; (vf25 :class vf) +; (vf26 :class vf) +; (vf28 :class vf) +; (vf29 :class vf) +; (vf30 :class vf) +; (vf31 :class vf) +; ) +; (init-vf0-vector) +; (let ((v1-0 *math-camera*) +; (a1-0 (new-stack-vector0)) +; ) +; (let ((a2-0 (-> obj cam-mat))) +; (set! (-> a1-0 quad) (-> v1-0 hvdf-off quad)) + ;; interestingly, they cheat the height of the sky by 1, possibly to avoid a "gap" + ;; on the horizon. (but they use the wrong position if it's using other camera) +; (if (< 0.0 (-> v1-0 trans y)) +; (set! (-> a1-0 y) 2049.0) +; (set! (-> a1-0 y) 2047.0) +; ) +; (set-vector! (-> obj fog) (-> v1-0 pfog0) (-> v1-0 fog-min) (-> v1-0 fog-max) 3071.0) +; (.lvf vf31 (&-> a2-0 vector 0 quad)) +; (.lvf vf30 (&-> a2-0 vector 1 quad)) +; (.lvf vf29 (&-> a2-0 vector 2 quad)) +; (.lvf vf28 (&-> a2-0 trans quad)) +; ) +; (.lvf vf14 (&-> v1-0 hmge-scale quad)) +; (.lvf vf26 (&-> v1-0 inv-hmge-scale quad)) +; (.lvf vf25 (&-> a1-0 quad)) +; ) +; (.lvf vf13 (&-> obj fog quad)) +; (.mul.vf vf31 vf31 vf14) +; (.mul.vf vf30 vf30 vf14) +; (.mul.vf vf29 vf29 vf14) +; (.mul.vf vf28 vf28 vf14) +; (.mov.vf vf25 vf0 :mask #b100) +; (.mov.vf vf24 vf0) +; (.mov.vf vf23 vf0) +; (.mov v1-1 vf23) +; 0 +; (none) +; ) +; ) +(defmethod-mips2c "(method 16 sky-work)" 16 sky-work) + + +;; very similar to the above, but sets things up for other sky asm stuff (not large-polygon) +;; VF registers for sky +;; vf13: fog +;; vf14: hmge +;; vf23: 0? +;; vf25: hvdf-offset (no off-by-one hack applied) +;; vf26: some weird scale thing in w. +;; vf28: cam 3 +;; vf29: cam 2 +;; vf30: cam 1 +;; vf31: cam 0 + +; (defmethod init-regs-for-sky-asm sky-work ((obj sky-work)) +; (local-vars (v1-2 float)) +; (rlet ((vf0 :class vf) +; (vf13 :class vf) +; (vf14 :class vf) +; (vf23 :class vf) +; (vf25 :class vf) +; (vf26 :class vf) +; (vf28 :class vf) +; (vf29 :class vf) +; (vf30 :class vf) +; (vf31 :class vf) +; ) +; (init-vf0-vector) +; (let ((a1-0 *math-camera*)) +; (let ((v1-0 (-> obj cam-mat))) +; (.lvf vf31 (&-> v1-0 vector 0 quad)) +; (.lvf vf30 (&-> v1-0 vector 1 quad)) +; (.lvf vf29 (&-> v1-0 vector 2 quad)) +; (.lvf vf28 (&-> v1-0 trans quad)) +; ) +; (.lvf vf14 (&-> a1-0 hmge-scale quad)) +; (.lvf vf25 (&-> a1-0 hvdf-off quad)) +; (.lvf vf13 (&-> obj fog quad)) +; (.mov.vf vf25 vf0 :mask #b100) +; (.mov.vf vf23 vf0) +; (let ((v1-1 (new-stack-vector0))) +; (set! (-> v1-1 w) (fmin 1.0 (/ 11650.845 (-> a1-0 fov)))) +; (.lvf vf26 (&-> v1-1 quad)) +; ) +; ) +; (.mov v1-2 vf26) +; 0 +; (none) +; ) +; ) +(defmethod-mips2c "(method 17 sky-work)" 17 sky-work) + + (defmethod update-colors-for-time sky-work ((obj sky-work) (arg0 float)) + "Update sky colors for the given time." 0 0 0.0 @@ -87,4 +289,972 @@ ) 0 (none) + ) + +(defmethod cloud-vtx-light-update sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 cloud-lights) (arg3 vector) (arg4 vector)) + "Update lighting for cloud mesh vertex." + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg4 quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 arg3) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +(defmethod cloud-vtx-tex-update sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 cloud-lights)) + "Update texture stq for cloud mesh vertex." + (let ((s5-0 (new 'stack-no-clear 'vector4)) + (s2-0 (new 'stack-no-clear 'vector4)) + (s4-0 (new 'stack-no-clear 'vector4)) + (f28-0 0.00390625) + (f30-0 0.015625) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (vector--float*! (the-as vector s5-0) arg2 (-> arg3 sun0-normal) 9.0) + (vector--float*! (the-as vector s2-0) arg2 (-> arg3 sun1-normal) 9.0) + (vector--float*! (the-as vector s4-0) arg2 (-> arg3 moon-normal) 9.0) + (vector4-scale! s5-0 s5-0 (* (-> arg3 sun0-scale) f28-0)) + (vector4-madd! s5-0 s5-0 s2-0 (* 0.25 f28-0 (-> arg3 sun1-scale))) + (vector4-madd! s5-0 s5-0 s4-0 (* (-> arg3 moon-scale) f28-0)) + (+! (-> arg0 x) (fmax (fmin (-> s5-0 x) f30-0) (- f30-0))) + (+! (-> arg0 y) (fmax (fmin (-> s5-0 z) f30-0) (- f30-0))) + ) + 0 + (none) + ) + +(defmethod adjust-cloud-lighting sky-work ((obj sky-work)) + "Apply lighting to cloud vertices" + (let ((s5-0 *cloud-vert-array*) + (s4-0 (-> obj cloud-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> obj upload-data sun 0 pos quad)) + (set! (-> s4-0 sun1-normal quad) (-> obj upload-data sun 1 pos quad)) + (set! (-> s4-0 moon-normal quad) (-> obj upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s1-0 (-> s4-0 ambi-color)) + (s2-0 (-> s4-0 ambi-color-lower)) + (s3-0 (-> obj sun0-color-lower)) + ) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f28-0 (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y))))))) + ) + (vector4-scale! (the-as vector4 s2-0) (the-as vector4 (-> obj ambi-color-lower)) f30-0) + (vector4-madd! (the-as vector4 s2-0) (the-as vector4 s2-0) (the-as vector4 s3-0) f28-0) + (vector4-scale! (the-as vector4 s1-0) (the-as vector4 (-> obj ambi-color)) f30-0) + (vector4-madd! (the-as vector4 s1-0) (the-as vector4 s1-0) (the-as vector4 s3-0) f28-0) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> obj sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> obj sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> obj moon-color)) + (-> s4-0 moon-scale) + ) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color-lower)) (the-as vector4 s3-0) (-> s4-0 sun0-scale)) + ) + (dotimes (s3-1 100) + (let ((s2-1 (-> s5-0 data s3-1))) + (cloud-vtx-light-update obj (-> s2-1 col) (-> s2-1 nrm) s4-0 (-> s4-0 sun0-color) (-> s4-0 ambi-color)) + (cloud-vtx-light-update + obj + (-> s2-1 col2) + (-> s2-1 nrm2) + s4-0 + (-> s4-0 sun0-color-lower) + (-> s4-0 ambi-color-lower) + ) + (cloud-vtx-tex-update obj (-> s2-1 stq2) (-> s2-1 stq) (-> s2-1 pos) s4-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod cloud-vtx1-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + "Convert a cloud vertex to a sky vertex, using the 'normal' stq/col" + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq quad)) + (set! (-> arg0 col quad) (-> arg1 col quad)) + (none) + ) + +(defmethod cloud-vtx2-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + "Convert a cloud vertex to a sky vertex, using the '2' stq/col" + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq2 quad)) + (set! (-> arg0 col quad) (-> arg1 col2 quad)) + (none) + ) + +(defmethod draw-clouds sky-work ((obj sky-work) (arg0 dma-buffer)) + "Draw the cloud layer using large polygon renderer + Assumes that init-regs-for-large-polygon-draw was already called." + (local-vars (v1-19 float) (sv-16 cloud-vert-array) (sv-20 (inline-array sky-vertex)) (sv-32 int)) + (rlet ((vf23 :class vf) + (vf27 :class vf) + ) + + ;; set up for sky DMA: + (let* ((v1-0 arg0) + (a0-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt))) + (set! (-> a0-1 vif0) (new 'static 'vif-tag)) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ a0-1 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as gs-gif-tag (-> v1-1 base))) + ) + (set! (-> a0-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6)) + (set! (-> a0-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (the-as pointer (&+ a0-3 16))) + ) + (let* ((s4-0 arg0) + (s3-0 (-> s4-0 base)) + ) + (set! (-> (the-as (pointer gs-test) s3-0) 0) (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x50 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s3-0) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-tex0) s3-0) 2) (new 'static 'gs-tex0 + :tbp0 #x100 + :tbw #x2 + :psm #x1b + :tcc #x1 + :cbp #x300 + :cld #x1 + :th (log2 128) + :tw (log2 128) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s3-0) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) s3-0) 4) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 5) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) s3-0) 6) (new 'static 'gs-clamp)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 7) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-alpha) s3-0) 8) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 9) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) s3-0) 10) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 11) (gs-reg64 texflush)) + (set! (-> s4-0 base) (&+ s3-0 96)) + ) + + ;; set regs for large polygon renderer + ;(init-regs-for-large-polygon-draw obj) ;; hack hack hack hack hack! + ;;(.lvf vf27 (&-> obj giftag-roof quad)) + (set-sky-vf27 (&-> obj giftag-roof quad)) + (set-sky-vf23-value #x43c80000) + ; (let ((v1-18 #x43c80000)) + ; (.mov vf23 v1-18) + ; ) + ;(.mov v1-19 vf23) + (set-tex-offset (the-as int (-> obj off-s)) (the-as int (-> obj off-t))) + + ;; convert cloud vertices to sky. + (let ((s4-1 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (set! sv-16 *cloud-vert-array*) + (set! sv-20 *cloud-poly*) + (dotimes (s3-1 9) + (dotimes (s2-2 9) + (let ((s1-0 (+ (* 10 s3-1) s2-2))) + (set! sv-32 (+ (* 9 s3-1) s2-2)) + (let ((s0-0 (+ s2-2 81 (* 9 s3-1)))) + (cloud-vtx1-to-sky obj (-> sv-20 (* sv-32 4)) (-> sv-16 data s1-0)) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 3)) (-> sv-16 data (+ s1-0 10))) + (cloud-vtx2-to-sky obj (-> sv-20 (* s0-0 4)) (-> sv-16 data s1-0)) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 3)) (-> sv-16 data (+ s1-0 10))) + ) + ) + ) + ) + ;; do large polygon rendering! + (dotimes (s5-1 162) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + ;; finish. + (close-sky-buffer arg0) + (let ((v1-81 (/ (the-as int (+ (- -16 (the-as int s4-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s4-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-81)) + (set! (-> (the-as dma-packet s4-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s4-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-81)) + ) + ) + 0 + (none) + ) + ) + +(defmethod apply-haze-light sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 haze-lights)) + "Apply haze lights to a vertex." + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg2 ambi-color quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun0-color)) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +(defmethod adjust-haze-lighting sky-work ((obj sky-work)) + "Adjust lighting for haze." + (let ((s5-0 *haze-vert-array*) + (s4-0 (-> obj haze-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> obj upload-data sun 0 pos quad)) + (set! (-> s4-0 sun1-normal quad) (-> obj upload-data sun 1 pos quad)) + (set! (-> s4-0 moon-normal quad) (-> obj upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((a0-10 (-> s4-0 ambi-color))) + (-> obj sun0-color-lower) + (let ((f0-7 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y))))))) + (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y)))))) + (vector4-scale! (the-as vector4 a0-10) (the-as vector4 (-> obj ambi-color)) f0-7) + ) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> obj sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> obj sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> obj moon-color)) + (-> s4-0 moon-scale) + ) + (dotimes (s3-0 36) + (let ((v1-25 (-> s5-0 data s3-0))) + (apply-haze-light obj (-> v1-25 col) (-> v1-25 nrm) s4-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod haze-vtx-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 sky-vertex) (arg2 haze-vertex)) + "Convert haze vertex to sky format." + (set! (-> arg0 pos quad) (-> arg2 pos quad)) + (set! (-> arg0 col quad) (-> arg2 col quad)) + (set! (-> arg0 col w) 128.0) + (set! (-> arg1 pos quad) (-> arg2 pos quad)) + (set! (-> arg1 col quad) (-> arg2 col quad)) + (set! (-> arg1 pos y) 3.0) + (set! (-> arg1 col w) 0.0) + 0 + (none) + ) + +(defmethod draw-haze sky-work ((obj sky-work) (arg0 dma-buffer)) + "Draw haze using large polygon renderer. + Calls init-regs-for-large-polygon-draw." + (local-vars (sv-16 haze-vert-array) (sv-20 (inline-array sky-vertex))) + + ;; set up dma + (rlet ((vf27 :class vf)) + (let* ((v1-0 arg0) + (a0-1 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a0-1) 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a0-3) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a0-3) regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (&+ (the-as pointer a0-3) 16)) + ) + (let* ((v1-2 arg0) + (a0-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a0-5) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a0-5) 1) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a0-5 16)) + ) + ;; set up polygon regs + (init-regs-for-large-polygon-draw obj) + ;(.lvf vf27 (&-> obj giftag-haze quad)) + (set-sky-vf27 (&-> obj giftag-haze quad)) + + ;; convert to sky format + (let ((s4-0 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (set! sv-16 *haze-vert-array*) + (set! sv-20 *haze-poly*) + (dotimes (s3-0 35) + (haze-vtx-to-sky obj (-> sv-20 (* s3-0 4)) (-> sv-20 (+ (* s3-0 4) 1)) (-> sv-16 data s3-0)) + (haze-vtx-to-sky obj (-> sv-20 (+ (* s3-0 4) 3)) (-> sv-20 (+ (* s3-0 4) 2)) (-> sv-16 data (+ s3-0 1))) + ) + (haze-vtx-to-sky obj (-> sv-20 140) (-> sv-20 141) (-> sv-16 data 35)) + (haze-vtx-to-sky obj (-> sv-20 143) (-> sv-20 142) (the-as haze-vertex (-> sv-16 data))) + ;; draw! + (dotimes (s5-1 36) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + ;; finish up. + (close-sky-buffer arg0) + (let ((v1-41 (/ (the-as int (+ (- -16 (the-as int s4-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s4-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-41)) + (set! (-> (the-as dma-packet s4-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s4-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-41)) + ) + ) + 0 + (none) + ) + ) + +;; sky dma method: +;; generates dma for sun or moon (no large polygon) +;; assumes sky registers are set up (not polygon) +(defmethod-mips2c "(method 28 sky-work)" 28 sky-work) ;; first sun (normal) +(defmethod-mips2c "(method 29 sky-work)" 29 sky-work) ;; green sun +(defmethod-mips2c "(method 30 sky-work)" 30 sky-work) ;; moon + +(defmethod setup-stars sky-work ((obj sky-work) (arg0 matrix) (arg1 sky-upload-data)) + "Prepare for star drawing." + (set! (-> arg0 vector 2 quad) (-> arg1 sun 0 pos quad)) + (vector-normalize! (-> arg0 vector 2) 1.0) + (vector-cross! (the-as vector (-> arg0 vector)) *z-vector* (-> arg0 vector 2)) + (vector-normalize! (the-as vector (-> arg0 vector)) 1.0) + (vector-cross! (-> arg0 vector 1) (-> arg0 vector 2) (the-as vector (-> arg0 vector))) + (vector-normalize! (-> arg0 vector 1) 1.0) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> arg1 sun 0 pos quad)) + (vector-normalize! s4-1 -1.0) + (let ((f0-1 (fmax 0.0 (fmin 1.0 (* 20.0 (+ 0.05 (-> s4-1 y))))))) + (dotimes (v1-7 16) + (let ((f1-4 (* (- 128.0 (* 8.0 (the float v1-7))) f0-1))) + (set-vector! (-> obj star-colors v1-7) (the int f1-4) (the int f1-4) (the int f1-4) 128) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod-mips2c "(method 32 sky-work)" 32 sky-work) ;; stars transform +(defmethod-mips2c "(method 33 sky-work)" 33 sky-work) ;; stars dma + +(defmethod draw-roof sky-work ((obj sky-work) (arg0 dma-buffer)) + "Draw the roof of the sky box. Uses large-polygon renderer." + (rlet ((vf27 :class vf)) + ;; GS setup + (let* ((v1-0 arg0) + (a0-1 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a0-1) 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a0-3) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> (the-as gs-gif-tag a0-3) regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (&+ (the-as pointer a0-3) 16)) + ) + (let* ((v1-2 arg0) + (a0-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a0-5) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a0-5) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a0-5) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-5) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) a0-5) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a0-5) 5) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a0-5 48)) + ) + ;; large polygon reg setup + (init-regs-for-large-polygon-draw obj) + ; (.lvf vf27 (&-> obj giftag-base quad)) + (set-sky-vf27 (&-> obj giftag-base quad)) + + ;; draw! + (let ((s5-1 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-14 (/ (the-as int (+ (- -16 (the-as int s5-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s5-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-14)) + (set! (-> (the-as dma-packet s5-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s5-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-14)) + ) + ) + 0 + (none) + ) + ) + +(defmethod draw-base sky-work ((obj sky-work) (arg0 dma-buffer)) + "Draw the base of the sky box. Uses large-polygon renderer." + (rlet ((vf27 :class vf)) + (let* ((v1-0 arg0) + (a1-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a1-1 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-1 vif0) (new 'static 'vif-tag)) + (set! (-> a1-1 vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ a1-1 16))) + ) + (let* ((v1-1 arg0) + (a1-3 (the-as gs-gif-tag (-> v1-1 base))) + ) + (set! (-> a1-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> a1-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (the-as pointer (&+ a1-3 16))) + ) + (let* ((v1-2 arg0) + (a1-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-test) a1-5) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-5) 1) (gs-reg64 test-1)) + (set! (-> v1-2 base) (&+ a1-5 16)) + ) + (let ((s5-0 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + ;(.lvf vf27 (&-> obj giftag-base quad)) + (set-sky-vf27 (&-> obj giftag-base quad)) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-12 (/ (the-as int (+ (- -16 (the-as int s5-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s5-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-12)) + (set! (-> (the-as dma-packet s5-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s5-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-12)) + ) + ) + 0 + (none) + ) + ) + +(defmethod draw-fog sky-work ((obj sky-work) (arg0 dma-buffer)) + (let ((s4-0 (-> *sky-texture-anim-array* array-data 8 tex))) + (when s4-0 + (let* ((v1-3 arg0) + (a0-1 (the-as dma-packet (-> v1-3 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) + (set! (-> a0-1 vif0) (new 'static 'vif-tag)) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-3 base) (the-as pointer (&+ a0-1 16))) + ) + (let* ((v1-4 arg0) + (a0-3 (the-as gs-gif-tag (-> v1-4 base))) + ) + (set! (-> a0-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) + (set! (-> a0-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-4 base) (the-as pointer (the-as gs-gif-tag (&+ a0-3 16)))) + ) + (let* ((s3-0 arg0) + (s2-0 (-> s3-0 base)) + ) + (set! (-> (the-as (pointer gs-tex0) s2-0) 0) + (new 'static 'gs-tex0 + :tcc #x1 + :cld #x1 + :psm (the-as int (-> s4-0 psm)) + :cpsm (-> s4-0 clutpsm) + :cbp (-> s4-0 clutdest) + :th (log2 (-> s4-0 h)) + :tw (log2 (-> s4-0 w)) + :tbw (-> s4-0 width 0) + :tbp0 (-> s4-0 dest 0) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 1) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) s2-0) 2) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) s2-0) 3) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-test) s2-0) 4) + (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x70 + :afail #x3 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 5) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-clamp) s2-0) 6) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 7) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-alpha) s2-0) 8) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) s2-0) 9) (gs-reg64 alpha-1)) + (set! (-> s3-0 base) (&+ s2-0 80)) + ) + ) + ) + (let* ((v1-26 (the-as (inline-array qword) (-> arg0 base))) + (f0-0 (-> *fog-texture-work* min-corner y)) + (f4-0 (- (-> *fog-texture-work* max-corner y) f0-0)) + (f3-0 (/ (- (-> *fog-texture-work* corner 1 y) f0-0) f4-0)) + (f2-0 (/ (- (-> *fog-texture-work* corner 0 y) f0-0) f4-0)) + (f1-7 (/ (- (-> *fog-texture-work* corner 3 y) f0-0) f4-0)) + (f0-2 (/ (- (-> *fog-texture-work* corner 2 y) f0-0) f4-0)) + (a0-28 6400) + ) + (set! (-> v1-26 0 quad) (-> obj fog-tmpl dma-vif quad)) + (set! (-> v1-26 1 quad) (-> obj fog-tmpl quad 1)) + (set-vector! (-> v1-26 2 vector4w) #x80 #x80 #x80 #x80) + (set-vector! (-> v1-26 3 vector) f3-0 0.0 1.0 0.0) + (set-vector! (-> v1-26 4 vector4w) #x7000 #x7300 a0-28 0) + (set-vector! (-> v1-26 5 vector) f2-0 0.0 1.0 0.0) + (set-vector! (-> v1-26 6 vector4w) #x9000 #x7300 a0-28 0) + (set-vector! (-> v1-26 7 vector) f1-7 0.0 1.0 0.0) + (set-vector! (-> v1-26 8 vector4w) #x7000 #x8d00 a0-28 0) + (set-vector! (-> v1-26 9 vector) f0-2 0.0 1.0 0.0) + (set-vector! (-> v1-26 10 vector4w) #x9000 #x8d00 a0-28 0) + ) + (&+! (-> arg0 base) 176) + 0 + (none) + ) + +(defmethod draw sky-work ((obj sky-work)) + (let ((v1-0 *time-of-day-context*) + (a0-1 #f) + ) + (dotimes (a1-0 (-> *level* length)) + (let ((a2-3 (-> *level* level a1-0))) + (when (= (-> a2-3 status) 'active) + (if (-> a2-3 info sky) + (set! a0-1 #t) + ) + ) + ) + ) + (cond + ((and a0-1 + (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask sky)) + (logtest? (-> *texture-pool* texture-enable-user) (texture-enable-mask sky)) + ) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (let ((a1-7 (if (-> v1-0 use-camera-other) + (-> *math-camera* camera-rot-other) + (-> *math-camera* camera-rot) + ) + ) + ) + (update-matrix obj a1-7) + ) + (update-template-colors obj) + (adjust-haze-lighting obj) + (adjust-cloud-lighting obj) + (let ((s4-0 (the-as object *fake-scratchpad-data*))) + (mem-copy! (the-as pointer s4-0) (the-as pointer obj) #x2760) + (setup-stars (the-as sky-work s4-0) (-> (the-as sky-work s4-0) star-mat) (-> obj upload-data)) + (if (nonzero? (-> (the-as sky-work s4-0) star-colors 0 x)) + (stars-transform-asm (the-as sky-work s4-0)) + ) + (let* ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-1 (-> s3-0 base)) + ) + (draw-roof (the-as sky-work s4-0) s3-0) + (init-regs-for-sky-asm (the-as sky-work s4-0)) + (if (nonzero? (-> (the-as sky-work s4-0) star-colors 0 x)) + (stars-dma (the-as sky-work s4-0) s3-0) + ) + (sun-dma (the-as sky-work s4-0) s3-0) + (green-sun-dma (the-as sky-work s4-0) s3-0) + (moon-dma (the-as sky-work s4-0) s3-0) + (draw-haze (the-as sky-work s4-0) s3-0) + (when (nonzero? *sky-texture-anim-array*) ;; added check + (draw-clouds (the-as sky-work s4-0) s3-0) + ) + (draw-base (the-as sky-work s4-0) s3-0) + (when (nonzero? *sky-texture-anim-array*) ;; added check + (draw-fog (the-as sky-work s4-0) s3-0) + ) + (let ((a3-5 (-> s3-0 base))) + (let ((v1-45 (the-as dma-packet (-> s3-0 base)))) + (set! (-> v1-45 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-45 vif0) (new 'static 'vif-tag)) + (set! (-> v1-45 vif1) (new 'static 'vif-tag)) + (set! (-> s3-0 base) (the-as pointer (&+ v1-45 16))) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id sky-draw) + s5-1 + (the-as (pointer dma-tag) a3-5) + ) + ) + ) + ) + (let ((v1-52 *dma-mem-usage*)) + (when (nonzero? v1-52) + (set! (-> v1-52 length) (max 89 (-> v1-52 length))) + (set! (-> v1-52 data 88 name) "sky") + (+! (-> v1-52 data 88 count) 1) + (+! (-> v1-52 data 88 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> v1-52 data 88 total) (-> v1-52 data 88 used)) + ) + ) + ) + ) + (else + (let* ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (gp-1 (-> s4-1 base)) + ) + (cond + ((-> *blit-displays-work* menu-mode) + (let ((f0-0 (-> *blit-displays-work* progress-interp))) + (let* ((a0-43 s4-1) + (a1-30 (the-as dma-packet (-> a0-43 base))) + ) + (set! (-> a1-30 dma) (new 'static 'dma-tag :qwc #x8 :id (dma-tag-id cnt))) + (set! (-> a1-30 vif0) (new 'static 'vif-tag)) + (set! (-> a1-30 vif1) (new 'static 'vif-tag :imm #x8 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-43 base) (the-as pointer (&+ a1-30 16))) + ) + (let* ((a0-44 s4-1) + (a1-32 (the-as gs-gif-tag (-> a0-44 base))) + ) + (set! (-> a1-32 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x7)) + (set! (-> a1-32 regs) GIF_REGS_ALL_AD) + (set! (-> a0-44 base) (the-as pointer (&+ a1-32 16))) + ) + (let* ((a0-45 s4-1) + (a1-34 (-> a0-45 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a1-34) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a1-34) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a1-34) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) a1-34) 4) (new 'static 'gs-alpha)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) a1-34) 6) + (new 'static 'gs-tex0 :tbp0 #x4c0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 7) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) a1-34) 8) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 9) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) a1-34) 10) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 11) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer uint64) a1-34) 12) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 13) (gs-reg64 texflush)) + (set! (-> a0-45 base) (&+ a1-34 112)) + ) + (let ((a2-40 (the-as (inline-array qword) (-> s4-1 base))) + (a3-7 #x7000) + (t0-1 #x7300) + (a0-46 #x7800) + (a1-36 #x7980) + ) + (set! (-> a2-40 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> a2-40 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> a2-40 2 vector4w) 128 128 128 128) + (set-vector! (-> a2-40 3 vector4w) 8 8 0 0) + (set-vector! (-> a2-40 4 vector4w) a3-7 t0-1 0 0) + (set-vector! (-> a2-40 5 vector4w) 8200 6664 0 0) + (set-vector! (-> a2-40 6 vector4w) a0-46 a1-36 0 0) + ) + (&+! (-> s4-1 base) 112) + (let ((t0-4 (the-as (inline-array qword) (-> s4-1 base))) + (a2-42 #x8000) + (a3-9 #x8000) + (a0-49 #x9000) + (a1-37 #x8d00) + ) + (set! (-> t0-4 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t0-4 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t0-4 2 vector4w) 128 128 128 128) + (set-vector! (-> t0-4 3 vector4w) 8 8 0 0) + (set-vector! (-> t0-4 4 vector4w) a2-42 a3-9 0 0) + (set-vector! (-> t0-4 5 vector4w) 8200 6664 0 0) + (set-vector! (-> t0-4 6 vector4w) a0-49 a1-37 0 0) + (&+! (-> s4-1 base) 112) + (let* ((t0-8 s4-1) + (t1-11 (the-as dma-packet (-> t0-8 base))) + ) + (set! (-> t1-11 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> t1-11 vif0) (new 'static 'vif-tag)) + (set! (-> t1-11 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t0-8 base) (the-as pointer (&+ t1-11 16))) + ) + (let* ((t0-9 s4-1) + (t1-13 (the-as gs-gif-tag (-> t0-9 base))) + ) + (set! (-> t1-13 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> t1-13 regs) GIF_REGS_ALL_AD) + (set! (-> t0-9 base) (the-as pointer (&+ t1-13 16))) + ) + (let* ((t0-10 s4-1) + (t1-15 (-> t0-10 base)) + ) + (set! (-> (the-as (pointer gs-alpha) t1-15) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t1-15) 1) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) t1-15) 2) + (new 'static 'gs-tex0 :tbp0 #x3300 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) t1-15) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer uint64) t1-15) 4) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) t1-15) 5) (gs-reg64 texflush)) + (set! (-> t0-10 base) (&+ t1-15 48)) + ) + (let ((t0-11 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> t0-11 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t0-11 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t0-11 2 vector4w) 128 128 128 80) + (set-vector! (-> t0-11 3 vector4w) 0 0 0 0) + (set-vector! (-> t0-11 4 vector4w) a2-42 a3-9 0 0) + (set-vector! (-> t0-11 5 vector4w) 2048 1664 0 0) + (set-vector! (-> t0-11 6 vector4w) a0-49 a1-37 0 0) + ) + ) + (&+! (-> s4-1 base) 112) + (let* ((a0-52 s4-1) + (a1-38 (the-as dma-packet (-> a0-52 base))) + ) + (set! (-> a1-38 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-38 vif0) (new 'static 'vif-tag)) + (set! (-> a1-38 vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-52 base) (the-as pointer (&+ a1-38 16))) + ) + (let* ((a0-53 s4-1) + (a1-40 (the-as gs-gif-tag (-> a0-53 base))) + ) + (set! (-> a1-40 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> a1-40 regs) GIF_REGS_ALL_AD) + (set! (-> a0-53 base) (the-as pointer (&+ a1-40 16))) + ) + (let* ((a0-54 s4-1) + (a1-42 (-> a0-54 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a1-42) 0) (new 'static 'gs-alpha)) + (set! (-> (the-as (pointer gs-reg64) a1-42) 1) (gs-reg64 alpha-1)) + (set! (-> a0-54 base) (&+ a1-42 16)) + ) + (let ((a0-57 (the int (+ 128.0 (* 32.0 f0-0)))) + (a1-46 (the int (- 128.0 (* 16.0 f0-0)))) + (a2-55 (the int (- 128.0 (* 96.0 f0-0)))) + ) + (when (or (!= (-> v1-0 filter x) 1.0) (!= (-> v1-0 filter y) 1.0) (!= (-> v1-0 filter z) 1.0)) + (set! a0-57 128) + (set! a1-46 128) + (set! a2-55 128) + ) + (let ((v1-57 3328) + (a3-16 6656) + ) + (dotimes (t0-12 16) + (let ((t1-22 (the-as (inline-array qword) (-> s4-1 base))) + (t3-0 (* (+ (* t0-12 32) 1792) 16)) + (t2-36 (* (+ (* (+ t0-12 1) 32) 1792) 16)) + ) + (let ((t5-0 (* (+ (* t0-12 16) 256) 16)) + (t4-5 (* (+ (* (+ t0-12 1) 16) 256) 16)) + ) + (set! (-> t1-22 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t1-22 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t1-22 2 vector4w) a0-57 a1-46 a2-55 128) + (set-vector! (-> t1-22 3 vector4w) (+ t5-0 8) (+ v1-57 24) 0 0) + (set-vector! (-> t1-22 4 vector4w) t3-0 #x7300 0 0) + (set-vector! (-> t1-22 5 vector4w) (+ t4-5 8) (+ a3-16 24) 0 0) + ) + (set-vector! (-> t1-22 6 vector4w) t2-36 #x8d00 0 0) + ) + (&+! (-> s4-1 base) 112) + ) + ) + (let* ((v1-60 s4-1) + (a3-17 (the-as dma-packet (-> v1-60 base))) + ) + (set! (-> a3-17 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> a3-17 vif0) (new 'static 'vif-tag)) + (set! (-> a3-17 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-60 base) (the-as pointer (&+ a3-17 16))) + ) + (let* ((v1-61 s4-1) + (a3-19 (the-as gs-gif-tag (-> v1-61 base))) + ) + (set! (-> a3-19 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> a3-19 regs) GIF_REGS_ALL_AD) + (set! (-> v1-61 base) (the-as pointer (&+ a3-19 16))) + ) + (let* ((v1-62 s4-1) + (a3-21 (-> v1-62 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a3-21) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a3-21) 1) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) a3-21) 2) + (new 'static 'gs-tex0 :tbp0 #x4c0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a3-21) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer uint64) a3-21) 4) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-21) 5) (gs-reg64 texflush)) + (set! (-> v1-62 base) (&+ a3-21 48)) + ) + (let ((v1-63 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> v1-63 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> v1-63 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> v1-63 2 vector4w) a0-57 a1-46 a2-55 (the int (- 128.0 (* 48.0 f0-0)))) + (set-vector! (-> v1-63 3 vector4w) 0 24 0 0) + (set-vector! (-> v1-63 4 vector4w) #x7000 #x7300 0 0) + (set-vector! (-> v1-63 5 vector4w) 8192 6680 0 0) + (set-vector! (-> v1-63 6 vector4w) #x9000 #x8d00 0 0) + ) + ) + ) + (&+! (-> s4-1 base) 112) + (seek! + (-> *blit-displays-work* progress-interp) + (-> *blit-displays-work* progress-interp-dest) + (-> *blit-displays-work* progress-interp-speed) + ) + ) + (else + (let* ((a0-66 s4-1) + (a1-53 (the-as dma-packet (-> a0-66 base))) + ) + (set! (-> a1-53 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> a1-53 vif0) (new 'static 'vif-tag)) + (set! (-> a1-53 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-66 base) (the-as pointer (&+ a1-53 16))) + ) + (let* ((a0-67 s4-1) + (a1-55 (the-as gs-gif-tag (-> a0-67 base))) + ) + (set! (-> a1-55 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> a1-55 regs) GIF_REGS_ALL_AD) + (set! (-> a0-67 base) (the-as pointer (&+ a1-55 16))) + ) + (let* ((a0-68 s4-1) + (a1-57 (-> a0-68 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a1-57) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a1-57) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a1-57) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-57) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-rgbaq) a1-57) 4) (new 'static 'gs-rgbaq + :q 1.0 + :a (the int (-> v1-0 current-fog erase-color w)) + :b (the int (-> v1-0 current-fog erase-color z)) + :g (the int (-> v1-0 current-fog erase-color y)) + :r (the int (-> v1-0 current-fog erase-color x)) + ) + ) + (set! (-> (the-as (pointer gs-reg64) a1-57) 5) (gs-reg64 rgbaq)) + (set! (-> a0-68 base) (&+ a1-57 48)) + ) + (let ((v1-78 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> v1-78 0 quad) (-> obj sprite-tmpl dma-vif quad)) + (set! (-> v1-78 1 quad) (-> obj sprite-tmpl quad 1)) + ) + (&+! (-> s4-1 base) 32) + (let ((v1-81 (the-as (inline-array qword) (-> s4-1 base)))) + (set-vector! (-> v1-81 0 vector4w) #x7000 #x7300 0 0) + (set-vector! (-> v1-81 1 vector4w) #x9000 #x8d00 0 0) + ) + (&+! (-> s4-1 base) 32) + ) + ) + (let ((a3-35 (-> s4-1 base))) + (let ((v1-85 (the-as dma-packet (-> s4-1 base)))) + (set! (-> v1-85 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-85 vif0) (new 'static 'vif-tag)) + (set! (-> v1-85 vif1) (new 'static 'vif-tag)) + (set! (-> s4-1 base) (the-as pointer (&+ v1-85 16))) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id sky-draw) + gp-1 + (the-as (pointer dma-tag) a3-35) + ) + ) + ) + ) + ) + ) + 0 + (none) ) \ No newline at end of file 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 37197222d1..cfdbcb618d 100644 --- a/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc +++ b/goal_src/jak2/engine/gfx/texture/texture-anim-h.gc @@ -54,7 +54,7 @@ (func-id basic :offset 4) (init-func basic :offset-assert 8) (init-func-id basic :offset 8) - (tex basic :offset-assert 12) + (tex texture :offset-assert 12) (tex-name basic :offset-assert 16) (extra vector :inline :offset-assert 32) (color rgba :offset-assert 48) @@ -76,7 +76,7 @@ ) (deftype texture-anim-array (array) - ((array-data texture-anim :inline :dynamic :offset-assert 16) + ((array-data texture-anim :dynamic :offset-assert 16) ) :method-count-assert 11 :size-assert #x10 diff --git a/goal_src/jak2/engine/gfx/vu1-user-h.gc b/goal_src/jak2/engine/gfx/vu1-user-h.gc index b409bffe4b..a481104cc6 100644 --- a/goal_src/jak2/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak2/engine/gfx/vu1-user-h.gc @@ -31,7 +31,7 @@ (bucket-2 2) (bucket-3 3) ;; blit displays (tex-lcom-sky-pre 4) ;; tex - (bucket-5 5) ;; sky + (sky-draw 5) ;; sky (bucket-6 6) ;; ocean ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/jak2/engine/level/level.gc b/goal_src/jak2/engine/level/level.gc index 4dd66fb800..2bc0e8ff4f 100644 --- a/goal_src/jak2/engine/level/level.gc +++ b/goal_src/jak2/engine/level/level.gc @@ -2151,7 +2151,7 @@ 'demo ) (*debug-segment* - ;;'prison + ; 'prison 'ctysluma ) (else @@ -2179,15 +2179,14 @@ ) (set! *time-of-day-fast* #f) (load-commands-set! *level* '()) - (format 0 "SKIP: time of day setup and initial level load.~%") - ; (send-event (ppointer->process *time-of-day*) 'change 'ratio #x3f800000) - ; (send-event (ppointer->process *time-of-day*) 'change 'hour 7) - ; (send-event (ppointer->process *time-of-day*) 'change 'minutes 0) - ; (send-event (ppointer->process *time-of-day*) 'change 'seconds 0) - ; (send-event (ppointer->process *time-of-day*) 'change 'frames 0) - ; (set! (-> *time-of-day-context* mode) (the-as uint 8)) - ; (set! (-> *mood-control* overide-weather-flag) #f) - ; (set-blackout-frames (seconds 0.02)) + (send-event (ppointer->process *time-of-day*) 'change 'ratio #x3f800000) + (send-event (ppointer->process *time-of-day*) 'change 'hour 7) + (send-event (ppointer->process *time-of-day*) 'change 'minutes 0) + (send-event (ppointer->process *time-of-day*) 'change 'seconds 0) + (send-event (ppointer->process *time-of-day*) 'change 'frames 0) + (set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3)) + (set! (-> *mood-control* overide-weather-flag) #f) + (set-blackout-frames (seconds 0.02)) (when (not *dproc*) (reset! *load-state*) (let ((s4-1 (level-get-for-use *level* s5-0 'active))) @@ -2223,9 +2222,10 @@ ) (start-debug "PLAY: starting dproc~%") (on #t) - (if arg1 - (initialize! *game-info* 'game (the-as game-save #f) (the-as string #f)) - ) + (format 0 "SKIP: initialize game info~%") + ; (if arg1 + ; (initialize! *game-info* 'game (the-as game-save #f) (the-as string #f)) + ; ) (kmemclose) (kmemclose) 0 diff --git a/test/decompiler/reference/jak2/engine/gfx/sky/sky-data_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sky/sky-data_REF.gc index 7cd04e1e75..251313a71c 100644 --- a/test/decompiler/reference/jak2/engine/gfx/sky/sky-data_REF.gc +++ b/test/decompiler/reference/jak2/engine/gfx/sky/sky-data_REF.gc @@ -250,285 +250,656 @@ ;; definition for symbol *cloud-vert-array*, type cloud-vert-array (define *cloud-vert-array* (new 'static 'cloud-vert-array)) -;; definition for symbol *cloud-poly*, type (inline-array cloud-vertex) -(define *cloud-poly* (new 'static 'inline-array cloud-vertex 277 - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) - (new 'static 'cloud-vertex) +;; definition for symbol *cloud-poly*, type (inline-array sky-vertex) +(define *cloud-poly* (new 'static 'inline-array sky-vertex 648 + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) ) ) @@ -576,152 +947,152 @@ ;; definition for symbol *haze-vert-array*, type haze-vert-array (define *haze-vert-array* (new 'static 'haze-vert-array)) -;; definition for symbol *haze-poly*, type (inline-array haze-vertex) -(define *haze-poly* (new 'static 'inline-array haze-vertex 144 - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) - (new 'static 'haze-vertex) +;; definition for symbol *haze-poly*, type (inline-array sky-vertex) +(define *haze-poly* (new 'static 'inline-array sky-vertex 144 + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) + (new 'static 'sky-vertex) ) ) 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 7ee1353682..ab1036ae51 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 @@ -434,7 +434,7 @@ (vec1 vector4w :inline :offset-assert 1568) (cloud-lights cloud-lights :inline :offset-assert 1584) (haze-lights haze-lights :inline :offset-assert 1744) - (buf basic :offset-assert 1868) + (buf dma-buffer :offset-assert 1868) (draw-vortex basic :offset-assert 1872) (stars vector 512 :inline :offset-assert 1888) ) @@ -447,29 +447,29 @@ (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) - (sky-work-method-16 () none 16) - (sky-work-method-17 () none 17) - (sky-work-method-18 () none 18) - (sky-work-method-19 () none 19) - (sky-work-method-20 () none 20) - (sky-work-method-21 () none 21) - (sky-work-method-22 () none 22) - (sky-work-method-23 () none 23) - (sky-work-method-24 () none 24) - (sky-work-method-25 () none 25) - (sky-work-method-26 () none 26) - (sky-work-method-27 () none 27) - (sky-work-method-28 () none 28) - (sky-work-method-29 () none 29) - (sky-work-method-30 () none 30) - (sky-work-method-31 () none 31) - (sky-work-method-32 () none 32) - (sky-work-method-33 () none 33) - (sky-work-method-34 () none 34) - (sky-work-method-35 () none 35) - (sky-work-method-36 () none 36) + (update-matrix (_type_ matrix) none 14) + (update-template-colors (_type_) none 15) + (init-regs-for-large-polygon-draw (_type_) none 16) + (init-regs-for-sky-asm (_type_) none 17) + (cloud-vtx-light-update (_type_ vector vector cloud-lights vector vector) none 18) + (cloud-vtx-tex-update (_type_ vector vector vector cloud-lights) none 19) + (adjust-cloud-lighting (_type_) none 20) + (cloud-vtx1-to-sky (_type_ sky-vertex cloud-vertex) none 21) + (cloud-vtx2-to-sky (_type_ sky-vertex cloud-vertex) none 22) + (draw-clouds (_type_ dma-buffer) none 23) + (apply-haze-light (_type_ vector vector haze-lights) none 24) + (adjust-haze-lighting (_type_) none 25) + (haze-vtx-to-sky (_type_ sky-vertex sky-vertex haze-vertex) none 26) + (draw-haze (_type_ dma-buffer) none 27) + (sun-dma (_type_ dma-buffer) none 28) + (green-sun-dma (_type_ dma-buffer) none 29) + (moon-dma (_type_ dma-buffer) none 30) + (setup-stars (_type_ matrix sky-upload-data) none 31) + (stars-transform-asm (_type_) none 32) + (stars-dma (_type_ dma-buffer) none 33) + (draw-roof (_type_ dma-buffer) none 34) + (draw-base (_type_ dma-buffer) none 35) + (draw-fog (_type_ dma-buffer) none 36) ) ) diff --git a/test/decompiler/reference/jak2/engine/gfx/sky/sky-tng_REF.gc b/test/decompiler/reference/jak2/engine/gfx/sky/sky-tng_REF.gc new file mode 100644 index 0000000000..1bbdb4cdb7 --- /dev/null +++ b/test/decompiler/reference/jak2/engine/gfx/sky/sky-tng_REF.gc @@ -0,0 +1,1131 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for function set-tex-offset +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function draw-large-polygon +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function clip-polygon-against-positive-hyperplane +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function clip-polygon-against-negative-hyperplane +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function render-sky-quad +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function render-sky-tri +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function close-sky-buffer +;; INFO: Used lq/sq +;; WARN: Return type mismatch pointer vs none. +;; ERROR: Function may read a register that is not set: ra +;; ERROR: Unsupported inline assembly instruction kind - [jr ra] +(defun close-sky-buffer ((arg0 dma-buffer)) + (local-vars (ra-0 none)) + (nop!) + (let ((v1-0 #x8000) + (v0-0 (-> arg0 base)) + ) + (set! (-> (the-as (pointer int128) v0-0)) 0) + (nop!) + (set! (-> (the-as (pointer int32) v0-0)) v1-0) + (let ((v0-1 (&+ v0-0 16))) + (.jr ra-0) + (set! (-> arg0 base) v0-1) + ) + ) + (none) + ) + +;; definition for method 14 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-matrix sky-work ((obj sky-work) (arg0 matrix)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((v1-0 (-> obj cam-mat))) + (let* ((a0-1 v1-0) + (t0-0 arg0) + (a1-1 (-> t0-0 vector 0 quad)) + (a2-0 (-> t0-0 vector 1 quad)) + (a3-0 (-> t0-0 vector 2 quad)) + (t0-1 (-> t0-0 trans quad)) + ) + (set! (-> a0-1 vector 0 quad) a1-1) + (set! (-> a0-1 vector 1 quad) a2-0) + (set! (-> a0-1 vector 2 quad) a3-0) + (set! (-> a0-1 trans quad) t0-1) + ) + (.svf (&-> v1-0 trans quad) vf0) + (matrix*! v1-0 v1-0 (-> *math-camera* perspective)) + ) + 0 + (none) + ) + ) + +;; definition for method 15 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-template-colors sky-work ((obj sky-work)) + (let ((v1-1 (-> *time-of-day-context* current-fog erase-color)) + (a0-2 (-> *level* default-level mood-context current-sky-color)) + ) + (dotimes (a1-0 12) + (set! (-> sky-base-polygons a1-0 col quad) (-> v1-1 quad)) + (set! (-> sky-roof-polygons a1-0 col quad) (-> a0-2 quad)) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type sky-work +;; WARN: Return type mismatch int vs none. +(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) + ) + +;; definition for method 16 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 17 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 11 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs 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) + ) + +;; definition for method 18 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx-light-update sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 cloud-lights) (arg3 vector) (arg4 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg4 quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 arg3) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +;; definition for method 19 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx-tex-update sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 vector) (arg3 cloud-lights)) + (let ((s5-0 (new 'stack-no-clear 'vector4)) + (s2-0 (new 'stack-no-clear 'vector4)) + (s4-0 (new 'stack-no-clear 'vector4)) + (f28-0 0.00390625) + (f30-0 0.015625) + ) + (set! (-> arg0 quad) (-> arg1 quad)) + (vector--float*! (the-as vector s5-0) arg2 (-> arg3 sun0-normal) 9.0) + (vector--float*! (the-as vector s2-0) arg2 (-> arg3 sun1-normal) 9.0) + (vector--float*! (the-as vector s4-0) arg2 (-> arg3 moon-normal) 9.0) + (vector4-scale! s5-0 s5-0 (* (-> arg3 sun0-scale) f28-0)) + (vector4-madd! s5-0 s5-0 s2-0 (* 0.25 f28-0 (-> arg3 sun1-scale))) + (vector4-madd! s5-0 s5-0 s4-0 (* (-> arg3 moon-scale) f28-0)) + (+! (-> arg0 x) (fmax (fmin (-> s5-0 x) f30-0) (- f30-0))) + (+! (-> arg0 y) (fmax (fmin (-> s5-0 z) f30-0) (- f30-0))) + ) + 0 + (none) + ) + +;; definition for method 20 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod adjust-cloud-lighting sky-work ((obj sky-work)) + (let ((s5-0 *cloud-vert-array*) + (s4-0 (-> obj cloud-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> obj upload-data sun 0 pos quad)) + (set! (-> s4-0 sun1-normal quad) (-> obj upload-data sun 1 pos quad)) + (set! (-> s4-0 moon-normal quad) (-> obj upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((s1-0 (-> s4-0 ambi-color)) + (s2-0 (-> s4-0 ambi-color-lower)) + (s3-0 (-> obj sun0-color-lower)) + ) + (let ((f30-0 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y)))))) + (f28-0 (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y))))))) + ) + (vector4-scale! (the-as vector4 s2-0) (the-as vector4 (-> obj ambi-color-lower)) f30-0) + (vector4-madd! (the-as vector4 s2-0) (the-as vector4 s2-0) (the-as vector4 s3-0) f28-0) + (vector4-scale! (the-as vector4 s1-0) (the-as vector4 (-> obj ambi-color)) f30-0) + (vector4-madd! (the-as vector4 s1-0) (the-as vector4 s1-0) (the-as vector4 s3-0) f28-0) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> obj sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> obj sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> obj moon-color)) + (-> s4-0 moon-scale) + ) + (vector4-scale! (the-as vector4 (-> s4-0 sun0-color-lower)) (the-as vector4 s3-0) (-> s4-0 sun0-scale)) + ) + (dotimes (s3-1 100) + (let ((s2-1 (-> s5-0 data s3-1))) + (cloud-vtx-light-update obj (-> s2-1 col) (-> s2-1 nrm) s4-0 (-> s4-0 sun0-color) (-> s4-0 ambi-color)) + (cloud-vtx-light-update + obj + (-> s2-1 col2) + (-> s2-1 nrm2) + s4-0 + (-> s4-0 sun0-color-lower) + (-> s4-0 ambi-color-lower) + ) + (cloud-vtx-tex-update obj (-> s2-1 stq2) (-> s2-1 stq) (-> s2-1 pos) s4-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 21 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx1-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq quad)) + (set! (-> arg0 col quad) (-> arg1 col quad)) + 0 + (none) + ) + +;; definition for method 22 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod cloud-vtx2-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 cloud-vertex)) + (set! (-> arg0 pos quad) (-> arg1 pos quad)) + (set! (-> arg0 stq quad) (-> arg1 stq2 quad)) + (set! (-> arg0 col quad) (-> arg1 col2 quad)) + 0 + (none) + ) + +;; definition for method 23 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-clouds sky-work ((obj sky-work) (arg0 dma-buffer)) + (local-vars (v1-19 float) (sv-16 cloud-vert-array) (sv-20 (inline-array sky-vertex)) (sv-32 int)) + (rlet ((vf23 :class vf) + (vf27 :class vf) + ) + (let* ((v1-0 arg0) + (a0-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt))) + (set! (-> a0-1 vif0) (new 'static 'vif-tag)) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ a0-1 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as gs-gif-tag (-> v1-1 base))) + ) + (set! (-> a0-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x6)) + (set! (-> a0-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (the-as pointer (&+ a0-3 16))) + ) + (let* ((s4-0 arg0) + (s3-0 (-> s4-0 base)) + ) + (set! (-> (the-as (pointer gs-test) s3-0) 0) (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x50 + :afail #x1 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s3-0) 1) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-tex0) s3-0) 2) (new 'static 'gs-tex0 + :tbp0 #x100 + :tbw #x2 + :psm #x1b + :tcc #x1 + :cbp #x300 + :cld #x1 + :th (log2 128) + :tw (log2 128) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s3-0) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) s3-0) 4) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 5) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) s3-0) 6) (new 'static 'gs-clamp)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 7) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-alpha) s3-0) 8) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 9) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer uint64) s3-0) 10) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) s3-0) 11) (gs-reg64 texflush)) + (set! (-> s4-0 base) (&+ s3-0 96)) + ) + (.lvf vf27 (&-> obj giftag-roof quad)) + (let ((v1-18 #x43c80000)) + (.mov vf23 v1-18) + ) + (.mov v1-19 vf23) + (set-tex-offset (the-as int (-> obj off-s)) (the-as int (-> obj off-t))) + (let ((s4-1 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (set! sv-16 *cloud-vert-array*) + (set! sv-20 *cloud-poly*) + (dotimes (s3-1 9) + (dotimes (s2-2 9) + (let ((s1-0 (+ (* 10 s3-1) s2-2))) + (set! sv-32 (+ (* 9 s3-1) s2-2)) + (let ((s0-0 (+ s2-2 81 (* 9 s3-1)))) + (cloud-vtx1-to-sky obj (-> sv-20 (* sv-32 4)) (-> sv-16 data s1-0)) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx1-to-sky obj (-> sv-20 (+ (* sv-32 4) 3)) (-> sv-16 data (+ s1-0 10))) + (cloud-vtx2-to-sky obj (-> sv-20 (* s0-0 4)) (-> sv-16 data s1-0)) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 1)) (-> sv-16 data (+ s1-0 1))) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 2)) (-> sv-16 data (+ s1-0 11))) + (cloud-vtx2-to-sky obj (-> sv-20 (+ (* s0-0 4) 3)) (-> sv-16 data (+ s1-0 10))) + ) + ) + ) + ) + (dotimes (s5-1 162) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-81 (/ (the-as int (+ (- -16 (the-as int s4-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s4-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-81)) + (set! (-> (the-as dma-packet s4-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s4-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-81)) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 24 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod apply-haze-light sky-work ((obj sky-work) (arg0 vector) (arg1 vector) (arg2 haze-lights)) + (let ((s5-0 (new 'stack-no-clear 'vector4))) + (let* ((f0-1 (vector-dot (-> arg2 sun0-normal) arg1)) + (f1-1 (vector-dot (-> arg2 sun1-normal) arg1)) + (f2-1 (vector-dot (-> arg2 moon-normal) arg1)) + (f0-2 (fmax 0.0 f0-1)) + (f30-0 (fmax 0.0 f1-1)) + (f28-0 (fmax 0.0 f2-1)) + ) + (set! (-> s5-0 quad) (-> arg2 ambi-color quad)) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun0-color)) f0-2) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 sun1-color)) f30-0) + (vector4-madd! s5-0 s5-0 (the-as vector4 (-> arg2 moon-color)) f28-0) + ) + (vector4-scale! s5-0 s5-0 128.0) + (set! (-> arg0 x) (fmax 0.0 (fmin 255.0 (-> s5-0 x)))) + (set! (-> arg0 y) (fmax 0.0 (fmin 255.0 (-> s5-0 y)))) + (set! (-> arg0 z) (fmax 0.0 (fmin 255.0 (-> s5-0 z)))) + ) + 0 + (none) + ) + +;; definition for method 25 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod adjust-haze-lighting sky-work ((obj sky-work)) + (let ((s5-0 *haze-vert-array*) + (s4-0 (-> obj haze-lights)) + ) + (set! (-> s4-0 sun0-normal quad) (-> obj upload-data sun 0 pos quad)) + (set! (-> s4-0 sun1-normal quad) (-> obj upload-data sun 1 pos quad)) + (set! (-> s4-0 moon-normal quad) (-> obj upload-data moon pos quad)) + (vector-normalize! (-> s4-0 sun0-normal) 1.0) + (vector-normalize! (-> s4-0 sun1-normal) 1.0) + (vector-normalize! (-> s4-0 moon-normal) 1.0) + (set! (-> s4-0 sun0-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun0-normal y)))))) + (set! (-> s4-0 sun1-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 sun1-normal y)))))) + (set! (-> s4-0 moon-scale) (fmax 0.0 (fmin 1.0 (* 8.0 (+ 0.125 (-> s4-0 moon-normal y)))))) + (let ((a0-10 (-> s4-0 ambi-color))) + (-> obj sun0-color-lower) + (let ((f0-7 (- 1.0 (fmax 0.0 (fmin 0.75 (* 4.0 (-> s4-0 moon-normal y))))))) + (* 0.3333 (fmax 0.0 (fmin 1.0 (+ -1.0 (* 8.0 (-> s4-0 sun0-normal y)))))) + (vector4-scale! (the-as vector4 a0-10) (the-as vector4 (-> obj ambi-color)) f0-7) + ) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun0-color)) + (the-as vector4 (-> obj sun0-color)) + (-> s4-0 sun0-scale) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 sun1-color)) + (the-as vector4 (-> obj sun1-color)) + (* 0.5 (-> s4-0 sun1-scale)) + ) + (vector4-scale! + (the-as vector4 (-> s4-0 moon-color)) + (the-as vector4 (-> obj moon-color)) + (-> s4-0 moon-scale) + ) + (dotimes (s3-0 36) + (let ((v1-25 (-> s5-0 data s3-0))) + (apply-haze-light obj (-> v1-25 col) (-> v1-25 nrm) s4-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod haze-vtx-to-sky sky-work ((obj sky-work) (arg0 sky-vertex) (arg1 sky-vertex) (arg2 haze-vertex)) + (set! (-> arg0 pos quad) (-> arg2 pos quad)) + (set! (-> arg0 col quad) (-> arg2 col quad)) + (set! (-> arg0 col w) 128.0) + (set! (-> arg1 pos quad) (-> arg2 pos quad)) + (set! (-> arg1 col quad) (-> arg2 col quad)) + (set! (-> arg1 pos y) 3.0) + (set! (-> arg1 col w) 0.0) + 0 + (none) + ) + +;; definition for method 27 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-haze sky-work ((obj sky-work) (arg0 dma-buffer)) + (local-vars (sv-16 haze-vert-array) (sv-20 (inline-array sky-vertex))) + (rlet ((vf27 :class vf)) + (let* ((v1-0 arg0) + (a0-1 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a0-1) 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a0-3) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> (the-as gs-gif-tag a0-3) regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (&+ (the-as pointer a0-3) 16)) + ) + (let* ((v1-2 arg0) + (a0-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a0-5) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a0-5) 1) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a0-5 16)) + ) + (init-regs-for-large-polygon-draw obj) + (.lvf vf27 (&-> obj giftag-haze quad)) + (let ((s4-0 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (set! sv-16 *haze-vert-array*) + (set! sv-20 *haze-poly*) + (dotimes (s3-0 35) + (haze-vtx-to-sky obj (-> sv-20 (* s3-0 4)) (-> sv-20 (+ (* s3-0 4) 1)) (-> sv-16 data s3-0)) + (haze-vtx-to-sky obj (-> sv-20 (+ (* s3-0 4) 3)) (-> sv-20 (+ (* s3-0 4) 2)) (-> sv-16 data (+ s3-0 1))) + ) + (haze-vtx-to-sky obj (-> sv-20 140) (-> sv-20 141) (-> sv-16 data 35)) + (haze-vtx-to-sky obj (-> sv-20 143) (-> sv-20 142) (the-as haze-vertex (-> sv-16 data))) + (dotimes (s5-1 36) + (render-sky-quad (the-as (inline-array sky-vertex) (-> sv-20 (* s5-1 4))) arg0) + ) + (close-sky-buffer arg0) + (let ((v1-41 (/ (the-as int (+ (- -16 (the-as int s4-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s4-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-41)) + (set! (-> (the-as dma-packet s4-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s4-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-41)) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 28 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 29 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 30 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 31 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod setup-stars sky-work ((obj sky-work) (arg0 matrix) (arg1 sky-upload-data)) + (set! (-> arg0 vector 2 quad) (-> arg1 sun 0 pos quad)) + (vector-normalize! (-> arg0 vector 2) 1.0) + (vector-cross! (the-as vector (-> arg0 vector)) *z-vector* (-> arg0 vector 2)) + (vector-normalize! (the-as vector (-> arg0 vector)) 1.0) + (vector-cross! (-> arg0 vector 1) (-> arg0 vector 2) (the-as vector (-> arg0 vector))) + (vector-normalize! (-> arg0 vector 1) 1.0) + (let ((s4-1 (new 'stack-no-clear 'vector))) + (set! (-> s4-1 quad) (-> arg1 sun 0 pos quad)) + (vector-normalize! s4-1 -1.0) + (let ((f0-1 (fmax 0.0 (fmin 1.0 (* 20.0 (+ 0.05 (-> s4-1 y))))))) + (dotimes (v1-7 16) + (let ((f1-4 (* (- 128.0 (* 8.0 (the float v1-7))) f0-1))) + (set-vector! (-> obj star-colors v1-7) (the int f1-4) (the int f1-4) (the int f1-4) 128) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 32 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 33 of type sky-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 34 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-roof sky-work ((obj sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (let* ((v1-0 arg0) + (a0-1 (the-as object (-> v1-0 base))) + ) + (set! (-> (the-as dma-packet a0-1) dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> (the-as dma-packet a0-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet a0-1) vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ (the-as dma-packet a0-1) 16))) + ) + (let* ((v1-1 arg0) + (a0-3 (the-as object (-> v1-1 base))) + ) + (set! (-> (the-as gs-gif-tag a0-3) tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> (the-as gs-gif-tag a0-3) regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (&+ (the-as pointer a0-3) 16)) + ) + (let* ((v1-2 arg0) + (a0-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a0-5) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a0-5) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a0-5) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a0-5) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) a0-5) 4) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a0-5) 5) (gs-reg64 alpha-1)) + (set! (-> v1-2 base) (&+ a0-5 48)) + ) + (init-regs-for-large-polygon-draw obj) + (.lvf vf27 (&-> obj giftag-base quad)) + (let ((s5-1 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-roof-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-14 (/ (the-as int (+ (- -16 (the-as int s5-1)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s5-1) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-14)) + (set! (-> (the-as dma-packet s5-1) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s5-1) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-14)) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 35 of type sky-work +;; WARN: Return type mismatch int vs none. +(defmethod draw-base sky-work ((obj sky-work) (arg0 dma-buffer)) + (rlet ((vf27 :class vf)) + (let* ((v1-0 arg0) + (a1-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a1-1 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-1 vif0) (new 'static 'vif-tag)) + (set! (-> a1-1 vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-0 base) (the-as pointer (&+ a1-1 16))) + ) + (let* ((v1-1 arg0) + (a1-3 (the-as gs-gif-tag (-> v1-1 base))) + ) + (set! (-> a1-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> a1-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-1 base) (the-as pointer (&+ a1-3 16))) + ) + (let* ((v1-2 arg0) + (a1-5 (-> v1-2 base)) + ) + (set! (-> (the-as (pointer gs-test) a1-5) 0) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-5) 1) (gs-reg64 test-1)) + (set! (-> v1-2 base) (&+ a1-5 16)) + ) + (let ((s5-0 (the-as object (-> arg0 base)))) + (&+! (-> arg0 base) 16) + (.lvf vf27 (&-> obj giftag-base quad)) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 0)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 3)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 6)) arg0) + (render-sky-tri (the-as (inline-array sky-vertex) (-> sky-base-polygons 9)) arg0) + (close-sky-buffer arg0) + (let ((v1-12 (/ (the-as int (+ (- -16 (the-as int s5-0)) (the-as int (-> arg0 base)))) 16))) + (set! (-> (the-as dma-packet s5-0) dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc v1-12)) + (set! (-> (the-as dma-packet s5-0) vif0) (new 'static 'vif-tag)) + (set! (-> (the-as dma-packet s5-0) vif1) (new 'static 'vif-tag :cmd (vif-cmd direct) :msk #x1 :imm v1-12)) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 36 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-fog sky-work ((obj sky-work) (arg0 dma-buffer)) + (let ((s4-0 (-> *sky-texture-anim-array* array-data 8 tex))) + (when s4-0 + (let* ((v1-3 arg0) + (a0-1 (the-as dma-packet (-> v1-3 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt))) + (set! (-> a0-1 vif0) (new 'static 'vif-tag)) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-3 base) (the-as pointer (&+ a0-1 16))) + ) + (let* ((v1-4 arg0) + (a0-3 (the-as gs-gif-tag (-> v1-4 base))) + ) + (set! (-> a0-3 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x5)) + (set! (-> a0-3 regs) GIF_REGS_ALL_AD) + (set! (-> v1-4 base) (the-as pointer (the-as gs-gif-tag (&+ a0-3 16)))) + ) + (let* ((s3-0 arg0) + (s2-0 (-> s3-0 base)) + ) + (set! (-> (the-as (pointer gs-tex0) s2-0) 0) + (new 'static 'gs-tex0 + :tcc #x1 + :cld #x1 + :psm (the-as int (-> s4-0 psm)) + :cpsm (-> s4-0 clutpsm) + :cbp (-> s4-0 clutdest) + :th (log2 (-> s4-0 h)) + :tw (log2 (-> s4-0 w)) + :tbw (-> s4-0 width 0) + :tbp0 (-> s4-0 dest 0) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 1) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) s2-0) 2) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) s2-0) 3) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-test) s2-0) 4) + (new 'static 'gs-test + :ate #x1 + :atst (gs-atest greater-equal) + :aref #x70 + :afail #x3 + :zte #x1 + :ztst (gs-ztest greater-equal) + ) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 5) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-clamp) s2-0) 6) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) s2-0) 7) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer gs-alpha) s2-0) 8) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) s2-0) 9) (gs-reg64 alpha-1)) + (set! (-> s3-0 base) (&+ s2-0 80)) + ) + ) + ) + (let* ((v1-26 (the-as (inline-array qword) (-> arg0 base))) + (f0-0 (-> *fog-texture-work* min-corner y)) + (f4-0 (- (-> *fog-texture-work* max-corner y) f0-0)) + (f3-0 (/ (- (-> *fog-texture-work* corner 1 y) f0-0) f4-0)) + (f2-0 (/ (- (-> *fog-texture-work* corner 0 y) f0-0) f4-0)) + (f1-7 (/ (- (-> *fog-texture-work* corner 3 y) f0-0) f4-0)) + (f0-2 (/ (- (-> *fog-texture-work* corner 2 y) f0-0) f4-0)) + (a0-28 6400) + ) + (set! (-> v1-26 0 quad) (-> obj fog-tmpl dma-vif quad)) + (set! (-> v1-26 1 quad) (-> obj fog-tmpl quad 1)) + (set-vector! (-> v1-26 2 vector4w) 128 128 128 128) + (set-vector! (-> v1-26 3 vector4w) (the-as int f3-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 4 vector4w) #x7000 #x7300 a0-28 0) + (set-vector! (-> v1-26 5 vector4w) (the-as int f2-0) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 6 vector4w) #x9000 #x7300 a0-28 0) + (set-vector! (-> v1-26 7 vector4w) (the-as int f1-7) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 8 vector4w) #x7000 #x8d00 a0-28 0) + (set-vector! (-> v1-26 9 vector4w) (the-as int f0-2) (the-as int 0.0) (the-as int 1.0) (the-as int 0.0)) + (set-vector! (-> v1-26 10 vector4w) #x9000 #x8d00 a0-28 0) + ) + (&+! (-> arg0 base) 176) + 0 + (none) + ) + +;; definition for method 13 of type sky-work +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw sky-work ((obj sky-work)) + (let ((v1-0 *time-of-day-context*) + (a0-1 #f) + ) + (dotimes (a1-0 (-> *level* length)) + (let ((a2-3 (-> *level* level a1-0))) + (when (= (-> a2-3 status) 'active) + (if (-> a2-3 info sky) + (set! a0-1 #t) + ) + ) + ) + ) + (cond + ((and a0-1 + (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask sky)) + (logtest? (-> *texture-pool* texture-enable-user) (texture-enable-mask sky)) + ) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf base))) + (let ((a1-7 (if (-> v1-0 use-camera-other) + (-> *math-camera* camera-rot-other) + (-> *math-camera* camera-rot) + ) + ) + ) + (update-matrix obj a1-7) + ) + (update-template-colors obj) + (adjust-haze-lighting obj) + (adjust-cloud-lighting obj) + (let ((s4-0 (the-as object #x70000000))) + (mem-copy! (the-as pointer s4-0) (the-as pointer obj) #x2760) + (setup-stars (the-as sky-work s4-0) (-> (the-as sky-work s4-0) star-mat) (-> obj upload-data)) + (if (nonzero? (-> (the-as sky-work s4-0) star-colors 0 x)) + (stars-transform-asm (the-as sky-work s4-0)) + ) + (let* ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-1 (-> s3-0 base)) + ) + (draw-roof (the-as sky-work s4-0) s3-0) + (init-regs-for-sky-asm (the-as sky-work s4-0)) + (if (nonzero? (-> (the-as sky-work s4-0) star-colors 0 x)) + (stars-dma (the-as sky-work s4-0) s3-0) + ) + (sun-dma (the-as sky-work s4-0) s3-0) + (green-sun-dma (the-as sky-work s4-0) s3-0) + (moon-dma (the-as sky-work s4-0) s3-0) + (draw-haze (the-as sky-work s4-0) s3-0) + (draw-clouds (the-as sky-work s4-0) s3-0) + (draw-base (the-as sky-work s4-0) s3-0) + (draw-fog (the-as sky-work s4-0) s3-0) + (let ((a3-5 (-> s3-0 base))) + (let ((v1-45 (the-as dma-packet (-> s3-0 base)))) + (set! (-> v1-45 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-45 vif0) (new 'static 'vif-tag)) + (set! (-> v1-45 vif1) (new 'static 'vif-tag)) + (set! (-> s3-0 base) (the-as pointer (&+ v1-45 16))) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id sky-draw) + s5-1 + (the-as (pointer dma-tag) a3-5) + ) + ) + ) + ) + (let ((v1-52 *dma-mem-usage*)) + (when (nonzero? v1-52) + (set! (-> v1-52 length) (max 89 (-> v1-52 length))) + (set! (-> v1-52 data 88 name) "sky") + (+! (-> v1-52 data 88 count) 1) + (+! (-> v1-52 data 88 used) + (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint gp-0)) + ) + (set! (-> v1-52 data 88 total) (-> v1-52 data 88 used)) + ) + ) + ) + ) + (else + (let* ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (gp-1 (-> s4-1 base)) + ) + (cond + ((-> *blit-displays-work* menu-mode) + (let ((f0-0 (-> *blit-displays-work* progress-interp))) + (let* ((a0-43 s4-1) + (a1-30 (the-as dma-packet (-> a0-43 base))) + ) + (set! (-> a1-30 dma) (new 'static 'dma-tag :qwc #x8 :id (dma-tag-id cnt))) + (set! (-> a1-30 vif0) (new 'static 'vif-tag)) + (set! (-> a1-30 vif1) (new 'static 'vif-tag :imm #x8 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-43 base) (the-as pointer (&+ a1-30 16))) + ) + (let* ((a0-44 s4-1) + (a1-32 (the-as gs-gif-tag (-> a0-44 base))) + ) + (set! (-> a1-32 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x7)) + (set! (-> a1-32 regs) GIF_REGS_ALL_AD) + (set! (-> a0-44 base) (the-as pointer (&+ a1-32 16))) + ) + (let* ((a0-45 s4-1) + (a1-34 (-> a0-45 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a1-34) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a1-34) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a1-34) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-alpha) a1-34) 4) (new 'static 'gs-alpha)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 5) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) a1-34) 6) + (new 'static 'gs-tex0 :tbp0 #x4c0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 7) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer gs-tex1) a1-34) 8) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 9) (gs-reg64 tex1-1)) + (set! (-> (the-as (pointer gs-clamp) a1-34) 10) + (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-34) 11) (gs-reg64 clamp-1)) + (set! (-> (the-as (pointer uint64) a1-34) 12) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a1-34) 13) (gs-reg64 texflush)) + (set! (-> a0-45 base) (&+ a1-34 112)) + ) + (let ((a2-40 (the-as (inline-array qword) (-> s4-1 base))) + (a3-7 #x7000) + (t0-1 #x7300) + (a0-46 #x7800) + (a1-36 #x7980) + ) + (set! (-> a2-40 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> a2-40 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> a2-40 2 vector4w) 128 128 128 128) + (set-vector! (-> a2-40 3 vector4w) 8 8 0 0) + (set-vector! (-> a2-40 4 vector4w) a3-7 t0-1 0 0) + (set-vector! (-> a2-40 5 vector4w) 8200 6664 0 0) + (set-vector! (-> a2-40 6 vector4w) a0-46 a1-36 0 0) + ) + (&+! (-> s4-1 base) 112) + (let ((t0-4 (the-as (inline-array qword) (-> s4-1 base))) + (a2-42 #x8000) + (a3-9 #x8000) + (a0-49 #x9000) + (a1-37 #x8d00) + ) + (set! (-> t0-4 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t0-4 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t0-4 2 vector4w) 128 128 128 128) + (set-vector! (-> t0-4 3 vector4w) 8 8 0 0) + (set-vector! (-> t0-4 4 vector4w) a2-42 a3-9 0 0) + (set-vector! (-> t0-4 5 vector4w) 8200 6664 0 0) + (set-vector! (-> t0-4 6 vector4w) a0-49 a1-37 0 0) + (&+! (-> s4-1 base) 112) + (let* ((t0-8 s4-1) + (t1-11 (the-as dma-packet (-> t0-8 base))) + ) + (set! (-> t1-11 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> t1-11 vif0) (new 'static 'vif-tag)) + (set! (-> t1-11 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> t0-8 base) (the-as pointer (&+ t1-11 16))) + ) + (let* ((t0-9 s4-1) + (t1-13 (the-as gs-gif-tag (-> t0-9 base))) + ) + (set! (-> t1-13 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> t1-13 regs) GIF_REGS_ALL_AD) + (set! (-> t0-9 base) (the-as pointer (&+ t1-13 16))) + ) + (let* ((t0-10 s4-1) + (t1-15 (-> t0-10 base)) + ) + (set! (-> (the-as (pointer gs-alpha) t1-15) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) t1-15) 1) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) t1-15) 2) + (new 'static 'gs-tex0 :tbp0 #x3300 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) t1-15) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer uint64) t1-15) 4) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) t1-15) 5) (gs-reg64 texflush)) + (set! (-> t0-10 base) (&+ t1-15 48)) + ) + (let ((t0-11 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> t0-11 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t0-11 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t0-11 2 vector4w) 128 128 128 80) + (set-vector! (-> t0-11 3 vector4w) 0 0 0 0) + (set-vector! (-> t0-11 4 vector4w) a2-42 a3-9 0 0) + (set-vector! (-> t0-11 5 vector4w) 2048 1664 0 0) + (set-vector! (-> t0-11 6 vector4w) a0-49 a1-37 0 0) + ) + ) + (&+! (-> s4-1 base) 112) + (let* ((a0-52 s4-1) + (a1-38 (the-as dma-packet (-> a0-52 base))) + ) + (set! (-> a1-38 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-38 vif0) (new 'static 'vif-tag)) + (set! (-> a1-38 vif1) (new 'static 'vif-tag :imm #x2 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-52 base) (the-as pointer (&+ a1-38 16))) + ) + (let* ((a0-53 s4-1) + (a1-40 (the-as gs-gif-tag (-> a0-53 base))) + ) + (set! (-> a1-40 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x1)) + (set! (-> a1-40 regs) GIF_REGS_ALL_AD) + (set! (-> a0-53 base) (the-as pointer (&+ a1-40 16))) + ) + (let* ((a0-54 s4-1) + (a1-42 (-> a0-54 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a1-42) 0) (new 'static 'gs-alpha)) + (set! (-> (the-as (pointer gs-reg64) a1-42) 1) (gs-reg64 alpha-1)) + (set! (-> a0-54 base) (&+ a1-42 16)) + ) + (let ((a0-57 (the int (+ 128.0 (* 32.0 f0-0)))) + (a1-46 (the int (- 128.0 (* 16.0 f0-0)))) + (a2-55 (the int (- 128.0 (* 96.0 f0-0)))) + ) + (when (or (!= (-> v1-0 filter x) 1.0) (!= (-> v1-0 filter y) 1.0) (!= (-> v1-0 filter z) 1.0)) + (set! a0-57 128) + (set! a1-46 128) + (set! a2-55 128) + ) + (let ((v1-57 3328) + (a3-16 6656) + ) + (dotimes (t0-12 16) + (let ((t1-22 (the-as (inline-array qword) (-> s4-1 base))) + (t3-0 (* (+ (* t0-12 32) 1792) 16)) + (t2-36 (* (+ (* (+ t0-12 1) 32) 1792) 16)) + ) + (let ((t5-0 (* (+ (* t0-12 16) 256) 16)) + (t4-5 (* (+ (* (+ t0-12 1) 16) 256) 16)) + ) + (set! (-> t1-22 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> t1-22 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> t1-22 2 vector4w) a0-57 a1-46 a2-55 128) + (set-vector! (-> t1-22 3 vector4w) (+ t5-0 8) (+ v1-57 24) 0 0) + (set-vector! (-> t1-22 4 vector4w) t3-0 #x7300 0 0) + (set-vector! (-> t1-22 5 vector4w) (+ t4-5 8) (+ a3-16 24) 0 0) + ) + (set-vector! (-> t1-22 6 vector4w) t2-36 #x8d00 0 0) + ) + (&+! (-> s4-1 base) 112) + ) + ) + (let* ((v1-60 s4-1) + (a3-17 (the-as dma-packet (-> v1-60 base))) + ) + (set! (-> a3-17 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> a3-17 vif0) (new 'static 'vif-tag)) + (set! (-> a3-17 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> v1-60 base) (the-as pointer (&+ a3-17 16))) + ) + (let* ((v1-61 s4-1) + (a3-19 (the-as gs-gif-tag (-> v1-61 base))) + ) + (set! (-> a3-19 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> a3-19 regs) GIF_REGS_ALL_AD) + (set! (-> v1-61 base) (the-as pointer (&+ a3-19 16))) + ) + (let* ((v1-62 s4-1) + (a3-21 (-> v1-62 base)) + ) + (set! (-> (the-as (pointer gs-alpha) a3-21) 0) (new 'static 'gs-alpha :b #x1 :d #x1)) + (set! (-> (the-as (pointer gs-reg64) a3-21) 1) (gs-reg64 alpha-1)) + (set! (-> (the-as (pointer gs-tex0) a3-21) 2) + (new 'static 'gs-tex0 :tbp0 #x4c0 :tbw #x8 :tw #x9 :th #x9 :tcc #x1) + ) + (set! (-> (the-as (pointer gs-reg64) a3-21) 3) (gs-reg64 tex0-1)) + (set! (-> (the-as (pointer uint64) a3-21) 4) (the-as uint 0)) + (set! (-> (the-as (pointer gs-reg64) a3-21) 5) (gs-reg64 texflush)) + (set! (-> v1-62 base) (&+ a3-21 48)) + ) + (let ((v1-63 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> v1-63 0 quad) (-> obj draw-tmpl2 dma-vif quad)) + (set! (-> v1-63 1 quad) (-> obj draw-tmpl2 quad 1)) + (set-vector! (-> v1-63 2 vector4w) a0-57 a1-46 a2-55 (the int (- 128.0 (* 48.0 f0-0)))) + (set-vector! (-> v1-63 3 vector4w) 0 24 0 0) + (set-vector! (-> v1-63 4 vector4w) #x7000 #x7300 0 0) + (set-vector! (-> v1-63 5 vector4w) 8192 6680 0 0) + (set-vector! (-> v1-63 6 vector4w) #x9000 #x8d00 0 0) + ) + ) + ) + (&+! (-> s4-1 base) 112) + (seek! + (-> *blit-displays-work* progress-interp) + (-> *blit-displays-work* progress-interp-dest) + (-> *blit-displays-work* progress-interp-speed) + ) + ) + (else + (let* ((a0-66 s4-1) + (a1-53 (the-as dma-packet (-> a0-66 base))) + ) + (set! (-> a1-53 dma) (new 'static 'dma-tag :qwc #x4 :id (dma-tag-id cnt))) + (set! (-> a1-53 vif0) (new 'static 'vif-tag)) + (set! (-> a1-53 vif1) (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd direct) :msk #x1)) + (set! (-> a0-66 base) (the-as pointer (&+ a1-53 16))) + ) + (let* ((a0-67 s4-1) + (a1-55 (the-as gs-gif-tag (-> a0-67 base))) + ) + (set! (-> a1-55 tag) (new 'static 'gif-tag64 :nloop #x1 :eop #x1 :nreg #x3)) + (set! (-> a1-55 regs) GIF_REGS_ALL_AD) + (set! (-> a0-67 base) (the-as pointer (&+ a1-55 16))) + ) + (let* ((a0-68 s4-1) + (a1-57 (-> a0-68 base)) + ) + (set! (-> (the-as (pointer gs-zbuf) a1-57) 0) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + (set! (-> (the-as (pointer gs-reg64) a1-57) 1) (gs-reg64 zbuf-1)) + (set! (-> (the-as (pointer gs-test) a1-57) 2) + (new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest always)) + ) + (set! (-> (the-as (pointer gs-reg64) a1-57) 3) (gs-reg64 test-1)) + (set! (-> (the-as (pointer gs-rgbaq) a1-57) 4) (new 'static 'gs-rgbaq + :q 1.0 + :a (the int (-> v1-0 current-fog erase-color w)) + :b (the int (-> v1-0 current-fog erase-color z)) + :g (the int (-> v1-0 current-fog erase-color y)) + :r (the int (-> v1-0 current-fog erase-color x)) + ) + ) + (set! (-> (the-as (pointer gs-reg64) a1-57) 5) (gs-reg64 rgbaq)) + (set! (-> a0-68 base) (&+ a1-57 48)) + ) + (let ((v1-78 (the-as (inline-array qword) (-> s4-1 base)))) + (set! (-> v1-78 0 quad) (-> obj sprite-tmpl dma-vif quad)) + (set! (-> v1-78 1 quad) (-> obj sprite-tmpl quad 1)) + ) + (&+! (-> s4-1 base) 32) + (let ((v1-81 (the-as (inline-array qword) (-> s4-1 base)))) + (set-vector! (-> v1-81 0 vector4w) #x7000 #x7300 0 0) + (set-vector! (-> v1-81 1 vector4w) #x9000 #x8d00 0 0) + ) + (&+! (-> s4-1 base) 32) + ) + ) + (let ((a3-35 (-> s4-1 base))) + (let ((v1-85 (the-as dma-packet (-> s4-1 base)))) + (set! (-> v1-85 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-85 vif0) (new 'static 'vif-tag)) + (set! (-> v1-85 vif1) (new 'static 'vif-tag)) + (set! (-> s4-1 base) (the-as pointer (&+ v1-85 16))) + ) + (dma-bucket-insert-tag + (-> *display* frames (-> *display* on-screen) bucket-group) + (bucket-id sky-draw) + gp-1 + (the-as (pointer dma-tag) a3-35) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) 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 64d337bc0a..5fb858ef8c 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 @@ -87,7 +87,7 @@ (func-id basic :offset 4) (init-func basic :offset-assert 8) (init-func-id basic :offset 8) - (tex basic :offset-assert 12) + (tex texture :offset-assert 12) (tex-name basic :offset-assert 16) (extra vector :inline :offset-assert 32) (color rgba :offset-assert 48) @@ -137,7 +137,7 @@ ;; definition of type texture-anim-array (deftype texture-anim-array (array) - ((array-data texture-anim :inline :dynamic :offset-assert 16) + ((array-data texture-anim :dynamic :offset-assert 16) ) :method-count-assert 11 :size-assert #x10 diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index c2b0096f78..b1ee112df1 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -163,6 +163,7 @@ "(method 16 level)", "unpack-comp-lzo", // asm mods "update-time-of-day", + "close-sky-buffer", // asm "i-hopefully-will-never-exist-dont-add-anything-after-me-please" ],