From 12fc118752e6122c0e8b8d3b2fb2af88caf2e65e Mon Sep 17 00:00:00 2001 From: water Date: Sat, 12 Mar 2022 17:46:12 -0500 Subject: [PATCH 1/6] first pass at ocean mid --- decompiler/VuDisasm/VuDisassembler.cpp | 25 +- game/CMakeLists.txt | 2 + .../opengl_renderer/ocean/OceanMid.cpp | 132 + .../graphics/opengl_renderer/ocean/OceanMid.h | 195 ++ .../opengl_renderer/ocean/OceanMidAndFar.cpp | 7 + .../opengl_renderer/ocean/OceanMidAndFar.h | 7 +- .../opengl_renderer/ocean/OceanMid_PS2.cpp | 2648 +++++++++++++++++ .../shaders/ocean_texture.frag | 3 +- goal_src/engine/gfx/ocean/ocean-mid.gc | 50 +- goal_src/engine/gfx/ocean/ocean.gc | 5 +- 10 files changed, 3058 insertions(+), 16 deletions(-) create mode 100644 game/graphics/opengl_renderer/ocean/OceanMid.cpp create mode 100644 game/graphics/opengl_renderer/ocean/OceanMid.h create mode 100644 game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp diff --git a/decompiler/VuDisasm/VuDisassembler.cpp b/decompiler/VuDisasm/VuDisassembler.cpp index b9880db429..00f062bac1 100644 --- a/decompiler/VuDisasm/VuDisassembler.cpp +++ b/decompiler/VuDisasm/VuDisassembler.cpp @@ -830,14 +830,19 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma vi_src(instr.src.at(1).to_string(m_label_names), mips2c_format)); case VuInstrK::IOR: if (instr.src.at(1).is_int_reg(0)) { - ASSERT(!instr.dst->is_int_reg(0)); - ASSERT(!instr.src.at(0).is_int_reg(0)); - if (mips2c_format) { - return fmt::format("vis[{}] = vis[{}];", instr.dst->to_string(m_label_names), - instr.src.at(0).to_string(m_label_names)); + fmt::print("instr: {}\n", to_string(instr)); + if (instr.src.at(0).is_int_reg(0) && instr.src.at(1).is_int_reg(0)) { + return fmt::format("vu.{} = 0;", instr.dst->to_string(m_label_names)); } else { - return fmt::format("vu.{} = vu.{};", instr.dst->to_string(m_label_names), - instr.src.at(0).to_string(m_label_names)); + ASSERT(!instr.dst->is_int_reg(0)); + ASSERT(!instr.src.at(0).is_int_reg(0)); + if (mips2c_format) { + return fmt::format("vis[{}] = vis[{}];", instr.dst->to_string(m_label_names), + instr.src.at(0).to_string(m_label_names)); + } else { + return fmt::format("vu.{} = vu.{};", instr.dst->to_string(m_label_names), + instr.src.at(0).to_string(m_label_names)); + } } } else { @@ -985,13 +990,17 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma return fmt::format("vu.{} = xtop();", instr.src.at(0).to_string(m_label_names)); default: unk++; + fmt::print("unknown 0 is {}\n", to_string(instr)); + return "ASSERT(false);"; //"???"; } unknown: unk++; - return "???"; + fmt::print("unknown 1 is {}\n", to_string(instr)); + + return "ASSERT(false);"; } std::string VuDisassembler::to_string(const VuInstruction& instr) const { diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 5350bd91e8..b235764ac4 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -84,6 +84,8 @@ set(RUNTIME_SOURCE graphics/opengl_renderer/foreground/Generic2_DMA.cpp graphics/opengl_renderer/foreground/Generic2_Build.cpp graphics/opengl_renderer/foreground/Generic2_OpenGL.cpp + graphics/opengl_renderer/ocean/OceanMid.cpp + graphics/opengl_renderer/ocean/OceanMid_PS2.cpp graphics/opengl_renderer/ocean/OceanMidAndFar.cpp graphics/opengl_renderer/ocean/OceanTexture.cpp graphics/opengl_renderer/ocean/OceanTexture_PC.cpp diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.cpp b/game/graphics/opengl_renderer/ocean/OceanMid.cpp new file mode 100644 index 0000000000..4149215a48 --- /dev/null +++ b/game/graphics/opengl_renderer/ocean/OceanMid.cpp @@ -0,0 +1,132 @@ +#include "OceanMid.h" + +static bool is_end_tag(const DmaTag& tag, const VifCode& v0, const VifCode& v1) { + return tag.qwc == 2 && tag.kind == DmaTag::Kind::CNT && v0.kind == VifCode::Kind::NOP && + v1.kind == VifCode::Kind::DIRECT; +} + +OceanMid::OceanMid() { + for (auto& x : m_vu_data) { + x.fill(0); + } + vu.vf25 = Vf(1, 1, 1, 1); +} + +void OceanMid::run(DmaFollower& dma, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + // first is setting base and offset + { + auto base_offset_tag = dma.read_and_advance(); + ASSERT(base_offset_tag.size_bytes == 0); + auto base = base_offset_tag.vifcode0(); + ASSERT(base.kind == VifCode::Kind::BASE); + ASSERT(base.immediate == VU1_INPUT_BUFFER_BASE); + auto offset = base_offset_tag.vifcode1(); + ASSERT(offset.kind == VifCode::Kind::OFFSET); + ASSERT(offset.immediate == VU1_INPUT_BUFFER_OFFSET); + } + + // next is constants + { + auto constants = dma.read_and_advance(); + ASSERT(constants.size_bytes == sizeof(Constants)); + ASSERT(constants.vifcode0().kind == VifCode::Kind::STCYCL); // for whatever reason they do this + auto unpack = constants.vifcode1(); + ASSERT(VifCodeUnpack(unpack).addr_qw == Vu1Data::CONSTANTS); + memcpy(&m_constants, constants.data, sizeof(Constants)); + memcpy(m_vu_data + Vu1Data::CONSTANTS, &m_constants, sizeof(Constants)); + } + + // next is call 0 + { + auto call0 = dma.read_and_advance(); + ASSERT(call0.vifcode0().kind == VifCode::Kind::STCYCL); + auto c = call0.vifcode1(); + ASSERT(c.kind == VifCode::Kind::MSCALF); + ASSERT(c.immediate == 0); + run_call0(); + } + + while (!is_end_tag(dma.current_tag(), dma.current_tag_vif0(), dma.current_tag_vif1())) { + auto data = dma.read_and_advance(); + auto v0 = data.vifcode0(); + auto v1 = data.vifcode1(); + if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && + v1.kind == VifCode::Kind::UNPACK_V4_32) { + auto up = VifCodeUnpack(v1); + ASSERT(up.use_tops_flag); + u16 addr = up.addr_qw + get_upload_buffer(); + ASSERT(addr + v1.num <= 1024); + memcpy(m_vu_data + addr, data.data, 16 * v1.num); + ASSERT(16 * v1.num == data.size_bytes); + } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && + v1.kind == VifCode::Kind::UNPACK_V4_8) { + auto up = VifCodeUnpack(v1); + ASSERT(up.use_tops_flag); + u16 addr = up.addr_qw + get_upload_buffer(); + ASSERT(addr + v1.num <= 1024); + + u32 temp[4]; + for (u32 i = 0; i < v1.num; i++) { + for (u32 j = 0; j < 4; j++) { + temp[j] = data.data[4 * i + j]; + } + memcpy(m_vu_data + addr + i, temp, 16); + } + + // TODO + } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x204 && + v1.kind == VifCode::Kind::UNPACK_V4_8) { + auto up = VifCodeUnpack(v1); + ASSERT(up.use_tops_flag); + u16 addr = up.addr_qw + get_upload_buffer(); + ASSERT(addr + v1.num <= 1024); + + u32 temp[4]; + for (u32 i = 0; i < v1.num; i++) { + for (u32 j = 0; j < 4; j++) { + temp[j] = data.data[4 * i + j]; + } + u32 addr_off = 4 * i / 2 + i % 2; + memcpy(m_vu_data + addr + addr_off, temp, 16); + } + + // TODO + } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && + v1.kind == VifCode::Kind::MSCALF) { + switch(v1.immediate) { + case 46: + run_call46_vu2c(render_state, prof, direct); + break; + case 73: + run_call73_vu2c(render_state, prof, direct); + break; + default: + fmt::print("unknown call: {}\n", v1.immediate); + } + // TODO + } else if (v0.kind == VifCode::Kind::MSCALF && v1.kind == VifCode::Kind::FLUSHA) { + switch(v0.immediate) { + case 41: + break; + default: + fmt::print("unknown call: {}\n", v0.immediate); + ASSERT(false); + } + + + // TODO + } + + else { + fmt::print("{} {}\n", data.vifcode0().print(), data.vifcode1().print()); + ASSERT(false); + } + } +} + +void OceanMid::run_call0() { + run_call0_vu2c(); +} diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.h b/game/graphics/opengl_renderer/ocean/OceanMid.h new file mode 100644 index 0000000000..95ea7b7620 --- /dev/null +++ b/game/graphics/opengl_renderer/ocean/OceanMid.h @@ -0,0 +1,195 @@ +#pragma once + +#include "game/graphics/opengl_renderer/BucketRenderer.h" +#include "game/graphics/opengl_renderer/DirectRenderer.h" +#include "game/common/vu.h" + +class OceanMid { + public: + OceanMid(); + void run(DmaFollower& dma, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + + private: + void run_call0(); + void run_call0_vu2c(); + void run_call46_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + + void run_call73_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void xgkick(u16 addr, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_L24_vu2c(); + void run_L30_vu2c(); + void run_L36_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_L41_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_L43_vu2c(); + + + bool m_buffer_toggle = false; + static constexpr int VU1_INPUT_BUFFER_BASE = 0; + static constexpr int VU1_INPUT_BUFFER_OFFSET = 0x76; + + u16 xtop() { + m_buffer_toggle = !m_buffer_toggle; + return get_vu_buffer(); + } + + u16 get_upload_buffer() { + if (m_buffer_toggle) { + return VU1_INPUT_BUFFER_OFFSET; + } else { + return VU1_INPUT_BUFFER_BASE; + } + } + + u16 get_vu_buffer() { + if (!m_buffer_toggle) { + return VU1_INPUT_BUFFER_OFFSET; + } else { + return VU1_INPUT_BUFFER_BASE; + } + } + + // (deftype ocean-mid-constants (structure) + struct Constants { + // ((hmge-scale vector :inline :offset-assert 0) + math::Vector4f hmge_scale; + // (inv-hmge-scale vector :inline :offset-assert 16) + math::Vector4f inv_hmge_scale; + // (hvdf-offset vector :inline :offset-assert 32) + math::Vector4f hvdf_offset; + // (fog vector :inline :offset-assert 48) + math::Vector4f fog; + // (constants vector :inline :offset-assert 64) + math::Vector4f constants; + // (constants2 vector :inline :offset-assert 80) + math::Vector4f constants2; + // (drw-fan gs-gif-tag :inline :offset-assert 96) ;; was qword + u8 drw_fan[16]; + // (env-fan gs-gif-tag :inline :offset-assert 112) ;; was qword + u8 env_fan[16]; + // (drw-adgif gs-gif-tag :inline :offset-assert 128);; was qword + AdGifData drw_adgif; + // (drw-texture adgif-shader :inline :offset-assert 144) + u8 drw_texture[16]; + // (drw-strip-0 gs-gif-tag :inline :offset-assert 224) ;; was qword + u8 drw_strip_0[16]; + // (drw-strip-1 gs-gif-tag :inline :offset-assert 240) ;; was qword + u8 drw_strip_1[16]; + // (env-adgif gs-gif-tag :inline :offset-assert 256) ;; was qword + u8 env_adgif[16]; + // (env-texture adgif-shader :inline :offset-assert 272) + AdGifData env_texture; + // (env-strip gs-gif-tag :inline :offset-assert 352) ;; was qword + u8 env_strip[16]; + // (env-color vector :inline :offset-assert 368) + math::Vector4f env_color; + // (index-table vector4w 8 :inline :offset-assert 384) + math::Vector index_table[8]; + // (pos0 vector :inline :offset-assert 512) + math::Vector4f pos0; + // (pos1 vector :inline :offset-assert 528) + math::Vector4f pos1; + // (pos2 vector :inline :offset-assert 544) + math::Vector4f pos2; + // (pos3 vector :inline :offset-assert 560) + math::Vector4f pos3; + // ) + // :method-count-assert 9 + // :size-assert #x240 + // :flag-assert #x900000240 + // ) + } m_constants; + static_assert(sizeof(Constants) == 0x240); + + enum Vu1Data { + IN_BUFFER_0 = VU1_INPUT_BUFFER_BASE, // 0 + IN_BUFFER_1 = VU1_INPUT_BUFFER_OFFSET, // 0x76 + + CONSTANTS = 0x2dd, + }; + + Vf m_vu_data[1024]; + + void sq_buffer(Mask mask, const Vf& val, u16 addr) { + ASSERT(addr < 1024); + for (int i = 0; i < 4; i++) { + if ((u64)mask & (1 << i)) { + m_vu_data[addr].data[i] = val[i]; + } + } + } + + void ilw_buffer(Mask mask, u16& dest, u16 addr) { + ASSERT(addr < 1024); + switch (mask) { + case Mask::x: + dest = m_vu_data[addr].x_as_u16(); + break; + case Mask::y: + dest = m_vu_data[addr].y_as_u16(); + break; + case Mask::z: + dest = m_vu_data[addr].z_as_u16(); + break; + case Mask::w: + dest = m_vu_data[addr].w_as_u16(); + break; + default: + ASSERT(false); + } + } + + void isw_buffer(Mask mask, u16 src, u16 addr) { + ASSERT(addr < 1024); + u32 val32 = src; + switch (mask) { + case Mask::x: + memcpy(&m_vu_data[addr].data[0], &val32, 4); + break; + case Mask::y: + memcpy(&m_vu_data[addr].data[1], &val32, 4); + break; + case Mask::z: + memcpy(&m_vu_data[addr].data[2], &val32, 4); + break; + case Mask::w: + memcpy(&m_vu_data[addr].data[3], &val32, 4); + break; + default: + ASSERT(false); + } + } + + void lq_buffer(Mask mask, Vf& dest, u16 addr) { + ASSERT(addr < 1024); + for (int i = 0; i < 4; i++) { + if ((u64)mask & (1 << i)) { + dest[i] = m_vu_data[addr].data[i]; + } + } + } + + struct Vu { + const Vf vf00; + Accumulator acc; + Vf vf01, vf02, vf03, vf04, vf05, vf06, vf07, vf08, vf09, vf10, vf11, vf12, vf13, vf14, vf15, + vf16, vf17, vf18, vf19, vf20, vf21, vf22, vf23, vf24, vf25, vf26, vf27, vf28, vf29, vf30, + vf31; + u16 vi01, vi02, vi03, vi04, vi05, vi06, vi07, vi08, vi09, vi10, vi11, vi12, vi13, vi14; + float Q, P; + Vu() : vf00(0, 0, 0, 1) {} + } vu; +}; diff --git a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp index 641e884e36..4edcbbc827 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp @@ -93,6 +93,13 @@ bool is_end_tag(const DmaTag& tag, const VifCode& v0, const VifCode& v1) { void OceanMidAndFar::handle_ocean_mid(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { + if (dma.current_tag_vifcode0().kind == VifCode::Kind::BASE) { + m_mid_renderer.run(dma, render_state, prof, m_direct); + } else { + // not drawing + return; + } + while (!is_end_tag(dma.current_tag(), dma.current_tag_vifcode0(), dma.current_tag_vifcode1())) { dma.read_and_advance(); } diff --git a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.h b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.h index e2e66cc896..81df49b644 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.h +++ b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.h @@ -4,10 +4,14 @@ #include "game/graphics/opengl_renderer/DirectRenderer.h" #include "game/graphics/opengl_renderer/opengl_utils.h" #include "game/graphics/opengl_renderer/ocean/OceanTexture.h" +#include "game/graphics/opengl_renderer/ocean/OceanMid.h" /*! * OceanMidAndFar is the handler for the first ocean bucket. - * + * This bucket runs three renderers: + * - ocean-texture (handled by the OceanTexture C++ class) + * - ocean-far (handled by this class, it's very simple) + * - ocean-mid (handled by the C++ OceanMid class) */ class OceanMidAndFar : public BucketRenderer { public: @@ -26,4 +30,5 @@ class OceanMidAndFar : public BucketRenderer { DirectRenderer m_direct; OceanTexture m_texture_renderer; + OceanMid m_mid_renderer; }; diff --git a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp new file mode 100644 index 0000000000..f610d79c17 --- /dev/null +++ b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp @@ -0,0 +1,2648 @@ +#include "OceanMid.h" +void fcand(u16& dest, u32 imm, u32 cf) { + dest = (cf & imm) ? 1 : 0; + // dest = cf & imm; // wrong +} + +void fcor(u16& dest, u32 imm, u32 cf) { + dest = (cf | imm) == imm ? 1 : 0; + // dest = cf | imm; +} +void OceanMid::run_call0_vu2c() { + bool bc; + // lq.xyzw vf01, 733(vi00) | nop 0 + lq_buffer(Mask::xyzw, vu.vf01, 733); + // lq.xyzw vf02, 735(vi00) | nop 1 + lq_buffer(Mask::xyzw, vu.vf02, 735); + // lq.xyzw vf03, 736(vi00) | nop 2 + lq_buffer(Mask::xyzw, vu.vf03, 736); + // lq.xyzw vf05, 737(vi00) | nop 3 + lq_buffer(Mask::xyzw, vu.vf05, 737); + // lq.xyzw vf06, 738(vi00) | nop 4 + lq_buffer(Mask::xyzw, vu.vf06, 738); + // iaddiu vi09, vi00, 0x14f | nop 5 + vu.vi09 = 0x14f; /* 335 */ + // iaddi vi01, vi00, 0x6 | nop 6 + vu.vi01 = 6; +L1: + // lq.xyzw vf20, 741(vi01) | nop 7 + lq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 741); + // lq.xyzw vf21, 749(vi01) | nop 8 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 749); + // sq.xyzw vf20, 335(vi01) | nop 9 + sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 335); + // sq.xyzw vf20, 457(vi01) | nop 10 + sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 457); + // sq.xyzw vf21, 396(vi01) | nop 11 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 396); + // sq.xyzw vf21, 518(vi01) | nop 12 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 518); + // BRANCH! + // ibgtz vi01, L1 | nop 13 + bc = ((s16)vu.vi01) > 0; + // iaddi vi01, vi01, -0x1 | nop 14 + vu.vi01 = vu.vi01 + -1; + if (bc) { + goto L1; + } + + // iaddi vi05, vi00, 0x0 | mul.xyzw vf16, vf00, vf00 15 + vu.vf16.mul(Mask::xyzw, vu.vf00, vu.vf00); + vu.vi05 = 0; + // iaddi vi07, vi00, 0x8 | nop 16 + vu.vi07 = 8; +L2: + // iaddi vi06, vi00, 0x8 | mul.x vf16, vf00, vf00 17 + vu.vf16.mul(Mask::x, vu.vf00, vu.vf00); + vu.vi06 = 8; +L3: + // sq.xyzw vf16, 236(vi05) | nop 18 + sq_buffer(Mask::xyzw, vu.vf16, vu.vi05 + 236); + // iaddi vi05, vi05, 0x1 | addw.x vf16, vf16, vf05 19 + vu.vf16.add(Mask::x, vu.vf16, vu.vf05.w()); + vu.vi05 = vu.vi05 + 1; + // BRANCH! + // ibgtz vi06, L3 | nop 20 + bc = ((s16)vu.vi06) > 0; + // iaddi vi06, vi06, -0x1 | nop 21 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L3; + } + + // BRANCH! + // ibgtz vi07, L2 | addw.z vf16, vf16, vf05 22 + vu.vf16.add(Mask::z, vu.vf16, vu.vf05.w()); + bc = ((s16)vu.vi07) > 0; + // iaddi vi07, vi07, -0x1 | nop 23 + vu.vi07 = vu.vi07 + -1; + if (bc) { + goto L2; + } + + // nop | sub.xyzw vf20, vf20, vf20 24 + vu.vf20.set_zero(); + // nop | sub.xyzw vf21, vf21, vf21 25 + vu.vf21.set_zero(); + // iaddi vi03, vi00, 0x0 | addw.z vf20, vf20, vf00 26 + vu.vf20.add(Mask::z, vu.vf20, vu.vf00.w()); + vu.vi03 = 0; + // iaddi vi06, vi00, 0x8 | addw.yz vf21, vf21, vf00 27 + vu.vf21.add(Mask::yz, vu.vf21, vu.vf00.w()); + vu.vi06 = 8; +L4: + // sq.xyzw vf20, 317(vi03) | nop 28 + sq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + // sq.xyzw vf21, 318(vi03) | addw.x vf20, vf20, vf00 29 + vu.vf20.add(Mask::x, vu.vf20, vu.vf00.w()); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); + // iaddi vi03, vi03, 0x2 | addw.x vf21, vf21, vf00 30 + vu.vf21.add(Mask::x, vu.vf21, vu.vf00.w()); + vu.vi03 = vu.vi03 + 2; + // BRANCH! + // ibgtz vi06, L4 | nop 31 + bc = ((s16)vu.vi06) > 0; + // iaddi vi06, vi06, -0x1 | nop 32 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L4; + } + + // lq.xyzw vf08, 756(vi00) | nop 33 + lq_buffer(Mask::xyzw, vu.vf08, 756); + // iaddi vi04, vi00, 0x8 | nop 34 + vu.vi04 = 8; + // iaddiu vi06, vi00, 0x11 | ftoi0.xyzw vf08, vf08 35 + vu.vf08.ftoi0(Mask::xyzw, vu.vf08); + vu.vi06 = 0x11; /* 17 */ +L5: + // sq.xyzw vf08, 396(vi04) | nop 36 + sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 396); + // sq.xyzw vf08, 518(vi04) | nop 37 + sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 518); + // iaddi vi04, vi04, 0x3 | nop 38 + vu.vi04 = vu.vi04 + 3; + // BRANCH! + // ibgtz vi06, L5 | nop 39 + bc = ((s16)vu.vi06) > 0; + // iaddi vi06, vi06, -0x1 | nop 40 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L5; + } + + // JUMP_41: + // nop | nop :e 41 + + // nop | nop 42 + + return; +} + +void OceanMid::run_call46_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc; +JUMP_46: + // xtop vi02 | nop 46 + vu.vi02 = xtop(); + // lq.xyzw vf07, 748(vi00) | nop 47 + lq_buffer(Mask::xyzw, vu.vf07, 748); + // lq.xyzw vf12, 4(vi02) | nop 48 + lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); + // lq.xyzw vf13, 5(vi02) | nop 49 + lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); + // lq.xyzw vf14, 6(vi02) | nop 50 + lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); + // lq.xyzw vf15, 7(vi02) | nop 51 + lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); + // sq.xyzw vf07, 341(vi00) | nop 52 + sq_buffer(Mask::xyzw, vu.vf07, 341); + // sq.xyzw vf07, 463(vi00) | nop 53 + sq_buffer(Mask::xyzw, vu.vf07, 463); + // iaddi vi07, vi00, 0x7 | nop 54 + vu.vi07 = 7; + // lq.xyzw vf04, 116(vi02) | nop 55 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 116); +L9: + // iaddi vi01, vi07, -0x4 | nop 56 + vu.vi01 = vu.vi07 + -4; + // mtir vi10, vf04.x | nop 57 + vu.vi10 = vu.vf04.x_as_u16(); + // iaddiu vi11, vi00, 0xff | nop 58 + vu.vi11 = 0xff; /* 255 */ + // BRANCH! + // ibne vi00, vi01, L10 | nop 59 + bc = (vu.vi01 != 0); + // mr32.xyzw vf04, vf04 | nop 60 + vu.vf04.mr32(Mask::xyzw, vu.vf04); + if (bc) { + goto L10; + } + + // lq.xyzw vf04, 117(vi02) | nop 61 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 117); +L10: + // BRANCH! + // ibeq vi11, vi10, L11 | nop 62 + bc = (vu.vi11 == vu.vi10); + // iaddi vi08, vi09, 0x7 | nop 63 + vu.vi08 = vu.vi09 + 7; + if (bc) { + goto L11; + } + + // BRANCH! + // bal vi15, L24 | nop 64 + // ASSERT(false); + run_L24_vu2c(); + // nop | nop 65 + + // iaddiu vi01, vi00, 0x318 | nop 66 + vu.vi01 = 0x318; /* 792 */ + // xgkick vi09 | nop 67 + xgkick(vu.vi09, render_state, prof, direct); + // isub vi09, vi01, vi09 | nop 68 + vu.vi09 = vu.vi01 - vu.vi09; +L11: + // BRANCH! + // ibgtz vi07, L9 | nop 69 + bc = ((s16)vu.vi07) > 0; + // iaddi vi07, vi07, -0x1 | nop 70 + vu.vi07 = vu.vi07 + -1; + if (bc) { + goto L9; + } + + // nop | nop :e 71 + + // nop | nop 72 + + return; +} + +namespace { +u32 clip(const Vf& vector, float val, u32 old_clip) { + u32 result = (old_clip << 6); + float plus = std::abs(val); + float minus = -plus; + + if (vector.x() > plus) { + result |= 0b1; + } + if (vector.x() < minus) { + result |= 0b10; + } + + if (vector.y() > plus) { + result |= 0b100; + } + if (vector.y() < minus) { + result |= 0b1000; + } + + if (vector.z() > plus) { + result |= 0b10000; + } + if (vector.z() < minus) { + result |= 0b100000; + } + return result & 0xffffff; // only 24 bits +} +} // namespace + +void OceanMid::run_L24_vu2c() { + bool bc; + u32 cf = 0; + +L24: + // ilw.x vi05, 757(vi07) | nop 391 + ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); + // ilw.y vi04, 757(vi07) | nop 392 + ilw_buffer(Mask::y, vu.vi04, vu.vi07 + 757); + // iaddi vi03, vi00, 0x0 | nop 393 + vu.vi03 = 0; + // iadd vi04, vi04, vi02 | nop 394 + vu.vi04 = vu.vi04 + vu.vi02; + // iaddi vi06, vi00, 0x8 | nop 395 + vu.vi06 = 8; + // lq.xyzw vf28, 236(vi05) | nop 396 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // lq.xyzw vf29, 245(vi05) | mulax.xyzw ACC, vf12, vf28 397 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // iaddi vi05, vi05, 0x1 | madday.xyzw ACC, vf13, vf28 398 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + vu.vi05 = vu.vi05 + 1; + // fcset 0x0 | maddaz.xyzw ACC, vf14, vf28 399 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + cf = 0; + // nop | maddw.xyzw vf30, vf15, vf00 400 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + // div Q, vf03.x, vf30.w | mulax.xyzw ACC, vf12, vf29 401 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); + vu.Q = vu.vf03.x() / vu.vf30.w(); + // lq.xyzw vf28, 236(vi05) | madday.xyzw ACC, vf13, vf29 402 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // lq.xyzw vf20, 317(vi03) | maddaz.xyzw ACC, vf14, vf29 403 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); + lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + // lq.xyzw vf22, 8(vi04) | maddw.xyzw vf31, vf15, vf00 404 + vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); + // nop | mul.xyzw vf18, vf30, vf01 405 + vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); + // waitq | mulaw.w ACC, vf30, vf00 406 + vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); + // nop | mula.xyz ACC, vf30, Q 407 + vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); + // nop | maddw.xyzw vf16, vf02, vf00 408 + vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); + // nop | clipw.xyz vf18, vf18 409 + cf = clip(vu.vf18, vu.vf18.w(), cf); + // nop | mul.xyzw vf19, vf31, vf01 410 + vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); + // div Q, vf03.x, vf31.w | mul.xyzw vf20, vf20, Q 411 + vu.vf20.mul(Mask::xyzw, vu.vf20, vu.Q); + vu.Q = vu.vf03.x() / vu.vf31.w(); + // nop | mulax.xyzw ACC, vf12, vf28 412 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + // nop | madday.xyzw ACC, vf13, vf28 413 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + // iaddi vi13, vi00, 0x0 | clipw.xyz vf19, vf19 414 + cf = clip(vu.vf19, vu.vf19.w(), cf); + vu.vi13 = 0; + // iaddi vi12, vi00, 0x1 | maxy.w vf16, vf16, vf03 415 + vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); + vu.vi12 = 1; + // lq.xyzw vf29, 245(vi05) | maddaz.xyzw ACC, vf14, vf28 416 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // iaddi vi01, vi00, 0x0 | nop 417 + vu.vi01 = 0; + // BRANCH! + // b L27 | maddw.xyzw vf30, vf15, vf00 418 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + bc = true; + // iaddi vi05, vi05, 0x1 | miniz.w vf16, vf16, vf03 419 + vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); + vu.vi05 = vu.vi05 + 1; + if (bc) { + goto L27; + } + +L25: + // iand vi13, vi10, vi12 | nop 420 + vu.vi13 = vu.vi10 & vu.vi12; + // BRANCH! + // ibeq vi00, vi01, L26 | mulaw.w ACC, vf30, vf00 421 + vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); + bc = (vu.vi01 == 0); + // lq.xyzw vf20, 317(vi03) | mula.xyz ACC, vf30, Q 422 + vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); + lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + if (bc) { + goto L26; + } + + // nop | addw.w vf17, vf17, vf03 423 + vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); +L26: + // lq.xyzw vf22, 8(vi04) | maddw.xyzw vf16, vf02, vf00 424 + vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); + // fcand vi01, 0x3ffff | mul.xyzw vf19, vf31, vf01 425 + vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); + // vu.vi01 = cf & 0x3ffff; + fcand(vu.vi01, 0x3ffff, cf); + + // div Q, vf03.x, vf31.w | mul.xyzw vf20, vf20, Q 426 + vu.vf20.mul(Mask::xyzw, vu.vf20, vu.Q); + vu.Q = vu.vf03.x() / vu.vf31.w(); + // ior vi01, vi01, vi13 | ftoi4.xyzw vf17, vf17 427 + vu.vf17.ftoi4(Mask::xyzw, vu.vf17); + vu.vi01 |= vu.vi13; + // iadd vi12, vi12, vi12 | maxy.w vf16, vf16, vf03 428 + vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); + vu.vi12 = vu.vi12 + vu.vi12; + // sq.xyzw vf21, 3(vi08) | mulax.xyzw ACC, vf12, vf28 429 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + // sq.xyzw vf23, 4(vi08) | madday.xyzw ACC, vf13, vf28 430 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf17, 5(vi08) | clipw.xyz vf19, vf19 431 + cf = clip(vu.vf19, vu.vf19.w(), cf); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + // lq.xyzw vf29, 245(vi05) | miniz.w vf16, vf16, vf03 432 + vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // iaddi vi08, vi08, 0x6 | maddaz.xyzw ACC, vf14, vf28 433 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + vu.vi08 = vu.vi08 + 6; + // iaddi vi05, vi05, 0x1 | maddw.xyzw vf30, vf15, vf00 434 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + vu.vi05 = vu.vi05 + 1; +L27: + // BRANCH! + // ibeq vi00, vi01, L28 | mulaw.w ACC, vf31, vf00 435 + vu.acc.mula(Mask::w, vu.vf31, vu.vf00.w()); + bc = (vu.vi01 == 0); + // lq.xyzw vf21, 318(vi03) | mula.xyz ACC, vf31, Q 436 + vu.acc.mula(Mask::xyz, vu.vf31, vu.Q); + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); + if (bc) { + goto L28; + } + + // nop | addw.w vf16, vf16, vf03 437 + vu.vf16.add(Mask::w, vu.vf16, vu.vf03.w()); +L28: + // lq.xyzw vf23, 20(vi04) | maddw.xyzw vf17, vf02, vf00 438 + vu.acc.madd(Mask::xyzw, vu.vf17, vu.vf02, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 20); + // fcand vi01, 0x3ffff | mul.xyzw vf18, vf30, vf01 439 + vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); + // vu.vi01 = cf & 0x3ffff; + fcand(vu.vi01, 0x3ffff, cf); + + // div Q, vf03.x, vf30.w | mul.xyzw vf21, vf21, Q 440 + vu.vf21.mul(Mask::xyzw, vu.vf21, vu.Q); + vu.Q = vu.vf03.x() / vu.vf30.w(); + // iaddi vi03, vi03, 0x2 | ftoi4.xyzw vf16, vf16 441 + vu.vf16.ftoi4(Mask::xyzw, vu.vf16); + vu.vi03 = vu.vi03 + 2; + // ior vi01, vi01, vi13 | nop 442 + vu.vi01 |= vu.vi13; + // iaddi vi04, vi04, 0x1 | maxy.w vf17, vf17, vf03 443 + vu.vf17.max(Mask::w, vu.vf17, vu.vf03.y()); + vu.vi04 = vu.vi04 + 1; + // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf12, vf29 444 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf13, vf29 445 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf16, 2(vi08) | clipw.xyz vf18, vf18 446 + cf = clip(vu.vf18, vu.vf18.w(), cf); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); + // lq.xyzw vf28, 236(vi05) | miniz.w vf17, vf17, vf03 447 + vu.vf17.mini(Mask::w, vu.vf17, vu.vf03.z()); + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // BRANCH! + // ibgtz vi06, L25 | maddaz.xyzw ACC, vf14, vf29 448 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); + bc = ((s16)vu.vi06) > 0; + // iaddi vi06, vi06, -0x1 | maddw.xyzw vf31, vf15, vf00 449 + vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L25; + } + + // BRANCH! + // ibeq vi00, vi01, L29 | nop 450 + bc = (vu.vi01 == 0); + // nop | nop 451 + + if (bc) { + goto L29; + } + + // nop | addw.w vf17, vf17, vf03 452 + vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); +L29: + // nop | ftoi4.xyzw vf17, vf17 453 + vu.vf17.ftoi4(Mask::xyzw, vu.vf17); + // sq.xyzw vf21, 3(vi08) | nop 454 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + // fmt::print("maybe tex: {}\n", vu.vf21.print()); + // sq.xyzw vf23, 4(vi08) | nop 455 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf17, 5(vi08) | nop 456 + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + // jr vi15 | nop 457 + // nop | nop 458 +} + +void OceanMid::xgkick(u16 addr, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + direct.render_gif((const u8*)&m_vu_data[addr], UINT32_MAX, render_state, prof); +} + +void OceanMid::run_call73_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + + bool bc; +JUMP_73: + // xtop vi02 | nop 73 + vu.vi02 = xtop(); + // lq.xyzw vf07, 747(vi00) | nop 74 + lq_buffer(Mask::xyzw, vu.vf07, 747); + // lq.xyzw vf08, 0(vi02) | nop 75 + lq_buffer(Mask::xyzw, vu.vf08, vu.vi02); + // lq.xyzw vf09, 1(vi02) | nop 76 + lq_buffer(Mask::xyzw, vu.vf09, vu.vi02 + 1); + // lq.xyzw vf10, 2(vi02) | nop 77 + lq_buffer(Mask::xyzw, vu.vf10, vu.vi02 + 2); + // lq.xyzw vf11, 3(vi02) | nop 78 + lq_buffer(Mask::xyzw, vu.vf11, vu.vi02 + 3); + // lq.xyzw vf12, 4(vi02) | nop 79 + lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); + // lq.xyzw vf13, 5(vi02) | nop 80 + lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); + // lq.xyzw vf14, 6(vi02) | nop 81 + lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); + // lq.xyzw vf15, 7(vi02) | nop 82 + lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); + // sq.xyzw vf07, 341(vi00) | nop 83 + sq_buffer(Mask::xyzw, vu.vf07, 341); + // sq.xyzw vf07, 463(vi00) | nop 84 + sq_buffer(Mask::xyzw, vu.vf07, 463); + // iaddi vi07, vi00, 0x7 | nop 85 + vu.vi07 = 7; + // lq.xyzw vf04, 116(vi02) | nop 86 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 116); +L13: + // iaddi vi01, vi07, -0x4 | nop 87 + vu.vi01 = vu.vi07 + -4; + // mtir vi10, vf04.x | nop 88 + vu.vi10 = vu.vf04.x_as_u16(); + // iaddiu vi11, vi00, 0xff | nop 89 + vu.vi11 = 0xff; /* 255 */ + // BRANCH! + // ibne vi00, vi01, L14 | nop 90 + bc = (vu.vi01 != 0); + // mr32.xyzw vf04, vf04 | nop 91 + vu.vf04.mr32(Mask::xyzw, vu.vf04); + if (bc) { + goto L14; + } + + // lq.xyzw vf04, 117(vi02) | nop 92 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 117); +L14: + // BRANCH! + // ibeq vi11, vi10, L15 | nop 93 + bc = (vu.vi11 == vu.vi10); + // iaddi vi08, vi09, 0x7 | nop 94 + vu.vi08 = vu.vi09 + 7; + if (bc) { + goto L15; + } + + // BRANCH! + // bal vi15, L30 | nop 95 + // nop | nop 96 + + run_L30_vu2c(); + + // iaddiu vi01, vi00, 0x318 | nop 97 + vu.vi01 = 0x318; /* 792 */ + // xgkick vi09 | nop 98 + xgkick(vu.vi09, render_state, prof, direct); + // BRANCH! + // ibeq vi00, vi14, L15 | nop 99 + bc = (vu.vi14 == 0); + // isub vi09, vi01, vi09 | nop 100 + vu.vi09 = vu.vi01 - vu.vi09; + if (bc) { + goto L15; + } + + // BRANCH! + // bal vi15, L36 | nop 101 + // nop | nop 102 + + // if (bc) { goto L36; } + run_L36_vu2c(render_state, prof, direct); + +L15: + // BRANCH! + // ibgtz vi07, L13 | nop 103 + bc = ((s16)vu.vi07) > 0; + // iaddi vi07, vi07, -0x1 | nop 104 + vu.vi07 = vu.vi07 + -1; + if (bc) { + goto L13; + } + + // nop | nop :e 105 + + // nop | nop 106 +} + +static inline REALLY_INLINE float erleng(const Vf& in) { + float len = in.x() * in.x() + in.y() * in.y() + in.z() * in.z(); + float res = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(len))); + return res; +} + +void OceanMid::run_L30_vu2c() { + u32 cf = 0; + bool bc; +L30: + // ilw.x vi05, 757(vi07) | nop 459 + ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); + // ilw.y vi04, 757(vi07) | nop 460 + ilw_buffer(Mask::y, vu.vi04, vu.vi07 + 757); + // iaddi vi03, vi00, 0x0 | nop 461 + vu.vi03 = 0; + // iadd vi04, vi04, vi02 | nop 462 + vu.vi04 = vu.vi04 + vu.vi02; + // iaddi vi06, vi00, 0x8 | nop 463 + vu.vi06 = 8; + // lq.xyzw vf28, 236(vi05) | nop 464 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // lq.xyzw vf29, 245(vi05) | mulax.xyzw ACC, vf12, vf28 465 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // iaddi vi05, vi05, 0x1 | madday.xyzw ACC, vf13, vf28 466 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + vu.vi05 = vu.vi05 + 1; + // fcset 0x0 | maddaz.xyzw ACC, vf14, vf28 467 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + cf = 0; + // nop | maddw.xyzw vf30, vf15, vf00 468 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + // nop | mulax.xyzw ACC, vf08, vf28 469 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + // nop | madday.xyzw ACC, vf09, vf28 470 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf10, vf28 471 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + // nop | maddw.xyzw vf26, vf11, vf00 472 + vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf11, vu.vf00.w()); + // lq.xyzw vf20, 317(vi03) | mulax.xyzw ACC, vf12, vf29 473 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); + lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + // lq.xyzw vf22, 8(vi04) | madday.xyzw ACC, vf13, vf29 474 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); + // div Q, vf03.x, vf30.w | maddaz.xyzw ACC, vf14, vf29 475 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); + vu.Q = vu.vf03.x() / vu.vf30.w(); + // erleng.xyz P, vf26 | maddw.xyzw vf31, vf15, vf00 476 + vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); + vu.P = erleng(vu.vf26); /* TODO erleng */ + // nop | mulax.xyzw ACC, vf08, vf29 477 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); + // nop | madday.xyzw ACC, vf09, vf29 478 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); + // lq.xyzw vf28, 236(vi05) | maddaz.xyzw ACC, vf10, vf29 479 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // lq.xyzw vf29, 245(vi05) | maddw.xyzw vf27, vf11, vf00 480 + vu.acc.madd(Mask::xyzw, vu.vf27, vu.vf11, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // nop | mul.xyzw vf18, vf30, vf01 481 + vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); + // nop | mul.xyzw vf19, vf31, vf01 482 + vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); + // nop | mulaw.w ACC, vf30, vf00 483 + vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); + // nop | mula.xyz ACC, vf30, Q 484 + vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); + // nop | maddw.xyzw vf16, vf02, vf00 485 + vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); + // div Q, vf03.x, vf31.w | mul.xyzw vf20, vf20, Q 486 + vu.vf20.mul(Mask::xyzw, vu.vf20, vu.Q); + vu.Q = vu.vf03.x() / vu.vf31.w(); + // nop | addz.y vf26, vf00, vf26 487 + vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); + // waitp | maxy.w vf16, vf16, vf03 488 + vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); + // ASSERT(false); + // mfp.w vf26, P | mulax.xyzw ACC, vf12, vf28 489 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + vu.vf26.mfp(Mask::w, vu.P); + // erleng.xyz P, vf27 | madday.xyzw ACC, vf13, vf28 490 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + vu.P = erleng(vu.vf27); /* TODO erleng */ + // iaddi vi12, vi00, 0x1 | maddaz.xyzw ACC, vf14, vf28 491 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + vu.vi12 = 1; + // iaddi vi01, vi00, 0x0 | maddw.xyzw vf30, vf15, vf00 492 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + vu.vi01 = 0; + // iaddi vi13, vi00, 0x0 | mulw.xy vf24, vf26, vf26 493 + vu.vf24.mul(Mask::xy, vu.vf26, vu.vf26.w()); + vu.vi13 = 0; + // iaddi vi11, vi00, 0x0 | miniz.w vf16, vf16, vf03 494 + vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); + vu.vi11 = 0; + // iaddi vi14, vi00, 0x0 | addz.y vf27, vf00, vf27 495 + vu.vf27.add(Mask::y, vu.vf00, vu.vf27.z()); + vu.vi14 = 0; + // nop | mulax.xyzw ACC, vf08, vf28 496 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + // nop | madday.xyzw ACC, vf09, vf28 497 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf10, vf28 498 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + // nop | maddw.xyzw vf26, vf11, vf00 499 + vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf11, vu.vf00.w()); + // nop | clipw.xyz vf18, vf18 500 + // ASSERT(false); + cf = clip(vu.vf18, vu.vf18.w(), cf); + // waitp | clipw.xyz vf19, vf19 501 + // ASSERT(false); + cf = clip(vu.vf19, vu.vf19.w(), cf); + // ASSERT(false); + // BRANCH! + // b L33 | mula.xyzw ACC, vf24, vf05 502 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); + bc = true; + // iaddi vi05, vi05, 0x1 | maddw.xyzw vf24, vf06, vf00 503 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); + vu.vi05 = vu.vi05 + 1; + if (bc) { + goto L33; + } + +L31: + // BRANCH! + // ibeq vi00, vi01, L32 | mulaw.w ACC, vf30, vf00 504 + vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); + bc = (vu.vi01 == 0); + // lq.xyzw vf20, 317(vi03) | mula.xyz ACC, vf30, Q 505 + // ASSERT(false); + vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); + lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + if (bc) { + goto L32; + } + + // BRANCH! + // ibne vi00, vi13, L32 | addw.w vf17, vf17, vf03 506 + vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); + bc = (vu.vi13 != 0); + // fcor vi01, 0x7df7ff | nop 507 + // ASSERT(false); + fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { + goto L32; + } + + // isw.x vi12, 775(vi14) | nop 508 + isw_buffer(Mask::x, vu.vi12, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L32 | nop 509 + bc = (vu.vi01 != 0); + // fcor vi01, 0xdf7dff | nop 510 + // ASSERT(false); + fcor(vu.vi01, 0xdf7dff, cf); + if (bc) { + goto L32; + } + + // isw.y vi05, 775(vi14) | nop 511 + isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L32 | nop 512 + bc = (vu.vi01 != 0); + // fcor vi01, 0xefbeff | nop 513 + // ASSERT(false); + fcor(vu.vi01, 0xefbeff, cf); + if (bc) { + goto L32; + } + + // ilw.z vi11, 757(vi07) | nop 514 + ilw_buffer(Mask::z, vu.vi11, vu.vi07 + 757); + // BRANCH! + // ibne vi00, vi01, L32 | nop 515 + bc = (vu.vi01 != 0); + // fcor vi01, 0xf7df7f | nop 516 + // ASSERT(false); + fcor(vu.vi01, 0xf7df7f, cf); + + if (bc) { + goto L32; + } + + // isw.z vi04, 775(vi14) | nop 517 + isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L32 | nop 518 + bc = (vu.vi01 != 0); + // fcor vi01, 0xfbefbf | nop 519 + // ASSERT(false); + fcor(vu.vi01, 0xfbefbf, cf); + + if (bc) { + goto L32; + } + + // isub vi11, vi05, vi11 | nop 520 + vu.vi11 = vu.vi05 - vu.vi11; + // BRANCH! + // ibne vi00, vi01, L32 | nop 521 + bc = (vu.vi01 != 0); + // nop | nop 522 + + if (bc) { + goto L32; + } + + // BRANCH! + // ibltz vi11, L32 | nop 523 + bc = ((s16)vu.vi11) < 0; + // nop | nop 524 + + if (bc) { + goto L32; + } + + // iaddi vi14, vi14, 0x1 | nop 525 + vu.vi14 = vu.vi14 + 1; +L32: + // lq.xyzw vf22, 8(vi04) | maddw.xyzw vf16, vf02, vf00 526 + vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); + // div Q, vf03.x, vf31.w | mul.xyzw vf20, vf20, Q 527 + vu.vf20.mul(Mask::xyzw, vu.vf20, vu.Q); + vu.Q = vu.vf03.x() / vu.vf31.w(); + // fcand vi01, 0x3ffff | mul.xyzw vf19, vf31, vf01 528 + vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); + // ASSERT(false); + // vu.vi01 = cf & 0x3ffff; + fcand(vu.vi01, 0x3ffff, cf); + + // waitp | ftoi4.xyzw vf17, vf17 529 + vu.vf17.ftoi4(Mask::xyzw, vu.vf17); + // ASSERT(false); + // mfp.w vf26, P | maxy.w vf16, vf16, vf03 530 + vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); + vu.vf26.mfp(Mask::w, vu.P); + // erleng.xyz P, vf27 | clipw.xyz vf19, vf19 531 + // ASSERT(false); + cf = clip(vu.vf19, vu.vf19.w(), cf); + vu.P = erleng(vu.vf27); /* TODO erleng */ + // iand vi13, vi10, vi12 | addz.y vf27, vf00, vf27 532 + vu.vf27.add(Mask::y, vu.vf00, vu.vf27.z()); + vu.vi13 = vu.vi10 & vu.vi12; + // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 533 + vu.vf25.z() = 1; // HACK + vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); // NaN's on input to here + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + // sq.xyzw vf23, 4(vi08) | mulw.xy vf24, vf26, vf26 534 + vu.vf24.mul(Mask::xy, vu.vf26, vu.vf26.w()); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf17, 5(vi08) | mulax.xyzw ACC, vf12, vf28 535 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + // sq.xyzw vf17, 66(vi08) | madday.xyzw ACC, vf13, vf28 536 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); + // sq.xyzw vf25, 64(vi08) | maddaz.xyzw ACC, vf14, vf28 537 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); + // iaddi vi08, vi08, 0x6 | maddw.xyzw vf30, vf15, vf00 538 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + vu.vi08 = vu.vi08 + 6; + // iadd vi12, vi12, vi12 | mulax.xyzw ACC, vf08, vf28 539 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + vu.vi12 = vu.vi12 + vu.vi12; + // ior vi01, vi01, vi13 | madday.xyzw ACC, vf09, vf28 540 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + // ASSERT(false); + vu.vi01 |= vu.vi13; + // nop | maddaz.xyzw ACC, vf10, vf28 541 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + // nop | maddw.xyzw vf26, vf11, vf00 542 + vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf11, vu.vf00.w()); + // lq.xyzw vf29, 245(vi05) | miniz.w vf16, vf16, vf03 543 + vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); + // iaddi vi05, vi05, 0x1 | mula.xyzw ACC, vf24, vf05 544 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); + vu.vi05 = vu.vi05 + 1; + // nop | maddw.xyzw vf24, vf06, vf00 545 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); +L33: + // BRANCH! + // ibeq vi00, vi01, L34 | mulaw.w ACC, vf31, vf00 546 + vu.acc.mula(Mask::w, vu.vf31, vu.vf00.w()); + bc = (vu.vi01 == 0); + // lq.xyzw vf21, 318(vi03) | mula.xyz ACC, vf31, Q 547 + // ASSERT(false); + vu.acc.mula(Mask::xyz, vu.vf31, vu.Q); + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); + if (bc) { + goto L34; + } + + // BRANCH! + // ibne vi00, vi13, L34 | addw.w vf16, vf16, vf03 548 + vu.vf16.add(Mask::w, vu.vf16, vu.vf03.w()); + bc = (vu.vi13 != 0); + // fcor vi01, 0x7df7ff | nop 549 + // ASSERT(false); + fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { + goto L34; + } + + // isw.x vi00, 775(vi14) | nop 550 + isw_buffer(Mask::x, 0, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L34 | nop 551 + bc = (vu.vi01 != 0); + // fcor vi01, 0xdf7dff | nop 552 + // ASSERT(false); + fcor(vu.vi01, 0xdf7dff, cf); + + if (bc) { + goto L34; + } + + // isw.y vi05, 775(vi14) | nop 553 + isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L34 | nop 554 + bc = (vu.vi01 != 0); + // fcor vi01, 0xefbeff | nop 555 + // ASSERT(false); + fcor(vu.vi01, 0xefbeff, cf); + + if (bc) { + goto L34; + } + + // isw.z vi04, 775(vi14) | nop 556 + isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L34 | nop 557 + bc = (vu.vi01 != 0); + // fcor vi01, 0xf7df7f | nop 558 + // ASSERT(false); + fcor(vu.vi01, 0xf7df7f, cf); + + if (bc) { + goto L34; + } + + // nop | nop 559 + + // BRANCH! + // ibne vi00, vi01, L34 | nop 560 + bc = (vu.vi01 != 0); + // fcor vi01, 0xfbefbf | nop 561 + // ASSERT(false); + fcor(vu.vi01, 0xfbefbf, cf); + + if (bc) { + goto L34; + } + + // nop | nop 562 + + // BRANCH! + // ibne vi00, vi01, L34 | nop 563 + bc = (vu.vi01 != 0); + // nop | nop 564 + + if (bc) { + goto L34; + } + + // iaddi vi14, vi14, 0x1 | nop 565 + vu.vi14 = vu.vi14 + 1; +L34: + // lq.xyzw vf23, 20(vi04) | maddw.xyzw vf17, vf02, vf00 566 + vu.acc.madd(Mask::xyzw, vu.vf17, vu.vf02, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 20); + // div Q, vf03.x, vf30.w | mul.xyzw vf21, vf21, Q 567 + vu.vf21.mul(Mask::xyzw, vu.vf21, vu.Q); + vu.Q = vu.vf03.x() / vu.vf30.w(); + // fcand vi01, 0x3ffff | mul.xyzw vf18, vf30, vf01 568 + vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); + // ASSERT(false); + // vu.vi01 = cf & 0x3ffff; + fcand(vu.vi01, 0x3ffff, cf); + + // waitp | ftoi4.xyzw vf16, vf16 569 + vu.vf16.ftoi4(Mask::xyzw, vu.vf16); + // ASSERT(false); + // mfp.w vf27, P | maxy.w vf17, vf17, vf03 570 + vu.vf17.max(Mask::w, vu.vf17, vu.vf03.y()); + vu.vf27.mfp(Mask::w, vu.P); + // erleng.xyz P, vf26 | clipw.xyz vf18, vf18 571 + // ASSERT(false); + cf = clip(vu.vf18, vu.vf18.w(), cf); + vu.P = erleng(vu.vf26); /* TODO erleng */ + // nop | addz.y vf26, vf00, vf26 572 + vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); + // sq.xyzw vf20, 0(vi08) | mulz.xyzw vf24, vf24, vf20 573 + vu.vf24.z() = 1.; // HACK + vu.vf24.mul(Mask::xyzw, vu.vf24, vu.vf20.z()); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf22, 1(vi08) | mulw.xy vf25, vf27, vf27 574 + vu.vf25.mul(Mask::xy, vu.vf27, vu.vf27.w()); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf16, 2(vi08) | mulax.xyzw ACC, vf12, vf29 575 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); + // sq.xyzw vf16, 63(vi08) | madday.xyzw ACC, vf13, vf29 576 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 63); + // sq.xyzw vf24, 61(vi08) | maddaz.xyzw ACC, vf14, vf29 577 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 61); + // iaddi vi04, vi04, 0x1 | maddw.xyzw vf31, vf15, vf00 578 + vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); + vu.vi04 = vu.vi04 + 1; + // iaddi vi03, vi03, 0x2 | mulax.xyzw ACC, vf08, vf29 579 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); + vu.vi03 = vu.vi03 + 2; + // ior vi01, vi01, vi13 | madday.xyzw ACC, vf09, vf29 580 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); + // ASSERT(false); + vu.vi01 |= vu.vi13; + // nop | maddaz.xyzw ACC, vf10, vf29 581 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); + // nop | maddw.xyzw vf27, vf11, vf00 582 + vu.acc.madd(Mask::xyzw, vu.vf27, vu.vf11, vu.vf00.w()); + // lq.xyzw vf28, 236(vi05) | miniz.w vf17, vf17, vf03 583 + vu.vf17.mini(Mask::w, vu.vf17, vu.vf03.z()); + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); + // BRANCH! + // ibgtz vi06, L31 | mula.xyzw ACC, vf25, vf05 584 + vu.acc.mula(Mask::xyzw, vu.vf25, vu.vf05); + bc = ((s16)vu.vi06) > 0; + // iaddi vi06, vi06, -0x1 | maddw.xyzw vf25, vf06, vf00 585 + vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf06, vu.vf00.w()); + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L31; + } + + // BRANCH! + // ibeq vi00, vi01, L35 | nop 586 + bc = (vu.vi01 == 0); + // nop | nop 587 + + if (bc) { + goto L35; + } + + // BRANCH! + // ibne vi00, vi13, L35 | addw.w vf17, vf17, vf03 588 + vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); + bc = (vu.vi13 != 0); + // fcor vi01, 0x7df7ff | nop 589 + // ASSERT(false); + fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { + goto L35; + } + + // isw.x vi12, 775(vi14) | nop 590 + isw_buffer(Mask::x, vu.vi12, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L35 | nop 591 + bc = (vu.vi01 != 0); + // fcor vi01, 0xdf7dff | nop 592 + // ASSERT(false); + fcor(vu.vi01, 0xdf7dff, cf); + + if (bc) { + goto L35; + } + + // isw.y vi05, 775(vi14) | nop 593 + isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L35 | nop 594 + bc = (vu.vi01 != 0); + // fcor vi01, 0xefbeff | nop 595 + // ASSERT(false); + fcor(vu.vi01, 0xefbeff, cf); + + if (bc) { + goto L35; + } + + // isw.z vi04, 775(vi14) | nop 596 + isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi01, L35 | nop 597 + bc = (vu.vi01 != 0); + // fcor vi01, 0xf7df7f | nop 598 + // ASSERT(false); + fcor(vu.vi01, 0xf7df7f, cf); + + if (bc) { + goto L35; + } + + // nop | nop 599 + + // BRANCH! + // ibne vi00, vi01, L35 | nop 600 + bc = (vu.vi01 != 0); + // fcor vi01, 0xfbefbf | nop 601 + // ASSERT(false); + fcor(vu.vi01, 0xfbefbf, cf); + + if (bc) { + goto L35; + } + + // nop | nop 602 + + // BRANCH! + // ibne vi00, vi01, L35 | nop 603 + bc = (vu.vi01 != 0); + // nop | nop 604 + + if (bc) { + goto L35; + } + + // iaddi vi14, vi14, 0x1 | nop 605 + vu.vi14 = vu.vi14 + 1; +L35: + // nop | ftoi4.xyzw vf17, vf17 606 + vu.vf17.ftoi4(Mask::xyzw, vu.vf17); + // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 607 + vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + // sq.xyzw vf23, 4(vi08) | nop 608 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf17, 5(vi08) | nop 609 + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + // sq.xyzw vf17, 66(vi08) | nop 610 + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); + // sq.xyzw vf25, 64(vi08) | nop 611 + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); + // jr vi15 | nop 612 + // nop | nop 613 +} + +void OceanMid::run_L36_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc; + fmt::print("run L36\n"); +L36: + // lq.xyzw vf31, 734(vi00) | nop 614 + lq_buffer(Mask::xyzw, vu.vf31, 734); + // iaddiu vi10, vi00, 0x243 | nop 615 + vu.vi10 = 0x243; /* 579 */ +L37: + // iaddi vi14, vi14, -0x1 | nop 616 + vu.vi14 = vu.vi14 + -1; + // iaddi vi08, vi10, 0x7 | nop 617 + vu.vi08 = vu.vi10 + 7; + // ilw.x vi12, 775(vi14) | nop 618 + ilw_buffer(Mask::x, vu.vi12, vu.vi14 + 775); + // ilw.y vi05, 775(vi14) | nop 619 + ilw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); + // ilw.z vi04, 775(vi14) | nop 620 + ilw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); + // BRANCH! + // ibne vi00, vi12, L38 | nop 621 + bc = (vu.vi12 != 0); + // nop | nop 622 + + if (bc) { + goto L38; + } + + // lq.xyzw vf28, 233(vi05) | nop 623 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 233); + // lq.xyzw vf29, 242(vi05) | nop 624 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 242); + // lq.xyzw vf30, 234(vi05) | nop 625 + lq_buffer(Mask::xyzw, vu.vf30, vu.vi05 + 234); + // lq.xyzw vf22, 7(vi04) | nop 626 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 7); + // lq.xyzw vf23, 19(vi04) | mulax.xyzw ACC, vf08, vf28 627 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 19); + // lq.xyzw vf16, 8(vi04) | madday.xyzw ACC, vf09, vf28 628 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + lq_buffer(Mask::xyzw, vu.vf16, vu.vi04 + 8); + // lq.xyzw vf20, 317(vi00) | maddaz.xyzw ACC, vf10, vf28 629 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + lq_buffer(Mask::xyzw, vu.vf20, 317); + // lq.xyzw vf21, 318(vi00) | maddw.xyzw vf24, vf11, vf00 630 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf11, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf21, 318); + // BRANCH! + // b L39 | mulax.xyzw ACC, vf12, vf28 631 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + bc = true; + // lq.xyzw vf07, 319(vi00) | madday.xyzw ACC, vf13, vf28 632 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + lq_buffer(Mask::xyzw, vu.vf07, 319); + if (bc) { + goto L39; + } + +L38: + // lq.xyzw vf28, 242(vi05) | nop 633 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 242); + // lq.xyzw vf29, 234(vi05) | nop 634 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 234); + // lq.xyzw vf30, 243(vi05) | nop 635 + lq_buffer(Mask::xyzw, vu.vf30, vu.vi05 + 243); + // lq.xyzw vf22, 18(vi04) | nop 636 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 18); + // lq.xyzw vf23, 7(vi04) | mulax.xyzw ACC, vf08, vf28 637 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 7); + // lq.xyzw vf16, 19(vi04) | madday.xyzw ACC, vf09, vf28 638 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + lq_buffer(Mask::xyzw, vu.vf16, vu.vi04 + 19); + // lq.xyzw vf20, 318(vi00) | maddaz.xyzw ACC, vf10, vf28 639 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + lq_buffer(Mask::xyzw, vu.vf20, 318); + // lq.xyzw vf21, 319(vi00) | maddw.xyzw vf24, vf11, vf00 640 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf11, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf21, 319); + // nop | mulax.xyzw ACC, vf12, vf28 641 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + // lq.xyzw vf07, 320(vi00) | madday.xyzw ACC, vf13, vf28 642 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + lq_buffer(Mask::xyzw, vu.vf07, 320); +L39: + // nop | maddaz.xyzw ACC, vf14, vf28 643 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + // erleng.xyz P, vf24 | maddw.xyzw vf28, vf15, vf00 644 + vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf15, vu.vf00.w()); + vu.P = erleng(vu.vf24); /* TODO erleng */ + // nop | addz.y vf24, vf00, vf24 645 + vu.vf24.add(Mask::y, vu.vf00, vu.vf24.z()); + // nop | itof0.xyzw vf22, vf22 646 + vu.vf22.itof0(Mask::xyzw, vu.vf22); + // nop | itof0.xyzw vf23, vf23 647 + vu.vf23.itof0(Mask::xyzw, vu.vf23); + // nop | itof0.xyzw vf16, vf16 648 + vu.vf16.itof0(Mask::xyzw, vu.vf16); + // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf08, vf29 649 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf09, vf29 650 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf21, 3(vi08) | maddaz.xyzw ACC, vf10, vf29 651 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + // sq.xyzw vf23, 4(vi08) | maddw.xyzw vf25, vf11, vf00 652 + vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf11, vu.vf00.w()); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf07, 6(vi08) | mulax.xyzw ACC, vf12, vf29 653 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); + sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + 6); + // sq.xyzw vf16, 7(vi08) | madday.xyzw ACC, vf13, vf29 654 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 7); + // sq.xyzw vf20, 9(vi08) | maddaz.xyzw ACC, vf14, vf29 655 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08 + 9); + // sq.xyzw vf22, 10(vi08) | maddw.xyzw vf29, vf15, vf00 656 + vu.acc.madd(Mask::xyzw, vu.vf29, vu.vf15, vu.vf00.w()); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); + // waitp | mul.xyzw vf28, vf28, vf01 657 + vu.vf28.mul(Mask::xyzw, vu.vf28, vu.vf01); + // ASSERT(false); + // mfp.w vf24, P | nop 658 + vu.vf24.mfp(Mask::w, vu.P); + // erleng.xyz P, vf25 | nop 659 + vu.P = erleng(vu.vf25); /* TODO erleng */ + // nop | addz.y vf25, vf00, vf25 660 + vu.vf25.add(Mask::y, vu.vf00, vu.vf25.z()); + // sq.xyzw vf28, 2(vi08) | mulax.xyzw ACC, vf08, vf30 661 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf30.x()); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf28, 11(vi08) | mulw.xy vf24, vf24, vf24 662 + vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); + // sq.xyzw vf28, 772(vi00) | madday.xyzw ACC, vf09, vf30 663 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf30.y()); + sq_buffer(Mask::xyzw, vu.vf28, 772); + // nop | maddaz.xyzw ACC, vf10, vf30 664 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf30.z()); + // nop | maddw.xyzw vf26, vf11, vf00 665 + vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf11, vu.vf00.w()); + // nop | mula.xyzw ACC, vf24, vf05 666 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); + // nop | maddw.xyzw vf24, vf06, vf00 667 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); + // nop | mulax.xyzw ACC, vf12, vf30 668 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf30.x()); + // nop | madday.xyzw ACC, vf13, vf30 669 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf30.y()); + // nop | maddaz.xyzw ACC, vf14, vf30 670 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf30.z()); + // sq.xyzw vf24, 769(vi00) | maddw.xyzw vf30, vf15, vf00 671 + vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); + sq_buffer(Mask::xyzw, vu.vf24, 769); + // waitp | mul.xyzw vf29, vf29, vf01 672 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.vf01); + // ASSERT(false); + // mfp.w vf25, P | nop 673 + vu.vf25.mfp(Mask::w, vu.P); + // erleng.xyz P, vf26 | nop 674 + vu.P = erleng(vu.vf26); /* TODO erleng */ + // nop | addz.y vf26, vf00, vf26 675 + vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); + // sq.xyzw vf29, 5(vi08) | nop 676 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); + // sq.xyzw vf29, 773(vi00) | mulw.xy vf25, vf25, vf25 677 + vu.vf25.mul(Mask::xy, vu.vf25, vu.vf25.w()); + sq_buffer(Mask::xyzw, vu.vf29, 773); + // nop | mula.xyzw ACC, vf25, vf05 678 + vu.acc.mula(Mask::xyzw, vu.vf25, vu.vf05); + // nop | maddw.xyzw vf25, vf06, vf00 679 + vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf06, vu.vf00.w()); + // waitp | mul.xyzw vf30, vf30, vf01 680 + vu.vf30.mul(Mask::xyzw, vu.vf30, vu.vf01); + // ASSERT(false); + // mfp.w vf26, P | nop 681 + vu.vf26.mfp(Mask::w, vu.P); + // sq.xyzw vf30, 8(vi08) | nop 682 + sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); + // sq.xyzw vf30, 774(vi00) | mulw.xy vf26, vf26, vf26 683 + vu.vf26.mul(Mask::xy, vu.vf26, vu.vf26.w()); + sq_buffer(Mask::xyzw, vu.vf30, 774); + // sq.xyzw vf25, 770(vi00) | mula.xyzw ACC, vf26, vf05 684 + vu.acc.mula(Mask::xyzw, vu.vf26, vu.vf05); + sq_buffer(Mask::xyzw, vu.vf25, 770); + // lq.xyzw vf07, 739(vi00) | maddw.xyzw vf26, vf06, vf00 685 + vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf06, vu.vf00.w()); + lq_buffer(Mask::xyzw, vu.vf07, 739); + // ior vi03, vi08, vi00 | nop 686 + vu.vi03 = vu.vi08; + // iaddi vi05, vi00, 0x3 | nop 687 + vu.vi05 = 3; + // BRANCH! + // bal vi13, L43 | nop 688 + // sq.xyzw vf26, 771(vi00) | nop 689 + sq_buffer(Mask::xyzw, vu.vf26, 771); + run_L43_vu2c(); + + // lq.xyzw vf28, 741(vi00) | nop 690 + lq_buffer(Mask::xyzw, vu.vf28, 741); + // BRANCH! + // ibeq vi00, vi05, L40 | nop 691 + bc = (vu.vi05 == 0); + // lq.xyzw vf29, 742(vi00) | nop 692 + lq_buffer(Mask::xyzw, vu.vf29, 742); + if (bc) { + goto L40; + } + + // lq.xyzw vf30, 743(vi00) | nop 693 + lq_buffer(Mask::xyzw, vu.vf30, 743); + // lq.xyzw vf24, 744(vi00) | nop 694 + lq_buffer(Mask::xyzw, vu.vf24, 744); + // lq.xyzw vf25, 745(vi00) | nop 695 + lq_buffer(Mask::xyzw, vu.vf25, 745); + // lq.xyzw vf26, 746(vi00) | nop 696 + lq_buffer(Mask::xyzw, vu.vf26, 746); + // sq.xyzw vf28, 0(vi10) | nop 697 + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); + // sq.xyzw vf29, 1(vi10) | nop 698 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); + // sq.xyzw vf30, 2(vi10) | nop 699 + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); + // sq.xyzw vf24, 3(vi10) | nop 700 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); + // sq.xyzw vf25, 4(vi10) | nop 701 + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); + // sq.xyzw vf26, 5(vi10) | nop 702 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); + // iaddiu vi06, vi05, 0x4000 | nop 703 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + // BRANCH! + // bal vi13, L41 | nop 704 + // iaddiu vi06, vi06, 0x4000 | nop 705 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + run_L41_vu2c(render_state, prof, direct); + + // iaddi vi08, vi10, 0x7 | nop 706 + vu.vi08 = vu.vi10 + 7; + // lq.xyzw vf24, 769(vi00) | nop 707 + lq_buffer(Mask::xyzw, vu.vf24, 769); + // lq.xyzw vf25, 770(vi00) | nop 708 + lq_buffer(Mask::xyzw, vu.vf25, 770); + // lq.xyzw vf26, 771(vi00) | nop 709 + lq_buffer(Mask::xyzw, vu.vf26, 771); + // lq.xyzw vf22, 756(vi00) | nop 710 + lq_buffer(Mask::xyzw, vu.vf22, 756); + // lq.xyzw vf28, 772(vi00) | nop 711 + lq_buffer(Mask::xyzw, vu.vf28, 772); + // lq.xyzw vf29, 773(vi00) | nop 712 + lq_buffer(Mask::xyzw, vu.vf29, 773); + // lq.xyzw vf30, 774(vi00) | nop 713 + lq_buffer(Mask::xyzw, vu.vf30, 774); + // sq.xyzw vf24, 0(vi08) | nop 714 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // sq.xyzw vf22, 1(vi08) | nop 715 + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 716 + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf25, 3(vi08) | nop 717 + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 3); + // sq.xyzw vf22, 4(vi08) | nop 718 + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 4); + // sq.xyzw vf29, 5(vi08) | nop 719 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); + // sq.xyzw vf26, 6(vi08) | nop 720 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi08 + 6); + // sq.xyzw vf22, 7(vi08) | nop 721 + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 7); + // sq.xyzw vf30, 8(vi08) | nop 722 + sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); + // sq.xyzw vf24, 9(vi08) | nop 723 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 9); + // sq.xyzw vf22, 10(vi08) | nop 724 + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); + // sq.xyzw vf28, 11(vi08) | nop 725 + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); + // ior vi03, vi08, vi00 | nop 726 + vu.vi03 = vu.vi08; + // iaddi vi05, vi00, 0x3 | nop 727 + vu.vi05 = 3; + // BRANCH! + // bal vi13, L43 | nop 728 + // lq.xyzw vf07, 740(vi00) | nop 729 + lq_buffer(Mask::xyzw, vu.vf07, 740); + run_L43_vu2c(); + + // lq.xyzw vf28, 749(vi00) | nop 730 + lq_buffer(Mask::xyzw, vu.vf28, 749); + // lq.xyzw vf29, 750(vi00) | nop 731 + lq_buffer(Mask::xyzw, vu.vf29, 750); + // lq.xyzw vf30, 751(vi00) | nop 732 + lq_buffer(Mask::xyzw, vu.vf30, 751); + // lq.xyzw vf24, 752(vi00) | nop 733 + lq_buffer(Mask::xyzw, vu.vf24, 752); + // lq.xyzw vf25, 753(vi00) | nop 734 + lq_buffer(Mask::xyzw, vu.vf25, 753); + // lq.xyzw vf26, 754(vi00) | nop 735 + lq_buffer(Mask::xyzw, vu.vf26, 754); + // sq.xyzw vf28, 0(vi10) | nop 736 + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); + // sq.xyzw vf29, 1(vi10) | nop 737 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); + // sq.xyzw vf30, 2(vi10) | nop 738 + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); + // sq.xyzw vf24, 3(vi10) | nop 739 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); + // sq.xyzw vf25, 4(vi10) | nop 740 + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); + // sq.xyzw vf26, 5(vi10) | nop 741 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); + // iaddiu vi06, vi05, 0x4000 | nop 742 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + // BRANCH! + // bal vi13, L41 | nop 743 + // iaddiu vi06, vi06, 0x4000 | nop 744 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + run_L41_vu2c(render_state, prof, direct); + +L40: + // BRANCH! + // ibgtz vi14, L37 | nop 745 + bc = ((s16)vu.vi14) > 0; + // nop | nop 746 + + if (bc) { + goto L37; + } + + // jr vi15 | nop 747 + // nop | nop 748 +} + +void OceanMid::run_L41_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc; +L41: + // sq.xyzw vf07, -1(vi08) | nop 749 + sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + -1); + // isw.x vi06, -1(vi08) | nop 750 + isw_buffer(Mask::x, vu.vi06, vu.vi08 + -1); +L42: + // lqi.xyzw vf24, vi08 | nop 751 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08++); + // lqi.xyzw vf27, vi08 | nop 752 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08++); + // lqi.xyzw vf21, vi08 | nop 753 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08++); + // nop | nop 754 + + // nop | nop 755 + + // nop | nop 756 + + // div Q, vf00.w, vf21.w | mul.xyzw vf21, vf21, vf31 757 + vu.vf21.mul(Mask::xyzw, vu.vf21, vu.vf31); + vu.Q = vu.vf00.w() / vu.vf21.w(); + // nop | nop 758 + + // nop | nop 759 + + // nop | nop 760 + + // nop | nop 761 + + // nop | nop 762 + + // nop | nop 763 + + // nop | mul.xyz vf21, vf21, Q 764 + vu.vf21.mul(Mask::xyz, vu.vf21, vu.Q); + // nop | mul.xyzw vf24, vf24, Q 765 + vu.vf24.mul(Mask::xyzw, vu.vf24, vu.Q); + // nop | nop 766 + + // nop | nop 767 + + // nop | add.xyzw vf21, vf21, vf02 768 + vu.vf21.add(Mask::xyzw, vu.vf21, vu.vf02); + // nop | nop 769 + + // nop | nop 770 + + // nop | nop 771 + + // nop | maxy.w vf21, vf21, vf03 772 + vu.vf21.max(Mask::w, vu.vf21, vu.vf03.y()); + // nop | nop 773 + + // nop | nop 774 + + // nop | nop 775 + + // nop | miniz.w vf21, vf21, vf03 776 + vu.vf21.mini(Mask::w, vu.vf21, vu.vf03.z()); + // nop | nop 777 + + // nop | nop 778 + + // nop | ftoi0.xyzw vf27, vf27 779 + vu.vf27.ftoi0(Mask::xyzw, vu.vf27); + // nop | ftoi4.xyzw vf21, vf21 780 + vu.vf21.ftoi4(Mask::xyzw, vu.vf21); + // nop | nop 781 + + // sq.xyzw vf24, -3(vi08) | nop 782 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + -3); + // sq.xyzw vf27, -2(vi08) | nop 783 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + -2); + // sq.xyzw vf21, -1(vi08) | nop 784 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + -1); + // iaddi vi05, vi05, -0x1 | nop 785 + vu.vi05 = vu.vi05 + -1; + // nop | nop 786 + + // BRANCH! + // ibne vi00, vi05, L42 | nop 787 + bc = (vu.vi05 != 0); + // nop | nop 788 + + if (bc) { + goto L42; + } + + // iaddiu vi01, vi00, 0x4d3 | nop 789 + vu.vi01 = 0x4d3; /* 1235 */ + // xgkick vi10 | nop 790 + fmt::print("kick from 1514\n"); + xgkick(vu.vi10, render_state, prof, direct); + // jr vi13 | nop 791 + // isub vi10, vi01, vi10 | nop 792 + vu.vi10 = vu.vi01 - vu.vi10; +} + +void OceanMid::run_L43_vu2c() { + u32 cf = 0; // isn't from earlier? + bool bc; + fmt::print("here!!!\n"); +L43: + // ior vi04, vi03, vi00 | nop 793 + vu.vi04 = vu.vi03; + // lq.xyzw vf21, 2(vi03) | nop 794 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 2); + // ior vi06, vi05, vi00 | nop 795 + vu.vi06 = vu.vi05; + // lq.xyzw vf24, 0(vi03) | nop 796 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03); + // lq.xyzw vf27, 1(vi03) | nop 797 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 798 + cf = clip(vu.vf21, vu.vf21.w(), cf); + vu.vi03 = vu.vi03 + 3; +L44: + // lq.xyzw vf22, 2(vi03) | nop 799 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); + // lq.xyzw vf25, 0(vi03) | nop 800 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi03); + // lq.xyzw vf28, 1(vi03) | nop 801 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | nop 802 + vu.vi03 = vu.vi03 + 3; + // nop | clipw.xyz vf22, vf22 803 + cf = clip(vu.vf22, vu.vf22.w(), cf); + // nop | nop 804 + + // nop | nop 805 + + // nop | nop 806 + + // fcor vi01, 0xfff7df | nop 807 + fcor(vu.vi01, 0xfff7df, cf); + // ASSERT(false); + // BRANCH! + // ibne vi00, vi01, L55 | nop 808 + bc = (vu.vi01 != 0); + // fcand vi01, 0x20 | nop 809 + // vu.vi01 = cf & 0x20; + fcand(vu.vi01, 0x20, cf); + + if (bc) { + goto L55; + } + + // BRANCH! + // ibne vi00, vi01, L56 | nop 810 + bc = (vu.vi01 != 0); + // fcand vi01, 0x800 | nop 811 + // ASSERT(false); + // vu.vi01 = cf & 0x800; + fcand(vu.vi01, 0x800, cf); + + if (bc) { + goto L56; + } + + // BRANCH! + // ibne vi00, vi01, L57 | nop 812 + bc = (vu.vi01 != 0); + // nop | nop 813 + + if (bc) { + goto L57; + } + + // sqi.xyzw vf24, vi04 | nop 814 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 815 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 816 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); +L45: + // move.xyzw vf24, vf25 | nop 817 + vu.vf24.move(Mask::xyzw, vu.vf25); + // iaddi vi05, vi05, -0x1 | nop 818 + vu.vi05 = vu.vi05 + -1; + // move.xyzw vf27, vf28 | nop 819 + vu.vf27.move(Mask::xyzw, vu.vf28); + // BRANCH! + // ibne vi00, vi05, L44 | nop 820 + bc = (vu.vi05 != 0); + // move.xyzw vf21, vf22 | nop 821 + vu.vf21.move(Mask::xyzw, vu.vf22); + if (bc) { + goto L44; + } + + // lq.xyzw vf24, 0(vi08) | nop 822 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // lq.xyzw vf27, 1(vi08) | nop 823 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + 1); + // lq.xyzw vf21, 2(vi08) | nop 824 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 2); + // ior vi03, vi08, vi00 | nop 825 + vu.vi03 = vu.vi08; + // sqi.xyzw vf24, vi04 | nop 826 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 827 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 828 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi00, vi06, L54 | nop 829 + bc = (vu.vi06 == 0); + // ior vi05, vi06, vi00 | nop 830 + vu.vi05 = vu.vi06; + if (bc) { + goto L54; + } + + // ior vi04, vi03, vi00 | nop 831 + vu.vi04 = vu.vi03; + // lq.xyzw vf21, 2(vi03) | nop 832 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 2); + // ior vi06, vi05, vi00 | nop 833 + vu.vi06 = vu.vi05; + // lq.xyzw vf24, 0(vi03) | nop 834 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03); + // lq.xyzw vf27, 1(vi03) | nop 835 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 836 + cf = clip(vu.vf21, vu.vf21.w(), cf); + vu.vi03 = vu.vi03 + 3; +L46: + // lq.xyzw vf22, 2(vi03) | nop 837 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); + // lq.xyzw vf25, 0(vi03) | nop 838 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi03); + // lq.xyzw vf28, 1(vi03) | nop 839 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | nop 840 + vu.vi03 = vu.vi03 + 3; + // nop | clipw.xyz vf22, vf22 841 + cf = clip(vu.vf22, vu.vf22.w(), cf); + // nop | nop 842 + + // nop | nop 843 + + // nop | nop 844 + + // fcor vi01, 0xfffdf7 | nop 845 + // ASSERT(false); + fcor(vu.vi01, 0xfffdf7 ,cf); + // BRANCH! + // ibne vi00, vi01, L58 | nop 846 + bc = (vu.vi01 != 0); + // fcand vi01, 0x8 | nop 847 + // ASSERT(false); + // vu.vi01 = cf & 0x8; + fcand(vu.vi01, 0x8, cf); + + if (bc) { + goto L58; + } + + // BRANCH! + // ibne vi00, vi01, L59 | nop 848 + bc = (vu.vi01 != 0); + // fcand vi01, 0x200 | nop 849 + // ASSERT(false); + // vu.vi01 = cf & 0x200; + fcand(vu.vi01, 0x200, cf); + + + if (bc) { + goto L59; + } + + // BRANCH! + // ibne vi00, vi01, L60 | nop 850 + bc = (vu.vi01 != 0); + // nop | nop 851 + + if (bc) { + goto L60; + } + + // sqi.xyzw vf24, vi04 | nop 852 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 853 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 854 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); +L47: + // move.xyzw vf24, vf25 | nop 855 + vu.vf24.move(Mask::xyzw, vu.vf25); + // iaddi vi05, vi05, -0x1 | nop 856 + vu.vi05 = vu.vi05 + -1; + // move.xyzw vf27, vf28 | nop 857 + vu.vf27.move(Mask::xyzw, vu.vf28); + // BRANCH! + // ibne vi00, vi05, L46 | nop 858 + bc = (vu.vi05 != 0); + // move.xyzw vf21, vf22 | nop 859 + vu.vf21.move(Mask::xyzw, vu.vf22); + if (bc) { + goto L46; + } + + // lq.xyzw vf24, 0(vi08) | nop 860 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // lq.xyzw vf27, 1(vi08) | nop 861 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + 1); + // lq.xyzw vf21, 2(vi08) | nop 862 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 2); + // ior vi03, vi08, vi00 | nop 863 + vu.vi03 = vu.vi08; + // sqi.xyzw vf24, vi04 | nop 864 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 865 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 866 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi00, vi06, L54 | nop 867 + bc = (vu.vi06 == 0); + // ior vi05, vi06, vi00 | nop 868 + vu.vi05 = vu.vi06; + if (bc) { + goto L54; + } + + // ior vi04, vi03, vi00 | nop 869 + vu.vi04 = vu.vi03; + // lq.xyzw vf21, 2(vi03) | nop 870 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 2); + // ior vi06, vi05, vi00 | nop 871 + vu.vi06 = vu.vi05; + // lq.xyzw vf24, 0(vi03) | nop 872 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03); + // lq.xyzw vf27, 1(vi03) | nop 873 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 874 + cf = clip(vu.vf21, vu.vf21.w(), cf); + vu.vi03 = vu.vi03 + 3; +L48: + // lq.xyzw vf22, 2(vi03) | nop 875 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); + // lq.xyzw vf25, 0(vi03) | nop 876 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi03); + // lq.xyzw vf28, 1(vi03) | nop 877 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | nop 878 + vu.vi03 = vu.vi03 + 3; + // nop | clipw.xyz vf22, vf22 879 + cf = clip(vu.vf22, vu.vf22.w(), cf); + // nop | nop 880 + + // nop | nop 881 + + // nop | nop 882 + + // fcor vi01, 0xfffefb | nop 883 + // ASSERT(false); + fcor(vu.vi01, 0xfffefb, cf); + // BRANCH! + // ibne vi00, vi01, L61 | nop 884 + bc = (vu.vi01 != 0); + // fcand vi01, 0x4 | nop 885 + // ASSERT(false); + // vu.vi01 = cf & 0x4; + fcand(vu.vi01, 0x4, cf); + + if (bc) { + goto L61; + } + + // BRANCH! + // ibne vi00, vi01, L62 | nop 886 + bc = (vu.vi01 != 0); + // fcand vi01, 0x100 | nop 887 + // ASSERT(false); + // vu.vi01 = cf & 0x100; + fcand(vu.vi01, 0x100, cf); + + if (bc) { + goto L62; + } + + // BRANCH! + // ibne vi00, vi01, L63 | nop 888 + bc = (vu.vi01 != 0); + // nop | nop 889 + + if (bc) { + goto L63; + } + + // sqi.xyzw vf24, vi04 | nop 890 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 891 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 892 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); +L49: + // move.xyzw vf24, vf25 | nop 893 + vu.vf24.move(Mask::xyzw, vu.vf25); + // iaddi vi05, vi05, -0x1 | nop 894 + vu.vi05 = vu.vi05 + -1; + // move.xyzw vf27, vf28 | nop 895 + vu.vf27.move(Mask::xyzw, vu.vf28); + // BRANCH! + // ibne vi00, vi05, L48 | nop 896 + bc = (vu.vi05 != 0); + // move.xyzw vf21, vf22 | nop 897 + vu.vf21.move(Mask::xyzw, vu.vf22); + if (bc) { + goto L48; + } + + // lq.xyzw vf24, 0(vi08) | nop 898 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // lq.xyzw vf27, 1(vi08) | nop 899 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + 1); + // lq.xyzw vf21, 2(vi08) | nop 900 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 2); + // ior vi03, vi08, vi00 | nop 901 + vu.vi03 = vu.vi08; + // sqi.xyzw vf24, vi04 | nop 902 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 903 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 904 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi00, vi06, L54 | nop 905 + bc = (vu.vi06 == 0); + // ior vi05, vi06, vi00 | nop 906 + vu.vi05 = vu.vi06; + if (bc) { + goto L54; + } + + // ior vi04, vi03, vi00 | nop 907 + vu.vi04 = vu.vi03; + // lq.xyzw vf21, 2(vi03) | nop 908 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 2); + // ior vi06, vi05, vi00 | nop 909 + vu.vi06 = vu.vi05; + // lq.xyzw vf24, 0(vi03) | nop 910 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03); + // lq.xyzw vf27, 1(vi03) | nop 911 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 912 + // ASSERT(false); + cf = clip(vu.vf21, vu.vf21.w(), cf); + vu.vi03 = vu.vi03 + 3; +L50: + // lq.xyzw vf22, 2(vi03) | nop 913 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); + // lq.xyzw vf25, 0(vi03) | nop 914 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi03); + // lq.xyzw vf28, 1(vi03) | nop 915 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | nop 916 + vu.vi03 = vu.vi03 + 3; + // nop | clipw.xyz vf22, vf22 917 + // ASSERT(false); + cf = clip(vu.vf22, vu.vf22.w(), cf); + // nop | nop 918 + + // nop | nop 919 + + // nop | nop 920 + + // fcor vi01, 0xffff7d | nop 921 + // ASSERT(false); + fcor(vu.vi01, 0xffff7d, cf); + // BRANCH! + // ibne vi00, vi01, L64 | nop 922 + bc = (vu.vi01 != 0); + // fcand vi01, 0x2 | nop 923 + // ASSERT(false); + // vu.vi01 = cf & 0x2; + fcand(vu.vi01, 0x2, cf); + + if (bc) { + goto L64; + } + + // BRANCH! + // ibne vi00, vi01, L65 | nop 924 + bc = (vu.vi01 != 0); + // fcand vi01, 0x80 | nop 925 + // ASSERT(false); + // vu.vi01 = cf & 0x80; + fcand(vu.vi01, 0x80, cf); + + if (bc) { + goto L65; + } + + // BRANCH! + // ibne vi00, vi01, L66 | nop 926 + bc = (vu.vi01 != 0); + // nop | nop 927 + + if (bc) { + goto L66; + } + + // sqi.xyzw vf24, vi04 | nop 928 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 929 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 930 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); +L51: + // move.xyzw vf24, vf25 | nop 931 + vu.vf24.move(Mask::xyzw, vu.vf25); + // iaddi vi05, vi05, -0x1 | nop 932 + vu.vi05 = vu.vi05 + -1; + // move.xyzw vf27, vf28 | nop 933 + vu.vf27.move(Mask::xyzw, vu.vf28); + // BRANCH! + // ibne vi00, vi05, L50 | nop 934 + bc = (vu.vi05 != 0); + // move.xyzw vf21, vf22 | nop 935 + vu.vf21.move(Mask::xyzw, vu.vf22); + if (bc) { + goto L50; + } + + // lq.xyzw vf24, 0(vi08) | nop 936 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // lq.xyzw vf27, 1(vi08) | nop 937 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + 1); + // lq.xyzw vf21, 2(vi08) | nop 938 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 2); + // ior vi03, vi08, vi00 | nop 939 + vu.vi03 = vu.vi08; + // sqi.xyzw vf24, vi04 | nop 940 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 941 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 942 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi00, vi06, L54 | nop 943 + bc = (vu.vi06 == 0); + // ior vi05, vi06, vi00 | nop 944 + vu.vi05 = vu.vi06; + if (bc) { + goto L54; + } + + // ior vi04, vi03, vi00 | nop 945 + vu.vi04 = vu.vi03; + // lq.xyzw vf21, 2(vi03) | nop 946 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 2); + // ior vi06, vi05, vi00 | nop 947 + vu.vi06 = vu.vi05; + // lq.xyzw vf24, 0(vi03) | nop 948 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03); + // lq.xyzw vf27, 1(vi03) | nop 949 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 950 + // ASSERT(false); + cf = clip(vu.vf21, vu.vf21.w(), cf); + vu.vi03 = vu.vi03 + 3; +L52: + // lq.xyzw vf22, 2(vi03) | nop 951 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); + // lq.xyzw vf25, 0(vi03) | nop 952 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi03); + // lq.xyzw vf28, 1(vi03) | nop 953 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 1); + // iaddi vi03, vi03, 0x3 | nop 954 + vu.vi03 = vu.vi03 + 3; + // nop | clipw.xyz vf22, vf22 955 + // ASSERT(false); + cf = clip(vu.vf22, vu.vf22.w(), cf); + // nop | nop 956 + + // nop | nop 957 + + // nop | nop 958 + + // fcor vi01, 0xffffbe | nop 959 + // ASSERT(false); + fcor(vu.vi01, 0xffffbe, cf); + // BRANCH! + // ibne vi00, vi01, L67 | nop 960 + bc = (vu.vi01 != 0); + // fcand vi01, 0x1 | nop 961 + // ASSERT(false); + fcand(vu.vi01, 1, cf); + // vu.vi01 = cf & 0x1; + + if (bc) { + goto L67; + } + + // BRANCH! + // ibne vi00, vi01, L68 | nop 962 + bc = (vu.vi01 != 0); + // fcand vi01, 0x40 | nop 963 + // ASSERT(false); + fcand(vu.vi01, 0x40, cf); + // vu.vi01 = cf & 0x40; + + if (bc) { + goto L68; + } + + // BRANCH! + // ibne vi00, vi01, L69 | nop 964 + bc = (vu.vi01 != 0); + // nop | nop 965 + + if (bc) { + goto L69; + } + + // sqi.xyzw vf24, vi04 | nop 966 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 967 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 968 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); +L53: + // move.xyzw vf24, vf25 | nop 969 + vu.vf24.move(Mask::xyzw, vu.vf25); + // iaddi vi05, vi05, -0x1 | nop 970 + vu.vi05 = vu.vi05 + -1; + // move.xyzw vf27, vf28 | nop 971 + vu.vf27.move(Mask::xyzw, vu.vf28); + // BRANCH! + // ibne vi00, vi05, L52 | nop 972 + bc = (vu.vi05 != 0); + // move.xyzw vf21, vf22 | nop 973 + vu.vf21.move(Mask::xyzw, vu.vf22); + if (bc) { + goto L52; + } + + // lq.xyzw vf24, 0(vi08) | nop 974 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + // lq.xyzw vf27, 1(vi08) | nop 975 + lq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + 1); + // lq.xyzw vf21, 2(vi08) | nop 976 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 2); + // ior vi03, vi08, vi00 | nop 977 + vu.vi03 = vu.vi08; + // sqi.xyzw vf24, vi04 | nop 978 + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | nop 979 + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | nop 980 + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi00, vi06, L54 | nop 981 + bc = (vu.vi06 == 0); + // ior vi05, vi06, vi00 | nop 982 + vu.vi05 = vu.vi06; + if (bc) { + goto L54; + } + +L54: + // jr vi13 | nop 983 + // ASSERT(false); + return; + // nop | nop 984 + +L55: + // BRANCH! + // b L45 | nop 985 + bc = true; + // iaddi vi06, vi06, -0x1 | nop 986 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L45; + } + +L56: + // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 987 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 988 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 989 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi03, vi04, L45 | nop 990 + bc = (vu.vi03 == vu.vi04); + // nop | addz.w vf30, vf23, vf23 991 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.z()); + if (bc) { + goto L45; + } + + // nop | addw.z vf30, vf21, vf21 992 + vu.vf30.add(Mask::z, vu.vf21, vu.vf21.w()); + // div Q, vf30.z, vf30.w | nop 993 + vu.Q = vu.vf30.z() / vu.vf30.w(); + // waitq | nop 994 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 995 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 996 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 997 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf24, vf26 998 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf26); + // nop | sub.xyzw vf29, vf27, vf29 999 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf29); + // nop | sub.xyzw vf23, vf21, vf23 1000 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf23); + // iaddi vi06, vi06, 0x1 | nop 1001 + vu.vi06 = vu.vi06 + 1; + // sqi.xyzw vf26, vi04 | nop 1002 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1003 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L45 | nop 1004 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1005 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L45; + } + +L57: + // nop | sub.xyzw vf23, vf21, vf22 1006 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); + // nop | sub.xyzw vf26, vf24, vf25 1007 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf25); + // nop | sub.xyzw vf29, vf27, vf28 1008 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf28); + // nop | addz.w vf30, vf23, vf23 1009 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.z()); + // nop | addw.z vf30, vf22, vf22 1010 + vu.vf30.add(Mask::z, vu.vf22, vu.vf22.w()); + // div Q, vf30.z, vf30.w | nop 1011 + vu.Q = vu.vf30.z() / vu.vf30.w(); + // waitq | nop 1012 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1013 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1014 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1015 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf25, vf26 1016 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf26); + // nop | sub.xyzw vf29, vf28, vf29 1017 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf29); + // nop | sub.xyzw vf23, vf22, vf23 1018 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); + // sqi.xyzw vf26, vi04 | nop 1019 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1020 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L45 | nop 1021 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1022 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L45; + } + +L58: + // BRANCH! + // b L47 | nop 1023 + bc = true; + // iaddi vi06, vi06, -0x1 | nop 1024 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L47; + } + +L59: + // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1025 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1026 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1027 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi03, vi04, L47 | nop 1028 + bc = (vu.vi03 == vu.vi04); + // nop | addy.w vf30, vf23, vf23 1029 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.y()); + if (bc) { + goto L47; + } + + // nop | addw.y vf30, vf21, vf21 1030 + vu.vf30.add(Mask::y, vu.vf21, vu.vf21.w()); + // div Q, vf30.y, vf30.w | nop 1031 + vu.Q = vu.vf30.y() / vu.vf30.w(); + // waitq | nop 1032 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1033 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1034 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1035 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf24, vf26 1036 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf26); + // nop | sub.xyzw vf29, vf27, vf29 1037 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf29); + // nop | sub.xyzw vf23, vf21, vf23 1038 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf23); + // iaddi vi06, vi06, 0x1 | nop 1039 + vu.vi06 = vu.vi06 + 1; + // sqi.xyzw vf26, vi04 | nop 1040 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1041 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L47 | nop 1042 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1043 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L47; + } + +L60: + // nop | sub.xyzw vf23, vf21, vf22 1044 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); + // nop | sub.xyzw vf26, vf24, vf25 1045 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf25); + // nop | sub.xyzw vf29, vf27, vf28 1046 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf28); + // nop | addy.w vf30, vf23, vf23 1047 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.y()); + // nop | addw.y vf30, vf22, vf22 1048 + vu.vf30.add(Mask::y, vu.vf22, vu.vf22.w()); + // div Q, vf30.y, vf30.w | nop 1049 + vu.Q = vu.vf30.y() / vu.vf30.w(); + // waitq | nop 1050 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1051 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1052 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1053 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf25, vf26 1054 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf26); + // nop | sub.xyzw vf29, vf28, vf29 1055 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf29); + // nop | sub.xyzw vf23, vf22, vf23 1056 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); + // sqi.xyzw vf26, vi04 | nop 1057 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1058 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L47 | nop 1059 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1060 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L47; + } + +L61: + // BRANCH! + // b L49 | nop 1061 + bc = true; + // iaddi vi06, vi06, -0x1 | nop 1062 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L49; + } + +L62: + // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1063 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1064 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1065 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi03, vi04, L49 | nop 1066 + bc = (vu.vi03 == vu.vi04); + // nop | suby.w vf30, vf23, vf23 1067 + vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.y()); + if (bc) { + goto L49; + } + + // nop | subw.y vf30, vf21, vf21 1068 + vu.vf30.sub(Mask::y, vu.vf21, vu.vf21.w()); + // div Q, vf30.y, vf30.w | nop 1069 + vu.Q = vu.vf30.y() / vu.vf30.w(); + // waitq | nop 1070 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1071 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1072 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1073 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | add.xyzw vf26, vf24, vf26 1074 + vu.vf26.add(Mask::xyzw, vu.vf24, vu.vf26); + // nop | add.xyzw vf29, vf27, vf29 1075 + vu.vf29.add(Mask::xyzw, vu.vf27, vu.vf29); + // nop | add.xyzw vf23, vf21, vf23 1076 + vu.vf23.add(Mask::xyzw, vu.vf21, vu.vf23); + // iaddi vi06, vi06, 0x1 | nop 1077 + vu.vi06 = vu.vi06 + 1; + // sqi.xyzw vf26, vi04 | nop 1078 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1079 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L49 | nop 1080 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1081 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L49; + } + +L63: + // nop | sub.xyzw vf23, vf21, vf22 1082 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); + // nop | sub.xyzw vf26, vf24, vf25 1083 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf25); + // nop | sub.xyzw vf29, vf27, vf28 1084 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf28); + // nop | suby.w vf30, vf23, vf23 1085 + vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.y()); + // nop | subw.y vf30, vf22, vf22 1086 + vu.vf30.sub(Mask::y, vu.vf22, vu.vf22.w()); + // div Q, vf30.y, vf30.w | nop 1087 + vu.Q = vu.vf30.y() / vu.vf30.w(); + // waitq | nop 1088 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1089 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1090 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1091 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | add.xyzw vf26, vf25, vf26 1092 + vu.vf26.add(Mask::xyzw, vu.vf25, vu.vf26); + // nop | add.xyzw vf29, vf28, vf29 1093 + vu.vf29.add(Mask::xyzw, vu.vf28, vu.vf29); + // nop | add.xyzw vf23, vf22, vf23 1094 + vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); + // sqi.xyzw vf26, vi04 | nop 1095 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1096 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L49 | nop 1097 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1098 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L49; + } + +L64: + // BRANCH! + // b L51 | nop 1099 + bc = true; + // iaddi vi06, vi06, -0x1 | nop 1100 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L51; + } + +L65: + // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1101 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1102 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1103 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi03, vi04, L51 | nop 1104 + bc = (vu.vi03 == vu.vi04); + // nop | addx.w vf30, vf23, vf23 1105 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.x()); + if (bc) { + goto L51; + } + + // nop | addw.x vf30, vf21, vf21 1106 + vu.vf30.add(Mask::x, vu.vf21, vu.vf21.w()); + // div Q, vf30.x, vf30.w | nop 1107 + vu.Q = vu.vf30.x() / vu.vf30.w(); + // waitq | nop 1108 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1109 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1110 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1111 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf24, vf26 1112 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf26); + // nop | sub.xyzw vf29, vf27, vf29 1113 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf29); + // nop | sub.xyzw vf23, vf21, vf23 1114 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf23); + // iaddi vi06, vi06, 0x1 | nop 1115 + vu.vi06 = vu.vi06 + 1; + // sqi.xyzw vf26, vi04 | nop 1116 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1117 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L51 | nop 1118 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1119 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L51; + } + +L66: + // nop | sub.xyzw vf23, vf21, vf22 1120 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); + // nop | sub.xyzw vf26, vf24, vf25 1121 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf25); + // nop | sub.xyzw vf29, vf27, vf28 1122 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf28); + // nop | addx.w vf30, vf23, vf23 1123 + vu.vf30.add(Mask::w, vu.vf23, vu.vf23.x()); + // nop | addw.x vf30, vf22, vf22 1124 + vu.vf30.add(Mask::x, vu.vf22, vu.vf22.w()); + // div Q, vf30.x, vf30.w | nop 1125 + vu.Q = vu.vf30.x() / vu.vf30.w(); + // waitq | nop 1126 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1127 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1128 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1129 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | sub.xyzw vf26, vf25, vf26 1130 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf26); + // nop | sub.xyzw vf29, vf28, vf29 1131 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf29); + // nop | sub.xyzw vf23, vf22, vf23 1132 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); + // sqi.xyzw vf26, vi04 | nop 1133 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1134 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L51 | nop 1135 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1136 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L51; + } + +L67: + // BRANCH! + // b L53 | nop 1137 + bc = true; + // iaddi vi06, vi06, -0x1 | nop 1138 + vu.vi06 = vu.vi06 + -1; + if (bc) { + goto L53; + } + +L68: + // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1139 + vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1140 + vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1141 + vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + // BRANCH! + // ibeq vi03, vi04, L53 | nop 1142 + bc = (vu.vi03 == vu.vi04); + // nop | subx.w vf30, vf23, vf23 1143 + vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.x()); + if (bc) { + goto L53; + } + + // nop | subw.x vf30, vf21, vf21 1144 + vu.vf30.sub(Mask::x, vu.vf21, vu.vf21.w()); + // div Q, vf30.x, vf30.w | nop 1145 + vu.Q = vu.vf30.x() / vu.vf30.w(); + // waitq | nop 1146 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1147 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1148 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1149 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | add.xyzw vf26, vf24, vf26 1150 + vu.vf26.add(Mask::xyzw, vu.vf24, vu.vf26); + // nop | add.xyzw vf29, vf27, vf29 1151 + vu.vf29.add(Mask::xyzw, vu.vf27, vu.vf29); + // nop | add.xyzw vf23, vf21, vf23 1152 + vu.vf23.add(Mask::xyzw, vu.vf21, vu.vf23); + // iaddi vi06, vi06, 0x1 | nop 1153 + vu.vi06 = vu.vi06 + 1; + // sqi.xyzw vf26, vi04 | nop 1154 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1155 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L53 | nop 1156 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1157 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L53; + } + +L69: + // nop | sub.xyzw vf23, vf21, vf22 1158 + vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); + // nop | sub.xyzw vf26, vf24, vf25 1159 + vu.vf26.sub(Mask::xyzw, vu.vf24, vu.vf25); + // nop | sub.xyzw vf29, vf27, vf28 1160 + vu.vf29.sub(Mask::xyzw, vu.vf27, vu.vf28); + // nop | subx.w vf30, vf23, vf23 1161 + vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.x()); + // nop | subw.x vf30, vf22, vf22 1162 + vu.vf30.sub(Mask::x, vu.vf22, vu.vf22.w()); + // div Q, vf30.x, vf30.w | nop 1163 + vu.Q = vu.vf30.x() / vu.vf30.w(); + // waitq | nop 1164 + // ASSERT(false); + // nop | mul.xyzw vf26, vf26, Q 1165 + vu.vf26.mul(Mask::xyzw, vu.vf26, vu.Q); + // nop | mul.xyzw vf29, vf29, Q 1166 + vu.vf29.mul(Mask::xyzw, vu.vf29, vu.Q); + // nop | mul.xyzw vf23, vf23, Q 1167 + vu.vf23.mul(Mask::xyzw, vu.vf23, vu.Q); + // nop | add.xyzw vf26, vf25, vf26 1168 + vu.vf26.add(Mask::xyzw, vu.vf25, vu.vf26); + // nop | add.xyzw vf29, vf28, vf29 1169 + vu.vf29.add(Mask::xyzw, vu.vf28, vu.vf29); + // nop | add.xyzw vf23, vf22, vf23 1170 + vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); + // sqi.xyzw vf26, vi04 | nop 1171 + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + // sqi.xyzw vf29, vi04 | nop 1172 + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + // BRANCH! + // b L53 | nop 1173 + bc = true; + // sqi.xyzw vf23, vi04 | nop 1174 + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + if (bc) { + goto L53; + } +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/shaders/ocean_texture.frag b/game/graphics/opengl_renderer/shaders/ocean_texture.frag index 20fe614b9d..a6305cf3f7 100644 --- a/game/graphics/opengl_renderer/shaders/ocean_texture.frag +++ b/game/graphics/opengl_renderer/shaders/ocean_texture.frag @@ -8,5 +8,6 @@ uniform sampler2D tex_T0; void main() { vec4 tex = texture(tex_T0, tex_coord); - color = fragment_color * tex * 2; + tex.xyz *= 2; + color = fragment_color * tex; } \ No newline at end of file diff --git a/goal_src/engine/gfx/ocean/ocean-mid.gc b/goal_src/engine/gfx/ocean/ocean-mid.gc index e4ef7de88b..4846a1047f 100644 --- a/goal_src/engine/gfx/ocean/ocean-mid.gc +++ b/goal_src/engine/gfx/ocean/ocean-mid.gc @@ -982,6 +982,40 @@ (none) ) +(defun sphere-cull-for-ocean ((arg0 vector)) + "NOTE: added in PC port" + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf10 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf9 :class vf) + ) + (init-vf0-vector) + (let ((v1-5 *math-camera*)) + ;; note: these are for sphere cull. + (.lvf vf16 (&-> v1-5 plane 0 quad)) + (.lvf vf17 (&-> v1-5 plane 1 quad)) + (.lvf vf18 (&-> v1-5 plane 2 quad)) + (.lvf vf19 (&-> v1-5 plane 3 quad)) + ) + + (.lvf vf10 (&-> arg0 quad)) + (.mul.x.vf acc vf16 vf10) + (.add.mul.y.vf acc vf17 vf10 acc) + (.add.mul.z.vf acc vf18 vf10 acc) + (.sub.mul.w.vf vf9 vf19 vf0 acc) + (.add.w.vf vf9 vf9 vf10) + (.mov v1-0 vf9) + (.pcgtw v1-1 0 v1-0) + (.ppach v1-2 (the-as uint128 0) v1-1) + (zero? (the-as int v1-2)) + ) + ) + ;; definition for function draw-ocean-mid-seams ;; INFO: Return type mismatch symbol vs none. (defun draw-ocean-mid-seams ((arg0 dma-buffer)) @@ -1004,7 +1038,7 @@ (while (>= s2-0 s3-0) (set! (-> sv-36 x) (+ 196608.0 (* 393216.0 (the float s3-0)) (-> *ocean-map* start-corner x))) (set! (-> sv-36 z) (+ 196608.0 (* 393216.0 (the float s5-0)) (-> *ocean-map* start-corner z))) - (when (sphere-cull sv-36) + (when (sphere-cull-for-ocean sv-36) (cond ((= s5-0 sv-34) (ocean-mid-add-upload-top arg0 s5-0 s3-0) @@ -1060,6 +1094,7 @@ (ocean-mid-add-constants arg0) (ocean-mid-add-call arg0 0) (let ((v1-5 *math-camera*)) + ;; note: these are for sphere cull. (.lvf vf16 (&-> v1-5 plane 0 quad)) (.lvf vf17 (&-> v1-5 plane 1 quad)) (.lvf vf18 (&-> v1-5 plane 2 quad)) @@ -1077,14 +1112,19 @@ (s1-0 (-> *ocean-map* ocean-spheres spheres s2-0)) (s0-0 (-> (the-as (pointer int16) (+ (* s2-0 2) (the-as int (-> *ocean-map* ocean-mid-indices)))))) ) - (when (sphere-cull s1-0) + (when (sphere-cull-for-ocean s1-0) (cond ((< s0-0 0) ) - ((let ((f30-0 (- (vector-vector-distance s1-0 s5-0) (-> s1-0 w)))) + ( + + (let ((f30-0 (- (vector-vector-distance s1-0 s5-0) (-> s1-0 w)))) (ocean-mid-add-upload arg0 s4-0 s3-0 s0-0 s2-0 f30-0) (< f30-0 786432.0) + ;; HACK + ;; #t ) + (ocean-mid-add-call arg0 73) (+! (-> *terrain-stats* ocean-mid fragments) 1) (+! (-> *terrain-stats* ocean-mid tris) 256) @@ -1102,6 +1142,8 @@ ) ) ) + #| + ;; for now, skip seams. (when (not (or *ocean-near-off* (< 196608.0 (fabs (-> *math-camera* trans y))))) (let ((a1-11 48) (a2-2 0) @@ -1153,7 +1195,7 @@ (draw-ocean-mid-seams arg0) ) ) - ) + ) |# (ocean-mid-add-call-flush arg0 (the-as uint 41)) 0 (none) diff --git a/goal_src/engine/gfx/ocean/ocean.gc b/goal_src/engine/gfx/ocean/ocean.gc index ff82ea366e..affbb05562 100644 --- a/goal_src/engine/gfx/ocean/ocean.gc +++ b/goal_src/engine/gfx/ocean/ocean.gc @@ -667,7 +667,8 @@ ) ) ) - ; (when (not (or *ocean-near-off* (or *ocean-mid-off* (< 196608.0 (fabs (-> *math-camera* trans y)))))) + (when (not (or *ocean-near-off* (or *ocean-mid-off* (< 196608.0 (fabs (-> *math-camera* trans y)))))) + ; (format *stdcon* "draw near~%") ; (let* ((s5-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) ; (gp-2 (-> s5-1 base)) ; ) @@ -689,7 +690,7 @@ ; ) ; ) ; ) - ; ) + ) ) ) ) From 35eceed3e00f7addaa05e47ef83c7c523d9627bb Mon Sep 17 00:00:00 2001 From: water Date: Sun, 13 Mar 2022 15:27:25 -0400 Subject: [PATCH 2/6] fix some bugs --- common/util/colors.h | 2 +- decompiler/VuDisasm/VuDisassembler.cpp | 17 +- .../opengl_renderer/ocean/OceanMid.cpp | 37 +- .../graphics/opengl_renderer/ocean/OceanMid.h | 45 +- .../opengl_renderer/ocean/OceanMid_PS2.cpp | 1934 +++++++++++------ goal_src/engine/gfx/ocean/ocean-mid.gc | 231 +- 6 files changed, 1563 insertions(+), 703 deletions(-) diff --git a/common/util/colors.h b/common/util/colors.h index 96249ec155..4cde5560ef 100644 --- a/common/util/colors.h +++ b/common/util/colors.h @@ -5,7 +5,7 @@ namespace colors { // some reasonable colors that are different from each other constexpr int COLOR_COUNT = 131; -u32 common_colors[COLOR_COUNT] = { +constexpr u32 common_colors[COLOR_COUNT] = { 0xF0F8FE, 0xFAEBD7, 0x00FFFF, 0x70DB93, 0xF0FFFF, 0xF5F5DC, 0x000000, 0x0000FF, 0x9F5F9F, 0xB5A642, 0xD9D919, 0x8C7853, 0xA52A2A, 0x5F9EA0, 0xD2691E, 0xB87333, 0xFF7F50, 0xDC143C, 0x00FFFF, 0x00008B, 0x5C4033, 0x008B8B, 0xB8860B, 0xA9A9A9, 0x006400, 0xBDB76B, 0x8B008B, diff --git a/decompiler/VuDisasm/VuDisassembler.cpp b/decompiler/VuDisasm/VuDisassembler.cpp index 00f062bac1..67c071c41e 100644 --- a/decompiler/VuDisasm/VuDisassembler.cpp +++ b/decompiler/VuDisasm/VuDisassembler.cpp @@ -846,7 +846,9 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma } } else { - goto unknown; + return fmt::format("vu.{} = vu.{} | vu.{};", instr.dst->to_string(m_label_names), + instr.src.at(0).to_string(m_label_names), + instr.src.at(1).to_string(m_label_names)); } case VuInstrK::MFP: @@ -870,8 +872,7 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma bc_to_part(*instr.second_src_field)); case VuInstrK::ERLENG: - return fmt::format("vu.P = erleng(Mask::{}, vu.{}); /* TODO erleng */", - mask_to_string(*instr.mask), instr.src.at(0).to_string(m_label_names)); + return fmt::format("vu.P = erleng(vu.{});", instr.src.at(0).to_string(m_label_names)); case VuInstrK::RSQRT: return fmt::format( "c->Q = c->vf_src({}).vf.{}() / std::sqrt(c->vf_src({}).vf.{}());", @@ -896,8 +897,11 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma vf_src(instr.src.at(0).to_string(m_label_names), mips2c_format), vf_src(instr.src.at(1).to_string(m_label_names), mips2c_format)); case VuInstrK::FCAND: - return fmt::format("ASSERT(false); vu.vi01 = cf & 0x{:x};\n", instr.src.at(0).value()); - + return fmt::format("fcand(vu.vi01, 0x{:x}, cf);\n", instr.src.at(0).value()); + case VuInstrK::FCOR: + return fmt::format("fcor(vu.vi01, 0x{:x}, cf);\n", instr.src.at(0).value()); + case VuInstrK::FCSET: + return fmt::format("cf = 0x{:x};\n", instr.src.at(0).value()); case VuInstrK::ADDbc: case VuInstrK::SUBbc: case VuInstrK::MULbc: @@ -976,6 +980,9 @@ std::string VuDisassembler::to_cpp(const VuInstruction& instr, bool mips2c_forma return fmt::format("vu.acc.mula(Mask::{}, vu.{}, vu.{});", mask_to_string(*instr.mask), instr.src.at(0).to_string(m_label_names), instr.src.at(1).to_string(m_label_names)); + case VuInstrK::MULAq: + return fmt::format("vu.acc.mula(Mask::{}, vu.{}, vu.Q);", mask_to_string(*instr.mask), + instr.src.at(0).to_string(m_label_names)); case VuInstrK::MULAbc: return fmt::format(mips2c_format ? "c->acc.vf.mula(Mask::{}, c->vf_src({}).vf, c->vf_src({}).vf.{}());" diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.cpp b/game/graphics/opengl_renderer/ocean/OceanMid.cpp index 4149215a48..c07127e6c5 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid.cpp @@ -7,9 +7,9 @@ static bool is_end_tag(const DmaTag& tag, const VifCode& v0, const VifCode& v1) OceanMid::OceanMid() { for (auto& x : m_vu_data) { - x.fill(0); + x.fill(999.); } - vu.vf25 = Vf(1, 1, 1, 1); + vu.vf25 = Vf(1, 1, 1, 1); } void OceanMid::run(DmaFollower& dma, @@ -56,15 +56,16 @@ void OceanMid::run(DmaFollower& dma, if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && v1.kind == VifCode::Kind::UNPACK_V4_32) { auto up = VifCodeUnpack(v1); - ASSERT(up.use_tops_flag); - u16 addr = up.addr_qw + get_upload_buffer(); + // ASSERT(up.use_tops_flag); + u16 addr = up.addr_qw + (up.use_tops_flag ? get_upload_buffer() : 0); ASSERT(addr + v1.num <= 1024); - memcpy(m_vu_data + addr, data.data, 16 * v1.num); + memcpy(m_vu_data + addr, data.data, 16 * v1.num); ASSERT(16 * v1.num == data.size_bytes); } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && v1.kind == VifCode::Kind::UNPACK_V4_8) { auto up = VifCodeUnpack(v1); ASSERT(up.use_tops_flag); + ASSERT(up.is_unsigned); u16 addr = up.addr_qw + get_upload_buffer(); ASSERT(addr + v1.num <= 1024); @@ -73,7 +74,7 @@ void OceanMid::run(DmaFollower& dma, for (u32 j = 0; j < 4; j++) { temp[j] = data.data[4 * i + j]; } - memcpy(m_vu_data + addr + i, temp, 16); + memcpy(m_vu_data + addr + i, temp, 16); } // TODO @@ -81,6 +82,7 @@ void OceanMid::run(DmaFollower& dma, v1.kind == VifCode::Kind::UNPACK_V4_8) { auto up = VifCodeUnpack(v1); ASSERT(up.use_tops_flag); + ASSERT(up.is_unsigned); u16 addr = up.addr_qw + get_upload_buffer(); ASSERT(addr + v1.num <= 1024); @@ -89,34 +91,45 @@ void OceanMid::run(DmaFollower& dma, for (u32 j = 0; j < 4; j++) { temp[j] = data.data[4 * i + j]; } - u32 addr_off = 4 * i / 2 + i % 2; + // cl = 4 + // wl = 2 + u32 addr_off = 4 * (i / 2) + i % 2; memcpy(m_vu_data + addr + addr_off, temp, 16); } // TODO } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && v1.kind == VifCode::Kind::MSCALF) { - switch(v1.immediate) { + switch (v1.immediate) { case 46: run_call46_vu2c(render_state, prof, direct); break; case 73: run_call73_vu2c(render_state, prof, direct); break; + case 107: + run_call107_vu2c(render_state, prof, direct); + break; + case 275: + run_call275_vu2c(render_state, prof, direct); + break; default: - fmt::print("unknown call: {}\n", v1.immediate); + fmt::print("unknown call1: {}\n", v1.immediate); } // TODO } else if (v0.kind == VifCode::Kind::MSCALF && v1.kind == VifCode::Kind::FLUSHA) { - switch(v0.immediate) { + switch (v0.immediate) { case 41: + run_call41_vu2c(); + break; + case 43: + run_call43_vu2c(); break; default: - fmt::print("unknown call: {}\n", v0.immediate); + fmt::print("unknown call2: {}\n", v0.immediate); ASSERT(false); } - // TODO } diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.h b/game/graphics/opengl_renderer/ocean/OceanMid.h index 95ea7b7620..287f2b1b2e 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.h +++ b/game/graphics/opengl_renderer/ocean/OceanMid.h @@ -15,6 +15,8 @@ class OceanMid { private: void run_call0(); void run_call0_vu2c(); + void run_call41_vu2c(); + void run_call43_vu2c(); void run_call46_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); @@ -22,20 +24,47 @@ class OceanMid { void run_call73_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); + void run_call107_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_call275_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); void xgkick(u16 addr, SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); - void run_L24_vu2c(); - void run_L30_vu2c(); - void run_L36_vu2c(SharedRenderState* render_state, + + void run_L26_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); - void run_L41_vu2c(SharedRenderState* render_state, + void run_L32_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); - void run_L43_vu2c(); - + void run_L38_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_L43_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + void run_L45_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct); + // void run_L30_vu2c(); + // void run_L36_vu2c(SharedRenderState* render_state, + // ScopedProfilerNode& prof, + // DirectRenderer& direct); + // void run_L41_vu2c(SharedRenderState* render_state, + // ScopedProfilerNode& prof, + // DirectRenderer& direct); + // void run_L43_vu2c(); + // + // void run_L42_vu2c(SharedRenderState* render_state, + // ScopedProfilerNode& prof, + // DirectRenderer& direct); + // void run_L44_vu2c(SharedRenderState* render_state, + // ScopedProfilerNode& prof, + // DirectRenderer& direct); bool m_buffer_toggle = false; static constexpr int VU1_INPUT_BUFFER_BASE = 0; @@ -123,7 +152,7 @@ class OceanMid { Vf m_vu_data[1024]; - void sq_buffer(Mask mask, const Vf& val, u16 addr) { + void sq_buffer(int line_num, Mask mask, const Vf& val, u16 addr) { ASSERT(addr < 1024); for (int i = 0; i < 4; i++) { if ((u64)mask & (1 << i)) { @@ -188,7 +217,7 @@ class OceanMid { Vf vf01, vf02, vf03, vf04, vf05, vf06, vf07, vf08, vf09, vf10, vf11, vf12, vf13, vf14, vf15, vf16, vf17, vf18, vf19, vf20, vf21, vf22, vf23, vf24, vf25, vf26, vf27, vf28, vf29, vf30, vf31; - u16 vi01, vi02, vi03, vi04, vi05, vi06, vi07, vi08, vi09, vi10, vi11, vi12, vi13, vi14; + u16 vi01, vi02, vi03, vi04, vi05, vi06, vi07, vi08, vi09, vi10, vi11, vi12, vi13, vi14, vi15; float Q, P; Vu() : vf00(0, 0, 0, 1) {} } vu; diff --git a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp index f610d79c17..1e2f53ac45 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp @@ -1,13 +1,65 @@ #include "OceanMid.h" + +namespace { +u32 clip(const Vf& vector, float val, u32 old_clip) { + u32 result = (old_clip << 6); + float plus = std::abs(val); + float minus = -plus; + + if (vector.x() > plus) { + result |= 0b1; + } + if (vector.x() < minus) { + result |= 0b10; + } + + if (vector.y() > plus) { + result |= 0b100; + } + if (vector.y() < minus) { + result |= 0b1000; + } + + if (vector.z() > plus) { + result |= 0b10000; + } + if (vector.z() < minus) { + result |= 0b100000; + } + return result & 0xffffff; // only 24 bits +} void fcand(u16& dest, u32 imm, u32 cf) { - dest = (cf & imm) ? 1 : 0; + // dest = (cf & imm) ? 1 : 0; + if((cf & 0xFFFFFF) & (imm& 0xFFFFFF)) dest = 1; + else dest = 0; // dest = cf & imm; // wrong } void fcor(u16& dest, u32 imm, u32 cf) { - dest = (cf | imm) == imm ? 1 : 0; + // dest = ((0xffffff & (cf | imm)) == 0xffffff) ? 1 : 0; + u32 hold = (cf & 0xFFFFFF) | (imm & 0xFFFFFF); + if (hold == 0xFFFFFF) + dest = 1; + else + dest = 0; + // dest = cf | imm; } + +static inline REALLY_INLINE float erleng(const Vf& in) { + float len = in.x() * in.x() + in.y() * in.y() + in.z() * in.z(); + float res = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(len))); + return res; +} +} // namespace + +void OceanMid::xgkick(u16 addr, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + direct.render_gif((const u8*)&m_vu_data[addr], UINT32_MAX, render_state, prof); +} + void OceanMid::run_call0_vu2c() { bool bc; // lq.xyzw vf01, 733(vi00) | nop 0 @@ -30,13 +82,13 @@ void OceanMid::run_call0_vu2c() { // lq.xyzw vf21, 749(vi01) | nop 8 lq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 749); // sq.xyzw vf20, 335(vi01) | nop 9 - sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 335); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi01 + 335); // sq.xyzw vf20, 457(vi01) | nop 10 - sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 457); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi01 + 457); // sq.xyzw vf21, 396(vi01) | nop 11 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 396); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi01 + 396); // sq.xyzw vf21, 518(vi01) | nop 12 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 518); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi01 + 518); // BRANCH! // ibgtz vi01, L1 | nop 13 bc = ((s16)vu.vi01) > 0; @@ -57,7 +109,7 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 8; L3: // sq.xyzw vf16, 236(vi05) | nop 18 - sq_buffer(Mask::xyzw, vu.vf16, vu.vi05 + 236); + sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi05 + 236); // iaddi vi05, vi05, 0x1 | addw.x vf16, vf16, vf05 19 vu.vf16.add(Mask::x, vu.vf16, vu.vf05.w()); vu.vi05 = vu.vi05 + 1; @@ -92,10 +144,10 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 8; L4: // sq.xyzw vf20, 317(vi03) | nop 28 - sq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi03 + 317); // sq.xyzw vf21, 318(vi03) | addw.x vf20, vf20, vf00 29 vu.vf20.add(Mask::x, vu.vf20, vu.vf00.w()); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi03 + 318); // iaddi vi03, vi03, 0x2 | addw.x vf21, vf21, vf00 30 vu.vf21.add(Mask::x, vu.vf21, vu.vf00.w()); vu.vi03 = vu.vi03 + 2; @@ -117,9 +169,9 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 0x11; /* 17 */ L5: // sq.xyzw vf08, 396(vi04) | nop 36 - sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 396); + sq_buffer(__LINE__, Mask::xyzw, vu.vf08, vu.vi04 + 396); // sq.xyzw vf08, 518(vi04) | nop 37 - sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 518); + sq_buffer(__LINE__, Mask::xyzw, vu.vf08, vu.vi04 + 518); // iaddi vi04, vi04, 0x3 | nop 38 vu.vi04 = vu.vi04 + 3; // BRANCH! @@ -131,7 +183,7 @@ void OceanMid::run_call0_vu2c() { goto L5; } - // JUMP_41: +JUMP_41: // nop | nop :e 41 // nop | nop 42 @@ -139,6 +191,26 @@ void OceanMid::run_call0_vu2c() { return; } +void OceanMid::run_call41_vu2c() { +JUMP_41: + // nop | nop :e 41 + + // nop | nop 42 + + return; +} + +void OceanMid::run_call43_vu2c() { +JUMP_43: + // iaddiu vi10, vi00, 0x243 | nop 43 + vu.vi10 = 0x243; /* 579 */ + // nop | nop :e 44 + + // nop | nop 45 + + return; +} + void OceanMid::run_call46_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { @@ -157,9 +229,9 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, // lq.xyzw vf15, 7(vi02) | nop 51 lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); // sq.xyzw vf07, 341(vi00) | nop 52 - sq_buffer(Mask::xyzw, vu.vf07, 341); + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 341); // sq.xyzw vf07, 463(vi00) | nop 53 - sq_buffer(Mask::xyzw, vu.vf07, 463); + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 463); // iaddi vi07, vi00, 0x7 | nop 54 vu.vi07 = 7; // lq.xyzw vf04, 116(vi02) | nop 55 @@ -193,11 +265,13 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, } // BRANCH! - // bal vi15, L24 | nop 64 + // bal vi15, L26 | nop 64 // ASSERT(false); - run_L24_vu2c(); // nop | nop 65 + // if (bc) { goto L26; } + run_L26_vu2c(render_state, prof, direct); + // iaddiu vi01, vi00, 0x318 | nop 66 vu.vi01 = 0x318; /* 792 */ // xgkick vi09 | nop 67 @@ -221,41 +295,834 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, return; } -namespace { -u32 clip(const Vf& vector, float val, u32 old_clip) { - u32 result = (old_clip << 6); - float plus = std::abs(val); - float minus = -plus; +void OceanMid::run_call73_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc; +JUMP_73: + // xtop vi02 | nop 73 + vu.vi02 = xtop(); + // lq.xyzw vf07, 747(vi00) | nop 74 + lq_buffer(Mask::xyzw, vu.vf07, 747); + // lq.xyzw vf08, 0(vi02) | nop 75 + lq_buffer(Mask::xyzw, vu.vf08, vu.vi02); + // lq.xyzw vf09, 1(vi02) | nop 76 + lq_buffer(Mask::xyzw, vu.vf09, vu.vi02 + 1); + // lq.xyzw vf10, 2(vi02) | nop 77 + lq_buffer(Mask::xyzw, vu.vf10, vu.vi02 + 2); + // lq.xyzw vf11, 3(vi02) | nop 78 + lq_buffer(Mask::xyzw, vu.vf11, vu.vi02 + 3); + // lq.xyzw vf12, 4(vi02) | nop 79 + lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); + // lq.xyzw vf13, 5(vi02) | nop 80 + lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); + // lq.xyzw vf14, 6(vi02) | nop 81 + lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); + // lq.xyzw vf15, 7(vi02) | nop 82 + lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); + // sq.xyzw vf07, 341(vi00) | nop 83 + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 341); + // sq.xyzw vf07, 463(vi00) | nop 84 + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 463); + // iaddi vi07, vi00, 0x7 | nop 85 + vu.vi07 = 7; + // lq.xyzw vf04, 116(vi02) | nop 86 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 116); +L13: + // iaddi vi01, vi07, -0x4 | nop 87 + vu.vi01 = vu.vi07 + -4; + // mtir vi10, vf04.x | nop 88 + vu.vi10 = vu.vf04.x_as_u16(); + // iaddiu vi11, vi00, 0xff | nop 89 + vu.vi11 = 0xff; /* 255 */ + // BRANCH! + // ibne vi00, vi01, L14 | nop 90 + bc = (vu.vi01 != 0); + // mr32.xyzw vf04, vf04 | nop 91 + vu.vf04.mr32(Mask::xyzw, vu.vf04); + if (bc) { + goto L14; + } - if (vector.x() > plus) { - result |= 0b1; + // lq.xyzw vf04, 117(vi02) | nop 92 + lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 117); +L14: + // BRANCH! + // ibeq vi11, vi10, L15 | nop 93 + bc = (vu.vi11 == vu.vi10); + // iaddi vi08, vi09, 0x7 | nop 94 + vu.vi08 = vu.vi09 + 7; + if (bc) { + goto L15; } - if (vector.x() < minus) { - result |= 0b10; + + // BRANCH! + // bal vi15, L32 | nop 95 + // ASSERT(false); + // nop | nop 96 + + // if (bc) { goto L32; } + run_L32_vu2c(render_state, prof, direct); + + // iaddiu vi01, vi00, 0x318 | nop 97 + vu.vi01 = 0x318; /* 792 */ + // xgkick vi09 | nop 98 + xgkick(vu.vi09, render_state, prof, direct); // draws envmapped ocean + // BRANCH! + // ibeq vi00, vi14, L15 | nop 99 + bc = (vu.vi14 == 0); + // isub vi09, vi01, vi09 | nop 100 + vu.vi09 = vu.vi01 - vu.vi09; + if (bc) { + goto L15; } - if (vector.y() > plus) { - result |= 0b100; + // BRANCH! + // bal vi15, L38 | nop 101 + // ASSERT(false); + // nop | nop 102 + + // if (bc) { goto L38; } + run_L38_vu2c(render_state, prof, direct); + +L15: + // BRANCH! + // ibgtz vi07, L13 | nop 103 + bc = ((s16)vu.vi07) > 0; + // iaddi vi07, vi07, -0x1 | nop 104 + vu.vi07 = vu.vi07 + -1; + if (bc) { + goto L13; } - if (vector.y() < minus) { - result |= 0b1000; + + // nop | nop :e 105 + + // nop | nop 106 + + return; +} + +void OceanMid::run_call107_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc; +JUMP_107: + // xtop vi02 | nop 107 + vu.vi02 = xtop(); + // xtop vi03 | nop 108 + vu.vi03 = xtop(); + // ior vi04, vi00, vi00 | nop 109 + vu.vi04 = 0; + // ilw.x vi05, 8(vi02) | nop 110 + ilw_buffer(Mask::x, vu.vi05, vu.vi02 + 8); + // lq.xyzw vf08, 0(vi02) | nop 111 + lq_buffer(Mask::xyzw, vu.vf08, vu.vi02); + // lq.xyzw vf09, 1(vi02) | nop 112 + lq_buffer(Mask::xyzw, vu.vf09, vu.vi02 + 1); + // lq.xyzw vf10, 2(vi02) | nop 113 + lq_buffer(Mask::xyzw, vu.vf10, vu.vi02 + 2); + // lq.xyzw vf11, 3(vi02) | nop 114 + lq_buffer(Mask::xyzw, vu.vf11, vu.vi02 + 3); + // lq.xyzw vf12, 4(vi02) | nop 115 + lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); + // lq.xyzw vf13, 5(vi02) | nop 116 + lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); + // lq.xyzw vf14, 6(vi02) | nop 117 + lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); + // lq.xyzw vf15, 7(vi02) | nop 118 + lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); +L17: + // lq.xyzw vf16, 17(vi03) | nop 119 + lq_buffer(Mask::xyzw, vu.vf16, vu.vi03 + 17); + // lq.xyzw vf28, 765(vi00) | nop 120 + lq_buffer(Mask::xyzw, vu.vf28, 765); + // lq.xyzw vf29, 766(vi00) | nop 121 + lq_buffer(Mask::xyzw, vu.vf29, 766); + // lq.xyzw vf30, 767(vi00) | nop 122 + lq_buffer(Mask::xyzw, vu.vf30, 767); + // lq.xyzw vf31, 768(vi00) | nop 123 + lq_buffer(Mask::xyzw, vu.vf31, 768); + // lq.xyzw vf24, 9(vi02) | mulax.xyzw ACC, vf28, vf16 124 + vu.acc.mula(Mask::xyzw, vu.vf28, vu.vf16.x()); + lq_buffer(Mask::xyzw, vu.vf24, vu.vi02 + 9); + // lq.xyzw vf25, 10(vi02) | madday.xyzw ACC, vf29, vf16 125 + vu.acc.madda(Mask::xyzw, vu.vf29, vu.vf16.y()); + lq_buffer(Mask::xyzw, vu.vf25, vu.vi02 + 10); + // lq.xyzw vf26, 11(vi02) | maddaz.xyzw ACC, vf30, vf16 126 + vu.acc.madda(Mask::xyzw, vu.vf30, vu.vf16.z()); + lq_buffer(Mask::xyzw, vu.vf26, vu.vi02 + 11); + // lq.xyzw vf27, 12(vi02) | maddw.xyzw vf28, vf31, vf16 127 + vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf31, vu.vf16.w()); + lq_buffer(Mask::xyzw, vu.vf27, vu.vi02 + 12); + // lq.xyzw vf22, 13(vi02) | mulax.xyzw ACC, vf24, vf16 128 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf16.x()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi02 + 13); + // lq.xyzw vf23, 14(vi02) | madday.xyzw ACC, vf25, vf16 129 + vu.acc.madda(Mask::xyzw, vu.vf25, vu.vf16.y()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi02 + 14); + // lq.xyzw vf18, 15(vi02) | maddaz.xyzw ACC, vf26, vf16 130 + vu.acc.madda(Mask::xyzw, vu.vf26, vu.vf16.z()); + lq_buffer(Mask::xyzw, vu.vf18, vu.vi02 + 15); + // lq.xyzw vf19, 16(vi02) | maddw.xyzw vf20, vf27, vf16 131 + vu.acc.madd(Mask::xyzw, vu.vf20, vu.vf27, vu.vf16.w()); + lq_buffer(Mask::xyzw, vu.vf19, vu.vi02 + 16); + // iaddi vi05, vi05, -0x1 | mulax.xyzw ACC, vf08, vf28 132 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + vu.vi05 = vu.vi05 + -1; + // nop | madday.xyzw ACC, vf09, vf28 133 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf10, vf28 134 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + // nop | maddw.xyzw vf24, vf11, vf00 135 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf11, vu.vf00.w()); + // nop | mulax.xyzw ACC, vf12, vf28 136 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + // nop | madday.xyzw ACC, vf13, vf28 137 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf14, vf28 138 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + // erleng.xyz P, vf24 | maddw.xyzw vf28, vf15, vf00 139 + vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf15, vu.vf00.w()); + vu.P = erleng(vu.vf24); + // waitp | addz.y vf24, vf00, vf24 140 + vu.vf24.add(Mask::y, vu.vf00, vu.vf24.z()); + // nop | mul.xyzw vf28, vf28, vf01 141 + vu.vf28.mul(Mask::xyzw, vu.vf28, vu.vf01); + // mfp.w vf24, P | mulax.xyzw ACC, vf22, vf16 142 + vu.acc.mula(Mask::xyzw, vu.vf22, vu.vf16.x()); + vu.vf24.mfp(Mask::w, vu.P); + // iaddi vi03, vi03, 0x1 | madday.xyzw ACC, vf23, vf16 143 + vu.acc.madda(Mask::xyzw, vu.vf23, vu.vf16.y()); + vu.vi03 = vu.vi03 + 1; + // nop | maddaz.xyzw ACC, vf18, vf16 144 + vu.acc.madda(Mask::xyzw, vu.vf18, vu.vf16.z()); + // sq.xyzw vf20, 791(vi04) | maddw.xyzw vf22, vf19, vf16 145 + vu.acc.madd(Mask::xyzw, vu.vf22, vu.vf19, vu.vf16.w()); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi04 + 791); + // sq.xyzw vf28, 793(vi04) | mulw.xy vf24, vf24, vf24 146 + vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi04 + 793); + // sq.xyzw vf22, 792(vi04) | mula.xyzw ACC, vf24, vf05 147 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi04 + 792); + // iaddi vi04, vi04, 0x4 | maddw.xyzw vf24, vf06, vf00 148 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); + vu.vi04 = vu.vi04 + 4; + // BRANCH! + // ibgtz vi05, L17 | nop 149 + bc = ((s16)vu.vi05) > 0; + // sq.xyzw vf24, 790(vi04) | nop 150 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04 + 790); + if (bc) { + goto L17; } - if (vector.z() > plus) { - result |= 0b10000; + // ior vi14, vi00, vi00 | nop 151 + vu.vi14 = 0; + // lq.xyzw vf31, 734(vi00) | nop 152 + lq_buffer(Mask::xyzw, vu.vf31, 734); + // ilw.x vi11, 8(vi02) | nop 153 + ilw_buffer(Mask::x, vu.vi11, vu.vi02 + 8); + // ilw.y vi07, 8(vi02) | nop 154 + ilw_buffer(Mask::y, vu.vi07, vu.vi02 + 8); + // iaddi vi15, vi00, 0x1 | nop 155 + vu.vi15 = 1; + // lq.xyzw vf28, 741(vi00) | nop 156 + lq_buffer(Mask::xyzw, vu.vf28, 741); + // lq.xyzw vf29, 742(vi00) | nop 157 + lq_buffer(Mask::xyzw, vu.vf29, 742); + // lq.xyzw vf30, 743(vi00) | nop 158 + lq_buffer(Mask::xyzw, vu.vf30, 743); + // lq.xyzw vf24, 744(vi00) | nop 159 + lq_buffer(Mask::xyzw, vu.vf24, 744); + // lq.xyzw vf25, 745(vi00) | nop 160 + lq_buffer(Mask::xyzw, vu.vf25, 745); + // lq.xyzw vf26, 746(vi00) | nop 161 + lq_buffer(Mask::xyzw, vu.vf26, 746); + // lq.xyzw vf07, 739(vi00) | nop 162 + lq_buffer(Mask::xyzw, vu.vf07, 739); + // sq.xyzw vf28, 579(vi00) | nop 163 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 579); + // sq.xyzw vf29, 580(vi00) | nop 164 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 580); + // sq.xyzw vf30, 581(vi00) | nop 165 + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 581); + // sq.xyzw vf24, 582(vi00) | nop 166 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 582); + // sq.xyzw vf25, 583(vi00) | nop 167 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 583); + // sq.xyzw vf26, 584(vi00) | nop 168 + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 584); + // sq.xyzw vf28, 656(vi00) | nop 169 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 656); + // sq.xyzw vf29, 657(vi00) | nop 170 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 657); + // sq.xyzw vf30, 658(vi00) | nop 171 + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 658); + // sq.xyzw vf24, 659(vi00) | nop 172 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 659); + // sq.xyzw vf25, 660(vi00) | nop 173 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 660); + // sq.xyzw vf26, 661(vi00) | nop 174 + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 661); + // iaddi vi11, vi11, -0x2 | nop 175 + vu.vi11 = vu.vi11 + -2; +L18: + // iand vi01, vi07, vi15 | nop 176 + vu.vi01 = vu.vi07 & vu.vi15; + // iaddi vi11, vi11, -0x2 | nop 177 + vu.vi11 = vu.vi11 + -2; + // BRANCH! + // ibne vi00, vi01, L19 | nop 178 + bc = (vu.vi01 != 0); + // iadd vi15, vi15, vi15 | nop 179 + vu.vi15 = vu.vi15 + vu.vi15; + if (bc) { + goto L19; } - if (vector.z() < minus) { - result |= 0b100000; + + // iaddi vi08, vi10, 0x7 | nop 180 + vu.vi08 = vu.vi10 + 7; + // iaddi vi03, vi10, 0x7 | nop 181 + vu.vi03 = vu.vi10 + 7; + // iaddi vi05, vi00, 0x4 | nop 182 + vu.vi05 = 4; + // lq.xyzw vf20, 791(vi14) | nop 183 + lq_buffer(Mask::xyzw, vu.vf20, vu.vi14 + 791); + // lq.xyzw vf22, 792(vi14) | nop 184 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi14 + 792); + // lq.xyzw vf28, 793(vi14) | nop 185 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi14 + 793); + // lq.xyzw vf21, 795(vi14) | nop 186 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi14 + 795); + // lq.xyzw vf23, 796(vi14) | nop 187 + lq_buffer(Mask::xyzw, vu.vf23, vu.vi14 + 796); + // lq.xyzw vf29, 797(vi14) | nop 188 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 797); + // sq.xyzw vf20, 0(vi08) | nop 189 + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf22, 1(vi08) | nop 190 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 191 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf21, 3(vi08) | nop 192 + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + // sq.xyzw vf23, 4(vi08) | nop 193 + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + // sq.xyzw vf29, 5(vi08) | nop 194 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + // sq.xyzw vf20, 12(vi08) | nop 195 + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 12); + // sq.xyzw vf22, 13(vi08) | nop 196 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 13); + // sq.xyzw vf28, 14(vi08) | nop 197 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 14); + // lq.xyzw vf20, 803(vi14) | nop 198 + lq_buffer(Mask::xyzw, vu.vf20, vu.vi14 + 803); + // lq.xyzw vf22, 804(vi14) | nop 199 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi14 + 804); + // lq.xyzw vf28, 805(vi14) | nop 200 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi14 + 805); + // lq.xyzw vf21, 799(vi14) | nop 201 + lq_buffer(Mask::xyzw, vu.vf21, vu.vi14 + 799); + // lq.xyzw vf23, 800(vi14) | nop 202 + lq_buffer(Mask::xyzw, vu.vf23, vu.vi14 + 800); + // lq.xyzw vf29, 801(vi14) | nop 203 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 801); + // sq.xyzw vf20, 6(vi08) | nop 204 + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 6); + // sq.xyzw vf22, 7(vi08) | nop 205 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); + // sq.xyzw vf28, 8(vi08) | nop 206 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 8); + // sq.xyzw vf21, 9(vi08) | nop 207 + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 9); + // sq.xyzw vf23, 10(vi08) | nop 208 + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 10); + // BRANCH! + // bal vi13, L45 | nop 209 + // ASSERT(false); + // sq.xyzw vf29, 11(vi08) | nop 210 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 11); + // if (bc) { goto L45; } + run_L45_vu2c(render_state, prof, direct); + + // BRANCH! + // ibeq vi00, vi05, L19 | nop 211 + bc = (vu.vi05 == 0); + // iaddiu vi06, vi05, 0x4000 | nop 212 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + if (bc) { + goto L19; } - return result & 0xffffff; // only 24 bits + + // BRANCH! + // bal vi13, L43 | nop 213 + // ASSERT(false); + // iaddiu vi06, vi06, 0x4000 | nop 214 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + // if (bc) { goto L43; } + run_L43_vu2c(render_state, prof, direct); + +L19: + // BRANCH! + // ibgtz vi11, L18 | nop 215 + bc = ((s16)vu.vi11) > 0; + // iaddi vi14, vi14, 0x8 | nop 216 + vu.vi14 = vu.vi14 + 8; + if (bc) { + goto L18; + } + + // ior vi14, vi00, vi00 | nop 217 + vu.vi14 = 0; + // ilw.x vi11, 8(vi02) | nop 218 + ilw_buffer(Mask::x, vu.vi11, vu.vi02 + 8); + // ilw.y vi07, 8(vi02) | nop 219 + ilw_buffer(Mask::y, vu.vi07, vu.vi02 + 8); + // iaddi vi15, vi00, 0x1 | nop 220 + vu.vi15 = 1; + // lq.xyzw vf07, 740(vi00) | nop 221 + lq_buffer(Mask::xyzw, vu.vf07, 740); + // iaddi vi11, vi11, -0x2 | nop 222 + vu.vi11 = vu.vi11 + -2; +L20: + // iand vi01, vi07, vi15 | nop 223 + vu.vi01 = vu.vi07 & vu.vi15; + // iaddi vi11, vi11, -0x2 | nop 224 + vu.vi11 = vu.vi11 + -2; + // BRANCH! + // ibne vi00, vi01, L21 | nop 225 + bc = (vu.vi01 != 0); + // iadd vi15, vi15, vi15 | nop 226 + vu.vi15 = vu.vi15 + vu.vi15; + if (bc) { + goto L21; + } + + // iaddi vi08, vi10, 0x7 | nop 227 + vu.vi08 = vu.vi10 + 7; + // iaddi vi03, vi10, 0x7 | nop 228 + vu.vi03 = vu.vi10 + 7; + // iaddi vi05, vi00, 0x4 | nop 229 + vu.vi05 = 4; + // lq.xyzw vf24, 794(vi14) | nop 230 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi14 + 794); + // lq.xyzw vf22, 756(vi00) | nop 231 + lq_buffer(Mask::xyzw, vu.vf22, 756); + // lq.xyzw vf28, 793(vi14) | nop 232 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi14 + 793); + // lq.xyzw vf25, 798(vi14) | nop 233 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi14 + 798); + // lq.xyzw vf29, 797(vi14) | nop 234 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 797); + // sq.xyzw vf24, 0(vi08) | nop 235 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + // sq.xyzw vf22, 1(vi08) | nop 236 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 237 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf25, 3(vi08) | nop 238 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 3); + // sq.xyzw vf22, 4(vi08) | nop 239 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 4); + // sq.xyzw vf29, 5(vi08) | nop 240 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + // sq.xyzw vf24, 12(vi08) | nop 241 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 12); + // sq.xyzw vf22, 13(vi08) | nop 242 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 13); + // sq.xyzw vf28, 14(vi08) | nop 243 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 14); + // lq.xyzw vf24, 806(vi14) | nop 244 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi14 + 806); + // lq.xyzw vf28, 805(vi14) | nop 245 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi14 + 805); + // lq.xyzw vf25, 802(vi14) | nop 246 + lq_buffer(Mask::xyzw, vu.vf25, vu.vi14 + 802); + // lq.xyzw vf29, 801(vi14) | nop 247 + lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 801); + // sq.xyzw vf24, 6(vi08) | nop 248 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 6); + // sq.xyzw vf22, 7(vi08) | nop 249 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); + // sq.xyzw vf28, 8(vi08) | nop 250 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 8); + // sq.xyzw vf25, 9(vi08) | nop 251 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 9); + // sq.xyzw vf22, 10(vi08) | nop 252 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); + // BRANCH! + // bal vi13, L45 | nop 253 + // ASSERT(false); + // sq.xyzw vf29, 11(vi08) | nop 254 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 11); + // if (bc) { goto L45; } + run_L45_vu2c(render_state, prof, direct); + + // lq.xyzw vf28, 749(vi00) | nop 255 + lq_buffer(Mask::xyzw, vu.vf28, 749); + // BRANCH! + // ibeq vi00, vi05, L21 | nop 256 + bc = (vu.vi05 == 0); + // lq.xyzw vf29, 750(vi00) | nop 257 + lq_buffer(Mask::xyzw, vu.vf29, 750); + if (bc) { + goto L21; + } + + // lq.xyzw vf30, 751(vi00) | nop 258 + lq_buffer(Mask::xyzw, vu.vf30, 751); + // lq.xyzw vf24, 752(vi00) | nop 259 + lq_buffer(Mask::xyzw, vu.vf24, 752); + // lq.xyzw vf25, 753(vi00) | nop 260 + lq_buffer(Mask::xyzw, vu.vf25, 753); + // lq.xyzw vf26, 754(vi00) | nop 261 + lq_buffer(Mask::xyzw, vu.vf26, 754); + // sq.xyzw vf28, 0(vi10) | nop 262 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + // sq.xyzw vf29, 1(vi10) | nop 263 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + // sq.xyzw vf30, 2(vi10) | nop 264 + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + // sq.xyzw vf24, 3(vi10) | nop 265 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + // sq.xyzw vf25, 4(vi10) | nop 266 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + // sq.xyzw vf26, 5(vi10) | nop 267 + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + // iaddiu vi06, vi05, 0x4000 | nop 268 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + // BRANCH! + // bal vi13, L43 | nop 269 + // ASSERT(false); + // iaddiu vi06, vi06, 0x4000 | nop 270 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + // if (bc) { goto L43; } + run_L43_vu2c(render_state, prof, direct); + +L21: + // BRANCH! + // ibgtz vi11, L20 | nop 271 + bc = ((s16)vu.vi11) > 0; + // iaddi vi14, vi14, 0x8 | nop 272 + vu.vi14 = vu.vi14 + 8; + if (bc) { + goto L20; + } + + // nop | nop :e 273 + + // nop | nop 274 + + return; } -} // namespace -void OceanMid::run_L24_vu2c() { +void OceanMid::run_call275_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { bool bc; - u32 cf = 0; + // fmt::print("call 275\n"); +JUMP_275: + // xtop vi02 | nop 275 + vu.vi02 = xtop(); + // xtop vi03 | nop 276 + vu.vi03 = xtop(); + // ior vi04, vi00, vi00 | nop 277 + vu.vi04 = 0; + // iaddi vi08, vi10, 0x7 | nop 278 + vu.vi08 = vu.vi10 + 7; + // ilw.x vi05, 8(vi02) | nop 279 + ilw_buffer(Mask::x, vu.vi05, vu.vi02 + 8); + // lq.xyzw vf08, 0(vi02) | nop 280 + lq_buffer(Mask::xyzw, vu.vf08, vu.vi02); + // lq.xyzw vf09, 1(vi02) | nop 281 + lq_buffer(Mask::xyzw, vu.vf09, vu.vi02 + 1); + // lq.xyzw vf10, 2(vi02) | nop 282 + lq_buffer(Mask::xyzw, vu.vf10, vu.vi02 + 2); + // lq.xyzw vf11, 3(vi02) | nop 283 + lq_buffer(Mask::xyzw, vu.vf11, vu.vi02 + 3); + // lq.xyzw vf12, 4(vi02) | nop 284 + lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); + // lq.xyzw vf13, 5(vi02) | nop 285 + lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); + // lq.xyzw vf14, 6(vi02) | nop 286 + lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); + // lq.xyzw vf15, 7(vi02) | nop 287 + lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); +L23: + // lq.xyzw vf16, 17(vi03) | nop 288 + lq_buffer(Mask::xyzw, vu.vf16, vu.vi03 + 17); + // lq.xyzw vf28, 765(vi00) | nop 289 + lq_buffer(Mask::xyzw, vu.vf28, 765); + // lq.xyzw vf29, 766(vi00) | nop 290 + lq_buffer(Mask::xyzw, vu.vf29, 766); + // lq.xyzw vf30, 767(vi00) | nop 291 + lq_buffer(Mask::xyzw, vu.vf30, 767); + // lq.xyzw vf31, 768(vi00) | nop 292 + lq_buffer(Mask::xyzw, vu.vf31, 768); + // lq.xyzw vf24, 9(vi02) | mulax.xyzw ACC, vf28, vf16 293 + vu.acc.mula(Mask::xyzw, vu.vf28, vu.vf16.x()); + lq_buffer(Mask::xyzw, vu.vf24, vu.vi02 + 9); + // lq.xyzw vf25, 10(vi02) | madday.xyzw ACC, vf29, vf16 294 + vu.acc.madda(Mask::xyzw, vu.vf29, vu.vf16.y()); + lq_buffer(Mask::xyzw, vu.vf25, vu.vi02 + 10); + // lq.xyzw vf26, 11(vi02) | maddaz.xyzw ACC, vf30, vf16 295 + vu.acc.madda(Mask::xyzw, vu.vf30, vu.vf16.z()); + lq_buffer(Mask::xyzw, vu.vf26, vu.vi02 + 11); + // lq.xyzw vf27, 12(vi02) | maddw.xyzw vf28, vf31, vf16 296 + vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf31, vu.vf16.w()); + lq_buffer(Mask::xyzw, vu.vf27, vu.vi02 + 12); + // lq.xyzw vf22, 13(vi02) | mulax.xyzw ACC, vf24, vf16 297 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf16.x()); + lq_buffer(Mask::xyzw, vu.vf22, vu.vi02 + 13); + // lq.xyzw vf23, 14(vi02) | madday.xyzw ACC, vf25, vf16 298 + vu.acc.madda(Mask::xyzw, vu.vf25, vu.vf16.y()); + lq_buffer(Mask::xyzw, vu.vf23, vu.vi02 + 14); + // lq.xyzw vf18, 15(vi02) | maddaz.xyzw ACC, vf26, vf16 299 + vu.acc.madda(Mask::xyzw, vu.vf26, vu.vf16.z()); + lq_buffer(Mask::xyzw, vu.vf18, vu.vi02 + 15); + // lq.xyzw vf19, 16(vi02) | maddw.xyzw vf20, vf27, vf16 300 + vu.acc.madd(Mask::xyzw, vu.vf20, vu.vf27, vu.vf16.w()); + lq_buffer(Mask::xyzw, vu.vf19, vu.vi02 + 16); + // iaddi vi05, vi05, -0x1 | mulax.xyzw ACC, vf08, vf28 301 + vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf28.x()); + vu.vi05 = vu.vi05 + -1; + // nop | madday.xyzw ACC, vf09, vf28 302 + vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf10, vf28 303 + vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); + // nop | maddw.xyzw vf24, vf11, vf00 304 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf11, vu.vf00.w()); + // nop | mulax.xyzw ACC, vf12, vf28 305 + vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); + // nop | madday.xyzw ACC, vf13, vf28 306 + vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); + // nop | maddaz.xyzw ACC, vf14, vf28 307 + vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); + // erleng.xyz P, vf24 | maddw.xyzw vf28, vf15, vf00 308 + vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf15, vu.vf00.w()); + vu.P = erleng(vu.vf24); + // waitp | addz.y vf24, vf00, vf24 309 + vu.vf24.add(Mask::y, vu.vf00, vu.vf24.z()); + // nop | mul.xyzw vf28, vf28, vf01 310 + vu.vf28.mul(Mask::xyzw, vu.vf28, vu.vf01); + // mfp.w vf24, P | mulax.xyzw ACC, vf22, vf16 311 + vu.acc.mula(Mask::xyzw, vu.vf22, vu.vf16.x()); + vu.vf24.mfp(Mask::w, vu.P); + // iaddi vi03, vi03, 0x1 | madday.xyzw ACC, vf23, vf16 312 + vu.acc.madda(Mask::xyzw, vu.vf23, vu.vf16.y()); + vu.vi03 = vu.vi03 + 1; + // nop | maddaz.xyzw ACC, vf18, vf16 313 + vu.acc.madda(Mask::xyzw, vu.vf18, vu.vf16.z()); + // sq.xyzw vf20, 0(vi08) | maddw.xyzw vf22, vf19, vf16 314 + vu.acc.madd(Mask::xyzw, vu.vf22, vu.vf19, vu.vf16.w()); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf28, 2(vi08) | mulw.xy vf24, vf24, vf24 315 + vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf28, 792(vi04) | nop 316 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi04 + 792); + // sq.xyzw vf22, 1(vi08) | mula.xyzw ACC, vf24, vf05 317 + vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // iaddi vi04, vi04, 0x2 | maddw.xyzw vf24, vf06, vf00 318 + vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); + vu.vi04 = vu.vi04 + 2; + // iaddi vi08, vi08, 0x3 | nop 319 + vu.vi08 = vu.vi08 + 3; + // BRANCH! + // ibgtz vi05, L23 | nop 320 + bc = ((s16)vu.vi05) > 0; + // sq.xyzw vf24, 789(vi04) | nop 321 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04 + 789); + if (bc) { + goto L23; + } + + // lq.xyzw vf31, 734(vi00) | nop 322 + lq_buffer(Mask::xyzw, vu.vf31, 734); + // ilw.x vi05, 8(vi02) | nop 323 + ilw_buffer(Mask::x, vu.vi05, vu.vi02 + 8); + // fmt::print("loaded vi05: {}\n", vu.vi05); + // lq.xyzw vf20, 7(vi10) | nop 324 + lq_buffer(Mask::xyzw, vu.vf20, vu.vi10 + 7); + // lq.xyzw vf22, 8(vi10) | nop 325 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi10 + 8); + // lq.xyzw vf28, 9(vi10) | nop 326 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi10 + 9); + // sq.xyzw vf20, 0(vi08) | nop 327 + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + // sq.xyzw vf22, 1(vi08) | nop 328 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 329 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // iaddi vi08, vi10, 0x7 | nop 330 + vu.vi08 = vu.vi10 + 7; + // BRANCH! + // bal vi13, L45 | nop 331 + // ASSERT(false); + // iaddi vi03, vi10, 0x7 | nop 332 + vu.vi03 = vu.vi10 + 7; + // if (bc) { goto L45; } + run_L45_vu2c(render_state, prof, direct); + // lq.xyzw vf28, 741(vi00) | nop 333 + lq_buffer(Mask::xyzw, vu.vf28, 741); + // BRANCH! + // ibeq vi00, vi05, L25 | nop 334 + // fmt::print("vu.vi05 = {}\n", vu.vi05); + bc = (vu.vi05 == 0); + // lq.xyzw vf29, 742(vi00) | nop 335 + lq_buffer(Mask::xyzw, vu.vf29, 742); + if (bc) { + goto L25; + } + + // lq.xyzw vf30, 743(vi00) | nop 336 + lq_buffer(Mask::xyzw, vu.vf30, 743); + // lq.xyzw vf24, 744(vi00) | nop 337 + lq_buffer(Mask::xyzw, vu.vf24, 744); + // lq.xyzw vf25, 745(vi00) | nop 338 + lq_buffer(Mask::xyzw, vu.vf25, 745); + // lq.xyzw vf26, 746(vi00) | nop 339 + lq_buffer(Mask::xyzw, vu.vf26, 746); + // lq.xyzw vf07, 739(vi00) | nop 340 + lq_buffer(Mask::xyzw, vu.vf07, 739); + // sq.xyzw vf28, 0(vi10) | nop 341 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + // sq.xyzw vf29, 1(vi10) | nop 342 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + // sq.xyzw vf30, 2(vi10) | nop 343 + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + // sq.xyzw vf24, 3(vi10) | nop 344 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + // sq.xyzw vf25, 4(vi10) | nop 345 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + // sq.xyzw vf26, 5(vi10) | nop 346 + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + // iaddiu vi06, vi05, 0x4000 | nop 347 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + // BRANCH! + // bal vi13, L43 | nop 348 + // ASSERT(false); + // iaddiu vi06, vi06, 0x4000 | nop 349 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + // if (bc) { + // goto L43; + // } + run_L43_vu2c(render_state, prof, direct); + + // ior vi03, vi00, vi00 | nop 350 + vu.vi03 = 0; + // lq.xyzw vf22, 756(vi00) | nop 351 + lq_buffer(Mask::xyzw, vu.vf22, 756); + // ilw.x vi05, 8(vi02) | nop 352 + ilw_buffer(Mask::x, vu.vi05, vu.vi02 + 8); + // iaddi vi08, vi10, 0x7 | nop 353 + vu.vi08 = vu.vi10 + 7; L24: + // lq.xyzw vf28, 792(vi03) | nop 354 + lq_buffer(Mask::xyzw, vu.vf28, vu.vi03 + 792); + // lq.xyzw vf24, 791(vi03) | nop 355 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi03 + 791); + // iaddi vi03, vi03, 0x2 | nop 356 + vu.vi03 = vu.vi03 + 2; + // iaddi vi05, vi05, -0x1 | nop 357 + vu.vi05 = vu.vi05 + -1; + // sq.xyzw vf22, 1(vi08) | nop 358 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 359 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // sq.xyzw vf24, 0(vi08) | nop 360 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + // BRANCH! + // ibgtz vi05, L24 | nop 361 + bc = ((s16)vu.vi05) > 0; + // iaddi vi08, vi08, 0x3 | nop 362 + vu.vi08 = vu.vi08 + 3; + if (bc) { + goto L24; + } + + // ilw.x vi05, 8(vi02) | nop 363 + ilw_buffer(Mask::x, vu.vi05, vu.vi02 + 8); + // lq.xyzw vf20, 7(vi10) | nop 364 + lq_buffer(Mask::xyzw, vu.vf20, vu.vi10 + 7); + // lq.xyzw vf22, 8(vi10) | nop 365 + lq_buffer(Mask::xyzw, vu.vf22, vu.vi10 + 8); + // lq.xyzw vf24, 9(vi10) | nop 366 + lq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 9); + // sq.xyzw vf24, 0(vi08) | nop 367 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + // sq.xyzw vf22, 1(vi08) | nop 368 + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + // sq.xyzw vf28, 2(vi08) | nop 369 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + // iaddi vi08, vi10, 0x7 | nop 370 + vu.vi08 = vu.vi10 + 7; + // BRANCH! + // bal vi13, L45 | nop 371 + // ASSERT(false); + // iaddi vi03, vi10, 0x7 | nop 372 + vu.vi03 = vu.vi10 + 7; + // if (bc) { + // goto L45; + // } + run_L45_vu2c(render_state, prof, direct); + + // lq.xyzw vf28, 749(vi00) | nop 373 + lq_buffer(Mask::xyzw, vu.vf28, 749); + // lq.xyzw vf29, 750(vi00) | nop 374 + lq_buffer(Mask::xyzw, vu.vf29, 750); + // lq.xyzw vf30, 751(vi00) | nop 375 + lq_buffer(Mask::xyzw, vu.vf30, 751); + // lq.xyzw vf24, 752(vi00) | nop 376 + lq_buffer(Mask::xyzw, vu.vf24, 752); + // lq.xyzw vf25, 753(vi00) | nop 377 + lq_buffer(Mask::xyzw, vu.vf25, 753); + // lq.xyzw vf26, 754(vi00) | nop 378 + lq_buffer(Mask::xyzw, vu.vf26, 754); + // lq.xyzw vf07, 740(vi00) | nop 379 + lq_buffer(Mask::xyzw, vu.vf07, 740); + // sq.xyzw vf28, 0(vi10) | nop 380 + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + // sq.xyzw vf29, 1(vi10) | nop 381 + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + // sq.xyzw vf30, 2(vi10) | nop 382 + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + // sq.xyzw vf24, 3(vi10) | nop 383 + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + // sq.xyzw vf25, 4(vi10) | nop 384 + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + // sq.xyzw vf26, 5(vi10) | nop 385 + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + // iaddiu vi06, vi05, 0x4000 | nop 386 + vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ + // BRANCH! + // bal vi13, L43 | nop 387 + // ASSERT(false); + // iaddiu vi06, vi06, 0x4000 | nop 388 + vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ + // if (bc) { + // goto L43; + // } + run_L43_vu2c(render_state, prof, direct); + +L25: + // nop | nop :e 389 + + // nop | nop 390 + + return; +} + +void OceanMid::run_L26_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc = false; + u32 cf = 0; +L26: // ilw.x vi05, 757(vi07) | nop 391 ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); // ilw.y vi04, 757(vi07) | nop 392 @@ -276,7 +1143,8 @@ void OceanMid::run_L24_vu2c() { vu.vi05 = vu.vi05 + 1; // fcset 0x0 | maddaz.xyzw ACC, vf14, vf28 399 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); - cf = 0; + cf = 0x0; + // nop | maddw.xyzw vf30, vf15, vf00 400 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); // div Q, vf03.x, vf30.w | mulax.xyzw ACC, vf12, vf29 401 @@ -322,39 +1190,38 @@ void OceanMid::run_L24_vu2c() { // iaddi vi01, vi00, 0x0 | nop 417 vu.vi01 = 0; // BRANCH! - // b L27 | maddw.xyzw vf30, vf15, vf00 418 + // b L29 | maddw.xyzw vf30, vf15, vf00 418 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); bc = true; // iaddi vi05, vi05, 0x1 | miniz.w vf16, vf16, vf03 419 vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); vu.vi05 = vu.vi05 + 1; if (bc) { - goto L27; + goto L29; } -L25: +L27: // iand vi13, vi10, vi12 | nop 420 vu.vi13 = vu.vi10 & vu.vi12; // BRANCH! - // ibeq vi00, vi01, L26 | mulaw.w ACC, vf30, vf00 421 + // ibeq vi00, vi01, L28 | mulaw.w ACC, vf30, vf00 421 vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); bc = (vu.vi01 == 0); // lq.xyzw vf20, 317(vi03) | mula.xyz ACC, vf30, Q 422 vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); if (bc) { - goto L26; + goto L28; } // nop | addw.w vf17, vf17, vf03 423 vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); -L26: +L28: // lq.xyzw vf22, 8(vi04) | maddw.xyzw vf16, vf02, vf00 424 vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); // fcand vi01, 0x3ffff | mul.xyzw vf19, vf31, vf01 425 vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); - // vu.vi01 = cf & 0x3ffff; fcand(vu.vi01, 0x3ffff, cf); // div Q, vf03.x, vf31.w | mul.xyzw vf20, vf20, Q 426 @@ -362,19 +1229,19 @@ void OceanMid::run_L24_vu2c() { vu.Q = vu.vf03.x() / vu.vf31.w(); // ior vi01, vi01, vi13 | ftoi4.xyzw vf17, vf17 427 vu.vf17.ftoi4(Mask::xyzw, vu.vf17); - vu.vi01 |= vu.vi13; + vu.vi01 = vu.vi01 | vu.vi13; // iadd vi12, vi12, vi12 | maxy.w vf16, vf16, vf03 428 vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); vu.vi12 = vu.vi12 + vu.vi12; // sq.xyzw vf21, 3(vi08) | mulax.xyzw ACC, vf12, vf28 429 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | madday.xyzw ACC, vf13, vf28 430 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); - sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | clipw.xyz vf19, vf19 431 cf = clip(vu.vf19, vu.vf19.w(), cf); - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); // lq.xyzw vf29, 245(vi05) | miniz.w vf16, vf16, vf03 432 vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); @@ -384,27 +1251,26 @@ void OceanMid::run_L24_vu2c() { // iaddi vi05, vi05, 0x1 | maddw.xyzw vf30, vf15, vf00 434 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); vu.vi05 = vu.vi05 + 1; -L27: +L29: // BRANCH! - // ibeq vi00, vi01, L28 | mulaw.w ACC, vf31, vf00 435 + // ibeq vi00, vi01, L30 | mulaw.w ACC, vf31, vf00 435 vu.acc.mula(Mask::w, vu.vf31, vu.vf00.w()); bc = (vu.vi01 == 0); // lq.xyzw vf21, 318(vi03) | mula.xyz ACC, vf31, Q 436 vu.acc.mula(Mask::xyz, vu.vf31, vu.Q); lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); if (bc) { - goto L28; + goto L30; } // nop | addw.w vf16, vf16, vf03 437 vu.vf16.add(Mask::w, vu.vf16, vu.vf03.w()); -L28: +L30: // lq.xyzw vf23, 20(vi04) | maddw.xyzw vf17, vf02, vf00 438 vu.acc.madd(Mask::xyzw, vu.vf17, vu.vf02, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 20); // fcand vi01, 0x3ffff | mul.xyzw vf18, vf30, vf01 439 vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); - // vu.vi01 = cf & 0x3ffff; fcand(vu.vi01, 0x3ffff, cf); // div Q, vf03.x, vf30.w | mul.xyzw vf21, vf21, Q 440 @@ -414,178 +1280,68 @@ void OceanMid::run_L24_vu2c() { vu.vf16.ftoi4(Mask::xyzw, vu.vf16); vu.vi03 = vu.vi03 + 2; // ior vi01, vi01, vi13 | nop 442 - vu.vi01 |= vu.vi13; + vu.vi01 = vu.vi01 | vu.vi13; // iaddi vi04, vi04, 0x1 | maxy.w vf17, vf17, vf03 443 vu.vf17.max(Mask::w, vu.vf17, vu.vf03.y()); vu.vi04 = vu.vi04 + 1; // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf12, vf29 444 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf13, vf29 445 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf16, 2(vi08) | clipw.xyz vf18, vf18 446 cf = clip(vu.vf18, vu.vf18.w(), cf); - sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 2); // lq.xyzw vf28, 236(vi05) | miniz.w vf17, vf17, vf03 447 vu.vf17.mini(Mask::w, vu.vf17, vu.vf03.z()); lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); // BRANCH! - // ibgtz vi06, L25 | maddaz.xyzw ACC, vf14, vf29 448 + // ibgtz vi06, L27 | maddaz.xyzw ACC, vf14, vf29 448 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); bc = ((s16)vu.vi06) > 0; // iaddi vi06, vi06, -0x1 | maddw.xyzw vf31, vf15, vf00 449 vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); vu.vi06 = vu.vi06 + -1; if (bc) { - goto L25; + goto L27; } // BRANCH! - // ibeq vi00, vi01, L29 | nop 450 + // ibeq vi00, vi01, L31 | nop 450 bc = (vu.vi01 == 0); // nop | nop 451 if (bc) { - goto L29; + goto L31; } // nop | addw.w vf17, vf17, vf03 452 vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); -L29: +L31: // nop | ftoi4.xyzw vf17, vf17 453 vu.vf17.ftoi4(Mask::xyzw, vu.vf17); - // sq.xyzw vf21, 3(vi08) | nop 454 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); - // fmt::print("maybe tex: {}\n", vu.vf21.print()); + // vu.vf17.fill(0); + // sq.xyzw vf21, 3(vi08) | nop 454 + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | nop 455 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | nop 456 - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); // jr vi15 | nop 457 + return; // nop | nop 458 } -void OceanMid::xgkick(u16 addr, - SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct) { - direct.render_gif((const u8*)&m_vu_data[addr], UINT32_MAX, render_state, prof); -} - -void OceanMid::run_call73_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct) { - - bool bc; -JUMP_73: - // xtop vi02 | nop 73 - vu.vi02 = xtop(); - // lq.xyzw vf07, 747(vi00) | nop 74 - lq_buffer(Mask::xyzw, vu.vf07, 747); - // lq.xyzw vf08, 0(vi02) | nop 75 - lq_buffer(Mask::xyzw, vu.vf08, vu.vi02); - // lq.xyzw vf09, 1(vi02) | nop 76 - lq_buffer(Mask::xyzw, vu.vf09, vu.vi02 + 1); - // lq.xyzw vf10, 2(vi02) | nop 77 - lq_buffer(Mask::xyzw, vu.vf10, vu.vi02 + 2); - // lq.xyzw vf11, 3(vi02) | nop 78 - lq_buffer(Mask::xyzw, vu.vf11, vu.vi02 + 3); - // lq.xyzw vf12, 4(vi02) | nop 79 - lq_buffer(Mask::xyzw, vu.vf12, vu.vi02 + 4); - // lq.xyzw vf13, 5(vi02) | nop 80 - lq_buffer(Mask::xyzw, vu.vf13, vu.vi02 + 5); - // lq.xyzw vf14, 6(vi02) | nop 81 - lq_buffer(Mask::xyzw, vu.vf14, vu.vi02 + 6); - // lq.xyzw vf15, 7(vi02) | nop 82 - lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); - // sq.xyzw vf07, 341(vi00) | nop 83 - sq_buffer(Mask::xyzw, vu.vf07, 341); - // sq.xyzw vf07, 463(vi00) | nop 84 - sq_buffer(Mask::xyzw, vu.vf07, 463); - // iaddi vi07, vi00, 0x7 | nop 85 - vu.vi07 = 7; - // lq.xyzw vf04, 116(vi02) | nop 86 - lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 116); -L13: - // iaddi vi01, vi07, -0x4 | nop 87 - vu.vi01 = vu.vi07 + -4; - // mtir vi10, vf04.x | nop 88 - vu.vi10 = vu.vf04.x_as_u16(); - // iaddiu vi11, vi00, 0xff | nop 89 - vu.vi11 = 0xff; /* 255 */ - // BRANCH! - // ibne vi00, vi01, L14 | nop 90 - bc = (vu.vi01 != 0); - // mr32.xyzw vf04, vf04 | nop 91 - vu.vf04.mr32(Mask::xyzw, vu.vf04); - if (bc) { - goto L14; - } - - // lq.xyzw vf04, 117(vi02) | nop 92 - lq_buffer(Mask::xyzw, vu.vf04, vu.vi02 + 117); -L14: - // BRANCH! - // ibeq vi11, vi10, L15 | nop 93 - bc = (vu.vi11 == vu.vi10); - // iaddi vi08, vi09, 0x7 | nop 94 - vu.vi08 = vu.vi09 + 7; - if (bc) { - goto L15; - } - - // BRANCH! - // bal vi15, L30 | nop 95 - // nop | nop 96 - - run_L30_vu2c(); - - // iaddiu vi01, vi00, 0x318 | nop 97 - vu.vi01 = 0x318; /* 792 */ - // xgkick vi09 | nop 98 - xgkick(vu.vi09, render_state, prof, direct); - // BRANCH! - // ibeq vi00, vi14, L15 | nop 99 - bc = (vu.vi14 == 0); - // isub vi09, vi01, vi09 | nop 100 - vu.vi09 = vu.vi01 - vu.vi09; - if (bc) { - goto L15; - } - - // BRANCH! - // bal vi15, L36 | nop 101 - // nop | nop 102 - - // if (bc) { goto L36; } - run_L36_vu2c(render_state, prof, direct); - -L15: - // BRANCH! - // ibgtz vi07, L13 | nop 103 - bc = ((s16)vu.vi07) > 0; - // iaddi vi07, vi07, -0x1 | nop 104 - vu.vi07 = vu.vi07 + -1; - if (bc) { - goto L13; - } - - // nop | nop :e 105 - - // nop | nop 106 -} - -static inline REALLY_INLINE float erleng(const Vf& in) { - float len = in.x() * in.x() + in.y() * in.y() + in.z() * in.z(); - float res = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(len))); - return res; -} - -void OceanMid::run_L30_vu2c() { +/*! + * packet generation for plain envmapped ocean + */ +void OceanMid::run_L32_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + bool bc = false; u32 cf = 0; - bool bc; -L30: +L32: // ilw.x vi05, 757(vi07) | nop 459 ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); // ilw.y vi04, 757(vi07) | nop 460 @@ -606,7 +1362,8 @@ void OceanMid::run_L30_vu2c() { vu.vi05 = vu.vi05 + 1; // fcset 0x0 | maddaz.xyzw ACC, vf14, vf28 467 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); - cf = 0; + cf = 0x0; + // nop | maddw.xyzw vf30, vf15, vf00 468 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); // nop | mulax.xyzw ACC, vf08, vf28 469 @@ -628,7 +1385,7 @@ void OceanMid::run_L30_vu2c() { vu.Q = vu.vf03.x() / vu.vf30.w(); // erleng.xyz P, vf26 | maddw.xyzw vf31, vf15, vf00 476 vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); - vu.P = erleng(vu.vf26); /* TODO erleng */ + vu.P = erleng(vu.vf26); // nop | mulax.xyzw ACC, vf08, vf29 477 vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); // nop | madday.xyzw ACC, vf09, vf29 478 @@ -655,14 +1412,13 @@ void OceanMid::run_L30_vu2c() { // nop | addz.y vf26, vf00, vf26 487 vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); // waitp | maxy.w vf16, vf16, vf03 488 - vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); - // ASSERT(false); + vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); // fog amx // mfp.w vf26, P | mulax.xyzw ACC, vf12, vf28 489 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); vu.vf26.mfp(Mask::w, vu.P); // erleng.xyz P, vf27 | madday.xyzw ACC, vf13, vf28 490 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); - vu.P = erleng(vu.vf27); /* TODO erleng */ + vu.P = erleng(vu.vf27); // iaddi vi12, vi00, 0x1 | maddaz.xyzw ACC, vf14, vf28 491 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); vu.vi12 = 1; @@ -687,120 +1443,113 @@ void OceanMid::run_L30_vu2c() { // nop | maddw.xyzw vf26, vf11, vf00 499 vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf11, vu.vf00.w()); // nop | clipw.xyz vf18, vf18 500 - // ASSERT(false); cf = clip(vu.vf18, vu.vf18.w(), cf); // waitp | clipw.xyz vf19, vf19 501 - // ASSERT(false); cf = clip(vu.vf19, vu.vf19.w(), cf); - // ASSERT(false); // BRANCH! - // b L33 | mula.xyzw ACC, vf24, vf05 502 + // b L35 | mula.xyzw ACC, vf24, vf05 502 vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); bc = true; // iaddi vi05, vi05, 0x1 | maddw.xyzw vf24, vf06, vf00 503 vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); vu.vi05 = vu.vi05 + 1; if (bc) { - goto L33; + goto L35; } -L31: +L33: // BRANCH! - // ibeq vi00, vi01, L32 | mulaw.w ACC, vf30, vf00 504 + // ibeq vi00, vi01, L34 | mulaw.w ACC, vf30, vf00 504 vu.acc.mula(Mask::w, vu.vf30, vu.vf00.w()); bc = (vu.vi01 == 0); // lq.xyzw vf20, 317(vi03) | mula.xyz ACC, vf30, Q 505 - // ASSERT(false); vu.acc.mula(Mask::xyz, vu.vf30, vu.Q); lq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); if (bc) { - goto L32; + goto L34; } // BRANCH! - // ibne vi00, vi13, L32 | addw.w vf17, vf17, vf03 506 + // ibne vi00, vi13, L34 | addw.w vf17, vf17, vf03 506 vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); bc = (vu.vi13 != 0); // fcor vi01, 0x7df7ff | nop 507 - // ASSERT(false); fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { - goto L32; + goto L34; } // isw.x vi12, 775(vi14) | nop 508 isw_buffer(Mask::x, vu.vi12, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L32 | nop 509 + // ibne vi00, vi01, L34 | nop 509 bc = (vu.vi01 != 0); // fcor vi01, 0xdf7dff | nop 510 - // ASSERT(false); fcor(vu.vi01, 0xdf7dff, cf); + if (bc) { - goto L32; + goto L34; } // isw.y vi05, 775(vi14) | nop 511 isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L32 | nop 512 + // ibne vi00, vi01, L34 | nop 512 bc = (vu.vi01 != 0); // fcor vi01, 0xefbeff | nop 513 - // ASSERT(false); fcor(vu.vi01, 0xefbeff, cf); if (bc) { - goto L32; + goto L34; } // ilw.z vi11, 757(vi07) | nop 514 ilw_buffer(Mask::z, vu.vi11, vu.vi07 + 757); // BRANCH! - // ibne vi00, vi01, L32 | nop 515 + // ibne vi00, vi01, L34 | nop 515 bc = (vu.vi01 != 0); // fcor vi01, 0xf7df7f | nop 516 - // ASSERT(false); fcor(vu.vi01, 0xf7df7f, cf); if (bc) { - goto L32; + goto L34; } // isw.z vi04, 775(vi14) | nop 517 isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L32 | nop 518 + // ibne vi00, vi01, L34 | nop 518 bc = (vu.vi01 != 0); // fcor vi01, 0xfbefbf | nop 519 - // ASSERT(false); fcor(vu.vi01, 0xfbefbf, cf); if (bc) { - goto L32; + goto L34; } // isub vi11, vi05, vi11 | nop 520 vu.vi11 = vu.vi05 - vu.vi11; // BRANCH! - // ibne vi00, vi01, L32 | nop 521 + // ibne vi00, vi01, L34 | nop 521 bc = (vu.vi01 != 0); // nop | nop 522 if (bc) { - goto L32; + goto L34; } // BRANCH! - // ibltz vi11, L32 | nop 523 + // ibltz vi11, L34 | nop 523 bc = ((s16)vu.vi11) < 0; // nop | nop 524 if (bc) { - goto L32; + goto L34; } // iaddi vi14, vi14, 0x1 | nop 525 vu.vi14 = vu.vi14 + 1; -L32: +L34: // lq.xyzw vf22, 8(vi04) | maddw.xyzw vf16, vf02, vf00 526 vu.acc.madd(Mask::xyzw, vu.vf16, vu.vf02, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 8); @@ -809,39 +1558,36 @@ void OceanMid::run_L30_vu2c() { vu.Q = vu.vf03.x() / vu.vf31.w(); // fcand vi01, 0x3ffff | mul.xyzw vf19, vf31, vf01 528 vu.vf19.mul(Mask::xyzw, vu.vf31, vu.vf01); - // ASSERT(false); - // vu.vi01 = cf & 0x3ffff; fcand(vu.vi01, 0x3ffff, cf); // waitp | ftoi4.xyzw vf17, vf17 529 vu.vf17.ftoi4(Mask::xyzw, vu.vf17); - // ASSERT(false); + // vu.vf17.fill(0); // mfp.w vf26, P | maxy.w vf16, vf16, vf03 530 vu.vf16.max(Mask::w, vu.vf16, vu.vf03.y()); vu.vf26.mfp(Mask::w, vu.P); // erleng.xyz P, vf27 | clipw.xyz vf19, vf19 531 - // ASSERT(false); cf = clip(vu.vf19, vu.vf19.w(), cf); - vu.P = erleng(vu.vf27); /* TODO erleng */ + vu.P = erleng(vu.vf27); // iand vi13, vi10, vi12 | addz.y vf27, vf00, vf27 532 vu.vf27.add(Mask::y, vu.vf00, vu.vf27.z()); vu.vi13 = vu.vi10 & vu.vi12; // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 533 - vu.vf25.z() = 1; // HACK - vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); // NaN's on input to here - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + vu.vf25.z() = 1; // TODO hack + vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | mulw.xy vf24, vf26, vf26 534 vu.vf24.mul(Mask::xy, vu.vf26, vu.vf26.w()); - sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | mulax.xyzw ACC, vf12, vf28 535 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); // sq.xyzw vf17, 66(vi08) | madday.xyzw ACC, vf13, vf28 536 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 66); // sq.xyzw vf25, 64(vi08) | maddaz.xyzw ACC, vf14, vf28 537 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); - sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 64); // iaddi vi08, vi08, 0x6 | maddw.xyzw vf30, vf15, vf00 538 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); vu.vi08 = vu.vi08 + 6; @@ -850,8 +1596,7 @@ void OceanMid::run_L30_vu2c() { vu.vi12 = vu.vi12 + vu.vi12; // ior vi01, vi01, vi13 | madday.xyzw ACC, vf09, vf28 540 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf28.y()); - // ASSERT(false); - vu.vi01 |= vu.vi13; + vu.vi01 = vu.vi01 | vu.vi13; // nop | maddaz.xyzw ACC, vf10, vf28 541 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf28.z()); // nop | maddw.xyzw vf26, vf11, vf00 542 @@ -864,96 +1609,91 @@ void OceanMid::run_L30_vu2c() { vu.vi05 = vu.vi05 + 1; // nop | maddw.xyzw vf24, vf06, vf00 545 vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); -L33: +L35: // BRANCH! - // ibeq vi00, vi01, L34 | mulaw.w ACC, vf31, vf00 546 + // ibeq vi00, vi01, L36 | mulaw.w ACC, vf31, vf00 546 vu.acc.mula(Mask::w, vu.vf31, vu.vf00.w()); bc = (vu.vi01 == 0); // lq.xyzw vf21, 318(vi03) | mula.xyz ACC, vf31, Q 547 - // ASSERT(false); vu.acc.mula(Mask::xyz, vu.vf31, vu.Q); lq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); if (bc) { - goto L34; + goto L36; } // BRANCH! - // ibne vi00, vi13, L34 | addw.w vf16, vf16, vf03 548 + // ibne vi00, vi13, L36 | addw.w vf16, vf16, vf03 548 vu.vf16.add(Mask::w, vu.vf16, vu.vf03.w()); bc = (vu.vi13 != 0); // fcor vi01, 0x7df7ff | nop 549 - // ASSERT(false); fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { - goto L34; + goto L36; } // isw.x vi00, 775(vi14) | nop 550 isw_buffer(Mask::x, 0, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L34 | nop 551 + // ibne vi00, vi01, L36 | nop 551 bc = (vu.vi01 != 0); // fcor vi01, 0xdf7dff | nop 552 - // ASSERT(false); fcor(vu.vi01, 0xdf7dff, cf); if (bc) { - goto L34; + goto L36; } // isw.y vi05, 775(vi14) | nop 553 isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L34 | nop 554 + // ibne vi00, vi01, L36 | nop 554 bc = (vu.vi01 != 0); // fcor vi01, 0xefbeff | nop 555 - // ASSERT(false); fcor(vu.vi01, 0xefbeff, cf); if (bc) { - goto L34; + goto L36; } // isw.z vi04, 775(vi14) | nop 556 isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L34 | nop 557 + // ibne vi00, vi01, L36 | nop 557 bc = (vu.vi01 != 0); // fcor vi01, 0xf7df7f | nop 558 - // ASSERT(false); fcor(vu.vi01, 0xf7df7f, cf); if (bc) { - goto L34; + goto L36; } // nop | nop 559 // BRANCH! - // ibne vi00, vi01, L34 | nop 560 + // ibne vi00, vi01, L36 | nop 560 bc = (vu.vi01 != 0); // fcor vi01, 0xfbefbf | nop 561 - // ASSERT(false); fcor(vu.vi01, 0xfbefbf, cf); if (bc) { - goto L34; + goto L36; } // nop | nop 562 // BRANCH! - // ibne vi00, vi01, L34 | nop 563 + // ibne vi00, vi01, L36 | nop 563 bc = (vu.vi01 != 0); // nop | nop 564 if (bc) { - goto L34; + goto L36; } // iaddi vi14, vi14, 0x1 | nop 565 vu.vi14 = vu.vi14 + 1; -L34: +L36: // lq.xyzw vf23, 20(vi04) | maddw.xyzw vf17, vf02, vf00 566 vu.acc.madd(Mask::xyzw, vu.vf17, vu.vf02, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf23, vu.vi04 + 20); @@ -962,38 +1702,36 @@ void OceanMid::run_L30_vu2c() { vu.Q = vu.vf03.x() / vu.vf30.w(); // fcand vi01, 0x3ffff | mul.xyzw vf18, vf30, vf01 568 vu.vf18.mul(Mask::xyzw, vu.vf30, vu.vf01); - // ASSERT(false); - // vu.vi01 = cf & 0x3ffff; fcand(vu.vi01, 0x3ffff, cf); // waitp | ftoi4.xyzw vf16, vf16 569 - vu.vf16.ftoi4(Mask::xyzw, vu.vf16); - // ASSERT(false); + vu.vf16.ftoi4(Mask::xyzw, vu.vf16); // possible 1 + // vu.vf16.fill(0); // mfp.w vf27, P | maxy.w vf17, vf17, vf03 570 vu.vf17.max(Mask::w, vu.vf17, vu.vf03.y()); vu.vf27.mfp(Mask::w, vu.P); // erleng.xyz P, vf26 | clipw.xyz vf18, vf18 571 - // ASSERT(false); cf = clip(vu.vf18, vu.vf18.w(), cf); - vu.P = erleng(vu.vf26); /* TODO erleng */ + vu.P = erleng(vu.vf26); // nop | addz.y vf26, vf00, vf26 572 vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); // sq.xyzw vf20, 0(vi08) | mulz.xyzw vf24, vf24, vf20 573 - vu.vf24.z() = 1.; // HACK + // todo hack + vu.vf24.z() = 1; vu.vf24.mul(Mask::xyzw, vu.vf24, vu.vf20.z()); - sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | mulw.xy vf25, vf27, vf27 574 vu.vf25.mul(Mask::xy, vu.vf27, vu.vf27.w()); - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf16, 2(vi08) | mulax.xyzw ACC, vf12, vf29 575 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 2); // sq.xyzw vf16, 63(vi08) | madday.xyzw ACC, vf13, vf29 576 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 63); + sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 63); // sq.xyzw vf24, 61(vi08) | maddaz.xyzw ACC, vf14, vf29 577 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 61); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 61); // iaddi vi04, vi04, 0x1 | maddw.xyzw vf31, vf15, vf00 578 vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); vu.vi04 = vu.vi04 + 1; @@ -1002,8 +1740,7 @@ void OceanMid::run_L30_vu2c() { vu.vi03 = vu.vi03 + 2; // ior vi01, vi01, vi13 | madday.xyzw ACC, vf09, vf29 580 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); - // ASSERT(false); - vu.vi01 |= vu.vi13; + vu.vi01 = vu.vi01 | vu.vi13; // nop | maddaz.xyzw ACC, vf10, vf29 581 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); // nop | maddw.xyzw vf27, vf11, vf00 582 @@ -1012,130 +1749,127 @@ void OceanMid::run_L30_vu2c() { vu.vf17.mini(Mask::w, vu.vf17, vu.vf03.z()); lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); // BRANCH! - // ibgtz vi06, L31 | mula.xyzw ACC, vf25, vf05 584 + // ibgtz vi06, L33 | mula.xyzw ACC, vf25, vf05 584 vu.acc.mula(Mask::xyzw, vu.vf25, vu.vf05); bc = ((s16)vu.vi06) > 0; // iaddi vi06, vi06, -0x1 | maddw.xyzw vf25, vf06, vf00 585 vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf06, vu.vf00.w()); vu.vi06 = vu.vi06 + -1; if (bc) { - goto L31; + goto L33; } // BRANCH! - // ibeq vi00, vi01, L35 | nop 586 + // ibeq vi00, vi01, L37 | nop 586 bc = (vu.vi01 == 0); // nop | nop 587 if (bc) { - goto L35; + goto L37; } // BRANCH! - // ibne vi00, vi13, L35 | addw.w vf17, vf17, vf03 588 + // ibne vi00, vi13, L37 | addw.w vf17, vf17, vf03 588 vu.vf17.add(Mask::w, vu.vf17, vu.vf03.w()); bc = (vu.vi13 != 0); // fcor vi01, 0x7df7ff | nop 589 - // ASSERT(false); fcor(vu.vi01, 0x7df7ff, cf); + if (bc) { - goto L35; + goto L37; } // isw.x vi12, 775(vi14) | nop 590 isw_buffer(Mask::x, vu.vi12, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L35 | nop 591 + // ibne vi00, vi01, L37 | nop 591 bc = (vu.vi01 != 0); // fcor vi01, 0xdf7dff | nop 592 - // ASSERT(false); fcor(vu.vi01, 0xdf7dff, cf); if (bc) { - goto L35; + goto L37; } // isw.y vi05, 775(vi14) | nop 593 isw_buffer(Mask::y, vu.vi05, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L35 | nop 594 + // ibne vi00, vi01, L37 | nop 594 bc = (vu.vi01 != 0); // fcor vi01, 0xefbeff | nop 595 - // ASSERT(false); fcor(vu.vi01, 0xefbeff, cf); if (bc) { - goto L35; + goto L37; } // isw.z vi04, 775(vi14) | nop 596 isw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi01, L35 | nop 597 + // ibne vi00, vi01, L37 | nop 597 bc = (vu.vi01 != 0); // fcor vi01, 0xf7df7f | nop 598 - // ASSERT(false); fcor(vu.vi01, 0xf7df7f, cf); if (bc) { - goto L35; + goto L37; } // nop | nop 599 // BRANCH! - // ibne vi00, vi01, L35 | nop 600 + // ibne vi00, vi01, L37 | nop 600 bc = (vu.vi01 != 0); // fcor vi01, 0xfbefbf | nop 601 - // ASSERT(false); fcor(vu.vi01, 0xfbefbf, cf); if (bc) { - goto L35; + goto L37; } // nop | nop 602 // BRANCH! - // ibne vi00, vi01, L35 | nop 603 + // ibne vi00, vi01, L37 | nop 603 bc = (vu.vi01 != 0); // nop | nop 604 if (bc) { - goto L35; + goto L37; } // iaddi vi14, vi14, 0x1 | nop 605 vu.vi14 = vu.vi14 + 1; -L35: +L37: // nop | ftoi4.xyzw vf17, vf17 606 vu.vf17.ftoi4(Mask::xyzw, vu.vf17); + // vu.vf17.fill(0); // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 607 vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | nop 608 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | nop 609 - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); // sq.xyzw vf17, 66(vi08) | nop 610 - sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); + sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 66); // sq.xyzw vf25, 64(vi08) | nop 611 - sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 64); // jr vi15 | nop 612 // nop | nop 613 } -void OceanMid::run_L36_vu2c(SharedRenderState* render_state, +void OceanMid::run_L38_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; - fmt::print("run L36\n"); -L36: + +L38: // lq.xyzw vf31, 734(vi00) | nop 614 lq_buffer(Mask::xyzw, vu.vf31, 734); // iaddiu vi10, vi00, 0x243 | nop 615 vu.vi10 = 0x243; /* 579 */ -L37: +L39: // iaddi vi14, vi14, -0x1 | nop 616 vu.vi14 = vu.vi14 + -1; // iaddi vi08, vi10, 0x7 | nop 617 @@ -1147,12 +1881,12 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // ilw.z vi04, 775(vi14) | nop 620 ilw_buffer(Mask::z, vu.vi04, vu.vi14 + 775); // BRANCH! - // ibne vi00, vi12, L38 | nop 621 + // ibne vi00, vi12, L40 | nop 621 bc = (vu.vi12 != 0); // nop | nop 622 if (bc) { - goto L38; + goto L40; } // lq.xyzw vf28, 233(vi05) | nop 623 @@ -1176,17 +1910,17 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf11, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf21, 318); // BRANCH! - // b L39 | mulax.xyzw ACC, vf12, vf28 631 + // b L41 | mulax.xyzw ACC, vf12, vf28 631 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); bc = true; // lq.xyzw vf07, 319(vi00) | madday.xyzw ACC, vf13, vf28 632 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); lq_buffer(Mask::xyzw, vu.vf07, 319); if (bc) { - goto L39; + goto L41; } -L38: +L40: // lq.xyzw vf28, 242(vi05) | nop 633 lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 242); // lq.xyzw vf29, 234(vi05) | nop 634 @@ -1212,12 +1946,12 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // lq.xyzw vf07, 320(vi00) | madday.xyzw ACC, vf13, vf28 642 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); lq_buffer(Mask::xyzw, vu.vf07, 320); -L39: +L41: // nop | maddaz.xyzw ACC, vf14, vf28 643 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); // erleng.xyz P, vf24 | maddw.xyzw vf28, vf15, vf00 644 vu.acc.madd(Mask::xyzw, vu.vf28, vu.vf15, vu.vf00.w()); - vu.P = erleng(vu.vf24); /* TODO erleng */ + vu.P = erleng(vu.vf24); // nop | addz.y vf24, vf00, vf24 645 vu.vf24.add(Mask::y, vu.vf00, vu.vf24.z()); // nop | itof0.xyzw vf22, vf22 646 @@ -1228,46 +1962,45 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, vu.vf16.itof0(Mask::xyzw, vu.vf16); // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf08, vf29 649 vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); - sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf09, vf29 650 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf21, 3(vi08) | maddaz.xyzw ACC, vf10, vf29 651 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | maddw.xyzw vf25, vf11, vf00 652 vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf11, vu.vf00.w()); - sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf07, 6(vi08) | mulax.xyzw ACC, vf12, vf29 653 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + 6); + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, vu.vi08 + 6); // sq.xyzw vf16, 7(vi08) | madday.xyzw ACC, vf13, vf29 654 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 7); + sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 7); // sq.xyzw vf20, 9(vi08) | maddaz.xyzw ACC, vf14, vf29 655 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); - sq_buffer(Mask::xyzw, vu.vf20, vu.vi08 + 9); + sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 9); // sq.xyzw vf22, 10(vi08) | maddw.xyzw vf29, vf15, vf00 656 vu.acc.madd(Mask::xyzw, vu.vf29, vu.vf15, vu.vf00.w()); - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); // waitp | mul.xyzw vf28, vf28, vf01 657 vu.vf28.mul(Mask::xyzw, vu.vf28, vu.vf01); - // ASSERT(false); // mfp.w vf24, P | nop 658 vu.vf24.mfp(Mask::w, vu.P); // erleng.xyz P, vf25 | nop 659 - vu.P = erleng(vu.vf25); /* TODO erleng */ + vu.P = erleng(vu.vf25); // nop | addz.y vf25, vf00, vf25 660 vu.vf25.add(Mask::y, vu.vf00, vu.vf25.z()); // sq.xyzw vf28, 2(vi08) | mulax.xyzw ACC, vf08, vf30 661 vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf30.x()); - sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf28, 11(vi08) | mulw.xy vf24, vf24, vf24 662 vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); - sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 11); // sq.xyzw vf28, 772(vi00) | madday.xyzw ACC, vf09, vf30 663 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf30.y()); - sq_buffer(Mask::xyzw, vu.vf28, 772); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 772); // nop | maddaz.xyzw ACC, vf10, vf30 664 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf30.z()); // nop | maddw.xyzw vf26, vf11, vf00 665 @@ -1284,38 +2017,36 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf30.z()); // sq.xyzw vf24, 769(vi00) | maddw.xyzw vf30, vf15, vf00 671 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); - sq_buffer(Mask::xyzw, vu.vf24, 769); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 769); // waitp | mul.xyzw vf29, vf29, vf01 672 vu.vf29.mul(Mask::xyzw, vu.vf29, vu.vf01); - // ASSERT(false); // mfp.w vf25, P | nop 673 vu.vf25.mfp(Mask::w, vu.P); // erleng.xyz P, vf26 | nop 674 - vu.P = erleng(vu.vf26); /* TODO erleng */ + vu.P = erleng(vu.vf26); // nop | addz.y vf26, vf00, vf26 675 vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); // sq.xyzw vf29, 5(vi08) | nop 676 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf29, 773(vi00) | mulw.xy vf25, vf25, vf25 677 vu.vf25.mul(Mask::xy, vu.vf25, vu.vf25.w()); - sq_buffer(Mask::xyzw, vu.vf29, 773); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 773); // nop | mula.xyzw ACC, vf25, vf05 678 vu.acc.mula(Mask::xyzw, vu.vf25, vu.vf05); // nop | maddw.xyzw vf25, vf06, vf00 679 vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf06, vu.vf00.w()); // waitp | mul.xyzw vf30, vf30, vf01 680 vu.vf30.mul(Mask::xyzw, vu.vf30, vu.vf01); - // ASSERT(false); // mfp.w vf26, P | nop 681 vu.vf26.mfp(Mask::w, vu.P); // sq.xyzw vf30, 8(vi08) | nop 682 - sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi08 + 8); // sq.xyzw vf30, 774(vi00) | mulw.xy vf26, vf26, vf26 683 vu.vf26.mul(Mask::xy, vu.vf26, vu.vf26.w()); - sq_buffer(Mask::xyzw, vu.vf30, 774); + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 774); // sq.xyzw vf25, 770(vi00) | mula.xyzw ACC, vf26, vf05 684 vu.acc.mula(Mask::xyzw, vu.vf26, vu.vf05); - sq_buffer(Mask::xyzw, vu.vf25, 770); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 770); // lq.xyzw vf07, 739(vi00) | maddw.xyzw vf26, vf06, vf00 685 vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf06, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf07, 739); @@ -1324,20 +2055,22 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // iaddi vi05, vi00, 0x3 | nop 687 vu.vi05 = 3; // BRANCH! - // bal vi13, L43 | nop 688 + // bal vi13, L45 | nop 688 + // sq.xyzw vf26, 771(vi00) | nop 689 - sq_buffer(Mask::xyzw, vu.vf26, 771); - run_L43_vu2c(); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 771); + // if (bc) { goto L45; } + run_L45_vu2c(render_state, prof, direct); // lq.xyzw vf28, 741(vi00) | nop 690 lq_buffer(Mask::xyzw, vu.vf28, 741); // BRANCH! - // ibeq vi00, vi05, L40 | nop 691 + // ibeq vi00, vi05, L42 | nop 691 bc = (vu.vi05 == 0); // lq.xyzw vf29, 742(vi00) | nop 692 lq_buffer(Mask::xyzw, vu.vf29, 742); if (bc) { - goto L40; + goto L42; } // lq.xyzw vf30, 743(vi00) | nop 693 @@ -1349,24 +2082,26 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // lq.xyzw vf26, 746(vi00) | nop 696 lq_buffer(Mask::xyzw, vu.vf26, 746); // sq.xyzw vf28, 0(vi10) | nop 697 - sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 698 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 699 - sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 700 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 701 - sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 702 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 703 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! - // bal vi13, L41 | nop 704 + // bal vi13, L43 | nop 704 + // ASSERT(false); // iaddiu vi06, vi06, 0x4000 | nop 705 vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ - run_L41_vu2c(render_state, prof, direct); + // if (bc) { goto L43; } + run_L43_vu2c(render_state, prof, direct); // iaddi vi08, vi10, 0x7 | nop 706 vu.vi08 = vu.vi10 + 7; @@ -1385,38 +2120,40 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // lq.xyzw vf30, 774(vi00) | nop 713 lq_buffer(Mask::xyzw, vu.vf30, 774); // sq.xyzw vf24, 0(vi08) | nop 714 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 715 - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 716 - sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf25, 3(vi08) | nop 717 - sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 3); // sq.xyzw vf22, 4(vi08) | nop 718 - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 4); // sq.xyzw vf29, 5(vi08) | nop 719 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf26, 6(vi08) | nop 720 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi08 + 6); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi08 + 6); // sq.xyzw vf22, 7(vi08) | nop 721 - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 7); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); // sq.xyzw vf30, 8(vi08) | nop 722 - sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi08 + 8); // sq.xyzw vf24, 9(vi08) | nop 723 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 9); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 9); // sq.xyzw vf22, 10(vi08) | nop 724 - sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); + sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); // sq.xyzw vf28, 11(vi08) | nop 725 - sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 11); // ior vi03, vi08, vi00 | nop 726 vu.vi03 = vu.vi08; // iaddi vi05, vi00, 0x3 | nop 727 vu.vi05 = 3; // BRANCH! - // bal vi13, L43 | nop 728 + // bal vi13, L45 | nop 728 + // ASSERT(false); // lq.xyzw vf07, 740(vi00) | nop 729 lq_buffer(Mask::xyzw, vu.vf07, 740); - run_L43_vu2c(); + // if (bc) { goto L45; } + run_L45_vu2c(render_state, prof, direct); // lq.xyzw vf28, 749(vi00) | nop 730 lq_buffer(Mask::xyzw, vu.vf28, 749); @@ -1431,49 +2168,50 @@ void OceanMid::run_L36_vu2c(SharedRenderState* render_state, // lq.xyzw vf26, 754(vi00) | nop 735 lq_buffer(Mask::xyzw, vu.vf26, 754); // sq.xyzw vf28, 0(vi10) | nop 736 - sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 737 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 738 - sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 739 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 740 - sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 741 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 742 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! - // bal vi13, L41 | nop 743 + // bal vi13, L43 | nop 743 + // ASSERT(false); // iaddiu vi06, vi06, 0x4000 | nop 744 vu.vi06 = vu.vi06 + 0x4000; /* 16384 */ - run_L41_vu2c(render_state, prof, direct); + // if (bc) { goto L43; } + run_L43_vu2c(render_state, prof, direct); -L40: +L42: // BRANCH! - // ibgtz vi14, L37 | nop 745 + // ibgtz vi14, L39 | nop 745 bc = ((s16)vu.vi14) > 0; // nop | nop 746 if (bc) { - goto L37; + goto L39; } // jr vi15 | nop 747 // nop | nop 748 } - -void OceanMid::run_L41_vu2c(SharedRenderState* render_state, +void OceanMid::run_L43_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; -L41: +L43: // sq.xyzw vf07, -1(vi08) | nop 749 - sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + -1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf07, vu.vi08 + -1); // isw.x vi06, -1(vi08) | nop 750 isw_buffer(Mask::x, vu.vi06, vu.vi08 + -1); -L42: +L44: // lqi.xyzw vf24, vi08 | nop 751 lq_buffer(Mask::xyzw, vu.vf24, vu.vi08++); // lqi.xyzw vf27, vi08 | nop 752 @@ -1487,8 +2225,8 @@ void OceanMid::run_L41_vu2c(SharedRenderState* render_state, // nop | nop 756 // div Q, vf00.w, vf21.w | mul.xyzw vf21, vf21, vf31 757 - vu.vf21.mul(Mask::xyzw, vu.vf21, vu.vf31); vu.Q = vu.vf00.w() / vu.vf21.w(); + vu.vf21.mul(Mask::xyzw, vu.vf21, vu.vf31); // nop | nop 758 // nop | nop 759 @@ -1535,42 +2273,46 @@ void OceanMid::run_L41_vu2c(SharedRenderState* render_state, vu.vf27.ftoi0(Mask::xyzw, vu.vf27); // nop | ftoi4.xyzw vf21, vf21 780 vu.vf21.ftoi4(Mask::xyzw, vu.vf21); + // nop | nop 781 // sq.xyzw vf24, -3(vi08) | nop 782 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + -3); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + -3); // sq.xyzw vf27, -2(vi08) | nop 783 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + -2); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi08 + -2); // sq.xyzw vf21, -1(vi08) | nop 784 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + -1); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + -1); // iaddi vi05, vi05, -0x1 | nop 785 vu.vi05 = vu.vi05 + -1; // nop | nop 786 // BRANCH! - // ibne vi00, vi05, L42 | nop 787 + // ibne vi00, vi05, L44 | nop 787 bc = (vu.vi05 != 0); // nop | nop 788 if (bc) { - goto L42; + goto L44; } // iaddiu vi01, vi00, 0x4d3 | nop 789 vu.vi01 = 0x4d3; /* 1235 */ // xgkick vi10 | nop 790 - fmt::print("kick from 1514\n"); xgkick(vu.vi10, render_state, prof, direct); // jr vi13 | nop 791 + // ASSERT(false); // isub vi10, vi01, vi10 | nop 792 vu.vi10 = vu.vi01 - vu.vi10; } -void OceanMid::run_L43_vu2c() { - u32 cf = 0; // isn't from earlier? - bool bc; - fmt::print("here!!!\n"); -L43: +void OceanMid::run_L45_vu2c(SharedRenderState* render_state, + ScopedProfilerNode& prof, + DirectRenderer& direct) { + // fmt::print("run L45\n"); + + bool bc = false; + u32 cf = 0; +L45: // ior vi04, vi03, vi00 | nop 793 vu.vi04 = vu.vi03; // lq.xyzw vf21, 2(vi03) | nop 794 @@ -1584,7 +2326,7 @@ void OceanMid::run_L43_vu2c() { // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 798 cf = clip(vu.vf21, vu.vf21.w(), cf); vu.vi03 = vu.vi03 + 3; -L44: +L46: // lq.xyzw vf22, 2(vi03) | nop 799 lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); // lq.xyzw vf25, 0(vi03) | nop 800 @@ -1603,46 +2345,43 @@ void OceanMid::run_L43_vu2c() { // fcor vi01, 0xfff7df | nop 807 fcor(vu.vi01, 0xfff7df, cf); - // ASSERT(false); + // BRANCH! - // ibne vi00, vi01, L55 | nop 808 + // ibne vi00, vi01, L57 | nop 808 bc = (vu.vi01 != 0); // fcand vi01, 0x20 | nop 809 - // vu.vi01 = cf & 0x20; fcand(vu.vi01, 0x20, cf); if (bc) { - goto L55; + goto L57; } // BRANCH! - // ibne vi00, vi01, L56 | nop 810 + // ibne vi00, vi01, L58 | nop 810 bc = (vu.vi01 != 0); // fcand vi01, 0x800 | nop 811 - // ASSERT(false); - // vu.vi01 = cf & 0x800; fcand(vu.vi01, 0x800, cf); if (bc) { - goto L56; + goto L58; } // BRANCH! - // ibne vi00, vi01, L57 | nop 812 + // ibne vi00, vi01, L59 | nop 812 bc = (vu.vi01 != 0); // nop | nop 813 if (bc) { - goto L57; + goto L59; } // sqi.xyzw vf24, vi04 | nop 814 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 815 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 816 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); -L45: + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); +L47: // move.xyzw vf24, vf25 | nop 817 vu.vf24.move(Mask::xyzw, vu.vf25); // iaddi vi05, vi05, -0x1 | nop 818 @@ -1650,12 +2389,12 @@ void OceanMid::run_L43_vu2c() { // move.xyzw vf27, vf28 | nop 819 vu.vf27.move(Mask::xyzw, vu.vf28); // BRANCH! - // ibne vi00, vi05, L44 | nop 820 + // ibne vi00, vi05, L46 | nop 820 bc = (vu.vi05 != 0); // move.xyzw vf21, vf22 | nop 821 vu.vf21.move(Mask::xyzw, vu.vf22); if (bc) { - goto L44; + goto L46; } // lq.xyzw vf24, 0(vi08) | nop 822 @@ -1667,18 +2406,18 @@ void OceanMid::run_L43_vu2c() { // ior vi03, vi08, vi00 | nop 825 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 826 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 827 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 828 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi00, vi06, L54 | nop 829 + // ibeq vi00, vi06, L56 | nop 829 bc = (vu.vi06 == 0); // ior vi05, vi06, vi00 | nop 830 vu.vi05 = vu.vi06; if (bc) { - goto L54; + goto L56; } // ior vi04, vi03, vi00 | nop 831 @@ -1694,7 +2433,7 @@ void OceanMid::run_L43_vu2c() { // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 836 cf = clip(vu.vf21, vu.vf21.w(), cf); vu.vi03 = vu.vi03 + 3; -L46: +L48: // lq.xyzw vf22, 2(vi03) | nop 837 lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); // lq.xyzw vf25, 0(vi03) | nop 838 @@ -1712,49 +2451,44 @@ void OceanMid::run_L43_vu2c() { // nop | nop 844 // fcor vi01, 0xfffdf7 | nop 845 - // ASSERT(false); - fcor(vu.vi01, 0xfffdf7 ,cf); + fcor(vu.vi01, 0xfffdf7, cf); + // BRANCH! - // ibne vi00, vi01, L58 | nop 846 + // ibne vi00, vi01, L60 | nop 846 bc = (vu.vi01 != 0); // fcand vi01, 0x8 | nop 847 - // ASSERT(false); - // vu.vi01 = cf & 0x8; fcand(vu.vi01, 0x8, cf); if (bc) { - goto L58; + goto L60; } // BRANCH! - // ibne vi00, vi01, L59 | nop 848 + // ibne vi00, vi01, L61 | nop 848 bc = (vu.vi01 != 0); // fcand vi01, 0x200 | nop 849 - // ASSERT(false); - // vu.vi01 = cf & 0x200; fcand(vu.vi01, 0x200, cf); - if (bc) { - goto L59; + goto L61; } // BRANCH! - // ibne vi00, vi01, L60 | nop 850 + // ibne vi00, vi01, L62 | nop 850 bc = (vu.vi01 != 0); // nop | nop 851 if (bc) { - goto L60; + goto L62; } // sqi.xyzw vf24, vi04 | nop 852 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 853 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 854 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); -L47: + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); +L49: // move.xyzw vf24, vf25 | nop 855 vu.vf24.move(Mask::xyzw, vu.vf25); // iaddi vi05, vi05, -0x1 | nop 856 @@ -1762,12 +2496,12 @@ void OceanMid::run_L43_vu2c() { // move.xyzw vf27, vf28 | nop 857 vu.vf27.move(Mask::xyzw, vu.vf28); // BRANCH! - // ibne vi00, vi05, L46 | nop 858 + // ibne vi00, vi05, L48 | nop 858 bc = (vu.vi05 != 0); // move.xyzw vf21, vf22 | nop 859 vu.vf21.move(Mask::xyzw, vu.vf22); if (bc) { - goto L46; + goto L48; } // lq.xyzw vf24, 0(vi08) | nop 860 @@ -1779,18 +2513,18 @@ void OceanMid::run_L43_vu2c() { // ior vi03, vi08, vi00 | nop 863 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 864 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 865 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 866 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi00, vi06, L54 | nop 867 + // ibeq vi00, vi06, L56 | nop 867 bc = (vu.vi06 == 0); // ior vi05, vi06, vi00 | nop 868 vu.vi05 = vu.vi06; if (bc) { - goto L54; + goto L56; } // ior vi04, vi03, vi00 | nop 869 @@ -1806,7 +2540,7 @@ void OceanMid::run_L43_vu2c() { // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 874 cf = clip(vu.vf21, vu.vf21.w(), cf); vu.vi03 = vu.vi03 + 3; -L48: +L50: // lq.xyzw vf22, 2(vi03) | nop 875 lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); // lq.xyzw vf25, 0(vi03) | nop 876 @@ -1824,48 +2558,44 @@ void OceanMid::run_L43_vu2c() { // nop | nop 882 // fcor vi01, 0xfffefb | nop 883 - // ASSERT(false); fcor(vu.vi01, 0xfffefb, cf); + // BRANCH! - // ibne vi00, vi01, L61 | nop 884 + // ibne vi00, vi01, L63 | nop 884 bc = (vu.vi01 != 0); // fcand vi01, 0x4 | nop 885 - // ASSERT(false); - // vu.vi01 = cf & 0x4; fcand(vu.vi01, 0x4, cf); if (bc) { - goto L61; + goto L63; } // BRANCH! - // ibne vi00, vi01, L62 | nop 886 + // ibne vi00, vi01, L64 | nop 886 bc = (vu.vi01 != 0); // fcand vi01, 0x100 | nop 887 - // ASSERT(false); - // vu.vi01 = cf & 0x100; fcand(vu.vi01, 0x100, cf); if (bc) { - goto L62; + goto L64; } // BRANCH! - // ibne vi00, vi01, L63 | nop 888 + // ibne vi00, vi01, L65 | nop 888 bc = (vu.vi01 != 0); // nop | nop 889 if (bc) { - goto L63; + goto L65; } // sqi.xyzw vf24, vi04 | nop 890 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 891 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 892 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); -L49: + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); +L51: // move.xyzw vf24, vf25 | nop 893 vu.vf24.move(Mask::xyzw, vu.vf25); // iaddi vi05, vi05, -0x1 | nop 894 @@ -1873,12 +2603,12 @@ void OceanMid::run_L43_vu2c() { // move.xyzw vf27, vf28 | nop 895 vu.vf27.move(Mask::xyzw, vu.vf28); // BRANCH! - // ibne vi00, vi05, L48 | nop 896 + // ibne vi00, vi05, L50 | nop 896 bc = (vu.vi05 != 0); // move.xyzw vf21, vf22 | nop 897 vu.vf21.move(Mask::xyzw, vu.vf22); if (bc) { - goto L48; + goto L50; } // lq.xyzw vf24, 0(vi08) | nop 898 @@ -1890,18 +2620,18 @@ void OceanMid::run_L43_vu2c() { // ior vi03, vi08, vi00 | nop 901 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 902 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 903 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 904 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi00, vi06, L54 | nop 905 + // ibeq vi00, vi06, L56 | nop 905 bc = (vu.vi06 == 0); // ior vi05, vi06, vi00 | nop 906 vu.vi05 = vu.vi06; if (bc) { - goto L54; + goto L56; } // ior vi04, vi03, vi00 | nop 907 @@ -1915,10 +2645,9 @@ void OceanMid::run_L43_vu2c() { // lq.xyzw vf27, 1(vi03) | nop 911 lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 912 - // ASSERT(false); cf = clip(vu.vf21, vu.vf21.w(), cf); vu.vi03 = vu.vi03 + 3; -L50: +L52: // lq.xyzw vf22, 2(vi03) | nop 913 lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); // lq.xyzw vf25, 0(vi03) | nop 914 @@ -1928,7 +2657,6 @@ void OceanMid::run_L43_vu2c() { // iaddi vi03, vi03, 0x3 | nop 916 vu.vi03 = vu.vi03 + 3; // nop | clipw.xyz vf22, vf22 917 - // ASSERT(false); cf = clip(vu.vf22, vu.vf22.w(), cf); // nop | nop 918 @@ -1937,48 +2665,44 @@ void OceanMid::run_L43_vu2c() { // nop | nop 920 // fcor vi01, 0xffff7d | nop 921 - // ASSERT(false); fcor(vu.vi01, 0xffff7d, cf); + // BRANCH! - // ibne vi00, vi01, L64 | nop 922 + // ibne vi00, vi01, L66 | nop 922 bc = (vu.vi01 != 0); // fcand vi01, 0x2 | nop 923 - // ASSERT(false); - // vu.vi01 = cf & 0x2; fcand(vu.vi01, 0x2, cf); if (bc) { - goto L64; + goto L66; } // BRANCH! - // ibne vi00, vi01, L65 | nop 924 + // ibne vi00, vi01, L67 | nop 924 bc = (vu.vi01 != 0); // fcand vi01, 0x80 | nop 925 - // ASSERT(false); - // vu.vi01 = cf & 0x80; fcand(vu.vi01, 0x80, cf); if (bc) { - goto L65; + goto L67; } // BRANCH! - // ibne vi00, vi01, L66 | nop 926 + // ibne vi00, vi01, L68 | nop 926 bc = (vu.vi01 != 0); // nop | nop 927 if (bc) { - goto L66; + goto L68; } // sqi.xyzw vf24, vi04 | nop 928 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 929 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 930 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); -L51: + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); +L53: // move.xyzw vf24, vf25 | nop 931 vu.vf24.move(Mask::xyzw, vu.vf25); // iaddi vi05, vi05, -0x1 | nop 932 @@ -1986,12 +2710,12 @@ void OceanMid::run_L43_vu2c() { // move.xyzw vf27, vf28 | nop 933 vu.vf27.move(Mask::xyzw, vu.vf28); // BRANCH! - // ibne vi00, vi05, L50 | nop 934 + // ibne vi00, vi05, L52 | nop 934 bc = (vu.vi05 != 0); // move.xyzw vf21, vf22 | nop 935 vu.vf21.move(Mask::xyzw, vu.vf22); if (bc) { - goto L50; + goto L52; } // lq.xyzw vf24, 0(vi08) | nop 936 @@ -2003,18 +2727,18 @@ void OceanMid::run_L43_vu2c() { // ior vi03, vi08, vi00 | nop 939 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 940 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 941 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 942 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi00, vi06, L54 | nop 943 + // ibeq vi00, vi06, L56 | nop 943 bc = (vu.vi06 == 0); // ior vi05, vi06, vi00 | nop 944 vu.vi05 = vu.vi06; if (bc) { - goto L54; + goto L56; } // ior vi04, vi03, vi00 | nop 945 @@ -2028,10 +2752,9 @@ void OceanMid::run_L43_vu2c() { // lq.xyzw vf27, 1(vi03) | nop 949 lq_buffer(Mask::xyzw, vu.vf27, vu.vi03 + 1); // iaddi vi03, vi03, 0x3 | clipw.xyz vf21, vf21 950 - // ASSERT(false); cf = clip(vu.vf21, vu.vf21.w(), cf); vu.vi03 = vu.vi03 + 3; -L52: +L54: // lq.xyzw vf22, 2(vi03) | nop 951 lq_buffer(Mask::xyzw, vu.vf22, vu.vi03 + 2); // lq.xyzw vf25, 0(vi03) | nop 952 @@ -2041,7 +2764,6 @@ void OceanMid::run_L43_vu2c() { // iaddi vi03, vi03, 0x3 | nop 954 vu.vi03 = vu.vi03 + 3; // nop | clipw.xyz vf22, vf22 955 - // ASSERT(false); cf = clip(vu.vf22, vu.vf22.w(), cf); // nop | nop 956 @@ -2050,48 +2772,44 @@ void OceanMid::run_L43_vu2c() { // nop | nop 958 // fcor vi01, 0xffffbe | nop 959 - // ASSERT(false); fcor(vu.vi01, 0xffffbe, cf); + // BRANCH! - // ibne vi00, vi01, L67 | nop 960 + // ibne vi00, vi01, L69 | nop 960 bc = (vu.vi01 != 0); // fcand vi01, 0x1 | nop 961 - // ASSERT(false); - fcand(vu.vi01, 1, cf); - // vu.vi01 = cf & 0x1; + fcand(vu.vi01, 0x1, cf); if (bc) { - goto L67; + goto L69; } // BRANCH! - // ibne vi00, vi01, L68 | nop 962 + // ibne vi00, vi01, L70 | nop 962 bc = (vu.vi01 != 0); // fcand vi01, 0x40 | nop 963 - // ASSERT(false); fcand(vu.vi01, 0x40, cf); - // vu.vi01 = cf & 0x40; if (bc) { - goto L68; + goto L70; } // BRANCH! - // ibne vi00, vi01, L69 | nop 964 + // ibne vi00, vi01, L71 | nop 964 bc = (vu.vi01 != 0); // nop | nop 965 if (bc) { - goto L69; + goto L71; } // sqi.xyzw vf24, vi04 | nop 966 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 967 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 968 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); -L53: + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); +L55: // move.xyzw vf24, vf25 | nop 969 vu.vf24.move(Mask::xyzw, vu.vf25); // iaddi vi05, vi05, -0x1 | nop 970 @@ -2099,12 +2817,12 @@ void OceanMid::run_L43_vu2c() { // move.xyzw vf27, vf28 | nop 971 vu.vf27.move(Mask::xyzw, vu.vf28); // BRANCH! - // ibne vi00, vi05, L52 | nop 972 + // ibne vi00, vi05, L54 | nop 972 bc = (vu.vi05 != 0); // move.xyzw vf21, vf22 | nop 973 vu.vf21.move(Mask::xyzw, vu.vf22); if (bc) { - goto L52; + goto L54; } // lq.xyzw vf24, 0(vi08) | nop 974 @@ -2116,53 +2834,53 @@ void OceanMid::run_L43_vu2c() { // ior vi03, vi08, vi00 | nop 977 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 978 - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 979 - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 980 - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi00, vi06, L54 | nop 981 + // ibeq vi00, vi06, L56 | nop 981 bc = (vu.vi06 == 0); // ior vi05, vi06, vi00 | nop 982 vu.vi05 = vu.vi06; if (bc) { - goto L54; + goto L56; } -L54: +L56: // jr vi13 | nop 983 // ASSERT(false); return; // nop | nop 984 -L55: +L57: // BRANCH! - // b L45 | nop 985 + // b L47 | nop 985 bc = true; // iaddi vi06, vi06, -0x1 | nop 986 vu.vi06 = vu.vi06 + -1; if (bc) { - goto L45; + goto L47; } -L56: +L58: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 987 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 988 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 989 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi03, vi04, L45 | nop 990 + // ibeq vi03, vi04, L47 | nop 990 bc = (vu.vi03 == vu.vi04); // nop | addz.w vf30, vf23, vf23 991 vu.vf30.add(Mask::w, vu.vf23, vu.vf23.z()); if (bc) { - goto L45; + goto L47; } // nop | addw.z vf30, vf21, vf21 992 @@ -2186,19 +2904,19 @@ void OceanMid::run_L43_vu2c() { // iaddi vi06, vi06, 0x1 | nop 1001 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1002 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1003 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L45 | nop 1004 + // b L47 | nop 1004 bc = true; // sqi.xyzw vf23, vi04 | nop 1005 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L45; + goto L47; } -L57: +L59: // nop | sub.xyzw vf23, vf21, vf22 1006 vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); // nop | sub.xyzw vf26, vf24, vf25 1007 @@ -2226,45 +2944,45 @@ void OceanMid::run_L43_vu2c() { // nop | sub.xyzw vf23, vf22, vf23 1018 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1019 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1020 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L45 | nop 1021 + // b L47 | nop 1021 bc = true; // sqi.xyzw vf23, vi04 | nop 1022 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L45; + goto L47; } -L58: +L60: // BRANCH! - // b L47 | nop 1023 + // b L49 | nop 1023 bc = true; // iaddi vi06, vi06, -0x1 | nop 1024 vu.vi06 = vu.vi06 + -1; if (bc) { - goto L47; + goto L49; } -L59: +L61: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1025 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1026 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1027 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi03, vi04, L47 | nop 1028 + // ibeq vi03, vi04, L49 | nop 1028 bc = (vu.vi03 == vu.vi04); // nop | addy.w vf30, vf23, vf23 1029 vu.vf30.add(Mask::w, vu.vf23, vu.vf23.y()); if (bc) { - goto L47; + goto L49; } // nop | addw.y vf30, vf21, vf21 1030 @@ -2288,19 +3006,19 @@ void OceanMid::run_L43_vu2c() { // iaddi vi06, vi06, 0x1 | nop 1039 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1040 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1041 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L47 | nop 1042 + // b L49 | nop 1042 bc = true; // sqi.xyzw vf23, vi04 | nop 1043 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L47; + goto L49; } -L60: +L62: // nop | sub.xyzw vf23, vf21, vf22 1044 vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); // nop | sub.xyzw vf26, vf24, vf25 1045 @@ -2328,45 +3046,45 @@ void OceanMid::run_L43_vu2c() { // nop | sub.xyzw vf23, vf22, vf23 1056 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1057 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1058 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L47 | nop 1059 + // b L49 | nop 1059 bc = true; // sqi.xyzw vf23, vi04 | nop 1060 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L47; + goto L49; } -L61: +L63: // BRANCH! - // b L49 | nop 1061 + // b L51 | nop 1061 bc = true; // iaddi vi06, vi06, -0x1 | nop 1062 vu.vi06 = vu.vi06 + -1; if (bc) { - goto L49; + goto L51; } -L62: +L64: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1063 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1064 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1065 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi03, vi04, L49 | nop 1066 + // ibeq vi03, vi04, L51 | nop 1066 bc = (vu.vi03 == vu.vi04); // nop | suby.w vf30, vf23, vf23 1067 vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.y()); if (bc) { - goto L49; + goto L51; } // nop | subw.y vf30, vf21, vf21 1068 @@ -2390,19 +3108,19 @@ void OceanMid::run_L43_vu2c() { // iaddi vi06, vi06, 0x1 | nop 1077 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1078 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1079 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L49 | nop 1080 + // b L51 | nop 1080 bc = true; // sqi.xyzw vf23, vi04 | nop 1081 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L49; + goto L51; } -L63: +L65: // nop | sub.xyzw vf23, vf21, vf22 1082 vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); // nop | sub.xyzw vf26, vf24, vf25 1083 @@ -2430,45 +3148,45 @@ void OceanMid::run_L43_vu2c() { // nop | add.xyzw vf23, vf22, vf23 1094 vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1095 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1096 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L49 | nop 1097 + // b L51 | nop 1097 bc = true; // sqi.xyzw vf23, vi04 | nop 1098 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L49; + goto L51; } -L64: +L66: // BRANCH! - // b L51 | nop 1099 + // b L53 | nop 1099 bc = true; // iaddi vi06, vi06, -0x1 | nop 1100 vu.vi06 = vu.vi06 + -1; if (bc) { - goto L51; + goto L53; } -L65: +L67: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1101 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1102 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1103 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi03, vi04, L51 | nop 1104 + // ibeq vi03, vi04, L53 | nop 1104 bc = (vu.vi03 == vu.vi04); // nop | addx.w vf30, vf23, vf23 1105 vu.vf30.add(Mask::w, vu.vf23, vu.vf23.x()); if (bc) { - goto L51; + goto L53; } // nop | addw.x vf30, vf21, vf21 1106 @@ -2492,19 +3210,19 @@ void OceanMid::run_L43_vu2c() { // iaddi vi06, vi06, 0x1 | nop 1115 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1116 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1117 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L51 | nop 1118 + // b L53 | nop 1118 bc = true; // sqi.xyzw vf23, vi04 | nop 1119 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L51; + goto L53; } -L66: +L68: // nop | sub.xyzw vf23, vf21, vf22 1120 vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); // nop | sub.xyzw vf26, vf24, vf25 1121 @@ -2532,45 +3250,45 @@ void OceanMid::run_L43_vu2c() { // nop | sub.xyzw vf23, vf22, vf23 1132 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1133 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1134 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L51 | nop 1135 + // b L53 | nop 1135 bc = true; // sqi.xyzw vf23, vi04 | nop 1136 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L51; + goto L53; } -L67: +L69: // BRANCH! - // b L53 | nop 1137 + // b L55 | nop 1137 bc = true; // iaddi vi06, vi06, -0x1 | nop 1138 vu.vi06 = vu.vi06 + -1; if (bc) { - goto L53; + goto L55; } -L68: +L70: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1139 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1140 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1141 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! - // ibeq vi03, vi04, L53 | nop 1142 + // ibeq vi03, vi04, L55 | nop 1142 bc = (vu.vi03 == vu.vi04); // nop | subx.w vf30, vf23, vf23 1143 vu.vf30.sub(Mask::w, vu.vf23, vu.vf23.x()); if (bc) { - goto L53; + goto L55; } // nop | subw.x vf30, vf21, vf21 1144 @@ -2594,19 +3312,19 @@ void OceanMid::run_L43_vu2c() { // iaddi vi06, vi06, 0x1 | nop 1153 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1154 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1155 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L53 | nop 1156 + // b L55 | nop 1156 bc = true; // sqi.xyzw vf23, vi04 | nop 1157 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L53; + goto L55; } -L69: +L71: // nop | sub.xyzw vf23, vf21, vf22 1158 vu.vf23.sub(Mask::xyzw, vu.vf21, vu.vf22); // nop | sub.xyzw vf26, vf24, vf25 1159 @@ -2634,15 +3352,15 @@ void OceanMid::run_L43_vu2c() { // nop | add.xyzw vf23, vf22, vf23 1170 vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1171 - sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1172 - sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! - // b L53 | nop 1173 + // b L55 | nop 1173 bc = true; // sqi.xyzw vf23, vi04 | nop 1174 - sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { - goto L53; + goto L55; } } \ No newline at end of file diff --git a/goal_src/engine/gfx/ocean/ocean-mid.gc b/goal_src/engine/gfx/ocean/ocean-mid.gc index 4846a1047f..049b1713b0 100644 --- a/goal_src/engine/gfx/ocean/ocean-mid.gc +++ b/goal_src/engine/gfx/ocean/ocean-mid.gc @@ -9,14 +9,21 @@ (defun ocean-mid-setup-constants ((arg0 ocean-mid-constants)) + "Generate the ocean VU1 renderer constants in-place." + + ;; the usual camera math (let ((v1-0 *math-camera*)) (set! (-> arg0 hmge-scale quad) (-> v1-0 hmge-scale quad)) (set! (-> arg0 inv-hmge-scale quad) (-> v1-0 inv-hmge-scale quad)) (set! (-> arg0 hvdf-offset quad) (-> v1-0 hvdf-off quad)) (set-vector! (-> arg0 fog) (-> v1-0 pfog0) (-> v1-0 fog-min) (-> v1-0 fog-max) 3072.0) ) + + ;; is this 393216 the size of a triangle? (96 meters) (set-vector! (-> arg0 constants) 0.5 0.5 0.0 393216.0) (set-vector! (-> arg0 constants2) 0.5 0.5 1.0 0.0) + + (let ((v1-3 *ocean-subdivide-draw-mode*)) (cond ((zero? v1-3) @@ -258,6 +265,8 @@ (set-vector! (-> arg0 index-table 5) 18 24 21 0) (set-vector! (-> arg0 index-table 6) 9 12 12 0) (set-vector! (-> arg0 index-table 7) 0 0 3 0) + + (set-vector! (-> arg0 pos0) 0.0 0.0 0.0 1.0) (set-vector! (-> arg0 pos1) 393216.0 0.0 0.0 1.0) (set-vector! (-> arg0 pos2) 0.0 0.0 393216.0 1.0) @@ -265,9 +274,8 @@ (none) ) -;; definition for function ocean-mid-add-constants -;; INFO: Return type mismatch pointer vs none. (defun ocean-mid-add-constants ((arg0 dma-buffer)) + "Generate DMA for loading ocean-mid constants to VU1 data memory." (let* ((a1-0 36) (v1-0 arg0) (a0-1 (the-as object (-> v1-0 base))) @@ -279,6 +287,7 @@ ) (set! (-> v1-0 base) (&+ (the-as pointer a0-1) 16)) ) + ;; generate the constants in place. (ocean-mid-setup-constants (the-as ocean-mid-constants (-> arg0 base))) (&+! (-> arg0 base) 576) (none) @@ -509,9 +518,10 @@ (none) ) -;; definition for function ocean-mid-add-upload -;; Used lq/sq (defun ocean-mid-add-upload ((arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 float)) + "Add DMA data to upload data needed to draw an ocean tile." + + ;; calculate the location of the tile. (let ((gp-0 (new-stack-vector0))) (let ((v1-1 (-> *ocean-map* start-corner))) (set! (-> gp-0 x) (+ (-> v1-1 x) (* 3145728.0 (the float arg2)))) @@ -519,7 +529,11 @@ (set! (-> gp-0 z) (+ (-> v1-1 z) (* 3145728.0 (the float arg1)))) ) (set! (-> gp-0 w) 1.0) + + ;; compute combined matrix (ocean-mid-add-matrices arg0 gp-0) + + ;; upload color. (let ((v1-4 (+ (the-as uint (-> *ocean-map* ocean-colors)) (* (+ (* 416 arg1) (* arg2 8)) 4)))) (dotimes (a0-6 9) (let* ((a1-3 arg0) @@ -538,6 +552,10 @@ (+! v1-4 208) ) ) + + ;; upload "mid masks". + ;; these allow some zones to be skipped. + ;; using 0 will draw, using 1 willl skip. (let* ((a2-3 1) (v1-7 arg0) (a0-7 (the-as object (-> v1-7 base))) @@ -553,10 +571,15 @@ (let ((a0-12 (-> *ocean-map* ocean-mid-masks data arg3))) (set! (-> *ocean-work* mid-mask-ptrs arg4) (the-as (pointer int64) v1-8)) (set! (-> (the-as (pointer uint64) v1-8)) (-> a0-12 dword)) + ;; (set! (-> (the-as (pointer uint64) v1-8)) #xffffffffffffffff) ) (set! (-> (the-as (pointer uint64) v1-8) 1) (the-as uint 0)) ) (&+! (-> arg0 base) 16) + + ;; when the camera is very close, we need to do additional checking. + ;; I believe this checks which subtiles will be skipped by the renderer + ;; and adds them to the camera masks. (when (< arg5 556091.4) (let* ((v1-12 (-> *math-camera* trans)) (s5-1 (&-> *ocean-work* mid-camera-masks arg4)) @@ -984,6 +1007,7 @@ (defun sphere-cull-for-ocean ((arg0 vector)) "NOTE: added in PC port" + (local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128)) (rlet ((acc :class vf) (vf0 :class vf) @@ -1065,10 +1089,60 @@ (none) ) -;; definition for function draw-ocean-mid -;; INFO: Return type mismatch int vs none. -;; Used lq/sq +;; ADDED for PC Port +(defun debug-draw-ocean-tile ((y int) (x int) (color0 rgba) (color1 rgba) (masks int)) + ;;3145728.0 + (let* ((ps (-> *ocean-map* start-corner)) + (p0 (vector-copy! (new-stack-vector0) ps)) + (p1 (vector-copy! (new-stack-vector0) ps)) + (p2 (vector-copy! (new-stack-vector0) ps)) + (p1s (vector-copy! (new-stack-vector0) ps)) + (p2s (vector-copy! (new-stack-vector0) ps)) + (p3 (vector-copy! (new-stack-vector0) ps)) + (x0 (* 3145728.0 (the float x))) + (y0 (* 3145728.0 (the float y))) + + ) + (+! (-> p0 x) x0) + (+! (-> p0 z) y0) + + (+! (-> p1 x) (+ x0 3145728.0)) + (+! (-> p1 z) y0) + + (+! (-> p2 x) x0) + (+! (-> p2 z) (+ y0 3145728.0)) + + (+! (-> p1s x) (+ x0 314572.0)) + (+! (-> p1s z) y0) + + (+! (-> p2s x) x0) + (+! (-> p2s z) (+ y0 314572.0)) + + (+! (-> p3 x) (+ x0 3145728.0)) + (+! (-> p3 z) (+ y0 3145728.0)) + + (add-debug-flat-triangle #t (bucket-id debug-draw1) p0 p1s p2s color0) + ;; (add-debug-flat-triangle #t (bucket-id debug-draw1) p3 p1 p2 color0) + (add-debug-outline-triangle #t (bucket-id debug-draw1) p0 p1 p2 color1) + (add-debug-outline-triangle #t (bucket-id debug-draw1) p3 p1 p2 color1) + (format (clear *temp-string*) "o: ~d ~d ~d ~b" x y (+ (* 6 y) x) masks) + + (add-debug-text-3d + #t + (bucket-id debug-draw1) + *temp-string* + p0 + (font-color orange-red) + (the vector2h #f) + ) + ) + ) + (defun draw-ocean-mid ((arg0 dma-buffer)) + "Main function to draw the 'mid' ocean + The mid ocean is used to draw the non-transparent ocean parts. + There is a large 6x6 grid of tiles. + Tiles that are closer to the camera have an environment mapping effect applied." (rlet ((vf16 :class vf) (vf17 :class vf) (vf18 :class vf) @@ -1078,11 +1152,16 @@ (vf22 :class vf) (vf23 :class vf) ) + + ;; first, reset all masks to 0 (dotimes (v1-0 36) (set! (-> *ocean-work* mid-mask-ptrs v1-0) (the-as (pointer int64) #f)) (set! (-> *ocean-work* mid-camera-masks v1-0) (the-as uint 0)) ) + ;; upload VU1 program (dma-buffer-add-vu-function arg0 ocean-mid-block 1) + + ;; set up base+offset for the VU1 program uploads (let* ((v1-3 arg0) (a0-6 (the-as object (-> v1-3 base))) ) @@ -1091,10 +1170,15 @@ (set! (-> (the-as dma-packet a0-6) vif1) (new 'static 'vif-tag :imm #x76 :cmd (vif-cmd offset))) (set! (-> v1-3 base) (&+ (the-as pointer a0-6) 16)) ) + + ;; upload ocean constants (ocean-mid-add-constants arg0) + + ;; run program to initialize VU1 renderer (ocean-mid-add-call arg0 0) + + ;; set up VF registers for sphere culling. (let ((v1-5 *math-camera*)) - ;; note: these are for sphere cull. (.lvf vf16 (&-> v1-5 plane 0 quad)) (.lvf vf17 (&-> v1-5 plane 1 quad)) (.lvf vf18 (&-> v1-5 plane 2 quad)) @@ -1105,26 +1189,30 @@ (.lvf vf23 (&-> v1-5 guard-plane 3 quad)) ) (set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0)) + + ;; draw tiles! (let ((s5-0 (-> *math-camera* trans))) - (dotimes (s4-0 6) - (dotimes (s3-0 6) - (let* ((s2-0 (+ (* 6 s4-0) s3-0)) - (s1-0 (-> *ocean-map* ocean-spheres spheres s2-0)) + (dotimes (s4-0 6) ;; x? + (dotimes (s3-0 6) ;; y? + (let* ((s2-0 (+ (* 6 s4-0) s3-0)) ;; tile index + (s1-0 (-> *ocean-map* ocean-spheres spheres s2-0)) ;; vis sphere of ocean (s0-0 (-> (the-as (pointer int16) (+ (* s2-0 2) (the-as int (-> *ocean-map* ocean-mid-indices)))))) ) + ;; (format 0 "draw ocean tile: ~d x ~d = ~d index ~d~%" s4-0 s3-0 s2-0 s0-0) + ;; (debug-draw-ocean-tile s4-0 s3-0 (new 'static 'rgba :r #x80 :a #x80) (new 'static 'rgba :g #x80 :a #x80) s0-0) (when (sphere-cull-for-ocean s1-0) + ;;(format 0 " vis!~%") (cond ((< s0-0 0) + ;; (format 0 " skip tile.~%") ) - ( - - (let ((f30-0 (- (vector-vector-distance s1-0 s5-0) (-> s1-0 w)))) + ((let ((f30-0 (- (vector-vector-distance s1-0 s5-0) (-> s1-0 w)))) (ocean-mid-add-upload arg0 s4-0 s3-0 s0-0 s2-0 f30-0) (< f30-0 786432.0) ;; HACK ;; #t ) - + ;; (format 0 " draw env map~%") (ocean-mid-add-call arg0 73) (+! (-> *terrain-stats* ocean-mid fragments) 1) (+! (-> *terrain-stats* ocean-mid tris) 256) @@ -1142,60 +1230,65 @@ ) ) ) - #| + + ; (dotimes (i 36) + ; (format 0 "tidx: ~d ~X~%" i (-> *ocean-work* mid-camera-masks i)) + ; ) + ;; for now, skip seams. - (when (not (or *ocean-near-off* (< 196608.0 (fabs (-> *math-camera* trans y))))) - (let ((a1-11 48) - (a2-2 0) - (v1-42 48) - (a0-25 0) - ) - (dotimes (a3-1 6) - (dotimes (t0-1 6) - (let ((t1-6 (&-> *ocean-work* mid-camera-masks (+ (* 6 a3-1) t0-1)))) - (when (nonzero? (-> t1-6 0)) - (dotimes (t2-3 8) - (let ((t3-1 (-> (the-as (pointer uint8) (+ t2-3 (the-as int t1-6))) 0))) - (when (nonzero? t3-1) - (let ((t4-2 (+ (* a3-1 8) t2-3))) - (if (< t4-2 v1-42) - (set! v1-42 t4-2) - ) - (if (< a0-25 t4-2) - (set! a0-25 t4-2) - ) - ) - (dotimes (t4-3 8) - (when (logtest? t3-1 (ash 1 t4-3)) - (let ((t5-9 (+ (* t0-1 8) t4-3))) - (if (< t5-9 a1-11) - (set! a1-11 t5-9) - ) - (if (< a2-2 t5-9) - (set! a2-2 t5-9) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (set! (-> *ocean-work* mid-minx) (the-as uint a1-11)) - (set! (-> *ocean-work* mid-maxx) (the-as uint a2-2)) - (set! (-> *ocean-work* mid-minz) (the-as uint v1-42)) - (set! (-> *ocean-work* mid-maxz) (the-as uint a0-25)) - (when (and (< a1-11 a2-2) (< v1-42 a0-25)) - (ocean-mid-add-call-flush arg0 (the-as uint 41)) - (ocean-mid-add-call-flush arg0 (the-as uint 43)) - (draw-ocean-transition arg0) - (draw-ocean-mid-seams arg0) - ) - ) - ) |# + ; (when (not (or *ocean-near-off* (< 196608.0 (fabs (-> *math-camera* trans y))))) + ; (let ((a1-11 48) + ; (a2-2 0) + ; (v1-42 48) + ; (a0-25 0) + ; ) + ; (dotimes (a3-1 6) + ; (dotimes (t0-1 6) + ; (let ((t1-6 (&-> *ocean-work* mid-camera-masks (+ (* 6 a3-1) t0-1)))) + ; (when (nonzero? (-> t1-6 0)) + ; (dotimes (t2-3 8) + ; (let ((t3-1 (-> (the-as (pointer uint8) (+ t2-3 (the-as int t1-6))) 0))) + ; (when (nonzero? t3-1) + ; (let ((t4-2 (+ (* a3-1 8) t2-3))) + ; (if (< t4-2 v1-42) + ; (set! v1-42 t4-2) + ; ) + ; (if (< a0-25 t4-2) + ; (set! a0-25 t4-2) + ; ) + ; ) + ; (dotimes (t4-3 8) + ; (when (logtest? t3-1 (ash 1 t4-3)) + ; (let ((t5-9 (+ (* t0-1 8) t4-3))) + ; (if (< t5-9 a1-11) + ; (set! a1-11 t5-9) + ; ) + ; (if (< a2-2 t5-9) + ; (set! a2-2 t5-9) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; (set! (-> *ocean-work* mid-minx) (the-as uint a1-11)) + ; (set! (-> *ocean-work* mid-maxx) (the-as uint a2-2)) + ; (set! (-> *ocean-work* mid-minz) (the-as uint v1-42)) + ; (set! (-> *ocean-work* mid-maxz) (the-as uint a0-25)) + ; (when (and (< a1-11 a2-2) (< v1-42 a0-25)) + ; (format *stdcon* "transition~%") + ; (ocean-mid-add-call-flush arg0 (the-as uint 41)) + ; (ocean-mid-add-call-flush arg0 (the-as uint 43)) + ; (draw-ocean-transition arg0) + ; (draw-ocean-mid-seams arg0) + ; ) + ; ) + ; ) (ocean-mid-add-call-flush arg0 (the-as uint 41)) 0 (none) From 865a0aea63c5191ba9ca578ace6bc9a5bc1ea8ba Mon Sep 17 00:00:00 2001 From: water Date: Sun, 13 Mar 2022 16:50:10 -0400 Subject: [PATCH 3/6] fix seams --- .../opengl_renderer/ocean/OceanMid.cpp | 4 +- .../graphics/opengl_renderer/ocean/OceanMid.h | 2 +- .../opengl_renderer/ocean/OceanMid_PS2.cpp | 482 +++++++++--------- goal_src/engine/gfx/ocean/ocean-mid.gc | 108 ++-- 4 files changed, 300 insertions(+), 296 deletions(-) diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.cpp b/game/graphics/opengl_renderer/ocean/OceanMid.cpp index c07127e6c5..0d6d675b5d 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid.cpp @@ -76,8 +76,8 @@ void OceanMid::run(DmaFollower& dma, } memcpy(m_vu_data + addr + i, temp, 16); } + ASSERT(4 * v1.num == data.size_bytes); - // TODO } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x204 && v1.kind == VifCode::Kind::UNPACK_V4_8) { auto up = VifCodeUnpack(v1); @@ -96,7 +96,7 @@ void OceanMid::run(DmaFollower& dma, u32 addr_off = 4 * (i / 2) + i % 2; memcpy(m_vu_data + addr + addr_off, temp, 16); } - + ASSERT(8 * v1.num == data.size_bytes); // TODO } else if (v0.kind == VifCode::Kind::STCYCL && v0.immediate == 0x404 && v1.kind == VifCode::Kind::MSCALF) { diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.h b/game/graphics/opengl_renderer/ocean/OceanMid.h index 287f2b1b2e..7654c85163 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.h +++ b/game/graphics/opengl_renderer/ocean/OceanMid.h @@ -152,7 +152,7 @@ class OceanMid { Vf m_vu_data[1024]; - void sq_buffer(int line_num, Mask mask, const Vf& val, u16 addr) { + void sq_buffer(Mask mask, const Vf& val, u16 addr) { ASSERT(addr < 1024); for (int i = 0; i < 4; i++) { if ((u64)mask & (1 << i)) { diff --git a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp index 1e2f53ac45..049416313f 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp @@ -30,8 +30,10 @@ u32 clip(const Vf& vector, float val, u32 old_clip) { } void fcand(u16& dest, u32 imm, u32 cf) { // dest = (cf & imm) ? 1 : 0; - if((cf & 0xFFFFFF) & (imm& 0xFFFFFF)) dest = 1; - else dest = 0; + if ((cf & 0xFFFFFF) & (imm & 0xFFFFFF)) + dest = 1; + else + dest = 0; // dest = cf & imm; // wrong } @@ -82,13 +84,13 @@ void OceanMid::run_call0_vu2c() { // lq.xyzw vf21, 749(vi01) | nop 8 lq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 749); // sq.xyzw vf20, 335(vi01) | nop 9 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi01 + 335); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 335); // sq.xyzw vf20, 457(vi01) | nop 10 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi01 + 457); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi01 + 457); // sq.xyzw vf21, 396(vi01) | nop 11 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi01 + 396); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 396); // sq.xyzw vf21, 518(vi01) | nop 12 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi01 + 518); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi01 + 518); // BRANCH! // ibgtz vi01, L1 | nop 13 bc = ((s16)vu.vi01) > 0; @@ -109,7 +111,7 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 8; L3: // sq.xyzw vf16, 236(vi05) | nop 18 - sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi05 + 236); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi05 + 236); // iaddi vi05, vi05, 0x1 | addw.x vf16, vf16, vf05 19 vu.vf16.add(Mask::x, vu.vf16, vu.vf05.w()); vu.vi05 = vu.vi05 + 1; @@ -144,10 +146,10 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 8; L4: // sq.xyzw vf20, 317(vi03) | nop 28 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi03 + 317); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi03 + 317); // sq.xyzw vf21, 318(vi03) | addw.x vf20, vf20, vf00 29 vu.vf20.add(Mask::x, vu.vf20, vu.vf00.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi03 + 318); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi03 + 318); // iaddi vi03, vi03, 0x2 | addw.x vf21, vf21, vf00 30 vu.vf21.add(Mask::x, vu.vf21, vu.vf00.w()); vu.vi03 = vu.vi03 + 2; @@ -169,9 +171,9 @@ void OceanMid::run_call0_vu2c() { vu.vi06 = 0x11; /* 17 */ L5: // sq.xyzw vf08, 396(vi04) | nop 36 - sq_buffer(__LINE__, Mask::xyzw, vu.vf08, vu.vi04 + 396); + sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 396); // sq.xyzw vf08, 518(vi04) | nop 37 - sq_buffer(__LINE__, Mask::xyzw, vu.vf08, vu.vi04 + 518); + sq_buffer(Mask::xyzw, vu.vf08, vu.vi04 + 518); // iaddi vi04, vi04, 0x3 | nop 38 vu.vi04 = vu.vi04 + 3; // BRANCH! @@ -229,9 +231,9 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, // lq.xyzw vf15, 7(vi02) | nop 51 lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); // sq.xyzw vf07, 341(vi00) | nop 52 - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 341); + sq_buffer(Mask::xyzw, vu.vf07, 341); // sq.xyzw vf07, 463(vi00) | nop 53 - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 463); + sq_buffer(Mask::xyzw, vu.vf07, 463); // iaddi vi07, vi00, 0x7 | nop 54 vu.vi07 = 7; // lq.xyzw vf04, 116(vi02) | nop 55 @@ -321,9 +323,9 @@ void OceanMid::run_call73_vu2c(SharedRenderState* render_state, // lq.xyzw vf15, 7(vi02) | nop 82 lq_buffer(Mask::xyzw, vu.vf15, vu.vi02 + 7); // sq.xyzw vf07, 341(vi00) | nop 83 - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 341); + sq_buffer(Mask::xyzw, vu.vf07, 341); // sq.xyzw vf07, 463(vi00) | nop 84 - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, 463); + sq_buffer(Mask::xyzw, vu.vf07, 463); // iaddi vi07, vi00, 0x7 | nop 85 vu.vi07 = 7; // lq.xyzw vf04, 116(vi02) | nop 86 @@ -410,7 +412,7 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // xtop vi02 | nop 107 vu.vi02 = xtop(); // xtop vi03 | nop 108 - vu.vi03 = xtop(); + vu.vi03 = vu.vi02; // xtop(); // ior vi04, vi00, vi00 | nop 109 vu.vi04 = 0; // ilw.x vi05, 8(vi02) | nop 110 @@ -498,13 +500,13 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, vu.acc.madda(Mask::xyzw, vu.vf18, vu.vf16.z()); // sq.xyzw vf20, 791(vi04) | maddw.xyzw vf22, vf19, vf16 145 vu.acc.madd(Mask::xyzw, vu.vf22, vu.vf19, vu.vf16.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi04 + 791); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi04 + 791); // sq.xyzw vf28, 793(vi04) | mulw.xy vf24, vf24, vf24 146 vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi04 + 793); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi04 + 793); // sq.xyzw vf22, 792(vi04) | mula.xyzw ACC, vf24, vf05 147 vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi04 + 792); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi04 + 792); // iaddi vi04, vi04, 0x4 | maddw.xyzw vf24, vf06, vf00 148 vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); vu.vi04 = vu.vi04 + 4; @@ -512,7 +514,7 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // ibgtz vi05, L17 | nop 149 bc = ((s16)vu.vi05) > 0; // sq.xyzw vf24, 790(vi04) | nop 150 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04 + 790); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04 + 790); if (bc) { goto L17; } @@ -542,29 +544,29 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf07, 739(vi00) | nop 162 lq_buffer(Mask::xyzw, vu.vf07, 739); // sq.xyzw vf28, 579(vi00) | nop 163 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 579); + sq_buffer(Mask::xyzw, vu.vf28, 579); // sq.xyzw vf29, 580(vi00) | nop 164 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 580); + sq_buffer(Mask::xyzw, vu.vf29, 580); // sq.xyzw vf30, 581(vi00) | nop 165 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 581); + sq_buffer(Mask::xyzw, vu.vf30, 581); // sq.xyzw vf24, 582(vi00) | nop 166 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 582); + sq_buffer(Mask::xyzw, vu.vf24, 582); // sq.xyzw vf25, 583(vi00) | nop 167 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 583); + sq_buffer(Mask::xyzw, vu.vf25, 583); // sq.xyzw vf26, 584(vi00) | nop 168 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 584); + sq_buffer(Mask::xyzw, vu.vf26, 584); // sq.xyzw vf28, 656(vi00) | nop 169 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 656); + sq_buffer(Mask::xyzw, vu.vf28, 656); // sq.xyzw vf29, 657(vi00) | nop 170 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 657); + sq_buffer(Mask::xyzw, vu.vf29, 657); // sq.xyzw vf30, 658(vi00) | nop 171 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 658); + sq_buffer(Mask::xyzw, vu.vf30, 658); // sq.xyzw vf24, 659(vi00) | nop 172 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 659); + sq_buffer(Mask::xyzw, vu.vf24, 659); // sq.xyzw vf25, 660(vi00) | nop 173 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 660); + sq_buffer(Mask::xyzw, vu.vf25, 660); // sq.xyzw vf26, 661(vi00) | nop 174 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 661); + sq_buffer(Mask::xyzw, vu.vf26, 661); // iaddi vi11, vi11, -0x2 | nop 175 vu.vi11 = vu.vi11 + -2; L18: @@ -600,23 +602,23 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf29, 797(vi14) | nop 188 lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 797); // sq.xyzw vf20, 0(vi08) | nop 189 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 190 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 191 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf21, 3(vi08) | nop 192 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | nop 193 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf29, 5(vi08) | nop 194 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf20, 12(vi08) | nop 195 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 12); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08 + 12); // sq.xyzw vf22, 13(vi08) | nop 196 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 13); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 13); // sq.xyzw vf28, 14(vi08) | nop 197 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 14); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 14); // lq.xyzw vf20, 803(vi14) | nop 198 lq_buffer(Mask::xyzw, vu.vf20, vu.vi14 + 803); // lq.xyzw vf22, 804(vi14) | nop 199 @@ -630,20 +632,20 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf29, 801(vi14) | nop 203 lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 801); // sq.xyzw vf20, 6(vi08) | nop 204 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 6); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08 + 6); // sq.xyzw vf22, 7(vi08) | nop 205 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 7); // sq.xyzw vf28, 8(vi08) | nop 206 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 8); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 8); // sq.xyzw vf21, 9(vi08) | nop 207 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 9); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 9); // sq.xyzw vf23, 10(vi08) | nop 208 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 10); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 10); // BRANCH! // bal vi13, L45 | nop 209 // ASSERT(false); // sq.xyzw vf29, 11(vi08) | nop 210 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 11); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 11); // if (bc) { goto L45; } run_L45_vu2c(render_state, prof, direct); @@ -717,23 +719,23 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf29, 797(vi14) | nop 234 lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 797); // sq.xyzw vf24, 0(vi08) | nop 235 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 236 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 237 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf25, 3(vi08) | nop 238 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 3); // sq.xyzw vf22, 4(vi08) | nop 239 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 4); // sq.xyzw vf29, 5(vi08) | nop 240 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf24, 12(vi08) | nop 241 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 12); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 12); // sq.xyzw vf22, 13(vi08) | nop 242 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 13); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 13); // sq.xyzw vf28, 14(vi08) | nop 243 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 14); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 14); // lq.xyzw vf24, 806(vi14) | nop 244 lq_buffer(Mask::xyzw, vu.vf24, vu.vi14 + 806); // lq.xyzw vf28, 805(vi14) | nop 245 @@ -743,20 +745,20 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf29, 801(vi14) | nop 247 lq_buffer(Mask::xyzw, vu.vf29, vu.vi14 + 801); // sq.xyzw vf24, 6(vi08) | nop 248 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 6); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 6); // sq.xyzw vf22, 7(vi08) | nop 249 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 7); // sq.xyzw vf28, 8(vi08) | nop 250 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 8); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 8); // sq.xyzw vf25, 9(vi08) | nop 251 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 9); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 9); // sq.xyzw vf22, 10(vi08) | nop 252 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); // BRANCH! // bal vi13, L45 | nop 253 // ASSERT(false); // sq.xyzw vf29, 11(vi08) | nop 254 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 11); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 11); // if (bc) { goto L45; } run_L45_vu2c(render_state, prof, direct); @@ -780,17 +782,17 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // lq.xyzw vf26, 754(vi00) | nop 261 lq_buffer(Mask::xyzw, vu.vf26, 754); // sq.xyzw vf28, 0(vi10) | nop 262 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 263 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 264 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 265 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 266 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 267 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 268 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! @@ -827,7 +829,7 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // xtop vi02 | nop 275 vu.vi02 = xtop(); // xtop vi03 | nop 276 - vu.vi03 = xtop(); + vu.vi03 = vu.vi02; // xtop(); // ior vi04, vi00, vi00 | nop 277 vu.vi04 = 0; // iaddi vi08, vi10, 0x7 | nop 278 @@ -917,15 +919,15 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, vu.acc.madda(Mask::xyzw, vu.vf18, vu.vf16.z()); // sq.xyzw vf20, 0(vi08) | maddw.xyzw vf22, vf19, vf16 314 vu.acc.madd(Mask::xyzw, vu.vf22, vu.vf19, vu.vf16.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf28, 2(vi08) | mulw.xy vf24, vf24, vf24 315 vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf28, 792(vi04) | nop 316 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi04 + 792); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi04 + 792); // sq.xyzw vf22, 1(vi08) | mula.xyzw ACC, vf24, vf05 317 vu.acc.mula(Mask::xyzw, vu.vf24, vu.vf05); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // iaddi vi04, vi04, 0x2 | maddw.xyzw vf24, vf06, vf00 318 vu.acc.madd(Mask::xyzw, vu.vf24, vu.vf06, vu.vf00.w()); vu.vi04 = vu.vi04 + 2; @@ -935,7 +937,7 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // ibgtz vi05, L23 | nop 320 bc = ((s16)vu.vi05) > 0; // sq.xyzw vf24, 789(vi04) | nop 321 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04 + 789); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04 + 789); if (bc) { goto L23; } @@ -952,11 +954,11 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // lq.xyzw vf28, 9(vi10) | nop 326 lq_buffer(Mask::xyzw, vu.vf28, vu.vi10 + 9); // sq.xyzw vf20, 0(vi08) | nop 327 - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 328 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 329 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // iaddi vi08, vi10, 0x7 | nop 330 vu.vi08 = vu.vi10 + 7; // BRANCH! @@ -990,17 +992,17 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // lq.xyzw vf07, 739(vi00) | nop 340 lq_buffer(Mask::xyzw, vu.vf07, 739); // sq.xyzw vf28, 0(vi10) | nop 341 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 342 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 343 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 344 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 345 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 346 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 347 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! @@ -1031,11 +1033,11 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // iaddi vi05, vi05, -0x1 | nop 357 vu.vi05 = vu.vi05 + -1; // sq.xyzw vf22, 1(vi08) | nop 358 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 359 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf24, 0(vi08) | nop 360 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); // BRANCH! // ibgtz vi05, L24 | nop 361 bc = ((s16)vu.vi05) > 0; @@ -1054,11 +1056,11 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // lq.xyzw vf24, 9(vi10) | nop 366 lq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 9); // sq.xyzw vf24, 0(vi08) | nop 367 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 368 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 369 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // iaddi vi08, vi10, 0x7 | nop 370 vu.vi08 = vu.vi10 + 7; // BRANCH! @@ -1086,17 +1088,17 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // lq.xyzw vf07, 740(vi00) | nop 379 lq_buffer(Mask::xyzw, vu.vf07, 740); // sq.xyzw vf28, 0(vi10) | nop 380 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 381 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 382 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 383 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 384 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 385 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 386 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! @@ -1235,13 +1237,13 @@ void OceanMid::run_L26_vu2c(SharedRenderState* render_state, vu.vi12 = vu.vi12 + vu.vi12; // sq.xyzw vf21, 3(vi08) | mulax.xyzw ACC, vf12, vf28 429 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | madday.xyzw ACC, vf13, vf28 430 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | clipw.xyz vf19, vf19 431 cf = clip(vu.vf19, vu.vf19.w(), cf); - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); // lq.xyzw vf29, 245(vi05) | miniz.w vf16, vf16, vf03 432 vu.vf16.mini(Mask::w, vu.vf16, vu.vf03.z()); lq_buffer(Mask::xyzw, vu.vf29, vu.vi05 + 245); @@ -1286,13 +1288,13 @@ void OceanMid::run_L26_vu2c(SharedRenderState* render_state, vu.vi04 = vu.vi04 + 1; // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf12, vf29 444 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf13, vf29 445 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf16, 2(vi08) | clipw.xyz vf18, vf18 446 cf = clip(vu.vf18, vu.vf18.w(), cf); - sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); // lq.xyzw vf28, 236(vi05) | miniz.w vf17, vf17, vf03 447 vu.vf17.mini(Mask::w, vu.vf17, vu.vf03.z()); lq_buffer(Mask::xyzw, vu.vf28, vu.vi05 + 236); @@ -1323,11 +1325,11 @@ void OceanMid::run_L26_vu2c(SharedRenderState* render_state, vu.vf17.ftoi4(Mask::xyzw, vu.vf17); // vu.vf17.fill(0); // sq.xyzw vf21, 3(vi08) | nop 454 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | nop 455 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | nop 456 - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); // jr vi15 | nop 457 return; // nop | nop 458 @@ -1575,19 +1577,19 @@ void OceanMid::run_L32_vu2c(SharedRenderState* render_state, // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 533 vu.vf25.z() = 1; // TODO hack vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | mulw.xy vf24, vf26, vf26 534 vu.vf24.mul(Mask::xy, vu.vf26, vu.vf26.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | mulax.xyzw ACC, vf12, vf28 535 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf28.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); // sq.xyzw vf17, 66(vi08) | madday.xyzw ACC, vf13, vf28 536 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf28.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 66); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); // sq.xyzw vf25, 64(vi08) | maddaz.xyzw ACC, vf14, vf28 537 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf28.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 64); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); // iaddi vi08, vi08, 0x6 | maddw.xyzw vf30, vf15, vf00 538 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); vu.vi08 = vu.vi08 + 6; @@ -1719,19 +1721,19 @@ void OceanMid::run_L32_vu2c(SharedRenderState* render_state, // todo hack vu.vf24.z() = 1; vu.vf24.mul(Mask::xyzw, vu.vf24, vu.vf20.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | mulw.xy vf25, vf27, vf27 574 vu.vf25.mul(Mask::xy, vu.vf27, vu.vf27.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf16, 2(vi08) | mulax.xyzw ACC, vf12, vf29 575 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 2); // sq.xyzw vf16, 63(vi08) | madday.xyzw ACC, vf13, vf29 576 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 63); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 63); // sq.xyzw vf24, 61(vi08) | maddaz.xyzw ACC, vf14, vf29 577 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 61); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 61); // iaddi vi04, vi04, 0x1 | maddw.xyzw vf31, vf15, vf00 578 vu.acc.madd(Mask::xyzw, vu.vf31, vu.vf15, vu.vf00.w()); vu.vi04 = vu.vi04 + 1; @@ -1846,15 +1848,15 @@ void OceanMid::run_L32_vu2c(SharedRenderState* render_state, // vu.vf17.fill(0); // sq.xyzw vf21, 3(vi08) | mulz.xyzw vf25, vf25, vf21 607 vu.vf25.mul(Mask::xyzw, vu.vf25, vu.vf21.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | nop 608 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf17, 5(vi08) | nop 609 - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 5); // sq.xyzw vf17, 66(vi08) | nop 610 - sq_buffer(__LINE__, Mask::xyzw, vu.vf17, vu.vi08 + 66); + sq_buffer(Mask::xyzw, vu.vf17, vu.vi08 + 66); // sq.xyzw vf25, 64(vi08) | nop 611 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 64); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 64); // jr vi15 | nop 612 // nop | nop 613 } @@ -1962,28 +1964,28 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, vu.vf16.itof0(Mask::xyzw, vu.vf16); // sq.xyzw vf20, 0(vi08) | mulax.xyzw ACC, vf08, vf29 649 vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf29.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08); // sq.xyzw vf22, 1(vi08) | madday.xyzw ACC, vf09, vf29 650 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf29.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf21, 3(vi08) | maddaz.xyzw ACC, vf10, vf29 651 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf29.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + 3); // sq.xyzw vf23, 4(vi08) | maddw.xyzw vf25, vf11, vf00 652 vu.acc.madd(Mask::xyzw, vu.vf25, vu.vf11, vu.vf00.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi08 + 4); // sq.xyzw vf07, 6(vi08) | mulax.xyzw ACC, vf12, vf29 653 vu.acc.mula(Mask::xyzw, vu.vf12, vu.vf29.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, vu.vi08 + 6); + sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + 6); // sq.xyzw vf16, 7(vi08) | madday.xyzw ACC, vf13, vf29 654 vu.acc.madda(Mask::xyzw, vu.vf13, vu.vf29.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf16, vu.vi08 + 7); + sq_buffer(Mask::xyzw, vu.vf16, vu.vi08 + 7); // sq.xyzw vf20, 9(vi08) | maddaz.xyzw ACC, vf14, vf29 655 vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf29.z()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf20, vu.vi08 + 9); + sq_buffer(Mask::xyzw, vu.vf20, vu.vi08 + 9); // sq.xyzw vf22, 10(vi08) | maddw.xyzw vf29, vf15, vf00 656 vu.acc.madd(Mask::xyzw, vu.vf29, vu.vf15, vu.vf00.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); // waitp | mul.xyzw vf28, vf28, vf01 657 vu.vf28.mul(Mask::xyzw, vu.vf28, vu.vf01); // mfp.w vf24, P | nop 658 @@ -1994,13 +1996,13 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, vu.vf25.add(Mask::y, vu.vf00, vu.vf25.z()); // sq.xyzw vf28, 2(vi08) | mulax.xyzw ACC, vf08, vf30 661 vu.acc.mula(Mask::xyzw, vu.vf08, vu.vf30.x()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf28, 11(vi08) | mulw.xy vf24, vf24, vf24 662 vu.vf24.mul(Mask::xy, vu.vf24, vu.vf24.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 11); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); // sq.xyzw vf28, 772(vi00) | madday.xyzw ACC, vf09, vf30 663 vu.acc.madda(Mask::xyzw, vu.vf09, vu.vf30.y()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, 772); + sq_buffer(Mask::xyzw, vu.vf28, 772); // nop | maddaz.xyzw ACC, vf10, vf30 664 vu.acc.madda(Mask::xyzw, vu.vf10, vu.vf30.z()); // nop | maddw.xyzw vf26, vf11, vf00 665 @@ -2017,7 +2019,7 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, vu.acc.madda(Mask::xyzw, vu.vf14, vu.vf30.z()); // sq.xyzw vf24, 769(vi00) | maddw.xyzw vf30, vf15, vf00 671 vu.acc.madd(Mask::xyzw, vu.vf30, vu.vf15, vu.vf00.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, 769); + sq_buffer(Mask::xyzw, vu.vf24, 769); // waitp | mul.xyzw vf29, vf29, vf01 672 vu.vf29.mul(Mask::xyzw, vu.vf29, vu.vf01); // mfp.w vf25, P | nop 673 @@ -2027,10 +2029,10 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // nop | addz.y vf26, vf00, vf26 675 vu.vf26.add(Mask::y, vu.vf00, vu.vf26.z()); // sq.xyzw vf29, 5(vi08) | nop 676 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf29, 773(vi00) | mulw.xy vf25, vf25, vf25 677 vu.vf25.mul(Mask::xy, vu.vf25, vu.vf25.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, 773); + sq_buffer(Mask::xyzw, vu.vf29, 773); // nop | mula.xyzw ACC, vf25, vf05 678 vu.acc.mula(Mask::xyzw, vu.vf25, vu.vf05); // nop | maddw.xyzw vf25, vf06, vf00 679 @@ -2040,13 +2042,13 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // mfp.w vf26, P | nop 681 vu.vf26.mfp(Mask::w, vu.P); // sq.xyzw vf30, 8(vi08) | nop 682 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi08 + 8); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); // sq.xyzw vf30, 774(vi00) | mulw.xy vf26, vf26, vf26 683 vu.vf26.mul(Mask::xy, vu.vf26, vu.vf26.w()); - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, 774); + sq_buffer(Mask::xyzw, vu.vf30, 774); // sq.xyzw vf25, 770(vi00) | mula.xyzw ACC, vf26, vf05 684 vu.acc.mula(Mask::xyzw, vu.vf26, vu.vf05); - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, 770); + sq_buffer(Mask::xyzw, vu.vf25, 770); // lq.xyzw vf07, 739(vi00) | maddw.xyzw vf26, vf06, vf00 685 vu.acc.madd(Mask::xyzw, vu.vf26, vu.vf06, vu.vf00.w()); lq_buffer(Mask::xyzw, vu.vf07, 739); @@ -2058,7 +2060,7 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // bal vi13, L45 | nop 688 // sq.xyzw vf26, 771(vi00) | nop 689 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, 771); + sq_buffer(Mask::xyzw, vu.vf26, 771); // if (bc) { goto L45; } run_L45_vu2c(render_state, prof, direct); @@ -2082,17 +2084,17 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // lq.xyzw vf26, 746(vi00) | nop 696 lq_buffer(Mask::xyzw, vu.vf26, 746); // sq.xyzw vf28, 0(vi10) | nop 697 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 698 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 699 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 700 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 701 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 702 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 703 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! @@ -2120,29 +2122,29 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // lq.xyzw vf30, 774(vi00) | nop 713 lq_buffer(Mask::xyzw, vu.vf30, 774); // sq.xyzw vf24, 0(vi08) | nop 714 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08); // sq.xyzw vf22, 1(vi08) | nop 715 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 1); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 1); // sq.xyzw vf28, 2(vi08) | nop 716 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 2); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 2); // sq.xyzw vf25, 3(vi08) | nop 717 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi08 + 3); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi08 + 3); // sq.xyzw vf22, 4(vi08) | nop 718 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 4); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 4); // sq.xyzw vf29, 5(vi08) | nop 719 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi08 + 5); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 5); // sq.xyzw vf26, 6(vi08) | nop 720 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi08 + 6); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi08 + 6); // sq.xyzw vf22, 7(vi08) | nop 721 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 7); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 7); // sq.xyzw vf30, 8(vi08) | nop 722 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi08 + 8); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi08 + 8); // sq.xyzw vf24, 9(vi08) | nop 723 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + 9); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + 9); // sq.xyzw vf22, 10(vi08) | nop 724 - sq_buffer(__LINE__, Mask::xyzw, vu.vf22, vu.vi08 + 10); + sq_buffer(Mask::xyzw, vu.vf22, vu.vi08 + 10); // sq.xyzw vf28, 11(vi08) | nop 725 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi08 + 11); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi08 + 11); // ior vi03, vi08, vi00 | nop 726 vu.vi03 = vu.vi08; // iaddi vi05, vi00, 0x3 | nop 727 @@ -2168,17 +2170,17 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // lq.xyzw vf26, 754(vi00) | nop 735 lq_buffer(Mask::xyzw, vu.vf26, 754); // sq.xyzw vf28, 0(vi10) | nop 736 - sq_buffer(__LINE__, Mask::xyzw, vu.vf28, vu.vi10); + sq_buffer(Mask::xyzw, vu.vf28, vu.vi10); // sq.xyzw vf29, 1(vi10) | nop 737 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi10 + 1); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi10 + 1); // sq.xyzw vf30, 2(vi10) | nop 738 - sq_buffer(__LINE__, Mask::xyzw, vu.vf30, vu.vi10 + 2); + sq_buffer(Mask::xyzw, vu.vf30, vu.vi10 + 2); // sq.xyzw vf24, 3(vi10) | nop 739 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi10 + 3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi10 + 3); // sq.xyzw vf25, 4(vi10) | nop 740 - sq_buffer(__LINE__, Mask::xyzw, vu.vf25, vu.vi10 + 4); + sq_buffer(Mask::xyzw, vu.vf25, vu.vi10 + 4); // sq.xyzw vf26, 5(vi10) | nop 741 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi10 + 5); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi10 + 5); // iaddiu vi06, vi05, 0x4000 | nop 742 vu.vi06 = vu.vi05 + 0x4000; /* 16384 */ // BRANCH! @@ -2208,7 +2210,7 @@ void OceanMid::run_L43_vu2c(SharedRenderState* render_state, bool bc; L43: // sq.xyzw vf07, -1(vi08) | nop 749 - sq_buffer(__LINE__, Mask::xyzw, vu.vf07, vu.vi08 + -1); + sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + -1); // isw.x vi06, -1(vi08) | nop 750 isw_buffer(Mask::x, vu.vi06, vu.vi08 + -1); L44: @@ -2277,11 +2279,11 @@ void OceanMid::run_L43_vu2c(SharedRenderState* render_state, // nop | nop 781 // sq.xyzw vf24, -3(vi08) | nop 782 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi08 + -3); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi08 + -3); // sq.xyzw vf27, -2(vi08) | nop 783 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi08 + -2); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi08 + -2); // sq.xyzw vf21, -1(vi08) | nop 784 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi08 + -1); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi08 + -1); // iaddi vi05, vi05, -0x1 | nop 785 vu.vi05 = vu.vi05 + -1; // nop | nop 786 @@ -2376,11 +2378,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, } // sqi.xyzw vf24, vi04 | nop 814 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 815 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 816 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); L47: // move.xyzw vf24, vf25 | nop 817 vu.vf24.move(Mask::xyzw, vu.vf25); @@ -2406,11 +2408,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // ior vi03, vi08, vi00 | nop 825 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 826 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 827 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 828 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi00, vi06, L56 | nop 829 bc = (vu.vi06 == 0); @@ -2483,11 +2485,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, } // sqi.xyzw vf24, vi04 | nop 852 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 853 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 854 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); L49: // move.xyzw vf24, vf25 | nop 855 vu.vf24.move(Mask::xyzw, vu.vf25); @@ -2513,11 +2515,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // ior vi03, vi08, vi00 | nop 863 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 864 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 865 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 866 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi00, vi06, L56 | nop 867 bc = (vu.vi06 == 0); @@ -2590,11 +2592,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, } // sqi.xyzw vf24, vi04 | nop 890 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 891 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 892 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); L51: // move.xyzw vf24, vf25 | nop 893 vu.vf24.move(Mask::xyzw, vu.vf25); @@ -2620,11 +2622,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // ior vi03, vi08, vi00 | nop 901 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 902 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 903 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 904 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi00, vi06, L56 | nop 905 bc = (vu.vi06 == 0); @@ -2697,11 +2699,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, } // sqi.xyzw vf24, vi04 | nop 928 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 929 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 930 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); L53: // move.xyzw vf24, vf25 | nop 931 vu.vf24.move(Mask::xyzw, vu.vf25); @@ -2727,11 +2729,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // ior vi03, vi08, vi00 | nop 939 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 940 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 941 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 942 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi00, vi06, L56 | nop 943 bc = (vu.vi06 == 0); @@ -2804,11 +2806,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, } // sqi.xyzw vf24, vi04 | nop 966 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 967 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 968 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); L55: // move.xyzw vf24, vf25 | nop 969 vu.vf24.move(Mask::xyzw, vu.vf25); @@ -2834,11 +2836,11 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // ior vi03, vi08, vi00 | nop 977 vu.vi03 = vu.vi08; // sqi.xyzw vf24, vi04 | nop 978 - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | nop 979 - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | nop 980 - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi00, vi06, L56 | nop 981 bc = (vu.vi06 == 0); @@ -2867,13 +2869,13 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, L58: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 987 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 988 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 989 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi03, vi04, L47 | nop 990 bc = (vu.vi03 == vu.vi04); @@ -2904,14 +2906,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // iaddi vi06, vi06, 0x1 | nop 1001 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1002 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1003 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L47 | nop 1004 bc = true; // sqi.xyzw vf23, vi04 | nop 1005 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L47; } @@ -2944,14 +2946,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // nop | sub.xyzw vf23, vf22, vf23 1018 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1019 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1020 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L47 | nop 1021 bc = true; // sqi.xyzw vf23, vi04 | nop 1022 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L47; } @@ -2969,13 +2971,13 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, L61: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1025 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1026 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1027 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi03, vi04, L49 | nop 1028 bc = (vu.vi03 == vu.vi04); @@ -3006,14 +3008,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // iaddi vi06, vi06, 0x1 | nop 1039 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1040 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1041 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L49 | nop 1042 bc = true; // sqi.xyzw vf23, vi04 | nop 1043 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L49; } @@ -3046,14 +3048,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // nop | sub.xyzw vf23, vf22, vf23 1056 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1057 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1058 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L49 | nop 1059 bc = true; // sqi.xyzw vf23, vi04 | nop 1060 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L49; } @@ -3071,13 +3073,13 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, L64: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1063 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1064 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1065 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi03, vi04, L51 | nop 1066 bc = (vu.vi03 == vu.vi04); @@ -3108,14 +3110,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // iaddi vi06, vi06, 0x1 | nop 1077 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1078 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1079 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L51 | nop 1080 bc = true; // sqi.xyzw vf23, vi04 | nop 1081 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L51; } @@ -3148,14 +3150,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // nop | add.xyzw vf23, vf22, vf23 1094 vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1095 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1096 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L51 | nop 1097 bc = true; // sqi.xyzw vf23, vi04 | nop 1098 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L51; } @@ -3173,13 +3175,13 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, L67: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1101 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1102 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1103 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi03, vi04, L53 | nop 1104 bc = (vu.vi03 == vu.vi04); @@ -3210,14 +3212,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // iaddi vi06, vi06, 0x1 | nop 1115 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1116 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1117 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L53 | nop 1118 bc = true; // sqi.xyzw vf23, vi04 | nop 1119 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L53; } @@ -3250,14 +3252,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // nop | sub.xyzw vf23, vf22, vf23 1132 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1133 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1134 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L53 | nop 1135 bc = true; // sqi.xyzw vf23, vi04 | nop 1136 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L53; } @@ -3275,13 +3277,13 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, L70: // sqi.xyzw vf24, vi04 | sub.xyzw vf23, vf22, vf21 1139 vu.vf23.sub(Mask::xyzw, vu.vf22, vu.vf21); - sq_buffer(__LINE__, Mask::xyzw, vu.vf24, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf24, vu.vi04++); // sqi.xyzw vf27, vi04 | sub.xyzw vf26, vf25, vf24 1140 vu.vf26.sub(Mask::xyzw, vu.vf25, vu.vf24); - sq_buffer(__LINE__, Mask::xyzw, vu.vf27, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf27, vu.vi04++); // sqi.xyzw vf21, vi04 | sub.xyzw vf29, vf28, vf27 1141 vu.vf29.sub(Mask::xyzw, vu.vf28, vu.vf27); - sq_buffer(__LINE__, Mask::xyzw, vu.vf21, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf21, vu.vi04++); // BRANCH! // ibeq vi03, vi04, L55 | nop 1142 bc = (vu.vi03 == vu.vi04); @@ -3312,14 +3314,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // iaddi vi06, vi06, 0x1 | nop 1153 vu.vi06 = vu.vi06 + 1; // sqi.xyzw vf26, vi04 | nop 1154 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1155 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L55 | nop 1156 bc = true; // sqi.xyzw vf23, vi04 | nop 1157 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L55; } @@ -3352,14 +3354,14 @@ void OceanMid::run_L45_vu2c(SharedRenderState* render_state, // nop | add.xyzw vf23, vf22, vf23 1170 vu.vf23.add(Mask::xyzw, vu.vf22, vu.vf23); // sqi.xyzw vf26, vi04 | nop 1171 - sq_buffer(__LINE__, Mask::xyzw, vu.vf26, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf26, vu.vi04++); // sqi.xyzw vf29, vi04 | nop 1172 - sq_buffer(__LINE__, Mask::xyzw, vu.vf29, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf29, vu.vi04++); // BRANCH! // b L55 | nop 1173 bc = true; // sqi.xyzw vf23, vi04 | nop 1174 - sq_buffer(__LINE__, Mask::xyzw, vu.vf23, vu.vi04++); + sq_buffer(Mask::xyzw, vu.vf23, vu.vi04++); if (bc) { goto L55; } diff --git a/goal_src/engine/gfx/ocean/ocean-mid.gc b/goal_src/engine/gfx/ocean/ocean-mid.gc index 049b1713b0..38b5b35c57 100644 --- a/goal_src/engine/gfx/ocean/ocean-mid.gc +++ b/goal_src/engine/gfx/ocean/ocean-mid.gc @@ -717,6 +717,7 @@ (set! (-> a1-2 z) (+ (-> v1-1 z) (* 393216.0 (the float arg1)))) ) (set! (-> a1-2 w) 1.0) + ;; (format 0 "~`vector`P~%" (-> *ocean-map* start-corner)) (ocean-mid-add-matrices arg0 a1-2) ) (let* ((a1-3 9) @@ -1236,59 +1237,60 @@ ; ) ;; for now, skip seams. - ; (when (not (or *ocean-near-off* (< 196608.0 (fabs (-> *math-camera* trans y))))) - ; (let ((a1-11 48) - ; (a2-2 0) - ; (v1-42 48) - ; (a0-25 0) - ; ) - ; (dotimes (a3-1 6) - ; (dotimes (t0-1 6) - ; (let ((t1-6 (&-> *ocean-work* mid-camera-masks (+ (* 6 a3-1) t0-1)))) - ; (when (nonzero? (-> t1-6 0)) - ; (dotimes (t2-3 8) - ; (let ((t3-1 (-> (the-as (pointer uint8) (+ t2-3 (the-as int t1-6))) 0))) - ; (when (nonzero? t3-1) - ; (let ((t4-2 (+ (* a3-1 8) t2-3))) - ; (if (< t4-2 v1-42) - ; (set! v1-42 t4-2) - ; ) - ; (if (< a0-25 t4-2) - ; (set! a0-25 t4-2) - ; ) - ; ) - ; (dotimes (t4-3 8) - ; (when (logtest? t3-1 (ash 1 t4-3)) - ; (let ((t5-9 (+ (* t0-1 8) t4-3))) - ; (if (< t5-9 a1-11) - ; (set! a1-11 t5-9) - ; ) - ; (if (< a2-2 t5-9) - ; (set! a2-2 t5-9) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; ) - ; (set! (-> *ocean-work* mid-minx) (the-as uint a1-11)) - ; (set! (-> *ocean-work* mid-maxx) (the-as uint a2-2)) - ; (set! (-> *ocean-work* mid-minz) (the-as uint v1-42)) - ; (set! (-> *ocean-work* mid-maxz) (the-as uint a0-25)) - ; (when (and (< a1-11 a2-2) (< v1-42 a0-25)) - ; (format *stdcon* "transition~%") - ; (ocean-mid-add-call-flush arg0 (the-as uint 41)) - ; (ocean-mid-add-call-flush arg0 (the-as uint 43)) - ; (draw-ocean-transition arg0) - ; (draw-ocean-mid-seams arg0) - ; ) - ; ) - ; ) + ;; when it's both on and cam is low + (when (not (or *ocean-near-off* (< 196608.0 (fabs (-> *math-camera* trans y))))) + (let ((a1-11 48) + (a2-2 0) + (v1-42 48) + (a0-25 0) + ) + (dotimes (a3-1 6) + (dotimes (t0-1 6) + (let ((t1-6 (&-> *ocean-work* mid-camera-masks (+ (* 6 a3-1) t0-1)))) + (when (nonzero? (-> t1-6 0)) + (dotimes (t2-3 8) + (let ((t3-1 (-> (the-as (pointer uint8) (+ t2-3 (the-as int t1-6))) 0))) + (when (nonzero? t3-1) + (let ((t4-2 (+ (* a3-1 8) t2-3))) + (if (< t4-2 v1-42) + (set! v1-42 t4-2) + ) + (if (< a0-25 t4-2) + (set! a0-25 t4-2) + ) + ) + (dotimes (t4-3 8) + (when (logtest? t3-1 (ash 1 t4-3)) + (let ((t5-9 (+ (* t0-1 8) t4-3))) + (if (< t5-9 a1-11) + (set! a1-11 t5-9) + ) + (if (< a2-2 t5-9) + (set! a2-2 t5-9) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> *ocean-work* mid-minx) (the-as uint a1-11)) + (set! (-> *ocean-work* mid-maxx) (the-as uint a2-2)) + (set! (-> *ocean-work* mid-minz) (the-as uint v1-42)) + (set! (-> *ocean-work* mid-maxz) (the-as uint a0-25)) + (when (and (< a1-11 a2-2) (< v1-42 a0-25)) + (format *stdcon* "transition~%") + (ocean-mid-add-call-flush arg0 (the-as uint 41)) + (ocean-mid-add-call-flush arg0 (the-as uint 43)) + (draw-ocean-transition arg0) + (draw-ocean-mid-seams arg0) + ) + ) + ) (ocean-mid-add-call-flush arg0 (the-as uint 41)) 0 (none) From 85edc1dbb9455fabd1ccbd985f845fb9a02f7a1f Mon Sep 17 00:00:00 2001 From: water Date: Sun, 13 Mar 2022 17:23:25 -0400 Subject: [PATCH 4/6] cleanup --- .../graphics/opengl_renderer/ocean/OceanMid.h | 27 +- .../opengl_renderer/ocean/OceanMid_PS2.cpp | 45 +- goal_src/engine/gfx/ocean/ocean-mid.gc | 1 - .../engine/gfx/ocean/ocean-trans-tables.gc | 2163 ++++++++--------- 4 files changed, 1079 insertions(+), 1157 deletions(-) diff --git a/game/graphics/opengl_renderer/ocean/OceanMid.h b/game/graphics/opengl_renderer/ocean/OceanMid.h index 7654c85163..d94a37e2f5 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid.h +++ b/game/graphics/opengl_renderer/ocean/OceanMid.h @@ -35,36 +35,15 @@ class OceanMid { ScopedProfilerNode& prof, DirectRenderer& direct); - void run_L26_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct); - void run_L32_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct); + void run_L26_vu2c(); + void run_L32_vu2c(); void run_L38_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); void run_L43_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct); - void run_L45_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct); - // void run_L30_vu2c(); - // void run_L36_vu2c(SharedRenderState* render_state, - // ScopedProfilerNode& prof, - // DirectRenderer& direct); - // void run_L41_vu2c(SharedRenderState* render_state, - // ScopedProfilerNode& prof, - // DirectRenderer& direct); - // void run_L43_vu2c(); - // - // void run_L42_vu2c(SharedRenderState* render_state, - // ScopedProfilerNode& prof, - // DirectRenderer& direct); - // void run_L44_vu2c(SharedRenderState* render_state, - // ScopedProfilerNode& prof, - // DirectRenderer& direct); + void run_L45_vu2c(); bool m_buffer_toggle = false; static constexpr int VU1_INPUT_BUFFER_BASE = 0; diff --git a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp index 049416313f..baa4a0dd5d 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp @@ -185,7 +185,6 @@ void OceanMid::run_call0_vu2c() { goto L5; } -JUMP_41: // nop | nop :e 41 // nop | nop 42 @@ -194,7 +193,6 @@ void OceanMid::run_call0_vu2c() { } void OceanMid::run_call41_vu2c() { -JUMP_41: // nop | nop :e 41 // nop | nop 42 @@ -203,7 +201,6 @@ void OceanMid::run_call41_vu2c() { } void OceanMid::run_call43_vu2c() { -JUMP_43: // iaddiu vi10, vi00, 0x243 | nop 43 vu.vi10 = 0x243; /* 579 */ // nop | nop :e 44 @@ -217,7 +214,6 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; -JUMP_46: // xtop vi02 | nop 46 vu.vi02 = xtop(); // lq.xyzw vf07, 748(vi00) | nop 47 @@ -272,7 +268,7 @@ void OceanMid::run_call46_vu2c(SharedRenderState* render_state, // nop | nop 65 // if (bc) { goto L26; } - run_L26_vu2c(render_state, prof, direct); + run_L26_vu2c(); // iaddiu vi01, vi00, 0x318 | nop 66 vu.vi01 = 0x318; /* 792 */ @@ -301,7 +297,6 @@ void OceanMid::run_call73_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; -JUMP_73: // xtop vi02 | nop 73 vu.vi02 = xtop(); // lq.xyzw vf07, 747(vi00) | nop 74 @@ -364,7 +359,7 @@ void OceanMid::run_call73_vu2c(SharedRenderState* render_state, // nop | nop 96 // if (bc) { goto L32; } - run_L32_vu2c(render_state, prof, direct); + run_L32_vu2c(); // iaddiu vi01, vi00, 0x318 | nop 97 vu.vi01 = 0x318; /* 792 */ @@ -408,11 +403,10 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; -JUMP_107: // xtop vi02 | nop 107 vu.vi02 = xtop(); // xtop vi03 | nop 108 - vu.vi03 = vu.vi02; // xtop(); + vu.vi03 = vu.vi02; // xtop(); // ior vi04, vi00, vi00 | nop 109 vu.vi04 = 0; // ilw.x vi05, 8(vi02) | nop 110 @@ -647,7 +641,7 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // sq.xyzw vf29, 11(vi08) | nop 210 sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 11); // if (bc) { goto L45; } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // BRANCH! // ibeq vi00, vi05, L19 | nop 211 @@ -760,7 +754,7 @@ void OceanMid::run_call107_vu2c(SharedRenderState* render_state, // sq.xyzw vf29, 11(vi08) | nop 254 sq_buffer(Mask::xyzw, vu.vf29, vu.vi08 + 11); // if (bc) { goto L45; } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // lq.xyzw vf28, 749(vi00) | nop 255 lq_buffer(Mask::xyzw, vu.vf28, 749); @@ -825,11 +819,10 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, DirectRenderer& direct) { bool bc; // fmt::print("call 275\n"); -JUMP_275: // xtop vi02 | nop 275 vu.vi02 = xtop(); // xtop vi03 | nop 276 - vu.vi03 = vu.vi02; // xtop(); + vu.vi03 = vu.vi02; // xtop(); // ior vi04, vi00, vi00 | nop 277 vu.vi04 = 0; // iaddi vi08, vi10, 0x7 | nop 278 @@ -967,7 +960,7 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // iaddi vi03, vi10, 0x7 | nop 332 vu.vi03 = vu.vi10 + 7; // if (bc) { goto L45; } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // lq.xyzw vf28, 741(vi00) | nop 333 lq_buffer(Mask::xyzw, vu.vf28, 741); @@ -1071,7 +1064,7 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, // if (bc) { // goto L45; // } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // lq.xyzw vf28, 749(vi00) | nop 373 lq_buffer(Mask::xyzw, vu.vf28, 749); @@ -1119,12 +1112,10 @@ void OceanMid::run_call275_vu2c(SharedRenderState* render_state, return; } -void OceanMid::run_L26_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct) { +void OceanMid::run_L26_vu2c() { bool bc = false; u32 cf = 0; -L26: + // L26: // ilw.x vi05, 757(vi07) | nop 391 ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); // ilw.y vi04, 757(vi07) | nop 392 @@ -1338,12 +1329,9 @@ void OceanMid::run_L26_vu2c(SharedRenderState* render_state, /*! * packet generation for plain envmapped ocean */ -void OceanMid::run_L32_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct) { +void OceanMid::run_L32_vu2c() { bool bc = false; u32 cf = 0; -L32: // ilw.x vi05, 757(vi07) | nop 459 ilw_buffer(Mask::x, vu.vi05, vu.vi07 + 757); // ilw.y vi04, 757(vi07) | nop 460 @@ -1866,7 +1854,6 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, DirectRenderer& direct) { bool bc; -L38: // lq.xyzw vf31, 734(vi00) | nop 614 lq_buffer(Mask::xyzw, vu.vf31, 734); // iaddiu vi10, vi00, 0x243 | nop 615 @@ -2062,7 +2049,7 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // sq.xyzw vf26, 771(vi00) | nop 689 sq_buffer(Mask::xyzw, vu.vf26, 771); // if (bc) { goto L45; } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // lq.xyzw vf28, 741(vi00) | nop 690 lq_buffer(Mask::xyzw, vu.vf28, 741); @@ -2155,7 +2142,7 @@ void OceanMid::run_L38_vu2c(SharedRenderState* render_state, // lq.xyzw vf07, 740(vi00) | nop 729 lq_buffer(Mask::xyzw, vu.vf07, 740); // if (bc) { goto L45; } - run_L45_vu2c(render_state, prof, direct); + run_L45_vu2c(); // lq.xyzw vf28, 749(vi00) | nop 730 lq_buffer(Mask::xyzw, vu.vf28, 749); @@ -2208,7 +2195,6 @@ void OceanMid::run_L43_vu2c(SharedRenderState* render_state, ScopedProfilerNode& prof, DirectRenderer& direct) { bool bc; -L43: // sq.xyzw vf07, -1(vi08) | nop 749 sq_buffer(Mask::xyzw, vu.vf07, vu.vi08 + -1); // isw.x vi06, -1(vi08) | nop 750 @@ -2307,14 +2293,11 @@ void OceanMid::run_L43_vu2c(SharedRenderState* render_state, vu.vi10 = vu.vi01 - vu.vi10; } -void OceanMid::run_L45_vu2c(SharedRenderState* render_state, - ScopedProfilerNode& prof, - DirectRenderer& direct) { +void OceanMid::run_L45_vu2c() { // fmt::print("run L45\n"); bool bc = false; u32 cf = 0; -L45: // ior vi04, vi03, vi00 | nop 793 vu.vi04 = vu.vi03; // lq.xyzw vf21, 2(vi03) | nop 794 diff --git a/goal_src/engine/gfx/ocean/ocean-mid.gc b/goal_src/engine/gfx/ocean/ocean-mid.gc index 38b5b35c57..ef26f87ea6 100644 --- a/goal_src/engine/gfx/ocean/ocean-mid.gc +++ b/goal_src/engine/gfx/ocean/ocean-mid.gc @@ -1283,7 +1283,6 @@ (set! (-> *ocean-work* mid-minz) (the-as uint v1-42)) (set! (-> *ocean-work* mid-maxz) (the-as uint a0-25)) (when (and (< a1-11 a2-2) (< v1-42 a0-25)) - (format *stdcon* "transition~%") (ocean-mid-add-call-flush arg0 (the-as uint 41)) (ocean-mid-add-call-flush arg0 (the-as uint 43)) (draw-ocean-transition arg0) diff --git a/goal_src/engine/gfx/ocean/ocean-trans-tables.gc b/goal_src/engine/gfx/ocean/ocean-trans-tables.gc index b5e395133c..bcc28f530c 100644 --- a/goal_src/engine/gfx/ocean/ocean-trans-tables.gc +++ b/goal_src/engine/gfx/ocean/ocean-trans-tables.gc @@ -1,1141 +1,1102 @@ ;;-*-Lisp-*- (in-package goal) -;; name: ocean-trans-tables.gc -;; name in dgo: ocean-trans-tables -;; dgos: GAME, ENGINE - ;; definition for symbol *ocean-left-table*, type (pointer float) -(define - *ocean-left-table* - (new 'static 'array float 28 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-left-table* (new 'static 'array float 28 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-right-table*, type (pointer float) -(define - *ocean-right-table* - (new 'static 'array float 28 - 0.0 - 0.0 - 1.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-right-table* (new 'static 'array float 28 + 0.0 + 0.0 + 1.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-up-table*, type (pointer float) -(define - *ocean-up-table* - (new 'static 'array float 28 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-up-table* (new 'static 'array float 28 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-down-table*, type (pointer float) -(define - *ocean-down-table* - (new 'static 'array float 28 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-down-table* (new 'static 'array float 28 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-down-left-table*, type (pointer float) -(define - *ocean-down-left-table* - (new 'static 'array float 40 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-down-left-table* (new 'static 'array float 40 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-down-right-table*, type (pointer float) -(define - *ocean-down-right-table* - (new 'static 'array float 40 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-down-right-table* (new 'static 'array float 40 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-up-right-table*, type (pointer float) -(define - *ocean-up-right-table* - (new 'static 'array float 40 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 1.0 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-up-right-table* (new 'static 'array float 40 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 1.0 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-up-left-table*, type (pointer float) -(define - *ocean-up-left-table* - (new 'static 'array float 40 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-up-left-table* (new 'static 'array float 40 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-trans-left-table*, type (pointer float) -(define - *ocean-trans-left-table* - (new 'static 'array float 44 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-trans-left-table* (new 'static 'array float 44 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-trans-right-table*, type (pointer float) -(define - *ocean-trans-right-table* - (new 'static 'array float 44 - 0.0 - 0.0 - 1.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-trans-right-table* (new 'static 'array float 44 + 0.0 + 0.0 + 1.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-trans-up-table*, type (pointer float) -(define - *ocean-trans-up-table* - (new 'static 'array float 44 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.125 - 0.875 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.375 - 0.625 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.625 - 0.375 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.875 - 0.125 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-trans-up-table* (new 'static 'array float 44 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.125 + 0.875 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.375 + 0.625 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.625 + 0.375 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.875 + 0.125 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-trans-down-table*, type (pointer float) -(define - *ocean-trans-down-table* - (new 'static 'array float 44 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.875 - 0.125 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.625 - 0.375 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.375 - 0.625 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.125 - 0.875 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-trans-down-table* (new 'static 'array float 44 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.875 + 0.125 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.625 + 0.375 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.375 + 0.625 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.125 + 0.875 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-trans-down-left-table*, type (pointer float) -(define - *ocean-trans-down-left-table* - (new 'static 'array float 72 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.875 - 0.125 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.625 - 0.375 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.375 - 0.625 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.125 - 0.875 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-trans-down-left-table* (new 'static 'array float 72 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.875 + 0.125 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.625 + 0.375 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.375 + 0.625 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.125 + 0.875 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-trans-down-right-table*, type (pointer float) -(define - *ocean-trans-down-right-table* - (new 'static 'array float 72 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.875 - 0.125 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.0 - 0.625 - 0.375 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.0 - 0.375 - 0.625 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.125 - 0.875 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-trans-down-right-table* (new 'static 'array float 72 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.875 + 0.125 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.0 + 0.625 + 0.375 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.0 + 0.375 + 0.625 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.125 + 0.875 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-trans-up-right-table*, type (pointer float) -(define - *ocean-trans-up-right-table* - (new 'static 'array float 72 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 1.0 - 0.0 - 0.0 - 0.125 - 0.875 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.375 - 0.625 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.625 - 0.375 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.875 - 0.125 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-trans-up-right-table* (new 'static 'array float 72 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 1.0 + 0.0 + 0.0 + 0.125 + 0.875 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.375 + 0.625 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.625 + 0.375 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.875 + 0.125 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-trans-up-left-table*, type (pointer float) -(define - *ocean-trans-up-left-table* - (new 'static 'array float 72 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.125 - 0.0 - 0.875 - 0.0 - 0.125 - 0.875 - 0.0 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.375 - 0.0 - 0.625 - 0.0 - 0.375 - 0.625 - 0.0 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.625 - 0.0 - 0.375 - 0.0 - 0.625 - 0.375 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.875 - 0.0 - 0.125 - 0.0 - 0.875 - 0.125 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - ) - ) +(define *ocean-trans-up-left-table* (new 'static 'array float 72 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.125 + 0.0 + 0.875 + 0.0 + 0.125 + 0.875 + 0.0 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.375 + 0.0 + 0.625 + 0.0 + 0.375 + 0.625 + 0.0 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.625 + 0.0 + 0.375 + 0.0 + 0.625 + 0.375 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.875 + 0.0 + 0.125 + 0.0 + 0.875 + 0.125 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + ) + ) ;; definition for symbol *ocean-trans-corner-table*, type (inline-array vector4w-2) -(define - *ocean-trans-corner-table* - (the-as (inline-array vector4w-2) - (new 'static 'array float 100 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.5625 - 0.1875 - 0.1875 - 0.0625 - 0.375 - 0.375 - 0.125 - 0.125 - 0.1875 - 0.5625 - 0.0625 - 0.1875 - 0.0 - 0.75 - 0.0 - 0.25 - 0.5 - 0.0 - 0.5 - 0.0 - 0.375 - 0.125 - 0.375 - 0.125 - 0.25 - 0.25 - 0.25 - 0.25 - 0.125 - 0.375 - 0.125 - 0.375 - 0.0 - 0.5 - 0.0 - 0.5 - 0.25 - 0.0 - 0.75 - 0.0 - 0.1875 - 0.0625 - 0.5625 - 0.1875 - 0.125 - 0.125 - 0.375 - 0.375 - 0.0625 - 0.1875 - 0.1875 - 0.5625 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) - ) +(define *ocean-trans-corner-table* (the-as (inline-array vector4w-2) (new 'static 'array float 100 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.5625 + 0.1875 + 0.1875 + 0.0625 + 0.375 + 0.375 + 0.125 + 0.125 + 0.1875 + 0.5625 + 0.0625 + 0.1875 + 0.0 + 0.75 + 0.0 + 0.25 + 0.5 + 0.0 + 0.5 + 0.0 + 0.375 + 0.125 + 0.375 + 0.125 + 0.25 + 0.25 + 0.25 + 0.25 + 0.125 + 0.375 + 0.125 + 0.375 + 0.0 + 0.5 + 0.0 + 0.5 + 0.25 + 0.0 + 0.75 + 0.0 + 0.1875 + 0.0625 + 0.5625 + 0.1875 + 0.125 + 0.125 + 0.375 + 0.375 + 0.0625 + 0.1875 + 0.1875 + 0.5625 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) + ) ;; definition for symbol *ocean-trans-strip-array*, type (pointer float) -(define - *ocean-trans-strip-array* - (new 'static 'array float 160 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.25 - 0.0 - 0.0 - 0.5625 - 0.1875 - 0.1875 - 0.0625 - 0.5 - 0.5 - 0.0 - 0.0 - 0.375 - 0.375 - 0.125 - 0.125 - 0.25 - 0.75 - 0.0 - 0.0 - 0.1875 - 0.5625 - 0.0625 - 0.1875 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.75 - 0.0 - 0.25 - 0.75 - 0.0 - 0.25 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.5625 - 0.1875 - 0.1875 - 0.0625 - 0.375 - 0.125 - 0.375 - 0.125 - 0.375 - 0.375 - 0.125 - 0.125 - 0.25 - 0.25 - 0.25 - 0.25 - 0.1875 - 0.5625 - 0.0625 - 0.1875 - 0.125 - 0.375 - 0.125 - 0.375 - 0.0 - 0.75 - 0.0 - 0.25 - 0.0 - 0.5 - 0.0 - 0.5 - 0.5 - 0.0 - 0.5 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.375 - 0.125 - 0.375 - 0.125 - 0.1875 - 0.0625 - 0.5625 - 0.1875 - 0.25 - 0.25 - 0.25 - 0.25 - 0.125 - 0.125 - 0.375 - 0.375 - 0.125 - 0.375 - 0.125 - 0.375 - 0.0625 - 0.1875 - 0.1875 - 0.5625 - 0.0 - 0.5 - 0.0 - 0.5 - 0.0 - 0.25 - 0.0 - 0.75 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.1875 - 0.0625 - 0.5625 - 0.1875 - 0.0 - 0.0 - 0.75 - 0.25 - 0.125 - 0.125 - 0.375 - 0.375 - 0.0 - 0.0 - 0.5 - 0.5 - 0.0625 - 0.1875 - 0.1875 - 0.5625 - 0.0 - 0.0 - 0.25 - 0.75 - 0.0 - 0.25 - 0.0 - 0.75 - 0.0 - 0.0 - 0.0 - 1.0 - ) - ) +(define *ocean-trans-strip-array* (new 'static 'array float 160 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.25 + 0.0 + 0.0 + 0.5625 + 0.1875 + 0.1875 + 0.0625 + 0.5 + 0.5 + 0.0 + 0.0 + 0.375 + 0.375 + 0.125 + 0.125 + 0.25 + 0.75 + 0.0 + 0.0 + 0.1875 + 0.5625 + 0.0625 + 0.1875 + 0.0 + 1.0 + 0.0 + 0.0 + 0.0 + 0.75 + 0.0 + 0.25 + 0.75 + 0.0 + 0.25 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.5625 + 0.1875 + 0.1875 + 0.0625 + 0.375 + 0.125 + 0.375 + 0.125 + 0.375 + 0.375 + 0.125 + 0.125 + 0.25 + 0.25 + 0.25 + 0.25 + 0.1875 + 0.5625 + 0.0625 + 0.1875 + 0.125 + 0.375 + 0.125 + 0.375 + 0.0 + 0.75 + 0.0 + 0.25 + 0.0 + 0.5 + 0.0 + 0.5 + 0.5 + 0.0 + 0.5 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.375 + 0.125 + 0.375 + 0.125 + 0.1875 + 0.0625 + 0.5625 + 0.1875 + 0.25 + 0.25 + 0.25 + 0.25 + 0.125 + 0.125 + 0.375 + 0.375 + 0.125 + 0.375 + 0.125 + 0.375 + 0.0625 + 0.1875 + 0.1875 + 0.5625 + 0.0 + 0.5 + 0.0 + 0.5 + 0.0 + 0.25 + 0.0 + 0.75 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + 0.0 + 0.1875 + 0.0625 + 0.5625 + 0.1875 + 0.0 + 0.0 + 0.75 + 0.25 + 0.125 + 0.125 + 0.375 + 0.375 + 0.0 + 0.0 + 0.5 + 0.5 + 0.0625 + 0.1875 + 0.1875 + 0.5625 + 0.0 + 0.0 + 0.25 + 0.75 + 0.0 + 0.25 + 0.0 + 0.75 + 0.0 + 0.0 + 0.0 + 1.0 + ) + ) ;; definition for symbol *ocean-trans-st-table*, type (inline-array vector) -(define - *ocean-trans-st-table* - (new 'static 'inline-array vector 4 - (new 'static 'vector :z 1.0) - (new 'static 'vector :x 1.0 :z 1.0) - (new 'static 'vector :y 1.0 :z 1.0) - (new 'static 'vector :x 1.0 :y 1.0 :z 1.0) - ) - ) +(define *ocean-trans-st-table* (new 'static 'inline-array vector 4 + (new 'static 'vector :z 1.0) + (new 'static 'vector :x 1.0 :z 1.0) + (new 'static 'vector :y 1.0 :z 1.0) + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0) + ) + ) + + + + From 4162d8bf95e51d88e5ff4fa21698db542c375f59 Mon Sep 17 00:00:00 2001 From: water Date: Sun, 13 Mar 2022 20:34:08 -0400 Subject: [PATCH 5/6] temp --- game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp | 3 +-- game/graphics/opengl_renderer/ocean/OceanTexture.cpp | 5 ++--- game/graphics/opengl_renderer/ocean/OceanTexture.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp index baa4a0dd5d..4751e2d178 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMid_PS2.cpp @@ -50,8 +50,7 @@ void fcor(u16& dest, u32 imm, u32 cf) { static inline REALLY_INLINE float erleng(const Vf& in) { float len = in.x() * in.x() + in.y() * in.y() + in.z() * in.z(); - float res = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(len))); - return res; + return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(len))); } } // namespace diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp index 0378f35ef1..d30bcd8c01 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp @@ -22,9 +22,8 @@ OceanTexture::~OceanTexture() { void OceanTexture::init_textures(TexturePool& pool) { TextureInput in; in.gpu_texture = m_tex0.texture(); - constexpr int boost = 2; - in.w = 128 * boost; - in.h = 128 * boost; + in.w = TEX0_SIZE; + in.h = TEX0_SIZE; in.page_name = "PC-OCEAN"; in.name = "pc-ocean"; m_tex0_gpu = pool.give_texture_and_load_to_vram(in, OCEAN_TEX_TBP); diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.h b/game/graphics/opengl_renderer/ocean/OceanTexture.h index 86aa68faa4..e33a0a5ee3 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.h +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.h @@ -41,7 +41,7 @@ class OceanTexture { bool m_use_ocean_specific = true; - static constexpr int TEX0_SIZE = 256; // TODO actually 128 + static constexpr int TEX0_SIZE = 128; FramebufferTexturePair m_tex0; GpuTexture* m_tex0_gpu = nullptr; From db08f95e8a50c5738f2cae4243fb4a3fbe744f7f Mon Sep 17 00:00:00 2001 From: water Date: Sun, 13 Mar 2022 21:49:17 -0400 Subject: [PATCH 6/6] fix mipmap --- .../graphics/opengl_renderer/DirectRenderer.h | 2 + game/graphics/opengl_renderer/Shader.cpp | 1 + game/graphics/opengl_renderer/Shader.h | 1 + .../opengl_renderer/ocean/OceanMidAndFar.cpp | 3 + .../opengl_renderer/ocean/OceanTexture.cpp | 75 ++++++++++++++++++- .../opengl_renderer/ocean/OceanTexture.h | 14 +++- .../graphics/opengl_renderer/opengl_utils.cpp | 74 +++++++++++++----- game/graphics/opengl_renderer/opengl_utils.h | 6 +- .../shaders/ocean_texture_mipmap.frag | 13 ++++ .../shaders/ocean_texture_mipmap.vert | 11 +++ 10 files changed, 174 insertions(+), 26 deletions(-) create mode 100644 game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.frag create mode 100644 game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.vert diff --git a/game/graphics/opengl_renderer/DirectRenderer.h b/game/graphics/opengl_renderer/DirectRenderer.h index a068b6b5a4..21686b3739 100644 --- a/game/graphics/opengl_renderer/DirectRenderer.h +++ b/game/graphics/opengl_renderer/DirectRenderer.h @@ -64,6 +64,8 @@ class DirectRenderer : public BucketRenderer { m_blend_state.d = GsAlpha::BlendMode::SOURCE; } + void set_mipmap(bool en) { m_debug_state.disable_mipmap = !en; } + private: void handle_ad(const u8* data, SharedRenderState* render_state, ScopedProfilerNode& prof); void handle_zbuf1(u64 val, SharedRenderState* render_state, ScopedProfilerNode& prof); diff --git a/game/graphics/opengl_renderer/Shader.cpp b/game/graphics/opengl_renderer/Shader.cpp index 4f124e39d0..8cf7f996d0 100644 --- a/game/graphics/opengl_renderer/Shader.cpp +++ b/game/graphics/opengl_renderer/Shader.cpp @@ -79,4 +79,5 @@ ShaderLibrary::ShaderLibrary() { at(ShaderId::EYE) = {"eye"}; at(ShaderId::GENERIC) = {"generic"}; at(ShaderId::OCEAN_TEXTURE) = {"ocean_texture"}; + at(ShaderId::OCEAN_TEXTURE_MIPMAP) = {"ocean_texture_mipmap"}; } diff --git a/game/graphics/opengl_renderer/Shader.h b/game/graphics/opengl_renderer/Shader.h index a7bbc5e612..06626f1f7c 100644 --- a/game/graphics/opengl_renderer/Shader.h +++ b/game/graphics/opengl_renderer/Shader.h @@ -36,6 +36,7 @@ enum class ShaderId { EYE = 11, GENERIC = 12, OCEAN_TEXTURE = 13, + OCEAN_TEXTURE_MIPMAP = 14, MAX_SHADERS }; diff --git a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp index 4edcbbc827..9135f637f4 100644 --- a/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanMidAndFar.cpp @@ -47,7 +47,9 @@ void OceanMidAndFar::render(DmaFollower& dma, } handle_ocean_far(dma, render_state, prof); + m_direct.flush_pending(render_state, prof); + m_direct.set_mipmap(true); handle_ocean_mid(dma, render_state, prof); auto final_next = dma.read_and_advance(); @@ -59,6 +61,7 @@ void OceanMidAndFar::render(DmaFollower& dma, ASSERT(dma.current_tag_offset() == render_state->next_bucket); m_direct.flush_pending(render_state, prof); + m_direct.set_mipmap(false); } void OceanMidAndFar::handle_ocean_far(DmaFollower& dma, diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp index d30bcd8c01..c3341fa7b9 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp @@ -4,7 +4,8 @@ constexpr int OCEAN_TEX_TBP = 8160; // todo OceanTexture::OceanTexture() - : m_tex0(TEX0_SIZE, TEX0_SIZE, GL_UNSIGNED_INT_8_8_8_8_REV), + : m_result_texture(TEX0_SIZE, TEX0_SIZE, GL_UNSIGNED_INT_8_8_8_8_REV, 8), + m_temp_texture(TEX0_SIZE, TEX0_SIZE, GL_UNSIGNED_INT_8_8_8_8_REV), m_hack_renderer("burp", BucketId::BUCKET0, 0x8000) { m_dbuf_x = m_dbuf_a; m_dbuf_y = m_dbuf_b; @@ -13,6 +14,34 @@ OceanTexture::OceanTexture() m_tbuf_y = m_tbuf_b; init_pc(); + + // initialize the mipmap drawing + glGenVertexArrays(1, &m_mipmap.vao); + glBindVertexArray(m_mipmap.vao); + glGenBuffers(1, &m_mipmap.vtx_buffer); + glBindBuffer(GL_ARRAY_BUFFER, m_mipmap.vtx_buffer); + std::vector vertices = { + {-1, -1, 0, 0}, {-1, 1, 0, 1}, {1, -1, 1, 0}, {1, 1, 1, 1}}; + glBufferData(GL_ARRAY_BUFFER, sizeof(MipMap::Vertex) * 4, vertices.data(), GL_STATIC_DRAW); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glVertexAttribPointer( + 0, // location 0 in the shader + 2, // 4 color components + GL_FLOAT, // floats + GL_FALSE, // normalized, ignored, + sizeof(MipMap::Vertex), // + (void*)offsetof(MipMap::Vertex, x) // offset in array (why is this a pointer...) + ); + glVertexAttribPointer( + 1, // location 0 in the shader + 2, // 4 color components + GL_FLOAT, // floats + GL_FALSE, // normalized, ignored, + sizeof(MipMap::Vertex), // + (void*)offsetof(MipMap::Vertex, s) // offset in array (why is this a pointer...) + ); + glBindVertexArray(0); } OceanTexture::~OceanTexture() { @@ -21,7 +50,7 @@ OceanTexture::~OceanTexture() { void OceanTexture::init_textures(TexturePool& pool) { TextureInput in; - in.gpu_texture = m_tex0.texture(); + in.gpu_texture = m_result_texture.texture(); in.w = TEX0_SIZE; in.h = TEX0_SIZE; in.page_name = "PC-OCEAN"; @@ -72,7 +101,7 @@ void OceanTexture::handle_tex_call_rest(SharedRenderState* render_state, ScopedP void OceanTexture::handle_ocean_texture(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { - FramebufferTexturePairContext ctxt(m_tex0); + FramebufferTexturePairContext ctxt(m_temp_texture); // render to the first texture { // (set-display-gs-state arg0 ocean-tex-page-0 128 128 0 0) @@ -233,5 +262,43 @@ void OceanTexture::handle_ocean_texture(DmaFollower& dma, } flush(render_state, prof); - render_state->texture_pool->move_existing_to_vram(m_tex0_gpu, 8160); + make_mipmaps(render_state, prof); +} + +/*! + * Generate mipmaps for the ocean texture. + * There's a trick here - we reduce the intensity of alpha on the lower lods. This lets texture + * filtering slowly fade the alpha value out to 0 with distance. + */ +void OceanTexture::make_mipmaps(SharedRenderState* render_state, ScopedProfilerNode& prof) { + glBindVertexArray(m_mipmap.vao); + render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].activate(); + glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), + "alpha_intensity"), + 1.0); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_temp_texture.texture()); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glUniform1i( + glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), "tex_T0"), + 0); + glBindBuffer(GL_ARRAY_BUFFER, m_mipmap.vtx_buffer); + + for (int i = 0; i < 8; i++) { + FramebufferTexturePairContext ctxt(m_result_texture, i); + glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), + "alpha_intensity"), + std::max(0.f, 1.f - 0.5f * i)); + glUniform1f( + glGetUniformLocation(render_state->shaders[ShaderId::OCEAN_TEXTURE_MIPMAP].id(), "scale"), + 1.f / (1 << i)); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + prof.add_draw_call(); + prof.add_tri(2); + } + render_state->texture_pool->move_existing_to_vram(m_tex0_gpu, OCEAN_TEX_TBP); + glBindVertexArray(0); } \ No newline at end of file diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.h b/game/graphics/opengl_renderer/ocean/OceanTexture.h index e33a0a5ee3..dddfbb313c 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.h +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.h @@ -39,10 +39,13 @@ class OceanTexture { void init_pc(); void destroy_pc(); + void make_mipmaps(SharedRenderState* render_state, ScopedProfilerNode& prof); + bool m_use_ocean_specific = true; static constexpr int TEX0_SIZE = 128; - FramebufferTexturePair m_tex0; + FramebufferTexturePair m_result_texture; + FramebufferTexturePair m_temp_texture; GpuTexture* m_tex0_gpu = nullptr; // (deftype ocean-texture-constants (structure) @@ -136,6 +139,15 @@ class OceanTexture { GLuint vao, static_vertex_buffer, dynamic_vertex_buffer, gl_index_buffer; } m_pc; + struct MipMap { + GLuint vao, vtx_buffer; + struct Vertex { + float x, y; + float s, t; + }; + static_assert(sizeof(Vertex) == 16); + } m_mipmap; + enum TexVu1Data { BUF0 = 384, BUF1 = 583, diff --git a/game/graphics/opengl_renderer/opengl_utils.cpp b/game/graphics/opengl_renderer/opengl_utils.cpp index cf90d95203..d56cbaee34 100644 --- a/game/graphics/opengl_renderer/opengl_utils.cpp +++ b/game/graphics/opengl_renderer/opengl_utils.cpp @@ -1,51 +1,89 @@ #include "opengl_utils.h" #include "common/util/Assert.h" +#include -FramebufferTexturePair::FramebufferTexturePair(int w, int h, u64 texture_format) : m_w(w), m_h(h) { - glGenFramebuffers(1, &m_framebuffer); +FramebufferTexturePair::FramebufferTexturePair(int w, int h, u64 texture_format, int num_levels) + : m_w(w), m_h(h) { + m_framebuffers.resize(num_levels); + glGenFramebuffers(num_levels, m_framebuffers.data()); glGenTextures(1, &m_texture); GLint old_framebuffer; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_framebuffer); - glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); - glBindTexture(GL_TEXTURE_2D, m_texture); + for (int i = 0; i < num_levels; i++) { + glBindTexture(GL_TEXTURE_2D, m_texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, num_levels); + glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, w >> i, h >> i, 0, GL_RGBA, texture_format, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, texture_format, nullptr); + for (int i = 0; i < num_levels; i++) { + glBindTexture(GL_TEXTURE_2D, 0); + glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffers[i]); + glBindTexture(GL_TEXTURE_2D, m_texture); + // I don't know if we really need to do this. whatever uses this texture should figure it out. - // I don't know if we really need to do this. whatever uses this texture should figure it out. - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, m_texture, i); + GLenum draw_buffers[1] = {GLenum(GL_COLOR_ATTACHMENT0 + i)}; + glDrawBuffers(1, draw_buffers); + auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + switch (status) { + case GL_FRAMEBUFFER_UNDEFINED: + printf("GL_FRAMEBUFFER_UNDEFINED\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + printf("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + printf("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + printf("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + printf("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER\n"); + break; + case GL_FRAMEBUFFER_UNSUPPORTED: + printf("GL_FRAMEBUFFER_UNSUPPORTED\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + printf("GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE\n"); + break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: + printf("GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS\n"); + break; + } - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture, 0); - GLenum draw_buffers[1] = {GL_COLOR_ATTACHMENT0}; - glDrawBuffers(1, draw_buffers); - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - ASSERT(false); + ASSERT(false); + } + glBindFramebuffer(GL_FRAMEBUFFER, old_framebuffer); } glBindFramebuffer(GL_FRAMEBUFFER, old_framebuffer); } FramebufferTexturePair::~FramebufferTexturePair() { - glDeleteFramebuffers(1, &m_framebuffer); + glDeleteFramebuffers(m_framebuffers.size(), m_framebuffers.data()); glDeleteTextures(1, &m_texture); } -FramebufferTexturePairContext::FramebufferTexturePairContext(FramebufferTexturePair& fb) +FramebufferTexturePairContext::FramebufferTexturePairContext(FramebufferTexturePair& fb, int level) : m_fb(&fb) { glGetIntegerv(GL_VIEWPORT, m_old_viewport); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_old_framebuffer); - glBindFramebuffer(GL_FRAMEBUFFER, m_fb->m_framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, m_fb->m_framebuffers[level]); glViewport(0, 0, m_fb->m_w, m_fb->m_h); - glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_fb->m_texture, 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_fb->m_texture, level); } void FramebufferTexturePairContext::switch_to(FramebufferTexturePair& fb) { if (&fb != m_fb) { m_fb = &fb; - glBindFramebuffer(GL_FRAMEBUFFER, m_fb->m_framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, m_fb->m_framebuffers[0]); glViewport(0, 0, m_fb->m_w, m_fb->m_h); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_fb->m_texture, 0); } diff --git a/game/graphics/opengl_renderer/opengl_utils.h b/game/graphics/opengl_renderer/opengl_utils.h index 7e02e8ee07..6d749a6d75 100644 --- a/game/graphics/opengl_renderer/opengl_utils.h +++ b/game/graphics/opengl_renderer/opengl_utils.h @@ -7,7 +7,7 @@ */ class FramebufferTexturePair { public: - FramebufferTexturePair(int w, int h, u64 texture_format); + FramebufferTexturePair(int w, int h, u64 texture_format, int num_levels = 1); ~FramebufferTexturePair(); GLuint texture() const { return m_texture; } @@ -17,14 +17,14 @@ class FramebufferTexturePair { private: friend class FramebufferTexturePairContext; - GLuint m_framebuffer; + std::vector m_framebuffers; GLuint m_texture; int m_w, m_h; }; class FramebufferTexturePairContext { public: - FramebufferTexturePairContext(FramebufferTexturePair& fb); + FramebufferTexturePairContext(FramebufferTexturePair& fb, int level = 0); ~FramebufferTexturePairContext(); void switch_to(FramebufferTexturePair& fb); diff --git a/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.frag b/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.frag new file mode 100644 index 0000000000..c02c7b1c6e --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.frag @@ -0,0 +1,13 @@ +#version 430 core + +out vec4 color; +in vec2 tex_coord; + +uniform float alpha_intensity; +uniform sampler2D tex_T0; + +void main() { + vec4 tex = texture(tex_T0, tex_coord); + tex.w *= alpha_intensity; + color = tex; +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.vert b/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.vert new file mode 100644 index 0000000000..7a306f501a --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/ocean_texture_mipmap.vert @@ -0,0 +1,11 @@ +#version 430 core + +layout (location = 0) in vec2 position_in; +layout (location = 1) in vec2 tex_coord_in; + +out vec2 tex_coord; +uniform float scale; +void main() { + gl_Position = vec4(position_in.x * scale - (1 - scale), position_in.y * scale - (1 - scale), 0.5, 1.0); + tex_coord = tex_coord_in; +}