From 5b04be2fa00731c76f5be11688e2e860e6e468b3 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Thu, 9 May 2024 20:11:43 -0400 Subject: [PATCH] Add hfrag, clean up some background renderer stuff (#3509) This adds hfrag, but with a few remaining issues: - The textures aren't animated. Instead, it just uses one texture. - The texture filtering isn't as good as at it could be. I also cleaned up a few issues with the background renderers: - Cleaned up some stuff that is common to hfrag, tie, tfrag, shrub - Moved time-of-day color packing stuff to FR3 creation, rather than at level load. This appears to reduce the frame time spikes when a level is first drawn by about 5 or 6 ms in big levels. - Cleaned up the x86 specific stuff used in time of day. Now there's only one place where we have an `ifdef`, rather than spreading it all over the rendering code. --- common/custom_data/TFrag3Data.cpp | 58 +- common/custom_data/Tfrag3Data.h | 80 +- decompiler/CMakeLists.txt | 1 + decompiler/config/jak3/all-types.gc | 326 +- .../config/jak3/ntsc_v1/label_types.jsonc | 24 + .../config/jak3/ntsc_v1/type_casts.jsonc | 18 + decompiler/level_extractor/BspHeader.cpp | 270 +- decompiler/level_extractor/BspHeader.h | 106 +- decompiler/level_extractor/extract_common.cpp | 41 +- decompiler/level_extractor/extract_common.h | 8 +- decompiler/level_extractor/extract_hfrag.cpp | 205 + decompiler/level_extractor/extract_hfrag.h | 10 + decompiler/level_extractor/extract_level.cpp | 11 +- decompiler/level_extractor/extract_shrub.cpp | 8 +- decompiler/level_extractor/extract_tfrag.cpp | 8 +- decompiler/level_extractor/extract_tie.cpp | 27 +- decompiler/level_extractor/fr3_to_gltf.cpp | 13 +- decompiler/util/data_decompile.cpp | 5 +- docs/progress-notes/jak3/hfrag.md | 6346 +++++++++++++++++ game/CMakeLists.txt | 1 + .../opengl_renderer/OpenGLRenderer.cpp | 4 + game/graphics/opengl_renderer/Shader.cpp | 2 + game/graphics/opengl_renderer/Shader.h | 2 + .../opengl_renderer/background/Hfrag.cpp | 462 ++ .../opengl_renderer/background/Hfrag.h | 76 + .../opengl_renderer/background/Shrub.cpp | 25 +- .../opengl_renderer/background/Shrub.h | 4 +- .../opengl_renderer/background/TFragment.cpp | 25 +- .../opengl_renderer/background/TFragment.h | 4 +- .../opengl_renderer/background/Tie3.cpp | 24 +- .../opengl_renderer/background/Tie3.h | 3 +- .../background/background_common.cpp | 110 +- .../background/background_common.h | 21 +- game/graphics/opengl_renderer/buckets.h | 2 + .../opengl_renderer/loader/Loader.cpp | 20 +- game/graphics/opengl_renderer/loader/Loader.h | 1 + .../opengl_renderer/loader/LoaderStages.cpp | 68 + game/graphics/opengl_renderer/loader/common.h | 3 + .../opengl_renderer/shaders/hfrag.frag | 23 + .../opengl_renderer/shaders/hfrag.vert | 56 + .../shaders/hfrag_montage.frag | 8 + .../shaders/hfrag_montage.vert | 11 + game/overlord/jak2/srpc.cpp | 3 +- goal_src/goal-lib.gc | 4 +- goal_src/jak3/engine/collide/collide-cache.gc | 4 +- goal_src/jak3/engine/draw/drawable.gc | 10 +- .../jak3/engine/gfx/background/background.gc | 82 +- .../engine/gfx/background/hfrag/hfrag-h.gc | 245 +- .../gfx/background/hfrag/hfrag-vu1-h.gc | 106 + .../engine/gfx/background/hfrag/hfrag-vu1.gc | 363 + .../engine/gfx/background/hfrag/hfrag-work.gc | 939 +++ .../jak3/engine/gfx/background/hfrag/hfrag.gc | 721 +- .../jak3/engine/gfx/background/tfrag/tfrag.gc | 2 +- .../engine/gfx/background/tie/tie-methods.gc | 2 +- .../jak3/engine/gfx/background/tie/tie.gc | 4 +- .../jak3/engine/gfx/foreground/foreground.gc | 4 +- goal_src/jak3/engine/gfx/hw/display-h.gc | 8 +- goal_src/jak3/engine/gfx/shrub/shrubbery.gc | 2 +- goal_src/jak3/engine/gfx/texture/texture-h.gc | 12 +- goal_src/jak3/engine/gfx/texture/texture.gc | 12 +- goal_src/jak3/engine/gfx/vu1-user-h.gc | 8 +- goal_src/jak3/engine/level/level-h.gc | 2 +- goal_src/jak3/engine/level/level-info.gc | 4 +- goal_src/jak3/engine/level/level.gc | 10 +- goalc/build_level/common/Tfrag.cpp | 14 +- .../jak3/engine/collide/collide-cache_REF.gc | 4 +- .../jak3/engine/draw/drawable_REF.gc | 2 +- .../gfx/background/hfrag/hfrag-h_REF.gc | 255 +- .../gfx/background/hfrag/hfrag-vu1-h_REF.gc | 273 + .../gfx/background/hfrag/hfrag-vu1_REF.gc | 386 + .../gfx/background/hfrag/hfrag-work_REF.gc | 959 +++ .../engine/gfx/background/hfrag/hfrag_REF.gc | 1036 +++ .../jak3/engine/gfx/background/tie/tie_REF.gc | 4 +- .../engine/gfx/foreground/foreground_REF.gc | 4 +- .../jak3/engine/gfx/hw/display-h_REF.gc | 8 +- .../jak3/engine/gfx/texture/texture-h_REF.gc | 12 +- .../jak3/engine/gfx/texture/texture_REF.gc | 12 +- .../jak3/engine/level/level-info_REF.gc | 8 +- .../reference/jak3/engine/level/level_REF.gc | 10 +- tools/level_tools/level_dump/main.cpp | 4 +- 80 files changed, 13081 insertions(+), 977 deletions(-) create mode 100644 decompiler/level_extractor/extract_hfrag.cpp create mode 100644 decompiler/level_extractor/extract_hfrag.h create mode 100644 docs/progress-notes/jak3/hfrag.md create mode 100644 game/graphics/opengl_renderer/background/Hfrag.cpp create mode 100644 game/graphics/opengl_renderer/background/Hfrag.h create mode 100644 game/graphics/opengl_renderer/shaders/hfrag.frag create mode 100644 game/graphics/opengl_renderer/shaders/hfrag.vert create mode 100644 game/graphics/opengl_renderer/shaders/hfrag_montage.frag create mode 100644 game/graphics/opengl_renderer/shaders/hfrag_montage.vert create mode 100644 test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1-h_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-work_REF.gc create mode 100644 test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag_REF.gc diff --git a/common/custom_data/TFrag3Data.cpp b/common/custom_data/TFrag3Data.cpp index f66b821c3..c42003e3f 100644 --- a/common/custom_data/TFrag3Data.cpp +++ b/common/custom_data/TFrag3Data.cpp @@ -14,6 +14,11 @@ namespace tfrag3 { +void PackedTimeOfDay::serialize(Serializer& ser) { + ser.from_pod_vector(&data); + ser.from_ptr(&color_count); +} + void PackedTieVertices::serialize(Serializer& ser) { ser.from_pod_vector(&color_indices); ser.from_pod_vector(&matrices); @@ -72,10 +77,9 @@ void TfragTree::serialize(Serializer& ser) { draw.serialize(ser); } - // ser.from_pod_vector(&vertices); ser.from_pod_vector(&packed_vertices.vertices); ser.from_pod_vector(&packed_vertices.cluster_origins); - ser.from_pod_vector(&colors); + colors.serialize(ser); bvh.serialize(ser); ser.from_ptr(&use_strips); } @@ -399,7 +403,7 @@ void TieTree::serialize(Serializer& ser) { } packed_vertices.serialize(ser); - ser.from_pod_vector(&colors); + colors.serialize(ser); bvh.serialize(ser); ser.from_ptr(&has_per_proto_visibility_toggle); @@ -407,7 +411,7 @@ void TieTree::serialize(Serializer& ser) { } void ShrubTree::serialize(Serializer& ser) { - ser.from_pod_vector(&time_of_day_colors); + time_of_day_colors.serialize(ser); ser.from_pod_vector(&indices); packed_vertices.serialize(ser); if (ser.is_saving()) { @@ -423,6 +427,30 @@ void ShrubTree::serialize(Serializer& ser) { ser.from_string_vector(&proto_names); } +void HfragmentBucket::serialize(Serializer& ser) { + ser.from_pod_vector(&corners); + ser.from_ptr(&montage_table); +} + +void Hfragment::serialize(Serializer& ser) { + ser.from_pod_vector(&vertices); + ser.from_pod_vector(&indices); + ser.from_pod_vector(&corners); + + if (ser.is_saving()) { + ser.save(buckets.size()); + } else { + buckets.resize(ser.load()); + } + for (auto& x : buckets) { + x.serialize(ser); + } + time_of_day_colors.serialize(ser); + ser.from_ptr(&wang_tree_tex_id); + ser.from_ptr(&draw_mode); + ser.from_ptr(&occlusion_offset); +} + void BVH::serialize(Serializer& ser) { ser.from_ptr(&first_leaf_node); ser.from_ptr(&last_leaf_node); @@ -605,6 +633,8 @@ void Level::serialize(Serializer& ser) { tree.serialize(ser); } + hfrag.serialize(ser); + collision.serialize(ser); merc_data.serialize(ser); @@ -655,8 +685,7 @@ void PackedShrubVertices::memory_usage(MemoryUsageTracker* tracker) const { } void ShrubTree::memory_usage(MemoryUsageTracker* tracker) const { - tracker->add(MemoryUsageCategory::SHRUB_TIME_OF_DAY, - sizeof(TimeOfDayColor) * time_of_day_colors.size()); + tracker->add(MemoryUsageCategory::SHRUB_TIME_OF_DAY, sizeof(u8) * time_of_day_colors.data.size()); packed_vertices.memory_usage(tracker); tracker->add(MemoryUsageCategory::SHRUB_DRAW, sizeof(ShrubDraw) * static_draws.size()); tracker->add(MemoryUsageCategory::SHRUB_IND, sizeof(u32) * indices.size()); @@ -684,7 +713,7 @@ void TieTree::memory_usage(MemoryUsageTracker* tracker) const { draw.vis_groups.size() * sizeof(StripDraw::VisGroup)); } packed_vertices.memory_usage(tracker); - tracker->add(MemoryUsageCategory::TIE_TIME_OF_DAY, sizeof(TimeOfDayColor) * colors.size()); + tracker->add(MemoryUsageCategory::TIE_TIME_OF_DAY, sizeof(u8) * colors.data.size()); for (auto& draw : instanced_wind_draws) { draw.memory_usage(tracker); @@ -708,7 +737,7 @@ void TfragTree::memory_usage(MemoryUsageTracker* tracker) const { draw.vis_groups.size() * sizeof(StripDraw::VisGroup)); } packed_vertices.memory_usage(tracker); - tracker->add(MemoryUsageCategory::TFRAG_TIME_OF_DAY, sizeof(TimeOfDayColor) * colors.size()); + tracker->add(MemoryUsageCategory::TFRAG_TIME_OF_DAY, sizeof(u8) * colors.data.size()); tracker->add(MemoryUsageCategory::TFRAG_BVH, sizeof(VisNode) * bvh.vis_nodes.size()); } @@ -721,6 +750,13 @@ void IndexTexture::memory_usage(MemoryUsageTracker* tracker) const { tracker->add(MemoryUsageCategory::SPECIAL_TEXTURE, 256 * 4); // clut } +void Hfragment::memory_usage(tfrag3::MemoryUsageTracker* tracker) const { + tracker->add(MemoryUsageCategory::HFRAG_VERTS, vertices.size() * sizeof(HfragmentVertex)); + tracker->add(MemoryUsageCategory::HFRAG_INDEX, indices.size() * sizeof(u32)); + tracker->add(MemoryUsageCategory::HFRAG_TIME_OF_DAY, time_of_day_colors.data.size() * sizeof(u8)); + tracker->add(MemoryUsageCategory::HFRAG_CORNERS, corners.size() * sizeof(HfragmentCorner)); +} + void Level::memory_usage(MemoryUsageTracker* tracker) const { for (const auto& texture : textures) { texture.memory_usage(tracker); @@ -741,6 +777,7 @@ void Level::memory_usage(MemoryUsageTracker* tracker) const { for (const auto& tree : shrub_trees) { tree.memory_usage(tracker); } + hfrag.memory_usage(tracker); collision.memory_usage(tracker); merc_data.memory_usage(tracker); } @@ -784,6 +821,11 @@ void print_memory_usage(const tfrag3::Level& lev, int uncompressed_data_size) { {"merc-mod-draw-1", mem_use.data[tfrag3::MemoryUsageCategory::MERC_MOD_DRAW_1]}, {"merc-mod-draw-2", mem_use.data[tfrag3::MemoryUsageCategory::MERC_MOD_DRAW_2]}, {"blerc", mem_use.data[tfrag3::MemoryUsageCategory::BLERC]}, + {"hfrag-verts", mem_use.data[tfrag3::MemoryUsageCategory::HFRAG_VERTS]}, + {"hfrag-index", mem_use.data[tfrag3::MemoryUsageCategory::HFRAG_INDEX]}, + {"hfrag-time-of-day", mem_use.data[tfrag3::MemoryUsageCategory::HFRAG_TIME_OF_DAY]}, + {"hfrag-corners", mem_use.data[tfrag3::MemoryUsageCategory::HFRAG_CORNERS]} + }; for (auto& known : known_categories) { total_accounted += known.second; diff --git a/common/custom_data/Tfrag3Data.h b/common/custom_data/Tfrag3Data.h index a0007b6c9..bd951e7e8 100644 --- a/common/custom_data/Tfrag3Data.h +++ b/common/custom_data/Tfrag3Data.h @@ -18,7 +18,7 @@ namespace tfrag3 { // - if changing any large things (vertices, vis, bvh, colors, textures) update get_memory_usage // - if adding a new category to the memory usage, update extract_level to print it. -constexpr int TFRAG3_VERSION = 39; +constexpr int TFRAG3_VERSION = 40; enum MemoryUsageCategory { TEXTURE, @@ -61,6 +61,11 @@ enum MemoryUsageCategory { MERC_MOD_TABLE, BLERC, + HFRAG_VERTS, + HFRAG_INDEX, + HFRAG_TIME_OF_DAY, + HFRAG_CORNERS, + COLLISION, NUM_CATEGORIES @@ -269,18 +274,23 @@ struct BVH { void serialize(Serializer& ser); }; -// A time-of-day color. Each stores 8 colors. At a given "time of day", they are interpolated -// to find a single color which goes into a color palette. -struct TimeOfDayColor { - math::Vector rgba[8]; +// This is split into groups of 4 colors. +// The data in these groups is stored first by palette, then color, then channel. +struct PackedTimeOfDay { + std::vector data; + u32 color_count = 0; + void serialize(Serializer& ser); - bool operator==(const TimeOfDayColor& other) const { - for (size_t i = 0; i < 8; i++) { - if (rgba[i] != other.rgba[i]) { - return false; - } - } - return true; + u8 read(int color, int palette, int channel) const { + const int color_quad = color / 4; + const int color_in_quad = color % 4; + return data[color_quad * 4 * 4 * 8 + palette * 4 * 4 + color_in_quad * 4 + channel]; + } + + u8& read(int color, int palette, int channel) { + const int color_quad = color / 4; + const int color_in_quad = color % 4; + return data[color_quad * 4 * 4 * 8 + palette * 4 * 4 + color_in_quad * 4 + channel]; } }; @@ -319,8 +329,8 @@ struct TfragTree { TFragmentTreeKind kind; // our tfrag kind std::vector draws; // the actual topology and settings PackedTfragVertices packed_vertices; - std::vector colors; // vertex colors (pre-interpolation) - BVH bvh; // the bvh for frustum culling + PackedTimeOfDay colors; // vertex colors (pre-interpolation) + BVH bvh; // the bvh for frustum culling bool use_strips = true; struct { @@ -401,7 +411,7 @@ struct TieTree { std::array category_draw_indices; PackedTieVertices packed_vertices; - std::vector colors; // vertex colors (pre-interpolation) + PackedTimeOfDay colors; // vertex colors (pre-interpolation) std::vector instanced_wind_draws; std::vector wind_instance_info; @@ -422,7 +432,7 @@ struct TieTree { struct ShrubTree { // todo some visibility structure - std::vector time_of_day_colors; // multiplier colors + PackedTimeOfDay time_of_day_colors; // multiplier colors PackedShrubVertices packed_vertices; std::vector static_draws; // the actual topology and settings @@ -441,6 +451,43 @@ struct ShrubTree { void unpack(); }; +struct HfragmentVertex { + float height = 0; + u32 vi = 0; + u16 color_index = 0; + u8 u = 0, v = 0; + u32 pad = 0; +}; + +struct HfragmentCorner { + math::Vector bsphere; + u32 vis_id = 0; + u32 index_start = 0; + u32 index_length = 0; + u32 num_tris = 0; +}; + +struct HfragmentBucket { + std::vector corners; + std::array montage_table; + void serialize(Serializer& ser); +}; + +struct Hfragment { + std::vector vertices; + std::vector indices; + std::vector corners; + std::vector buckets; + PackedTimeOfDay time_of_day_colors; + + std::array wang_tree_tex_id; + DrawMode draw_mode; + u32 occlusion_offset; + + void serialize(Serializer& ser); + void memory_usage(MemoryUsageTracker* tracker) const; +}; + struct CollisionMesh { struct Vertex { float x, y, z; @@ -566,6 +613,7 @@ struct Level { std::array, TFRAG_GEOS> tfrag_trees; std::array, TIE_GEOS> tie_trees; std::vector shrub_trees; + Hfragment hfrag; CollisionMesh collision; MercModelGroup merc_data; u16 version2 = TFRAG3_VERSION; diff --git a/decompiler/CMakeLists.txt b/decompiler/CMakeLists.txt index a46781bf0..00ef05461 100644 --- a/decompiler/CMakeLists.txt +++ b/decompiler/CMakeLists.txt @@ -58,6 +58,7 @@ add_library( level_extractor/extract_actors.cpp level_extractor/extract_collide_frags.cpp level_extractor/extract_common.cpp + level_extractor/extract_hfrag.cpp level_extractor/extract_joint_group.cpp level_extractor/extract_level.cpp level_extractor/extract_merc.cpp diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index b3afc985d..5106997e0 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -3543,8 +3543,8 @@ (bucket5 5) ;; sky (bucket6 6) ;; ocean (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. - (bucket8 8) ;; hfrag - (bucket9 9) ;; hfrag + (hfrag 8) ;; hfrag + (hfrag-scissor 9) ;; hfrag (tex-l0-tfrag 10) ;; texture (tfrag-l0-tfrag 11) ;; tfrag @@ -4237,8 +4237,8 @@ (rn3) (rn4) (rn5) - (rn6) - (rn7) + (hfrag) + (hfrag-scissor) (tfrag) (tie-scissor) (tie) @@ -6478,7 +6478,7 @@ (h int16 :offset-assert 6) (num-mips uint8 :offset-assert 8) (tex1-control uint8 :offset-assert 9) - (psm uint8 :offset-assert 10) ;; gs-psm + (psm gs-psm :offset-assert 10) ;; gs-psm (mip-shift uint8 :offset-assert 11) (clutpsm uint16 :offset-assert 12) (dest uint16 7 :offset-assert 14) ;; guessed by decompiler @@ -6639,11 +6639,11 @@ of the texture." ((quad qword 5 :inline :offset-assert 0 :score -100) ;; guessed by decompiler (prims gs-reg64 10 :offset 0 :score -100) ;; guessed by decompiler - (reg-0 uint8 :offset 8) - (reg-1 uint8 :offset 24) - (reg-2 uint8 :offset 40) - (reg-3 uint8 :offset 56) - (reg-4 uint8 :offset 72) + (reg-0 gs-reg :offset 8) + (reg-1 gs-reg :offset 24) + (reg-2 gs-reg :offset 40) + (reg-3 gs-reg :offset 56) + (reg-4 gs-reg :offset 72) (tex0 gs-tex0 :offset 0) ;; (tex1 gs-tex1 :offset 16) ;; (miptbp1 gs-miptbp :offset 32) ;; @@ -7529,7 +7529,7 @@ (lf11 11) (lf12 12) (lf13 13) - (lf14 14) + (low-res-hfrag 14) (lf15 15) (lf16 16) (lf17 17) @@ -11349,7 +11349,7 @@ (billboard 33) (instance-shrubbery 34) - + (hfragment 43) (entity 44) (camera 45) @@ -25019,10 +25019,10 @@ ) (deftype hfrag-bucket (structure) - ((next uint32 :offset-assert 0) + ((next pointer :offset-assert 0) (count uint16 :offset-assert 4) - (vertex-count uint16 :offset-assert 6) - (next-scissor uint32 :offset-assert 8) + (vertex-count uint16 :offset-assert 6) ;; toggles between 32 and 16??? + (next-scissor pointer :offset-assert 8) (count-scissor uint16 :offset-assert 12) (vertex-count-scissor uint16 :offset-assert 14) ) @@ -25032,7 +25032,8 @@ ) (deftype hfrag-packed-index (uint16) - ((bit11 uint8 :offset 11 :size 5) + ((color uint16 :offset 0 :size 11) ;; color index in palette + (bit11 uint8 :offset 11 :size 5) ;; tells you which bucket ) :flag-assert #x900000002 ) @@ -25041,6 +25042,7 @@ ((height uint16 :offset-assert 0) (packed-index hfrag-packed-index :offset-assert 2) ) + :pack-me :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 @@ -25048,8 +25050,8 @@ (deftype hfrag-vert-index (structure) ((pos vector2ub :inline :offset-assert 0) - (index0 uint16 :offset 2) - (index1 uint16 :offset 4) + (index0 uint16 :offset 2) ;; high lod + (index1 uint16 :offset 4) ;; average between this and index2 for low-lod (index2 uint16 :offset 6) ) :pack-me @@ -25060,6 +25062,7 @@ ;; note: the poly vert-index stuff is a total guess! +;; 2x2 (deftype hfrag-poly4 (structure) ((data hfrag-vert-index 4 :inline :offset-assert 0) ;; field could not be read. ) @@ -25068,22 +25071,27 @@ :flag-assert #x900000020 ) +;; 3x3 (deftype hfrag-poly9 (structure) ((data hfrag-vert-index 9 :inline :offset-assert 0) ;; field could not be read. ) + :pack-me :method-count-assert 9 :size-assert #x48 :flag-assert #x900000048 ) +;; 5x5 (deftype hfrag-poly25 (structure) ((data hfrag-vert-index 25 :inline :offset-assert 0) ;; field could not be read. ) + :pack-me :method-count-assert 9 :size-assert #xc8 :flag-assert #x9000000c8 ) +;; literal dma data to go to VU1 (deftype hfrag-poly4-chain (structure) ((tag dma-packet :inline :offset-assert 0) (verts vector4w-3 4 :inline :offset-assert 16) @@ -25165,7 +25173,8 @@ (deftype hfrag-init-packet (structure) ((init-tmpl dma-packet :inline :offset-assert 0) - (init-data uint32 8 :offset-assert 16) + (init-data uint32 8 :offset-assert 16) ;; last one is viftag for mscalf sometimes? + (init-vif vif-tag :overlay-at (-> init-data 7)) ;(quad UNKNOWN 3 :offset-assert 0) ) :method-count-assert 9 @@ -25205,13 +25214,13 @@ ) (deftype hfrag-tex-data (structure) - ((quad qword 3 :inline :offset-assert 0) - (prims uint64 6 :offset 0) - (reg-0 uint8 :offset 8) - (reg-1 uint8 :offset 24) - (reg-2 uint8 :offset 40) - (tex0 uint64 :offset 0) - (tex1 uint64 :offset 16) + ((quad qword 3 :inline :offset-assert 0 :score -1) + (prims uint64 6 :offset 0 :score -1) + (reg-0 gs-reg :offset 8) + (reg-1 gs-reg :offset 24) + (reg-2 gs-reg :offset 40) + (tex0 gs-tex0 :offset 0) + (tex1 gs-tex1 :offset 16) (texflush uint64 :offset 32) ) :method-count-assert 9 @@ -25255,16 +25264,16 @@ ) (deftype hfrag-frame (structure) - ((quad qword 4 :inline :offset 0) - (prims uint64 8 :offset 0) - (reg-0 uint8 :offset 8) - (reg-1 uint8 :offset 24) - (reg-2 uint8 :offset 40) - (reg-3 uint8 :offset 56) - (frame uint64 :offset 0) - (scissor uint64 :offset 16) - (xyoffset uint64 :offset 32) - (test uint64 :offset 48) + ((quad qword 4 :inline :offset 0 :score -1) + (prims uint64 8 :offset 0 :score -1) + (reg-0 gs-reg :offset 8) + (reg-1 gs-reg :offset 24) + (reg-2 gs-reg :offset 40) + (reg-3 gs-reg :offset 56) + (frame gs-frame :offset 0) + (scissor gs-scissor :offset 16) + (xyoffset gs-xy-offset :offset 32) + (test gs-test :offset 48) ) :method-count-assert 9 :size-assert #x40 @@ -25282,31 +25291,31 @@ (deftype hfragment (drawable) ((start-corner vector :inline :offset-assert 32) - (spheres uint32 :offset-assert 48) - (visids uint32 :offset-assert 52) + (spheres (inline-array vector) :offset-assert 48) + (visids (pointer int16) :offset-assert 52) (shaders (inline-array adgif-shader) :offset-assert 56) - (colors basic :offset-assert 60) - (montage uint32 :offset-assert 64) - (buckets-far uint32 :offset-assert 68) - (buckets-mid uint32 :offset-assert 72) - (buckets-near uint32 :offset-assert 76) - (verts (inline-array hfrag-vertex) :offset-assert 80) - (pat-array (pointer pat-surface) :offset-assert 84) - (pat-length uint16 :offset-assert 88) - (num-buckets-far uint16 :offset-assert 90) - (num-buckets-mid uint16 :offset-assert 92) - (num-buckets-near uint16 :offset-assert 94) - (size uint32 :offset 44) + (colors time-of-day-palette :offset-assert 60) + (montage uint32 :offset-assert 64) ;; 8272 + (buckets-far (inline-array hfrag-bucket) :offset-assert 68) ;; 8276 + (buckets-mid (inline-array hfrag-bucket) :offset-assert 72) ;; 8280 + (buckets-near (inline-array hfrag-bucket) :offset-assert 76) ;; 8284 + (verts (inline-array hfrag-vertex) :offset-assert 80) ;; 8288 + (pat-array (pointer pat-surface) :offset-assert 84) ;; 8292 + (pat-length uint16 :offset-assert 88) ;; 8296 + (num-buckets-far uint16 :offset-assert 90) ;; 8298 + (num-buckets-mid uint16 :offset-assert 92) ;; 8300 + (num-buckets-near uint16 :offset-assert 94) ;; 8302 + (size uint32 :offset 44 :score 1) ) :method-count-assert 22 :size-assert #x60 :flag-assert #x1600000060 (:methods - (hfragment-method-17 (_type_ collide-cache collide-query) none) ;; 17 - (hfragment-method-18 (_type_ collide-cache collide-query) none) ;; 18 - (hfragment-method-19 (_type_ collide-cache collide-query int int int int) none) ;; 19 - (hfragment-method-20 (_type_ collide-cache int int uint uint uint pat-surface) none) ;; 20 - (hfragment-method-21 (_type_ collide-cache int int uint uint uint pat-surface) none) ;; 21 + (bounding-box-query (_type_ collide-cache collide-query) none) ;; 17 + (line-sphere-query (_type_ collide-cache collide-query) none) ;; 18 + (add-tri-to-collide-cache (_type_ collide-cache collide-query int int int int) none) ;; 19 + (add-tri-a-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) ;; 20 + (add-tri-b-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) ;; 21 ) ) @@ -25333,16 +25342,16 @@ (poly4-tmpl dma-packet 3 :inline :offset-assert 1088) (poly9-tmpl dma-packet 3 :inline :offset-assert 1136) (poly25-tmpl dma-packet 3 :inline :offset-assert 1184) - (init-tmpl dma-packet 3 :inline :offset-assert 1232) ;; ?? - (control-tmpl dma-packet 2 :inline :offset 1376) + (init-tmpl hfrag-init-packet 3 :inline :offset-assert 1232) ;; ?? + (control-tmpl dma-packet 2 :inline :offset-assert 1376) (heights4-tmpl dma-packet 2 :inline :offset-assert 1408) (colors4-tmpl dma-packet 2 :inline :offset-assert 1440) (heights9-tmpl dma-packet 2 :inline :offset-assert 1472) (colors9-tmpl dma-packet 2 :inline :offset-assert 1504) (heights25-tmpl dma-packet 2 :inline :offset-assert 1536) (colors25-tmpl dma-packet 2 :inline :offset-assert 1568) - (init-vu1-tmpl dma-packet 2 :inline :offset-assert 1600) ;; ?? - (next-tmpl dma-packet :inline :offset 1696) + (init-vu1-tmpl hfrag-init-packet 2 :inline :offset-assert 1600) ;; ?? + (next-tmpl dma-packet :inline :offset-assert 1696) (call-tmpl dma-packet :inline :offset-assert 1712) (ret-tmpl dma-packet :inline :offset-assert 1728) (next-scissor-tmpl dma-packet :inline :offset-assert 1744) @@ -25353,45 +25362,45 @@ (adgif-tmpl2 dma-gif-packet :inline :offset-assert 2160) (sprite-tmpl dma-gif-packet :inline :offset-assert 2192) (mip-tmpl dma-gif-packet :inline :offset-assert 2224) - (color uint128 6 :offset-assert 2256) + (color vector4w 6 :inline :offset-assert 2256) (far-data hfrag-sprite-coord :inline :offset-assert 2352) (near-data vector4w-2 16 :inline :offset-assert 2384) - (mip-data vector4w-3 7 :inline :offset 2896) - (tex-data hfrag-tex-data 5 :offset 3120) - (tex uint128 6 :offset 3360) - (montage-tex-coords uint128 128 :offset 3456) + (mip-data vector4w-2 7 :inline :offset-assert 2896) + (tex-data hfrag-tex-data 5 :inline :offset-assert 3120) + (tex vector 6 :inline :offset-assert 3360) + (montage-tex-coords hfrag-montage-coord 128 :inline :offset 3456) (giftag generic-gif-tag :inline :offset 7552) (call-abort dma-packet :inline :offset-assert 7568) (call-abort-vu1 dma-packet :inline :offset-assert 7584) (shader-far adgif-shader :inline :offset-assert 7600) (shader-mid adgif-shader :inline :offset-assert 7680) (shader-near adgif-shader :inline :offset-assert 7760) - (stq uint128 9 :offset-assert 7840) + (stq vector4w 9 :inline :offset-assert 7840) (shader adgif-shader :inline :offset-assert 7984) (constants vector :inline :offset-assert 8064) (pos-temp vector4w :inline :offset-assert 8080) (trans-temp vector :inline :offset 8080) (dists vector :inline :offset-assert 8096) (rdists vector :inline :offset-assert 8112) - (call-poly4-near uint32 :offset-assert 8128) - (call-poly9-mid uint32 :offset-assert 8132) - (call-poly9-near uint32 :offset-assert 8136) - (call-poly25-far uint32 :offset-assert 8140) - (call-poly25-mid uint32 :offset-assert 8144) + (call-poly4-near vif-tag :offset-assert 8128) + (call-poly9-mid vif-tag :offset-assert 8132) + (call-poly9-near vif-tag :offset-assert 8136) + (call-poly25-far vif-tag :offset-assert 8140) + (call-poly25-mid vif-tag :offset-assert 8144) (dma-buffer basic :offset-assert 8148) - (base uint32 :offset-assert 8152) + (base uint32 :offset-assert 8152) ;; dma-buffer.base (wait-to-spr uint32 :offset-assert 8156) (wait-from-spr uint32 :offset-assert 8160) (buffer-end uint32 :offset-assert 8164) (subdiv-index uint32 :offset-assert 8168) - (scissor basic :offset-assert 8172) + (scissor symbol :offset-assert 8172) (chain-ptr uint32 :offset-assert 8176) (chain-ptr-next uint32 :offset-assert 8180) (near-dist float :offset-assert 8184) (far-dist float :offset-assert 8188) - (to-spr uint32 :offset-assert 8192) + (to-spr uint32 :offset-assert 8192) ;; dma control register (from-spr uint32 :offset-assert 8196) - (lowres-flag basic :offset-assert 8200) + (lowres-flag symbol :offset-assert 8200) (hfrag hfragment :inline :offset-assert 8208) (next-far int16 :offset-assert 8304) (next-far-mid int16 :offset-assert 8306) @@ -25419,45 +25428,46 @@ (size-near-scissor int32 :offset-assert 8364) (size-texture int32 :offset-assert 8368) (poly-far hfrag-poly25 :offset-assert 8372) - (poly-mid25 uint32 :offset-assert 8376) - (poly-mid uint32 :offset-assert 8380) - (poly-near uint32 :offset-assert 8384) - (far-texture uint32 :offset-assert 8388) + (poly-mid25 (inline-array hfrag-poly25) :offset-assert 8376) + (poly-mid (inline-array hfrag-poly9) :offset-assert 8380) + (poly-near (inline-array hfrag-poly9) :offset-assert 8384) + (far-texture pointer :offset-assert 8388) (near-textures uint16 16 :offset-assert 8392) - (draw-table uint16 1024 :offset 8456) - (corners uint128 1024 :offset-assert 10512) + (draw-table int16 1024 :offset 8456) + ;; 32 x 32 grid, (z * 32 + x) + (corners vector 1024 :inline :offset-assert 10512) ) :method-count-assert 36 :size-assert #x6910 :flag-assert #x2400006910 (:methods - (hfrag-work-method-9 () none) ;; 9 - (hfrag-work-method-10 () none) ;; 10 - (hfrag-work-method-11 () none) ;; 11 - (hfrag-work-method-12 () none) ;; 12 - (hfrag-work-method-13 () none) ;; 13 - (hfrag-work-method-14 () none) ;; 14 - (hfrag-work-method-15 () none) ;; 15 - (hfrag-work-method-16 () none) ;; 16 - (hfrag-work-method-17 () none) ;; 17 - (hfrag-work-method-18 () none) ;; 18 + (initialize-renderer! (_type_) none) ;; 9 + (init-work-from-current-hfrag! (_type_) none) ;; 10 + (pick-level-of-detail! (_type_ level) none) ;; 11 (unk argument) + (generate-vertices! (_type_) none) ;; 12 + (finalize-dma! (_type_) none) ;; 13, calls shader funcs and calls init buf + (setup-far-vertex-index! (_type_ hfrag-vert-index int int) none) ;; 14 + (setup-mid-vertex-index! (_type_ hfrag-vert-index int int) none) ;; 15 + (setup-near-vertex-index! (_type_ hfrag-vert-index int int) none) ;; 16 + (init-montage-tex-coords (_type_) none) ;; 17 + (asm-far-scissor (_type_ dma-buffer int) none) ;; 18 (hfrag-work-method-19 () none) ;; 19 (hfrag-work-method-20 () none) ;; 20 - (hfrag-work-method-21 () none) ;; 21 - (hfrag-work-method-22 () none) ;; 22 - (hfrag-work-method-23 () none) ;; 23 - (hfrag-work-method-24 () none) ;; 24 - (hfrag-work-method-25 () none) ;; 25 - (hfrag-work-method-26 () none) ;; 26 - (hfrag-work-method-27 () none) ;; 27 - (hfrag-work-method-28 () none) ;; 28 - (hfrag-work-method-29 () none) ;; 29 - (hfrag-work-method-30 () none) ;; 30 - (hfrag-work-method-31 () none) ;; 31 - (hfrag-work-method-32 () none) ;; 32 - (hfrag-work-method-33 () none) ;; 33 - (hfrag-work-method-34 () none) ;; 34 - (hfrag-work-method-35 () none) ;; 35 + (asm-near-mid-scissor (_type_ dma-buffer int) none) ;; 21 + (hfrag-work-method-22 () none) ;; 22 asm + (generate-montage-texture (_type_) none) ;; 23, also asm + (hfrag-work-method-24 (_type_ dma-buffer) none) ;; 24 scissor related, spad dma? + (hfrag-work-method-25 (_type_ dma-buffer) none) ;; 25 scissor related, spad dma + (hfrag-work-method-26 (_type_ dma-buffer) none) ;; 26 scissor related, spad dma + (asm-far (_type_ dma-buffer int) none) ;; 27 asm, dma and some conversions + (asm-far-mid (_type_ dma-buffer int) none) ;; 28 asm (large), dma, vector transformation?, unpacking + (asm-mid (_type_ dma-buffer int) none) ;; 29 asm, similar to 28 + (asm-near-mid (_type_ dma-buffer int) none) ;; 30 asm, similar to 29/28 + (asm-near (_type_ dma-buffer int) none) ;; 31 asm, near? has vclip + (hfrag-work-method-32 (_type_ dma-buffer) none) ;; 32 asm, dma + (hfrag-work-method-33 (_type_ dma-buffer) none) ;; 33 asm, dma + (hfrag-work-method-34 (_type_ dma-buffer) none) ;; 34 asm, dma + (trim-dma-to-fit-in-memory (_type_) none) ;; 35 adding only thing we have dma memory for. ) ) @@ -52362,53 +52372,46 @@ ;; hfrag-vu1-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype hfrag-vu1-poly4-packet (structure) ((height-tag dma-packet :inline :offset-assert 0) (base vector :inline :offset-assert 16) - (heights UNKNOWN 4 :offset-assert 32) + (heights uint32 4 :offset-assert 32) (color-tag dma-packet :inline :offset-assert 48) - (colors UNKNOWN 4 :offset-assert 64) + (colors rgba 4 :offset-assert 64) (next dma-packet :inline :offset-assert 80) ) :method-count-assert 9 :size-assert #x60 :flag-assert #x900000060 ) -|# -#| (deftype hfrag-vu1-poly9-packet (structure) ((height-tag dma-packet :inline :offset-assert 0) (base vector3 :inline :offset-assert 16) - (heights UNKNOWN 9 :offset-assert 28) + (heights uint32 9 :offset-assert 28) (color-tag dma-packet :inline :offset-assert 64) - (colors UNKNOWN 12 :offset-assert 80) + (colors rgba 12 :offset-assert 80) (next dma-packet :inline :offset-assert 128) - (jump-index int32 :offset-assert 20) + (jump-index int32 :offset 20) ) :method-count-assert 9 :size-assert #x90 :flag-assert #x900000090 ) -|# -#| (deftype hfrag-vu1-poly25-packet (structure) ((height-tag dma-packet :inline :offset-assert 0) (base vector3 :inline :offset-assert 16) - (heights UNKNOWN 25 :offset-assert 28) + (heights uint32 25 :offset-assert 28) (color-tag dma-packet :inline :offset-assert 128) - (colors UNKNOWN 28 :offset-assert 144) + (colors rgba 28 :offset-assert 144) (next dma-packet :inline :offset-assert 256) ) :method-count-assert 9 :size-assert #x110 :flag-assert #x900000110 ) -|# -#| (deftype hfrag-vu1-vertex (structure) ((tex vector :inline :offset-assert 0) (clr vector :inline :offset-assert 16) @@ -52418,79 +52421,69 @@ :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype hfrag-vu1-poly4 (structure) ((giftag vector :inline :offset-assert 0) - (verts UNKNOWN 4 :offset-assert 16) + (verts hfrag-vu1-vertex 4 :inline :offset-assert 16) ) :method-count-assert 9 :size-assert #xd0 :flag-assert #x9000000d0 ) -|# -#| (deftype hfrag-vu1-poly9 (structure) ((giftag0 vector :inline :offset-assert 0) - (verts0 UNKNOWN 6 :offset-assert 16) + (verts0 hfrag-vu1-vertex 6 :inline :offset-assert 16) (giftag1 vector :inline :offset-assert 304) - (verts1 UNKNOWN 6 :offset-assert 320) + (verts1 hfrag-vu1-vertex 6 :inline :offset-assert 320) ) :method-count-assert 9 :size-assert #x260 :flag-assert #x900000260 ) -|# -#| (deftype hfrag-vu1-poly25 (structure) ((giftag0 vector :inline :offset-assert 0) - (verts0 UNKNOWN 10 :offset-assert 16) + (verts0 hfrag-vu1-vertex 10 :inline :offset-assert 16) (giftag1 vector :inline :offset-assert 496) - (verts1 UNKNOWN 10 :offset-assert 512) + (verts1 hfrag-vu1-vertex 10 :inline :offset-assert 512) (giftag2 vector :inline :offset-assert 992) - (verts2 UNKNOWN 10 :offset-assert 1008) + (verts2 hfrag-vu1-vertex 10 :inline :offset-assert 1008) (giftag3 vector :inline :offset-assert 1488) - (verts3 UNKNOWN 10 :offset-assert 1504) + (verts3 hfrag-vu1-vertex 10 :inline :offset-assert 1504) ) :method-count-assert 9 :size-assert #x7c0 :flag-assert #x9000007c0 ) -|# -#| (deftype hfrag-vu1-constants-base (structure) - ((far-verts UNKNOWN 25 :offset-assert 0) - (mid-verts9 UNKNOWN 9 :offset-assert 400) - (mid-verts25 UNKNOWN 25 :offset-assert 544) - (near-verts4 UNKNOWN 4 :offset-assert 944) - (near-verts9 UNKNOWN 9 :offset-assert 1008) - (sts UNKNOWN 9 :offset-assert 1152) - (data UNKNOWN 81 :offset-assert 0) + ((far-verts vector 25 :inline :offset-assert 0) + (mid-verts9 vector 9 :inline :offset-assert 400) + (mid-verts25 vector 25 :inline :offset-assert 544) + (near-verts4 vector 4 :inline :offset-assert 944) + (near-verts9 vector 9 :inline :offset-assert 1008) + (sts vector 9 :inline :offset-assert 1152) + (data vector 81 :inline :offset 0) ) :method-count-assert 9 :size-assert #x510 :flag-assert #x900000510 ) -|# -#| (deftype hfrag-vu1-constants (structure) ((base hfrag-vu1-constants-base :inline :offset-assert 0) - (far-verts UNKNOWN 25 :offset-assert 0) - (mid-verts9 UNKNOWN 9 :offset-assert 400) - (mid-verts25 UNKNOWN 25 :offset-assert 544) - (near-verts4 UNKNOWN 4 :offset-assert 944) - (near-verts9 UNKNOWN 9 :offset-assert 1008) - (sts UNKNOWN 9 :offset-assert 1152) - (drw-strip4 qword :inline :offset-assert 1296) - (drw-strip9-0 qword :inline :offset-assert 1312) - (drw-strip9-1 qword :inline :offset-assert 1328) - (drw-strip25-0 qword :inline :offset-assert 1344) - (drw-strip25-1 qword :inline :offset-assert 1360) + (far-verts vector 25 :inline :offset 0) + (mid-verts9 vector 9 :inline :offset 400) + (mid-verts25 vector 25 :inline :offset 544) + (near-verts4 vector 4 :inline :offset 944) + (near-verts9 vector 9 :inline :offset 1008) + (sts vector 9 :inline :offset 1152) + (drw-strip4 gs-gif-tag :inline :offset-assert 1296) + (drw-strip9-0 gs-gif-tag :inline :offset-assert 1312) + (drw-strip9-1 gs-gif-tag :inline :offset-assert 1328) + (drw-strip25-0 gs-gif-tag :inline :offset-assert 1344) + (drw-strip25-1 gs-gif-tag :inline :offset-assert 1360) (matrix matrix :inline :offset-assert 1376) (hvdf-offset vector :inline :offset-assert 1440) (hmge-scale vector :inline :offset-assert 1456) @@ -52501,7 +52494,6 @@ :size-assert #x5e0 :flag-assert #x9000005e0 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -52513,34 +52505,34 @@ ;; hfrag-vu1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern hfrag-vu1-block object) -;; (define-extern hfrag-setup-constants function) -;; (define-extern hfrag-add-constants function) -;; (define-extern hfrag-vu1-end-buffer function) -;; (define-extern hfrag-vu1-init-buf function) +(define-extern hfrag-vu1-block vu-function) +(define-extern hfrag-setup-constants (function hfrag-vu1-constants none)) +(define-extern hfrag-add-constants (function dma-buffer none)) +(define-extern hfrag-vu1-end-buffer (function dma-buffer none)) +(define-extern hfrag-vu1-init-buf (function none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hfrag ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern *hfrag-debug* symbol) -;; (define-extern hfrag-vert-print function) +(define-extern hfrag-vert-print (function int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hfrag-work ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern *hfrag-work* object) -;; (define-extern *hfrag-vu1-constants-base* object) +(define-extern *hfrag-work* hfrag-work) +(define-extern *hfrag-vu1-constants-base* hfrag-vu1-constants-base) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hfrag-texture-anim ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern wang-texture-anim-init function) -;; (define-extern real-wang-texture-anim-func function) -;; (define-extern wang-texture-anim-func function) -;; (define-extern *hfrag-texture-anim-array* texture-anim-array) +(define-extern wang-texture-anim-init (function texture-anim none)) +(define-extern real-wang-texture-anim-func (function texture-anim texture-anim none)) +(define-extern wang-texture-anim-func (function none)) +(define-extern *hfrag-texture-anim-array* (texture-anim-array texture-anim)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; desert-mood ;; diff --git a/decompiler/config/jak3/ntsc_v1/label_types.jsonc b/decompiler/config/jak3/ntsc_v1/label_types.jsonc index 30d888189..ad8fb9397 100644 --- a/decompiler/config/jak3/ntsc_v1/label_types.jsonc +++ b/decompiler/config/jak3/ntsc_v1/label_types.jsonc @@ -1900,5 +1900,29 @@ ["L580", "uint64", true], ["L593", "uint64", true], ["L595", "uint64", true] + ], + "hfrag-vu1": [ + ["L250", "uint64", true], + ["L249", "uint64", true], + ["L248", "uint64", true], + ["L247", "uint64", true], + ["L246", "uint64", true], + ["L245", "uint64", true], + ["L244", "uint64", true], + ["L243", "uint64", true], + ["L242", "uint64", true], + ["L241", "uint64", true], + ["L240", "uint64", true], + ["L239", "uint64", true], + ["L238", "uint64", true], + ["L237", "uint64", true], + ["L236", "uint64", true], + ["L235", "uint64", true], + ["L234", "uint64", true], + ["L233", "uint64", true], + ["L232", "uint64", true], + ["L231", "uint64", true], + ["L230", "uint64", true], + ["L229", "uint64", true] ] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 4458c6209..17287af95 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -10551,5 +10551,23 @@ "(method 26 task-manager-city-sniper-fight)": [["_stack_", 16, "res-tag"]], "(code active task-manager-city-sniper-fight)": [ [80, "a1", "process-drawable"] + ], + "hfrag-add-constants": [ + [[3, 17], "a0", "dma-packet"] + ], + "hfrag-vu1-end-buffer": [ + [[1, 8], "a1", "dma-packet"], + [[10, 28], "a1", "(pointer vif-tag)"] + ], + "hfrag-vu1-init-buf": [ + [[53, 60], "a0", "dma-packet"], + [[63, 67], "a0", "(pointer uint32)"], + [[68, 79], "a0", "(pointer vif-tag)"], + [[81, 91], "v1", "dma-packet"], + [[135, 141], "v1", "dma-packet"], + [143, "v1", "(pointer uint32)"] + ], + "real-wang-texture-anim-func": [ + [[3, 31], "v1", "mood-context"] ] } diff --git a/decompiler/level_extractor/BspHeader.cpp b/decompiler/level_extractor/BspHeader.cpp index fe44d7306..b502af8f9 100644 --- a/decompiler/level_extractor/BspHeader.cpp +++ b/decompiler/level_extractor/BspHeader.cpp @@ -11,16 +11,6 @@ namespace level_tools { -std::string DrawStats::print() const { - std::string result; - result += fmt::format("tfrag tris: {}\n", total_tfrag_tris); - result += fmt::format("tie prototype tris: {}\n", total_tie_prototype_tris); - result += fmt::format("actors: {}\n", total_actors); - result += fmt::format("instances: {}\n", total_tie_instances); - result += fmt::format("total tfragments: {}\n", total_tfragments); - return result; -} - void Vector::read_from_file(Ref ref) { if ((ref.byte_offset % 16) != 0) { throw Error("misaligned vector"); @@ -47,6 +37,17 @@ void Matrix4h::read_from_file(Ref ref) { } } +void TimeOfDayPalette::read_from_file(Ref ref) { + width = deref_u32(ref, 0); + ASSERT(width == 8); + height = deref_u32(ref, 1); + pad = deref_u32(ref, 2); + ASSERT(pad == 0); + for (int i = 0; i < int(8 * height); i++) { + colors.push_back(deref_u32(ref, 3 + i)); + } +} + std::string Vector::print(int indent) const { std::string is(indent, ' '); std::string result; @@ -95,7 +96,6 @@ std::string FileInfo::print(int indent) const { void DrawableTreeUnknown::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& /*dts*/, - DrawStats* /*stats*/, GameVersion /*version*/) { type_name = ref.type->get_name(); } @@ -113,7 +113,6 @@ std::string DrawableTreeUnknown::my_type() const { void DrawableInlineArrayUnknown::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& /*dts*/, - DrawStats* /*stats*/, GameVersion /*version*/) { type_name = ref.type->get_name(); } @@ -131,27 +130,26 @@ std::string DrawableInlineArrayUnknown::my_type() const { std::unique_ptr make_draw_node_child(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { if (ref.type->get_name() == "draw-node") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } else if (ref.type->get_name() == "tfragment") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } else if (ref.type->get_name() == "instance-tie") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } else if (ref.type->get_name() == "drawable-actor") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } else if (ref.type->get_name() == "instance-shrubbery") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } else { throw Error("Unknown child of draw node: {}\n", ref.type->get_name()); @@ -174,9 +172,7 @@ int get_child_stride(const std::string& type) { } } -void TFragmentDebugData::read_from_file(Ref ref, - const decompiler::DecompilerTypeSystem& /*dts*/, - DrawStats* stats) { +void TFragmentDebugData::read_from_file(Ref ref, const decompiler::DecompilerTypeSystem& /*dts*/) { u32 data[4]; auto& words = ref.data->words_by_seg.at(ref.seg); for (int i = 0; i < 4; i++) { @@ -194,7 +190,6 @@ void TFragmentDebugData::read_from_file(Ref ref, for (auto num_tri : num_tris) { tris = std::max(tris, (u32)num_tri); } - stats->total_tfrag_tris += tris; auto& debug_word = words.at(4 + (ref.byte_offset / 4)); if (debug_word.kind() != decompiler::LinkedWord::PLAIN_DATA || debug_word.data != 0) { @@ -319,12 +314,10 @@ std::vector read_dma_chain(Ref& start, u32 qwc) { void TFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { - stats->total_tfragments++; id = read_plain_data_field(ref, "id", dts); color_index = read_plain_data_field(ref, "color-index", dts); - debug_data.read_from_file(deref_label(get_field_ref(ref, "debug-data", dts)), dts, stats); + debug_data.read_from_file(deref_label(get_field_ref(ref, "debug-data", dts)), dts); // todo color_indices bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); @@ -350,7 +343,7 @@ void TFragment::read_from_file(TypedRef ref, dma_slot.byte_offset += 4; } - if (stats->debug_print_dma_data) { + if (false) { // first, common lg::info("DMA COMMON {}, {} qwc:", dmas[0].label_name, dma_qwc[0]); tfrag_debug_print_unpack(dmas[0].ref, dma_qwc[0]); @@ -457,7 +450,6 @@ void memcpy_plain_data(u8* dst, const Ref& ref, size_t size_bytes) { void TieFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); switch (version) { @@ -502,8 +494,6 @@ void TieFragment::read_from_file(TypedRef ref, memcpy(point_ref.data() + (i * 4), &word.data, 4); } - stats->total_tie_prototype_tris += num_tris; - if (version > GameVersion::Jak1) { u16 normals_qwc = read_plain_data_field(ref, "normal-count", dts); if (normals_qwc) { @@ -539,7 +529,6 @@ std::string DrawableActor::print(const PrintSettings& /*settings*/, int indent) void InstanceTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion /*version*/) { bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); bucket_index = read_plain_data_field(ref, "bucket-index", dts); @@ -549,7 +538,6 @@ void InstanceTie::read_from_file(TypedRef ref, origin.read_from_file(get_field_ref(ref, "origin", dts)); wind_index = read_plain_data_field(ref, "wind-index", dts); color_indices = deref_label(get_field_ref(ref, "color-indices", dts)); - stats->total_tie_instances++; } std::string InstanceTie::print(const PrintSettings& /*settings*/, int indent) const { @@ -562,7 +550,6 @@ std::string InstanceTie::print(const PrintSettings& /*settings*/, int indent) co void DrawNode::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); // 4 bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); // 16 @@ -575,7 +562,7 @@ void DrawNode::read_from_file(TypedRef ref, for (int i = 0; i < child_count; i++) { children.push_back( - make_draw_node_child(typed_ref_from_basic(first_child_obj, dts), dts, stats, version)); + make_draw_node_child(typed_ref_from_basic(first_child_obj, dts), dts, version)); first_child_obj.byte_offset += get_child_stride(get_type_of_basic(first_child_obj)); } @@ -607,7 +594,6 @@ std::string DrawNode::my_type() const { void DrawableInlineArrayNode::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -622,7 +608,7 @@ void DrawableInlineArrayNode::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } draw_nodes.emplace_back(); - draw_nodes.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + draw_nodes.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -650,7 +636,6 @@ std::string DrawableInlineArrayNode::my_type() const { void DrawableInlineArrayTFrag::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -665,7 +650,7 @@ void DrawableInlineArrayTFrag::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } tfragments.emplace_back(); - tfragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + tfragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -693,7 +678,6 @@ std::string DrawableInlineArrayTFrag::my_type() const { void DrawableInlineArrayInstanceTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -708,7 +692,7 @@ void DrawableInlineArrayInstanceTie::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } instances.emplace_back(); - instances.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + instances.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -740,7 +724,6 @@ std::string PrototypeTie::my_type() const { void PrototypeTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -755,7 +738,7 @@ void PrototypeTie::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } tie_fragments.emplace_back(); - tie_fragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + tie_fragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -780,58 +763,56 @@ std::string PrototypeTie::print(const PrintSettings& settings, int indent) const std::unique_ptr make_drawable_inline_array( TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { if (ref.type->get_name() == "drawable-inline-array-node") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-tfrag") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-trans-tfrag") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-tfrag-trans") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-tfrag-water") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-instance-tie") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } if (ref.type->get_name() == "drawable-inline-array-instance-shrub") { auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } auto result = std::make_unique(); - result->read_from_file(ref, dts, stats, version); + result->read_from_file(ref, dts, version); return result; } void DrawableTreeTfrag::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -842,16 +823,7 @@ void DrawableTreeTfrag::read_from_file(TypedRef ref, throw Error("misaligned data array"); } - auto palette = deref_label(get_field_ref(ref, "time-of-day-pal", dts)); - time_of_day.width = deref_u32(palette, 0); - - ASSERT(time_of_day.width == 8); - time_of_day.height = deref_u32(palette, 1); - time_of_day.pad = deref_u32(palette, 2); - ASSERT(time_of_day.pad == 0); - for (int i = 0; i < int(8 * time_of_day.height); i++) { - time_of_day.colors.push_back(deref_u32(palette, 3 + i)); - } + time_of_day.read_from_file(deref_label(get_field_ref(ref, "time-of-day-pal", dts))); for (int idx = 0; idx < length; idx++) { Ref array_slot_ref = data_ref; @@ -861,7 +833,7 @@ void DrawableTreeTfrag::read_from_file(TypedRef ref, object_ref.byte_offset -= 4; arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } } @@ -894,7 +866,6 @@ std::string DrawableTreeTfrag::my_type() const { void DrawableTreeActor::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -913,7 +884,7 @@ void DrawableTreeActor::read_from_file(TypedRef ref, object_ref.byte_offset -= 4; arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } } @@ -942,7 +913,6 @@ std::string DrawableTreeActor::my_type() const { void PrototypeBucketTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { name = read_string_field(ref, "name", dts, true); switch (version) { @@ -970,7 +940,7 @@ void PrototypeBucketTie::read_from_file(TypedRef ref, if (word.kind() == decompiler::LinkedWord::PTR) { auto p = deref_label(fr); p.byte_offset -= 4; - collide_frag.read_from_file(typed_ref_from_basic(p, dts), dts, stats, version); + collide_frag.read_from_file(typed_ref_from_basic(p, dts), dts, version); } } } else { @@ -1024,7 +994,7 @@ void PrototypeBucketTie::read_from_file(TypedRef ref, if (get_type_of_basic(geom) != "prototype-tie") { throw Error("bad type in prototype-bucket-tie: {}", get_type_of_basic(geom)); } - geometry[i].read_from_file(typed_ref_from_basic(geom, dts), dts, stats, version); + geometry[i].read_from_file(typed_ref_from_basic(geom, dts), dts, version); geom_start.byte_offset += 4; } @@ -1060,16 +1030,7 @@ void PrototypeBucketTie::read_from_file(TypedRef ref, } // get the colors - auto palette = deref_label(get_field_ref(ref, "tie-colors", dts)); - time_of_day.width = deref_u32(palette, 0); - - ASSERT(time_of_day.width == 8); - time_of_day.height = deref_u32(palette, 1); - time_of_day.pad = deref_u32(palette, 2); - ASSERT(time_of_day.pad == 0); - for (int i = 0; i < int(8 * time_of_day.height); i++) { - time_of_day.colors.push_back(deref_u32(palette, 3 + i)); - } + time_of_day.read_from_file(deref_label(get_field_ref(ref, "tie-colors", dts))); auto fr = get_field_ref(ref, "envmap-shader", dts); const auto& word = fr.data->words_by_seg.at(fr.seg).at(fr.byte_offset / 4); @@ -1129,7 +1090,6 @@ std::string PrototypeBucketTie::print(const PrintSettings& settings, int indent) void PrototypeArrayTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { length = read_plain_data_field(ref, "length", dts); allocated_length = read_plain_data_field(ref, "allocated-length", dts); @@ -1146,7 +1106,7 @@ void PrototypeArrayTie::read_from_file(TypedRef ref, throw Error("bad type in PrototypeArrayTie data: {}\n", type); } data.emplace_back(); - data.back().read_from_file(typed_ref_from_basic(thing, dts), dts, stats, version); + data.back().read_from_file(typed_ref_from_basic(thing, dts), dts, version); } } @@ -1167,11 +1127,10 @@ std::string PrototypeArrayTie::print(const PrintSettings& settings, int indent) void ProxyPrototypeArrayTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { prototype_array_tie.read_from_file( get_and_check_ref_to_basic(ref, "prototype-array-tie", "prototype-array-tie", dts), dts, - stats, version); + version); wind_vectors = deref_label(get_field_ref(ref, "wind-vectors", dts)); } @@ -1182,7 +1141,6 @@ std::string ProxyPrototypeArrayTie::print(const PrintSettings& settings, int ind void DrawableTreeInstanceTie::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -1191,7 +1149,7 @@ void DrawableTreeInstanceTie::read_from_file(TypedRef ref, auto pt = deref_label(get_field_ref(ref, "prototypes", dts)); pt.byte_offset -= 4; - prototypes.read_from_file(typed_ref_from_basic(pt, dts), dts, stats, version); + prototypes.read_from_file(typed_ref_from_basic(pt, dts), dts, version); auto data_ref = get_field_ref(ref, "data", dts); if ((data_ref.byte_offset % 4) != 0) { @@ -1205,7 +1163,7 @@ void DrawableTreeInstanceTie::read_from_file(TypedRef ref, object_ref.byte_offset -= 4; arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } } @@ -1241,7 +1199,6 @@ std::string DrawableTreeInstanceTie::my_type() const { void DrawableTreeCollideFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { s16 length = read_plain_data_field(ref, "length", dts); auto data_ref = get_field_ref(ref, "data", dts); @@ -1254,7 +1211,7 @@ void DrawableTreeCollideFragment::read_from_file(TypedRef ref, Ref object_ref = deref_label(array_slot_ref); object_ref.byte_offset -= 4; - last_array.read_from_file(typed_ref_from_basic(object_ref, dts), dts, stats, version); + last_array.read_from_file(typed_ref_from_basic(object_ref, dts), dts, version); } std::string DrawableTreeCollideFragment::print(const PrintSettings& settings, int indent) const { @@ -1267,7 +1224,6 @@ std::string DrawableTreeCollideFragment::my_type() const { void DrawableInlineArrayCollideFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion /*version*/) { ASSERT(ref.type->get_name() == "drawable-inline-array-collide-fragment"); id = read_plain_data_field(ref, "id", dts); @@ -1283,7 +1239,7 @@ void DrawableInlineArrayCollideFragment::read_from_file(TypedRef ref, throw Error("bad collide fragment type: {}", type); } collide_fragments.emplace_back(); - collide_fragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats); + collide_fragments.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts); } } @@ -1309,13 +1265,11 @@ std::string DrawableInlineArrayCollideFragment::my_type() const { return "drawable-inline-array-collide-fragment"; } -void CollideFragment::read_from_file(TypedRef ref, - const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats) { +void CollideFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts) { bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); auto r = deref_label(get_field_ref(ref, "mesh", dts)); r.byte_offset -= 4; - mesh.read_from_file(typed_ref_from_basic(r, dts), dts, stats); + mesh.read_from_file(typed_ref_from_basic(r, dts), dts); } std::string CollideFragment::print(const PrintSettings& settings, int indent) const { @@ -1327,9 +1281,7 @@ std::string CollideFragment::print(const PrintSettings& settings, int indent) co return result; } -void CollideFragMesh::read_from_file(TypedRef ref, - const decompiler::DecompilerTypeSystem& dts, - DrawStats* /*stats*/) { +void CollideFragMesh::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts) { strip_data_len = read_plain_data_field(ref, "strip-data-len", dts); poly_count = read_plain_data_field(ref, "poly-count", dts); vertex_count = read_plain_data_field(ref, "vertex-count", dts); @@ -1363,7 +1315,6 @@ namespace shrub_types { void DrawableTreeInstanceShrub::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { // the usual drawable stuff id = read_plain_data_field(ref, "id", dts); @@ -1385,7 +1336,7 @@ void DrawableTreeInstanceShrub::read_from_file(TypedRef ref, object_ref.byte_offset -= 4; arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } // confirm that we have the weird shrub pattern and only found one array. ASSERT(length == 1); @@ -1399,7 +1350,7 @@ void DrawableTreeInstanceShrub::read_from_file(TypedRef ref, Ref object_ref = deref_label(data_ref); object_ref.byte_offset -= 4; discovered_arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); bool done = false; object_ref.byte_offset += 16; @@ -1408,10 +1359,10 @@ void DrawableTreeInstanceShrub::read_from_file(TypedRef ref, if (word.kind() == decompiler::LinkedWord::TYPE_PTR) { if (word.symbol_name() == "drawable-inline-array-node") { discovered_arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } else if (word.symbol_name() == "drawable-inline-array-instance-shrub") { discovered_arrays.push_back( - make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + make_drawable_inline_array(typed_ref_from_basic(object_ref, dts), dts, version)); } else if (word.symbol_name() == "time-of-day-palette" || word.symbol_name() == "light-hash" || word.symbol_name() == "collide-hash-fragment") { @@ -1426,18 +1377,10 @@ void DrawableTreeInstanceShrub::read_from_file(TypedRef ref, // this "info" thing holds all the prototypes auto pt = deref_label(get_field_ref(ref, "info", dts)); pt.byte_offset -= 4; - info.read_from_file(typed_ref_from_basic(pt, dts), dts, stats, version); + info.read_from_file(typed_ref_from_basic(pt, dts), dts, version); // time of day palette. we'll want these colors in the FR3 file. - auto palette = deref_label(get_field_ref(ref, "colors-added", dts)); - time_of_day.width = deref_u32(palette, 0); - ASSERT(time_of_day.width == 8); - time_of_day.height = deref_u32(palette, 1); - time_of_day.pad = deref_u32(palette, 2); - ASSERT(time_of_day.pad == 0); - for (int i = 0; i < int(8 * time_of_day.height); i++) { - time_of_day.colors.push_back(deref_u32(palette, 3 + i)); - } + time_of_day.read_from_file(deref_label(get_field_ref(ref, "colors-added", dts))); } std::string DrawableTreeInstanceShrub::my_type() const { @@ -1471,7 +1414,6 @@ std::string DrawableTreeInstanceShrub::print(const level_tools::PrintSettings& s void InstanceShrubbery::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* /*stats*/, GameVersion /*version*/) { bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); bucket_index = read_plain_data_field(ref, "bucket-index", dts); @@ -1496,7 +1438,6 @@ std::string InstanceShrubbery::print(const level_tools::PrintSettings& /*setting void DrawableInlineArrayInstanceShrub::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -1511,7 +1452,7 @@ void DrawableInlineArrayInstanceShrub::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } instances.emplace_back(); - instances.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + instances.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -1536,12 +1477,11 @@ std::string DrawableInlineArrayInstanceShrub::print(const PrintSettings& setting void PrototypeArrayShrubInfo::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { prototype_inline_array_shrub.read_from_file( get_and_check_ref_to_basic(ref, "prototype-inline-array-shrub", "prototype-inline-array-shrub", dts), - dts, stats, version); + dts, version); wind_vectors = deref_label(get_field_ref(ref, "wind-vectors", dts)); } @@ -1552,7 +1492,6 @@ std::string PrototypeArrayShrubInfo::print(const level_tools::PrintSettings& set void PrototypeInlineArrayShrub::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { length = read_plain_data_field(ref, "length", dts); auto data_ref = get_field_ref(ref, "data", dts); @@ -1566,7 +1505,7 @@ void PrototypeInlineArrayShrub::read_from_file(TypedRef ref, throw Error("bad type in PrototypeInlineArrayShrub data: {}\n", type); } data.emplace_back(); - data.back().read_from_file(typed_ref_from_basic(thing, dts), dts, stats, version); + data.back().read_from_file(typed_ref_from_basic(thing, dts), dts, version); } } @@ -1586,7 +1525,6 @@ std::string PrototypeGenericShrub::print(const level_tools::PrintSettings& setti void PrototypeGenericShrub::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { length = read_plain_data_field(ref, "length", dts); bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); @@ -1602,7 +1540,7 @@ void PrototypeGenericShrub::read_from_file(TypedRef ref, throw Error("bad type in PrototypeGenericShrub data: {}\n", type); } shrubs.emplace_back(); - shrubs.back().read_from_file(typed_ref_from_basic(thing, dts), dts, stats, version); + shrubs.back().read_from_file(typed_ref_from_basic(thing, dts), dts, version); } } @@ -1622,7 +1560,6 @@ std::string PrototypeInlineArrayShrub::print(const level_tools::PrintSettings& s void PrototypeBucketShrub::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { name = read_string_field(ref, "name", dts, true); switch (version) { @@ -1667,10 +1604,10 @@ void PrototypeBucketShrub::read_from_file(TypedRef ref, if (get_type_of_basic(normal_geom) != "prototype-shrubbery") { throw Error("bad normal shrub type: {}", get_type_of_basic(normal_geom)); } - shrubbery_geom.read_from_file(typed_ref_from_basic(normal_geom, dts), dts, stats, version); + shrubbery_geom.read_from_file(typed_ref_from_basic(normal_geom, dts), dts, version); geom_start.byte_offset += 4; - generic_geom.read_from_file(typed_ref_from_basic(generic_geom_l, dts), dts, stats, version); + generic_geom.read_from_file(typed_ref_from_basic(generic_geom_l, dts), dts, version); // todo transparent version // todo billboard version. @@ -1694,7 +1631,6 @@ std::string PrototypeBucketShrub::print(const level_tools::PrintSettings& settin void PrototypeShrubbery::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -1709,7 +1645,7 @@ void PrototypeShrubbery::read_from_file(TypedRef ref, throw Error("bad draw node type: {}", type); } shrubs.emplace_back(); - shrubs.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + shrubs.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } @@ -1740,7 +1676,6 @@ void copy_dma_to_vector(std::vector* out, Ref data_start, int qwc) { void Shrubbery::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* /*stats*/, GameVersion /*version*/) { // read the easy ones. obj_qwc = read_plain_data_field(ref, "obj-qwc", dts); @@ -1779,7 +1714,6 @@ std::string GenericShrubFragment::print(const level_tools::PrintSettings& /*sett void GenericShrubFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* /*stats*/, GameVersion /*version*/) { cnt_qwc = read_plain_data_field(ref, "cnt-qwc", dts); vtx_qwc = read_plain_data_field(ref, "vtx-qwc", dts); @@ -1797,82 +1731,80 @@ void GenericShrubFragment::read_from_file(TypedRef ref, std::unique_ptr make_drawable_tree(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { if (ref.type->get_name() == "drawable-tree-tfrag") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-trans-tfrag") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-lowres-tfrag") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-dirt-tfrag") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-ice-tfrag") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-instance-tie") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-tfrag-trans") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-tfrag-water") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-actor") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-instance-shrub") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } if (ref.type->get_name() == "drawable-tree-collide-fragment") { auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } auto tree = std::make_unique(); - tree->read_from_file(ref, dts, stats, version); + tree->read_from_file(ref, dts, version); return tree; } void DrawableTreeArray::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { id = read_plain_data_field(ref, "id", dts); length = read_plain_data_field(ref, "length", dts); @@ -1889,7 +1821,7 @@ void DrawableTreeArray::read_from_file(TypedRef ref, Ref object_ref = deref_label(array_slot_ref); object_ref.byte_offset -= 4; - trees.push_back(make_drawable_tree(typed_ref_from_basic(object_ref, dts), dts, stats, version)); + trees.push_back(make_drawable_tree(typed_ref_from_basic(object_ref, dts), dts, version)); } } @@ -1916,7 +1848,6 @@ void fill_res_with_value_types(Res& res_tag, const Ref& data) { void EntityActor::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* /*stats*/, GameVersion /*version*/) { trans.read_from_file(get_field_ref(ref, "trans", dts)); aid = read_plain_data_field(ref, "aid", dts); @@ -1998,17 +1929,13 @@ void EntityActor::read_from_file(TypedRef ref, void DrawableActor::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { bsphere.read_from_file(get_field_ref(ref, "bsphere", dts)); - actor.read_from_file(get_and_check_ref_to_basic(ref, "actor", "entity-actor", dts), dts, stats, - version); - stats->total_actors++; + actor.read_from_file(get_and_check_ref_to_basic(ref, "actor", "entity-actor", dts), dts, version); } void DrawableInlineArrayActor::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) { int num_actors = read_plain_data_field(ref, "length", dts); auto data_ref = get_field_ref(ref, "data", dts); @@ -2020,21 +1947,48 @@ void DrawableInlineArrayActor::read_from_file(TypedRef ref, throw Error("bad drawable-actor type: {}", type); } drawable_actors.emplace_back(); - drawable_actors.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, stats, version); + drawable_actors.back().read_from_file(typed_ref_from_basic(obj_ref, dts), dts, version); } } void CollideHash::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* /*stats*/, GameVersion /*version*/) { num_items = read_plain_data_field(ref, "num-items", dts); item_array = deref_label(get_field_ref(ref, "item-array", dts)); } +void HFragment::read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts) { + start_corner.read_from_file(get_field_ref(ref, "start-corner", dts)); + spheres.resize(kNumCorners); + auto spheres_ptr = deref_label(get_field_ref(ref, "spheres", dts)); + for (int i = 0; i < kNumCorners; i++) { + spheres[i].read_from_file(spheres_ptr); + spheres_ptr.byte_offset += 16; + } + + vis_ids.resize(kNumCorners); + memcpy_plain_data((u8*)vis_ids.data(), deref_label(get_field_ref(ref, "visids", dts)), + sizeof(s16) * kNumCorners); + memcpy_plain_data((u8*)shaders, deref_label(get_field_ref(ref, "shaders", dts)), 80 * 3); + colors.read_from_file(deref_label(get_field_ref(ref, "colors", dts))); + // note: using hard-coded size here + memcpy_plain_data((u8*)montage, deref_label(get_field_ref(ref, "montage", dts)), + sizeof(u16) * 16 * 17); + // bucket + verts.resize(kNumVerts); + memcpy_plain_data((u8*)verts.data(), deref_label(get_field_ref(ref, "verts", dts)), + sizeof(u32) * kNumVerts); + // pat-array + // pat-len + num_buckets_far = read_plain_data_field(ref, "num-buckets-far", dts); + num_buckets_mid = read_plain_data_field(ref, "num-buckets-mid", dts); + num_buckets_near = read_plain_data_field(ref, "num-buckets-near", dts); + size = read_plain_data_field(ref, "size", dts); +} + void BspHeader::read_from_file(const decompiler::LinkedObjectFile& file, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version, bool only_read_texture_remap) { TypedRef ref; @@ -2072,14 +2026,14 @@ void BspHeader::read_from_file(const decompiler::LinkedObjectFile& file, case GameVersion::Jak2: case GameVersion::Jak3: visible_list_length = read_plain_data_field(ref, "visible-list-length", dts); + extra_vis_list_length = read_plain_data_field(ref, "extra-vis-list-length", dts); break; default: ASSERT(false); } drawable_tree_array.read_from_file( - get_and_check_ref_to_basic(ref, "drawable-trees", "drawable-tree-array", dts), dts, stats, - version); + get_and_check_ref_to_basic(ref, "drawable-trees", "drawable-tree-array", dts), dts, version); if (version > GameVersion::Jak1) { auto ff = get_field_ref(ref, "texture-flags", dts); @@ -2088,14 +2042,22 @@ void BspHeader::read_from_file(const decompiler::LinkedObjectFile& file, if (get_word_kind_for_field(ref, "actors", dts) == decompiler::LinkedWord::PTR) { actors.read_from_file( - get_and_check_ref_to_basic(ref, "actors", "drawable-inline-array-actor", dts), dts, stats, + get_and_check_ref_to_basic(ref, "actors", "drawable-inline-array-actor", dts), dts, version); } if (version > GameVersion::Jak1 && get_word_kind_for_field(ref, "collide-hash", dts) == decompiler::LinkedWord::PTR) { collide_hash.read_from_file( - get_and_check_ref_to_basic(ref, "collide-hash", "collide-hash", dts), dts, stats, version); + get_and_check_ref_to_basic(ref, "collide-hash", "collide-hash", dts), dts, version); + } + + if (version == GameVersion::Jak3) { + if (get_word_kind_for_field(ref, "hfrag-drawable", dts) == decompiler::LinkedWord::PTR) { + hfrag.emplace(); + hfrag->read_from_file(get_and_check_ref_to_basic(ref, "hfrag-drawable", "hfragment", dts), + dts); + } } } diff --git a/decompiler/level_extractor/BspHeader.h b/decompiler/level_extractor/BspHeader.h index 26e497ea7..128912a82 100644 --- a/decompiler/level_extractor/BspHeader.h +++ b/decompiler/level_extractor/BspHeader.h @@ -32,18 +32,6 @@ struct PrintSettings { bool expand_collide = false; }; -struct DrawStats { - int total_tfrag_tris = 0; - int total_tie_prototype_tris = 0; - int total_actors = 0; - int total_tie_instances = 0; - int total_tfragments = 0; - - bool debug_print_dma_data = false; - - std::string print() const; -}; - ///////////////////// // Common Types ///////////////////// @@ -73,6 +61,7 @@ struct TimeOfDayPalette { u32 height; u32 pad; std::vector colors; + void read_from_file(Ref ref); }; ///////////////////// @@ -87,7 +76,6 @@ struct TimeOfDayPalette { struct Drawable { virtual void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) = 0; virtual std::string print(const PrintSettings& settings, int indent) const = 0; virtual std::string my_type() const = 0; @@ -100,7 +88,6 @@ struct Drawable { struct DrawNode : public Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -126,7 +113,6 @@ struct DrawableInlineArrayNode : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -140,7 +126,6 @@ struct DrawableTree : public Drawable {}; struct DrawableTreeUnknown : public DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -150,7 +135,6 @@ struct DrawableTreeUnknown : public DrawableTree { struct DrawableInlineArrayUnknown : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -190,7 +174,6 @@ struct EntityActor { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); }; @@ -201,7 +184,6 @@ struct DrawableActor : public Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override { return "drawable-actor"; } @@ -210,7 +192,6 @@ struct DrawableActor : public Drawable { struct DrawableTreeActor : public DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -241,7 +222,7 @@ struct CollideFragMesh { (unused uint8 :offset 31) ) */ - void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, DrawStats* stats); + void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts); std::string print(const PrintSettings& settings, int indent) const; u16 strip_data_len; @@ -257,7 +238,7 @@ struct CollideFragMesh { }; struct CollideFragment { - void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, DrawStats* stats); + void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts); std::string print(const PrintSettings& settings, int indent) const; Vector bsphere; CollideFragMesh mesh; @@ -266,7 +247,6 @@ struct CollideFragment { struct DrawableInlineArrayCollideFragment : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -279,7 +259,6 @@ struct DrawableInlineArrayCollideFragment : public DrawableInlineArray { struct DrawableTreeCollideFragment : public DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -297,14 +276,13 @@ struct TFragmentDebugData { bool has_debug_lines; std::string print(int indent) const; - void read_from_file(Ref ref, const decompiler::DecompilerTypeSystem& dts, DrawStats* stats); + void read_from_file(Ref ref, const decompiler::DecompilerTypeSystem& dts); }; // the "fragment" is just a collection of data that fits into the VU memory. struct TFragment : public Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override { return "tfragment"; } @@ -346,7 +324,6 @@ struct DrawableInlineArrayTFrag : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -357,7 +334,6 @@ struct DrawableInlineArrayTFrag : public DrawableInlineArray { struct DrawableTreeTfrag : public DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -417,7 +393,6 @@ struct DrawableTreeTfragWater : public DrawableTreeTfrag { struct TieFragment : public Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override { return "tie-fragment"; } @@ -448,7 +423,6 @@ struct TieFragment : public Drawable { struct InstanceTie : public Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override { return "instance-tie"; } @@ -470,7 +444,6 @@ struct InstanceTie : public Drawable { struct PrototypeTie : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -524,7 +497,6 @@ struct PrototypeBucketTie { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); std::string print(const PrintSettings& settings, int indent) const; }; @@ -539,7 +511,6 @@ struct PrototypeArrayTie { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); std::string print(const PrintSettings& settings, int indent) const; }; @@ -549,7 +520,6 @@ struct PrototypeArrayTie { struct ProxyPrototypeArrayTie { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); std::string print(const PrintSettings& settings, int indent) const; @@ -567,7 +537,6 @@ struct DrawableInlineArrayInstanceTie : public DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -577,7 +546,6 @@ struct DrawableInlineArrayInstanceTie : public DrawableInlineArray { struct DrawableTreeInstanceTie : public DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version) override; std::string print(const PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -599,7 +567,6 @@ namespace shrub_types { struct Shrubbery : public level_tools::Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "shrubbery"; } @@ -622,7 +589,6 @@ struct Shrubbery : public level_tools::Drawable { struct PrototypeShrubbery : public level_tools::DrawableInlineArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "prototype-shrubbery"; } @@ -638,7 +604,6 @@ struct Billboard {}; struct GenericShrubFragment : public level_tools::Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "generic-shrub-fragment"; } @@ -670,7 +635,6 @@ struct GenericShrubFragment : public level_tools::Drawable { struct PrototypeGenericShrub : public level_tools::Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "prototype-generic-shrub"; } @@ -709,7 +673,6 @@ struct PrototypeBucketShrub { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version); std::string print(const level_tools::PrintSettings& settings, int indent) const; }; @@ -722,7 +685,6 @@ struct PrototypeInlineArrayShrub { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version); std::string print(const level_tools::PrintSettings& settings, int indent) const; }; @@ -730,7 +692,6 @@ struct PrototypeInlineArrayShrub { struct PrototypeArrayShrubInfo { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version); std::string print(const level_tools::PrintSettings& settings, int indent) const; @@ -741,7 +702,6 @@ struct PrototypeArrayShrubInfo { struct InstanceShrubbery : public level_tools::Drawable { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "instance-shrubbery"; } @@ -766,7 +726,6 @@ struct DrawableInlineArrayInstanceShrub : public level_tools::DrawableInlineArra void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override { return "drawable-inline-array-instance-shrub"; } @@ -775,7 +734,6 @@ struct DrawableInlineArrayInstanceShrub : public level_tools::DrawableInlineArra struct DrawableTreeInstanceShrub : public level_tools::DrawableTree { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - level_tools::DrawStats* stats, GameVersion version) override; std::string print(const level_tools::PrintSettings& settings, int indent) const override; std::string my_type() const override; @@ -804,7 +762,6 @@ struct DrawableInlineArrayActor { std::vector drawable_actors; void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); }; @@ -814,10 +771,57 @@ struct CollideHash { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); }; +/* +((start-corner vector :inline :offset-assert 32) + (spheres (inline-array vector) :offset-assert 48) + (visids (pointer int16) :offset-assert 52) + (shaders (inline-array adgif-shader) :offset-assert 56) + (colors time-of-day-palette :offset-assert 60) + (montage uint32 :offset-assert 64) + (buckets-far (inline-array hfrag-bucket) :offset-assert 68) + (buckets-mid (inline-array hfrag-bucket) :offset-assert 72) + (buckets-near (inline-array hfrag-bucket) :offset-assert 76) + (verts (inline-array hfrag-vertex) :offset-assert 80) ;; wrong type? 8288 + (pat-array (pointer pat-surface) :offset-assert 84) + (pat-length uint16 :offset-assert 88) + (num-buckets-far uint16 :offset-assert 90) + (num-buckets-mid uint16 :offset-assert 92) + (num-buckets-near uint16 :offset-assert 94) + (size uint32 :offset 44 :score 1) + */ + +struct HFragmentMontage { + u16 table[16]; +}; + +struct HFragment { + void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts); + + static constexpr int kCornersPerEdge = 32; + static constexpr int kNumCorners = kCornersPerEdge * kCornersPerEdge; + + static constexpr int kVertsPerEdge = 512; + static constexpr int kNumVerts = 512 * 512; + + level_tools::Vector start_corner; // location of corner (0, 0) + std::vector spheres; // array of bspheres for each "corner" + std::vector vis_ids; // precomputed vis id for each "corner" + AdGifData shaders[3]; + TimeOfDayPalette colors; + HFragmentMontage montage[17]; + // buckets?? + std::vector verts; + // pat-array + // pat-length + u16 num_buckets_far = 0; + u16 num_buckets_mid = 0; + u16 num_buckets_near = 0; + u32 size = 0; +}; + //////////////////////////////// // Main Level Type (bsp-header) //////////////////////////////// @@ -829,7 +833,6 @@ struct DrawableTreeArray { void read_from_file(TypedRef ref, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version); std::string print(const PrintSettings& settings, int indent) const; @@ -864,6 +867,7 @@ struct BspHeader { // (visible-list-length int32 :offset-assert 36) s32 visible_list_length = -1; + s32 extra_vis_list_length = -1; // jak 2+ only // (drawable-trees drawable-tree-array :offset-assert 40) DrawableTreeArray drawable_tree_array; @@ -910,9 +914,11 @@ struct BspHeader { // jak 2 only CollideHash collide_hash; + // jak 3 only + std::optional hfrag; + void read_from_file(const decompiler::LinkedObjectFile& file, const decompiler::DecompilerTypeSystem& dts, - DrawStats* stats, GameVersion version, bool only_read_texture_remap = false); diff --git a/decompiler/level_extractor/extract_common.cpp b/decompiler/level_extractor/extract_common.cpp index 216127d2b..2f2455a94 100644 --- a/decompiler/level_extractor/extract_common.cpp +++ b/decompiler/level_extractor/extract_common.cpp @@ -2,6 +2,7 @@ #include +namespace decompiler { u32 clean_up_vertex_indices(std::vector& idx) { std::vector fixed; u32 num_tris = 0; @@ -43,4 +44,42 @@ u32 clean_up_vertex_indices(std::vector& idx) { idx = std::move(fixed); return num_tris; -} \ No newline at end of file +} + +// we want to absolutely minimize the number of time we have to "cross lanes" in AVX (meaning X +// component of one vector interacts with Y component of another). We can make this a lot better by +// taking groups of 4 time of day colors (each containing 8x RGBAs) and rearranging them with this +// pattern. We want to compute: +// [rgba][0][0] * weights[0] + [rgba][0][1] * weights[1] + [rgba][0][2]... + rgba[0][7] * weights[7] +// RGBA is already a vector of 4 components, but with AVX we have vectors with 32 bytes which fit +// 16 colors in them. + +// This makes each vector have: +// colors0 = [rgba][0][0], [rgba][1][0], [rgba][2][0], [rgba][3][0] +// colors1 = [rgba][0][1], [rgba][1][1], [rgba][2][1], [rgba][3][1] +// ... +// so we can basically add up the columns (multiplying by weights in between) +// and we'll end up with [final0, final1, final2, final3, final4] +tfrag3::PackedTimeOfDay pack_colors(const level_tools::TimeOfDayPalette& in) { + tfrag3::PackedTimeOfDay out; + out.color_count = (in.height + 3) & (~3); + out.data.resize(out.color_count * 8 * 4); + + // we're rearranging per 4 colors (groups of 32 * 4 = 128) + // color (lots of these) + // component (8 of these) + // channel (4 of these, rgba) + + for (u32 color = 0; color < in.height; color++) { + for (u32 palette = 0; palette < 8; palette++) { + for (u32 channel = 0; channel < 4; channel++) { + out.read(color, palette, channel) = + (in.colors[color * 8 + palette] >> (8 * channel)) & 0xff; + } + } + } + + return out; +} + +} // namespace decompiler \ No newline at end of file diff --git a/decompiler/level_extractor/extract_common.h b/decompiler/level_extractor/extract_common.h index c50030df5..f9b60c6e3 100644 --- a/decompiler/level_extractor/extract_common.h +++ b/decompiler/level_extractor/extract_common.h @@ -2,5 +2,11 @@ #include #include "common/common_types.h" +#include "common/custom_data/Tfrag3Data.h" -u32 clean_up_vertex_indices(std::vector& idx); \ No newline at end of file +#include "decompiler/level_extractor/BspHeader.h" + +namespace decompiler { +u32 clean_up_vertex_indices(std::vector& idx); +tfrag3::PackedTimeOfDay pack_colors(const level_tools::TimeOfDayPalette& in); +} // namespace decompiler diff --git a/decompiler/level_extractor/extract_hfrag.cpp b/decompiler/level_extractor/extract_hfrag.cpp new file mode 100644 index 000000000..16f4731f8 --- /dev/null +++ b/decompiler/level_extractor/extract_hfrag.cpp @@ -0,0 +1,205 @@ +#include "extract_hfrag.h" + +#include "decompiler/level_extractor/extract_common.h" + +namespace decompiler { + +constexpr int kCornersPerEdge = level_tools::HFragment::kCornersPerEdge; +constexpr int kVertsPerEdge = level_tools::HFragment::kVertsPerEdge; +constexpr int kVertsPerCorner = kVertsPerEdge / kCornersPerEdge; + +int vertex_xz_to_index(int vx, int vz) { + return vz * kVertsPerEdge + vx; +} + +int corner_xz_to_index(int x, int z) { + return z * kCornersPerEdge + x; +} + +void extract_hfrag(const level_tools::BspHeader& bsp, const TextureDB& tex_db, tfrag3::Level* out) { + ASSERT(bsp.hfrag.has_value()); + const auto& hfrag = bsp.hfrag.value(); + auto& hfrag_out = out->hfrag; + + hfrag_out.occlusion_offset = bsp.visible_list_length - bsp.extra_vis_list_length; + + // create corners + hfrag_out.buckets.resize(hfrag.num_buckets_near); + for (int cz = 0; cz < kCornersPerEdge; cz++) { + for (int cx = 0; cx < kCornersPerEdge; cx++) { + const int ci = corner_xz_to_index(cx, cz); + const int vi = vertex_xz_to_index(cx * kVertsPerCorner, cz * kVertsPerCorner); + + auto& corner_out = hfrag_out.corners.emplace_back(); + const auto& corner = hfrag.spheres.at(ci); + + for (int i = 0; i < 4; i++) { + corner_out.bsphere[i] = corner.data[i]; + } + corner_out.vis_id = hfrag.vis_ids.at(ci); + const u32 v_data = hfrag.verts.at(vi); + const u16 v_packed = v_data >> 16; + const u16 bucket = v_packed >> 11; + hfrag_out.buckets.at(bucket).corners.push_back(ci); + } + } + + // create vertices and indices + // loop over each corner + for (int cz = 0; cz < kCornersPerEdge; cz++) { + const int vz_corner_base = cz * kVertsPerCorner; + for (int cx = 0; cx < kCornersPerEdge; cx++) { + const int vx_corner_base = cx * kVertsPerCorner; + const int ci = corner_xz_to_index(cx, cz); + auto& corner = hfrag_out.corners.at(ci); + corner.index_start = hfrag_out.indices.size(); + + // loop over quad rows which have lower vertex in vz + for (int vz_offset = 0; vz_offset < kVertsPerCorner; vz_offset++) { + const int vz = vz_corner_base + vz_offset; + // loop over quads which have lower vertex in vx, vz + for (int vx_offset = 0; vx_offset < kVertsPerCorner; vx_offset++) { + const int vx = vx_corner_base + vx_offset; + + // skip out of bound quads + if (vx + 1 < kVertsPerEdge && vz + 1 < kVertsPerEdge) { + corner.num_tris += 2; + for (int qx = 0; qx < 2; qx++) { + for (int qz = 0; qz < 2; qz++) { + hfrag_out.indices.push_back(hfrag_out.vertices.size()); + int vi = vertex_xz_to_index(vx + qx, vz + qz); + const u32 data = hfrag.verts.at(vi); + auto& vert = hfrag_out.vertices.emplace_back(); + vert.height = 8.f * (data & 0xffff); + vert.color_index = (data >> 16) & 0b111'1111'1111; + vert.u = qx; + vert.v = qz; + vert.vi = vi; + } + } + hfrag_out.indices.push_back(UINT32_MAX); + } + } + } + corner.index_length = hfrag_out.indices.size() - corner.index_start; + } + } + + for (int i = 0; i < 3; i++) { + ASSERT(hfrag.start_corner.data[i] == 0); + } + + // colors + hfrag_out.time_of_day_colors = pack_colors(hfrag.colors); + + // shaders + DrawMode mode; + mode.set_at(false); // I think this is just the default and hfrag doesn't set it + mode.set_ab(false); // see prim regs set up in hfrag-vu1 + mode.set_alpha_blend(DrawMode::AlphaBlend::SRC_SRC_SRC_SRC); // unused + mode.set_zt(true); // default ztest + mode.set_depth_test(GsTest::ZTest::GEQUAL); + mode.set_depth_write_enable(true); + mode.enable_fog(); + mode.set_decal(false); + mode.set_clamp_s_enable(true); + mode.set_clamp_t_enable(true); + + // adgif0 should be tex0 + const auto& shader = hfrag.shaders[2]; + ASSERT((u8)shader.tex0_addr == (u32)GsRegisterAddress::TEX0_1); + ASSERT(shader.tex0_data == 0); // no decal + // adgif1 should be tex1 + ASSERT((u8)shader.tex1_addr == (u32)GsRegisterAddress::TEX1_1); + u32 tpage = shader.tex1_addr >> 20; + u32 tidx = (shader.tex1_addr >> 8) & 0b1111'1111'1111; + u32 tex_combo = (((u32)tpage) << 16) | tidx; + auto tex = tex_db.textures.find(tex_combo); + ASSERT(tex != tex_db.textures.end()); + ASSERT(tex->second.name == "wang_0"); + ASSERT((u8)shader.mip_addr == (u32)GsRegisterAddress::MIPTBP1_1); + ASSERT((u8)shader.clamp_addr == (u32)GsRegisterAddress::CLAMP_1); + bool clamp_s = shader.clamp_data & 0b001; + bool clamp_t = shader.clamp_data & 0b100; + ASSERT(clamp_t && clamp_s); + ASSERT((u8)shader.alpha_addr == (u32)GsRegisterAddress::ALPHA_1); + GsAlpha reg(shader.alpha_data); + ASSERT(reg.a_mode() == GsAlpha::BlendMode::SOURCE && reg.b_mode() == GsAlpha::BlendMode::DEST && + reg.c_mode() == GsAlpha::BlendMode::SOURCE && reg.d_mode() == GsAlpha::BlendMode::DEST); + hfrag_out.draw_mode = mode; + + // find texture (hack, until we have texture animations) + u32 idx_in_lev_data = UINT32_MAX; + for (u32 i = 0; i < out->textures.size(); i++) { + if (out->textures[i].combo_id == tex_combo) { + idx_in_lev_data = i; + break; + } + } + ASSERT(idx_in_lev_data != UINT32_MAX); + hfrag_out.wang_tree_tex_id[0] = idx_in_lev_data; + hfrag_out.wang_tree_tex_id[1] = -1; + hfrag_out.wang_tree_tex_id[2] = -1; + hfrag_out.wang_tree_tex_id[3] = -1; + + // montage table + for (int bi = 0; bi < 17; bi++) { + for (int mi = 0; mi < 16; mi++) { + // the game stores this as a memory offset, but we convert to an index for convenience. + u32 montage_mem_offset = hfrag.montage[bi].table[mi]; + ASSERT((montage_mem_offset & 31) == 0); + hfrag_out.buckets.at(bi).montage_table.at(mi) = montage_mem_offset / 32; + } + } + + // std::string result = fmt::format( + // "ply\nformat ascii 1.0\nelement vertex {}\nproperty float x\nproperty float y\nproperty + // " "float z\nproperty uchar red\nproperty uchar green\nproperty uchar blue\nelement face + // " + // "{}\nproperty list uchar int vertex_index\nend_header\n", + // kVertsPerEdge * kVertsPerEdge, 2 * (kVertsPerEdge - 1) * (kVertsPerEdge - 1)); + // + // // build vertices + // for (int vz = 0; vz < kVertsPerEdge; vz++) { + // for (int vx = 0; vx < kVertsPerEdge; vx++) { + // // total size is 524288 * 32 + // + // const int v_idx = vertex_xz_to_index(vx, vz); + // const u32 v_data = hfrag.verts.at(v_idx); + // const u16 v_height_u16 = v_data & 0xffff; + // const int cx = vx / kVertsPerCorner; + // const int cz = vz / kVertsPerCorner; + // const int c_idx = corner_xz_to_index(cx, cz); + // const int bucket_v_idx = vertex_xz_to_index(cx * kVertsPerCorner, cz * kVertsPerCorner); + // const u32 cv_data = hfrag.verts.at(bucket_v_idx); + // + // // const float height_offset = hfrag. + // const float v_height = ((float)v_height_u16) * 8; + // const u16 cv_packed = cv_data >> 16; + // const u16 bucket = cv_packed >> 11; + // const u16 bucket_color = bucket * 10; + // if (cx * kVertsPerCorner == vx && cz * kVertsPerCorner == vz) { + // printf("bucket %d\n", bucket); + // } + // + // math::Vector3f v(vx * kVertSpacing, v_height, vz * kVertSpacing); + // result += fmt::format("{} {} {} {} {} {}\n", v.x() / 1024.f, v.y() / 1024.f, v.z() / + // 1024.f, + // bucket_color, 128, 128); + // } + // } + // + // for (int vz = 0; vz < kVertsPerEdge - 1; vz++) { + // for (int vx = 0; vx < kVertsPerEdge - 1; vx++) { + // result += fmt::format("3 {} {} {}\n", vertex_xz_to_index(vx, vz), + // vertex_xz_to_index(vx + 1, vz), vertex_xz_to_index(vx, vz + 1)); + // result += fmt::format("3 {} {} {}\n", vertex_xz_to_index(vx + 1, vz + 1), + // vertex_xz_to_index(vx, vz + 1), vertex_xz_to_index(vx + 1, vz)); + // } + // } + // + // auto file_path = file_util::get_file_path({"debug_out/hfrag", fmt::format("{}.ply", + // debug_name)}); file_util::create_dir_if_needed_for_file(file_path); + // file_util::write_text_file(file_path, result); +} +} // namespace decompiler \ No newline at end of file diff --git a/decompiler/level_extractor/extract_hfrag.h b/decompiler/level_extractor/extract_hfrag.h new file mode 100644 index 000000000..65f850288 --- /dev/null +++ b/decompiler/level_extractor/extract_hfrag.h @@ -0,0 +1,10 @@ +#pragma once + +#include "common/custom_data/Tfrag3Data.h" + +#include "decompiler/level_extractor/BspHeader.h" + +namespace decompiler { + +void extract_hfrag(const level_tools::BspHeader& bsp, const TextureDB& tex_db, tfrag3::Level* out); +} \ No newline at end of file diff --git a/decompiler/level_extractor/extract_level.cpp b/decompiler/level_extractor/extract_level.cpp index e209e6621..eab74d109 100644 --- a/decompiler/level_extractor/extract_level.cpp +++ b/decompiler/level_extractor/extract_level.cpp @@ -12,6 +12,7 @@ #include "decompiler/level_extractor/BspHeader.h" #include "decompiler/level_extractor/extract_actors.h" #include "decompiler/level_extractor/extract_collide_frags.h" +#include "decompiler/level_extractor/extract_hfrag.h" #include "decompiler/level_extractor/extract_joint_group.h" #include "decompiler/level_extractor/extract_merc.h" #include "decompiler/level_extractor/extract_shrub.h" @@ -150,9 +151,8 @@ std::vector extract_tex_remap(const ObjectFileDB& db, bool ok = is_valid_bsp(bsp_file.linked_data); ASSERT(ok); - level_tools::DrawStats draw_stats; level_tools::BspHeader bsp_header; - bsp_header.read_from_file(bsp_file.linked_data, db.dts, &draw_stats, db.version(), true); + bsp_header.read_from_file(bsp_file.linked_data, db.dts, db.version(), true); return bsp_header.texture_remap_table; } @@ -174,10 +174,8 @@ level_tools::BspHeader extract_bsp_from_level(const ObjectFileDB& db, bool ok = is_valid_bsp(bsp_file.linked_data); ASSERT(ok); - level_tools::DrawStats draw_stats; - // draw_stats.debug_print_dma_data = true; level_tools::BspHeader bsp_header; - bsp_header.read_from_file(bsp_file.linked_data, db.dts, &draw_stats, db.version()); + bsp_header.read_from_file(bsp_file.linked_data, db.dts, db.version()); ASSERT((int)bsp_header.drawable_tree_array.trees.size() == bsp_header.drawable_tree_array.length); // grrr..... @@ -257,6 +255,9 @@ level_tools::BspHeader extract_bsp_from_level(const ObjectFileDB& db, extract_collide_frags(bsp_header.collide_hash, all_ties, config, fmt::format("{}-{}-collide", dgo_name, i++), db.dts, level_data); } + if (bsp_header.hfrag) { + extract_hfrag(bsp_header, tex_db, &level_data); + } level_data.level_name = bsp_header.name; return bsp_header; diff --git a/decompiler/level_extractor/extract_shrub.cpp b/decompiler/level_extractor/extract_shrub.cpp index ae1ba210e..ec54718cf 100644 --- a/decompiler/level_extractor/extract_shrub.cpp +++ b/decompiler/level_extractor/extract_shrub.cpp @@ -601,13 +601,7 @@ void extract_shrub(const shrub_types::DrawableTreeInstanceShrub* tree, } // time of day colors - tree_out.time_of_day_colors.resize(tree->time_of_day.height); - for (int k = 0; k < (int)tree->time_of_day.height; k++) { - for (int j = 0; j < 8; j++) { - memcpy(tree_out.time_of_day_colors[k].rgba[j].data(), &tree->time_of_day.colors[k * 8 + j], - 4); - } - } + tree_out.time_of_day_colors = pack_colors(tree->time_of_day); make_draws(out, tree_out, proto_info, tex_db); diff --git a/decompiler/level_extractor/extract_tfrag.cpp b/decompiler/level_extractor/extract_tfrag.cpp index 995ecc42f..0949db9fc 100644 --- a/decompiler/level_extractor/extract_tfrag.cpp +++ b/decompiler/level_extractor/extract_tfrag.cpp @@ -8,6 +8,7 @@ #include "common/util/FileUtil.h" #include "decompiler/ObjectFile/LinkedObjectFile.h" +#include "decompiler/level_extractor/extract_common.h" #include "decompiler/util/Error.h" namespace decompiler { @@ -2164,12 +2165,7 @@ void emulate_tfrags(int geom, } void extract_time_of_day(const level_tools::DrawableTreeTfrag* tree, tfrag3::TfragTree& out) { - out.colors.resize(tree->time_of_day.height); - for (int i = 0; i < (int)tree->time_of_day.height; i++) { - for (int j = 0; j < 8; j++) { - memcpy(out.colors[i].rgba[j].data(), &tree->time_of_day.colors[i * 8 + j], 4); - } - } + out.colors = pack_colors(tree->time_of_day); } void merge_groups(std::vector& grps) { diff --git a/decompiler/level_extractor/extract_tie.cpp b/decompiler/level_extractor/extract_tie.cpp index 86995609f..1d0dc08b5 100644 --- a/decompiler/level_extractor/extract_tie.cpp +++ b/decompiler/level_extractor/extract_tie.cpp @@ -356,6 +356,10 @@ struct TieFrag { } prog_info; }; +struct TimeOfDayColor { + math::Vector rgba[8]; +}; + // main instance type // unlike the GOAL type, we store all instances info in here too. struct TieProtoInfo { @@ -364,8 +368,8 @@ struct TieProtoInfo { u32 proto_flag; float stiffness = 0; // wind std::optional envmap_adgif; - std::vector time_of_day_colors; // c++ type for time of day data - std::vector frags; // the fragments of the prototype + std::vector time_of_day_colors; // c++ type for time of day data + std::vector frags; // the fragments of the prototype }; /*! @@ -2094,7 +2098,7 @@ std::string dump_full_to_obj(const std::vector& protos) { // and this tells us an index in the time of day palette. struct BigPalette { - std::vector colors; + std::vector colors; }; // combine all individual time of day palettes into one giant one. @@ -2124,6 +2128,21 @@ BigPalette make_big_palette(std::vector& protos) { return result; } +tfrag3::PackedTimeOfDay pack_big_palette(const BigPalette& in) { + tfrag3::PackedTimeOfDay out; + out.color_count = (in.colors.size() + 3) & (~3); + out.data.resize(out.color_count * 8 * 4); + + for (u32 color = 0; color < in.colors.size(); color++) { + for (u32 palette = 0; palette < 8; palette++) { + for (u32 channel = 0; channel < 4; channel++) { + out.read(color, palette, channel) = in.colors.at(color).rgba[palette][channel]; + } + } + } + return out; +} + /*! * Given a current draw mode, update the alpha settings from a gs-alpha register value. */ @@ -2823,7 +2842,7 @@ void extract_tie(const level_tools::DrawableTreeInstanceTie* tree, merge_groups(this_tree.packed_vertices.matrix_groups); - this_tree.colors = full_palette.colors; + this_tree.colors = pack_big_palette(full_palette); out.tie_trees[geo].push_back(std::move(this_tree)); } } diff --git a/decompiler/level_extractor/fr3_to_gltf.cpp b/decompiler/level_extractor/fr3_to_gltf.cpp index 826c92cdd..73313df2e 100644 --- a/decompiler/level_extractor/fr3_to_gltf.cpp +++ b/decompiler/level_extractor/fr3_to_gltf.cpp @@ -246,9 +246,9 @@ int make_color_buffer_accessor(const std::vector& verti std::vector floats; for (size_t i = 0; i < vertices.size(); i++) { - auto& color = tfrag_tree.colors.at(vertices[i].color_index); for (int j = 0; j < 3; j++) { - floats.push_back(((float)color.rgba[time_of_day][j]) / 255.f); + floats.push_back(((float)tfrag_tree.colors.read(vertices[i].color_index, time_of_day, j)) / + 255.f); } floats.push_back(1.f); } @@ -289,9 +289,9 @@ int make_color_buffer_accessor(const std::vector& verti std::vector floats; for (size_t i = 0; i < vertices.size(); i++) { - auto& color = tie_tree.colors.at(vertices[i].color_index); for (int j = 0; j < 3; j++) { - floats.push_back(((float)color.rgba[time_of_day][j]) / 255.f); + floats.push_back(((float)tie_tree.colors.read(vertices[i].color_index, time_of_day, j)) / + 255.f); } floats.push_back(1.f); } @@ -368,9 +368,10 @@ int make_color_buffer_accessor(const std::vector& vertic std::vector floats; for (size_t i = 0; i < vertices.size(); i++) { - auto& color = shrub_tree.time_of_day_colors.at(vertices[i].color_index); for (int j = 0; j < 3; j++) { - floats.push_back(((float)color.rgba[time_of_day][j]) / 255.f); + floats.push_back( + ((float)shrub_tree.time_of_day_colors.read(vertices[i].color_index, time_of_day, j)) / + 255.f); } floats.push_back(1.f); } diff --git a/decompiler/util/data_decompile.cpp b/decompiler/util/data_decompile.cpp index 172ee7fb3..aca3d866e 100644 --- a/decompiler/util/data_decompile.cpp +++ b/decompiler/util/data_decompile.cpp @@ -1233,7 +1233,10 @@ goos::Object decompile_structure(const TypeSpec& type, auto len = field.array_size(); auto stride = ts.get_size_in_type(field) / len; ASSERT(stride == field_type_info->get_size_in_memory()); - + if (field.type() == TypeSpec("int128") || field.type() == TypeSpec("uint128")) { + lg::die("Trying to decompile field {} of {} as an array of type {} not supported", + field.name(), type_info->get_name(), field.type().print()); + } field_defs_out.emplace_back( field.name(), decompile_value_array(field.type(), field_type_info, len, stride, field_start, obj_words, ts)); diff --git a/docs/progress-notes/jak3/hfrag.md b/docs/progress-notes/jak3/hfrag.md new file mode 100644 index 000000000..36d184c42 --- /dev/null +++ b/docs/progress-notes/jak3/hfrag.md @@ -0,0 +1,6346 @@ +# C++ Plan + +- Write the extractor: + - giant mesh vertex data (position, color, texture coordinates per vertex) + - giant mesh index data (a chunk of indices per corner) + - list of buckets, each contains a list of corners in the bucket, and montage table + - Each corner has a vis ID for precomputed vis, bsphere for view frustum culling, and index group + - time-of-day colors + - Draw mode for textures (HACK: get the un-animated textures in here too, just for debug) + +- Write the loader + - load mesh and colors to GPU + +- Write the C++ renderer + - skip texture for now. + +- Write the GOAL renderer code (send camera data/visibility data to C++) + +- Debug! + +- Add textures (un-animated) + +# Vertex + +- hfragment +- buckets: collection of corners, likely using shared texture? +- "corners": smallest thing that can be processed by vertex generation asm +- "polyN": square grid of vertices, culled together + +# Far Vertices + +Vertex pos spacing is 32 +index0 = index1 = index2. + +5 chains + +always poly25's. +Each poly25 is a 5x5 grid of vertex indices. + +160x160 position units. + +Can optionally scissor. + +Taken if entire "corner" sphere is past far threshold. + +# Mid Vertices + +Vertex pos spacing is 16 +index0,1,2 different. + +9 chains + +(poly-mid25, far, if the sphere is in mid and far. No scissoring support.) +2x2 grid of poly25's. Each poly25 is a 5x5 grid of vertex indices. +160x160 position unit + +(poly-mid, far-mid, if the sphere is entirely mid. no scissoring.) +4x4 grid of poly9's. Each poly9 is a 3x3 grid of vertex indices. +192x192 position units + + +# Near Vertices + +Vertex pos spacing is 8. +index0,1,2 different. + +17 chains + +(poly-near, near-mid, if sphere is in mid and near, has scissoring support.) +8x8 grid of poly9's, each poly9 is a grid of 3x3 indices. +192x129 position units + +poly4 as well?? +"near" if sphere is in near. No scissoring option (always on?) + +# Poly4 +2x2 +12 quadword upload + +# Poly9 +3x3 +36 quadword upload + +# poly25 +5x5 +120 quadword upload + +# DMA generation asms + +- `near`, 31, 4326 lines +- `near-mid`, 30, 3274 +- `mid`, 29 +- `far-mid`, 28, 3244 line +- `far`, 27, 753 lines +- `far-scissor`, 18 +- `near-mid-scissor`, 21, 3628 lines + +# Montage Texture Coords + +16x8 grid texture. + +# VU1 program addresses + +- 0x06: scissor?? +- 0x0c: another init?? +- 0x20: abort +- 0x2c: init +- 0x2e: poly4-near +- 0x7d: poly25-far +- 0x7f: poly25-mid +- 0x14b: poly9-mid +- 0x14f: poly9-near + +# hfrag-vert-index +Metadata about a vertex? + +# Corners +32x32 grid +Each corner is 524288 apart (128 meters) + +# Draw table (in work) +Stores linked list (by index, not pointer) of chains per mode. + +Example: +`work.next-far-scissor` points to entry in draw-table for the first corner to be drawn with far scissor. Value in the draw table is the index of the next corner... eventually it's -1, and that's the end of the chain. + +# Drawing process +- `init-work-from-current-hfrag` + - maybe set lowres + - build corner array + - zero out work's next/count (next is set to -1) + - zero out hfragment static data bucket next/count (next is 0) +- `pick-level-of-detail` + - loop over all corners, check vis bit. + - do sphere cull to reject + - do guard-band-cull to set scissor + - subdiv-index bits: 8: back mid, 4: front mid, 2: back near, 1: front near + - build draw-table chains per rendering type +- `trim-draw-lists` + - remove stuff from draw table if too big +- `time-of-day-interp-colors-scratch` + +- `generate-dma` + - call asm stuff +- method 23 + - no idea +- `finalize-dma` + - shader asm stuff, finshing up buffers. + +# `asm-near` summary + +## Vertex 0 +`vt0` only + +## Vertex 1 +`weight * vt0 + (1 - weight) * 0.5 * (vt1 + vt2)` + +## Vertex 2 +`vt0` only + +## Vertex 3 +`weight * vt0 + (1 - weight) * 0.5 * (vt1 + vt2)` + +## Vertex 4 +`weight * vt0 + (1 - weight) * 0.5 * (vt1 + vt2)` + +## Vertex 5 +`weight * vt0 + (1 - weight) * 0.5 * (vt1 + vt2)` + +## Vertex 6 +`vt0` only + +## Vertex 7 +`weight * vt0 + (1 - weight) * 0.5 * (vt1 + vt2)` + +## Vertex 8 +`vt0` only + +# DMA from spr order (within a poly9) +0: 16 byte header +16: c0's pos (xyzw) +32: c0, c3, c1, c4 (pos'ys as floats) +48: 16 byte gap +64: c0, c3, c1, c4 (colors as u8's packed) + + +# poly9 orders + +;; 0 1 2 | 0 1 2 +;; 3 4 5 | 3 4 5 +;; 6 7 8 | 6 7 8 + +(0, 3, 1, 4) +(1, 4, 2, 5) +(3, 6, 4, 7) +(4, 7, 5, 8) + + +First poly9 is special (no shared verts w/ prev) +Then 6 shared poly9's + +0 +1 +2 +3 +4 +5 +6 + +# Texture Stuff + +```lisp +(defmethod login ((this hfragment)) + "Initialize the object after it is loaded." + (dotimes (s5-0 3) + (adgif-shader-login (-> this shaders s5-0)) + (if (> s5-0 0) + (set! (-> this shaders s5-0 tex0 tcc) 0) + ) + (set! (-> this shaders 1 tex0 cbp) 3904) + (set! (-> this shaders 2 tex0 cbp) 3904) + ) + this + ) +``` + +# Method 23 near texture data summary: + +- `work.frame-tmpl`: 4 a+d data setup +- `work.frames[0]`: a+d for frame (hard-coded fbp), scissor 0x7f, xyoffset 0, test (no zbuf, always pass) +- `work.adgif-tmpl`: usual adgif direct template +- `hfrag.shaders[2]`: the whole thing. + +Loop over montage (16x?) +- `hfrag.sprite-tmpl`: 2 qw (template rgba, st, xyz, st, xyz) +- `colors[0] = 0x80, 0x80, 0x80, 0x80` +- `montage-tex-coords[montage[m]].st0` +- `near-data[2 * m]` +- `montage-tex-coords[montage[m]].st1` +- `near-data[2 * m + 1]` + +- `work.frame-tmpl` +- `work.frames[1]`: half size frame, seems like the MIP data + + +# C++ version of texture stuff: + +```c++ +struct Bucket { + std::vector corners; + u16 montage_table[16]; +}; +``` + +# `asm-near` + +``` +L15: + daddiu sp, sp, -64 + sd ra, 0(sp) + sq s4, 16(sp) + sq s5, 32(sp) + sq gp, 48(sp) + +a0 hfrag-work +a1 dma-buffer +a2 draw-table chain + +B0: + sll r0, r0, 0 + lw v1, 4(a1) ;; v1 = dma-buffer.base + sll r0, r0, 0 + sw a1, 8148(a0) ;; stash dma-buffer in work + lui t0, 4096 ;; 0x1000???? + lui t1, 4096 + sync.l ;; cache stuff + cache dxwbin v1, 0 + sync.l + cache dxwbin v1, 1 + sync.l + lui a3, 28672 ;; a3 = scratchpad memory 0x7000'0000 + daddiu v1, a0, 512 ;; v1 = work.near-chaina + daddiu t3, a0, 800 ;; t3 = work.near-chainb + ori t0, t0, 54272 ;; t0 = 0x1000'd400 (SPR-TO DMA) + ori t2, t1, 53248 ;; t2 = 0x1000'd000 (SPR-FROM DMA) + or t1, a3, r0 ;; t1 = scratchpad memory (input bank buffer) + sw v1, 8180(a0) ;; work.chain-ptr-next = work.near-chaina + vmaxw.xyzw vf11, vf0, vf0 ;; vf11 = [1, 1, 1, 1] + sw t3, 8176(a0) ;; work.chain-ptr = work.near-chainb + lw t3, 4(a1) ;; t3 = dma-buffer.base + ori v1, a3, 2720 ;; v1 = spad.outa + addiu a1, r0, 0 ;; a1 = 0 + sw t0, 8192(a0) ;; stash to-spr (ctrl reg) + or t0, v1, r0 ;; t0 = spad.outa + sw t2, 8196(a0) ;; stash from-spr (ctrl reg) + sll r0, r0, 0 + sw t3, 8152(a0) ;; stash base + sll r0, r0, 0 + lqc2 vf20, 7840(a0) ;; stq.vectors[0] = [1, 0, 0, 0] + sll r0, r0, 0 + lqc2 vf21, 7872(a0) ;; stq.vectors[2] = [0x1001, 0, 0, 0] + sll r0, r0, 0 + lqc2 vf22, 7936(a0) ;; stq.vectors[6] = [0x1000, 0, 0, 0] + sll r0, r0, 0 + lqc2 vf23, 7968(a0) ;; stq.vectors[8] = [0x1000, 0x1000, 0, 0] + lui t2, 8192 ;; t2 = 0x2000'???? + lw t3, 8176(a0) ;; t3 = work.chain-ptr + andi t6, a2, 31 ;; t6 = corner_idx[0] (maybe x?) idx = 32 * z + x + lw t4, 8288(a0) ;; t4 = work.frag.verts + sra t5, a2, 5 ;; t5 = corner_idx[1] (maybe z?) + sll t6, t6, 6 ;; t6 = cx * 64 + sll t5, t5, 15 ;; t5 = cz * 32768 ??? + daddu t4, t6, t4 + or t2, t3, t2 ;; uncached chain ptr. + daddu t3, t4, t5 + + ;; loop over gi's, upload 5qw + + ;; vertex data + + ;; verts is a 512x512 grid of 4-byte vertices. + ;; vx,vz -> vx + vz * 512 -> (vx * 4 + vz * 2048) + + ;; a "corner" is a 16x16 tile of vertices (there are 32x32 corners) + ;; cx,cz -> v(cx * 16, cz * 16) -> (cx * 64 + cz * 32768) + + ;; DMA chain to scratchpad to load vertices + ;; vx_start = cx * 16 + ;; vz_start = cz * 16 + ;; for vz in range(vz_start, vz_start + 17): + ;; for vx in range(vx_start, vx_start + 20): + ;; vi = vx + 512 * vz + ;; vaddr = vi * 4 + ;; get_vertex(vaddr) + + ;; to draw a corner, you need 1 vertex past the end in z and x + + ;; patching near-chain addresses for each line of vertices + sw t3, 4(t2) + daddiu t3, t3, 2048 + sw t3, 20(t2) + daddiu t3, t3, 2048 + sw t3, 36(t2) + daddiu t3, t3, 2048 + sw t3, 52(t2) + daddiu t3, t3, 2048 + sw t3, 68(t2) + daddiu t3, t3, 2048 + sw t3, 84(t2) + daddiu t3, t3, 2048 + sw t3, 100(t2) + daddiu t3, t3, 2048 + sw t3, 116(t2) + daddiu t3, t3, 2048 + sw t3, 132(t2) + daddiu t3, t3, 2048 + sw t3, 148(t2) + daddiu t3, t3, 2048 + sw t3, 164(t2) + daddiu t3, t3, 2048 + sw t3, 180(t2) + daddiu t3, t3, 2048 + sw t3, 196(t2) + daddiu t3, t3, 2048 + sw t3, 212(t2) + daddiu t3, t3, 2048 + sw t3, 228(t2) + daddiu t3, t3, 2048 + sw t3, 244(t2) + daddiu t3, t3, 2048 + sw t3, 260(t2) + + sll r0, r0, 0 + lw t2, 8192(a0) ;; to-spr + sll r0, r0, 0 + +;; wait for to-spr transfer to finish +B1: +L16: + lw t3, 0(t2) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t3, t3, 256 + sll r0, r0, 0 + beq t3, r0, L17 + sll r0, r0, 0 + +B2: + sll r0, r0, 0 + lw t3, 8156(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t3, t3, 1 + sll r0, r0, 0 + sw t3, 8156(a0) + beq r0, r0, L16 + sll r0, r0, 0 + +B3: +L17: + sll r0, r0, 0 + lw t3, 8176(a0) ;; t3 = chain-ptr (to-spr vertex gather) + sll r0, r0, 0 + lw t4, 8180(a0) ;; t4 = chain-ptr-next + sll r0, r0, 0 + sw t3, 8180(a0) ;; swap chain-ptr to chan-ptr-next + sll r0, r0, 0 + sw t4, 8176(a0) ;; swap chain-ptr-next to chain-ptr + sw t1, 128(t2) ;; set spad addr + sll r0, r0, 0 + sw t3, 48(t2) ;; set chain ptr + sll r0, r0, 0 + sw r0, 32(t2) ;; other control stuf + addiu t3, r0, 260 + sw t3, 0(t2) ;; run DMA to spr! + xori t1, t1, 1360 ;; toggling bank ptr buffer (next spad upload addr) + sll r0, r0, 0 + or a2, a2, r0 ;; a2 still draw-table index + +;; loop over corners +B4: +L18: + dsll t2, a2, 1 ;; int16's + sll r0, r0, 0 + daddu t2, t2, a0 ;; idx * 2 + hfrag_work + dsll t3, a2, 4 ;; corner_index * 16 + bltz a2, L21 ;; check if draw index is negative, if so don't start next one. + lh a2, 8456(t2) ;; load next draw + +B5: + lui t2, 8192 + lw t4, 8176(a0) ;; t4 = chain-ptr + andi t7, a2, 31 + lw t5, 8288(a0) ;; t5 - verts + sra t6, a2, 5 + sll t7, t7, 6 + sll t6, t6, 15 + daddu t5, t7, t5 + or t2, t4, t2 + daddu t4, t5, t6 + + ;; patch the chain + sw t4, 4(t2) + daddiu t4, t4, 2048 + sw t4, 20(t2) + daddiu t4, t4, 2048 + sw t4, 36(t2) + daddiu t4, t4, 2048 + sw t4, 52(t2) + daddiu t4, t4, 2048 + sw t4, 68(t2) + daddiu t4, t4, 2048 + sw t4, 84(t2) + daddiu t4, t4, 2048 + sw t4, 100(t2) + daddiu t4, t4, 2048 + sw t4, 116(t2) + daddiu t4, t4, 2048 + sw t4, 132(t2) + daddiu t4, t4, 2048 + sw t4, 148(t2) + daddiu t4, t4, 2048 + sw t4, 164(t2) + daddiu t4, t4, 2048 + sw t4, 180(t2) + daddiu t4, t4, 2048 + sw t4, 196(t2) + daddiu t4, t4, 2048 + sw t4, 212(t2) + daddiu t4, t4, 2048 + sw t4, 228(t2) + daddiu t4, t4, 2048 + sw t4, 244(t2) + daddiu t4, t4, 2048 + sw t4, 260(t2) + sll r0, r0, 0 + + ;; wait for spr to to be free + lw t2, 8192(a0) + sll r0, r0, 0 +B6: +L19: + lw t4, 0(t2) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t4, t4, 256 + sll r0, r0, 0 + beq t4, r0, L20 + sll r0, r0, 0 + +B7: + sll r0, r0, 0 + lw t4, 8156(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t4, t4, 1 + sll r0, r0, 0 + sw t4, 8156(a0) + beq r0, r0, L19 + sll r0, r0, 0 + +B8: +L20: + sll r0, r0, 0 ;; swap chain-ptrs + lw t4, 8176(a0) + sll r0, r0, 0 + lw t5, 8180(a0) + sll r0, r0, 0 + sw t4, 8180(a0) + sll r0, r0, 0 + sw t5, 8176(a0) + sw t1, 128(t2) ;; start next vetex gather dma + sll r0, r0, 0 + sw t4, 48(t2) + sll r0, r0, 0 + sw r0, 32(t2) + addiu t4, r0, 260 + sw t4, 0(t2) + xori t1, t1, 1360 ;; swap spad input bank ptr + beq r0, r0, L23 + sll r0, r0, 0 + ;; end next vertex gather dma setup. + +;; wait for spad to to complete if we're doing the last one. +B9: +L21: + lw t2, 8192(a0) + sll r0, r0, 0 +B10: +L22: + lw t4, 0(t2) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t4, t4, 256 + sll r0, r0, 0 + beq t4, r0, L23 + sll r0, r0, 0 + +B11: + sll r0, r0, 0 + lw t4, 8156(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t4, t4, 1 + sll r0, r0, 0 + sw t4, 8156(a0) + beq r0, r0, L22 + sll r0, r0, 0 + +;; assume we have input data in spad +B12: +L23: + addiu t2, r0, 6 ;; t2 = 6 + lhu t4, 2(t1) ;; t4 = vertex[0,0].packed-index + daddu t5, t3, a0 ;; preparing to index into work.corners + lw t3, 8384(a0) ;; t3 = work.poly-near + dsra t4, t4, 11 ;; t4 = bit11 (unsigned) + lqc2 vf15, 10512(t5) ;; vf15 = work.corners[this_corner] + beq t4, r0, L52 ;; skip entirely if bit11.16 is 0 + sll r0, r0, 0 + +B13: + daddiu t4, a1, -171 ;; t4 = a1 (0) - 171 + sll r0, r0, 0 + blez t4, L26 + sll r0, r0, 0 + +B14: + lw t4, 8196(a0) + sll r0, r0, 0 +B15: +L24: ;; wait for from-spr to finish + lw t0, 0(t4) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t0, t0, 256 + sll r0, r0, 0 + beq t0, r0, L25 + sll r0, r0, 0 + +B16: + sll r0, r0, 0 + lw t0, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t0, t0, 1 + sll r0, r0, 0 + sw t0, 8160(a0) + beq r0, r0, L24 + sll r0, r0, 0 + +B17: +L25: ;; swapping from-spr buffer + lw t0, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t4) + xori v1, v1, 4720 + sw t0, 16(t4) + sll t5, a1, 4 + addu t5, t0, t5 + or t0, v1, r0 + sw a1, 32(t4) + addiu a1, r0, 256 + sw a1, 0(t4) + addiu a1, r0, 0 + sw t5, 8152(a0) + sll r0, r0, 0 +B18: + +;; start of actual vertex procssing. +L26: + daddiu t4, a3, 9984 ;; t4 = hfrag-cache-line + addiu t5, r0, 6 ;; t5 = 6 + sll r0, r0, 0 +;; Vertex 0 + lhu t6, 2(t3) ;; t6 = p9[0].index0 + sll r0, r0, 0 + lhu t7, 0(t3) ;; t7 = p9[0].pos (packed u8's) + daddu t6, t6, t1 ;; t6 = gathered_verts[p9[0].index0] (index0 has the shift applied) + sll r0, r0, 0 + pextlb t8, r0, t7 ;; expanding the pos (u8's to u16's) + lhu t7, 2(t6) ;; t7 = t6(the vertex).packed-index + pextlh t8, r0, t8 ;; expanding the pos (u32's) -> [pos.x, pos.y, 0, 0] + lhu t6, 0(t6) ;; t6 = t6(the vertex).height + dsll t8, t8, 12 ;; t8 -> pos to meters (multiply by 4096) + andi t7, t7, 2047 ;; extract first 11 bits of packed-index + pexcw t8, t8 ;; t8 = [pos.x * 2048, 0, pos.y * 2048, 0] + mfc1 r0, f31 + dsll t7, t7, 2 ;; t7 = vert.packed-index.first11 * 4 + qmtc2.i vf1, t8 ;; vf1 = pos + daddu t7, t7, a3 ;; t7 = spad + 4 * packed-index.first11 + sll t6, t6, 3 ;; t6 = height is multiplied by 8 + vitof0.xyzw vf1, vf1 ;; vf1 pos to float + mtc1 f0, t6 ;; f0 = t6 height to fpr + sll r0, r0, 0 + lw t6, 12288(t7) ;; load colors! + cvt.s.w f0, f0 ;; height to float + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 ;; vf1 += works.corners[this_corner] + sll r0, r0, 0 + pextlb t6, r0, t6 ;; colors expand to u16 + mfc1 r0, f31 + pextlh t6, r0, t6 ;; colors expand to u32 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 0(t4) ;; stash colors in hfrag-cache-vertex[0] + sll r0, r0, 0 + sqc2 vf1, 16(t4) ;; stash pos in hfrag-cache-vertex[0] + sll r0, r0, 0 + swc1 f0, 20(t4) ;; stash y component (height) in hfrag-cache-vertex[0] + sll r0, r0, 0 + lqc2 vf1, 16(t4) ;; load pos, now containing the height + + ;; camera projection of the vertex + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 ;; multiply for clipping check + sll r0, r0, 0 + vclip.xyz vf1, vf1 ;; check if in view... + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping ;; check clipping result + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 ;; mask clip flag for this clip + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 28(t4) ;; stash clip result for later + sll r0, r0, 0 + +;; Vertex 1 + lhu t6, 10(t3) ;; t6 = p9[1].index0 + sll r0, r0, 0 + lhu t8, 12(t3) ;; t8 = p9[1].index1 + daddu t7, t6, t1 ;; t7 = verts[p9[1].index0] vt0 + lhu t6, 14(t3) ;; t6 = p9[1].index2 + daddu t8, t8, t1 ;; t8 = verts[p9[1].index1] vt1 + lhu t9, 8(t3) ;; t9 = pos + daddu t6, t6, t1 ;; t6 = verts[p9[1].index2] vt2 + lhu ra, 2(t7) ;; ra = vt0.packed-index + pextlb t9, r0, t9 ;; pos to u16's + lhu t7, 0(t7) ;; t7 = vt0.height + pextlh t9, r0, t9 ;; pos to u32's + lhu gp, 2(t8) ;; gp = vt1.packed-index + dsll t9, t9, 12 ;; pos *= 4096 + lhu t8, 0(t8) ;; t8 = vt1.height + pexcw t9, t9 ;; move pos.y to pos.z + lhu s5, 2(t6) ;; s5 = vt2.packed-index + andi ra, ra, 2047 ;; mask packed index to get color indices + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 ;; shift to load 32-bit rgba's from colors + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 ;; color addr + lhu t6, 0(t6) ;; t6 = vt2.height + sll s5, t7, 3 ;; mult height by 8 + lw t7, 12288(s4) ;; t7 = vt0's color + daddu gp, gp, a3 ;; color addr + sq t9, 8080(a0) ;; stash pos in work + sll t8, t8, 3 ;; mult height by 8 + lw t9, 12288(gp) ;; t9 = vt1's color + daddu ra, ra, a3 ;; color addr + sw s5, 8084(a0) ;; store vt0.height * 8 in pos-temp.y + sll t6, t6, 3 ;; mult height by 8 + lw ra, 12288(ra) ;; ra = vt2's color + pextlb t7, r0, t7 ;; color to u16's + lqc2 vf1, 8080(a0) ;; vf1 = load pos-temp with [px_i, vt0.h * 8, pz_i, 0] + pextlh t7, r0, t7 ;; color to u32's + sw t8, 8084(a0) ;; store vt1's height in pos-temp + pextlb t8, r0, t9 ;; color u16's + qmtc2.i vf4, t7 ;; vf4 = vt0's color + pextlh t7, r0, t8 ;; t7 = vt1's color + lqc2 vf2, 8080(a0) ;; vf2 = pos-temp with [px_i, vt1.h * 8, pz_i, 0] + pextlb t8, r0, ra ;; color to u16's + qmtc2.i vf5, t7 ;; vf5 = vt1's color + pextlh t7, r0, t8 ;; vt2's color to u32's + sw t6, 8084(a0) ;; store vt2's height in pos-temp + vitof0.xyzw vf4, vf4 ;; vf4 = vt0's color as float + qmtc2.i vf6, t7 ;; vf6 = vt2's color + vitof0.xyzw vf5, vf5 ;; vf5 = vt1's color as float + lqc2 vf3, 8080(a0) ;; vf3 = vt2 pos temp + + ;; vf1,vf2,vf3 - positions; vf4,vf5,vf6 - colors; + ;; convert all to floats + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 ;; vf5 = vt1.col + vt2.col + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 ;; vf1 = vt0.pos + [cx, 0, cz] < world position of vt0 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 ;; acc = cam-pos + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 ;; vf2 = vt1.pos + vt2.pos + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 ;; vf5 = 0.5*(vt1.col + vt2.col) + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 ;; camera-rot multiplication... + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 ;; camera-rot multiplication... + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 ;; vf7 = pos_vt0_rt_camera + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 ;; vf2 = 0.5*(vt1.pos + vt2.pos) + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 ;; vf6 = vt0.col - 0.5*(vt1.col + vt2.col) + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 ;; vf7 = depth-rt-cam + dists + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 ;; vf3 = corner + vt0.pos - 0.5*(vt1.pos + vt2.pos) + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 ;; vf3.w = 1 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 ;; vf7 = (depth-rt-cam + dists)*rdists + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 ;; clamp dists within 0 to 1 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 ;; clamp dists within 0 to 1 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 ;; acc = 0.5*(vt1.col + vt2.col) + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 ;; vf4 = 0.5*(vt1.col + vt2.col) + weight * (vt0.col - 0.5*(vt1.col + vt2.col)) + ;; vf4 = weight * vt0 + (1 - weight) * 0.5 * (vt1.col + vt2.col) + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 ;; colors back to int + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 32(t4) ;; store in cache vertex 1 + sll r0, r0, 0 + sqc2 vf1, 48(t4) ;; pos + sll r0, r0, 0 + lqc2 vf1, 48(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 60(t4) ;; store clip + sll r0, r0, 0 + +;; Vertex 2 + lhu t6, 18(t3) ;; p9[2].index0 + sll r0, r0, 0 + lhu t7, 16(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 64(t4) ;; store in vertex 2 of cache + sll r0, r0, 0 + sqc2 vf1, 80(t4) + sll r0, r0, 0 + swc1 f0, 84(t4) + sll r0, r0, 0 + lqc2 vf1, 80(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 92(t4) + sll r0, r0, 0 + +# Vertex 3 + lhu t6, 26(t3) + sll r0, r0, 0 + lhu t8, 28(t3) + daddu t7, t6, t1 + lhu t6, 30(t3) + daddu t8, t8, t1 + lhu t9, 24(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 96(t4) + sll r0, r0, 0 + sqc2 vf1, 112(t4) + sll r0, r0, 0 + lqc2 vf1, 112(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 124(t4) + sll r0, r0, 0 + +# Vertex 4 + lhu t6, 34(t3) + sll r0, r0, 0 + lhu t8, 36(t3) + daddu t7, t6, t1 + lhu t6, 38(t3) + daddu t8, t8, t1 + lhu t9, 32(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 128(t4) + sll r0, r0, 0 + sqc2 vf1, 144(t4) + sll r0, r0, 0 + lqc2 vf1, 144(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 156(t4) + sll r0, r0, 0 + +# Vertex 5 + lhu t6, 42(t3) + sll r0, r0, 0 + lhu t8, 44(t3) + daddu t7, t6, t1 + lhu t6, 46(t3) + daddu t8, t8, t1 + lhu t9, 40(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 160(t4) + sll r0, r0, 0 + sqc2 vf1, 176(t4) + sll r0, r0, 0 + lqc2 vf1, 176(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 188(t4) + sll r0, r0, 0 + + # Vertex 6 + lhu t6, 50(t3) + sll r0, r0, 0 + lhu t7, 48(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 192(t4) + sll r0, r0, 0 + sqc2 vf1, 208(t4) + sll r0, r0, 0 + swc1 f0, 212(t4) + sll r0, r0, 0 + lqc2 vf1, 208(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 220(t4) + sll r0, r0, 0 + + # vertex 7 + lhu t6, 58(t3) + sll r0, r0, 0 + lhu t8, 60(t3) + daddu t7, t6, t1 + lhu t6, 62(t3) + daddu t8, t8, t1 + lhu t9, 56(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 224(t4) + sll r0, r0, 0 + sqc2 vf1, 240(t4) + sll r0, r0, 0 + lqc2 vf1, 240(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 252(t4) + sll r0, r0, 0 + + # Vertex 8 + lhu t6, 66(t3) + sll r0, r0, 0 + lhu t7, 64(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 256(t4) + sll r0, r0, 0 + sqc2 vf1, 272(t4) + sll r0, r0, 0 + swc1 f0, 276(t4) + sll r0, r0, 0 + lqc2 vf1, 272(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 284(t4) + + bgezal r0, L39 + sll r0, r0, 0 + +B19: + daddiu t3, t3, 72 ;; onto the next poly9 + daddiu t4, t4, 288 ;; onto next cache line +B20: +L27: + daddiu t6, a1, -171 + sll r0, r0, 0 + blez t6, L30 ;; maybe dma sync + sll r0, r0, 0 + +B21: + lw t6, 8196(a0) + sll r0, r0, 0 +B22: +L28: + lw t0, 0(t6) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t0, t0, 256 + sll r0, r0, 0 + beq t0, r0, L29 + sll r0, r0, 0 + +B23: + sll r0, r0, 0 + lw t0, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t0, t0, 1 + sll r0, r0, 0 + sw t0, 8160(a0) + beq r0, r0, L28 + sll r0, r0, 0 + +B24: +L29: + lw t0, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t6) + xori v1, v1, 4720 + sw t0, 16(t6) + sll t7, a1, 4 + addu t7, t0, t7 + or t0, v1, r0 + sw a1, 32(t6) + addiu a1, r0, 256 + sw a1, 0(t6) + addiu a1, r0, 0 + sw t7, 8152(a0) + sll r0, r0, 0 +B25: +L30: +;; copying shared vertices in cache + sll r0, r0, 0 + lq t6, -96(t4) + sll r0, r0, 0 + lqc2 vf2, -80(t4) + sll r0, r0, 0 + sq t6, 0(t4) + sll r0, r0, 0 + sqc2 vf2, 16(t4) + sll r0, r0, 0 + lq t6, -64(t4) + sll r0, r0, 0 + lqc2 vf2, -48(t4) + sll r0, r0, 0 + sq t6, 32(t4) + sll r0, r0, 0 + sqc2 vf2, 48(t4) + sll r0, r0, 0 + lq t6, -32(t4) + sll r0, r0, 0 + lqc2 vf2, -16(t4) + sll r0, r0, 0 + sq t6, 64(t4) + sll r0, r0, 0 + sqc2 vf2, 80(t4) + sll r0, r0, 0 + + ;; another vertex processing + ;; vertex 0 + lhu t6, 26(t3) + sll r0, r0, 0 + lhu t8, 28(t3) + daddu t7, t6, t1 + lhu t6, 30(t3) + daddu t8, t8, t1 + lhu t9, 24(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 96(t4) + sll r0, r0, 0 + sqc2 vf1, 112(t4) + sll r0, r0, 0 + lqc2 vf1, 112(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 124(t4) + sll r0, r0, 0 + + # Vertex 1 + lhu t6, 34(t3) + sll r0, r0, 0 + lhu t8, 36(t3) + daddu t7, t6, t1 + lhu t6, 38(t3) + daddu t8, t8, t1 + lhu t9, 32(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 128(t4) + sll r0, r0, 0 + sqc2 vf1, 144(t4) + sll r0, r0, 0 + lqc2 vf1, 144(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 156(t4) + sll r0, r0, 0 + +;; vertex 2 + lhu t6, 42(t3) + sll r0, r0, 0 + lhu t8, 44(t3) + daddu t7, t6, t1 + lhu t6, 46(t3) + daddu t8, t8, t1 + lhu t9, 40(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 160(t4) + sll r0, r0, 0 + sqc2 vf1, 176(t4) + sll r0, r0, 0 + lqc2 vf1, 176(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 188(t4) + sll r0, r0, 0 + + ;; vertex 3 + lhu t6, 50(t3) + sll r0, r0, 0 + lhu t7, 48(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 192(t4) + sll r0, r0, 0 + sqc2 vf1, 208(t4) + sll r0, r0, 0 + swc1 f0, 212(t4) + sll r0, r0, 0 + lqc2 vf1, 208(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 220(t4) + sll r0, r0, 0 + + ;; vertex 4 + lhu t6, 58(t3) + sll r0, r0, 0 + lhu t8, 60(t3) + daddu t7, t6, t1 + lhu t6, 62(t3) + daddu t8, t8, t1 + lhu t9, 56(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 224(t4) + sll r0, r0, 0 + sqc2 vf1, 240(t4) + sll r0, r0, 0 + lqc2 vf1, 240(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 252(t4) + sll r0, r0, 0 + + ;; vertex 5 + lhu t6, 66(t3) + sll r0, r0, 0 + lhu t7, 64(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 256(t4) + sll r0, r0, 0 + sqc2 vf1, 272(t4) + sll r0, r0, 0 + swc1 f0, 276(t4) + sll r0, r0, 0 + lqc2 vf1, 272(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 284(t4) + bgezal r0, L39 + sll r0, r0, 0 + +B26: + daddiu t3, t3, 72 + daddiu t4, t4, 288 + bgtz t5, L27 ;; loop over 6 'inner' poly9's + daddiu t5, t5, -1 + +B27: +L31: + daddiu t4, a1, -171 + sll r0, r0, 0 + blez t4, L34 ;; optional dma sync + sll r0, r0, 0 + +B28: + lw t4, 8196(a0) + sll r0, r0, 0 +B29: +L32: + lw t0, 0(t4) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t0, t0, 256 + sll r0, r0, 0 + beq t0, r0, L33 + sll r0, r0, 0 + +B30: + sll r0, r0, 0 + lw t0, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t0, t0, 1 + sll r0, r0, 0 + sw t0, 8160(a0) + beq r0, r0, L32 + sll r0, r0, 0 + +B31: +L33: + lw t0, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t4) + xori v1, v1, 4720 + sw t0, 16(t4) + sll t5, a1, 4 + addu t5, t0, t5 + or t0, v1, r0 + sw a1, 32(t4) + addiu a1, r0, 256 + sw a1, 0(t4) + addiu a1, r0, 0 + sw t5, 8152(a0) + sll r0, r0, 0 +B32: +L34: ;; last poly9 in the row?? + daddiu t4, a3, 9984 ;; reset cache to the beginning + addiu t5, r0, 6 + sll r0, r0, 0 + lq t6, 64(t4) ;; swap 2 -> 0 + sll r0, r0, 0 + lqc2 vf2, 80(t4) + sll r0, r0, 0 + sq t6, 0(t4) + sll r0, r0, 0 + sqc2 vf2, 16(t4) + sll r0, r0, 0 + +;; vertex 1 + lhu t6, 10(t3) + sll r0, r0, 0 + lhu t8, 12(t3) + daddu t7, t6, t1 + lhu t6, 14(t3) + daddu t8, t8, t1 + lhu t9, 8(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 32(t4) + sll r0, r0, 0 + sqc2 vf1, 48(t4) + sll r0, r0, 0 + lqc2 vf1, 48(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 60(t4) + sll r0, r0, 0 + +;; vertex 2 + lhu t6, 18(t3) + sll r0, r0, 0 + lhu t7, 16(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 64(t4) + sll r0, r0, 0 + sqc2 vf1, 80(t4) + sll r0, r0, 0 + swc1 f0, 84(t4) + sll r0, r0, 0 + lqc2 vf1, 80(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 92(t4) + +;; copy cached vertex 5 -> 3 + sll r0, r0, 0 + lq t6, 160(t4) + sll r0, r0, 0 + lqc2 vf2, 176(t4) + sll r0, r0, 0 + sq t6, 96(t4) + sll r0, r0, 0 + sqc2 vf2, 112(t4) + sll r0, r0, 0 + +;; vertex 4 + lhu t6, 34(t3) + sll r0, r0, 0 + lhu t8, 36(t3) + daddu t7, t6, t1 + lhu t6, 38(t3) + daddu t8, t8, t1 + lhu t9, 32(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 128(t4) + sll r0, r0, 0 + sqc2 vf1, 144(t4) + sll r0, r0, 0 + lqc2 vf1, 144(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 156(t4) + sll r0, r0, 0 + + ;; vertex 5 + lhu t6, 42(t3) + sll r0, r0, 0 + lhu t8, 44(t3) + daddu t7, t6, t1 + lhu t6, 46(t3) + daddu t8, t8, t1 + lhu t9, 40(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 160(t4) + sll r0, r0, 0 + sqc2 vf1, 176(t4) + sll r0, r0, 0 + lqc2 vf1, 176(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 188(t4) + sll r0, r0, 0 + + ;; copy 8 -> 6 + lq t6, 256(t4) + sll r0, r0, 0 + lqc2 vf2, 272(t4) + sll r0, r0, 0 + sq t6, 192(t4) + sll r0, r0, 0 + sqc2 vf2, 208(t4) + sll r0, r0, 0 + +;; vertex 7 + lhu t6, 58(t3) + sll r0, r0, 0 + lhu t8, 60(t3) + daddu t7, t6, t1 + lhu t6, 62(t3) + daddu t8, t8, t1 + lhu t9, 56(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 224(t4) + sll r0, r0, 0 + sqc2 vf1, 240(t4) + sll r0, r0, 0 + lqc2 vf1, 240(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 252(t4) + sll r0, r0, 0 + + ;; vertex 8 + lhu t6, 66(t3) + sll r0, r0, 0 + lhu t7, 64(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 256(t4) + sll r0, r0, 0 + sqc2 vf1, 272(t4) + sll r0, r0, 0 + swc1 f0, 276(t4) + sll r0, r0, 0 + lqc2 vf1, 272(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 284(t4) + bgezal r0, L39 + sll r0, r0, 0 + +B33: + daddiu t3, t3, 72 ;; advance cache and poly table + daddiu t4, t4, 288 +B34: +L35: + daddiu t6, a1, -171 + sll r0, r0, 0 + blez t6, L38 ;; maybe dma sync + sll r0, r0, 0 + +B35: + lw t6, 8196(a0) + sll r0, r0, 0 +B36: +L36: + lw t0, 0(t6) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t0, t0, 256 + sll r0, r0, 0 + beq t0, r0, L37 + sll r0, r0, 0 + +B37: + sll r0, r0, 0 + lw t0, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t0, t0, 1 + sll r0, r0, 0 + sw t0, 8160(a0) + beq r0, r0, L36 + sll r0, r0, 0 + +B38: +L37: + lw t0, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t6) + xori v1, v1, 4720 + sw t0, 16(t6) + sll t7, a1, 4 + addu t7, t0, t7 + or t0, v1, r0 + sw a1, 32(t6) + addiu a1, r0, 256 + sw a1, 0(t6) + addiu a1, r0, 0 + sw t7, 8152(a0) + sll r0, r0, 0 +B39: +L38: ;; cache copy "down" + sll r0, r0, 0 + lq t6, -96(t4) + sll r0, r0, 0 + lqc2 vf2, -80(t4) + sll r0, r0, 0 + sq t6, 0(t4) + sll r0, r0, 0 + sqc2 vf2, 16(t4) + sll r0, r0, 0 + lq t6, -64(t4) + sll r0, r0, 0 + lqc2 vf2, -48(t4) + sll r0, r0, 0 + sq t6, 32(t4) + sll r0, r0, 0 + sqc2 vf2, 48(t4) + sll r0, r0, 0 + lq t6, -32(t4) + sll r0, r0, 0 + lqc2 vf2, -16(t4) + sll r0, r0, 0 + sq t6, 64(t4) + sll r0, r0, 0 + sqc2 vf2, 80(t4) + sll r0, r0, 0 + lq t6, 160(t4) + sll r0, r0, 0 + lqc2 vf2, 176(t4) + sll r0, r0, 0 + sq t6, 96(t4) + sll r0, r0, 0 + sqc2 vf2, 112(t4) + sll r0, r0, 0 + lhu t6, 34(t3) + sll r0, r0, 0 + + ;; inner 0 + lhu t8, 36(t3) + daddu t7, t6, t1 + lhu t6, 38(t3) + daddu t8, t8, t1 + lhu t9, 32(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 128(t4) + sll r0, r0, 0 + sqc2 vf1, 144(t4) + sll r0, r0, 0 + lqc2 vf1, 144(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 156(t4) + sll r0, r0, 0 + +;; inner 1 + lhu t6, 42(t3) + sll r0, r0, 0 + lhu t8, 44(t3) + daddu t7, t6, t1 + lhu t6, 46(t3) + daddu t8, t8, t1 + lhu t9, 40(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 160(t4) + sll r0, r0, 0 + sqc2 vf1, 176(t4) + sll r0, r0, 0 + lqc2 vf1, 176(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 188(t4) + sll r0, r0, 0 + + lq t6, 256(t4) + sll r0, r0, 0 + lqc2 vf2, 272(t4) + sll r0, r0, 0 + sq t6, 192(t4) + sll r0, r0, 0 + sqc2 vf2, 208(t4) + sll r0, r0, 0 + + ;; inner 2 + lhu t6, 58(t3) + sll r0, r0, 0 + lhu t8, 60(t3) + daddu t7, t6, t1 + lhu t6, 62(t3) + daddu t8, t8, t1 + lhu t9, 56(t3) + daddu t6, t6, t1 + lhu ra, 2(t7) + pextlb t9, r0, t9 + lhu t7, 0(t7) + pextlh t9, r0, t9 + lhu gp, 2(t8) + dsll t9, t9, 12 + lhu t8, 0(t8) + pexcw t9, t9 + lhu s5, 2(t6) + andi ra, ra, 2047 + andi gp, gp, 2047 + andi s5, s5, 2047 + dsll s4, ra, 2 + dsll gp, gp, 2 + dsll ra, s5, 2 + daddu s4, s4, a3 + lhu t6, 0(t6) + sll s5, t7, 3 + lw t7, 12288(s4) + daddu gp, gp, a3 + sq t9, 8080(a0) + sll t8, t8, 3 + lw t9, 12288(gp) + daddu ra, ra, a3 + sw s5, 8084(a0) + sll t6, t6, 3 + lw ra, 12288(ra) + pextlb t7, r0, t7 + lqc2 vf1, 8080(a0) + pextlh t7, r0, t7 + sw t8, 8084(a0) + pextlb t8, r0, t9 + qmtc2.i vf4, t7 + pextlh t7, r0, t8 + lqc2 vf2, 8080(a0) + pextlb t8, r0, ra + qmtc2.i vf5, t7 + pextlh t7, r0, t8 + sw t6, 8084(a0) + vitof0.xyzw vf4, vf4 + qmtc2.i vf6, t7 + vitof0.xyzw vf5, vf5 + lqc2 vf3, 8080(a0) + vitof0.xyzw vf6, vf6 + sll r0, r0, 0 + vitof0.xyzw vf1, vf1 + sll r0, r0, 0 + vitof0.xyzw vf2, vf2 + sll r0, r0, 0 + vitof0.xyzw vf3, vf3 + sll r0, r0, 0 + vadd.xyzw vf5, vf5, vf6 + sll r0, r0, 0 + vadd.xz vf1, vf1, vf15 + sll r0, r0, 0 + vmulaw.xyzw acc, vf27, vf0 + sll r0, r0, 0 + vadd.xyzw vf2, vf2, vf3 + sll r0, r0, 0 + vmulx.xyzw vf5, vf5, vf28 + sll r0, r0, 0 + vmaddax.xyzw acc, vf24, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf25, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf7, vf26, vf1 + sll r0, r0, 0 + vmulx.xyzw vf2, vf2, vf28 + sll r0, r0, 0 + vsub.xyzw vf6, vf4, vf5 + sll r0, r0, 0 + vaddz.xyzw vf7, vf13, vf7 + sll r0, r0, 0 + vsub.xyz vf3, vf1, vf2 + sll r0, r0, 0 + vmulw.w vf3, vf0, vf0 + sll r0, r0, 0 + vmul.xyzw vf7, vf7, vf14 + sll r0, r0, 0 + vmini.xyzw vf7, vf7, vf11 + sll r0, r0, 0 + vmaxx.xyzw vf7, vf7, vf0 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf5 + sll r0, r0, 0 + vmaddy.xyzw vf4, vf6, vf7 + sll r0, r0, 0 + vmula.xyzw acc, vf11, vf2 + sll r0, r0, 0 + vmaddy.yw vf1, vf3, vf7 + sll r0, r0, 0 + vftoi0.xyzw vf4, vf4 + sll r0, r0, 0 + sll r0, r0, 0 + sqc2 vf4, 224(t4) + sll r0, r0, 0 + sqc2 vf1, 240(t4) + sll r0, r0, 0 + lqc2 vf1, 240(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 252(t4) + sll r0, r0, 0 + + + lhu t6, 66(t3) + sll r0, r0, 0 + lhu t7, 64(t3) + daddu t6, t6, t1 + sll r0, r0, 0 + pextlb t8, r0, t7 + lhu t7, 2(t6) + pextlh t8, r0, t8 + lhu t6, 0(t6) + dsll t8, t8, 12 + andi t7, t7, 2047 + pexcw t8, t8 + mfc1 r0, f31 + dsll t7, t7, 2 + qmtc2.i vf1, t8 + daddu t7, t7, a3 + sll t6, t6, 3 + vitof0.xyzw vf1, vf1 + mtc1 f0, t6 + sll r0, r0, 0 + lw t6, 12288(t7) + cvt.s.w f0, f0 + sll r0, r0, 0 + vadd.xyzw vf1, vf1, vf15 + sll r0, r0, 0 + pextlb t6, r0, t6 + mfc1 r0, f31 + pextlh t6, r0, t6 + mfc1 r0, f31 + sll r0, r0, 0 + sq t6, 256(t4) + sll r0, r0, 0 + sqc2 vf1, 272(t4) + sll r0, r0, 0 + swc1 f0, 276(t4) + sll r0, r0, 0 + lqc2 vf1, 272(t4) + vmulaw.xyzw acc, vf19, vf0 + sll r0, r0, 0 + vmaddax.xyzw acc, vf16, vf1 + sll r0, r0, 0 + vmadday.xyzw acc, vf17, vf1 + sll r0, r0, 0 + vmaddz.xyzw vf1, vf18, vf1 + sll r0, r0, 0 + vmul.xyzw vf1, vf1, vf31 + sll r0, r0, 0 + vclip.xyz vf1, vf1 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + cfc2.i t6, Clipping + sll r0, r0, 0 + sll r0, r0, 0 + andi t6, t6, 47 + sll r0, r0, 0 + sll r0, r0, 0 + sw t6, 284(t4) + bgezal r0, L39 + sll r0, r0, 0 + +B40: + daddiu t3, t3, 72 + daddiu t4, t4, 288 + bgtz t5, L35 + daddiu t5, t5, -1 + +B41: + bgtz t2, L31 + daddiu t2, t2, -1 + +B42: + beq r0, r0, L52 + sll r0, r0, 0 + +B43: +L39: + ;;;;;;; subroutine + ;; t4 = hfrag-cache + ;; t3 = p9 + ;; t1 = gathered verts (spad input buffer) + ;; t0 = output buffer on spad + ;; a0 = work + sll r0, r0, 0 + lw t6, 28(t4) ;; cv0.clip + sll r0, r0, 0 + lw t7, 124(t4) ;; cv6.clip + sll r0, r0, 0 + lw t8, 60(t4) ;; cv6.clip + sll r0, r0, 0 + lw t9, 156(t4) ;; cv8.clip + and gp, t6, t7 + and s5, t8, t9 + and gp, gp, s5 + or t8, t8, t9 + bne gp, r0, L41 + or t6, t6, t7 + +B44: + or t7, t6, t8 + lq t6, 0(t4) ;; t6 = cv0.col + bne t7, r0, L40 + lq t7, 96(t4) ;; t7 = cv3.col + +B45: + sll r0, r0, 0 + lq t9, 32(t4) ;; t9 = cv1.col + sll r0, r0, 0 + lq t8, 128(t4) ;; t8 = cv4.col + ppach t6, r0, t6 ;; cv0.col u16's + lwc1 f0, 20(t4) ;; f0 = cv0.posy + ppach t7, r0, t7 ;; cv3.col u16's + lwc1 f1, 116(t4) ;; f1 = cv3.posy + ppach t9, r0, t9 ;; t9 = cv1.col u16's + lwc1 f2, 52(t4) ;; f2 = cv1.height + ppach t8, r0, t8 ;; col to u8's + lwc1 f3, 148(t4) ;; f3 = cv4's height + ppacb t6, r0, t6 ;; cv0.col u8's + swc1 f0, 32(t0) + ppacb t7, r0, t7 ;; cv3.col u8's + swc1 f1, 36(t0) + ppacb t9, r0, t9 + swc1 f2, 40(t0) + ppacb t8, r0, t8 + swc1 f3, 44(t0) + sll r0, r0, 0 + sw t6, 64(t0) ;; writing colors 0 + sll r0, r0, 0 + sw t7, 68(t0) ;; writing colors 3 + sll r0, r0, 0 + sw t9, 72(t0) ;; colors 1 + sll r0, r0, 0 + sw t8, 76(t0) ;; colors 4 + sll r0, r0, 0 + + lhu t7, 2(t3) ;; p9[0].index0 + sll r0, r0, 0 + lw t6, 8284(a0) ;; buckets-near + daddu t7, t7, t1 ;; t7 = gathered_verts[p9[0].index0] + lw t8, 8152(a0) ;; t8 = dma-buffer base. + sll r0, r0, 0 + lhu t7, 2(t7) ;; t7 = t7.packed-index + dsra t7, t7, 11 ;; t7 = upperbit11 + lqc2 vf1, 16(t4) ;; vf1 is the whole position + sll r0, r0, 0 + dsll t7, t7, 4 ;; multiply by 16 to get the right bucket + daddu t7, t6, t7 ;; hfrag-bucket pointer + sqc2 vf1, 16(t0) ;; store output corner + sll r0, r0, 0 + lh t9, 6(t7) ;; vtx count + sll r0, r0, 0 + lw t6, 0(t7) ;; next pointer + dsll s5, a1, 4 + lh gp, 4(t7) ;; count + daddu s5, s5, t8 ;; dma dest stuff... + sw t6, 1700(a0) ;; dma next stuff + daddu t8, t9, a0 + sw s5, 0(t7) ;; update bucket + daddiu gp, gp, 1 ;; inc count + daddiu s5, t9, -16 + addiu t9, r0, 32 + sh gp, 4(t7) + movz s5, t9, s5 ;; dma crap + lq t9, 1696(a0) + sll r0, r0, 0 + sh s5, 6(t7) + sll r0, r0, 0 + lq gp, 1728(a0) + sll r0, r0, 0 + lq t7, 1392(t8) + movz t9, gp, t6 + lq t6, 1424(t8) + sll r0, r0, 0 + sq t7, 0(t0) + sll r0, r0, 0 + sq t6, 48(t0) + daddiu a1, a1, 6 + sq t9, 80(t0) + beq r0, r0, L42 + daddiu t0, t0, 96 + +B46: +L40: + sll r0, r0, 0 + lq t8, 32(t4) + sll r0, r0, 0 + lq t9, 128(t4) + sq t6, 32(t0) + sll r0, r0, 0 + sq t7, 80(t0) + sll r0, r0, 0 + sq t8, 128(t0) + sll r0, r0, 0 + sq t9, 176(t0) + sll r0, r0, 0 + sll r0, r0, 0 + lhu t7, 2(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lqc2 vf2, 16(t4) + sll r0, r0, 0 + lhu t7, 2(t7) + sll r0, r0, 0 + lqc2 vf3, 112(t4) + dsra t7, t7, 11 + lw t9, 8152(a0) + dsll t7, t7, 4 + sll r0, r0, 0 + daddu t6, t6, t7 + lqc2 vf4, 48(t4) + sll r0, r0, 0 + lh t8, 14(t6) + sll r0, r0, 0 + lw t7, 8(t6) + dsll s5, a1, 4 + lh gp, 12(t6) + daddu s5, s5, t9 + sw t7, 1748(a0) + daddu t9, t8, a0 + sw s5, 8(t6) + daddiu gp, gp, 1 + lq t9, 1072(t9) + daddiu t8, t8, -16 + sh gp, 12(t6) + addiu gp, r0, 48 + lq s5, 1744(a0) + sll r0, r0, 0 + lq s4, 1760(a0) + movz t8, gp, t8 + sq t9, 0(t0) + movz s5, s4, t7 + sh t8, 14(t6) + sll r0, r0, 0 + sq s5, 208(t0) + sll r0, r0, 0 + lqc2 vf5, 144(t4) + sqc2 vf2, 48(t0) + sll r0, r0, 0 + sqc2 vf20, 16(t0) + sll r0, r0, 0 + sqc2 vf3, 96(t0) + sll r0, r0, 0 + sqc2 vf21, 64(t0) + sll r0, r0, 0 + sqc2 vf4, 144(t0) + sll r0, r0, 0 + sqc2 vf22, 112(t0) + sll r0, r0, 0 + sqc2 vf5, 192(t0) + daddiu a1, a1, 14 + sqc2 vf23, 160(t0) + daddiu t0, t0, 224 + beq r0, r0, L42 + sll r0, r0, 0 + +B47: +L41: + sll r0, r0, 0 + sll r0, r0, 0 +B48: +L42: + sll r0, r0, 0 + lw t6, 60(t4) ;; 1 + sll r0, r0, 0 + lw t7, 156(t4) ;; 4 + sll r0, r0, 0 + lw t8, 92(t4) ;; 2 + sll r0, r0, 0 + lw t9, 188(t4) ;; 5 + and gp, t6, t7 + and s5, t8, t9 + and gp, gp, s5 + or t8, t8, t9 + bne gp, r0, L44 + or t6, t6, t7 + +B49: + or t7, t6, t8 + lq t6, 32(t4) + bne t7, r0, L43 + lq t7, 128(t4) + +B50: + sll r0, r0, 0 + lq t9, 64(t4) + sll r0, r0, 0 + lq t8, 160(t4) + ppach t6, r0, t6 + lwc1 f0, 52(t4) + ppach t7, r0, t7 + lwc1 f1, 148(t4) + ppach t9, r0, t9 + lwc1 f2, 84(t4) + ppach t8, r0, t8 + lwc1 f3, 180(t4) + ppacb t6, r0, t6 + swc1 f0, 32(t0) + ppacb t7, r0, t7 + swc1 f1, 36(t0) + ppacb t9, r0, t9 + swc1 f2, 40(t0) + ppacb t8, r0, t8 + swc1 f3, 44(t0) + sll r0, r0, 0 + sw t6, 64(t0) + sll r0, r0, 0 + sw t7, 68(t0) + sll r0, r0, 0 + sw t9, 72(t0) + sll r0, r0, 0 + sw t8, 76(t0) + sll r0, r0, 0 + lhu t7, 10(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lw t8, 8152(a0) + sll r0, r0, 0 + lhu t7, 2(t7) + dsra t7, t7, 11 + lqc2 vf1, 48(t4) + sll r0, r0, 0 + dsll t7, t7, 4 + daddu t7, t6, t7 + sqc2 vf1, 16(t0) + sll r0, r0, 0 + lh t9, 6(t7) + sll r0, r0, 0 + lw t6, 0(t7) + dsll s5, a1, 4 + lh gp, 4(t7) + daddu s5, s5, t8 + sw t6, 1700(a0) + daddu t8, t9, a0 + sw s5, 0(t7) + daddiu gp, gp, 1 + daddiu s5, t9, -16 + addiu t9, r0, 32 + sh gp, 4(t7) + movz s5, t9, s5 + lq t9, 1696(a0) + sll r0, r0, 0 + sh s5, 6(t7) + sll r0, r0, 0 + lq gp, 1728(a0) + sll r0, r0, 0 + lq t7, 1392(t8) + movz t9, gp, t6 + lq t6, 1424(t8) + sll r0, r0, 0 + sq t7, 0(t0) + sll r0, r0, 0 + sq t6, 48(t0) + daddiu a1, a1, 6 + sq t9, 80(t0) + beq r0, r0, L45 + daddiu t0, t0, 96 + +B51: +L43: + sll r0, r0, 0 + lq t8, 64(t4) + sll r0, r0, 0 + lq t9, 160(t4) + sq t6, 32(t0) + sll r0, r0, 0 + sq t7, 80(t0) + sll r0, r0, 0 + sq t8, 128(t0) + sll r0, r0, 0 + sq t9, 176(t0) + sll r0, r0, 0 + sll r0, r0, 0 + lhu t7, 10(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lqc2 vf2, 48(t4) + sll r0, r0, 0 + lhu t7, 2(t7) + sll r0, r0, 0 + lqc2 vf3, 144(t4) + dsra t7, t7, 11 + lw t9, 8152(a0) + dsll t7, t7, 4 + sll r0, r0, 0 + daddu t6, t6, t7 + lqc2 vf4, 80(t4) + sll r0, r0, 0 + lh t8, 14(t6) + sll r0, r0, 0 + lw t7, 8(t6) + dsll s5, a1, 4 + lh gp, 12(t6) + daddu s5, s5, t9 + sw t7, 1748(a0) + daddu t9, t8, a0 + sw s5, 8(t6) + daddiu gp, gp, 1 + lq t9, 1072(t9) + daddiu t8, t8, -16 + sh gp, 12(t6) + addiu gp, r0, 48 + lq s5, 1744(a0) + sll r0, r0, 0 + lq s4, 1760(a0) + movz t8, gp, t8 + sq t9, 0(t0) + movz s5, s4, t7 + sh t8, 14(t6) + sll r0, r0, 0 + sq s5, 208(t0) + sll r0, r0, 0 + lqc2 vf5, 176(t4) + sqc2 vf2, 48(t0) + sll r0, r0, 0 + sqc2 vf20, 16(t0) + sll r0, r0, 0 + sqc2 vf3, 96(t0) + sll r0, r0, 0 + sqc2 vf21, 64(t0) + sll r0, r0, 0 + sqc2 vf4, 144(t0) + sll r0, r0, 0 + sqc2 vf22, 112(t0) + sll r0, r0, 0 + sqc2 vf5, 192(t0) + daddiu a1, a1, 14 + sqc2 vf23, 160(t0) + daddiu t0, t0, 224 + beq r0, r0, L45 + sll r0, r0, 0 + +B52: +L44: + sll r0, r0, 0 + sll r0, r0, 0 +B53: +L45: + sll r0, r0, 0 + lw t6, 124(t4) + sll r0, r0, 0 + lw t7, 220(t4) + sll r0, r0, 0 + lw t8, 156(t4) + sll r0, r0, 0 + lw t9, 252(t4) + and gp, t6, t7 + and s5, t8, t9 + and gp, gp, s5 + or t8, t8, t9 + bne gp, r0, L47 + or t6, t6, t7 + +B54: + or t7, t6, t8 + lq t6, 96(t4) + bne t7, r0, L46 + lq t7, 192(t4) + +B55: + sll r0, r0, 0 + lq t9, 128(t4) + sll r0, r0, 0 + lq t8, 224(t4) + ppach t6, r0, t6 + lwc1 f0, 116(t4) + ppach t7, r0, t7 + lwc1 f1, 212(t4) + ppach t9, r0, t9 + lwc1 f2, 148(t4) + ppach t8, r0, t8 + lwc1 f3, 244(t4) + ppacb t6, r0, t6 + swc1 f0, 32(t0) + ppacb t7, r0, t7 + swc1 f1, 36(t0) + ppacb t9, r0, t9 + swc1 f2, 40(t0) + ppacb t8, r0, t8 + swc1 f3, 44(t0) + sll r0, r0, 0 + sw t6, 64(t0) + sll r0, r0, 0 + sw t7, 68(t0) + sll r0, r0, 0 + sw t9, 72(t0) + sll r0, r0, 0 + sw t8, 76(t0) + sll r0, r0, 0 + lhu t7, 26(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lw t8, 8152(a0) + sll r0, r0, 0 + lhu t7, 2(t7) + dsra t7, t7, 11 + lqc2 vf1, 112(t4) + sll r0, r0, 0 + dsll t7, t7, 4 + daddu t7, t6, t7 + sqc2 vf1, 16(t0) + sll r0, r0, 0 + lh t9, 6(t7) + sll r0, r0, 0 + lw t6, 0(t7) + dsll s5, a1, 4 + lh gp, 4(t7) + daddu s5, s5, t8 + sw t6, 1700(a0) + daddu t8, t9, a0 + sw s5, 0(t7) + daddiu gp, gp, 1 + daddiu s5, t9, -16 + addiu t9, r0, 32 + sh gp, 4(t7) + movz s5, t9, s5 + lq t9, 1696(a0) + sll r0, r0, 0 + sh s5, 6(t7) + sll r0, r0, 0 + lq gp, 1728(a0) + sll r0, r0, 0 + lq t7, 1392(t8) + movz t9, gp, t6 + lq t6, 1424(t8) + sll r0, r0, 0 + sq t7, 0(t0) + sll r0, r0, 0 + sq t6, 48(t0) + daddiu a1, a1, 6 + sq t9, 80(t0) + beq r0, r0, L48 + daddiu t0, t0, 96 + +B56: +L46: + sll r0, r0, 0 + lq t8, 128(t4) + sll r0, r0, 0 + lq t9, 224(t4) + sq t6, 32(t0) + sll r0, r0, 0 + sq t7, 80(t0) + sll r0, r0, 0 + sq t8, 128(t0) + sll r0, r0, 0 + sq t9, 176(t0) + sll r0, r0, 0 + sll r0, r0, 0 + lhu t7, 26(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lqc2 vf2, 112(t4) + sll r0, r0, 0 + lhu t7, 2(t7) + sll r0, r0, 0 + lqc2 vf3, 208(t4) + dsra t7, t7, 11 + lw t9, 8152(a0) + dsll t7, t7, 4 + sll r0, r0, 0 + daddu t6, t6, t7 + lqc2 vf4, 144(t4) + sll r0, r0, 0 + lh t8, 14(t6) + sll r0, r0, 0 + lw t7, 8(t6) + dsll s5, a1, 4 + lh gp, 12(t6) + daddu s5, s5, t9 + sw t7, 1748(a0) + daddu t9, t8, a0 + sw s5, 8(t6) + daddiu gp, gp, 1 + lq t9, 1072(t9) + daddiu t8, t8, -16 + sh gp, 12(t6) + addiu gp, r0, 48 + lq s5, 1744(a0) + sll r0, r0, 0 + lq s4, 1760(a0) + movz t8, gp, t8 + sq t9, 0(t0) + movz s5, s4, t7 + sh t8, 14(t6) + sll r0, r0, 0 + sq s5, 208(t0) + sll r0, r0, 0 + lqc2 vf5, 240(t4) + sqc2 vf2, 48(t0) + sll r0, r0, 0 + sqc2 vf20, 16(t0) + sll r0, r0, 0 + sqc2 vf3, 96(t0) + sll r0, r0, 0 + sqc2 vf21, 64(t0) + sll r0, r0, 0 + sqc2 vf4, 144(t0) + sll r0, r0, 0 + sqc2 vf22, 112(t0) + sll r0, r0, 0 + sqc2 vf5, 192(t0) + daddiu a1, a1, 14 + sqc2 vf23, 160(t0) + daddiu t0, t0, 224 + beq r0, r0, L48 + sll r0, r0, 0 + +B57: +L47: + sll r0, r0, 0 + sll r0, r0, 0 +B58: +L48: + sll r0, r0, 0 + lw t6, 156(t4) + sll r0, r0, 0 + lw t7, 252(t4) + sll r0, r0, 0 + lw t8, 188(t4) + sll r0, r0, 0 + lw t9, 284(t4) + and gp, t6, t7 + and s5, t8, t9 + and gp, gp, s5 + or t8, t8, t9 + bne gp, r0, L50 + or t6, t6, t7 + +B59: + or t7, t6, t8 + lq t6, 128(t4) + bne t7, r0, L49 + lq t7, 224(t4) + +B60: + sll r0, r0, 0 + lq t9, 160(t4) + sll r0, r0, 0 + lq t8, 256(t4) + ppach t6, r0, t6 + lwc1 f0, 148(t4) + ppach t7, r0, t7 + lwc1 f1, 244(t4) + ppach t9, r0, t9 + lwc1 f2, 180(t4) + ppach t8, r0, t8 + lwc1 f3, 276(t4) + ppacb t6, r0, t6 + swc1 f0, 32(t0) + ppacb t7, r0, t7 + swc1 f1, 36(t0) + ppacb t9, r0, t9 + swc1 f2, 40(t0) + ppacb t8, r0, t8 + swc1 f3, 44(t0) + sll r0, r0, 0 + sw t6, 64(t0) + sll r0, r0, 0 + sw t7, 68(t0) + sll r0, r0, 0 + sw t9, 72(t0) + sll r0, r0, 0 + sw t8, 76(t0) + sll r0, r0, 0 + lhu t7, 34(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lw t8, 8152(a0) + sll r0, r0, 0 + lhu t7, 2(t7) + dsra t7, t7, 11 + lqc2 vf1, 144(t4) + sll r0, r0, 0 + dsll t7, t7, 4 + daddu t7, t6, t7 + sqc2 vf1, 16(t0) + sll r0, r0, 0 + lh t9, 6(t7) + sll r0, r0, 0 + lw t6, 0(t7) + dsll s5, a1, 4 + lh gp, 4(t7) + daddu s5, s5, t8 + sw t6, 1700(a0) + daddu t8, t9, a0 + sw s5, 0(t7) + daddiu gp, gp, 1 + daddiu s5, t9, -16 + addiu t9, r0, 32 + sh gp, 4(t7) + movz s5, t9, s5 + lq t9, 1696(a0) + sll r0, r0, 0 + sh s5, 6(t7) + sll r0, r0, 0 + lq gp, 1728(a0) + sll r0, r0, 0 + lq t7, 1392(t8) + movz t9, gp, t6 + lq t6, 1424(t8) + sll r0, r0, 0 + sq t7, 0(t0) + sll r0, r0, 0 + sq t6, 48(t0) + daddiu a1, a1, 6 + sq t9, 80(t0) + beq r0, r0, L51 + daddiu t0, t0, 96 + +B61: +L49: + sll r0, r0, 0 + lq t8, 160(t4) + sll r0, r0, 0 + lq t9, 256(t4) + sq t6, 32(t0) + sll r0, r0, 0 + sq t7, 80(t0) + sll r0, r0, 0 + sq t8, 128(t0) + sll r0, r0, 0 + sq t9, 176(t0) + sll r0, r0, 0 + sll r0, r0, 0 + lhu t7, 34(t3) + sll r0, r0, 0 + lw t6, 8284(a0) + daddu t7, t7, t1 + lqc2 vf2, 144(t4) + sll r0, r0, 0 + lhu t7, 2(t7) + sll r0, r0, 0 + lqc2 vf3, 240(t4) + dsra t7, t7, 11 + lw t9, 8152(a0) + dsll t7, t7, 4 + sll r0, r0, 0 + daddu t6, t6, t7 + lqc2 vf4, 176(t4) + sll r0, r0, 0 + lh t8, 14(t6) + sll r0, r0, 0 + lw t7, 8(t6) + dsll s5, a1, 4 + lh gp, 12(t6) + daddu s5, s5, t9 + sw t7, 1748(a0) + daddu t9, t8, a0 + sw s5, 8(t6) + daddiu gp, gp, 1 + lq t9, 1072(t9) + daddiu t8, t8, -16 + sh gp, 12(t6) + addiu gp, r0, 48 + lq s5, 1744(a0) + sll r0, r0, 0 + lq s4, 1760(a0) + movz t8, gp, t8 + sq t9, 0(t0) + movz s5, s4, t7 + sh t8, 14(t6) + sll r0, r0, 0 + sq s5, 208(t0) + sll r0, r0, 0 + lqc2 vf5, 272(t4) + sqc2 vf2, 48(t0) + sll r0, r0, 0 + sqc2 vf20, 16(t0) + sll r0, r0, 0 + sqc2 vf3, 96(t0) + sll r0, r0, 0 + sqc2 vf21, 64(t0) + sll r0, r0, 0 + sqc2 vf4, 144(t0) + sll r0, r0, 0 + sqc2 vf22, 112(t0) + sll r0, r0, 0 + sqc2 vf5, 192(t0) + daddiu a1, a1, 14 + sqc2 vf23, 160(t0) + daddiu t0, t0, 224 + beq r0, r0, L51 + sll r0, r0, 0 + +B62: +L50: + sll r0, r0, 0 + sll r0, r0, 0 +B63: +L51: + jr ra + sll r0, r0, 0 + +B64: +L52: + bgez a2, L18 + or a2, a2, r0 + +B65: + beq a1, r0, L55 + sll r0, r0, 0 + +B66: + lw a2, 8196(a0) + sll r0, r0, 0 +B67: +L53: + lw a3, 0(a2) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a3, a3, 256 + sll r0, r0, 0 + beq a3, r0, L54 + sll r0, r0, 0 + +B68: + sll r0, r0, 0 + lw a3, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a3, a3, 1 + sll r0, r0, 0 + sw a3, 8160(a0) + beq r0, r0, L53 + sll r0, r0, 0 + +B69: +L54: + lw a3, 8152(a0) + sll r0, r0, 0 + sw v1, 128(a2) + xori t0, v1, 4720 + sw a3, 16(a2) + sll v1, a1, 4 + addu v1, a3, v1 + or a3, t0, r0 + sw a1, 32(a2) + addiu a1, r0, 256 + sw a1, 0(a2) + addiu a1, r0, 0 + sw v1, 8152(a0) + sll r0, r0, 0 +B70: +L55: + lw v1, 8196(a0) + sll r0, r0, 0 +B71: +L56: + lw a1, 0(v1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a1, a1, 256 + sll r0, r0, 0 + beq a1, r0, L57 + sll r0, r0, 0 + +B72: + sll r0, r0, 0 + lw a1, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a1, a1, 1 + sll r0, r0, 0 + sw a1, 8160(a0) + beq r0, r0, L56 + sll r0, r0, 0 + +B73: +L57: + lw v1, 8152(a0) + sll r0, r0, 0 + lw a0, 8148(a0) + sll r0, r0, 0 + sw v1, 4(a0) + sll r0, r0, 0 + or v0, r0, r0 + ld ra, 0(sp) + lq gp, 48(sp) + lq s5, 32(sp) + lq s4, 16(sp) + jr ra + daddiu sp, sp, 64 +``` + +# Unknown Method 23 (texture DMA generation?) +``` +L219: + daddiu sp, sp, -64 + sd ra, 0(sp) + sq s4, 16(sp) + sq s5, 32(sp) + sq gp, 48(sp) +B0: + lw v1, *display*(s7) + lw v1, 0(v1) + dsll v1, v1, 2 + lw a1, *display*(s7) + daddu v1, v1, a1 + lwu v1, 8(v1) ;; load the on-screen display frame + lwu a2, 36(v1) ;; global-buf for DMA + sll r0, r0, 0 + sll r0, r0, 0 + lw a1, 4(a2) ;; dma-buffer base + lui v1, 4096 + sw a2, 8148(a0) ;; stash buffer in work. + sync.l + cache dxwbin a1, 0 + sync.l + cache dxwbin a1, 1 + sync.l + lui a2, 28672 ;; a2 = scratchpad + ori a3, v1, 53248 ;; a3 = spr-from dma control register + vmaxw.xyzw vf11, vf0, vf0 ;; vf11 = [1, 1, 1, 1] + ori v1, a2, 2720 ;; v1 = spad output buffer + sw r0, 1736(a0) ;; modify dma return template + addiu a2, r0, 0 ;; a2 = 0 + sw a3, 8196(a0) ;; stash spr-from reg + or a3, v1, r0 ;; a3 = spad output + sw a1, 8152(a0) ;; stash global dma (EE) ptr + sll r0, r0, 0 + lqc2 vf29, 1728(a0) ;; vf29 = ret-tmpl + sll r0, r0, 0 + lw t0, 8152(a0) ;; t0 = global dma ptr + sll r0, r0, 0 + lw a1, 8264(a0) ;; a1 = work.hfragment.shaders + sll r0, r0, 0 + sw t0, 8388(a0) ;; far-texture = global dma ptr + daddiu t0, a2, -200 + sll r0, r0, 0 + blez t0, L222 + sll r0, r0, 0 + +B1: ;; if full, dma from transfer. + lw t0, 8196(a0) + sll r0, r0, 0 +B2: +L220: + lw a3, 0(t0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a3, a3, 256 + sll r0, r0, 0 + beq a3, r0, L221 + sll r0, r0, 0 + +B3: + sll r0, r0, 0 + lw a3, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a3, a3, 1 + sll r0, r0, 0 + sw a3, 8160(a0) + beq r0, r0, L220 + sll r0, r0, 0 + +B4: +L221: + lw a3, 8152(a0) ;; dma buffer swap + sll r0, r0, 0 + sw v1, 128(t0) + xori v1, v1, 4720 + sw a3, 16(t0) + sll t1, a2, 4 + addu t1, a3, t1 + or a3, v1, r0 + sw a2, 32(t0) + addiu a2, r0, 256 + sw a2, 0(t0) + addiu a2, r0, 0 + sw t1, 8152(a0) + sll r0, r0, 0 +B5: +L222: + sll r0, r0, 0 ;; set up the 1 far-texture bucket. + lq t1, 1776(a0) + sll r0, r0, 0 + lq t2, 1792(a0) + sll r0, r0, 0 + lq t3, 1936(a0) + sll r0, r0, 0 + lq t4, 1952(a0) + sll r0, r0, 0 + lq t5, 1968(a0) + sll r0, r0, 0 + lq t0, 1984(a0) + sq t1, 0(a3) + sll r0, r0, 0 + sq t2, 16(a3) + sll r0, r0, 0 + sq t3, 32(a3) + sll r0, r0, 0 + sq t4, 48(a3) + sll r0, r0, 0 + sq t5, 64(a3) + daddiu a2, a2, 6 + sq t0, 80(a3) + daddiu a3, a3, 96 + sll r0, r0, 0 + lq t0, 2128(a0) + sll r0, r0, 0 + lq t1, 2144(a0) + sll r0, r0, 0 + lq t2, 80(a1) + sll r0, r0, 0 + lq t3, 96(a1) + sll r0, r0, 0 + lq t4, 112(a1) + sll r0, r0, 0 + lq t5, 128(a1) + sll r0, r0, 0 + lq t6, 144(a1) + sq t0, 0(a3) + sll r0, r0, 0 + sq t1, 16(a3) + sll r0, r0, 0 + sq t2, 32(a3) + sll r0, r0, 0 + sq t3, 48(a3) + sll r0, r0, 0 + sq t4, 64(a3) + sll r0, r0, 0 + sq t5, 80(a3) + daddiu a1, a2, 7 + sq t6, 96(a3) + daddiu a2, a3, 112 + sll r0, r0, 0 + lq t0, 2192(a0) + sll r0, r0, 0 + lq t1, 2208(a0) + sll r0, r0, 0 + lq t2, 2256(a0) + sll r0, r0, 0 + lq t3, 3360(a0) + sll r0, r0, 0 + lq t4, 2352(a0) + sll r0, r0, 0 + lq t5, 3360(a0) + sll r0, r0, 0 + lq a3, 2368(a0) + sq t0, 0(a2) + sll r0, r0, 0 + sq t1, 16(a2) + sll r0, r0, 0 + sq t2, 32(a2) + sll r0, r0, 0 + sq t3, 48(a2) + sll r0, r0, 0 + sq t4, 64(a2) + sll r0, r0, 0 + sq t5, 80(a2) + daddiu a1, a1, 7 + sq a3, 96(a2) + daddiu a2, a2, 112 + sll r0, r0, 0 + lq t0, 1776(a0) + sll r0, r0, 0 + lq t1, 1792(a0) + sll r0, r0, 0 + lq t2, 2064(a0) + sll r0, r0, 0 + lq t3, 2080(a0) + sll r0, r0, 0 + lq t4, 2096(a0) + sll r0, r0, 0 + lq a3, 2112(a0) + sq t0, 0(a2) + sll r0, r0, 0 + sq t1, 16(a2) + sll r0, r0, 0 + sq t2, 32(a2) + sll r0, r0, 0 + sq t3, 48(a2) + sll r0, r0, 0 + sq t4, 64(a2) + daddiu a1, a1, 6 + sq a3, 80(a2) + daddiu a2, a2, 96 + sll r0, r0, 0 + daddiu t2, a1, 1 + sqc2 vf29, 0(a2) + daddiu t3, a2, 16 + or a1, a0, r0 + lw a2, 8284(a0) ;; a2 = hfragment.buckets-near + sll r0, r0, 0 + lw a3, 8272(a0) ;; a3 = hfragment.montage + sll r0, r0, 0 + lhu t0, 8302(a0) ;; t0 = hfragment.num-buckets-near + beq r0, r0, L230 + lw t1, 8264(a0) ;; t1 = hfragment.shaders + +B6: +L223: + daddu t5, t4, t5 ;; t5 = count + count-scissor + lw t4, 8152(a0) ;; t4 = dma-buffer.base + beq t5, r0, L230 ;; skip ahead to L230 if no near buckets + dsll t5, t2, 4 ;; t5 = qw offset in EE memory dma buffer?? + +B7: + daddu t4, t5, t4 ;; t4 = output for this texture DMA + sw t4, 8392(a1) ;; store dma ptr in work.near-textures[bucket-idx] + daddiu t4, t2, -102 + sll r0, r0, 0 + blez t4, L226 + sll r0, r0, 0 + +B8: ;; copy back from scratchpad to main memory + lw t4, 8196(a0) + sll r0, r0, 0 +B9: +L224: + lw t3, 0(t4) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t3, t3, 256 + sll r0, r0, 0 + beq t3, r0, L225 + sll r0, r0, 0 + +B10: + sll r0, r0, 0 + lw t3, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t3, t3, 1 + sll r0, r0, 0 + sw t3, 8160(a0) + beq r0, r0, L224 + sll r0, r0, 0 + +B11: +L225: + lw t3, 8152(a0) ;; swap dma buffers + sll r0, r0, 0 + sw v1, 128(t4) + xori v1, v1, 4720 + sw t3, 16(t4) + sll t5, t2, 4 + addu t5, t3, t5 + or t3, v1, r0 + sw t2, 32(t4) + addiu t2, r0, 256 + sw t2, 0(t4) + addiu t2, r0, 0 + sw t5, 8152(a0) + sll r0, r0, 0 +B12: +L226: + sll r0, r0, 0 + lq t5, 1776(a0) ;; t5 = work.frame-tmpl[0] + sll r0, r0, 0 + lq t6, 1792(a0) ;; t6 = work.frame-tmpl[1] + sll r0, r0, 0 + lq t7, 1808(a0) ;; t7 = work.frames[0].ad[0] (frame) + sll r0, r0, 0 + lq t8, 1824(a0) ;; t8 = work.frames[0].ad[1] (scissor, 0x7f) + sll r0, r0, 0 + lq t9, 1840(a0) ;; t9 = work.frames[0].ad[2] (xyoffset) + sll r0, r0, 0 + lq t4, 1856(a0) ;; t4 = work.frames[0].ad[3] (test) + + ;; store the frame template for frames[0] + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + daddiu t2, t2, 6 ;; inc offset + sq t4, 80(t3) + daddiu t3, t3, 96 ;; inc offset + sll r0, r0, 0 + + lq t5, 2128(a0) ;; t5 = adgif-tmpl[0] + sll r0, r0, 0 + lq t6, 2144(a0) ;; t6 = adgif-tmpl[1] + sll r0, r0, 0 + lq t7, 160(t1) ;; t7 = shaders[2][0] + sll r0, r0, 0 + lq t8, 176(t1) ;; t8 = shaders[2][1] + sll r0, r0, 0 + lq t9, 192(t1) ;; t9 = shaders[2][2] + sll r0, r0, 0 + lq ra, 208(t1) ;; ra = shaders[2][3] + sll r0, r0, 0 + lq t4, 224(t1) ;; t4 = shaders[2][4] + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 ;; inc offset + sq t4, 96(t3) + daddiu t3, t3, 112 ;; inc offset + sll r0, r0, 0 + +;; montage 0 + lhu t5, 0(a3) ;; t5 = montage[0] + sll r0, r0, 0 + lq t4, 2192(a0) ;; t4 = sprite-tmpl[0] + daddu t9, t5, a0 ;; t9 = work + montage value + lq t5, 2208(a0) ;; t5 = sprite-tmpl[1] + sll r0, r0, 0 + lq t6, 2256(a0) ;; t6 = color[0] = [0x80, 0x80, 0x80, 0x80] + sll r0, r0, 0 + lq t7, 3456(t9) ;; load montage-tex-coords + montage[0] + sll r0, r0, 0 + lq t8, 2384(a0) ;; t8 = near-data[0] + sll r0, r0, 0 + lq ra, 3472(t9) ;; load second montage tex coords + montage[0] + sll r0, r0, 0 + lq t9, 2400(a0) ;; t9 = near-data[1] + sq t4, 0(t3) ;; store sprite[0] + sll r0, r0, 0 + sq t5, 16(t3) ;; store sprite[1] + sll r0, r0, 0 + sq t6, 32(t3) ;; store color 0x80, 0x80, 0x80, 0x80 + sll r0, r0, 0 + sq t7, 48(t3) ;; store first tex coords + sll r0, r0, 0 + sq t8, 64(t3) ;; store first position + sll r0, r0, 0 + sq ra, 80(t3) ;; store second text coords + daddiu t2, t2, 7 + sq t9, 96(t3) ;; store second position + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 1 + lhu t5, 2(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2416(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2432(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 2 + lhu t5, 4(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2448(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2464(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 3 + lhu t5, 6(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2480(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2496(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 4 + lhu t5, 8(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2512(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2528(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 5 + lhu t5, 10(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2544(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2560(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 6 + lhu t5, 12(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2576(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2592(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 7 + lhu t5, 14(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2608(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2624(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 8 + lhu t5, 16(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2640(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2656(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 9 + lhu t5, 18(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2672(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2688(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 10 + lhu t5, 20(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2704(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2720(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 11 + lhu t5, 22(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2736(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2752(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 12 + lhu t5, 24(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2768(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2784(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 13 + lhu t5, 26(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2800(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2816(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 14 + lhu t5, 28(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2832(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2848(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + +;; montage 15 + lhu t5, 30(a3) + sll r0, r0, 0 + lq t4, 2192(a0) + daddu t9, t5, a0 + lq t5, 2208(a0) + sll r0, r0, 0 + lq t6, 2256(a0) + sll r0, r0, 0 + lq t7, 3456(t9) + sll r0, r0, 0 + lq t8, 2864(a0) + sll r0, r0, 0 + lq ra, 3472(t9) + sll r0, r0, 0 + lq t9, 2880(a0) + sq t4, 0(t3) + sll r0, r0, 0 + sq t5, 16(t3) + sll r0, r0, 0 + sq t6, 32(t3) + sll r0, r0, 0 + sq t7, 48(t3) + sll r0, r0, 0 + sq t8, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t9, 96(t3) + daddiu t3, t3, 112 + + daddiu t4, t2, -138 + sll r0, r0, 0 + blez t4, L229 ;; see if we need dma transfer + sll r0, r0, 0 + +B13: + lw t4, 8196(a0) + sll r0, r0, 0 +B14: +L227: + lw t3, 0(t4) ;; dma wait + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t3, t3, 256 + sll r0, r0, 0 + beq t3, r0, L228 + sll r0, r0, 0 + +B15: + sll r0, r0, 0 + lw t3, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t3, t3, 1 + sll r0, r0, 0 + sw t3, 8160(a0) + beq r0, r0, L227 + sll r0, r0, 0 + +B16: +L228: + lw t3, 8152(a0) ;; dma buffer swap + sll r0, r0, 0 + sw v1, 128(t4) + xori v1, v1, 4720 + sw t3, 16(t4) + sll t5, t2, 4 + addu t5, t3, t5 + or t3, v1, r0 + sw t2, 32(t4) + addiu t2, r0, 256 + sw t2, 0(t4) + addiu t2, r0, 0 + sw t5, 8152(a0) + sll r0, r0, 0 +B17: +L229: + sll r0, r0, 0 + lq t5, 1776(a0) ;; t5 = work.frame-tmpl[0] + sll r0, r0, 0 + lq t6, 1792(a0) ;; t6 = work.frame-tmpl[1] + sll r0, r0, 0 + lq t7, 1872(a0) ;; t7 = work.frames[1].ad[0] (frame) + sll r0, r0, 0 + lq t8, 1888(a0) ;; t8 = work.frames[1].ad[1] (scissor, 0x3f) + sll r0, r0, 0 + lq t9, 1904(a0) ;; t9 = work.frames[0].ad[2] (xyoffset) + sll r0, r0, 0 + lq t4, 1920(a0) ;; t4 = work.frames[0].ad[3] (test) + + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + daddiu t2, t2, 6 + sq t4, 80(t3) + daddiu t3, t3, 96 + sll r0, r0, 0 + + lq t5, 2224(a0) ;; t5 = mip-tmpl (different!) + sll r0, r0, 0 + lq t6, 2240(a0) ;; t6 = mip-tmpl[2] + sll r0, r0, 0 + lq t7, 3120(a0) ;; t7 = tex-data[0][0] + sll r0, r0, 0 + lq t8, 3136(a0) ;; t8 = tex-data[0][1] + sll r0, r0, 0 + lq t9, 3152(a0) ;; t9 = tex-data[0][2] + sll r0, r0, 0 + lq ra, 2256(a0) ;; ra = color[0] = [0x80, 0x80, 0x80, 0x80] + sll r0, r0, 0 + lq gp, 3360(a0) ;; gp = tex[0] + sll r0, r0, 0 + lq s5, 2896(a0) ;; s5 = mip-data[0] + sll r0, r0, 0 + lq s4, 3376(a0) ;; s4 = tex[1] + sll r0, r0, 0 + + lq t4, 2912(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + sll r0, r0, 0 + sq gp, 96(t3) + sll r0, r0, 0 + sq s5, 112(t3) + sll r0, r0, 0 + sq s4, 128(t3) + daddiu t2, t2, 10 + sq t4, 144(t3) + daddiu t3, t3, 160 + sll r0, r0, 0 + lq t5, 1776(a0) + sll r0, r0, 0 + lq t6, 1792(a0) + sll r0, r0, 0 + lq t7, 1936(a0) + sll r0, r0, 0 + lq t8, 1952(a0) + sll r0, r0, 0 + lq t9, 1968(a0) + sll r0, r0, 0 + lq t4, 1984(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + daddiu t2, t2, 6 + sq t4, 80(t3) + daddiu t3, t3, 96 + sll r0, r0, 0 + lq t5, 2128(a0) + sll r0, r0, 0 + lq t6, 2144(a0) + sll r0, r0, 0 + lq t7, 80(t1) + sll r0, r0, 0 + lq t8, 96(t1) + sll r0, r0, 0 + lq t9, 112(t1) + sll r0, r0, 0 + lq ra, 128(t1) + sll r0, r0, 0 + lq t4, 144(t1) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t4, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + lq t5, 2192(a0) + sll r0, r0, 0 + lq t6, 2208(a0) + sll r0, r0, 0 + lq t7, 2256(a0) + sll r0, r0, 0 + lq t8, 3360(a0) + sll r0, r0, 0 + lq t9, 3088(a0) + sll r0, r0, 0 + lq ra, 3360(a0) + sll r0, r0, 0 + lq t4, 3104(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + daddiu t2, t2, 7 + sq t4, 96(t3) + daddiu t3, t3, 112 + sll r0, r0, 0 + lq t5, 1776(a0) + sll r0, r0, 0 + lq t6, 1792(a0) + sll r0, r0, 0 + lq t7, 2000(a0) + sll r0, r0, 0 + lq t8, 2016(a0) + sll r0, r0, 0 + lq t9, 2032(a0) + sll r0, r0, 0 + lq t4, 2048(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + daddiu t2, t2, 6 + sq t4, 80(t3) + daddiu t3, t3, 96 + sll r0, r0, 0 + lq t5, 2224(a0) + sll r0, r0, 0 + lq t6, 2240(a0) + sll r0, r0, 0 + lq t7, 3168(a0) + sll r0, r0, 0 + lq t8, 3184(a0) + sll r0, r0, 0 + lq t9, 3200(a0) + sll r0, r0, 0 + lq ra, 2272(a0) + sll r0, r0, 0 + lq gp, 3360(a0) + sll r0, r0, 0 + lq s5, 2928(a0) + sll r0, r0, 0 + lq s4, 3392(a0) + sll r0, r0, 0 + lq t4, 2944(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + sll r0, r0, 0 + sq gp, 96(t3) + sll r0, r0, 0 + sq s5, 112(t3) + sll r0, r0, 0 + sq s4, 128(t3) + daddiu t2, t2, 10 + sq t4, 144(t3) + daddiu t3, t3, 160 + sll r0, r0, 0 + lq t5, 2224(a0) + sll r0, r0, 0 + lq t6, 2240(a0) + sll r0, r0, 0 + lq t7, 3216(a0) + sll r0, r0, 0 + lq t8, 3232(a0) + sll r0, r0, 0 + lq t9, 3248(a0) + sll r0, r0, 0 + lq ra, 2288(a0) + sll r0, r0, 0 + lq gp, 3360(a0) + sll r0, r0, 0 + lq s5, 2960(a0) + sll r0, r0, 0 + lq s4, 3408(a0) + sll r0, r0, 0 + lq t4, 2976(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + sll r0, r0, 0 + sq gp, 96(t3) + sll r0, r0, 0 + sq s5, 112(t3) + sll r0, r0, 0 + sq s4, 128(t3) + daddiu t2, t2, 10 + sq t4, 144(t3) + daddiu t3, t3, 160 + sll r0, r0, 0 + lq t5, 2224(a0) + sll r0, r0, 0 + lq t6, 2240(a0) + sll r0, r0, 0 + lq t7, 3264(a0) + sll r0, r0, 0 + lq t8, 3280(a0) + sll r0, r0, 0 + lq t9, 3296(a0) + sll r0, r0, 0 + lq ra, 2304(a0) + sll r0, r0, 0 + lq gp, 3360(a0) + sll r0, r0, 0 + lq s5, 2992(a0) + sll r0, r0, 0 + lq s4, 3424(a0) + sll r0, r0, 0 + lq t4, 3008(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + sll r0, r0, 0 + sq gp, 96(t3) + sll r0, r0, 0 + sq s5, 112(t3) + sll r0, r0, 0 + sq s4, 128(t3) + daddiu t2, t2, 10 + sq t4, 144(t3) + daddiu t3, t3, 160 + sll r0, r0, 0 + lq t5, 2224(a0) + sll r0, r0, 0 + lq t6, 2240(a0) + sll r0, r0, 0 + lq t7, 3312(a0) + sll r0, r0, 0 + lq t8, 3328(a0) + sll r0, r0, 0 + lq t9, 3344(a0) + sll r0, r0, 0 + lq ra, 2320(a0) + sll r0, r0, 0 + lq gp, 3360(a0) + sll r0, r0, 0 + lq s5, 3024(a0) + sll r0, r0, 0 + lq s4, 3440(a0) + sll r0, r0, 0 + lq t4, 3040(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + sll r0, r0, 0 + sq ra, 80(t3) + sll r0, r0, 0 + sq gp, 96(t3) + sll r0, r0, 0 + sq s5, 112(t3) + sll r0, r0, 0 + sq s4, 128(t3) + daddiu t2, t2, 10 + sq t4, 144(t3) + daddiu t3, t3, 160 + sll r0, r0, 0 + lq t5, 1776(a0) + sll r0, r0, 0 + lq t6, 1792(a0) + sll r0, r0, 0 + lq t7, 2064(a0) + sll r0, r0, 0 + lq t8, 2080(a0) + sll r0, r0, 0 + lq t9, 2096(a0) + sll r0, r0, 0 + lq t4, 2112(a0) + sq t5, 0(t3) + sll r0, r0, 0 + sq t6, 16(t3) + sll r0, r0, 0 + sq t7, 32(t3) + sll r0, r0, 0 + sq t8, 48(t3) + sll r0, r0, 0 + sq t9, 64(t3) + daddiu t2, t2, 6 + sq t4, 80(t3) + daddiu t3, t3, 96 + sll r0, r0, 0 + daddiu t2, t2, 1 + sqc2 vf29, 0(t3) + daddiu t3, t3, 16 +B18: +L230: + daddiu a2, a2, 16 ;; advance bucket + daddiu a3, a3, 32 ;; advange montage + daddiu t0, t0, -1 ;; decrement remaining bucket count. + lhu t4, 4(a2) ;; t4 = this-bucket.count (num tags?) + daddiu a1, a1, 4 ;; work-offset += 4 + lhu t5, 12(a2) ;; t5 = this-bucket.count-scissor (ignore) + bgtz t0, L223 ;; go back + sll r0, r0, 0 + + +;;;;;;;;;;;;;;;;;;;;;;;; End near texture stuff + +B19: + beq t2, r0, L233 + sll r0, r0, 0 + +B20: + lw a1, 8196(a0) + sll r0, r0, 0 +B21: +L231: + lw a2, 0(a1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a2, a2, 256 + sll r0, r0, 0 + beq a2, r0, L232 + sll r0, r0, 0 + +B22: + sll r0, r0, 0 + lw a2, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a2, a2, 1 + sll r0, r0, 0 + sw a2, 8160(a0) + beq r0, r0, L231 + sll r0, r0, 0 + +B23: +L232: + lw a2, 8152(a0) + sll r0, r0, 0 + sw v1, 128(a1) + xori a3, v1, 4720 + sw a2, 16(a1) + sll v1, t2, 4 + addu v1, a2, v1 + or a2, a3, r0 + sw t2, 32(a1) + addiu a2, r0, 256 + sw a2, 0(a1) + addiu a1, r0, 0 + sw v1, 8152(a0) + sll r0, r0, 0 +B24: +L233: + lw v1, 8196(a0) + sll r0, r0, 0 +B25: +L234: + lw a1, 0(v1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a1, a1, 256 + sll r0, r0, 0 + beq a1, r0, L235 + sll r0, r0, 0 + +B26: + sll r0, r0, 0 + lw a1, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a1, a1, 1 + sll r0, r0, 0 + sw a1, 8160(a0) + beq r0, r0, L234 + sll r0, r0, 0 + +B27: +L235: + lw v1, 8152(a0) + sll r0, r0, 0 + lw a0, 8148(a0) + sll r0, r0, 0 + sw v1, 4(a0) + sll r0, r0, 0 + or v1, r0, r0 + or v0, r0, r0 + ld ra, 0(sp) + lq gp, 48(sp) + lq s5, 32(sp) + lq s4, 16(sp) + jr ra + daddiu sp, sp, 64 + + sll r0, r0, 0 +``` + +# Method 34 +``` +vf6, vf7, vf8, vf9, vf10 have shader-near. + + sll r0, r0, 0 + sll r0, r0, 0 + lw a2, 4(a1) ;; a2 = dma ptr + lui v1, 4096 + sw a1, 8148(a0) ;; stash dma buffer + sync.l + cache dxwbin a2, 0 + sync.l + cache dxwbin a2, 1 + sync.l + lui a3, 28672 + ori a1, v1, 53248 + vmaxw.xyzw vf11, vf0, vf0 + ori v1, a3, 2720 + sw r0, 1736(a0) + addiu t0, r0, 0 + sw a1, 8196(a0) + or t1, v1, r0 + sw a2, 8152(a0) + sll r0, r0, 0 + lqc2 vf29, 1728(a0) ;; vf29 = ret-tmpl + or a1, a0, r0 ;; a1 is offset work + lw a2, 8284(a0) ;; a2 = work.hfragment.buckets-near + sll r0, r0, 0 + lhu a3, 8302(a0) ;; a3 = work.hfragment.num-buckets-near + beq r0, r0, L195 + lhu t2, 4(a2) ;; t2 = this-bucket.count + +B1: +L188: + sll r0, r0, 0 + lw t2, 8392(a1) ;; t2 = near-textures[bucket-idx] + beq t3, r0, L195 ;; skip if nothing in bucket. + sll r0, r0, 0 + +B2: + sll r0, r0, 0 + sw t2, 1716(a0) ;; put near-textures in call + daddiu t2, t0, -226 + sll r0, r0, 0 + blez t2, L191 ;; maybe dma out + sll r0, r0, 0 + +B3: ;; dma wait + lw t2, 8196(a0) + sll r0, r0, 0 +B4: +L189: + lw t1, 0(t2) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t1, t1, 256 + sll r0, r0, 0 + beq t1, r0, L190 + sll r0, r0, 0 + +B5: + sll r0, r0, 0 + lw t1, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t1, t1, 1 + sll r0, r0, 0 + sw t1, 8160(a0) + beq r0, r0, L189 + sll r0, r0, 0 + +B6: +L190: ;; dma swap + lw t1, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t2) + xori v1, v1, 4720 + sw t1, 16(t2) + sll t3, t0, 4 + addu t3, t1, t3 + or t1, v1, r0 + sw t0, 32(t2) + addiu t0, r0, 256 + sw t0, 0(t2) + addiu t0, r0, 0 + sw t3, 8152(a0) + sll r0, r0, 0 +B7: +L191: + lq t2, 7584(a0) ;; t2 = call-abort-vu1 + daddiu t0, t0, 1 + sq t2, 0(t1) + daddiu t2, t1, 16 + daddiu t1, t0, -215 + sll r0, r0, 0 + blez t1, L194 + sll r0, r0, 0 + +B8: + lw t1, 8196(a0) ;; dma out of scratchpad if needed + sll r0, r0, 0 +B9: +L192: + lw t2, 0(t1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi t2, t2, 256 + sll r0, r0, 0 + beq t2, r0, L193 + sll r0, r0, 0 + +B10: + sll r0, r0, 0 + lw t2, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu t2, t2, 1 + sll r0, r0, 0 + sw t2, 8160(a0) + beq r0, r0, L192 + sll r0, r0, 0 + +B11: +L193: ;; swap dma buffer + lw t2, 8152(a0) + sll r0, r0, 0 + sw v1, 128(t1) + xori v1, v1, 4720 + sw t2, 16(t1) + sll t3, t0, 4 + addu t3, t2, t3 + or t2, v1, r0 + sw t0, 32(t1) + addiu t0, r0, 256 + sw t0, 0(t1) + addiu t0, r0, 0 + sw t3, 8152(a0) + sll r0, r0, 0 +B12: +L194: + sll r0, r0, 0 + lqc2 vf30, 1712(a0) ;; vf30 = call + sll r0, r0, 0 + daddiu t0, t0, 1 + sqc2 vf30, 0(t2) + daddiu t1, t2, 16 + sll r0, r0, 0 + lq t2, 2160(a0) ;; t2 = adgif2[0] + sll r0, r0, 0 + lq t3, 2176(a0) ;; t3 = adgif2[1] + sq t2, 0(t1) + sll r0, r0, 0 + sq t3, 16(t1) + sll r0, r0, 0 + + sqc2 vf6, 32(t1) + sll r0, r0, 0 + sqc2 vf7, 48(t1) + sll r0, r0, 0 + sqc2 vf8, 64(t1) + sll r0, r0, 0 + sqc2 vf9, 80(t1) + sll r0, r0, 0 + sqc2 vf10, 96(t1) + daddiu t0, t0, 8 + sqc2 vf5, 112(t1) ;; plus the texflush! + daddiu t1, t1, 128 + sll r0, r0, 0 + lh t3, 6(a2) ;; t3 = vertex count + sll r0, r0, 0 + lw t2, 0(a2) ;; t2 = bucket.next (vertex uploads for bucket) + dsll t4, t3, 1 ;; t4 = vertex-count * 2 + sll r0, r0, 0 + daddu t3, t4, t3 ;; t3 = vertex-count * 3 = 48 or 96 + sll r0, r0, 0 + daddu t5, t3, a0 + sll r0, r0, 0 + sll r0, r0, 0 + lq t3, 1552(t5) ;; 1648 or 1600 + sll r0, r0, 0 + lq t4, 1568(t5) + sll r0, r0, 0 + lq t5, 1584(t5) + sq t3, 0(t1) + sll r0, r0, 0 + sq t4, 16(t1) + sll r0, r0, 0 + sq t5, 32(t1) + daddiu t0, t0, 3 + sw t2, 4(t1) + daddiu t1, t1, 48 +B13: +L195: + daddiu a2, a2, 16 ;; inc bucket + daddiu a1, a1, 4 ;; inc offset work + daddiu a3, a3, -1 ;; dec bucket count + lhu t3, 4(a2) ;; load count in bucket + bgtz a3, L188 ;; go back + sll r0, r0, 0 + +B14: + beq t0, r0, L198 + sll r0, r0, 0 + +B15: + lw a1, 8196(a0) + sll r0, r0, 0 +B16: +L196: + lw a2, 0(a1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a2, a2, 256 + sll r0, r0, 0 + beq a2, r0, L197 + sll r0, r0, 0 + +B17: + sll r0, r0, 0 + lw a2, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a2, a2, 1 + sll r0, r0, 0 + sw a2, 8160(a0) + beq r0, r0, L196 + sll r0, r0, 0 + +B18: +L197: + lw a2, 8152(a0) + sll r0, r0, 0 + sw v1, 128(a1) + xori a3, v1, 4720 + sw a2, 16(a1) + sll v1, t0, 4 + addu v1, a2, v1 + or a2, a3, r0 + sw t0, 32(a1) + addiu a2, r0, 256 + sw a2, 0(a1) + addiu a1, r0, 0 + sw v1, 8152(a0) + sll r0, r0, 0 +B19: +L198: + lw v1, 8196(a0) + sll r0, r0, 0 +B20: +L199: + lw a1, 0(v1) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + andi a1, a1, 256 + sll r0, r0, 0 + beq a1, r0, L200 + sll r0, r0, 0 + +B21: + sll r0, r0, 0 + lw a1, 8160(a0) + sll r0, r0, 0 + sll r0, r0, 0 + sll r0, r0, 0 + daddiu a1, a1, 1 + sll r0, r0, 0 + sw a1, 8160(a0) + beq r0, r0, L199 + sll r0, r0, 0 + +B22: +L200: + lw v1, 8152(a0) + sll r0, r0, 0 + lw a0, 8148(a0) + sll r0, r0, 0 + sw v1, 4(a0) + sll r0, r0, 0 + or v0, r0, r0 + jr ra + daddu sp, sp, r0 + +``` \ No newline at end of file diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index d28ffdd7c..0cc9554bf 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -34,6 +34,7 @@ set(RUNTIME_SOURCE graphics/jak3_texture_remap.cpp graphics/screenshot.cpp graphics/opengl_renderer/background/background_common.cpp + graphics/opengl_renderer/background/Hfrag.cpp graphics/opengl_renderer/background/Shrub.cpp graphics/opengl_renderer/background/TFragment.cpp graphics/opengl_renderer/background/Tie3.cpp diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index d004c9d6e..3a60d2a20 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -14,6 +14,7 @@ #include "game/graphics/opengl_renderer/TextureUploadHandler.h" #include "game/graphics/opengl_renderer/VisDataHandler.h" #include "game/graphics/opengl_renderer/Warp.h" +#include "game/graphics/opengl_renderer/background/Hfrag.h" #include "game/graphics/opengl_renderer/background/Shrub.h" #include "game/graphics/opengl_renderer/background/TFragment.h" #include "game/graphics/opengl_renderer/background/Tie3.h" @@ -144,6 +145,9 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { init_bucket_renderer("ocean-mid-far", BucketCategory::OCEAN, BucketId::OCEAN_MID_FAR); + // 8 (in tfrag category for now, just for stat reporting.) + init_bucket_renderer("hfrag", BucketCategory::TFRAG, BucketId::HFRAG); + // 10 for (int i = 0; i < LEVEL_MAX; i++) { #define GET_BUCKET_ID_FOR_LIST(bkt1, bkt2, idx) ((int)(bkt1) + ((int)(bkt2) - (int)(bkt1)) * (idx)) diff --git a/game/graphics/opengl_renderer/Shader.cpp b/game/graphics/opengl_renderer/Shader.cpp index 83e14a03d..cfdaed6ed 100644 --- a/game/graphics/opengl_renderer/Shader.cpp +++ b/game/graphics/opengl_renderer/Shader.cpp @@ -128,6 +128,8 @@ ShaderLibrary::ShaderLibrary(GameVersion version) { at(ShaderId::TEX_ANIM) = {"tex_anim", version}; at(ShaderId::GLOW_DEPTH_COPY) = {"glow_depth_copy", version}; at(ShaderId::GLOW_PROBE_ON_GRID) = {"glow_probe_on_grid", version}; + at(ShaderId::HFRAG) = {"hfrag", version}; + at(ShaderId::HFRAG_MONTAGE) = {"hfrag_montage", version}; for (auto& shader : m_shaders) { ASSERT_MSG(shader.okay(), "error compiling shader"); diff --git a/game/graphics/opengl_renderer/Shader.h b/game/graphics/opengl_renderer/Shader.h index 18a07cfc5..f7a4f8f55 100644 --- a/game/graphics/opengl_renderer/Shader.h +++ b/game/graphics/opengl_renderer/Shader.h @@ -61,6 +61,8 @@ enum class ShaderId { TEX_ANIM = 34, GLOW_DEPTH_COPY = 35, GLOW_PROBE_ON_GRID = 36, + HFRAG = 37, + HFRAG_MONTAGE = 38, MAX_SHADERS }; diff --git a/game/graphics/opengl_renderer/background/Hfrag.cpp b/game/graphics/opengl_renderer/background/Hfrag.cpp new file mode 100644 index 000000000..bd620b4b5 --- /dev/null +++ b/game/graphics/opengl_renderer/background/Hfrag.cpp @@ -0,0 +1,462 @@ +#include "Hfrag.h" + +#include "common/log/log.h" + +#include "third-party/imgui/imgui.h" + +Hfrag::Hfrag(const std::string& name, int my_id) : BucketRenderer(name, my_id) { + // generate shared index buffer + int vi = 0; + std::vector indices; + for (int bucket_idx = 0; bucket_idx < kNumBuckets; bucket_idx++) { + for (int tile_idx = 0; tile_idx < kNumMontageTiles; tile_idx++) { + indices.push_back(vi++); + indices.push_back(vi++); + indices.push_back(vi++); + indices.push_back(vi++); + indices.push_back(UINT32_MAX); + } + } + + glGenBuffers(1, &m_montage_indices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_montage_indices); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(u32) * indices.size(), indices.data(), + GL_STATIC_DRAW); + ASSERT(indices.size() == kIndsPerTile * kNumMontageTiles * kNumBuckets); +} + +void Hfrag::draw_debug_window() { + for (auto& level : m_levels) { + if (!level.in_use) { + ImGui::Text("Inactive"); + } else { + ImGui::Text("Level %s", level.name.c_str()); + ImGui::Text(" total corners: %d", level.stats.total_corners); + ImGui::Text(" in view corners: %d", level.stats.corners_in_view); + ImGui::Text(" in view and not occluded corners: %d", + level.stats.corners_in_view_and_not_occluded); + ImGui::Text(" buckets used: %d", level.stats.buckets_used); + } + } +} + +void Hfrag::init_shaders(ShaderLibrary&) {} + +bool is_dma_nop(const DmaTransfer& xfer) { + return xfer.size_bytes == 0 && xfer.vifcode0().kind == VifCode::Kind::NOP && + xfer.vifcode1().kind == VifCode::Kind::NOP; +} + +bool is_dma_init_nop(const DmaTransfer& xfer) { + return xfer.size_bytes == 0 && + (xfer.vifcode0().kind == VifCode::Kind::NOP || + xfer.vifcode0().kind == VifCode::Kind::MARK) && + xfer.vifcode1().kind == VifCode::Kind::NOP; +} + +void Hfrag::render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) { + // dma.read_and_advance(); // link to bucket data + { + auto nop1 = dma.read_and_advance(); + ASSERT(is_dma_init_nop(nop1)); + if (dma.current_tag_offset() == render_state->next_bucket) { + return; + } + } + + // first transfer is always FLUSHA, DIRECT to set up the bucket + { + auto default_init = dma.read_and_advance(); + ASSERT(default_init.size_bytes == 10 * 16); + ASSERT(default_init.vifcode0().kind == VifCode::Kind::FLUSHA); + ASSERT(default_init.vifcode1().kind == VifCode::Kind::DIRECT); + } + + { + auto first_nop = dma.read_and_advance(); + ASSERT(is_dma_nop(first_nop)); + } + + auto xfer = dma.read_and_advance(); + while (!is_dma_nop(xfer)) { + // grab the data + ASSERT(xfer.size_bytes == sizeof(TfragPcPortData)); + TfragPcPortData pc_port_data; + int level_idx = xfer.vifcode1().immediate; + memcpy(&pc_port_data, xfer.data, sizeof(TfragPcPortData)); + pc_port_data.level_name[11] = '\0'; + + const u8* occlusion_data = nullptr; + if (render_state->occlusion_vis[level_idx].valid) { + occlusion_data = render_state->occlusion_vis[level_idx].data; + } + + // ugh + if (std::string("desert-vis") == pc_port_data.level_name) { + strcpy(pc_port_data.level_name, "dst"); + } + + // try to get a hfrag level + auto* hfrag_level = get_hfrag_level(pc_port_data.level_name, render_state); + if (hfrag_level) { + hfrag_level->last_used_frame = render_state->frame_idx; + if (occlusion_data) { + occlusion_data += hfrag_level->hfrag->occlusion_offset; + } + render_hfrag_level(hfrag_level, render_state, prof, pc_port_data, occlusion_data); + } + + xfer = dma.read_and_advance(); + } + + // ending + { + auto default_init = dma.read_and_advance(); + ASSERT(default_init.size_bytes == 10 * 16); + ASSERT(default_init.vifcode0().kind == VifCode::Kind::FLUSHA); + ASSERT(default_init.vifcode1().kind == VifCode::Kind::DIRECT); + } + + { + auto end_nop = dma.read_and_advance(); + ASSERT(is_dma_nop(end_nop)); + } + ASSERT(render_state->next_bucket == dma.current_tag_offset()); +} + +Hfrag::HfragLevel* Hfrag::get_hfrag_level(const std::string& name, + SharedRenderState* render_state) { + // first, see if this level is loaded. If not, there's nothing we can do. + auto lev_data = render_state->loader->get_tfrag3_level(name); + if (!lev_data) { + printf("[hfrag] can't display %s because it's not loaded.\n", name.c_str()); + render_state->loader->debug_print_loaded_levels(); + return nullptr; + } + + // check if the level load work is already done and we can reuse. + for (auto& lev : m_levels) { + if (lev.in_use && lev.name == name && lev.load_id == lev_data->load_id) { + // we can reuse it! + return &lev; + } + } + + // prefer to load over a stale copy of this same level + for (auto& lev : m_levels) { + if (lev.in_use && lev.name == name) { + // unload the previous copy and reload + unload_hfrag_level(&lev); + load_hfrag_level(name, &lev, lev_data); + return &lev; + } + } + + // prefer to load in an unused slot + for (auto& lev : m_levels) { + if (!lev.in_use) { + load_hfrag_level(name, &lev, lev_data); + return &lev; + } + } + + // find the least recently used level + u64 oldest_frame = UINT64_MAX; + HfragLevel* oldest_lev = nullptr; + for (auto& lev : m_levels) { + if (lev.in_use) { + if (lev.last_used_frame < oldest_frame) { + lg::warn("hfrag discarding level {} for level {}, age {} frames", lev.name, name, + render_state->frame_idx - lev.last_used_frame); + oldest_frame = lev.last_used_frame; + oldest_lev = &lev; + } + } + } + + ASSERT(oldest_lev); + unload_hfrag_level(oldest_lev); + load_hfrag_level(name, oldest_lev, lev_data); + return oldest_lev; +} + +void Hfrag::unload_hfrag_level(Hfrag::HfragLevel* lev) { + ASSERT(lev->in_use); + // delete OpenGL resources we created. + glBindTexture(GL_TEXTURE_1D, lev->time_of_day_texture); + glDeleteTextures(1, &lev->time_of_day_texture); + glDeleteVertexArrays(1, &lev->vao); + + glDeleteVertexArrays(1, &lev->montage_vao); + glDeleteBuffers(1, &lev->montage_vertices); + + lev->in_use = false; + lev->name.clear(); + lev->last_used_frame = 0; + lev->hfrag = nullptr; +} + +void Hfrag::load_hfrag_level(const std::string& load_name, + Hfrag::HfragLevel* lev, + const LevelData* data) { + ASSERT(!lev->in_use); + + lev->in_use = true; + lev->name = load_name; + lev->load_id = data->load_id; + lev->vertex_buffer = data->hfrag_vertices; + lev->index_buffer = data->hfrag_indices; + lev->num_colors = data->level->hfrag.time_of_day_colors.color_count; + lev->hfrag = &data->level->hfrag; + lev->wang_texture = data->textures.at(data->level->hfrag.wang_tree_tex_id[0]); + + if (m_color_result.size() < lev->num_colors) { + m_color_result.resize(lev->num_colors); + } + + ASSERT(lev->hfrag->buckets.size() == kNumBuckets); + ASSERT(lev->hfrag->corners.size() == kNumCorners); + ASSERT(lev->num_colors <= TIME_OF_DAY_COLOR_COUNT); + + // normal drawing opengl + glGenVertexArrays(1, &lev->vao); + glBindVertexArray(lev->vao); + glBindBuffer(GL_ARRAY_BUFFER, lev->vertex_buffer); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + glEnableVertexAttribArray(3); + glEnableVertexAttribArray(4); + + glVertexAttribPointer(0, // location 0 in the shader + 3, // 3 values per vert + GL_FLOAT, // floats + GL_FALSE, // normalized (ignored) + sizeof(tfrag3::HfragmentVertex), // stride + (void*)offsetof(tfrag3::HfragmentVertex, height) // offset + ); + + glVertexAttribIPointer(1, // location 1 in the shader + 1, // 1 values per vert + GL_UNSIGNED_SHORT, // u16 + sizeof(tfrag3::HfragmentVertex), // stride + (void*)offsetof(tfrag3::HfragmentVertex, color_index) // offset (0) + ); + glVertexAttribIPointer(2, // location 1 in the shader + 2, // 2 values per vert + GL_UNSIGNED_BYTE, // u8 + sizeof(tfrag3::HfragmentVertex), // stride + (void*)offsetof(tfrag3::HfragmentVertex, u) // offset (0) + ); + glVertexAttribIPointer(3, // location 1 in the shader + 1, // 2 values per vert + GL_UNSIGNED_INT, // u32 + sizeof(tfrag3::HfragmentVertex), // stride + (void*)offsetof(tfrag3::HfragmentVertex, vi) // offset (0) + ); + glActiveTexture(GL_TEXTURE10); + glGenTextures(1, &lev->time_of_day_texture); + glBindTexture(GL_TEXTURE_1D, lev->time_of_day_texture); + glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, TIME_OF_DAY_COLOR_COUNT, 0, GL_RGBA, + GL_UNSIGNED_INT_8_8_8_8, nullptr); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glBindVertexArray(0); + + // montage + + struct MontageVertex { + float x, y, u, v; + }; + struct MontageTile { + MontageVertex verts[4]; + }; + struct MontageBucket { + MontageTile tiles[kNumMontageTiles]; + }; + MontageBucket montage[kNumBuckets]; + + // generate montage vertices + for (int bucket_idx = 0; bucket_idx < kNumBuckets; bucket_idx++) { + auto& bucket = montage[bucket_idx]; + for (int tile_idx = 0; tile_idx < kNumMontageTiles; tile_idx++) { + auto& tile = bucket.tiles[tile_idx]; + // the xy is the same for all buckets + const int tx = tile_idx % 4; + const int ty = tile_idx / 4; + + tile.verts[0].x = tx * 0.25f; + tile.verts[1].x = tx * 0.25f + 0.25f; + tile.verts[2].x = tx * 0.25f; + tile.verts[3].x = tx * 0.25f + 0.25f; + + tile.verts[0].y = ty * 0.25f; + tile.verts[1].y = ty * 0.25f; + tile.verts[2].y = ty * 0.25f + 0.25f; + tile.verts[3].y = ty * 0.25f + 0.25f; + + // use the lookup table from the game + const int montage_idx = lev->hfrag->buckets[bucket_idx].montage_table[tile_idx]; + const int mx = montage_idx & 15; + const int my = montage_idx / 16; + ASSERT(montage_idx < 8 * 16); + + tile.verts[0].u = mx * 0.0625f; + tile.verts[1].u = mx * 0.0625f + 0.0625f; + tile.verts[2].u = mx * 0.0625f; + tile.verts[3].u = mx * 0.0625f + 0.0625f; + + tile.verts[0].v = my * 0.125f; + tile.verts[1].v = my * 0.125f; + tile.verts[2].v = my * 0.125f + 0.125f; + tile.verts[3].v = my * 0.125f + 0.125f; + } + } + + glGenVertexArrays(1, &lev->montage_vao); + glBindVertexArray(lev->montage_vao); + glGenBuffers(1, &lev->montage_vertices); + glBindBuffer(GL_ARRAY_BUFFER, lev->montage_vertices); + glBufferData(GL_ARRAY_BUFFER, sizeof(MontageBucket) * kNumBuckets, montage, GL_STATIC_DRAW); + glActiveTexture(GL_TEXTURE0); + + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + + glVertexAttribPointer(0, // location 0 in the shader + 2, // 3 values per vert + GL_FLOAT, // floats + GL_FALSE, // normalized (ignored) + sizeof(MontageVertex), // stride + (void*)offsetof(MontageVertex, x) // offset + ); + glVertexAttribPointer(1, // location 0 in the shader + 2, // 3 values per vert + GL_FLOAT, // floats + GL_FALSE, // normalized (ignored) + sizeof(MontageVertex), // stride + (void*)offsetof(MontageVertex, u) // offset + ); +} + +void Hfrag::render_hfrag_level(Hfrag::HfragLevel* lev, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + const TfragPcPortData& pc_data, + const u8* occlusion_data) { + // first pass, determine visibility and which buckets we need to generate textures for + for (auto& b : m_bucket_used) { + b = false; + } + lev->stats = {}; + for (u32 bucket_idx = 0; bucket_idx < lev->hfrag->buckets.size(); bucket_idx++) { + const auto& bucket = lev->hfrag->buckets[bucket_idx]; + for (u32 corner_idx : bucket.corners) { + const auto& corner = lev->hfrag->corners[corner_idx]; + lev->stats.total_corners++; + bool draw = true; + + if (sphere_in_view_ref(corner.bsphere, pc_data.camera.planes)) { + lev->stats.corners_in_view++; + } else { + draw = false; + } + + if (draw && occlusion_data) { // only check vis bit if frustum culling passes + int occlusion_byte = corner.vis_id / 8; + int occlusion_bit = corner.vis_id & 7; + if ((occlusion_data[occlusion_byte] & (1 << (7 - occlusion_bit)))) { + lev->stats.corners_in_view_and_not_occluded++; + } else { + draw = false; + } + } + + m_corner_vis[corner_idx] = draw; + if (draw) { + m_bucket_used[bucket_idx] = true; + } + } + if (m_bucket_used[bucket_idx]) { + lev->stats.buckets_used++; + } + } + + // textures + render_hfrag_montage_textures(lev, render_state, prof); + + // generate time of day texture + interp_time_of_day(pc_data.camera.itimes, lev->hfrag->time_of_day_colors, m_color_result.data()); + glActiveTexture(GL_TEXTURE10); + glBindTexture(GL_TEXTURE_1D, lev->time_of_day_texture); + glTexSubImage1D(GL_TEXTURE_1D, 0, 0, lev->num_colors, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, + m_color_result.data()); + + // initialize data + glBindVertexArray(lev->vao); + glBindBuffer(GL_ARRAY_BUFFER, lev->vertex_buffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, lev->index_buffer); + glActiveTexture(GL_TEXTURE0); + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex(UINT32_MAX); + + // set up shader + first_tfrag_draw_setup(pc_data.camera, render_state, ShaderId::HFRAG); + setup_opengl_from_draw_mode(lev->hfrag->draw_mode, GL_TEXTURE0, false); + + glActiveTexture(GL_TEXTURE0); + // glBindTexture(GL_TEXTURE_2D, lev->hfrag->wang_tree_tex_id[0]); + + // draw pass + for (u32 bucket_idx = 0; bucket_idx < lev->hfrag->buckets.size(); bucket_idx++) { + if (!m_bucket_used[bucket_idx]) { + continue; // no need to bind texture. + } + glBindTexture(GL_TEXTURE_2D, lev->montage_texture[bucket_idx].fb.texture()); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // HACK rm + + const auto& bucket = lev->hfrag->buckets[bucket_idx]; + for (u32 corner_idx : bucket.corners) { + const auto& corner = lev->hfrag->corners[corner_idx]; + if (m_corner_vis[corner_idx]) { + glDrawElements(GL_TRIANGLE_STRIP, corner.index_length, GL_UNSIGNED_INT, + (void*)(corner.index_start * sizeof(u32))); + prof.add_draw_call(1); + prof.add_tri(corner.num_tris); + } + } + } +} + +void Hfrag::render_hfrag_montage_textures(Hfrag::HfragLevel* lev, + SharedRenderState* render_state, + ScopedProfilerNode& prof) { + glBindVertexArray(lev->montage_vao); + glBindBuffer(GL_ARRAY_BUFFER, lev->montage_vertices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_montage_indices); + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex(UINT32_MAX); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + + const auto& sh = render_state->shaders[ShaderId::HFRAG_MONTAGE]; + sh.activate(); + glUniform1i(glGetUniformLocation(sh.id(), "tex_T0"), 0); + + for (int bi = 0; bi < kNumBuckets; bi++) { + if (!m_bucket_used[bi]) { + continue; // no need to generate textures + } + + FramebufferTexturePairContext ctxt(lev->montage_texture[bi].fb); // render to texture + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, lev->wang_texture); + constexpr int index_stride = kIndsPerTile * kNumMontageTiles; + const int offset = bi * index_stride; + glDrawElements(GL_TRIANGLE_STRIP, index_stride, GL_UNSIGNED_INT, (void*)(offset * sizeof(u32))); + prof.add_draw_call(); + prof.add_tri(32); + } + + glEnable(GL_DEPTH_TEST); +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/background/Hfrag.h b/game/graphics/opengl_renderer/background/Hfrag.h new file mode 100644 index 000000000..ca78abf4c --- /dev/null +++ b/game/graphics/opengl_renderer/background/Hfrag.h @@ -0,0 +1,76 @@ +#pragma once + +#include "game/graphics/opengl_renderer/BucketRenderer.h" +#include "game/graphics/opengl_renderer/background/background_common.h" +#include "game/graphics/opengl_renderer/opengl_utils.h" + +class Hfrag : public BucketRenderer { + public: + Hfrag(const std::string& name, int my_id); + + void render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) override; + void draw_debug_window() override; + void init_shaders(ShaderLibrary&) override; + + static constexpr int kNumBuckets = 17; + static constexpr int kNumCorners = 1024; + static constexpr int kNumMontageTiles = 16; + static constexpr int kIndsPerTile = 5; + + struct MontageTexture { + FramebufferTexturePair fb; + MontageTexture() : fb(128, 128, GL_UNSIGNED_INT_8_8_8_8_REV) {} + }; + + struct HfragLevel { + bool in_use = false; + std::string name; + u64 load_id = 0; + GLuint vertex_buffer; + GLuint index_buffer; + GLuint time_of_day_texture; + GLuint vao; + tfrag3::Hfragment* hfrag = nullptr; + u64 num_colors = 0; + u64 last_used_frame = 0; + + GLuint wang_texture; + + MontageTexture montage_texture[kNumBuckets]; + GLuint montage_vertices; + GLuint montage_vao; + + struct { + int total_corners = 0; + int corners_in_view = 0; + int corners_in_view_and_not_occluded = 0; + int buckets_used = 0; + } stats; + }; + + private: + /*! + * Try to get a HfragLevel for the given level name. May return nullptr. + */ + HfragLevel* get_hfrag_level(const std::string& name, SharedRenderState* render_state); + void unload_hfrag_level(HfragLevel* lev); + void load_hfrag_level(const std::string& load_name, HfragLevel* lev, const LevelData* data); + void render_hfrag_level(HfragLevel* lev, + SharedRenderState* render_state, + ScopedProfilerNode& prof, + const TfragPcPortData& pc_data, + const u8* occlusion_data); + + void render_hfrag_montage_textures(HfragLevel* lev, + SharedRenderState* render_state, + ScopedProfilerNode& prof); + + static constexpr int kMaxLevels = 2; + std::array m_levels; + static constexpr int TIME_OF_DAY_COLOR_COUNT = 8192; + std::vector> m_color_result; + + bool m_bucket_used[kNumBuckets]; + bool m_corner_vis[kNumCorners]; + GLuint m_montage_indices = 0; +}; \ No newline at end of file diff --git a/game/graphics/opengl_renderer/background/Shrub.cpp b/game/graphics/opengl_renderer/background/Shrub.cpp index 674771934..a4c7a4517 100644 --- a/game/graphics/opengl_renderer/background/Shrub.cpp +++ b/game/graphics/opengl_renderer/background/Shrub.cpp @@ -74,7 +74,7 @@ void Shrub::update_load(const LevelData* loader_data) { m_trees.resize(lev_data->shrub_trees.size()); size_t max_draws = 0; - size_t time_of_day_count = 0; + u32 time_of_day_count = 0; size_t max_num_grps = 0; size_t max_inds = 0; @@ -90,7 +90,7 @@ void Shrub::update_load(const LevelData* loader_data) { } max_num_grps = std::max(max_num_grps, num_grps); - time_of_day_count = std::max(tree.time_of_day_colors.size(), time_of_day_count); + time_of_day_count = std::max(tree.time_of_day_colors.color_count, time_of_day_count); max_inds = std::max(tree.indices.size(), max_inds); u32 verts = tree.unpacked.vertices.size(); glGenVertexArrays(1, &m_trees[l_tree].vao); @@ -107,7 +107,6 @@ void Shrub::update_load(const LevelData* loader_data) { } m_trees[l_tree].colors = &tree.time_of_day_colors; m_trees[l_tree].index_data = tree.indices.data(); - m_trees[l_tree].tod_cache = swizzle_time_of_day(tree.time_of_day_colors); glBindBuffer(GL_ARRAY_BUFFER, m_trees[l_tree].vertex_buffer); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); @@ -281,29 +280,21 @@ void Shrub::render_tree(int idx, return; } - if (m_color_result.size() < tree.colors->size()) { - m_color_result.resize(tree.colors->size()); + if (m_color_result.size() < tree.colors->color_count) { + m_color_result.resize(tree.colors->color_count); } Timer interp_timer; -#ifndef __aarch64__ - if (m_use_fast_time_of_day) { - interp_time_of_day_fast(settings.camera.itimes, tree.tod_cache, m_color_result.data()); - } else { - interp_time_of_day_slow(settings.camera.itimes, *tree.colors, m_color_result.data()); - } -#else - interp_time_of_day_slow(settings.itimes, *tree.colors, m_color_result.data()); -#endif + interp_time_of_day(settings.camera.itimes, *tree.colors, m_color_result.data()); tree.perf.tod_time.add(interp_timer.getSeconds()); Timer setup_timer; glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_1D, tree.time_of_day_texture); - glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->size(), GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, - m_color_result.data()); + glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->color_count, GL_RGBA, + GL_UNSIGNED_INT_8_8_8_8_REV, m_color_result.data()); - first_tfrag_draw_setup(settings, render_state, ShaderId::SHRUB); + first_tfrag_draw_setup(settings.camera, render_state, ShaderId::SHRUB); glBindVertexArray(tree.vao); glBindBuffer(GL_ARRAY_BUFFER, tree.vertex_buffer); diff --git a/game/graphics/opengl_renderer/background/Shrub.h b/game/graphics/opengl_renderer/background/Shrub.h index 37f10194b..e0a7950f4 100644 --- a/game/graphics/opengl_renderer/background/Shrub.h +++ b/game/graphics/opengl_renderer/background/Shrub.h @@ -39,9 +39,8 @@ class Shrub : public BucketRenderer { u32 vert_count; const std::vector* draws = nullptr; const std::vector* instance_info = nullptr; - const std::vector* colors = nullptr; + const tfrag3::PackedTimeOfDay* colors = nullptr; const u32* index_data = nullptr; - SwizzledTimeOfDay tod_cache; std::vector proto_vis_mask; std::unordered_map> proto_name_to_idx; @@ -70,7 +69,6 @@ class Shrub : public BucketRenderer { static constexpr int TIME_OF_DAY_COLOR_COUNT = 8192; bool m_has_level = false; - bool m_use_fast_time_of_day = true; struct Cache { std::vector> draw_idx_temp; diff --git a/game/graphics/opengl_renderer/background/TFragment.cpp b/game/graphics/opengl_renderer/background/TFragment.cpp index 73260e0d6..78b6c4772 100644 --- a/game/graphics/opengl_renderer/background/TFragment.cpp +++ b/game/graphics/opengl_renderer/background/TFragment.cpp @@ -267,7 +267,7 @@ void TFragment::update_load(const std::vector& tree_k m_cached_trees[geom].clear(); } - size_t time_of_day_count = 0; + u32 time_of_day_count = 0; size_t vis_temp_len = 0; size_t max_draws = 0; size_t max_num_grps = 0; @@ -287,7 +287,7 @@ void TFragment::update_load(const std::vector& tree_k } max_num_grps = std::max(max_num_grps, num_grps); max_inds = std::max(tree.unpacked.indices.size(), max_inds); - time_of_day_count = std::max(tree.colors.size(), time_of_day_count); + time_of_day_count = std::max(tree.colors.color_count, time_of_day_count); u32 verts = tree.packed_vertices.vertices.size(); glGenVertexArrays(1, &tree_cache.vao); glBindVertexArray(tree_cache.vao); @@ -298,7 +298,6 @@ void TFragment::update_load(const std::vector& tree_k tree_cache.colors = &tree.colors; tree_cache.vis = &tree.bvh; tree_cache.index_data = tree.unpacked.indices.data(); - tree_cache.tod_cache = swizzle_time_of_day(tree.colors); tree_cache.draw_mode = tree.use_strips ? GL_TRIANGLE_STRIP : GL_TRIANGLES; vis_temp_len = std::max(vis_temp_len, tree.bvh.vis_nodes.size()); glBindBuffer(GL_ARRAY_BUFFER, tree_cache.vertex_buffer); @@ -419,24 +418,16 @@ void TFragment::render_tree(int geom, ASSERT(tree.kind != tfrag3::TFragmentTreeKind::INVALID); - if (m_color_result.size() < tree.colors->size()) { - m_color_result.resize(tree.colors->size()); + if (m_color_result.size() < tree.colors->color_count) { + m_color_result.resize(tree.colors->color_count); } -#ifndef __aarch64__ - if (m_use_fast_time_of_day) { - interp_time_of_day_fast(settings.camera.itimes, tree.tod_cache, m_color_result.data()); - } else { - interp_time_of_day_slow(settings.camera.itimes, *tree.colors, m_color_result.data()); - } -#else - interp_time_of_day_slow(settings.itimes, *tree.colors, m_color_result.data()); -#endif + interp_time_of_day(settings.camera.itimes, *tree.colors, m_color_result.data()); glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_1D, tree.time_of_day_texture); - glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->size(), GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, - m_color_result.data()); + glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->color_count, GL_RGBA, + GL_UNSIGNED_INT_8_8_8_8_REV, m_color_result.data()); - first_tfrag_draw_setup(settings, render_state, ShaderId::TFRAG3); + first_tfrag_draw_setup(settings.camera, render_state, ShaderId::TFRAG3); glBindVertexArray(tree.vao); glBindBuffer(GL_ARRAY_BUFFER, tree.vertex_buffer); diff --git a/game/graphics/opengl_renderer/background/TFragment.h b/game/graphics/opengl_renderer/background/TFragment.h index 3c34d4331..1f1753cdf 100644 --- a/game/graphics/opengl_renderer/background/TFragment.h +++ b/game/graphics/opengl_renderer/background/TFragment.h @@ -122,10 +122,9 @@ class TFragment : public BucketRenderer { GLuint vao = -1; u32 vert_count = 0; const std::vector* draws = nullptr; - const std::vector* colors = nullptr; + const tfrag3::PackedTimeOfDay* colors = nullptr; const tfrag3::BVH* vis = nullptr; const u32* index_data = nullptr; - SwizzledTimeOfDay tod_cache; u64 draw_mode = 0; void reset_stats() { @@ -177,6 +176,5 @@ class TFragment : public BucketRenderer { std::vector m_debug_vert_data; bool m_has_level = false; - bool m_use_fast_time_of_day = true; const std::vector* m_anim_slot_array; }; diff --git a/game/graphics/opengl_renderer/background/Tie3.cpp b/game/graphics/opengl_renderer/background/Tie3.cpp index 4baea3023..3bb689bec 100644 --- a/game/graphics/opengl_renderer/background/Tie3.cpp +++ b/game/graphics/opengl_renderer/background/Tie3.cpp @@ -105,8 +105,6 @@ void Tie3::load_from_fr3_data(const LevelData* loader_data) { // wind metadata lod_tree[l_tree].instance_info = &tree.wind_instance_info; lod_tree[l_tree].wind_draws = &tree.instanced_wind_draws; - // preprocess colors for faster interpolation (TODO: move to loader) - lod_tree[l_tree].tod_cache = swizzle_time_of_day(tree.colors); // OpenGL index buffer (fixed index buffer for multidraw system) lod_tree[l_tree].index_buffer = loader_data->tie_data[l_geo][l_tree].index_buffer; lod_tree[l_tree].category_draw_indices = tree.category_draw_indices; @@ -423,24 +421,16 @@ void Tie3::setup_tree(int idx, } // update time of day - if (m_color_result.size() < tree.colors->size()) { - m_color_result.resize(tree.colors->size()); + if (m_color_result.size() < tree.colors->color_count) { + m_color_result.resize(tree.colors->color_count); } -#ifndef __aarch64__ - if (m_use_fast_time_of_day) { - interp_time_of_day_fast(settings.camera.itimes, tree.tod_cache, m_color_result.data()); - } else { - interp_time_of_day_slow(settings.camera.itimes, *tree.colors, m_color_result.data()); - } -#else - interp_time_of_day_slow(settings.itimes, *tree.colors, m_color_result.data()); -#endif + interp_time_of_day(settings.camera.itimes, *tree.colors, m_color_result.data()); glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_1D, tree.time_of_day_texture); - glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->size(), GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, - m_color_result.data()); + glTexSubImage1D(GL_TEXTURE_1D, 0, 0, tree.colors->color_count, GL_RGBA, + GL_UNSIGNED_INT_8_8_8_8_REV, m_color_result.data()); // update proto vis mask if (proto_vis_data) { @@ -546,7 +536,7 @@ void Tie3::draw_matching_draws_for_tree(int idx, auto shader_id = use_envmap ? ShaderId::ETIE_BASE : ShaderId::TFRAG3; // setup OpenGL shader - first_tfrag_draw_setup(settings, render_state, shader_id); + first_tfrag_draw_setup(settings.camera, render_state, shader_id); if (use_envmap) { // if we use envmap, use the envmap-style math for the base draw to avoid rounding issue. @@ -648,7 +638,7 @@ void Tie3::envmap_second_pass_draw(const Tree& tree, SharedRenderState* render_state, ScopedProfilerNode& prof, tfrag3::TieCategory category) { - first_tfrag_draw_setup(settings, render_state, ShaderId::ETIE); + first_tfrag_draw_setup(settings.camera, render_state, ShaderId::ETIE); glBindVertexArray(tree.vao); glBindBuffer(GL_ARRAY_BUFFER, tree.vertex_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, diff --git a/game/graphics/opengl_renderer/background/Tie3.h b/game/graphics/opengl_renderer/background/Tie3.h index 27075c003..ba8ee5385 100644 --- a/game/graphics/opengl_renderer/background/Tie3.h +++ b/game/graphics/opengl_renderer/background/Tie3.h @@ -115,10 +115,9 @@ class Tie3 : public BucketRenderer { const std::vector* draws = nullptr; const std::vector* wind_draws = nullptr; const std::vector* instance_info = nullptr; - const std::vector* colors = nullptr; + const tfrag3::PackedTimeOfDay* colors = nullptr; const tfrag3::BVH* vis = nullptr; const u32* index_data = nullptr; - SwizzledTimeOfDay tod_cache; std::vector> wind_matrix_cache; GLuint wind_vertex_index_buffer; std::vector wind_vertex_index_offsets; diff --git a/game/graphics/opengl_renderer/background/background_common.cpp b/game/graphics/opengl_renderer/background/background_common.cpp index 3e51e04f0..d3e85fb0d 100644 --- a/game/graphics/opengl_renderer/background/background_common.cpp +++ b/game/graphics/opengl_renderer/background/background_common.cpp @@ -171,7 +171,7 @@ DoubleDraw setup_tfrag_shader(SharedRenderState* render_state, DrawMode mode, Sh return draw_settings; } -void first_tfrag_draw_setup(const TfragRenderSettings& settings, +void first_tfrag_draw_setup(const GoalBackgroundCameraData& settings, SharedRenderState* render_state, ShaderId shader) { const auto& sh = render_state->shaders[shader]; @@ -180,24 +180,21 @@ void first_tfrag_draw_setup(const TfragRenderSettings& settings, glUniform1i(glGetUniformLocation(id, "gfx_hack_no_tex"), Gfx::g_global_settings.hack_no_tex); glUniform1i(glGetUniformLocation(id, "decal"), false); glUniform1i(glGetUniformLocation(id, "tex_T0"), 0); - glUniformMatrix4fv(glGetUniformLocation(id, "camera"), 1, GL_FALSE, - settings.camera.camera[0].data()); - glUniform4f(glGetUniformLocation(id, "hvdf_offset"), settings.camera.hvdf_off[0], - settings.camera.hvdf_off[1], settings.camera.hvdf_off[2], - settings.camera.hvdf_off[3]); - glUniform1f(glGetUniformLocation(id, "fog_constant"), settings.camera.fog.x()); - glUniform1f(glGetUniformLocation(id, "fog_min"), settings.camera.fog.y()); - glUniform1f(glGetUniformLocation(id, "fog_max"), settings.camera.fog.z()); + glUniformMatrix4fv(glGetUniformLocation(id, "camera"), 1, GL_FALSE, settings.camera[0].data()); + glUniform4f(glGetUniformLocation(id, "hvdf_offset"), settings.hvdf_off[0], settings.hvdf_off[1], + settings.hvdf_off[2], settings.hvdf_off[3]); + glUniform1f(glGetUniformLocation(id, "fog_constant"), settings.fog.x()); + glUniform1f(glGetUniformLocation(id, "fog_min"), settings.fog.y()); + glUniform1f(glGetUniformLocation(id, "fog_max"), settings.fog.z()); glUniform4f(glGetUniformLocation(id, "fog_color"), render_state->fog_color[0] / 255.f, render_state->fog_color[1] / 255.f, render_state->fog_color[2] / 255.f, render_state->fog_intensity / 255); } void interp_time_of_day_slow(const math::Vector itimes[4], - const std::vector& in, + const tfrag3::PackedTimeOfDay& in, math::Vector* out) { - // Timer interp_timer; - math::Vector4f weights[8]; + math::Vector weights[8]; for (int component = 0; component < 8; component++) { int quad_idx = component / 2; int word_off = (component % 2 * 2); @@ -208,78 +205,43 @@ void interp_time_of_day_slow(const math::Vector itimes[4], u32 word_val = itimes[quad_idx][word]; u32 hw_val = hw_off ? (word_val >> 16) : word_val; hw_val = hw_val & 0xff; - weights[component][channel] = hw_val / 64.f; + weights[component][channel] = hw_val; } } - for (size_t color = 0; color < in.size(); color++) { - math::Vector4f result = math::Vector4f::zero(); - for (int component = 0; component < 8; component++) { - for (int channel = 0; channel < 4; channel++) { - result[channel] += in[color].rgba[component][channel] * weights[component][channel]; - } - // result += in[color].rgba[component].cast() * weights[component]; + math::Vector temp[4]; + + for (u32 color_quad = 0; color_quad < (in.color_count + 3) / 4; color_quad++) { + for (auto& x : temp) { + x.set_zero(); } - result[0] = std::min(result[0], 255.f); - result[1] = std::min(result[1], 255.f); - result[2] = std::min(result[2], 255.f); - result[3] = std::min(result[3], 128.f); // note: different for alpha! - out[color] = result.cast(); - } -} - -// we want to absolutely minimize the number of time we have to "cross lanes" in AVX (meaning X -// component of one vector interacts with Y component of another). We can make this a lot better by -// taking groups of 4 time of day colors (each containing 8x RGBAs) and rearranging them with this -// pattern. We want to compute: -// [rgba][0][0] * weights[0] + [rgba][0][1] * weights[1] + [rgba][0][2]... + rgba[0][7] * weights[7] -// RGBA is already a vector of 4 components, but with AVX we have vectors with 32 bytes which fit -// 16 colors in them. - -// This makes each vector have: -// colors0 = [rgba][0][0], [rgba][1][0], [rgba][2][0], [rgba][3][0] -// colors1 = [rgba][0][1], [rgba][1][1], [rgba][2][1], [rgba][3][1] -// ... -// so we can basically add up the columns (multiplying by weights in between) -// and we'll end up with [final0, final1, final2, final3, final4] - -// the swizzle function below rearranges to get this pattern. -// it's not the most efficient way to do it, but it just runs during loading and not on every frame. - -SwizzledTimeOfDay swizzle_time_of_day(const std::vector& in) { - SwizzledTimeOfDay out; - out.data.resize((in.size() + 3) * 8 * 4); - - // we're rearranging per 4 colors (groups of 32 * 4 = 128) - // color (lots of these) - // component (8 of these) - // channel (4 of these, rgba) - - for (u32 color_quad = 0; color_quad < (in.size() + 3) / 4; color_quad++) { - u8* quad_out = out.data.data() + color_quad * 128; + const u8* input_ptr = in.data.data() + color_quad * 128; for (u32 component = 0; component < 8; component++) { for (u32 color = 0; color < 4; color++) { for (u32 channel = 0; channel < 4; channel++) { - size_t in_idx = color_quad * 4 + color; - if (in_idx < in.size()) { - *quad_out = in.at(color_quad * 4 + color).rgba[component][channel]; - } else { - *quad_out = 0; - } - quad_out++; + temp[color][channel] += weights[component][channel] * (*input_ptr); + input_ptr++; } } } + + for (u32 color = 0; color < 4; color++) { + auto& o = out[color_quad * 4 + color]; + for (u32 channel = 0; channel < 3; channel++) { + o[channel] = std::min(255, temp[color][channel] >> 6); + } + o[3] = std::min(128, temp[color][3] >> 6); + } } - out.color_count = (in.size() + 3) & (~3); - return out; } -#ifndef __aarch64__ -void interp_time_of_day_fast(const math::Vector itimes[4], - const SwizzledTimeOfDay& swizzled_colors, - math::Vector* out) { +void interp_time_of_day(const math::Vector itimes[4], + const tfrag3::PackedTimeOfDay& packed_colors, + math::Vector* out) { +#ifdef __aarch64__ + interp_time_of_day_slow(itimes, packed_colors, out); +#else math::Vector weights[8]; for (int component = 0; component < 8; component++) { int quad_idx = component / 2; @@ -318,11 +280,11 @@ void interp_time_of_day_fast(const math::Vector itimes[4], // change the shader to deal with this. __m128i sat = _mm_set_epi16(128, 255, 255, 255, 128, 255, 255, 255); - for (u32 color_quad = 0; color_quad < swizzled_colors.color_count / 4; color_quad++) { + for (u32 color_quad = 0; color_quad < packed_colors.color_count / 4; color_quad++) { // first, load colors. We put 16 bytes / register and don't touch the upper half because we // convert u8s to u16s. { - const u8* base = swizzled_colors.data.data() + color_quad * 128; + const u8* base = packed_colors.data.data() + color_quad * 128; __m128i color0_p = _mm_loadu_si64((const __m128i*)(base + 0)); __m128i color1_p = _mm_loadu_si64((const __m128i*)(base + 16)); __m128i color2_p = _mm_loadu_si64((const __m128i*)(base + 32)); @@ -377,7 +339,7 @@ void interp_time_of_day_fast(const math::Vector itimes[4], } { - const u8* base = swizzled_colors.data.data() + color_quad * 128 + 8; + const u8* base = packed_colors.data.data() + color_quad * 128 + 8; __m128i color0_p = _mm_loadu_si64((const __m128i*)(base + 0)); __m128i color1_p = _mm_loadu_si64((const __m128i*)(base + 16)); __m128i color2_p = _mm_loadu_si64((const __m128i*)(base + 32)); @@ -431,8 +393,8 @@ void interp_time_of_day_fast(const math::Vector itimes[4], _mm_storel_epi64((__m128i*)(&out[color_quad * 4 + 2]), result); } } -} #endif +} bool sphere_in_view_ref(const math::Vector4f& sphere, const math::Vector4f* planes) { math::Vector4f acc = diff --git a/game/graphics/opengl_renderer/background/background_common.h b/game/graphics/opengl_renderer/background/background_common.h index 0701853bb..6993ae6ac 100644 --- a/game/graphics/opengl_renderer/background/background_common.h +++ b/game/graphics/opengl_renderer/background/background_common.h @@ -43,26 +43,13 @@ struct DoubleDraw { DoubleDraw setup_tfrag_shader(SharedRenderState* render_state, DrawMode mode, ShaderId shader); DoubleDraw setup_opengl_from_draw_mode(DrawMode mode, u32 tex_unit, bool mipmap); -void first_tfrag_draw_setup(const TfragRenderSettings& settings, +void first_tfrag_draw_setup(const GoalBackgroundCameraData& settings, SharedRenderState* render_state, ShaderId shader); -void interp_time_of_day_slow(const math::Vector itimes[4], - const std::vector& in, - math::Vector* out); - -struct SwizzledTimeOfDay { - std::vector data; - u32 color_count = 0; -}; - -SwizzledTimeOfDay swizzle_time_of_day(const std::vector& in); - -#ifndef __aarch64__ -void interp_time_of_day_fast(const math::Vector itimes[4], - const SwizzledTimeOfDay& swizzled_colors, - math::Vector* out); -#endif +void interp_time_of_day(const math::Vector itimes[4], + const tfrag3::PackedTimeOfDay& packed_colors, + math::Vector* out); void cull_check_all_slow(const math::Vector4f* planes, const std::vector& nodes, diff --git a/game/graphics/opengl_renderer/buckets.h b/game/graphics/opengl_renderer/buckets.h index 9d174e3dc..fb667456a 100644 --- a/game/graphics/opengl_renderer/buckets.h +++ b/game/graphics/opengl_renderer/buckets.h @@ -419,6 +419,8 @@ enum class BucketId { TEX_LCOM_SKY_PRE = 4, OCEAN_MID_FAR = 6, + HFRAG = 8, + TEX_L0_TFRAG = 10, TFRAG_L0_TFRAG = 11, TIE_L0_TFRAG = 12, diff --git a/game/graphics/opengl_renderer/loader/Loader.cpp b/game/graphics/opengl_renderer/loader/Loader.cpp index 524c22533..e0d7bedda 100644 --- a/game/graphics/opengl_renderer/loader/Loader.cpp +++ b/game/graphics/opengl_renderer/loader/Loader.cpp @@ -9,16 +9,6 @@ #include "third-party/imgui/imgui.h" -namespace { -std::string uppercase_string(const std::string& s) { - std::string result; - for (auto c : s) { - result.push_back(toupper(c)); - } - return result; -} -} // namespace - Loader::Loader(const fs::path& base_path, int max_levels) : m_base_path(base_path), m_max_levels(max_levels) { m_loader_thread = std::thread(&Loader::loader_thread, this); @@ -52,6 +42,13 @@ const LevelData* Loader::get_tfrag3_level(const std::string& level_name) { } } +void Loader::debug_print_loaded_levels() { + std::unique_lock lk(m_loader_mutex); + for (const auto& [name, _] : m_loaded_tfrag3_levels) { + fmt::print("{}\n", name); + } +} + /*! * The game calls this to give the loader a hint on which levels we want. * If the loader is not busy, it will begin loading the level. @@ -493,6 +490,9 @@ void Loader::update(TexturePool& texture_pool) { } } + m_garbage_buffers.push_back(lev->hfrag_indices); + m_garbage_buffers.push_back(lev->hfrag_indices); + m_garbage_buffers.push_back(lev->collide_vertices); m_garbage_buffers.push_back(lev->merc_vertices); m_garbage_buffers.push_back(lev->merc_indices); diff --git a/game/graphics/opengl_renderer/loader/Loader.h b/game/graphics/opengl_renderer/loader/Loader.h index fc2de5186..a6fde8399 100644 --- a/game/graphics/opengl_renderer/loader/Loader.h +++ b/game/graphics/opengl_renderer/loader/Loader.h @@ -26,6 +26,7 @@ class Loader { void set_active_levels(const std::vector& levels); std::vector get_in_use_levels(); void draw_debug_window(); + void debug_print_loaded_levels(); private: void loader_thread(); diff --git a/game/graphics/opengl_renderer/loader/LoaderStages.cpp b/game/graphics/opengl_renderer/loader/LoaderStages.cpp index 7c6c8621c..0e3dfcab3 100644 --- a/game/graphics/opengl_renderer/loader/LoaderStages.cpp +++ b/game/graphics/opengl_renderer/loader/LoaderStages.cpp @@ -552,6 +552,73 @@ class StallLoaderStage : public LoaderStage { int m_count = 0; }; +class HfragLoaderStage : public LoaderStage { + public: + HfragLoaderStage() : LoaderStage("hfrag") {} + void reset() override { + m_done = false; + m_opengl = false; + m_vtx_uploaded = false; + m_idx = 0; + } + + bool run(Timer&, LoaderInput& data) override { + if (m_done) { + return true; + } + + if (!m_opengl) { + glGenBuffers(1, &data.lev_data->hfrag_indices); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.lev_data->hfrag_indices); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, + data.lev_data->level->hfrag.indices.size() * sizeof(u32), nullptr, + GL_STATIC_DRAW); + + glGenBuffers(1, &data.lev_data->hfrag_vertices); + glBindBuffer(GL_ARRAY_BUFFER, data.lev_data->hfrag_vertices); + glBufferData(GL_ARRAY_BUFFER, + data.lev_data->level->hfrag.vertices.size() * sizeof(tfrag3::HfragmentVertex), + nullptr, GL_STATIC_DRAW); + m_opengl = true; + } + + if (!m_vtx_uploaded) { + u32 start = m_idx; + m_idx = std::min(start + 32768, (u32)data.lev_data->level->hfrag.indices.size()); + glBindBuffer(GL_ARRAY_BUFFER, data.lev_data->hfrag_indices); + glBufferSubData(GL_ARRAY_BUFFER, start * sizeof(u32), (m_idx - start) * sizeof(u32), + data.lev_data->level->hfrag.indices.data() + start); + if (m_idx != data.lev_data->level->hfrag.indices.size()) { + return false; + } else { + m_idx = 0; + m_vtx_uploaded = true; + } + } + + u32 start = m_idx; + m_idx = std::min(start + 32768, (u32)data.lev_data->level->hfrag.vertices.size()); + glBindBuffer(GL_ARRAY_BUFFER, data.lev_data->hfrag_vertices); + glBufferSubData(GL_ARRAY_BUFFER, start * sizeof(tfrag3::HfragmentVertex), + (m_idx - start) * sizeof(tfrag3::HfragmentVertex), + data.lev_data->level->hfrag.vertices.data() + start); + + if (m_idx != data.lev_data->level->hfrag.vertices.size()) { + return false; + } else { + m_done = true; + return true; + } + return true; + } + + private: + bool m_done = false; + bool m_opengl = false; + bool m_vtx_uploaded = false; + u32 m_idx = 0; +}; + MercLoaderStage::MercLoaderStage() : LoaderStage("merc") {} void MercLoaderStage::reset() { m_done = false; @@ -622,6 +689,7 @@ std::vector> make_loader_stages() { ret.push_back(std::make_unique()); ret.push_back(std::make_unique()); ret.push_back(std::make_unique()); + ret.push_back(std::make_unique()); ret.push_back(std::make_unique()); return ret; } diff --git a/game/graphics/opengl_renderer/loader/common.h b/game/graphics/opengl_renderer/loader/common.h index 2f5173bb5..31424bb09 100644 --- a/game/graphics/opengl_renderer/loader/common.h +++ b/game/graphics/opengl_renderer/loader/common.h @@ -28,6 +28,9 @@ struct LevelData { GLuint merc_indices; std::unordered_map merc_model_lookup; + GLuint hfrag_vertices; + GLuint hfrag_indices; + int frames_since_last_used = 0; }; diff --git a/game/graphics/opengl_renderer/shaders/hfrag.frag b/game/graphics/opengl_renderer/shaders/hfrag.frag new file mode 100644 index 000000000..fc6bdbce5 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/hfrag.frag @@ -0,0 +1,23 @@ +#version 410 core + +out vec4 color; + +in vec4 fragment_color; +in vec2 tex_coord; +in float fogginess; +uniform sampler2D tex_T0; +uniform vec4 fog_color; + +uniform int gfx_hack_no_tex; + + +void main() { + if (gfx_hack_no_tex == 0) { + vec4 T0 = texture(tex_T0, tex_coord); + color = fragment_color * T0 * 2; + } else { + color = fragment_color; + } + + color.rgb = mix(color.rgb, fog_color.rgb, clamp(fogginess * fog_color.a, 0, 1)); +} diff --git a/game/graphics/opengl_renderer/shaders/hfrag.vert b/game/graphics/opengl_renderer/shaders/hfrag.vert new file mode 100644 index 000000000..be46fe4e5 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/hfrag.vert @@ -0,0 +1,56 @@ +#version 410 core + +layout (location = 0) in float position_in; +layout (location = 1) in int time_of_day_index; +layout (location = 2) in ivec2 uv; +layout (location = 3) in int vi; + +uniform vec4 hvdf_offset; +uniform mat4 camera; +uniform float fog_constant; +uniform float fog_min; +uniform float fog_max; +uniform sampler1D tex_T10; // note, sampled in the vertex shader on purpose. +// uniform int decal; +uniform float fog_hack_threshold; + +out vec4 fragment_color; +out vec2 tex_coord; +out float fogginess; + +void main() { + int vx = vi % 512; + int vz = vi / 512; + + tex_coord.x = (uv.x == 1) ? 1.f : 0.f; + tex_coord.y = (uv.y == 1) ? 1.f : 0.f; + + vec4 transformed = -camera[3]; + transformed -= camera[0] * 32768.f * vx; + transformed -= camera[1] * position_in; + transformed -= camera[2] * 32768.f * vz; + + float Q = fog_constant / transformed.w; + + fogginess = 255 - clamp(-transformed.w + hvdf_offset.w, fog_min, fog_max); + + transformed.xyz *= Q; + // offset + transformed.xyz += hvdf_offset.xyz; + // correct xy offset + transformed.xy -= (2048.); + // correct z scale + transformed.z /= (8388608); + transformed.z -= 1; + // correct xy scale + transformed.x /= (256); + transformed.y /= -(128); + transformed.xyz *= transformed.w; + // scissoring area adjust + transformed.y *= SCISSOR_ADJUST * HEIGHT_SCALE; + gl_Position = transformed; + + // time of day lookup + fragment_color = texelFetch(tex_T10, time_of_day_index, 0); + fragment_color.a = 1.0; +} diff --git a/game/graphics/opengl_renderer/shaders/hfrag_montage.frag b/game/graphics/opengl_renderer/shaders/hfrag_montage.frag new file mode 100644 index 000000000..900522a40 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/hfrag_montage.frag @@ -0,0 +1,8 @@ +#version 410 core +out vec4 color; +in vec2 uv; +uniform sampler2D tex_T0; +void main() { + color = texture(tex_T0, uv); + color.a = 1; +} \ No newline at end of file diff --git a/game/graphics/opengl_renderer/shaders/hfrag_montage.vert b/game/graphics/opengl_renderer/shaders/hfrag_montage.vert new file mode 100644 index 000000000..a1b4b4316 --- /dev/null +++ b/game/graphics/opengl_renderer/shaders/hfrag_montage.vert @@ -0,0 +1,11 @@ +#version 410 core + +layout (location = 0) in vec2 pos; +layout (location = 1) in vec2 tex_coord; + +out vec2 uv; + +void main() { + gl_Position = vec4(pos.x * 2 - 1, pos.y * 2 - 1, 0, 1); + uv = tex_coord; +} diff --git a/game/overlord/jak2/srpc.cpp b/game/overlord/jak2/srpc.cpp index 23ccec273..3571c10f9 100644 --- a/game/overlord/jak2/srpc.cpp +++ b/game/overlord/jak2/srpc.cpp @@ -370,7 +370,8 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) { lg::error("RPC Player dgo cancel command received"); } break; default: - ASSERT_MSG(false, fmt::format("Unhandled RPC Player command {}", int(cmd->j2command))); + // ASSERT_MSG(false, fmt::format("Unhandled RPC Player command {}", int(cmd->j2command))); + lg::error("Unhandled Jak2 RPC Player command {}\n", int(cmd->j2command)); } n_messages--; diff --git a/goal_src/goal-lib.gc b/goal_src/goal-lib.gc index 4bf9e8e74..36da959ae 100644 --- a/goal_src/goal-lib.gc +++ b/goal_src/goal-lib.gc @@ -597,8 +597,8 @@ "Increments a value" `(1+ ,val)) -(defmacro +! (place amount) - `(set! ,place (+ ,place ,amount)) +(defmacro +! (place &rest args) + `(set! ,place (+ ,place ,@args)) ) (defmacro 1+! (place) diff --git a/goal_src/jak3/engine/collide/collide-cache.gc b/goal_src/jak3/engine/collide/collide-cache.gc index f33bf26ef..8031a5afe 100644 --- a/goal_src/jak3/engine/collide/collide-cache.gc +++ b/goal_src/jak3/engine/collide/collide-cache.gc @@ -197,7 +197,7 @@ (when (= (-> v1-15 status) 'active) (let ((a0-6 (-> v1-15 bsp hfrag-drawable))) (if (nonzero? a0-6) - (hfragment-method-17 (the-as hfragment a0-6) this arg0) + (bounding-box-query (the-as hfragment a0-6) this arg0) ) ) ) @@ -491,7 +491,7 @@ (when (= (-> v1-36 status) 'active) (let ((a0-18 (-> v1-36 bsp hfrag-drawable))) (if (nonzero? a0-18) - (hfragment-method-18 (the-as hfragment a0-18) this arg0) + (line-sphere-query (the-as hfragment a0-18) this arg0) ) ) ) diff --git a/goal_src/jak3/engine/draw/drawable.gc b/goal_src/jak3/engine/draw/drawable.gc index 3fac0133a..7c7523f46 100644 --- a/goal_src/jak3/engine/draw/drawable.gc +++ b/goal_src/jak3/engine/draw/drawable.gc @@ -277,7 +277,7 @@ Yes it says instance. No it does not return an instance." (let ((s5-0 (-> arg1 bsp drawable-trees))) (dotimes (s4-0 (-> s5-0 length)) - (let ((v1-3 (-> s5-0 data s4-0))) + (let ((v1-3 (-> s5-0 trees s4-0))) (case (-> v1-3 type) ((drawable-tree-instance-shrub) (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub))) @@ -349,7 +349,7 @@ (when (or (not arg2) (= a3-4 arg2)) (let ((a3-5 (-> a3-4 drawable-trees))) (dotimes (t0-5 (-> a3-5 length)) - (let ((t1-3 (-> a3-5 data t0-5))) + (let ((t1-3 (-> a3-5 trees t0-5))) (case (-> t1-3 type) ((drawable-tree-instance-shrub) (when (= arg0 (-> t1-3 type)) @@ -412,7 +412,7 @@ (format #t "-------- level ~S~%" (-> s5-0 name)) (let ((s5-1 (-> s5-0 bsp drawable-trees))) (dotimes (s4-0 (-> s5-1 length)) - (let ((v1-8 (-> s5-1 data s4-0))) + (let ((v1-8 (-> s5-1 trees s4-0))) (case (-> v1-8 type) ((drawable-tree-instance-shrub) (let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub))) @@ -527,7 +527,7 @@ (when (= (-> v1-5 status) 'active) (let ((s3-0 (-> v1-5 bsp drawable-trees))) (dotimes (s2-0 (-> s3-0 length)) - (let ((v1-9 (-> s3-0 data s2-0))) + (let ((v1-9 (-> s3-0 trees s2-0))) (case (-> v1-9 type) ((drawable-tree-instance-shrub) ) @@ -2017,7 +2017,7 @@ (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) ) (default-init-buffer - (bucket-id bucket8) + (bucket-id hfrag) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) ) diff --git a/goal_src/jak3/engine/gfx/background/background.gc b/goal_src/jak3/engine/gfx/background/background.gc index 406418cc1..72e37904a 100644 --- a/goal_src/jak3/engine/gfx/background/background.gc +++ b/goal_src/jak3/engine/gfx/background/background.gc @@ -5,12 +5,12 @@ ;; name in dgo: background ;; dgos: GAME -(defun add-pc-tfrag3-data ((dma-buf dma-buffer) (lev level)) +(defun add-pc-tfrag3-data ((dma-buf dma-buffer) (lev level) (imm int)) "Add PC-port specific tfrag data" (let ((packet (the-as dma-packet (-> dma-buf base)))) (set! (-> packet dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc 25)) (set! (-> packet vif0) (new 'static 'vif-tag)) - (set! (-> packet vif1) (new 'static 'vif-tag :cmd (vif-cmd pc-port))) + (set! (-> packet vif1) (new 'static 'vif-tag :cmd (vif-cmd pc-port) :imm imm)) (set! (-> dma-buf base) (the pointer (&+ packet 16))) ) @@ -89,6 +89,31 @@ (&+! (-> dma-buf base) (* 16 25)) ) +(defun pc-should-draw-hfrag ((lev level)) + (and lev + (= (-> lev status) 'active) + (nonzero? (-> lev bsp hfrag-drawable)) + (= (-> lev display?) 'display) + ) + ) + +(defun pc-draw-hfrags () + "Generate DMA for all hfrag levels" + (with-profiler 'hfrag *profile-hfrag-color* + (with-dma-buffer-add-bucket ((dma-buf (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hfrag) + ) + (dotimes (i (-> *level* draw-level-count)) + (let ((lev (-> *level* draw-level i))) + (when (pc-should-draw-hfrag lev) + (add-pc-tfrag3-data dma-buf lev i) + ) + ) + ) + ) + ) + ) + ;; DECOMP BEGINS (define *background-work* (new 'global 'background-work)) @@ -539,31 +564,34 @@ 0 ) ) - (dotimes (gp-6 (-> *level* draw-level-count)) - (let ((s5-10 (-> *level* draw-level gp-6))) - (when (and s5-10 (= (-> s5-10 status) 'active)) - (when (and (nonzero? (-> s5-10 bsp hfrag-drawable)) (= (-> s5-10 display?) 'display)) - (with-profiler 'hfrag *profile-hfrag-color* - (set! *draw-index* (-> s5-10 draw-index)) - (let ((s4-9 (-> *display* frames (-> *display* on-screen) global-buf base))) - (draw (-> s5-10 bsp hfrag-drawable)) - (let ((v1-293 *dma-mem-usage*)) - (when (nonzero? v1-293) - (set! (-> v1-293 length) (max 44 (-> v1-293 length))) - (set! (-> v1-293 data 43 name) "hfragment") - (+! (-> v1-293 data 43 count) 1) - (+! (-> v1-293 data 43 used) - (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint s4-9)) - ) - (set! (-> v1-293 data 43 total) (-> v1-293 data 43 used)) - ) - ) - ) - ) - ) - ) - ) - ) + + ;; og::preserve-this PC version of hfrag (see hfrag.gc) + (pc-draw-hfrags) + ; (dotimes (gp-6 (-> *level* draw-level-count)) + ; (let ((s5-10 (-> *level* draw-level gp-6))) + ; (when (and s5-10 (= (-> s5-10 status) 'active)) + ; (when (and (nonzero? (-> s5-10 bsp hfrag-drawable)) (= (-> s5-10 display?) 'display)) + ; (with-profiler 'hfrag *profile-hfrag-color* + ; (set! *draw-index* (-> s5-10 draw-index)) + ; (let ((s4-9 (-> *display* frames (-> *display* on-screen) global-buf base))) + ; (draw (-> s5-10 bsp hfrag-drawable)) + ; (let ((v1-293 *dma-mem-usage*)) + ; (when (nonzero? v1-293) + ; (set! (-> v1-293 length) (max 44 (-> v1-293 length))) + ; (set! (-> v1-293 data 43 name) "hfragment") + ; (+! (-> v1-293 data 43 count) 1) + ; (+! (-> v1-293 data 43 used) + ; (&- (-> *display* frames (-> *display* on-screen) global-buf base) (the-as uint s4-9)) + ; ) + ; (set! (-> v1-293 data 43 total) (-> v1-293 data 43 used)) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) + ; ) (let ((a0-139 (-> *display* frames (-> *display* on-screen) global-buf))) (when (< (-> a0-139 real-buffer-end) (the-as int (-> a0-139 base))) (break!) diff --git a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-h.gc b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-h.gc index ff78260ab..7b0b912fa 100644 --- a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-h.gc +++ b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-h.gc @@ -22,10 +22,10 @@ (deftype hfrag-bucket (structure) - ((next uint32) + ((next pointer) (count uint16) (vertex-count uint16) - (next-scissor uint32) + (next-scissor pointer) (count-scissor uint16) (vertex-count-scissor uint16) ) @@ -33,7 +33,8 @@ (deftype hfrag-packed-index (uint16) - ((bit11 uint8 :offset 11 :size 5) + ((color uint16 :offset 0 :size 11) + (bit11 uint8 :offset 11 :size 5) ) ) @@ -41,6 +42,7 @@ ((height uint16) (packed-index hfrag-packed-index) ) + :pack-me ) @@ -64,6 +66,7 @@ (deftype hfrag-poly9 (structure) ((data hfrag-vert-index 9 :inline) ) + :pack-me ) @@ -71,6 +74,7 @@ (deftype hfrag-poly25 (structure) ((data hfrag-vert-index 25 :inline) ) + :pack-me ) @@ -141,6 +145,7 @@ (deftype hfrag-init-packet (structure) ((init-tmpl dma-packet :inline) (init-data uint32 8) + (init-vif vif-tag :overlay-at (-> init-data 7)) ) ) @@ -171,14 +176,14 @@ (deftype hfrag-tex-data (structure) - ((quad qword 3 :inline) - (prims uint64 6 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> quad 0 data 2)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (tex0 uint64 :overlay-at (-> quad 0 data 0)) - (tex1 uint64 :overlay-at (-> prims 2)) - (texflush uint64 :overlay-at (-> prims 4)) + ((quad qword 3 :inline) + (prims uint64 6 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) + (tex1 gs-tex1 :overlay-at (-> prims 2)) + (texflush uint64 :overlay-at (-> prims 4)) ) ) @@ -213,16 +218,16 @@ (deftype hfrag-frame (structure) - ((quad qword 4 :inline :offset 0) - (prims uint64 8 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> prims 1)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (reg-3 uint8 :overlay-at (-> prims 7)) - (frame uint64 :overlay-at (-> prims 0)) - (scissor uint64 :overlay-at (-> prims 2)) - (xyoffset uint64 :overlay-at (-> prims 4)) - (test uint64 :overlay-at (-> prims 6)) + ((quad qword 4 :inline :offset 0) + (prims uint64 8 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> prims 1)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (frame gs-frame :overlay-at (-> prims 0)) + (scissor gs-scissor :overlay-at (-> prims 2)) + (xyoffset gs-xy-offset :overlay-at (-> prims 4)) + (test gs-test :overlay-at (-> prims 6)) ) ) @@ -236,14 +241,14 @@ (deftype hfragment (drawable) ((start-corner vector :inline) - (spheres uint32) - (visids uint32) + (spheres (inline-array vector)) + (visids (pointer int16)) (shaders (inline-array adgif-shader)) - (colors basic) + (colors time-of-day-palette) (montage uint32) - (buckets-far uint32) - (buckets-mid uint32) - (buckets-near uint32) + (buckets-far (inline-array hfrag-bucket)) + (buckets-mid (inline-array hfrag-bucket)) + (buckets-near (inline-array hfrag-bucket)) (verts (inline-array hfrag-vertex)) (pat-array (pointer pat-surface)) (pat-length uint16) @@ -253,11 +258,11 @@ (size uint32 :overlay-at (-> start-corner data 3)) ) (:methods - (hfragment-method-17 (_type_ collide-cache collide-query) none) - (hfragment-method-18 (_type_ collide-cache collide-query) none) - (hfragment-method-19 (_type_ collide-cache collide-query int int int int) none) - (hfragment-method-20 (_type_ collide-cache int int uint uint uint pat-surface) none) - (hfragment-method-21 (_type_ collide-cache int int uint uint uint pat-surface) none) + (bounding-box-query (_type_ collide-cache collide-query) none) + (line-sphere-query (_type_ collide-cache collide-query) none) + (add-tri-to-collide-cache (_type_ collide-cache collide-query int int int int) none) + (add-tri-a-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) + (add-tri-b-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) ) ) @@ -287,75 +292,75 @@ (deftype hfrag-work (structure) - ((far-chaina dma-packet 6 :inline) - (far-chainb dma-packet 6 :inline) - (mid-chaina dma-packet 10 :inline) - (mid-chainb dma-packet 10 :inline) - (near-chaina dma-packet 18 :inline) - (near-chainb dma-packet 18 :inline) - (poly4-tmpl dma-packet 3 :inline) - (poly9-tmpl dma-packet 3 :inline) - (poly25-tmpl dma-packet 3 :inline) - (init-tmpl dma-packet 3 :inline) - (control-tmpl dma-packet 2 :inline :offset 1376) - (heights4-tmpl dma-packet 2 :inline) - (colors4-tmpl dma-packet 2 :inline) - (heights9-tmpl dma-packet 2 :inline) - (colors9-tmpl dma-packet 2 :inline) - (heights25-tmpl dma-packet 2 :inline) - (colors25-tmpl dma-packet 2 :inline) - (init-vu1-tmpl dma-packet 2 :inline) - (next-tmpl dma-packet :inline :offset 1696) - (call-tmpl dma-packet :inline) - (ret-tmpl dma-packet :inline) - (next-scissor-tmpl dma-packet :inline) - (ret-scissor-tmpl dma-packet :inline) - (frame-tmpl dma-gif-packet :inline) - (frames hfrag-frame 5 :inline) - (adgif-tmpl dma-gif-packet :inline) - (adgif-tmpl2 dma-gif-packet :inline) - (sprite-tmpl dma-gif-packet :inline) - (mip-tmpl dma-gif-packet :inline) - (color uint128 6) - (far-data hfrag-sprite-coord :inline) - (near-data vector4w-2 16 :inline) - (mip-data vector4w-3 7 :inline :offset 2896) - (tex-data hfrag-tex-data 5 :offset 3120) - (tex uint128 6 :offset 3360) - (montage-tex-coords uint128 128 :offset 3456) - (giftag generic-gif-tag :inline :offset 7552) - (call-abort dma-packet :inline) - (call-abort-vu1 dma-packet :inline) - (shader-far adgif-shader :inline) - (shader-mid adgif-shader :inline) - (shader-near adgif-shader :inline) - (stq uint128 9) - (shader adgif-shader :inline) - (constants vector :inline) - (pos-temp vector4w :inline) - (trans-temp vector :inline :overlay-at (-> pos-temp data 0)) - (dists vector :inline) - (rdists vector :inline) - (call-poly4-near uint32) - (call-poly9-mid uint32) - (call-poly9-near uint32) - (call-poly25-far uint32) - (call-poly25-mid uint32) + ((far-chaina dma-packet 6 :inline) + (far-chainb dma-packet 6 :inline) + (mid-chaina dma-packet 10 :inline) + (mid-chainb dma-packet 10 :inline) + (near-chaina dma-packet 18 :inline) + (near-chainb dma-packet 18 :inline) + (poly4-tmpl dma-packet 3 :inline) + (poly9-tmpl dma-packet 3 :inline) + (poly25-tmpl dma-packet 3 :inline) + (init-tmpl hfrag-init-packet 3 :inline) + (control-tmpl dma-packet 2 :inline) + (heights4-tmpl dma-packet 2 :inline) + (colors4-tmpl dma-packet 2 :inline) + (heights9-tmpl dma-packet 2 :inline) + (colors9-tmpl dma-packet 2 :inline) + (heights25-tmpl dma-packet 2 :inline) + (colors25-tmpl dma-packet 2 :inline) + (init-vu1-tmpl hfrag-init-packet 2 :inline) + (next-tmpl dma-packet :inline) + (call-tmpl dma-packet :inline) + (ret-tmpl dma-packet :inline) + (next-scissor-tmpl dma-packet :inline) + (ret-scissor-tmpl dma-packet :inline) + (frame-tmpl dma-gif-packet :inline) + (frames hfrag-frame 5 :inline) + (adgif-tmpl dma-gif-packet :inline) + (adgif-tmpl2 dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (mip-tmpl dma-gif-packet :inline) + (color vector4w 6 :inline) + (far-data hfrag-sprite-coord :inline) + (near-data vector4w-2 16 :inline) + (mip-data vector4w-2 7 :inline) + (tex-data hfrag-tex-data 5 :inline) + (tex vector 6 :inline) + (montage-tex-coords hfrag-montage-coord 128 :inline :offset 3456) + (giftag generic-gif-tag :inline :offset 7552) + (call-abort dma-packet :inline) + (call-abort-vu1 dma-packet :inline) + (shader-far adgif-shader :inline) + (shader-mid adgif-shader :inline) + (shader-near adgif-shader :inline) + (stq vector4w 9 :inline) + (shader adgif-shader :inline) + (constants vector :inline) + (pos-temp vector4w :inline) + (trans-temp vector :inline :overlay-at (-> pos-temp data 0)) + (dists vector :inline) + (rdists vector :inline) + (call-poly4-near vif-tag) + (call-poly9-mid vif-tag) + (call-poly9-near vif-tag) + (call-poly25-far vif-tag) + (call-poly25-mid vif-tag) (dma-buffer basic) (base uint32) (wait-to-spr uint32) (wait-from-spr uint32) (buffer-end uint32) (subdiv-index uint32) - (scissor basic) + (scissor symbol) (chain-ptr uint32) (chain-ptr-next uint32) (near-dist float) (far-dist float) (to-spr uint32) (from-spr uint32) - (lowres-flag basic) - (hfrag hfragment :inline) + (lowres-flag symbol) + (hfrag hfragment :inline) (next-far int16) (next-far-mid int16) (next-mid int16) @@ -382,42 +387,42 @@ (size-near-scissor int32) (size-texture int32) (poly-far hfrag-poly25) - (poly-mid25 uint32) - (poly-mid uint32) - (poly-near uint32) - (far-texture uint32) - (near-textures uint16 16) - (draw-table uint16 1024 :offset 8456) - (corners uint128 1024) + (poly-mid25 (inline-array hfrag-poly25)) + (poly-mid (inline-array hfrag-poly9)) + (poly-near (inline-array hfrag-poly9)) + (far-texture pointer) + (near-textures uint16 16) + (draw-table int16 1024 :offset 8456) + (corners vector 1024 :inline) ) (:methods - (hfrag-work-method-9 () none) - (hfrag-work-method-10 () none) - (hfrag-work-method-11 () none) - (hfrag-work-method-12 () none) - (hfrag-work-method-13 () none) - (hfrag-work-method-14 () none) - (hfrag-work-method-15 () none) - (hfrag-work-method-16 () none) - (hfrag-work-method-17 () none) - (hfrag-work-method-18 () none) + (initialize-renderer! (_type_) none) + (init-work-from-current-hfrag! (_type_) none) + (pick-level-of-detail! (_type_ level) none) + (generate-vertices! (_type_) none) + (finalize-dma! (_type_) none) + (setup-far-vertex-index! (_type_ hfrag-vert-index int int) none) + (setup-mid-vertex-index! (_type_ hfrag-vert-index int int) none) + (setup-near-vertex-index! (_type_ hfrag-vert-index int int) none) + (init-montage-tex-coords (_type_) none) + (asm-far-scissor (_type_ dma-buffer int) none) (hfrag-work-method-19 () none) (hfrag-work-method-20 () none) - (hfrag-work-method-21 () none) + (asm-near-mid-scissor (_type_ dma-buffer int) none) (hfrag-work-method-22 () none) - (hfrag-work-method-23 () none) - (hfrag-work-method-24 () none) - (hfrag-work-method-25 () none) - (hfrag-work-method-26 () none) - (hfrag-work-method-27 () none) - (hfrag-work-method-28 () none) - (hfrag-work-method-29 () none) - (hfrag-work-method-30 () none) - (hfrag-work-method-31 () none) - (hfrag-work-method-32 () none) - (hfrag-work-method-33 () none) - (hfrag-work-method-34 () none) - (hfrag-work-method-35 () none) + (generate-montage-texture (_type_) none) + (hfrag-work-method-24 (_type_ dma-buffer) none) + (hfrag-work-method-25 (_type_ dma-buffer) none) + (hfrag-work-method-26 (_type_ dma-buffer) none) + (asm-far (_type_ dma-buffer int) none) + (asm-far-mid (_type_ dma-buffer int) none) + (asm-mid (_type_ dma-buffer int) none) + (asm-near-mid (_type_ dma-buffer int) none) + (asm-near (_type_ dma-buffer int) none) + (hfrag-work-method-32 (_type_ dma-buffer) none) + (hfrag-work-method-33 (_type_ dma-buffer) none) + (hfrag-work-method-34 (_type_ dma-buffer) none) + (trim-dma-to-fit-in-memory (_type_) none) ) ) diff --git a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1-h.gc b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1-h.gc index 29a132c37..c32e4f191 100644 --- a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1-h.gc +++ b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1-h.gc @@ -5,5 +5,111 @@ ;; name in dgo: hfrag-vu1-h ;; dgos: HGA, WIN, DST +(declare-type hfrag-vu1-constants-base structure) +(define-extern *hfrag-vu1-constants-base* hfrag-vu1-constants-base) + ;; DECOMP BEGINS +(deftype hfrag-vu1-poly4-packet (structure) + ((height-tag dma-packet :inline) + (base vector :inline) + (heights uint32 4) + (color-tag dma-packet :inline) + (colors rgba 4) + (next dma-packet :inline) + ) + ) + + +(deftype hfrag-vu1-poly9-packet (structure) + ((height-tag dma-packet :inline) + (base vector3 :inline) + (heights uint32 9) + (color-tag dma-packet :inline) + (colors rgba 12) + (next dma-packet :inline) + (jump-index int32 :overlay-at (-> base data 1)) + ) + ) + + +(deftype hfrag-vu1-poly25-packet (structure) + ((height-tag dma-packet :inline) + (base vector3 :inline) + (heights uint32 25) + (color-tag dma-packet :inline) + (colors rgba 28) + (next dma-packet :inline) + ) + ) + + +(deftype hfrag-vu1-vertex (structure) + ((tex vector :inline) + (clr vector :inline) + (pos vector :inline) + ) + ) + + +(deftype hfrag-vu1-poly4 (structure) + ((giftag vector :inline) + (verts hfrag-vu1-vertex 4 :inline) + ) + ) + + +(deftype hfrag-vu1-poly9 (structure) + ((giftag0 vector :inline) + (verts0 hfrag-vu1-vertex 6 :inline) + (giftag1 vector :inline) + (verts1 hfrag-vu1-vertex 6 :inline) + ) + ) + + +(deftype hfrag-vu1-poly25 (structure) + ((giftag0 vector :inline) + (verts0 hfrag-vu1-vertex 10 :inline) + (giftag1 vector :inline) + (verts1 hfrag-vu1-vertex 10 :inline) + (giftag2 vector :inline) + (verts2 hfrag-vu1-vertex 10 :inline) + (giftag3 vector :inline) + (verts3 hfrag-vu1-vertex 10 :inline) + ) + ) + + +(deftype hfrag-vu1-constants-base (structure) + ((far-verts vector 25 :inline) + (mid-verts9 vector 9 :inline) + (mid-verts25 vector 25 :inline) + (near-verts4 vector 4 :inline) + (near-verts9 vector 9 :inline) + (sts vector 9 :inline) + (data vector 81 :inline :overlay-at (-> far-verts 0)) + ) + ) + + +(deftype hfrag-vu1-constants (structure) + ((base hfrag-vu1-constants-base :inline) + (far-verts vector 25 :inline :overlay-at (-> base far-verts 0)) + (mid-verts9 vector 9 :inline :overlay-at (-> base mid-verts9 0)) + (mid-verts25 vector 25 :inline :overlay-at (-> base mid-verts25 0)) + (near-verts4 vector 4 :inline :overlay-at (-> base near-verts4 0)) + (near-verts9 vector 9 :inline :overlay-at (-> base near-verts9 0)) + (sts vector 9 :inline :overlay-at (-> base sts 0)) + (drw-strip4 gs-gif-tag :inline) + (drw-strip9-0 gs-gif-tag :inline) + (drw-strip9-1 gs-gif-tag :inline) + (drw-strip25-0 gs-gif-tag :inline) + (drw-strip25-1 gs-gif-tag :inline) + (matrix matrix :inline) + (hvdf-offset vector :inline) + (hmge-scale vector :inline) + (fog vector :inline) + (stores qword :inline) + ) + ) diff --git a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1.gc b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1.gc index 220449b45..969a66063 100644 --- a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1.gc +++ b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-vu1.gc @@ -7,3 +7,366 @@ ;; DECOMP BEGINS +(define hfrag-vu1-block (new 'static 'vu-function :length #x7ec :qlength #x3f6)) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; WARN: Return type mismatch vector vs none. +(defun hfrag-setup-constants ((arg0 hfrag-vu1-constants)) + (let ((gp-0 *math-camera*)) + (let ((v1-0 *hfrag-vu1-constants-base*)) + (dotimes (a0-1 81) + (set! (-> arg0 base far-verts a0-1 quad) (-> v1-0 far-verts a0-1 quad)) + ) + ) + (case *subdivide-draw-mode* + (((subdivide-setting textured)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting outline)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting gouraud)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting hack)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + ) + ) + (set! (-> arg0 drw-strip4 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip9-0 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip9-1 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip25-0 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip25-1 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (mem-copy! (the-as pointer (-> arg0 matrix)) (the-as pointer (-> gp-0 camera-temp)) 64) + (set! (-> arg0 hvdf-offset quad) (-> gp-0 hvdf-off quad)) + (set! (-> arg0 hmge-scale quad) (-> gp-0 hmge-scale quad)) + (set-vector! (-> arg0 fog) (-> gp-0 pfog0) (-> gp-0 fog-min) (-> gp-0 fog-max) 3072.0) + ) + (none) + ) + +;; WARN: Return type mismatch pointer vs none. +(defun hfrag-add-constants ((arg0 dma-buffer)) + (let* ((a1-0 94) + (v1-0 arg0) + (a0-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a1-0)) + (set! (-> a0-1 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x189 :cmd (vif-cmd unpack-v4-32) :num a1-0)) + (set! (-> v1-0 base) (the-as pointer (&+ a0-1 16))) + ) + (hfrag-setup-constants (the-as hfrag-vu1-constants (-> arg0 base))) + (&+! (-> arg0 base) 1504) + (none) + ) + +(defun hfrag-vu1-end-buffer ((arg0 dma-buffer)) + (let* ((v1-0 arg0) + (a1-0 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a1-0 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-0 vif0) (new 'static 'vif-tag :cmd (vif-cmd stmask))) + (set! (-> a1-0 vif1) (new 'static 'vif-tag)) + (set! (-> v1-0 base) (the-as pointer (&+ a1-0 16))) + ) + (let* ((v1-1 arg0) + (a1-2 (the-as (pointer vif-tag) (-> v1-1 base))) + ) + (set! (-> a1-2 0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x20)) + (set! (-> a1-2 1) (new 'static 'vif-tag :cmd (vif-cmd stmod))) + (set! (-> a1-2 2) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> a1-2 3) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1)) + (set! (-> a1-2 4) (new 'static 'vif-tag)) + (set! (-> a1-2 5) (new 'static 'vif-tag)) + (set! (-> a1-2 6) (new 'static 'vif-tag)) + (set! (-> a1-2 7) (new 'static 'vif-tag)) + (set! (-> v1-1 base) (&-> a1-2 8)) + ) + (dma-buffer-add-gs-set arg0 (test-1 (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)))) + 0 + (none) + ) + +(defun hfrag-vu1-init-buf () + (let ((v1-0 *display*) + (a0-5 (+ (* (+ (/ (-> hfrag-vu1-block qlength) 127) 1) 16) 1568)) + ) + (+! (-> v1-0 mem-reserve-size) a0-5) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((a2-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> a2-0 real-buffer-end) (the-as int (&+ (-> a2-0 base) a0-5))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) bucket-group 8))) + (when (!= gp-0 (-> gp-0 last)) + (let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-3 (-> s4-0 base)) + ) + (dma-buffer-add-vu-function s4-0 hfrag-vu1-block 1) + (hfrag-add-constants s4-0) + (let* ((v1-14 s4-0) + (a0-13 (the-as dma-packet (-> v1-14 base))) + ) + (set! (-> a0-13 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a0-13 vif0) (new 'static 'vif-tag)) + (set! (-> a0-13 vif1) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1)) + (set! (-> v1-14 base) (the-as pointer (&+ a0-13 16))) + ) + (let* ((v1-15 s4-0) + (a0-15 (-> v1-15 base)) + ) + (set! (-> (the-as (pointer uint32) a0-15) 0) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 1) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 2) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 3) (the-as uint 0)) + (set! (-> (the-as (pointer vif-tag) a0-15) 4) (new 'static 'vif-tag :cmd (vif-cmd base))) + (set! (-> (the-as (pointer vif-tag) a0-15) 5) (new 'static 'vif-tag :cmd (vif-cmd offset))) + (set! (-> (the-as (pointer vif-tag) a0-15) 6) (new 'static 'vif-tag :cmd (vif-cmd stmod))) + (set! (-> (the-as (pointer vif-tag) a0-15) 7) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x22)) + (set! (-> v1-15 base) (&+ a0-15 32)) + ) + (let ((v1-16 (the-as dma-packet (-> s4-0 base)))) + (set! (-> v1-16 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-0 next))) + (set! (-> v1-16 vif0) (new 'static 'vif-tag)) + (set! (-> v1-16 vif1) (new 'static 'vif-tag)) + (set! (-> s4-0 base) (the-as pointer (&+ v1-16 16))) + ) + (set! (-> gp-0 next) (the-as uint s5-3)) + ) + ) + ) + ) + ) + ) + (let ((v1-18 *display*) + (a0-19 96) + ) + (+! (-> v1-18 mem-reserve-size) a0-19) + (when (not (-> v1-18 dma-buffer-overflow)) + (let ((a2-6 (-> v1-18 frames (-> v1-18 on-screen) global-buf))) + (if (< (-> a2-6 real-buffer-end) (the-as int (&+ (-> a2-6 base) a0-19))) + (set! (-> v1-18 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-18 dma-buffer-overflow)) + (let ((gp-1 (-> *display* frames (-> *display* on-screen) bucket-group 8))) + (when (!= gp-1 (-> gp-1 last)) + (let* ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-4 (-> s4-1 base)) + ) + (hfrag-vu1-end-buffer s4-1) + (let ((a1-31 (-> s4-1 base))) + (let ((v1-32 (the-as dma-packet (-> s4-1 base)))) + (set! (-> v1-32 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-32 vif0) (new 'static 'vif-tag)) + (set! (-> v1-32 vif1) (new 'static 'vif-tag)) + (set! (-> s4-1 base) (the-as pointer (&+ v1-32 16))) + ) + (set! (-> (the-as (pointer uint32) (-> gp-1 last)) 1) (the-as uint s5-4)) + (set! (-> gp-1 last) (the-as (pointer dma-tag) a1-31)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-work.gc b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-work.gc index d3ff48f07..075335d0f 100644 --- a/goal_src/jak3/engine/gfx/background/hfrag/hfrag-work.gc +++ b/goal_src/jak3/engine/gfx/background/hfrag/hfrag-work.gc @@ -7,3 +7,942 @@ ;; DECOMP BEGINS +(defmethod setup-far-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((v1-3 (* (+ (* 20 arg1) (* arg2 4)) 4)) + (a0-2 (* arg2 32)) + (a2-1 (* arg1 32)) + ) + (set! (-> arg0 index0) (the-as uint v1-3)) + (set! (-> arg0 index1) (the-as uint v1-3)) + (set! (-> arg0 index2) (the-as uint v1-3)) + (set! (-> arg0 pos x) (the-as uint a0-2)) + (set! (-> arg0 pos y) (the-as uint a2-1)) + ) + 0 + (none) + ) + +(defmethod setup-mid-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((t1-0 (* (+ (* 20 arg1) (* arg2 2)) 4)) + (v1-3 (* arg2 16)) + (a0-2 (* arg1 16)) + ) + (let ((t0-2 (logior (* (logand arg1 1) 2) (logand arg2 1)))) + (set! (-> arg0 index0) (the-as uint t1-0)) + (cond + ((zero? t0-2) + (set! (-> arg0 index1) (the-as uint t1-0)) + (set! (-> arg0 index2) (the-as uint t1-0)) + ) + ((= t0-2 1) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 arg1) (* (+ arg2 -1) 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 arg1) (* (+ arg2 1) 2)) 4))) + ) + ((= t0-2 2) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) (* arg2 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) (* arg2 2)) 4))) + ) + ((= t0-2 3) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) (* (+ arg2 1) 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) (* (+ arg2 -1) 2)) 4))) + ) + ) + ) + (set! (-> arg0 pos x) (the-as uint v1-3)) + (set! (-> arg0 pos y) (the-as uint a0-2)) + ) + 0 + (none) + ) + +(defmethod setup-near-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((t1-0 (* (+ (* 20 arg1) arg2) 4)) + (v1-3 (* arg2 8)) + (a0-1 (* arg1 8)) + ) + (let ((t0-2 (logior (* (logand arg1 1) 2) (logand arg2 1)))) + (set! (-> arg0 index0) (the-as uint t1-0)) + (cond + ((zero? t0-2) + (set! (-> arg0 index1) (the-as uint t1-0)) + (set! (-> arg0 index2) (the-as uint t1-0)) + ) + ((= t0-2 1) + (set! (-> arg0 index1) (the-as uint (* (+ arg2 -1 (* 20 arg1)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ arg2 1 (* 20 arg1)) 4))) + ) + ((= t0-2 2) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) arg2) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) arg2) 4))) + ) + ((= t0-2 3) + (set! (-> arg0 index1) (the-as uint (* (+ arg2 1 (* 20 (+ arg1 -1))) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ arg2 -1 (* 20 (+ arg1 1))) 4))) + ) + ) + ) + (set! (-> arg0 pos x) (the-as uint v1-3)) + (set! (-> arg0 pos y) (the-as uint a0-1)) + ) + 0 + (none) + ) + +(defmethod init-montage-tex-coords ((this hfrag-work)) + (let ((f0-0 0.0)) + (dotimes (v1-0 8) + (dotimes (a1-0 16) + (let ((a2-4 (-> this montage-tex-coords (+ (* v1-0 16) a1-0)))) + (set-vector! (-> a2-4 stq0) (* 0.0625 (+ (the float a1-0) f0-0)) (* 0.125 (+ (the float v1-0) f0-0)) 1.0 0.0) + (set-vector! + (-> a2-4 stq1) + (* 0.0625 (- (the float (+ a1-0 1)) f0-0)) + (* 0.125 (- (the float (+ v1-0 1)) f0-0)) + 1.0 + 0.0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod initialize-renderer! ((this hfrag-work)) + (set! (-> this poly-far) (new 'loading-level 'hfrag-poly25)) + (set! (-> this poly-mid25) (the-as (inline-array hfrag-poly25) (malloc 'loading-level 800))) + (set! (-> this poly-mid) (the-as (inline-array hfrag-poly9) (malloc 'loading-level 1152))) + (set! (-> this poly-near) (the-as (inline-array hfrag-poly9) (malloc 'loading-level 4608))) + (set! (-> this init-vu1-tmpl 0 init-vif) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2c)) + (set! (-> this init-vu1-tmpl 1 init-vif) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2c)) + (set! (-> this call-abort-vu1 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x20)) + (set! (-> this call-poly4-near) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2e)) + (set! (-> this call-poly9-mid) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x14b)) + (set! (-> this call-poly9-near) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x14f)) + (set! (-> this call-poly25-far) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x7d)) + (set! (-> this call-poly25-mid) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x7f)) + (set! (-> this next-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> this ret-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (let ((s5-0 (-> this poly-far))) + (cond + ((nonzero? s5-0) + (dotimes (s4-0 5) + (dotimes (s3-0 5) + (let ((v1-21 (+ (* 5 s3-0) s4-0))) + (setup-far-vertex-index! this (-> s5-0 data v1-21) s4-0 s3-0) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-far table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-1 (-> this poly-mid25))) + (cond + ((nonzero? s5-1) + (dotimes (s4-1 2) + (dotimes (s3-1 2) + (let ((s2-0 (-> s5-1 (+ (* s4-1 2) s3-1))) + (s1-0 (* s4-1 4)) + (s0-0 (* s3-1 4)) + ) + (setup-mid-vertex-index! this (the-as hfrag-vert-index (-> s2-0 data)) s1-0 s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 1) (+ s1-0 1) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 2) (+ s1-0 2) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 3) (+ s1-0 3) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 4) (+ s1-0 4) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 5) s1-0 (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 6) (+ s1-0 1) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 7) (+ s1-0 2) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 8) (+ s1-0 3) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 9) (+ s1-0 4) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 10) s1-0 (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 11) (+ s1-0 1) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 12) (+ s1-0 2) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 13) (+ s1-0 3) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 14) (+ s1-0 4) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 15) s1-0 (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 16) (+ s1-0 1) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 17) (+ s1-0 2) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 18) (+ s1-0 3) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 19) (+ s1-0 4) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 20) s1-0 (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 21) (+ s1-0 1) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 22) (+ s1-0 2) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 23) (+ s1-0 3) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 24) (+ s1-0 4) (+ s0-0 4)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-far table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-2 (-> this poly-mid))) + (cond + ((nonzero? s5-2) + (dotimes (s4-2 4) + (dotimes (s3-2 4) + (let ((s2-1 (-> s5-2 (+ (* s4-2 4) s3-2))) + (s1-1 (* s4-2 2)) + (s0-1 (* s3-2 2)) + ) + (setup-mid-vertex-index! this (the-as hfrag-vert-index (-> s2-1 data)) s1-1 s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 1) (+ s1-1 1) s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 2) (+ s1-1 2) s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 3) s1-1 (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 4) (+ s1-1 1) (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 5) (+ s1-1 2) (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 6) s1-1 (+ s0-1 2)) + (setup-mid-vertex-index! this (-> s2-1 data 7) (+ s1-1 1) (+ s0-1 2)) + (setup-mid-vertex-index! this (-> s2-1 data 8) (+ s1-1 2) (+ s0-1 2)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-mid table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-3 (-> this poly-near))) + (cond + ((nonzero? s5-3) + (dotimes (s4-3 8) + (dotimes (s3-3 8) + (let ((s2-2 (-> s5-3 (+ (* s4-3 8) s3-3))) + (s1-2 (* s4-3 2)) + (s0-2 (* s3-3 2)) + ) + (setup-near-vertex-index! this (the-as hfrag-vert-index (-> s2-2 data)) s1-2 s0-2) + (setup-near-vertex-index! this (-> s2-2 data 1) (+ s1-2 1) s0-2) + (setup-near-vertex-index! this (-> s2-2 data 2) (+ s1-2 2) s0-2) + (setup-near-vertex-index! this (-> s2-2 data 3) s1-2 (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 4) (+ s1-2 1) (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 5) (+ s1-2 2) (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 6) s1-2 (+ s0-2 2)) + (setup-near-vertex-index! this (-> s2-2 data 7) (+ s1-2 1) (+ s0-2 2)) + (setup-near-vertex-index! this (-> s2-2 data 8) (+ s1-2 2) (+ s0-2 2)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-near table~%") + (break!) + 0 + ) + ) + ) + (let ((f1-0 (-> this near-dist)) + (f0-0 (-> this far-dist)) + ) + (let ((f2-1 (* 0.14285715 (- f0-0 f1-0)))) + (set! (-> this dists x) (- f1-0)) + (set! (-> this dists y) (- (+ f1-0 (* 0.5 f2-1)))) + (set! (-> this dists z) (- (+ f1-0 (* 2.0 f2-1)))) + ) + (set! (-> this dists w) (- f0-0)) + ) + (set! (-> this rdists x) (/ 1.0 (-> this dists x))) + (set! (-> this rdists y) (/ 1.0 (-> this dists y))) + (set! (-> this rdists z) (/ 1.0 (-> this dists z))) + (set! (-> this rdists w) (/ 1.0 (-> this dists w))) + (init-montage-tex-coords this) + 0 + (none) + ) + +(define *hfrag-work* + (new 'static 'hfrag-work + :far-chaina (new 'static 'inline-array dma-packet 6 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :far-chainb (new 'static 'inline-array dma-packet 6 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :mid-chaina (new 'static 'inline-array dma-packet 10 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :mid-chainb (new 'static 'inline-array dma-packet 10 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :near-chaina (new 'static 'inline-array dma-packet 18 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :near-chainb (new 'static 'inline-array dma-packet 18 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :poly4-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + ) + :poly9-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :poly25-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :init-tmpl (new 'static 'inline-array hfrag-init-packet 3 + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x117 #x0 #x0 #x0 #x1500000c) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x22e #x0 #x0 #x0 #x1500000c) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x0 #x0 #x0 #x0 #x1500000c) + ) + ) + :control-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x345 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x363 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + ) + :heights4-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x2 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x2 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors4-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #x4 :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #x4 :cmd (vif-cmd unpack-v4-8)) + ) + ) + :heights9-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x3 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x3 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors9-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #xc :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #xc :cmd (vif-cmd unpack-v4-8)) + ) + ) + :heights25-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x7 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x7 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors25-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #x1c :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #x1c :cmd (vif-cmd unpack-v4-8)) + ) + ) + :init-vu1-tmpl (new 'static 'inline-array hfrag-init-packet 2 + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x1e6 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x2a #x7 #x0 #x0 #x0 #x0) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x1e6 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #xe #x0 #x0 #x0 #x0 #x0) + ) + ) + :next-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))) + :call-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id call))) + :ret-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id ret))) + :next-scissor-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))) + :ret-scissor-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id ret))) + :frame-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008004 #xe) + ) + :frames (new 'static 'inline-array hfrag-frame 5 + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x6f :fbw #x2) + :scissor (new 'static 'gs-scissor :scax1 #x7f :scay1 #x7f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x77 :fbw #x1) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x3f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x79 :fbw #x1) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x1f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x79 :fbw #x1 :fbmsk #xff000000) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x1f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x198 :fbw #x8) + :scissor (new 'static 'gs-scissor :scax1 #x1ff :scay1 #x19f) + :xyoffset (new 'static 'gs-xy-offset :ofx #x7000 :ofy #x7300) + :test (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) + ) + ) + :adgif-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008005 #xe) + ) + :adgif-tmpl2 (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008006 #xe) + ) + :sprite-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x500b400000008001 #x52521) + ) + :mip-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x9 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x802f400000008001 #x52521eee) + ) + :color (new 'static 'inline-array vector4w 6 + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x70) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 88) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 64) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 32) + (new 'static 'vector4w) + ) + :far-data (new 'static 'hfrag-sprite-coord + :pos0 (new 'static 'vector4w :z #xffffff) + :pos1 (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + :near-data (new 'static 'inline-array vector4w-2 16 + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x800 :z #xffffff) + ) + ) + ) + :mip-data (new 'static 'inline-array vector4w-2 7 + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :z #xffffff) + (new 'static 'vector4w :x #x300 :y #x100 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x300 :z #xffffff) + (new 'static 'vector4w :x #x380 :y #x80 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x380 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x80 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x300 :y #x80 :z #xffffff) + (new 'static 'vector4w :x #x380 :y #x100 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + ) + ) + :tex-data (new 'static 'inline-array hfrag-tex-data 5 + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xde0 :tbw #x2 :tw #x7 :th #x7 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xee0 :tbw #x1 :tw #x6 :th #x6 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf20 :tbw #x1 :tw #x5 :th #x5 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf30 :tbw #x1 :tw #x4 :th #x4 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf34 :tbw #x1 :tw #x3 :th #x3 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + ) + :tex (new 'static 'inline-array vector 6 + (new 'static 'vector :z 1.0) + (new 'static 'vector :x 1.015625 :y 1.015625 :z 1.0) + (new 'static 'vector :x 1.03125 :y 1.03125 :z 1.0) + (new 'static 'vector :x 1.0625 :y 1.0625 :z 1.0) + (new 'static 'vector :x 1.125 :y 1.125 :z 1.0) + (new 'static 'vector :x 2.0 :y 2.0 :z 1.0) + ) + :giftag (new 'static 'generic-gif-tag + :fan-prim (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1 :abe #x1) + :nreg #x3 + ) + :str-prim (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1 :abe #x1) + :nreg #x3 + ) + :regs (new 'static 'gif-tag-regs-32 :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + :num-strips #x1 + ) + :call-abort (new 'static 'dma-packet + :dma (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif0 (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd mscalf) :msk #x1) + ) + :call-abort-vu1 (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id cnt))) + :shader-far (new 'static 'adgif-shader + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg miptbp1-1) + :reg-3 (gs-reg clamp-1) + :reg-4 (gs-reg miptbp2-1) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf20 :tbw #x1 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mxl #x1 :k #xfb1) + :clamp (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + :shader-near (new 'static 'adgif-shader + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg miptbp1-1) + :reg-3 (gs-reg clamp-1) + :reg-4 (gs-reg miptbp2-1) + :tex0 (new 'static 'gs-tex0 :tbp0 #xde0 :tbw #x2 :tw #x7 :th #x7 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mxl #x6 :mmag #x1 :mmin #x5 :k #xfbf) + :miptbp1 (new 'static 'gs-miptbp :tbp1 #xee0 :tbw1 #x1 :tbp2 #xf20 :tbw2 #x1 :tbp3 #xf30 :tbw3 #x1) + :clamp (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + :alpha (new 'static 'gs-miptbp :tbp1 #xf34 :tbw1 #x1 :tbp2 #xf35 :tbw2 #x1 :tbp3 #xf36) + ) + :stq (new 'static 'inline-array vector4w 9 + (new 'static 'vector4w :x 1) + (new 'static 'vector4w :x #x801) + (new 'static 'vector4w :x #x1001) + (new 'static 'vector4w :y #x800) + (new 'static 'vector4w :x #x800 :y #x800) + (new 'static 'vector4w :x #x1000 :y #x800) + (new 'static 'vector4w :y #x1000) + (new 'static 'vector4w :x #x800 :y #x1000) + (new 'static 'vector4w :x #x1000 :y #x1000) + ) + :constants (new 'static 'vector :x 0.5) + :near-dist 1228800.0 + :far-dist 4096000.0 + :lowres-flag #f + ) + ) + +(initialize-renderer! *hfrag-work*) + +(define *hfrag-vu1-constants-base* (new 'static 'hfrag-vu1-constants-base + :far-verts (new 'static 'inline-array vector 25 + (new 'static 'vector) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :z 262144.0) + (new 'static 'vector :z 393216.0) + (new 'static 'vector :z 524288.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 262144.0) + (new 'static 'vector :x 131072.0 :z 393216.0) + (new 'static 'vector :x 131072.0 :z 524288.0) + (new 'static 'vector :x 262144.0) + (new 'static 'vector :x 262144.0 :z 131072.0) + (new 'static 'vector :x 262144.0 :z 262144.0) + (new 'static 'vector :x 262144.0 :z 393216.0) + (new 'static 'vector :x 262144.0 :z 524288.0) + (new 'static 'vector :x 393216.0) + (new 'static 'vector :x 393216.0 :z 131072.0) + (new 'static 'vector :x 393216.0 :z 262144.0) + (new 'static 'vector :x 393216.0 :z 393216.0) + (new 'static 'vector :x 393216.0 :z 524288.0) + (new 'static 'vector :x 524288.0) + (new 'static 'vector :x 524288.0 :z 131072.0) + (new 'static 'vector :x 524288.0 :z 262144.0) + (new 'static 'vector :x 524288.0 :z 393216.0) + (new 'static 'vector :x 524288.0 :z 524288.0) + ) + :mid-verts9 (new 'static 'inline-array vector 9 + (new 'static 'vector) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + (new 'static 'vector :x 131072.0 :z 65536.0) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :x 65536.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + ) + :mid-verts25 (new 'static 'inline-array vector 25 + (new 'static 'vector) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :z 196608.0) + (new 'static 'vector :z 262144.0) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + (new 'static 'vector :x 65536.0 :z 131072.0) + (new 'static 'vector :x 65536.0 :z 196608.0) + (new 'static 'vector :x 65536.0 :z 262144.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :x 131072.0 :z 65536.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 196608.0) + (new 'static 'vector :x 131072.0 :z 262144.0) + (new 'static 'vector :x 196608.0) + (new 'static 'vector :x 196608.0 :z 65536.0) + (new 'static 'vector :x 196608.0 :z 131072.0) + (new 'static 'vector :x 196608.0 :z 196608.0) + (new 'static 'vector :x 196608.0 :z 262144.0) + (new 'static 'vector :x 262144.0) + (new 'static 'vector :x 262144.0 :z 65536.0) + (new 'static 'vector :x 262144.0 :z 131072.0) + (new 'static 'vector :x 262144.0 :z 196608.0) + (new 'static 'vector :x 262144.0 :z 262144.0) + ) + :near-verts4 (new 'static 'inline-array vector 4 + (new 'static 'vector) + (new 'static 'vector :x 32768.0) + (new 'static 'vector :z 32768.0) + (new 'static 'vector :x 32768.0 :z 32768.0) + ) + :near-verts9 (new 'static 'inline-array vector 9 + (new 'static 'vector) + (new 'static 'vector :x 32768.0) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :z 32768.0) + (new 'static 'vector :x 32768.0 :z 32768.0) + (new 'static 'vector :x 65536.0 :z 32768.0) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :x 32768.0 :z 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + ) + :sts (new 'static 'inline-array vector 9 + (new 'static 'vector :z 1.0) + (new 'static 'vector :x 0.5 :z 1.0) + (new 'static 'vector :x 1.0 :z 1.0) + (new 'static 'vector :y 0.5 :z 1.0) + (new 'static 'vector :x 0.5 :y 0.5 :z 1.0) + (new 'static 'vector :x 1.0 :y 0.5 :z 1.0) + (new 'static 'vector :y 1.0 :z 1.0) + (new 'static 'vector :x 0.5 :y 1.0 :z 1.0) + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0) + ) + ) + ) diff --git a/goal_src/jak3/engine/gfx/background/hfrag/hfrag.gc b/goal_src/jak3/engine/gfx/background/hfrag/hfrag.gc index 9b18f00f5..19b7c449f 100644 --- a/goal_src/jak3/engine/gfx/background/hfrag/hfrag.gc +++ b/goal_src/jak3/engine/gfx/background/hfrag/hfrag.gc @@ -5,17 +5,622 @@ ;; name in dgo: hfrag ;; dgos: HGA, WIN, DST +(define-extern *hfrag-work* hfrag-work) + ;; DECOMP BEGINS -(defmethod hfragment-method-20 ((this hfragment) - (arg0 collide-cache) - (arg1 int) - (arg2 int) - (arg3 uint) - (arg4 uint) - (arg5 uint) - (arg6 pat-surface) - ) +(defmethod init-work-from-current-hfrag! ((this hfrag-work)) + (let ((v1-0 (-> this hfrag))) + (set! (-> this lowres-flag) #f) + (dotimes (a1-0 (-> *level* length)) + (let ((a2-3 (-> *level* level a1-0))) + (when (= (-> a2-3 status) 'active) + (if (logtest? (-> a2-3 info level-flags) (level-flags low-res-hfrag)) + (set! (-> this lowres-flag) #t) + ) + ) + ) + ) + (let ((f0-0 (-> v1-0 start-corner x)) + (f1-0 (-> v1-0 start-corner z)) + ) + (dotimes (a1-3 32) + (dotimes (a2-9 32) + (let ((a3-6 (+ (* a1-3 32) a2-9))) + (set! (-> this corners a3-6 x) (+ f0-0 (* 524288.0 (the float a2-9)))) + (set! (-> this corners a3-6 y) 0.0) + (set! (-> this corners a3-6 z) (+ f1-0 (* 524288.0 (the float a1-3)))) + (set! (-> this corners a3-6 w) 1.0) + ) + ) + ) + ) + (let ((f0-1 (-> this near-dist)) + (f2-8 (-> this far-dist)) + (f1-1 819200.0) + ) + (set! (-> this dists x) (- f2-8)) + (set! (-> this dists y) (- f0-1)) + (set! (-> this rdists x) (/ 1.0 (- (- f2-8 (+ f0-1 f1-1))))) + (set! (-> this rdists y) (/ 1.0 (- (- f0-1 f1-1)))) + ) + (set! (-> this next-far) -1) + (set! (-> this next-far-mid) -1) + (set! (-> this next-mid) -1) + (set! (-> this next-near-mid) -1) + (set! (-> this next-near) -1) + (set! (-> this next-far-scissor) -1) + (set! (-> this next-near-mid-scissor) -1) + (set! (-> this next-near-scissor) -1) + (set! (-> this count-far) 0) + (set! (-> this count-far-mid) 0) + (set! (-> this count-mid) 0) + (set! (-> this count-near-mid) 0) + (set! (-> this count-near) 0) + (set! (-> this count-far-scissor) 0) + (set! (-> this count-near-mid-scissor) 0) + (set! (-> this count-near-scissor) 0) + (let ((a0-1 (-> v1-0 num-buckets-far))) + (dotimes (a1-18 (the-as int a0-1)) + (let ((a2-13 (-> v1-0 buckets-far a1-18))) + (set! (-> a2-13 next) (the-as pointer 0)) + (set! (-> a2-13 count) (the-as uint 0)) + (set! (-> a2-13 vertex-count) (the-as uint 32)) + (set! (-> a2-13 next-scissor) (the-as pointer 0)) + (set! (-> a2-13 count-scissor) (the-as uint 0)) + (set! (-> a2-13 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + (let ((a0-4 (-> v1-0 num-buckets-mid))) + (dotimes (a1-19 (the-as int a0-4)) + (let ((a2-15 (-> v1-0 buckets-mid a1-19))) + (set! (-> a2-15 next) (the-as pointer 0)) + (set! (-> a2-15 count) (the-as uint 0)) + (set! (-> a2-15 vertex-count) (the-as uint 32)) + (set! (-> a2-15 next-scissor) (the-as pointer 0)) + (set! (-> a2-15 count-scissor) (the-as uint 0)) + (set! (-> a2-15 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + (let ((a0-7 (-> v1-0 num-buckets-near))) + (dotimes (a1-20 (the-as int a0-7)) + (let ((a2-17 (-> v1-0 buckets-near a1-20))) + (set! (-> a2-17 next) (the-as pointer 0)) + (set! (-> a2-17 count) (the-as uint 0)) + (set! (-> a2-17 vertex-count) (the-as uint 32)) + (set! (-> a2-17 next-scissor) (the-as pointer 0)) + (set! (-> a2-17 count-scissor) (the-as uint 0)) + (set! (-> a2-17 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod pick-level-of-detail! ((this hfrag-work) (arg0 level)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf12 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (-> this hfrag)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + 0 + (let ((s4-0 *math-camera*)) + (vector-! s2-0 (camera-pos) (-> s5-0 start-corner)) + (+ (* (the int (* 0.0000019073486 (-> s2-0 y))) 32) (the int (* 0.0000019073486 (-> s2-0 x)))) + (.lvf vf16 (&-> s4-0 plane 0 quad)) + (.lvf vf17 (&-> s4-0 plane 1 quad)) + (.lvf vf18 (&-> s4-0 plane 2 quad)) + (.lvf vf19 (&-> s4-0 plane 3 quad)) + (.lvf vf20 (&-> s4-0 guard-plane 0 quad)) + (.lvf vf21 (&-> s4-0 guard-plane 1 quad)) + (.lvf vf22 (&-> s4-0 guard-plane 2 quad)) + (.lvf vf23 (&-> s4-0 guard-plane 3 quad)) + (.lvf vf24 (&-> s4-0 camera-rot rvec quad)) + (.lvf vf25 (&-> s4-0 camera-rot uvec quad)) + (.lvf vf26 (&-> s4-0 camera-rot fvec quad)) + (.lvf vf27 (&-> s4-0 camera-rot trans quad)) + (let ((s3-1 (+ (+ (- (-> arg0 bsp visible-list-length) (-> arg0 bsp extra-vis-list-length)) 0) + (the-as int (-> arg0 vis-bits)) + ) + ) + ) + (dotimes (s2-1 1024) + (let ((v1-13 (/ (-> s5-0 visids s2-1) 8)) + (a0-9 (ash 128 (- (logand (-> s5-0 visids s2-1) 7)))) + ) + (when (logtest? (-> (the-as (pointer uint8) (+ v1-13 (the-as int s3-1)))) a0-9) + (let ((s1-2 (-> s5-0 spheres s2-1))) + (when (sphere-cull s1-2) + (set! (-> this scissor) (guard-band-cull s1-2)) + (.lvf vf12 (&-> s1-2 quad)) + (.mul.x.vf acc vf24 vf12) + (.add.mul.y.vf acc vf25 vf12 acc) + (.add.mul.z.vf acc vf26 vf12 acc) + (.add.mul.w.vf vf12 vf27 vf0 acc) + (.svf (&-> this pos-temp quad) vf12) + (let* ((f0-6 (-> this trans-temp z)) + (f2-0 (-> s1-2 w)) + (f1-2 (+ f0-6 f2-0)) + (f0-7 (- f0-6 f2-0)) + (v1-20 0) + ) + (if (< f0-7 (-> s4-0 d)) + (set! (-> this scissor) #t) + ) + (if (< f1-2 (-> this far-dist)) + (set! v1-20 (logior v1-20 8)) + ) + (if (< f0-7 (-> this far-dist)) + (set! v1-20 (logior v1-20 4)) + ) + (if (< f1-2 (-> this near-dist)) + (set! v1-20 (logior v1-20 2)) + ) + (if (< f0-7 (-> this near-dist)) + (set! v1-20 (logior v1-20 1)) + ) + (set! (-> this subdiv-index) (the-as uint v1-20)) + ) + (cond + ((or (zero? (-> this subdiv-index)) (-> this lowres-flag)) + (cond + ((-> this scissor) + (set! (-> this draw-table s2-1) (-> this next-far-scissor)) + (set! (-> this next-far-scissor) s2-1) + (+! (-> this count-far-scissor) 1) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-far)) + (set! (-> this next-far) s2-1) + (+! (-> this count-far) 1) + ) + ) + ) + ((= (-> this subdiv-index) 4) + (set! (-> this draw-table s2-1) (-> this next-far-mid)) + (set! (-> this next-far-mid) s2-1) + (+! (-> this count-far-mid) 1) + ) + ((= (-> this subdiv-index) 12) + (set! (-> this draw-table s2-1) (-> this next-mid)) + (set! (-> this next-mid) s2-1) + (+! (-> this count-mid) 1) + ) + ((= (-> this subdiv-index) 13) + (cond + ((-> this scissor) + (set! (-> this draw-table s2-1) (-> this next-near-mid-scissor)) + (set! (-> this next-near-mid-scissor) s2-1) + (+! (-> this count-near-mid-scissor) 1) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-near-mid)) + (set! (-> this next-near-mid) s2-1) + (+! (-> this count-near-mid) 1) + ) + ) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-near)) + (set! (-> this next-near) s2-1) + (+! (-> this count-near) 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod generate-vertices! ((this hfrag-work)) + (local-vars (v1-1 float)) + (rlet ((vf13 :class vf) + (vf14 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf31 :class vf) + ) + (.lvf vf28 (&-> this constants quad)) + (.lvf vf13 (&-> this dists quad)) + (.lvf vf14 (&-> this rdists quad)) + (let ((v1-0 *math-camera*)) + (.lvf vf16 (&-> v1-0 camera-temp rvec quad)) + (.lvf vf17 (&-> v1-0 camera-temp uvec quad)) + (.lvf vf18 (&-> v1-0 camera-temp fvec quad)) + (.lvf vf19 (&-> v1-0 camera-temp trans quad)) + (.lvf vf24 (&-> v1-0 camera-rot rvec quad)) + (.lvf vf25 (&-> v1-0 camera-rot uvec quad)) + (.lvf vf26 (&-> v1-0 camera-rot fvec quad)) + (.lvf vf27 (&-> v1-0 camera-rot trans quad)) + (.lvf vf31 (&-> v1-0 hmge-scale quad)) + ) + (.mov v1-1 vf31) + (set! (-> this next-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> this ret-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (let ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag)) + (set! (-> this next-tmpl vif0) (-> this call-poly4-near)) + (set! (-> this ret-tmpl vif0) (-> this call-poly4-near)) + (if (>= (-> this next-near) 0) + (asm-near this s5-0 (-> this next-near)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly9-near)) + (set! (-> this ret-tmpl vif0) (-> this call-poly9-near)) + (if (>= (-> this next-near-mid) 0) + (asm-near-mid this s5-0 (-> this next-near-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly25-mid)) + (set! (-> this ret-tmpl vif0) (-> this call-poly25-mid)) + (if (>= (-> this next-mid) 0) + (asm-mid this s5-0 (-> this next-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly9-mid)) + (set! (-> this ret-tmpl vif0) (-> this call-poly9-mid)) + (if (>= (-> this next-far-mid) 0) + (asm-far-mid this s5-0 (-> this next-far-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly25-far)) + (set! (-> this ret-tmpl vif0) (-> this call-poly25-far)) + (if (>= (-> this next-far) 0) + (asm-far this s5-0 (-> this next-far)) + ) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag-scissor)) + (if (>= (-> this next-far-scissor) 0) + (asm-far-scissor this s5-0 (-> this next-far-scissor)) + ) + (if (>= (-> this next-near-mid-scissor) 0) + (asm-near-mid-scissor this s5-0 (-> this next-near-mid-scissor)) + ) + ) + ) + 0 + (none) + ) + ) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(defmethod finalize-dma! ((this hfrag-work)) + (local-vars (v1-40 float)) + (rlet ((vf10 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag)) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hfrag) + ) + (.lvf vf5 (&-> this tex-data 0 quad 2 quad)) + (.lvf vf6 (&-> this shader-far quad 0 quad)) + (.lvf vf7 (&-> this shader-far quad 1 quad)) + (.lvf vf8 (&-> this shader-far quad 2 quad)) + (.lvf vf9 (&-> this shader-far quad 3 quad)) + (.lvf vf10 (&-> this shader-far quad 4 quad)) + (hfrag-work-method-32 this s4-0) + (hfrag-work-method-33 this s4-0) + (.lvf vf6 (&-> this shader-near quad 0 quad)) + (.lvf vf7 (&-> this shader-near quad 1 quad)) + (.lvf vf8 (&-> this shader-near quad 2 quad)) + (.lvf vf9 (&-> this shader-near quad 3 quad)) + (.lvf vf10 (&-> this shader-near quad 4 quad)) + (hfrag-work-method-34 this s4-0) + ) + (hfrag-vu1-init-buf) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag-scissor)) + (case *subdivide-scissor-draw-mode* + (((subdivide-setting textured)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting outline)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting gouraud)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting hack)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + ) + (.lvf vf5 (&-> this giftag qword quad)) + (let ((v1-39 *math-camera*)) + (.lvf vf24 (&-> v1-39 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-39 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-39 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-39 camera-temp trans quad)) + ) + (.mov v1-40 vf27) + (with-dma-buffer-add-bucket ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hfrag-scissor) + ) + (.lvf vf6 (&-> this shader-far quad 0 quad)) + (.lvf vf7 (&-> this shader-far quad 1 quad)) + (.lvf vf8 (&-> this shader-far quad 2 quad)) + (.lvf vf9 (&-> this shader-far quad 3 quad)) + (.lvf vf10 (&-> this shader-far quad 4 quad)) + (hfrag-work-method-24 this s4-1) + (hfrag-work-method-25 this s4-1) + (.lvf vf6 (&-> this shader-near quad 0 quad)) + (.lvf vf7 (&-> this shader-near quad 1 quad)) + (.lvf vf8 (&-> this shader-near quad 2 quad)) + (.lvf vf9 (&-> this shader-near quad 3 quad)) + (.lvf vf10 (&-> this shader-near quad 4 quad)) + (hfrag-work-method-26 this s4-1) + ) + (generic-vu1-init-buf (bucket-id hfrag-scissor) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + ) + 0 + (none) + ) + ) + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; ERROR: function was not converted to expressions. Cannot decompile. + +(define *hfrag-debug* #t) + +(defmethod trim-dma-to-fit-in-memory ((this hfrag-work)) + (let* ((a1-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (v1-5 (-> a1-1 base)) + (v1-6 (&- (-> a1-1 end) (the-as uint v1-5))) + (a1-5 (+ #x110c0 + (* (+ (/ (-> generic-vu1-block qlength) 127) 1) 16) + (* (+ (/ (-> hfrag-vu1-block qlength) 127) 1) 16) + ) + ) + ) + (set! (-> this size-far) (* 272 (-> this count-far))) + (set! (-> this size-far-mid) (* 2304 (-> this count-far-mid))) + (set! (-> this size-mid) (* 1088 (-> this count-mid))) + (set! (-> this size-near-mid) (* 9216 (-> this count-near-mid))) + (set! (-> this size-near) (+ (* #x6000 (-> this count-near)) 1120)) + (set! (-> this size-far-scissor) (* 1952 (-> this count-far-scissor))) + (set! (-> this size-near-mid-scissor) (* #x9800 (-> this count-near-mid-scissor))) + (let ((v0-0 (+ a1-5 + (-> this size-far) + (-> this size-far-mid) + (-> this size-mid) + (-> this size-near-mid) + (-> this size-near) + (-> this size-far-scissor) + (-> this size-near-mid-scissor) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-19 (min (the int (* 0.0036764706 (the float (+ (- 272 v1-6) v0-0)))) (-> this count-far)))) + (set! (-> this count-far) (- (-> this count-far) a1-19)) + (set! (-> this size-far) (- (-> this size-far) (* 272 a1-19))) + (set! v0-0 (- v0-0 (* 272 a1-19))) + (let ((a3-11 (-> this next-far))) + (dotimes (a2-39 a1-19) + (set! a3-11 (-> this draw-table a3-11)) + ) + (set! (-> this next-far) a3-11) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-29 (min (the int (* 0.00043402778 (the float (+ (- 2304 v1-6) v0-0)))) (-> this count-far-mid)))) + (set! (-> this count-far-mid) (- (-> this count-far-mid) a1-29)) + (set! (-> this size-far-mid) (- (-> this size-far-mid) (* 2304 a1-29))) + (set! v0-0 (- v0-0 (* 2304 a1-29))) + (let ((a3-16 (-> this next-far-mid))) + (dotimes (a2-47 a1-29) + (set! a3-16 (-> this draw-table a3-16)) + ) + (set! (-> this next-far-mid) a3-16) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-39 (min (the int (* 0.00091911765 (the float (+ (- 1088 v1-6) v0-0)))) (-> this count-mid)))) + (set! (-> this count-mid) (- (-> this count-mid) a1-39)) + (set! (-> this size-mid) (- (-> this size-mid) (* 1088 a1-39))) + (set! v0-0 (- v0-0 (* 1088 a1-39))) + (let ((a3-21 (-> this next-mid))) + (dotimes (a2-55 a1-39) + (set! a3-21 (-> this draw-table a3-21)) + ) + (set! (-> this next-mid) a3-21) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-49 (min (the int (* 0.000108506945 (the float (+ (- 9216 v1-6) v0-0)))) (-> this count-near-mid)))) + (set! (-> this count-near-mid) (- (-> this count-near-mid) a1-49)) + (set! (-> this size-near-mid) (- (-> this size-near-mid) (* 9216 a1-49))) + (set! v0-0 (- v0-0 (* 9216 a1-49))) + (let ((a3-26 (-> this next-near-mid))) + (dotimes (a2-63 a1-49) + (set! a3-26 (-> this draw-table a3-26)) + ) + (set! (-> this next-near-mid) a3-26) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-59 (min (the int (* 0.000040690105 (the float (+ (- #x6000 v1-6) v0-0)))) (-> this count-near)))) + (set! (-> this count-near) (- (-> this count-near) a1-59)) + (set! (-> this size-near) (- (-> this size-near) (* #x6000 a1-59))) + (set! v0-0 (- v0-0 (* #x6000 a1-59))) + (let ((a3-31 (-> this next-near))) + (dotimes (a2-71 a1-59) + (set! a3-31 (-> this draw-table a3-31)) + ) + (set! (-> this next-near) a3-31) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-69 (min (the int (* 0.00051229505 (the float (+ (- 1952 v1-6) v0-0)))) (-> this count-far-scissor)))) + (set! (-> this count-far-scissor) (- (-> this count-far-scissor) a1-69)) + (set! (-> this size-far-scissor) (- (-> this size-far-scissor) (* 1952 a1-69))) + (set! v0-0 (- v0-0 (* 224 a1-69))) + (let ((a3-36 (-> this next-far-scissor))) + (dotimes (a2-79 a1-69) + (set! a3-36 (-> this draw-table a3-36)) + ) + (set! (-> this next-far-scissor) a3-36) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((v1-11 + (min (the int (* 0.000025699013 (the float (+ (- #x9800 v1-6) v0-0)))) (-> this count-near-mid-scissor)) + ) + ) + (set! (-> this count-near-mid-scissor) (- (-> this count-near-mid-scissor) v1-11)) + (set! (-> this size-near-mid-scissor) (- (-> this size-near-mid-scissor) (* #x9800 v1-11))) + (- v0-0 (* #x9800 v1-11)) + (let ((a2-82 (-> this next-near-mid-scissor))) + (dotimes (a1-82 v1-11) + (set! a2-82 (-> this draw-table a2-82)) + ) + (set! (-> this next-near-mid-scissor) a2-82) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod draw ((this hfragment)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (let ((gp-0 *hfrag-work*)) + (let ((s4-0 (-> *level* draw-level *draw-index*))) + (mem-copy! (&-> (-> gp-0 hfrag) type) (&-> this type) 96) + (init-work-from-current-hfrag! gp-0) + (pick-level-of-detail! gp-0 s4-0) + (trim-dma-to-fit-in-memory gp-0) + (time-of-day-interp-colors-scratch + (the-as (pointer rgba) (+ #x3000 #x70000000)) + (-> this colors) + (-> s4-0 mood-context) + ) + ) + (generate-vertices! gp-0) + (generate-montage-texture gp-0) + (finalize-dma! gp-0) + ) + (set-dirty-mask! (the-as level (-> *level* level)) 10 #x1a000 #xf4000) + 0 + (none) + ) + +(defmethod add-tri-a-xy-zzz-to-collide-cache ((this hfragment) + (arg0 collide-cache) + (arg1 int) + (arg2 int) + (arg3 uint) + (arg4 uint) + (arg5 uint) + (arg6 pat-surface) + ) (let ((v1-0 (-> arg0 num-tris))) (cond ((>= v1-0 460) @@ -44,15 +649,15 @@ (none) ) -(defmethod hfragment-method-21 ((this hfragment) - (arg0 collide-cache) - (arg1 int) - (arg2 int) - (arg3 uint) - (arg4 uint) - (arg5 uint) - (arg6 pat-surface) - ) +(defmethod add-tri-b-xy-zzz-to-collide-cache ((this hfragment) + (arg0 collide-cache) + (arg1 int) + (arg2 int) + (arg3 uint) + (arg4 uint) + (arg5 uint) + (arg6 pat-surface) + ) (let ((v1-0 (-> arg0 num-tris))) (cond ((>= v1-0 460) @@ -81,7 +686,7 @@ (none) ) -(defmethod hfragment-method-19 ((this hfragment) (arg0 collide-cache) (arg1 collide-query) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) +(defmethod add-tri-to-collide-cache ((this hfragment) (arg0 collide-cache) (arg1 collide-query) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) (local-vars (sv-16 uint) (sv-24 uint) @@ -97,11 +702,11 @@ (s2-0 (-> this pat-array 0)) ) (when (not (logtest? (-> arg1 ignore-pat) s2-0)) - (when (nonzero? (-> (the-as hfrag-vertex (+ (* a0-2 4) (the-as int v1-0))) packed-index bit11)) - (set! sv-16 (-> (the-as (pointer uint16) (+ (* a0-2 4) (the-as int v1-0))))) - (set! sv-24 (-> (the-as (pointer uint16) (+ (* (+ a0-2 1) 4) (the-as int v1-0))))) - (set! sv-32 (-> (the-as (pointer uint16) (+ (* (+ a0-2 512) 4) (the-as int v1-0))))) - (set! sv-40 (-> (the-as (pointer uint16) (+ (* (+ a0-2 513) 4) (the-as int v1-0))))) + (when (nonzero? (-> v1-0 a0-2 packed-index bit11)) + (set! sv-16 (-> v1-0 a0-2 height)) + (set! sv-24 (-> v1-0 (+ a0-2 1) height)) + (set! sv-32 (-> v1-0 (+ a0-2 512) height)) + (set! sv-40 (-> v1-0 (+ a0-2 513) height)) (set! sv-48 0) (set! sv-56 0) (set! sv-64 0) @@ -131,10 +736,10 @@ (set! sv-72 (logior sv-72 2)) ) (if (not (logtest? (logand sv-48 sv-56) sv-64)) - (hfragment-method-20 this arg0 arg2 arg3 sv-16 sv-24 sv-32 s2-0) + (add-tri-a-xy-zzz-to-collide-cache this arg0 arg2 arg3 sv-16 sv-24 sv-32 s2-0) ) (if (not (logtest? (logand sv-56 sv-64) sv-72)) - (hfragment-method-21 this arg0 arg2 arg3 sv-24 sv-32 sv-40 s2-0) + (add-tri-b-xy-zzz-to-collide-cache this arg0 arg2 arg3 sv-24 sv-32 sv-40 s2-0) ) ) ) @@ -143,7 +748,7 @@ (none) ) -(defmethod hfragment-method-17 ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) +(defmethod bounding-box-query ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) (local-vars (sv-16 int) (sv-24 int) (sv-32 int) (sv-40 int) (sv-48 int) (sv-56 int)) (set! sv-16 (the int (* 0.000030517578 (- (-> arg1 bbox min x) (-> this start-corner x))))) (set! sv-24 (the int (* 0.000030517578 (- (-> arg1 bbox min z) (-> this start-corner z))))) @@ -163,7 +768,7 @@ (s0-0 sv-32) ) (while (>= s0-0 s1-0) - (hfragment-method-19 this arg0 arg1 s1-0 s3-0 sv-48 sv-56) + (add-tri-to-collide-cache this arg0 arg1 s1-0 s3-0 sv-48 sv-56) (+! s1-0 1) ) ) @@ -174,7 +779,7 @@ (none) ) -(defmethod hfragment-method-18 ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) +(defmethod line-sphere-query ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) (local-vars (v1-30 int) (v1-31 int) @@ -266,7 +871,7 @@ ) (set! sv-160 v1-31) (while (>= sv-160 sv-144) - (hfragment-method-19 this arg0 arg1 s1-0 sv-144 s0-0 sv-128) + (add-tri-to-collide-cache this arg0 arg1 s1-0 sv-144 s0-0 sv-128) (set! sv-144 (+ sv-144 1)) ) ) @@ -333,7 +938,7 @@ ) (set! sv-208 v1-58) (while (>= sv-208 sv-192) - (hfragment-method-19 this arg0 arg1 sv-192 s1-1 s0-1 sv-176) + (add-tri-to-collide-cache this arg0 arg1 sv-192 s1-1 s0-1 sv-176) (set! sv-192 (+ sv-192 1)) ) ) @@ -346,3 +951,57 @@ 0 (none) ) + +;; WARN: Return type mismatch symbol vs none. +(defun-debug hfrag-vert-print ((arg0 int) (arg1 int)) + (let ((s4-0 (-> *hfrag-work* hfrag verts))) + (dotimes (s3-0 16) + (dotimes (s2-0 16) + (let ((v1-3 (+ (* (+ s3-0 arg1) 512) s2-0 arg0))) + (format 0 "#x~2x " (+ (shr (-> s4-0 v1-3 packed-index bit11) 3) -1)) + ) + ) + (format 0 "~%") + ) + ) + (none) + ) + +(defmethod collect-stats ((this hfragment)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (let ((v1-0 *hfrag-work*)) + (+! (-> *terrain-stats* hfrag groups) 1) + (+! (-> *terrain-stats* hfrag fragments) (-> v1-0 count-far) (-> v1-0 count-far-scissor)) + (+! (-> *terrain-stats* hfrag fragments) (* (-> v1-0 count-far-mid) 16)) + (+! (-> *terrain-stats* hfrag fragments) (* (-> v1-0 count-mid) 4)) + (+! (-> *terrain-stats* hfrag fragments) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 64)) + (+! (-> *terrain-stats* hfrag fragments) (* (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 256)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-far) (-> v1-0 count-far-scissor)) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (-> v1-0 count-far-mid) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (-> v1-0 count-mid) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 128)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 512)) + (+! (-> *terrain-stats* hfrag dverts) (* (+ (-> v1-0 count-far) (-> v1-0 count-far-scissor)) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (-> v1-0 count-far-mid) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (-> v1-0 count-mid) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 256)) + (+! (-> *terrain-stats* hfrag dverts) (shl (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 10)) + ) + 0 + (none) + ) + +(defmethod mem-usage ((this hfragment) (usage memory-usage-block) (flags int)) + (let ((v1-0 43)) + (set! (-> usage length) (max (-> usage length) (+ v1-0 1))) + (set! (-> usage data v1-0 name) "hfragment") + (+! (-> usage data v1-0 count) 1) + (let ((a2-9 (-> this size))) + (+! (-> usage data v1-0 used) a2-9) + (+! (-> usage data v1-0 total) (logand -16 (+ a2-9 15))) + ) + ) + this + ) diff --git a/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc b/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc index aa5756576..fda1b6d14 100644 --- a/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc +++ b/goal_src/jak3/engine/gfx/background/tfrag/tfrag.gc @@ -416,7 +416,7 @@ (add-tfrag-mtx-1 arg0 arg3) (add-tfrag-data arg0 arg2 (the-as int *subdivide-draw-mode*)) (#when PC_PORT - (add-pc-tfrag3-data arg0 *pc-tfrag-draw-level*) + (add-pc-tfrag3-data arg0 *pc-tfrag-draw-level* 0) ) (let ((v1-5 (the-as dma-packet (-> arg0 base)))) (set! (-> v1-5 dma) (new 'static 'dma-tag :id (dma-tag-id cnt))) diff --git a/goal_src/jak3/engine/gfx/background/tie/tie-methods.gc b/goal_src/jak3/engine/gfx/background/tie/tie-methods.gc index 436de8e01..ec85738b6 100644 --- a/goal_src/jak3/engine/gfx/background/tie/tie-methods.gc +++ b/goal_src/jak3/engine/gfx/background/tie/tie-methods.gc @@ -264,7 +264,7 @@ (-> arg1 draw-index) ) ) - (add-pc-tfrag3-data v1-69 arg1) + (add-pc-tfrag3-data v1-69 arg1 0) (pc-add-tie-vis-mask arg1 v1-69) (pc-add-tie-envmap-info v1-69) ; (let ((a1-37 (-> v1-69 base)) diff --git a/goal_src/jak3/engine/gfx/background/tie/tie.gc b/goal_src/jak3/engine/gfx/background/tie/tie.gc index 86358bb42..0e1bcf81b 100644 --- a/goal_src/jak3/engine/gfx/background/tie/tie.gc +++ b/goal_src/jak3/engine/gfx/background/tie/tie.gc @@ -29,8 +29,8 @@ ) ) ) - (when (= (-> s5-0 reg-4) 66) - (set! (-> s5-0 reg-4) (the-as uint 127)) + (when (= (-> s5-0 reg-4) (gs-reg alpha-1)) + (set! (-> s5-0 reg-4) (gs-reg hack)) (set! (-> s5-0 alpha) (new 'static 'gs-miptbp)) 0 ) diff --git a/goal_src/jak3/engine/gfx/foreground/foreground.gc b/goal_src/jak3/engine/gfx/foreground/foreground.gc index 31ddc33c3..f0ccbe4e1 100644 --- a/goal_src/jak3/engine/gfx/foreground/foreground.gc +++ b/goal_src/jak3/engine/gfx/foreground/foreground.gc @@ -365,7 +365,7 @@ (bucket-id-16 gmerc-l8-tfrag) (bucket-id-16 tex-l8-tfrag) (bucket-id-16 gmerc2-l8-tfrag) - (bucket-id-16 bucket8) + (bucket-id-16 hfrag) (bucket-id-16 merc-l8-pris) (bucket-id-16 emerc-l8-pris) (bucket-id-16 gmerc-l8-pris) @@ -407,7 +407,7 @@ (bucket-id-16 gmerc-l9-tfrag) (bucket-id-16 tex-l9-tfrag) (bucket-id-16 gmerc2-l9-tfrag) - (bucket-id-16 bucket9) + (bucket-id-16 hfrag-scissor) (bucket-id-16 merc-l9-pris) (bucket-id-16 emerc-l9-pris) (bucket-id-16 gmerc-l9-pris) diff --git a/goal_src/jak3/engine/gfx/hw/display-h.gc b/goal_src/jak3/engine/gfx/hw/display-h.gc index 45f1b2ea8..1614d4aab 100644 --- a/goal_src/jak3/engine/gfx/hw/display-h.gc +++ b/goal_src/jak3/engine/gfx/hw/display-h.gc @@ -117,8 +117,8 @@ At any point in time, there are 3 frames in progress: rn3 rn4 rn5 - rn6 - rn7 + hfrag + hfrag-scissor tfrag tie-scissor tie @@ -153,8 +153,8 @@ At any point in time, there are 3 frames in progress: rn3 rn4 rn5 - rn6 - rn7 + hfrag + hfrag-scissor tfrag tie-scissor tie diff --git a/goal_src/jak3/engine/gfx/shrub/shrubbery.gc b/goal_src/jak3/engine/gfx/shrub/shrubbery.gc index 6826a846a..aeab9eebd 100644 --- a/goal_src/jak3/engine/gfx/shrub/shrubbery.gc +++ b/goal_src/jak3/engine/gfx/shrub/shrubbery.gc @@ -970,7 +970,7 @@ ) *draw-index* )) - (add-pc-tfrag3-data buf (-> *level* draw-level *draw-index*)) + (add-pc-tfrag3-data buf (-> *level* draw-level *draw-index*) 0) (pc-add-shrub-vis-mask buf (-> *level* draw-level *draw-index*)) ) (let ((v1-33 *dma-mem-usage*)) diff --git a/goal_src/jak3/engine/gfx/texture/texture-h.gc b/goal_src/jak3/engine/gfx/texture/texture-h.gc index b9027ade5..b32c327ad 100644 --- a/goal_src/jak3/engine/gfx/texture/texture-h.gc +++ b/goal_src/jak3/engine/gfx/texture/texture-h.gc @@ -145,7 +145,7 @@ So mask 0 is needed if segment 0 of the texture is needed, etc..." (h int16) (num-mips uint8) (tex1-control uint8) - (psm uint8) + (psm gs-psm) (mip-shift uint8) (clutpsm uint16) (dest uint16 7) @@ -280,11 +280,11 @@ For example, the texture system will automatically update tbp to point to the lo of the texture." ((quad qword 5 :inline) (prims gs-reg64 10 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> quad 0 data 2)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (reg-3 uint8 :overlay-at (-> prims 7)) - (reg-4 uint8 :overlay-at (-> prims 9)) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (reg-4 gs-reg :overlay-at (-> prims 9)) (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) (tex1 gs-tex1 :overlay-at (-> prims 2)) (miptbp1 gs-miptbp :overlay-at (-> prims 4)) diff --git a/goal_src/jak3/engine/gfx/texture/texture.gc b/goal_src/jak3/engine/gfx/texture/texture.gc index bdc5aa713..b94275c49 100644 --- a/goal_src/jak3/engine/gfx/texture/texture.gc +++ b/goal_src/jak3/engine/gfx/texture/texture.gc @@ -147,7 +147,7 @@ #t "# this name) - (psm->string (the-as gs-psm (-> this psm))) + (psm->string (-> this psm)) (-> this w) (-> this h) (-> this num-mips) @@ -156,7 +156,7 @@ (dotimes (s5-1 (the-as int (-> this num-mips))) (format #t " #x~X/~X" (-> this dest s5-1) (-> this width s5-1)) ) - (if (< (texture-bpp (the-as gs-psm (-> this psm))) 16) + (if (< (texture-bpp (-> this psm)) 16) (format #t " :clut #x~X/1" (-> this clutdest)) ) (format #t " @ #x~X>" this) @@ -1683,7 +1683,7 @@ (bitbltbuf (new 'static 'gs-bitbltbuf :sbp (-> tex dest v1-0) :sbw (-> tex width v1-0) - :spsm (-> tex psm) + :spsm (the-as int (-> tex psm)) :dbp (/ dest 64) :dbw (-> tex width v1-0) :dpsm (the-as int tex-format) @@ -1699,7 +1699,7 @@ (cond ((< clut-dest 0) ) - ((= (-> tex psm) 20) + ((= (-> tex psm) (gs-psm mt4)) (dma-buffer-add-gs-set dma-buf (bitbltbuf (new 'static 'gs-bitbltbuf :sbw #x1 @@ -1716,7 +1716,7 @@ ) (set! (-> tex clutdest) (the-as uint (/ clut-dest 64))) ) - ((= (-> tex psm) 19) + ((= (-> tex psm) (gs-psm mt8)) (dma-buffer-add-gs-set dma-buf (bitbltbuf (new 'static 'gs-bitbltbuf :sbw #x2 @@ -1734,7 +1734,7 @@ (set! (-> tex clutdest) (the-as uint (/ clut-dest 64))) ) ) - (set! (-> tex psm) (the-as uint tex-format)) + (set! (-> tex psm) tex-format) dma-buf ) diff --git a/goal_src/jak3/engine/gfx/vu1-user-h.gc b/goal_src/jak3/engine/gfx/vu1-user-h.gc index 95007f153..63df0c7b5 100644 --- a/goal_src/jak3/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak3/engine/gfx/vu1-user-h.gc @@ -34,8 +34,8 @@ (bucket5 5) ;; sky (bucket6 6) ;; ocean (bucket7 7) ;; unknown new jak 3 texture upload, for all levels. - (bucket8 8) ;; hfrag - (bucket9 9) ;; hfrag + (hfrag 8) ;; hfrag + (hfrag-scissor 9) ;; hfrag (tex-l0-tfrag 10) ;; texture (tfrag-l0-tfrag 11) ;; tfrag @@ -703,8 +703,8 @@ (rn3) (rn4) (rn5) - (rn6) - (rn7) + (hfrag) + (hfrag-scissor) (tfrag) (tie-scissor) (tie) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index f783a45f3..1f6688160 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -185,7 +185,7 @@ (lf11 11) (lf12 12) (lf13 13) - (lf14 14) + (low-res-hfrag 14) (lf15 15) (lf16 16) (lf17 17) diff --git a/goal_src/jak3/engine/level/level-info.gc b/goal_src/jak3/engine/level/level-info.gc index 3c2b5e3e2..d179e4fc7 100644 --- a/goal_src/jak3/engine/level/level-info.gc +++ b/goal_src/jak3/engine/level/level-info.gc @@ -17993,7 +17993,7 @@ :index #x107 :task-level #xa :master-level #f - :level-flags (level-flags lf7 lf9 lf12 lf13 lf14) + :level-flags (level-flags lf7 lf9 lf12 lf13 low-res-hfrag) :packages '("vehiclep" "nav-graphp" "hvehiclep" "hanga") :run-packages '("common") :memory-mode (level-memory-mode small-edge) @@ -18072,7 +18072,7 @@ :index #x108 :task-level #xa :master-level 'hanga - :level-flags (level-flags lf1 lf9 lf12 lf14) + :level-flags (level-flags lf1 lf9 lf12 low-res-hfrag) :packages '() :run-packages '("common") :memory-mode (level-memory-mode small-center) diff --git a/goal_src/jak3/engine/level/level.gc b/goal_src/jak3/engine/level/level.gc index 31cceb4e1..7406010bb 100644 --- a/goal_src/jak3/engine/level/level.gc +++ b/goal_src/jak3/engine/level/level.gc @@ -1999,11 +1999,11 @@ (set! (-> sv-96 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) (set! (-> sv-96 clamp) (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) (set! (-> sv-96 alpha) (new 'static 'gs-miptbp :tbp1 #x58)) - (set! (-> sv-96 reg-0) (the-as uint 6)) - (set! (-> sv-96 reg-1) (the-as uint 20)) - (set! (-> sv-96 reg-2) (the-as uint 52)) - (set! (-> sv-96 reg-3) (the-as uint 8)) - (set! (-> sv-96 reg-4) (the-as uint 66)) + (set! (-> sv-96 reg-0) (gs-reg tex0-1)) + (set! (-> sv-96 reg-1) (gs-reg tex1-1)) + (set! (-> sv-96 reg-2) (gs-reg miptbp1-1)) + (set! (-> sv-96 reg-3) (gs-reg clamp-1)) + (set! (-> sv-96 reg-4) (gs-reg alpha-1)) ) ) (set! (-> arg1 pos) (the-as uint 0)) diff --git a/goalc/build_level/common/Tfrag.cpp b/goalc/build_level/common/Tfrag.cpp index a7bd8e957..45935d5fa 100644 --- a/goalc/build_level/common/Tfrag.cpp +++ b/goalc/build_level/common/Tfrag.cpp @@ -14,13 +14,15 @@ void tfrag_from_gltf(const gltf_mesh_extract::TfragOutput& mesh_extract_out, out_pc.kind = tfrag3::TFragmentTreeKind::NORMAL; // todo more types? out_pc.draws = std::move(mesh_extract_out.strip_draws); pack_tfrag_vertices(&out_pc.packed_vertices, mesh_extract_out.vertices); - - for (auto& col : mesh_extract_out.color_palette) { - tfrag3::TimeOfDayColor todc; - for (auto& rgba : todc.rgba) { - rgba = col; + out_pc.colors.color_count = (mesh_extract_out.color_palette.size() + 3) & (~3); + out_pc.colors.data.resize(out_pc.colors.color_count * 8 * 4); + for (u32 color_index = 0; color_index < mesh_extract_out.color_palette.size(); color_index++) { + for (u32 palette = 0; palette < 8; palette++) { + for (u32 channel = 0; channel < 4; channel++) { + out_pc.colors.read(color_index, palette, channel) = + mesh_extract_out.color_palette[color_index][channel]; + } } - out_pc.colors.push_back(todc); } out_pc.use_strips = false; } diff --git a/test/decompiler/reference/jak3/engine/collide/collide-cache_REF.gc b/test/decompiler/reference/jak3/engine/collide/collide-cache_REF.gc index ed3f8aa36..bf624cb2b 100644 --- a/test/decompiler/reference/jak3/engine/collide/collide-cache_REF.gc +++ b/test/decompiler/reference/jak3/engine/collide/collide-cache_REF.gc @@ -201,7 +201,7 @@ (when (= (-> v1-15 status) 'active) (let ((a0-6 (-> v1-15 bsp hfrag-drawable))) (if (nonzero? a0-6) - (hfragment-method-17 (the-as hfragment a0-6) this arg0) + (bounding-box-query (the-as hfragment a0-6) this arg0) ) ) ) @@ -497,7 +497,7 @@ (when (= (-> v1-36 status) 'active) (let ((a0-18 (-> v1-36 bsp hfrag-drawable))) (if (nonzero? a0-18) - (hfragment-method-18 (the-as hfragment a0-18) this arg0) + (line-sphere-query (the-as hfragment a0-18) this arg0) ) ) ) diff --git a/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc index 21ed27d8a..632214f33 100644 --- a/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc +++ b/test/decompiler/reference/jak3/engine/draw/drawable_REF.gc @@ -2377,7 +2377,7 @@ (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) ) (default-init-buffer - (bucket-id bucket8) + (bucket-id hfrag) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24)) (new 'static 'gs-test :zte #x1 :ztst (gs-ztest always)) ) diff --git a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-h_REF.gc index 84e9e7444..b9ba1c729 100644 --- a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-h_REF.gc @@ -44,10 +44,10 @@ ;; definition of type hfrag-bucket (deftype hfrag-bucket (structure) - ((next uint32) + ((next pointer) (count uint16) (vertex-count uint16) - (next-scissor uint32) + (next-scissor pointer) (count-scissor uint16) (vertex-count-scissor uint16) ) @@ -72,7 +72,8 @@ ;; definition of type hfrag-packed-index (deftype hfrag-packed-index (uint16) - ((bit11 uint8 :offset 11 :size 5) + ((color uint16 :offset 0 :size 11) + (bit11 uint8 :offset 11 :size 5) ) ) @@ -81,6 +82,7 @@ ((height uint16) (packed-index hfrag-packed-index) ) + :pack-me ) ;; definition for method 3 of type hfrag-vertex @@ -163,6 +165,7 @@ (deftype hfrag-poly9 (structure) ((data hfrag-vert-index 9 :inline) ) + :pack-me ) ;; definition for method 3 of type hfrag-poly9 @@ -201,6 +204,7 @@ (deftype hfrag-poly25 (structure) ((data hfrag-vert-index 25 :inline) ) + :pack-me ) ;; definition for method 3 of type hfrag-poly25 @@ -413,6 +417,7 @@ (deftype hfrag-init-packet (structure) ((init-tmpl dma-packet :inline) (init-data uint32 8) + (init-vif vif-tag :overlay-at (-> init-data 7)) ) ) @@ -500,14 +505,14 @@ ;; definition of type hfrag-tex-data (deftype hfrag-tex-data (structure) - ((quad qword 3 :inline) - (prims uint64 6 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> quad 0 data 2)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (tex0 uint64 :overlay-at (-> quad 0 data 0)) - (tex1 uint64 :overlay-at (-> prims 2)) - (texflush uint64 :overlay-at (-> prims 4)) + ((quad qword 3 :inline) + (prims uint64 6 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) + (tex1 gs-tex1 :overlay-at (-> prims 2)) + (texflush uint64 :overlay-at (-> prims 4)) ) ) @@ -518,8 +523,8 @@ (goto cfg-4) ) (format #t "[~8x] ~A~%" this 'hfrag-tex-data) - (format #t "~1Tquad[3] @ #x~X~%" (-> this quad)) - (format #t "~1Tprims[6] @ #x~X~%" (-> this quad)) + (format #t "~1Tquad[3] @ #x~X~%" (&-> this tex0)) + (format #t "~1Tprims[6] @ #x~X~%" (&-> this tex0)) (format #t "~1Treg-0: ~D~%" (-> this reg-0)) (format #t "~1Treg-1: ~D~%" (-> this reg-1)) (format #t "~1Treg-2: ~D~%" (-> this reg-2)) @@ -609,16 +614,16 @@ ;; definition of type hfrag-frame (deftype hfrag-frame (structure) - ((quad qword 4 :inline :offset 0) - (prims uint64 8 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> prims 1)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (reg-3 uint8 :overlay-at (-> prims 7)) - (frame uint64 :overlay-at (-> prims 0)) - (scissor uint64 :overlay-at (-> prims 2)) - (xyoffset uint64 :overlay-at (-> prims 4)) - (test uint64 :overlay-at (-> prims 6)) + ((quad qword 4 :inline :offset 0) + (prims uint64 8 :overlay-at quad) + (reg-0 gs-reg :overlay-at (-> prims 1)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (frame gs-frame :overlay-at (-> prims 0)) + (scissor gs-scissor :overlay-at (-> prims 2)) + (xyoffset gs-xy-offset :overlay-at (-> prims 4)) + (test gs-test :overlay-at (-> prims 6)) ) ) @@ -629,8 +634,8 @@ (goto cfg-4) ) (format #t "[~8x] ~A~%" this 'hfrag-frame) - (format #t "~1Tquad[4] @ #x~X~%" (-> this quad)) - (format #t "~1Tprims[8] @ #x~X~%" (-> this quad)) + (format #t "~1Tquad[4] @ #x~X~%" (&-> this frame)) + (format #t "~1Tprims[8] @ #x~X~%" (&-> this frame)) (format #t "~1Treg-0: ~D~%" (-> this reg-0)) (format #t "~1Treg-1: ~D~%" (-> this reg-1)) (format #t "~1Treg-2: ~D~%" (-> this reg-2)) @@ -666,14 +671,14 @@ ;; definition of type hfragment (deftype hfragment (drawable) ((start-corner vector :inline) - (spheres uint32) - (visids uint32) + (spheres (inline-array vector)) + (visids (pointer int16)) (shaders (inline-array adgif-shader)) - (colors basic) + (colors time-of-day-palette) (montage uint32) - (buckets-far uint32) - (buckets-mid uint32) - (buckets-near uint32) + (buckets-far (inline-array hfrag-bucket)) + (buckets-mid (inline-array hfrag-bucket)) + (buckets-near (inline-array hfrag-bucket)) (verts (inline-array hfrag-vertex)) (pat-array (pointer pat-surface)) (pat-length uint16) @@ -683,11 +688,11 @@ (size uint32 :overlay-at (-> start-corner data 3)) ) (:methods - (hfragment-method-17 (_type_ collide-cache collide-query) none) - (hfragment-method-18 (_type_ collide-cache collide-query) none) - (hfragment-method-19 (_type_ collide-cache collide-query int int int int) none) - (hfragment-method-20 (_type_ collide-cache int int uint uint uint pat-surface) none) - (hfragment-method-21 (_type_ collide-cache int int uint uint uint pat-surface) none) + (bounding-box-query (_type_ collide-cache collide-query) none) + (line-sphere-query (_type_ collide-cache collide-query) none) + (add-tri-to-collide-cache (_type_ collide-cache collide-query int int int int) none) + (add-tri-a-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) + (add-tri-b-xy-zzz-to-collide-cache (_type_ collide-cache int int uint uint uint pat-surface) none) ) ) @@ -715,7 +720,7 @@ (format #t "~1Tnum-buckets-far: ~D~%" (-> this num-buckets-far)) (format #t "~1Tnum-buckets-mid: ~D~%" (-> this num-buckets-mid)) (format #t "~1Tnum-buckets-near: ~D~%" (-> this num-buckets-near)) - (format #t "~1Tsize: ~D~%" (-> this start-corner w)) + (format #t "~1Tsize: ~D~%" (-> this size)) (label cfg-4) this ) @@ -764,75 +769,75 @@ ;; definition of type hfrag-work (deftype hfrag-work (structure) - ((far-chaina dma-packet 6 :inline) - (far-chainb dma-packet 6 :inline) - (mid-chaina dma-packet 10 :inline) - (mid-chainb dma-packet 10 :inline) - (near-chaina dma-packet 18 :inline) - (near-chainb dma-packet 18 :inline) - (poly4-tmpl dma-packet 3 :inline) - (poly9-tmpl dma-packet 3 :inline) - (poly25-tmpl dma-packet 3 :inline) - (init-tmpl dma-packet 3 :inline) - (control-tmpl dma-packet 2 :inline :offset 1376) - (heights4-tmpl dma-packet 2 :inline) - (colors4-tmpl dma-packet 2 :inline) - (heights9-tmpl dma-packet 2 :inline) - (colors9-tmpl dma-packet 2 :inline) - (heights25-tmpl dma-packet 2 :inline) - (colors25-tmpl dma-packet 2 :inline) - (init-vu1-tmpl dma-packet 2 :inline) - (next-tmpl dma-packet :inline :offset 1696) - (call-tmpl dma-packet :inline) - (ret-tmpl dma-packet :inline) - (next-scissor-tmpl dma-packet :inline) - (ret-scissor-tmpl dma-packet :inline) - (frame-tmpl dma-gif-packet :inline) - (frames hfrag-frame 5 :inline) - (adgif-tmpl dma-gif-packet :inline) - (adgif-tmpl2 dma-gif-packet :inline) - (sprite-tmpl dma-gif-packet :inline) - (mip-tmpl dma-gif-packet :inline) - (color uint128 6) - (far-data hfrag-sprite-coord :inline) - (near-data vector4w-2 16 :inline) - (mip-data vector4w-3 7 :inline :offset 2896) - (tex-data hfrag-tex-data 5 :offset 3120) - (tex uint128 6 :offset 3360) - (montage-tex-coords uint128 128 :offset 3456) - (giftag generic-gif-tag :inline :offset 7552) - (call-abort dma-packet :inline) - (call-abort-vu1 dma-packet :inline) - (shader-far adgif-shader :inline) - (shader-mid adgif-shader :inline) - (shader-near adgif-shader :inline) - (stq uint128 9) - (shader adgif-shader :inline) - (constants vector :inline) - (pos-temp vector4w :inline) - (trans-temp vector :inline :overlay-at (-> pos-temp data 0)) - (dists vector :inline) - (rdists vector :inline) - (call-poly4-near uint32) - (call-poly9-mid uint32) - (call-poly9-near uint32) - (call-poly25-far uint32) - (call-poly25-mid uint32) + ((far-chaina dma-packet 6 :inline) + (far-chainb dma-packet 6 :inline) + (mid-chaina dma-packet 10 :inline) + (mid-chainb dma-packet 10 :inline) + (near-chaina dma-packet 18 :inline) + (near-chainb dma-packet 18 :inline) + (poly4-tmpl dma-packet 3 :inline) + (poly9-tmpl dma-packet 3 :inline) + (poly25-tmpl dma-packet 3 :inline) + (init-tmpl hfrag-init-packet 3 :inline) + (control-tmpl dma-packet 2 :inline) + (heights4-tmpl dma-packet 2 :inline) + (colors4-tmpl dma-packet 2 :inline) + (heights9-tmpl dma-packet 2 :inline) + (colors9-tmpl dma-packet 2 :inline) + (heights25-tmpl dma-packet 2 :inline) + (colors25-tmpl dma-packet 2 :inline) + (init-vu1-tmpl hfrag-init-packet 2 :inline) + (next-tmpl dma-packet :inline) + (call-tmpl dma-packet :inline) + (ret-tmpl dma-packet :inline) + (next-scissor-tmpl dma-packet :inline) + (ret-scissor-tmpl dma-packet :inline) + (frame-tmpl dma-gif-packet :inline) + (frames hfrag-frame 5 :inline) + (adgif-tmpl dma-gif-packet :inline) + (adgif-tmpl2 dma-gif-packet :inline) + (sprite-tmpl dma-gif-packet :inline) + (mip-tmpl dma-gif-packet :inline) + (color vector4w 6 :inline) + (far-data hfrag-sprite-coord :inline) + (near-data vector4w-2 16 :inline) + (mip-data vector4w-2 7 :inline) + (tex-data hfrag-tex-data 5 :inline) + (tex vector 6 :inline) + (montage-tex-coords hfrag-montage-coord 128 :inline :offset 3456) + (giftag generic-gif-tag :inline :offset 7552) + (call-abort dma-packet :inline) + (call-abort-vu1 dma-packet :inline) + (shader-far adgif-shader :inline) + (shader-mid adgif-shader :inline) + (shader-near adgif-shader :inline) + (stq vector4w 9 :inline) + (shader adgif-shader :inline) + (constants vector :inline) + (pos-temp vector4w :inline) + (trans-temp vector :inline :overlay-at (-> pos-temp data 0)) + (dists vector :inline) + (rdists vector :inline) + (call-poly4-near vif-tag) + (call-poly9-mid vif-tag) + (call-poly9-near vif-tag) + (call-poly25-far vif-tag) + (call-poly25-mid vif-tag) (dma-buffer basic) (base uint32) (wait-to-spr uint32) (wait-from-spr uint32) (buffer-end uint32) (subdiv-index uint32) - (scissor basic) + (scissor symbol) (chain-ptr uint32) (chain-ptr-next uint32) (near-dist float) (far-dist float) (to-spr uint32) (from-spr uint32) - (lowres-flag basic) - (hfrag hfragment :inline) + (lowres-flag symbol) + (hfrag hfragment :inline) (next-far int16) (next-far-mid int16) (next-mid int16) @@ -859,42 +864,42 @@ (size-near-scissor int32) (size-texture int32) (poly-far hfrag-poly25) - (poly-mid25 uint32) - (poly-mid uint32) - (poly-near uint32) - (far-texture uint32) - (near-textures uint16 16) - (draw-table uint16 1024 :offset 8456) - (corners uint128 1024) + (poly-mid25 (inline-array hfrag-poly25)) + (poly-mid (inline-array hfrag-poly9)) + (poly-near (inline-array hfrag-poly9)) + (far-texture pointer) + (near-textures uint16 16) + (draw-table int16 1024 :offset 8456) + (corners vector 1024 :inline) ) (:methods - (hfrag-work-method-9 () none) - (hfrag-work-method-10 () none) - (hfrag-work-method-11 () none) - (hfrag-work-method-12 () none) - (hfrag-work-method-13 () none) - (hfrag-work-method-14 () none) - (hfrag-work-method-15 () none) - (hfrag-work-method-16 () none) - (hfrag-work-method-17 () none) - (hfrag-work-method-18 () none) + (initialize-renderer! (_type_) none) + (init-work-from-current-hfrag! (_type_) none) + (pick-level-of-detail! (_type_ level) none) + (generate-vertices! (_type_) none) + (finalize-dma! (_type_) none) + (setup-far-vertex-index! (_type_ hfrag-vert-index int int) none) + (setup-mid-vertex-index! (_type_ hfrag-vert-index int int) none) + (setup-near-vertex-index! (_type_ hfrag-vert-index int int) none) + (init-montage-tex-coords (_type_) none) + (asm-far-scissor (_type_ dma-buffer int) none) (hfrag-work-method-19 () none) (hfrag-work-method-20 () none) - (hfrag-work-method-21 () none) + (asm-near-mid-scissor (_type_ dma-buffer int) none) (hfrag-work-method-22 () none) - (hfrag-work-method-23 () none) - (hfrag-work-method-24 () none) - (hfrag-work-method-25 () none) - (hfrag-work-method-26 () none) - (hfrag-work-method-27 () none) - (hfrag-work-method-28 () none) - (hfrag-work-method-29 () none) - (hfrag-work-method-30 () none) - (hfrag-work-method-31 () none) - (hfrag-work-method-32 () none) - (hfrag-work-method-33 () none) - (hfrag-work-method-34 () none) - (hfrag-work-method-35 () none) + (generate-montage-texture (_type_) none) + (hfrag-work-method-24 (_type_ dma-buffer) none) + (hfrag-work-method-25 (_type_ dma-buffer) none) + (hfrag-work-method-26 (_type_ dma-buffer) none) + (asm-far (_type_ dma-buffer int) none) + (asm-far-mid (_type_ dma-buffer int) none) + (asm-mid (_type_ dma-buffer int) none) + (asm-near-mid (_type_ dma-buffer int) none) + (asm-near (_type_ dma-buffer int) none) + (hfrag-work-method-32 (_type_ dma-buffer) none) + (hfrag-work-method-33 (_type_ dma-buffer) none) + (hfrag-work-method-34 (_type_ dma-buffer) none) + (trim-dma-to-fit-in-memory (_type_) none) ) ) diff --git a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1-h_REF.gc new file mode 100644 index 000000000..0b53ff89d --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1-h_REF.gc @@ -0,0 +1,273 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type hfrag-vu1-poly4-packet +(deftype hfrag-vu1-poly4-packet (structure) + ((height-tag dma-packet :inline) + (base vector :inline) + (heights uint32 4) + (color-tag dma-packet :inline) + (colors rgba 4) + (next dma-packet :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly4-packet +(defmethod inspect ((this hfrag-vu1-poly4-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly4-packet) + (format #t "~1Theight-tag: #~%" (-> this height-tag)) + (format #t "~1Tbase: #~%" (-> this base)) + (format #t "~1Theights[4] @ #x~X~%" (-> this heights)) + (format #t "~1Tcolor-tag: #~%" (-> this color-tag)) + (format #t "~1Tcolors[4] @ #x~X~%" (-> this colors)) + (format #t "~1Tnext: #~%" (-> this next)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-poly9-packet +(deftype hfrag-vu1-poly9-packet (structure) + ((height-tag dma-packet :inline) + (base vector3 :inline) + (heights uint32 9) + (color-tag dma-packet :inline) + (colors rgba 12) + (next dma-packet :inline) + (jump-index int32 :overlay-at (-> base data 1)) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly9-packet +(defmethod inspect ((this hfrag-vu1-poly9-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly9-packet) + (format #t "~1Theight-tag: #~%" (-> this height-tag)) + (format #t "~1Tbase: #~%" (-> this base)) + (format #t "~1Theights[9] @ #x~X~%" (-> this heights)) + (format #t "~1Tcolor-tag: #~%" (-> this color-tag)) + (format #t "~1Tcolors[12] @ #x~X~%" (-> this colors)) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tjump-index: ~D~%" (-> this base y)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-poly25-packet +(deftype hfrag-vu1-poly25-packet (structure) + ((height-tag dma-packet :inline) + (base vector3 :inline) + (heights uint32 25) + (color-tag dma-packet :inline) + (colors rgba 28) + (next dma-packet :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly25-packet +(defmethod inspect ((this hfrag-vu1-poly25-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly25-packet) + (format #t "~1Theight-tag: #~%" (-> this height-tag)) + (format #t "~1Tbase: #~%" (-> this base)) + (format #t "~1Theights[25] @ #x~X~%" (-> this heights)) + (format #t "~1Tcolor-tag: #~%" (-> this color-tag)) + (format #t "~1Tcolors[28] @ #x~X~%" (-> this colors)) + (format #t "~1Tnext: #~%" (-> this next)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-vertex +(deftype hfrag-vu1-vertex (structure) + ((tex vector :inline) + (clr vector :inline) + (pos vector :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-vertex +(defmethod inspect ((this hfrag-vu1-vertex)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-vertex) + (format #t "~1Ttex: #~%" (-> this tex)) + (format #t "~1Tclr: #~%" (-> this clr)) + (format #t "~1Tpos: #~%" (-> this pos)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-poly4 +(deftype hfrag-vu1-poly4 (structure) + ((giftag vector :inline) + (verts hfrag-vu1-vertex 4 :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly4 +(defmethod inspect ((this hfrag-vu1-poly4)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly4) + (format #t "~1Tgiftag: #~%" (-> this giftag)) + (format #t "~1Tverts[4] @ #x~X~%" (-> this verts)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-poly9 +(deftype hfrag-vu1-poly9 (structure) + ((giftag0 vector :inline) + (verts0 hfrag-vu1-vertex 6 :inline) + (giftag1 vector :inline) + (verts1 hfrag-vu1-vertex 6 :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly9 +(defmethod inspect ((this hfrag-vu1-poly9)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly9) + (format #t "~1Tgiftag0: #~%" (-> this giftag0)) + (format #t "~1Tverts0[6] @ #x~X~%" (-> this verts0)) + (format #t "~1Tgiftag1: #~%" (-> this giftag1)) + (format #t "~1Tverts1[6] @ #x~X~%" (-> this verts1)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-poly25 +(deftype hfrag-vu1-poly25 (structure) + ((giftag0 vector :inline) + (verts0 hfrag-vu1-vertex 10 :inline) + (giftag1 vector :inline) + (verts1 hfrag-vu1-vertex 10 :inline) + (giftag2 vector :inline) + (verts2 hfrag-vu1-vertex 10 :inline) + (giftag3 vector :inline) + (verts3 hfrag-vu1-vertex 10 :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-poly25 +(defmethod inspect ((this hfrag-vu1-poly25)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-poly25) + (format #t "~1Tgiftag0: #~%" (-> this giftag0)) + (format #t "~1Tverts0[10] @ #x~X~%" (-> this verts0)) + (format #t "~1Tgiftag1: #~%" (-> this giftag1)) + (format #t "~1Tverts1[10] @ #x~X~%" (-> this verts1)) + (format #t "~1Tgiftag2: #~%" (-> this giftag2)) + (format #t "~1Tverts2[10] @ #x~X~%" (-> this verts2)) + (format #t "~1Tgiftag3: #~%" (-> this giftag3)) + (format #t "~1Tverts3[10] @ #x~X~%" (-> this verts3)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-constants-base +(deftype hfrag-vu1-constants-base (structure) + ((far-verts vector 25 :inline) + (mid-verts9 vector 9 :inline) + (mid-verts25 vector 25 :inline) + (near-verts4 vector 4 :inline) + (near-verts9 vector 9 :inline) + (sts vector 9 :inline) + (data vector 81 :inline :overlay-at (-> far-verts 0)) + ) + ) + +;; definition for method 3 of type hfrag-vu1-constants-base +(defmethod inspect ((this hfrag-vu1-constants-base)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-constants-base) + (format #t "~1Tfar-verts[25] @ #x~X~%" (-> this far-verts)) + (format #t "~1Tmid-verts9[9] @ #x~X~%" (-> this mid-verts9)) + (format #t "~1Tmid-verts25[25] @ #x~X~%" (-> this mid-verts25)) + (format #t "~1Tnear-verts4[4] @ #x~X~%" (-> this near-verts4)) + (format #t "~1Tnear-verts9[9] @ #x~X~%" (-> this near-verts9)) + (format #t "~1Tsts[9] @ #x~X~%" (-> this sts)) + (format #t "~1Tdata[81] @ #x~X~%" (-> this far-verts)) + (label cfg-4) + this + ) + +;; definition of type hfrag-vu1-constants +(deftype hfrag-vu1-constants (structure) + ((base hfrag-vu1-constants-base :inline) + (far-verts vector 25 :inline :overlay-at (-> base far-verts 0)) + (mid-verts9 vector 9 :inline :overlay-at (-> base mid-verts9 0)) + (mid-verts25 vector 25 :inline :overlay-at (-> base mid-verts25 0)) + (near-verts4 vector 4 :inline :overlay-at (-> base near-verts4 0)) + (near-verts9 vector 9 :inline :overlay-at (-> base near-verts9 0)) + (sts vector 9 :inline :overlay-at (-> base sts 0)) + (drw-strip4 gs-gif-tag :inline) + (drw-strip9-0 gs-gif-tag :inline) + (drw-strip9-1 gs-gif-tag :inline) + (drw-strip25-0 gs-gif-tag :inline) + (drw-strip25-1 gs-gif-tag :inline) + (matrix matrix :inline) + (hvdf-offset vector :inline) + (hmge-scale vector :inline) + (fog vector :inline) + (stores qword :inline) + ) + ) + +;; definition for method 3 of type hfrag-vu1-constants +(defmethod inspect ((this hfrag-vu1-constants)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'hfrag-vu1-constants) + (format #t "~1Tbase: #~%" (-> this base)) + (format #t "~1Tfar-verts[25] @ #x~X~%" (-> this base)) + (format #t "~1Tmid-verts9[9] @ #x~X~%" (-> this base mid-verts9)) + (format #t "~1Tmid-verts25[25] @ #x~X~%" (-> this base mid-verts25)) + (format #t "~1Tnear-verts4[4] @ #x~X~%" (-> this base near-verts4)) + (format #t "~1Tnear-verts9[9] @ #x~X~%" (-> this base near-verts9)) + (format #t "~1Tsts[9] @ #x~X~%" (-> this base sts)) + (format #t "~1Tdrw-strip4: #~%" (-> this drw-strip4)) + (format #t "~1Tdrw-strip9-0: #~%" (-> this drw-strip9-0)) + (format #t "~1Tdrw-strip9-1: #~%" (-> this drw-strip9-1)) + (format #t "~1Tdrw-strip25-0: #~%" (-> this drw-strip25-0)) + (format #t "~1Tdrw-strip25-1: #~%" (-> this drw-strip25-1)) + (format #t "~1Tmatrix: #~%" (-> this matrix)) + (format #t "~1Thvdf-offset: #~%" (-> this hvdf-offset)) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tfog: #~%" (-> this fog)) + (format #t "~1Tstores: #~%" (-> this stores)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1_REF.gc new file mode 100644 index 000000000..c50984106 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-vu1_REF.gc @@ -0,0 +1,386 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol hfrag-vu1-block, type vu-function +(define hfrag-vu1-block (new 'static 'vu-function :length #x7ec :qlength #x3f6)) + +;; definition for method 32 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 33 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 34 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 27 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 28 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 29 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 30 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 31 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for function hfrag-setup-constants +;; INFO: Used lq/sq +;; WARN: Return type mismatch vector vs none. +(defun hfrag-setup-constants ((arg0 hfrag-vu1-constants)) + (let ((gp-0 *math-camera*)) + (let ((v1-0 *hfrag-vu1-constants-base*)) + (dotimes (a0-1 81) + (set! (-> arg0 base far-verts a0-1 quad) (-> v1-0 far-verts a0-1 quad)) + ) + ) + (case *subdivide-draw-mode* + (((subdivide-setting textured)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting outline)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting gouraud)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting hack)) + (set! (-> arg0 drw-strip4 tag) + (new 'static 'gif-tag64 + :nloop #x4 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-0 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip9-1 tag) + (new 'static 'gif-tag64 + :nloop #x6 + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-0 tag) + (new 'static 'gif-tag64 + :nloop #xa + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + (set! (-> arg0 drw-strip25-1 tag) + (new 'static 'gif-tag64 + :nloop #xa + :eop #x1 + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1) + :nreg #x3 + ) + ) + ) + ) + (set! (-> arg0 drw-strip4 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip9-0 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip9-1 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip25-0 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (set! (-> arg0 drw-strip25-1 regs) + (new 'static 'gif-tag-regs :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + ) + (mem-copy! (the-as pointer (-> arg0 matrix)) (the-as pointer (-> gp-0 camera-temp)) 64) + (set! (-> arg0 hvdf-offset quad) (-> gp-0 hvdf-off quad)) + (set! (-> arg0 hmge-scale quad) (-> gp-0 hmge-scale quad)) + (set-vector! (-> arg0 fog) (-> gp-0 pfog0) (-> gp-0 fog-min) (-> gp-0 fog-max) 3072.0) + ) + (none) + ) + +;; definition for function hfrag-add-constants +;; WARN: Return type mismatch pointer vs none. +(defun hfrag-add-constants ((arg0 dma-buffer)) + (let* ((a1-0 94) + (v1-0 arg0) + (a0-1 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a0-1 dma) (new 'static 'dma-tag :id (dma-tag-id cnt) :qwc a1-0)) + (set! (-> a0-1 vif0) (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))) + (set! (-> a0-1 vif1) (new 'static 'vif-tag :imm #x189 :cmd (vif-cmd unpack-v4-32) :num a1-0)) + (set! (-> v1-0 base) (the-as pointer (&+ a0-1 16))) + ) + (hfrag-setup-constants (the-as hfrag-vu1-constants (-> arg0 base))) + (&+! (-> arg0 base) 1504) + (none) + ) + +;; definition for function hfrag-vu1-end-buffer +;; WARN: Return type mismatch int vs none. +(defun hfrag-vu1-end-buffer ((arg0 dma-buffer)) + (let* ((v1-0 arg0) + (a1-0 (the-as dma-packet (-> v1-0 base))) + ) + (set! (-> a1-0 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a1-0 vif0) (new 'static 'vif-tag :cmd (vif-cmd stmask))) + (set! (-> a1-0 vif1) (new 'static 'vif-tag)) + (set! (-> v1-0 base) (the-as pointer (&+ a1-0 16))) + ) + (let* ((v1-1 arg0) + (a1-2 (the-as (pointer vif-tag) (-> v1-1 base))) + ) + (set! (-> a1-2 0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x20)) + (set! (-> a1-2 1) (new 'static 'vif-tag :cmd (vif-cmd stmod))) + (set! (-> a1-2 2) (new 'static 'vif-tag :cmd (vif-cmd flusha) :msk #x1)) + (set! (-> a1-2 3) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1)) + (set! (-> a1-2 4) (new 'static 'vif-tag)) + (set! (-> a1-2 5) (new 'static 'vif-tag)) + (set! (-> a1-2 6) (new 'static 'vif-tag)) + (set! (-> a1-2 7) (new 'static 'vif-tag)) + (set! (-> v1-1 base) (&-> a1-2 8)) + ) + (dma-buffer-add-gs-set arg0 (test-1 (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)))) + 0 + (none) + ) + +;; definition for function hfrag-vu1-init-buf +;; WARN: Return type mismatch int vs none. +(defun hfrag-vu1-init-buf () + (let ((v1-0 *display*) + (a0-5 (+ (* (+ (/ (-> hfrag-vu1-block qlength) 127) 1) 16) 1568)) + ) + (+! (-> v1-0 mem-reserve-size) a0-5) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((a2-0 (-> v1-0 frames (-> v1-0 on-screen) global-buf))) + (if (< (-> a2-0 real-buffer-end) (the-as int (&+ (-> a2-0 base) a0-5))) + (set! (-> v1-0 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-0 dma-buffer-overflow)) + (let ((gp-0 (-> *display* frames (-> *display* on-screen) bucket-group 8))) + (when (!= gp-0 (-> gp-0 last)) + (let* ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-3 (-> s4-0 base)) + ) + (dma-buffer-add-vu-function s4-0 hfrag-vu1-block 1) + (hfrag-add-constants s4-0) + (let* ((v1-14 s4-0) + (a0-13 (the-as dma-packet (-> v1-14 base))) + ) + (set! (-> a0-13 dma) (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt))) + (set! (-> a0-13 vif0) (new 'static 'vif-tag)) + (set! (-> a0-13 vif1) (new 'static 'vif-tag :cmd (vif-cmd strow) :msk #x1)) + (set! (-> v1-14 base) (the-as pointer (&+ a0-13 16))) + ) + (let* ((v1-15 s4-0) + (a0-15 (-> v1-15 base)) + ) + (set! (-> (the-as (pointer uint32) a0-15) 0) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 1) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 2) (the-as uint 0)) + (set! (-> (the-as (pointer uint32) a0-15) 3) (the-as uint 0)) + (set! (-> (the-as (pointer vif-tag) a0-15) 4) (new 'static 'vif-tag :cmd (vif-cmd base))) + (set! (-> (the-as (pointer vif-tag) a0-15) 5) (new 'static 'vif-tag :cmd (vif-cmd offset))) + (set! (-> (the-as (pointer vif-tag) a0-15) 6) (new 'static 'vif-tag :cmd (vif-cmd stmod))) + (set! (-> (the-as (pointer vif-tag) a0-15) 7) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x22)) + (set! (-> v1-15 base) (&+ a0-15 32)) + ) + (let ((v1-16 (the-as dma-packet (-> s4-0 base)))) + (set! (-> v1-16 dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-0 next))) + (set! (-> v1-16 vif0) (new 'static 'vif-tag)) + (set! (-> v1-16 vif1) (new 'static 'vif-tag)) + (set! (-> s4-0 base) (the-as pointer (&+ v1-16 16))) + ) + (set! (-> gp-0 next) (the-as uint s5-3)) + ) + ) + ) + ) + ) + ) + (let ((v1-18 *display*) + (a0-19 96) + ) + (+! (-> v1-18 mem-reserve-size) a0-19) + (when (not (-> v1-18 dma-buffer-overflow)) + (let ((a2-6 (-> v1-18 frames (-> v1-18 on-screen) global-buf))) + (if (< (-> a2-6 real-buffer-end) (the-as int (&+ (-> a2-6 base) a0-19))) + (set! (-> v1-18 dma-buffer-overflow) #t) + ) + ) + (when (not (-> v1-18 dma-buffer-overflow)) + (let ((gp-1 (-> *display* frames (-> *display* on-screen) bucket-group 8))) + (when (!= gp-1 (-> gp-1 last)) + (let* ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (s5-4 (-> s4-1 base)) + ) + (hfrag-vu1-end-buffer s4-1) + (let ((a1-31 (-> s4-1 base))) + (let ((v1-32 (the-as dma-packet (-> s4-1 base)))) + (set! (-> v1-32 dma) (new 'static 'dma-tag :id (dma-tag-id next))) + (set! (-> v1-32 vif0) (new 'static 'vif-tag)) + (set! (-> v1-32 vif1) (new 'static 'vif-tag)) + (set! (-> s4-1 base) (the-as pointer (&+ v1-32 16))) + ) + (set! (-> (the-as (pointer uint32) (-> gp-1 last)) 1) (the-as uint s5-4)) + (set! (-> gp-1 last) (the-as (pointer dma-tag) a1-31)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-work_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-work_REF.gc new file mode 100644 index 000000000..a26257f41 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag-work_REF.gc @@ -0,0 +1,959 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 14 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod setup-far-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((v1-3 (* (+ (* 20 arg1) (* arg2 4)) 4)) + (a0-2 (* arg2 32)) + (a2-1 (* arg1 32)) + ) + (set! (-> arg0 index0) (the-as uint v1-3)) + (set! (-> arg0 index1) (the-as uint v1-3)) + (set! (-> arg0 index2) (the-as uint v1-3)) + (set! (-> arg0 pos x) (the-as uint a0-2)) + (set! (-> arg0 pos y) (the-as uint a2-1)) + ) + 0 + (none) + ) + +;; definition for method 15 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod setup-mid-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((t1-0 (* (+ (* 20 arg1) (* arg2 2)) 4)) + (v1-3 (* arg2 16)) + (a0-2 (* arg1 16)) + ) + (let ((t0-2 (logior (* (logand arg1 1) 2) (logand arg2 1)))) + (set! (-> arg0 index0) (the-as uint t1-0)) + (cond + ((zero? t0-2) + (set! (-> arg0 index1) (the-as uint t1-0)) + (set! (-> arg0 index2) (the-as uint t1-0)) + ) + ((= t0-2 1) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 arg1) (* (+ arg2 -1) 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 arg1) (* (+ arg2 1) 2)) 4))) + ) + ((= t0-2 2) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) (* arg2 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) (* arg2 2)) 4))) + ) + ((= t0-2 3) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) (* (+ arg2 1) 2)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) (* (+ arg2 -1) 2)) 4))) + ) + ) + ) + (set! (-> arg0 pos x) (the-as uint v1-3)) + (set! (-> arg0 pos y) (the-as uint a0-2)) + ) + 0 + (none) + ) + +;; definition for method 16 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod setup-near-vertex-index! ((this hfrag-work) (arg0 hfrag-vert-index) (arg1 int) (arg2 int)) + (let ((t1-0 (* (+ (* 20 arg1) arg2) 4)) + (v1-3 (* arg2 8)) + (a0-1 (* arg1 8)) + ) + (let ((t0-2 (logior (* (logand arg1 1) 2) (logand arg2 1)))) + (set! (-> arg0 index0) (the-as uint t1-0)) + (cond + ((zero? t0-2) + (set! (-> arg0 index1) (the-as uint t1-0)) + (set! (-> arg0 index2) (the-as uint t1-0)) + ) + ((= t0-2 1) + (set! (-> arg0 index1) (the-as uint (* (+ arg2 -1 (* 20 arg1)) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ arg2 1 (* 20 arg1)) 4))) + ) + ((= t0-2 2) + (set! (-> arg0 index1) (the-as uint (* (+ (* 20 (+ arg1 -1)) arg2) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ (* 20 (+ arg1 1)) arg2) 4))) + ) + ((= t0-2 3) + (set! (-> arg0 index1) (the-as uint (* (+ arg2 1 (* 20 (+ arg1 -1))) 4))) + (set! (-> arg0 index2) (the-as uint (* (+ arg2 -1 (* 20 (+ arg1 1))) 4))) + ) + ) + ) + (set! (-> arg0 pos x) (the-as uint v1-3)) + (set! (-> arg0 pos y) (the-as uint a0-1)) + ) + 0 + (none) + ) + +;; definition for method 17 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod init-montage-tex-coords ((this hfrag-work)) + (let ((f0-0 0.0)) + (dotimes (v1-0 8) + (dotimes (a1-0 16) + (let ((a2-4 (-> this montage-tex-coords (+ (* v1-0 16) a1-0)))) + (set-vector! (-> a2-4 stq0) (* 0.0625 (+ (the float a1-0) f0-0)) (* 0.125 (+ (the float v1-0) f0-0)) 1.0 0.0) + (set-vector! + (-> a2-4 stq1) + (* 0.0625 (- (the float (+ a1-0 1)) f0-0)) + (* 0.125 (- (the float (+ v1-0 1)) f0-0)) + 1.0 + 0.0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod initialize-renderer! ((this hfrag-work)) + (set! (-> this poly-far) (new 'loading-level 'hfrag-poly25)) + (set! (-> this poly-mid25) (the-as (inline-array hfrag-poly25) (malloc 'loading-level 800))) + (set! (-> this poly-mid) (the-as (inline-array hfrag-poly9) (malloc 'loading-level 1152))) + (set! (-> this poly-near) (the-as (inline-array hfrag-poly9) (malloc 'loading-level 4608))) + (set! (-> this init-vu1-tmpl 0 init-vif) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2c)) + (set! (-> this init-vu1-tmpl 1 init-vif) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2c)) + (set! (-> this call-abort-vu1 vif0) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x20)) + (set! (-> this call-poly4-near) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x2e)) + (set! (-> this call-poly9-mid) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x14b)) + (set! (-> this call-poly9-near) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x14f)) + (set! (-> this call-poly25-far) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x7d)) + (set! (-> this call-poly25-mid) (new 'static 'vif-tag :cmd (vif-cmd mscalf) :msk #x1 :imm #x7f)) + (set! (-> this next-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> this ret-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (let ((s5-0 (-> this poly-far))) + (cond + ((nonzero? s5-0) + (dotimes (s4-0 5) + (dotimes (s3-0 5) + (let ((v1-21 (+ (* 5 s3-0) s4-0))) + (setup-far-vertex-index! this (-> s5-0 data v1-21) s4-0 s3-0) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-far table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-1 (-> this poly-mid25))) + (cond + ((nonzero? s5-1) + (dotimes (s4-1 2) + (dotimes (s3-1 2) + (let ((s2-0 (-> s5-1 (+ (* s4-1 2) s3-1))) + (s1-0 (* s4-1 4)) + (s0-0 (* s3-1 4)) + ) + (setup-mid-vertex-index! this (the-as hfrag-vert-index (-> s2-0 data)) s1-0 s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 1) (+ s1-0 1) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 2) (+ s1-0 2) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 3) (+ s1-0 3) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 4) (+ s1-0 4) s0-0) + (setup-mid-vertex-index! this (-> s2-0 data 5) s1-0 (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 6) (+ s1-0 1) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 7) (+ s1-0 2) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 8) (+ s1-0 3) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 9) (+ s1-0 4) (+ s0-0 1)) + (setup-mid-vertex-index! this (-> s2-0 data 10) s1-0 (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 11) (+ s1-0 1) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 12) (+ s1-0 2) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 13) (+ s1-0 3) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 14) (+ s1-0 4) (+ s0-0 2)) + (setup-mid-vertex-index! this (-> s2-0 data 15) s1-0 (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 16) (+ s1-0 1) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 17) (+ s1-0 2) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 18) (+ s1-0 3) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 19) (+ s1-0 4) (+ s0-0 3)) + (setup-mid-vertex-index! this (-> s2-0 data 20) s1-0 (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 21) (+ s1-0 1) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 22) (+ s1-0 2) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 23) (+ s1-0 3) (+ s0-0 4)) + (setup-mid-vertex-index! this (-> s2-0 data 24) (+ s1-0 4) (+ s0-0 4)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-far table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-2 (-> this poly-mid))) + (cond + ((nonzero? s5-2) + (dotimes (s4-2 4) + (dotimes (s3-2 4) + (let ((s2-1 (-> s5-2 (+ (* s4-2 4) s3-2))) + (s1-1 (* s4-2 2)) + (s0-1 (* s3-2 2)) + ) + (setup-mid-vertex-index! this (the-as hfrag-vert-index (-> s2-1 data)) s1-1 s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 1) (+ s1-1 1) s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 2) (+ s1-1 2) s0-1) + (setup-mid-vertex-index! this (-> s2-1 data 3) s1-1 (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 4) (+ s1-1 1) (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 5) (+ s1-1 2) (+ s0-1 1)) + (setup-mid-vertex-index! this (-> s2-1 data 6) s1-1 (+ s0-1 2)) + (setup-mid-vertex-index! this (-> s2-1 data 7) (+ s1-1 1) (+ s0-1 2)) + (setup-mid-vertex-index! this (-> s2-1 data 8) (+ s1-1 2) (+ s0-1 2)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-mid table~%") + (break!) + 0 + ) + ) + ) + (let ((s5-3 (-> this poly-near))) + (cond + ((nonzero? s5-3) + (dotimes (s4-3 8) + (dotimes (s3-3 8) + (let ((s2-2 (-> s5-3 (+ (* s4-3 8) s3-3))) + (s1-2 (* s4-3 2)) + (s0-2 (* s3-3 2)) + ) + (setup-near-vertex-index! this (the-as hfrag-vert-index (-> s2-2 data)) s1-2 s0-2) + (setup-near-vertex-index! this (-> s2-2 data 1) (+ s1-2 1) s0-2) + (setup-near-vertex-index! this (-> s2-2 data 2) (+ s1-2 2) s0-2) + (setup-near-vertex-index! this (-> s2-2 data 3) s1-2 (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 4) (+ s1-2 1) (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 5) (+ s1-2 2) (+ s0-2 1)) + (setup-near-vertex-index! this (-> s2-2 data 6) s1-2 (+ s0-2 2)) + (setup-near-vertex-index! this (-> s2-2 data 7) (+ s1-2 1) (+ s0-2 2)) + (setup-near-vertex-index! this (-> s2-2 data 8) (+ s1-2 2) (+ s0-2 2)) + ) + ) + ) + ) + (else + (format 0 "ERROR: couldn't allocate memory for poly-near table~%") + (break!) + 0 + ) + ) + ) + (let ((f1-0 (-> this near-dist)) + (f0-0 (-> this far-dist)) + ) + (let ((f2-1 (* 0.14285715 (- f0-0 f1-0)))) + (set! (-> this dists x) (- f1-0)) + (set! (-> this dists y) (- (+ f1-0 (* 0.5 f2-1)))) + (set! (-> this dists z) (- (+ f1-0 (* 2.0 f2-1)))) + ) + (set! (-> this dists w) (- f0-0)) + ) + (set! (-> this rdists x) (/ 1.0 (-> this dists x))) + (set! (-> this rdists y) (/ 1.0 (-> this dists y))) + (set! (-> this rdists z) (/ 1.0 (-> this dists z))) + (set! (-> this rdists w) (/ 1.0 (-> this dists w))) + (init-montage-tex-coords this) + 0 + (none) + ) + +;; definition for symbol *hfrag-work*, type hfrag-work +(define *hfrag-work* + (new 'static 'hfrag-work + :far-chaina (new 'static 'inline-array dma-packet 6 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :far-chainb (new 'static 'inline-array dma-packet 6 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :mid-chaina (new 'static 'inline-array dma-packet 10 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :mid-chainb (new 'static 'inline-array dma-packet 10 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :near-chaina (new 'static 'inline-array dma-packet 18 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :near-chainb (new 'static 'inline-array dma-packet 18 + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id ref))) + (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id end))) + ) + :poly4-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + ) + :poly9-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x24 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #x24 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :poly25-tmpl (new 'static 'inline-array dma-packet 3 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x120 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x78 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x237 :num #x78 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :init-tmpl (new 'static 'inline-array hfrag-init-packet 3 + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x117 #x0 #x0 #x0 #x1500000c) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x22e #x0 #x0 #x0 #x1500000c) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x388 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x363 #x0 #x0 #x0 #x0 #x1500000c) + ) + ) + :control-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x345 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #xc :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x363 :num #xc :cmd (vif-cmd unpack-v4-32)) + ) + ) + :heights4-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x2 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x2 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors4-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #x4 :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x1 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #x4 :cmd (vif-cmd unpack-v4-8)) + ) + ) + :heights9-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x3 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x3 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors9-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #xc :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x3 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #xc :cmd (vif-cmd unpack-v4-8)) + ) + ) + :heights25-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :num #x7 :cmd (vif-cmd unpack-v4-32)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :num #x7 :cmd (vif-cmd unpack-v4-32)) + ) + ) + :colors25-tmpl (new 'static 'inline-array dma-packet 2 + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #xe :num #x1c :cmd (vif-cmd unpack-v4-8)) + ) + (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x2a :num #x1c :cmd (vif-cmd unpack-v4-8)) + ) + ) + :init-vu1-tmpl (new 'static 'inline-array hfrag-init-packet 2 + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x1e6 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #x2a #x7 #x0 #x0 #x0 #x0) + ) + (new 'static 'hfrag-init-packet + :init-tmpl (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x2 :id (dma-tag-id call)) + :vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl)) + :vif1 (new 'static 'vif-tag :imm #x1e6 :num #x1 :cmd (vif-cmd unpack-v4-32)) + ) + :init-data (new 'static 'array uint32 8 #x0 #x0 #xe #x0 #x0 #x0 #x0 #x0) + ) + ) + :next-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))) + :call-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id call))) + :ret-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id ret))) + :next-scissor-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id next))) + :ret-scissor-tmpl (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id ret))) + :frame-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x5 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x5 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008004 #xe) + ) + :frames (new 'static 'inline-array hfrag-frame 5 + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x6f :fbw #x2) + :scissor (new 'static 'gs-scissor :scax1 #x7f :scay1 #x7f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x77 :fbw #x1) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x3f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x79 :fbw #x1) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x1f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x79 :fbw #x1 :fbmsk #xff000000) + :scissor (new 'static 'gs-scissor :scax1 #x3f :scay1 #x1f) + :test (new 'static 'gs-test :ate #x1 :afail #x1 :zte #x1 :ztst (gs-ztest always)) + ) + (new 'static 'hfrag-frame + :reg-0 (gs-reg frame-1) + :reg-1 (gs-reg scissor-1) + :reg-2 (gs-reg xyoffset-1) + :reg-3 (gs-reg test-1) + :frame (new 'static 'gs-frame :fbp #x198 :fbw #x8) + :scissor (new 'static 'gs-scissor :scax1 #x1ff :scay1 #x19f) + :xyoffset (new 'static 'gs-xy-offset :ofx #x7000 :ofy #x7300) + :test (new 'static 'gs-test :zte #x1 :ztst (gs-ztest greater-equal)) + ) + ) + :adgif-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008005 #xe) + ) + :adgif-tmpl2 (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x7 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x7 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x1000000000008006 #xe) + ) + :sprite-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x6 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x500b400000008001 #x52521) + ) + :mip-tmpl (new 'static 'dma-gif-packet + :dma-vif (new 'static 'dma-packet + :dma (new 'static 'dma-tag :qwc #x9 :id (dma-tag-id cnt)) + :vif1 (new 'static 'vif-tag :imm #x9 :cmd (vif-cmd direct) :msk #x1) + ) + :gif (new 'static 'array uint64 2 #x802f400000008001 #x52521eee) + ) + :color (new 'static 'inline-array vector4w 6 + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x80) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w #x70) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 88) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 64) + (new 'static 'vector4w :x #x80 :y #x80 :z #x80 :w 32) + (new 'static 'vector4w) + ) + :far-data (new 'static 'hfrag-sprite-coord + :pos0 (new 'static 'vector4w :z #xffffff) + :pos1 (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + :near-data (new 'static 'inline-array vector4w-2 16 + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x200 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x400 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x600 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x400 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x600 :y #x800 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x600 :y #x600 :z #xffffff) + (new 'static 'vector4w :x #x800 :y #x800 :z #xffffff) + ) + ) + ) + :mip-data (new 'static 'inline-array vector4w-2 7 + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x400 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x200 :y #x200 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x200 :z #xffffff) + (new 'static 'vector4w :x #x300 :y #x100 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x300 :z #xffffff) + (new 'static 'vector4w :x #x380 :y #x80 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x380 :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x80 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :x #x300 :y #x80 :z #xffffff) + (new 'static 'vector4w :x #x380 :y #x100 :z #xffffff) + ) + ) + (new 'static 'vector4w-2 + :vector (new 'static 'inline-array vector4w 2 + (new 'static 'vector4w :z #xffffff) + (new 'static 'vector4w :x #x400 :y #x200 :z #xffffff) + ) + ) + ) + :tex-data (new 'static 'inline-array hfrag-tex-data 5 + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xde0 :tbw #x2 :tw #x7 :th #x7 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xee0 :tbw #x1 :tw #x6 :th #x6 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf20 :tbw #x1 :tw #x5 :th #x5 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf30 :tbw #x1 :tw #x4 :th #x4 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + (new 'static 'hfrag-tex-data + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg texflush) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf34 :tbw #x1 :tw #x3 :th #x3 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mmin #x1) + ) + ) + :tex (new 'static 'inline-array vector 6 + (new 'static 'vector :z 1.0) + (new 'static 'vector :x 1.015625 :y 1.015625 :z 1.0) + (new 'static 'vector :x 1.03125 :y 1.03125 :z 1.0) + (new 'static 'vector :x 1.0625 :y 1.0625 :z 1.0) + (new 'static 'vector :x 1.125 :y 1.125 :z 1.0) + (new 'static 'vector :x 2.0 :y 2.0 :z 1.0) + ) + :giftag (new 'static 'generic-gif-tag + :fan-prim (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1 :abe #x1) + :nreg #x3 + ) + :str-prim (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1 :abe #x1) + :nreg #x3 + ) + :regs (new 'static 'gif-tag-regs-32 :regs0 (gif-reg-id st) :regs1 (gif-reg-id rgbaq) :regs2 (gif-reg-id xyzf2)) + :num-strips #x1 + ) + :call-abort (new 'static 'dma-packet + :dma (new 'static 'dma-tag :id (dma-tag-id cnt)) + :vif0 (new 'static 'vif-tag :imm #x4 :cmd (vif-cmd mscalf) :msk #x1) + ) + :call-abort-vu1 (new 'static 'dma-packet :dma (new 'static 'dma-tag :id (dma-tag-id cnt))) + :shader-far (new 'static 'adgif-shader + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg miptbp1-1) + :reg-3 (gs-reg clamp-1) + :reg-4 (gs-reg miptbp2-1) + :tex0 (new 'static 'gs-tex0 :tbp0 #xf20 :tbw #x1 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mxl #x1 :k #xfb1) + :clamp (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + ) + :shader-near (new 'static 'adgif-shader + :reg-0 (gs-reg tex0-1) + :reg-1 (gs-reg tex1-1) + :reg-2 (gs-reg miptbp1-1) + :reg-3 (gs-reg clamp-1) + :reg-4 (gs-reg miptbp2-1) + :tex0 (new 'static 'gs-tex0 :tbp0 #xde0 :tbw #x2 :tw #x7 :th #x7 :tcc #x1) + :tex1 (new 'static 'gs-tex1 :mxl #x6 :mmag #x1 :mmin #x5 :k #xfbf) + :miptbp1 (new 'static 'gs-miptbp :tbp1 #xee0 :tbw1 #x1 :tbp2 #xf20 :tbw2 #x1 :tbp3 #xf30 :tbw3 #x1) + :clamp (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)) + :alpha (new 'static 'gs-miptbp :tbp1 #xf34 :tbw1 #x1 :tbp2 #xf35 :tbw2 #x1 :tbp3 #xf36) + ) + :stq (new 'static 'inline-array vector4w 9 + (new 'static 'vector4w :x 1) + (new 'static 'vector4w :x #x801) + (new 'static 'vector4w :x #x1001) + (new 'static 'vector4w :y #x800) + (new 'static 'vector4w :x #x800 :y #x800) + (new 'static 'vector4w :x #x1000 :y #x800) + (new 'static 'vector4w :y #x1000) + (new 'static 'vector4w :x #x800 :y #x1000) + (new 'static 'vector4w :x #x1000 :y #x1000) + ) + :constants (new 'static 'vector :x 0.5) + :near-dist 1228800.0 + :far-dist 4096000.0 + :lowres-flag #f + ) + ) + +;; failed to figure out what this is: +(initialize-renderer! *hfrag-work*) + +;; definition for symbol *hfrag-vu1-constants-base*, type hfrag-vu1-constants-base +(define *hfrag-vu1-constants-base* (new 'static 'hfrag-vu1-constants-base + :far-verts (new 'static 'inline-array vector 25 + (new 'static 'vector) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :z 262144.0) + (new 'static 'vector :z 393216.0) + (new 'static 'vector :z 524288.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 262144.0) + (new 'static 'vector :x 131072.0 :z 393216.0) + (new 'static 'vector :x 131072.0 :z 524288.0) + (new 'static 'vector :x 262144.0) + (new 'static 'vector :x 262144.0 :z 131072.0) + (new 'static 'vector :x 262144.0 :z 262144.0) + (new 'static 'vector :x 262144.0 :z 393216.0) + (new 'static 'vector :x 262144.0 :z 524288.0) + (new 'static 'vector :x 393216.0) + (new 'static 'vector :x 393216.0 :z 131072.0) + (new 'static 'vector :x 393216.0 :z 262144.0) + (new 'static 'vector :x 393216.0 :z 393216.0) + (new 'static 'vector :x 393216.0 :z 524288.0) + (new 'static 'vector :x 524288.0) + (new 'static 'vector :x 524288.0 :z 131072.0) + (new 'static 'vector :x 524288.0 :z 262144.0) + (new 'static 'vector :x 524288.0 :z 393216.0) + (new 'static 'vector :x 524288.0 :z 524288.0) + ) + :mid-verts9 (new 'static 'inline-array vector 9 + (new 'static 'vector) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + (new 'static 'vector :x 131072.0 :z 65536.0) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :x 65536.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + ) + :mid-verts25 (new 'static 'inline-array vector 25 + (new 'static 'vector) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :z 131072.0) + (new 'static 'vector :z 196608.0) + (new 'static 'vector :z 262144.0) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + (new 'static 'vector :x 65536.0 :z 131072.0) + (new 'static 'vector :x 65536.0 :z 196608.0) + (new 'static 'vector :x 65536.0 :z 262144.0) + (new 'static 'vector :x 131072.0) + (new 'static 'vector :x 131072.0 :z 65536.0) + (new 'static 'vector :x 131072.0 :z 131072.0) + (new 'static 'vector :x 131072.0 :z 196608.0) + (new 'static 'vector :x 131072.0 :z 262144.0) + (new 'static 'vector :x 196608.0) + (new 'static 'vector :x 196608.0 :z 65536.0) + (new 'static 'vector :x 196608.0 :z 131072.0) + (new 'static 'vector :x 196608.0 :z 196608.0) + (new 'static 'vector :x 196608.0 :z 262144.0) + (new 'static 'vector :x 262144.0) + (new 'static 'vector :x 262144.0 :z 65536.0) + (new 'static 'vector :x 262144.0 :z 131072.0) + (new 'static 'vector :x 262144.0 :z 196608.0) + (new 'static 'vector :x 262144.0 :z 262144.0) + ) + :near-verts4 (new 'static 'inline-array vector 4 + (new 'static 'vector) + (new 'static 'vector :x 32768.0) + (new 'static 'vector :z 32768.0) + (new 'static 'vector :x 32768.0 :z 32768.0) + ) + :near-verts9 (new 'static 'inline-array vector 9 + (new 'static 'vector) + (new 'static 'vector :x 32768.0) + (new 'static 'vector :x 65536.0) + (new 'static 'vector :z 32768.0) + (new 'static 'vector :x 32768.0 :z 32768.0) + (new 'static 'vector :x 65536.0 :z 32768.0) + (new 'static 'vector :z 65536.0) + (new 'static 'vector :x 32768.0 :z 65536.0) + (new 'static 'vector :x 65536.0 :z 65536.0) + ) + :sts (new 'static 'inline-array vector 9 + (new 'static 'vector :z 1.0) + (new 'static 'vector :x 0.5 :z 1.0) + (new 'static 'vector :x 1.0 :z 1.0) + (new 'static 'vector :y 0.5 :z 1.0) + (new 'static 'vector :x 0.5 :y 0.5 :z 1.0) + (new 'static 'vector :x 1.0 :y 0.5 :z 1.0) + (new 'static 'vector :y 1.0 :z 1.0) + (new 'static 'vector :x 0.5 :y 1.0 :z 1.0) + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0) + ) + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag_REF.gc new file mode 100644 index 000000000..111f14677 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/background/hfrag/hfrag_REF.gc @@ -0,0 +1,1036 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 10 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod init-work-from-current-hfrag! ((this hfrag-work)) + (let ((v1-0 (-> this hfrag))) + (set! (-> this lowres-flag) #f) + (dotimes (a1-0 (-> *level* length)) + (let ((a2-3 (-> *level* level a1-0))) + (when (= (-> a2-3 status) 'active) + (if (logtest? (-> a2-3 info level-flags) (level-flags low-res-hfrag)) + (set! (-> this lowres-flag) #t) + ) + ) + ) + ) + (let ((f0-0 (-> v1-0 start-corner x)) + (f1-0 (-> v1-0 start-corner z)) + ) + (dotimes (a1-3 32) + (dotimes (a2-9 32) + (let ((a3-6 (+ (* a1-3 32) a2-9))) + (set! (-> this corners a3-6 x) (+ f0-0 (* 524288.0 (the float a2-9)))) + (set! (-> this corners a3-6 y) 0.0) + (set! (-> this corners a3-6 z) (+ f1-0 (* 524288.0 (the float a1-3)))) + (set! (-> this corners a3-6 w) 1.0) + ) + ) + ) + ) + (let ((f0-1 (-> this near-dist)) + (f2-8 (-> this far-dist)) + (f1-1 819200.0) + ) + (set! (-> this dists x) (- f2-8)) + (set! (-> this dists y) (- f0-1)) + (set! (-> this rdists x) (/ 1.0 (- (- f2-8 (+ f0-1 f1-1))))) + (set! (-> this rdists y) (/ 1.0 (- (- f0-1 f1-1)))) + ) + (set! (-> this next-far) -1) + (set! (-> this next-far-mid) -1) + (set! (-> this next-mid) -1) + (set! (-> this next-near-mid) -1) + (set! (-> this next-near) -1) + (set! (-> this next-far-scissor) -1) + (set! (-> this next-near-mid-scissor) -1) + (set! (-> this next-near-scissor) -1) + (set! (-> this count-far) 0) + (set! (-> this count-far-mid) 0) + (set! (-> this count-mid) 0) + (set! (-> this count-near-mid) 0) + (set! (-> this count-near) 0) + (set! (-> this count-far-scissor) 0) + (set! (-> this count-near-mid-scissor) 0) + (set! (-> this count-near-scissor) 0) + (let ((a0-1 (-> v1-0 num-buckets-far))) + (dotimes (a1-18 (the-as int a0-1)) + (let ((a2-13 (-> v1-0 buckets-far a1-18))) + (set! (-> a2-13 next) (the-as pointer 0)) + (set! (-> a2-13 count) (the-as uint 0)) + (set! (-> a2-13 vertex-count) (the-as uint 32)) + (set! (-> a2-13 next-scissor) (the-as pointer 0)) + (set! (-> a2-13 count-scissor) (the-as uint 0)) + (set! (-> a2-13 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + (let ((a0-4 (-> v1-0 num-buckets-mid))) + (dotimes (a1-19 (the-as int a0-4)) + (let ((a2-15 (-> v1-0 buckets-mid a1-19))) + (set! (-> a2-15 next) (the-as pointer 0)) + (set! (-> a2-15 count) (the-as uint 0)) + (set! (-> a2-15 vertex-count) (the-as uint 32)) + (set! (-> a2-15 next-scissor) (the-as pointer 0)) + (set! (-> a2-15 count-scissor) (the-as uint 0)) + (set! (-> a2-15 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + (let ((a0-7 (-> v1-0 num-buckets-near))) + (dotimes (a1-20 (the-as int a0-7)) + (let ((a2-17 (-> v1-0 buckets-near a1-20))) + (set! (-> a2-17 next) (the-as pointer 0)) + (set! (-> a2-17 count) (the-as uint 0)) + (set! (-> a2-17 vertex-count) (the-as uint 32)) + (set! (-> a2-17 next-scissor) (the-as pointer 0)) + (set! (-> a2-17 count-scissor) (the-as uint 0)) + (set! (-> a2-17 vertex-count-scissor) (the-as uint 48)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod pick-level-of-detail! ((this hfrag-work) (arg0 level)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf12 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf20 :class vf) + (vf21 :class vf) + (vf22 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (-> this hfrag)) + (s2-0 (new 'stack-no-clear 'vector)) + ) + 0 + (let ((s4-0 *math-camera*)) + (vector-! s2-0 (camera-pos) (-> s5-0 start-corner)) + (+ (* (the int (* 0.0000019073486 (-> s2-0 y))) 32) (the int (* 0.0000019073486 (-> s2-0 x)))) + (.lvf vf16 (&-> s4-0 plane 0 quad)) + (.lvf vf17 (&-> s4-0 plane 1 quad)) + (.lvf vf18 (&-> s4-0 plane 2 quad)) + (.lvf vf19 (&-> s4-0 plane 3 quad)) + (.lvf vf20 (&-> s4-0 guard-plane 0 quad)) + (.lvf vf21 (&-> s4-0 guard-plane 1 quad)) + (.lvf vf22 (&-> s4-0 guard-plane 2 quad)) + (.lvf vf23 (&-> s4-0 guard-plane 3 quad)) + (.lvf vf24 (&-> s4-0 camera-rot rvec quad)) + (.lvf vf25 (&-> s4-0 camera-rot uvec quad)) + (.lvf vf26 (&-> s4-0 camera-rot fvec quad)) + (.lvf vf27 (&-> s4-0 camera-rot trans quad)) + (let ((s3-1 (+ (+ (- (-> arg0 bsp visible-list-length) (-> arg0 bsp extra-vis-list-length)) 0) + (the-as int (-> arg0 vis-bits)) + ) + ) + ) + (dotimes (s2-1 1024) + (let ((v1-13 (/ (-> s5-0 visids s2-1) 8)) + (a0-9 (ash 128 (- (logand (-> s5-0 visids s2-1) 7)))) + ) + (when (logtest? (-> (the-as (pointer uint8) (+ v1-13 (the-as int s3-1)))) a0-9) + (let ((s1-2 (-> s5-0 spheres s2-1))) + (when (sphere-cull s1-2) + (set! (-> this scissor) (guard-band-cull s1-2)) + (.lvf vf12 (&-> s1-2 quad)) + (.mul.x.vf acc vf24 vf12) + (.add.mul.y.vf acc vf25 vf12 acc) + (.add.mul.z.vf acc vf26 vf12 acc) + (.add.mul.w.vf vf12 vf27 vf0 acc) + (.svf (&-> this pos-temp quad) vf12) + (let* ((f0-6 (-> this trans-temp z)) + (f2-0 (-> s1-2 w)) + (f1-2 (+ f0-6 f2-0)) + (f0-7 (- f0-6 f2-0)) + (v1-20 0) + ) + (if (< f0-7 (-> s4-0 d)) + (set! (-> this scissor) #t) + ) + (if (< f1-2 (-> this far-dist)) + (set! v1-20 (logior v1-20 8)) + ) + (if (< f0-7 (-> this far-dist)) + (set! v1-20 (logior v1-20 4)) + ) + (if (< f1-2 (-> this near-dist)) + (set! v1-20 (logior v1-20 2)) + ) + (if (< f0-7 (-> this near-dist)) + (set! v1-20 (logior v1-20 1)) + ) + (set! (-> this subdiv-index) (the-as uint v1-20)) + ) + (cond + ((or (zero? (-> this subdiv-index)) (-> this lowres-flag)) + (cond + ((-> this scissor) + (set! (-> this draw-table s2-1) (-> this next-far-scissor)) + (set! (-> this next-far-scissor) s2-1) + (+! (-> this count-far-scissor) 1) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-far)) + (set! (-> this next-far) s2-1) + (+! (-> this count-far) 1) + ) + ) + ) + ((= (-> this subdiv-index) 4) + (set! (-> this draw-table s2-1) (-> this next-far-mid)) + (set! (-> this next-far-mid) s2-1) + (+! (-> this count-far-mid) 1) + ) + ((= (-> this subdiv-index) 12) + (set! (-> this draw-table s2-1) (-> this next-mid)) + (set! (-> this next-mid) s2-1) + (+! (-> this count-mid) 1) + ) + ((= (-> this subdiv-index) 13) + (cond + ((-> this scissor) + (set! (-> this draw-table s2-1) (-> this next-near-mid-scissor)) + (set! (-> this next-near-mid-scissor) s2-1) + (+! (-> this count-near-mid-scissor) 1) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-near-mid)) + (set! (-> this next-near-mid) s2-1) + (+! (-> this count-near-mid) 1) + ) + ) + ) + (else + (set! (-> this draw-table s2-1) (-> this next-near)) + (set! (-> this next-near) s2-1) + (+! (-> this count-near) 1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 12 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod generate-vertices! ((this hfrag-work)) + (local-vars (v1-1 float)) + (rlet ((vf13 :class vf) + (vf14 :class vf) + (vf16 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf31 :class vf) + ) + (.lvf vf28 (&-> this constants quad)) + (.lvf vf13 (&-> this dists quad)) + (.lvf vf14 (&-> this rdists quad)) + (let ((v1-0 *math-camera*)) + (.lvf vf16 (&-> v1-0 camera-temp rvec quad)) + (.lvf vf17 (&-> v1-0 camera-temp uvec quad)) + (.lvf vf18 (&-> v1-0 camera-temp fvec quad)) + (.lvf vf19 (&-> v1-0 camera-temp trans quad)) + (.lvf vf24 (&-> v1-0 camera-rot rvec quad)) + (.lvf vf25 (&-> v1-0 camera-rot uvec quad)) + (.lvf vf26 (&-> v1-0 camera-rot fvec quad)) + (.lvf vf27 (&-> v1-0 camera-rot trans quad)) + (.lvf vf31 (&-> v1-0 hmge-scale quad)) + ) + (.mov v1-1 vf31) + (set! (-> this next-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (set! (-> this ret-scissor-tmpl vif0) (new 'static 'vif-tag :imm #x6 :cmd (vif-cmd mscalf) :msk #x1)) + (let ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf))) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag)) + (set! (-> this next-tmpl vif0) (-> this call-poly4-near)) + (set! (-> this ret-tmpl vif0) (-> this call-poly4-near)) + (if (>= (-> this next-near) 0) + (asm-near this s5-0 (-> this next-near)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly9-near)) + (set! (-> this ret-tmpl vif0) (-> this call-poly9-near)) + (if (>= (-> this next-near-mid) 0) + (asm-near-mid this s5-0 (-> this next-near-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly25-mid)) + (set! (-> this ret-tmpl vif0) (-> this call-poly25-mid)) + (if (>= (-> this next-mid) 0) + (asm-mid this s5-0 (-> this next-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly9-mid)) + (set! (-> this ret-tmpl vif0) (-> this call-poly9-mid)) + (if (>= (-> this next-far-mid) 0) + (asm-far-mid this s5-0 (-> this next-far-mid)) + ) + (set! (-> this next-tmpl vif0) (-> this call-poly25-far)) + (set! (-> this ret-tmpl vif0) (-> this call-poly25-far)) + (if (>= (-> this next-far) 0) + (asm-far this s5-0 (-> this next-far)) + ) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag-scissor)) + (if (>= (-> this next-far-scissor) 0) + (asm-far-scissor this s5-0 (-> this next-far-scissor)) + ) + (if (>= (-> this next-near-mid-scissor) 0) + (asm-near-mid-scissor this s5-0 (-> this next-near-mid-scissor)) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 23 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 13 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod finalize-dma! ((this hfrag-work)) + (local-vars (v1-40 float)) + (rlet ((vf10 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag)) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hfrag) + ) + (.lvf vf5 (&-> this tex-data 0 quad 2 quad)) + (.lvf vf6 (&-> this shader-far quad 0 quad)) + (.lvf vf7 (&-> this shader-far quad 1 quad)) + (.lvf vf8 (&-> this shader-far quad 2 quad)) + (.lvf vf9 (&-> this shader-far quad 3 quad)) + (.lvf vf10 (&-> this shader-far quad 4 quad)) + (hfrag-work-method-32 this s4-0) + (hfrag-work-method-33 this s4-0) + (.lvf vf6 (&-> this shader-near quad 0 quad)) + (.lvf vf7 (&-> this shader-near quad 1 quad)) + (.lvf vf8 (&-> this shader-near quad 2 quad)) + (.lvf vf9 (&-> this shader-near quad 3 quad)) + (.lvf vf10 (&-> this shader-near quad 4 quad)) + (hfrag-work-method-34 this s4-0) + ) + (hfrag-vu1-init-buf) + ) + (when (logtest? (-> *display* vu1-enable-user) (vu1-renderer-mask hfrag-scissor)) + (case *subdivide-scissor-draw-mode* + (((subdivide-setting textured)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting outline)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type line-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting gouraud)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + (((subdivide-setting hack)) + (set! (-> this giftag str-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-strip) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + (set! (-> this giftag fan-prim) + (new 'static 'gif-tag-prim + :pre #x1 + :prim (new 'static 'gs-prim :prim (gs-prim-type tri-fan) :iip #x1 :tme #x1 :fge #x1) + :nreg #x3 + ) + ) + ) + ) + (.lvf vf5 (&-> this giftag qword quad)) + (let ((v1-39 *math-camera*)) + (.lvf vf24 (&-> v1-39 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-39 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-39 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-39 camera-temp trans quad)) + ) + (.mov v1-40 vf27) + (with-dma-buffer-add-bucket ((s4-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id hfrag-scissor) + ) + (.lvf vf6 (&-> this shader-far quad 0 quad)) + (.lvf vf7 (&-> this shader-far quad 1 quad)) + (.lvf vf8 (&-> this shader-far quad 2 quad)) + (.lvf vf9 (&-> this shader-far quad 3 quad)) + (.lvf vf10 (&-> this shader-far quad 4 quad)) + (hfrag-work-method-24 this s4-1) + (hfrag-work-method-25 this s4-1) + (.lvf vf6 (&-> this shader-near quad 0 quad)) + (.lvf vf7 (&-> this shader-near quad 1 quad)) + (.lvf vf8 (&-> this shader-near quad 2 quad)) + (.lvf vf9 (&-> this shader-near quad 3 quad)) + (.lvf vf10 (&-> this shader-near quad 4 quad)) + (hfrag-work-method-26 this s4-1) + ) + (generic-vu1-init-buf (bucket-id hfrag-scissor) (new 'static 'gs-zbuf :zbp #x130 :psm (gs-psm ct24))) + ) + 0 + (none) + ) + ) + +;; definition for method 18 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 21 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 22 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 24 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 25 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for method 26 of type hfrag-work +;; ERROR: function was not converted to expressions. Cannot decompile. + +;; definition for symbol *hfrag-debug*, type symbol +(define *hfrag-debug* #t) + +;; definition for method 35 of type hfrag-work +;; WARN: Return type mismatch int vs none. +(defmethod trim-dma-to-fit-in-memory ((this hfrag-work)) + (let* ((a1-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (v1-5 (-> a1-1 base)) + (v1-6 (&- (-> a1-1 end) (the-as uint v1-5))) + (a1-5 (+ #x110c0 + (* (+ (/ (-> generic-vu1-block qlength) 127) 1) 16) + (* (+ (/ (-> hfrag-vu1-block qlength) 127) 1) 16) + ) + ) + ) + (set! (-> this size-far) (* 272 (-> this count-far))) + (set! (-> this size-far-mid) (* 2304 (-> this count-far-mid))) + (set! (-> this size-mid) (* 1088 (-> this count-mid))) + (set! (-> this size-near-mid) (* 9216 (-> this count-near-mid))) + (set! (-> this size-near) (+ (* #x6000 (-> this count-near)) 1120)) + (set! (-> this size-far-scissor) (* 1952 (-> this count-far-scissor))) + (set! (-> this size-near-mid-scissor) (* #x9800 (-> this count-near-mid-scissor))) + (let ((v0-0 (+ a1-5 + (-> this size-far) + (-> this size-far-mid) + (-> this size-mid) + (-> this size-near-mid) + (-> this size-near) + (-> this size-far-scissor) + (-> this size-near-mid-scissor) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-19 (min (the int (* 0.0036764706 (the float (+ (- 272 v1-6) v0-0)))) (-> this count-far)))) + (set! (-> this count-far) (- (-> this count-far) a1-19)) + (set! (-> this size-far) (- (-> this size-far) (* 272 a1-19))) + (set! v0-0 (- v0-0 (* 272 a1-19))) + (let ((a3-11 (-> this next-far))) + (dotimes (a2-39 a1-19) + (set! a3-11 (-> this draw-table a3-11)) + ) + (set! (-> this next-far) a3-11) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-29 (min (the int (* 0.00043402778 (the float (+ (- 2304 v1-6) v0-0)))) (-> this count-far-mid)))) + (set! (-> this count-far-mid) (- (-> this count-far-mid) a1-29)) + (set! (-> this size-far-mid) (- (-> this size-far-mid) (* 2304 a1-29))) + (set! v0-0 (- v0-0 (* 2304 a1-29))) + (let ((a3-16 (-> this next-far-mid))) + (dotimes (a2-47 a1-29) + (set! a3-16 (-> this draw-table a3-16)) + ) + (set! (-> this next-far-mid) a3-16) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-39 (min (the int (* 0.00091911765 (the float (+ (- 1088 v1-6) v0-0)))) (-> this count-mid)))) + (set! (-> this count-mid) (- (-> this count-mid) a1-39)) + (set! (-> this size-mid) (- (-> this size-mid) (* 1088 a1-39))) + (set! v0-0 (- v0-0 (* 1088 a1-39))) + (let ((a3-21 (-> this next-mid))) + (dotimes (a2-55 a1-39) + (set! a3-21 (-> this draw-table a3-21)) + ) + (set! (-> this next-mid) a3-21) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-49 (min (the int (* 0.000108506945 (the float (+ (- 9216 v1-6) v0-0)))) (-> this count-near-mid)))) + (set! (-> this count-near-mid) (- (-> this count-near-mid) a1-49)) + (set! (-> this size-near-mid) (- (-> this size-near-mid) (* 9216 a1-49))) + (set! v0-0 (- v0-0 (* 9216 a1-49))) + (let ((a3-26 (-> this next-near-mid))) + (dotimes (a2-63 a1-49) + (set! a3-26 (-> this draw-table a3-26)) + ) + (set! (-> this next-near-mid) a3-26) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-59 (min (the int (* 0.000040690105 (the float (+ (- #x6000 v1-6) v0-0)))) (-> this count-near)))) + (set! (-> this count-near) (- (-> this count-near) a1-59)) + (set! (-> this size-near) (- (-> this size-near) (* #x6000 a1-59))) + (set! v0-0 (- v0-0 (* #x6000 a1-59))) + (let ((a3-31 (-> this next-near))) + (dotimes (a2-71 a1-59) + (set! a3-31 (-> this draw-table a3-31)) + ) + (set! (-> this next-near) a3-31) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((a1-69 (min (the int (* 0.00051229505 (the float (+ (- 1952 v1-6) v0-0)))) (-> this count-far-scissor)))) + (set! (-> this count-far-scissor) (- (-> this count-far-scissor) a1-69)) + (set! (-> this size-far-scissor) (- (-> this size-far-scissor) (* 1952 a1-69))) + (set! v0-0 (- v0-0 (* 224 a1-69))) + (let ((a3-36 (-> this next-far-scissor))) + (dotimes (a2-79 a1-69) + (set! a3-36 (-> this draw-table a3-36)) + ) + (set! (-> this next-far-scissor) a3-36) + ) + ) + ) + (when (< v1-6 v0-0) + (let ((v1-11 + (min (the int (* 0.000025699013 (the float (+ (- #x9800 v1-6) v0-0)))) (-> this count-near-mid-scissor)) + ) + ) + (set! (-> this count-near-mid-scissor) (- (-> this count-near-mid-scissor) v1-11)) + (set! (-> this size-near-mid-scissor) (- (-> this size-near-mid-scissor) (* #x9800 v1-11))) + (- v0-0 (* #x9800 v1-11)) + (let ((a2-82 (-> this next-near-mid-scissor))) + (dotimes (a1-82 v1-11) + (set! a2-82 (-> this draw-table a2-82)) + ) + (set! (-> this next-near-mid-scissor) a2-82) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 10 of type hfragment +;; WARN: Return type mismatch int vs none. +(defmethod draw ((this hfragment)) + "Draw the drawable, and typically its children. + This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." + (let ((gp-0 *hfrag-work*)) + (let ((s4-0 (-> *level* draw-level *draw-index*))) + (mem-copy! (&-> (-> gp-0 hfrag) type) (&-> this type) 96) + (init-work-from-current-hfrag! gp-0) + (pick-level-of-detail! gp-0 s4-0) + (trim-dma-to-fit-in-memory gp-0) + (time-of-day-interp-colors-scratch + (the-as (pointer rgba) (+ #x3000 #x70000000)) + (-> this colors) + (-> s4-0 mood-context) + ) + ) + (generate-vertices! gp-0) + (generate-montage-texture gp-0) + (finalize-dma! gp-0) + ) + (set-dirty-mask! (the-as level (-> *level* level)) 10 #x1a000 #xf4000) + 0 + (none) + ) + +;; definition for method 20 of type hfragment +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod add-tri-a-xy-zzz-to-collide-cache ((this hfragment) + (arg0 collide-cache) + (arg1 int) + (arg2 int) + (arg3 uint) + (arg4 uint) + (arg5 uint) + (arg6 pat-surface) + ) + (let ((v1-0 (-> arg0 num-tris))) + (cond + ((>= v1-0 460) + (if (= *cheat-mode* 'debug) + (print-exceeded-max-cache-tris) + ) + ) + (else + (let ((v1-6 (-> arg0 tris v1-0))) + (let ((f0-2 (+ (* 32768.0 (the float arg1)) (-> this start-corner x))) + (f1-5 (+ (* 32768.0 (the float arg2)) (-> this start-corner z))) + ) + (set-vector! (-> v1-6 vertex 2) f0-2 (the float (* arg3 8)) f1-5 1.0) + (set-vector! (-> v1-6 vertex 1) (+ 32768.0 f0-2) (the float (* arg4 8)) f1-5 1.0) + (set-vector! (-> v1-6 vertex 0) f0-2 (the float (* arg5 8)) (+ 32768.0 f1-5) 1.0) + ) + (set! (-> v1-6 clear-flags) (the-as uint128 0)) + (set! (-> v1-6 pat) arg6) + (set! (-> v1-6 collide-ptr) #f) + ) + (+! (-> arg0 num-tris) 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 21 of type hfragment +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod add-tri-b-xy-zzz-to-collide-cache ((this hfragment) + (arg0 collide-cache) + (arg1 int) + (arg2 int) + (arg3 uint) + (arg4 uint) + (arg5 uint) + (arg6 pat-surface) + ) + (let ((v1-0 (-> arg0 num-tris))) + (cond + ((>= v1-0 460) + (if (= *cheat-mode* 'debug) + (print-exceeded-max-cache-tris) + ) + ) + (else + (let ((v1-6 (-> arg0 tris v1-0))) + (let ((f0-2 (+ (* 32768.0 (the float arg1)) (-> this start-corner x))) + (f1-5 (+ (* 32768.0 (the float arg2)) (-> this start-corner z))) + ) + (set-vector! (-> v1-6 vertex 2) f0-2 (the float (* arg4 8)) (+ 32768.0 f1-5) 1.0) + (set-vector! (-> v1-6 vertex 1) (+ 32768.0 f0-2) (the float (* arg3 8)) f1-5 1.0) + (set-vector! (-> v1-6 vertex 0) (+ 32768.0 f0-2) (the float (* arg5 8)) (+ 32768.0 f1-5) 1.0) + ) + (set! (-> v1-6 clear-flags) (the-as uint128 0)) + (set! (-> v1-6 pat) arg6) + (set! (-> v1-6 collide-ptr) #f) + ) + (+! (-> arg0 num-tris) 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 19 of type hfragment +;; WARN: Return type mismatch int vs none. +(defmethod add-tri-to-collide-cache ((this hfragment) (arg0 collide-cache) (arg1 collide-query) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) + (local-vars + (sv-16 uint) + (sv-24 uint) + (sv-32 uint) + (sv-40 uint) + (sv-48 int) + (sv-56 int) + (sv-64 int) + (sv-72 int) + ) + (let ((v1-0 (-> this verts)) + (a0-2 (+ (* arg3 512) arg2)) + (s2-0 (-> this pat-array 0)) + ) + (when (not (logtest? (-> arg1 ignore-pat) s2-0)) + (when (nonzero? (-> (the-as hfrag-vertex (-> v1-0 a0-2)) packed-index bit11)) + (set! sv-16 (-> v1-0 a0-2 height)) + (set! sv-24 (-> v1-0 (+ a0-2 1) height)) + (set! sv-32 (-> v1-0 (+ a0-2 512) height)) + (set! sv-40 (-> v1-0 (+ a0-2 513) height)) + (set! sv-48 0) + (set! sv-56 0) + (set! sv-64 0) + (set! sv-72 0) + (if (< (the-as int sv-16) arg4) + (set! sv-48 1) + ) + (if (< arg5 (the-as int sv-16)) + (set! sv-48 (logior sv-48 2)) + ) + (if (< (the-as int sv-24) arg4) + (set! sv-56 1) + ) + (if (< arg5 (the-as int sv-24)) + (set! sv-56 (logior sv-56 2)) + ) + (if (< (the-as int sv-32) arg4) + (set! sv-64 1) + ) + (if (< arg5 (the-as int sv-32)) + (set! sv-64 (logior sv-64 2)) + ) + (if (< (the-as int sv-40) arg4) + (set! sv-72 1) + ) + (if (< arg5 (the-as int sv-40)) + (set! sv-72 (logior sv-72 2)) + ) + (if (not (logtest? (logand sv-48 sv-56) sv-64)) + (add-tri-a-xy-zzz-to-collide-cache this arg0 arg2 arg3 sv-16 sv-24 sv-32 s2-0) + ) + (if (not (logtest? (logand sv-56 sv-64) sv-72)) + (add-tri-b-xy-zzz-to-collide-cache this arg0 arg2 arg3 sv-24 sv-32 sv-40 s2-0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 17 of type hfragment +;; WARN: Return type mismatch int vs none. +(defmethod bounding-box-query ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) + (local-vars (sv-16 int) (sv-24 int) (sv-32 int) (sv-40 int) (sv-48 int) (sv-56 int)) + (set! sv-16 (the int (* 0.000030517578 (- (-> arg1 bbox min x) (-> this start-corner x))))) + (set! sv-24 (the int (* 0.000030517578 (- (-> arg1 bbox min z) (-> this start-corner z))))) + (set! sv-32 (the int (* 0.000030517578 (- (-> arg1 bbox max x) (-> this start-corner x))))) + (set! sv-40 (the int (* 0.000030517578 (- (-> arg1 bbox max z) (-> this start-corner z))))) + (set! sv-48 (the int (* 0.125 (-> arg1 bbox min y)))) + (set! sv-56 (the int (* 0.125 (-> arg1 bbox max y)))) + (set! sv-16 (max 0 (min 511 sv-16))) + (set! sv-32 (max 0 (min 511 sv-32))) + (set! sv-24 (max 0 (min 511 sv-24))) + (set! sv-40 (max 0 (min 511 sv-40))) + (let ((s3-0 sv-24) + (s2-0 sv-40) + ) + (while (>= s2-0 s3-0) + (let ((s1-0 sv-16) + (s0-0 sv-32) + ) + (while (>= s0-0 s1-0) + (add-tri-to-collide-cache this arg0 arg1 s1-0 s3-0 sv-48 sv-56) + (+! s1-0 1) + ) + ) + (+! s3-0 1) + ) + ) + 0 + (none) + ) + +;; definition for method 18 of type hfragment +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod line-sphere-query ((this hfragment) (arg0 collide-cache) (arg1 collide-query)) + (local-vars + (v1-30 int) + (v1-31 int) + (v1-57 int) + (v1-58 int) + (a0-16 int) + (a0-17 int) + (a0-35 int) + (a0-36 int) + (s3-0 int) + (s3-2 int) + (sv-64 vector) + (sv-68 vector) + (sv-72 vector) + (sv-76 float) + (sv-80 float) + (sv-128 int) + (sv-144 int) + (sv-160 int) + (sv-176 int) + (sv-192 int) + (sv-208 int) + ) + (set! sv-64 (new 'stack-no-clear 'vector)) + (set! sv-68 (new 'stack-no-clear 'vector)) + (set! sv-72 (new 'stack-no-clear 'vector)) + (set! sv-76 (the-as float 0.000030517578)) + (set! sv-80 (* 0.000030517578 (-> arg1 radius))) + (vector-! sv-64 (-> arg1 start-pos) (-> this start-corner)) + (vector-float*! sv-64 sv-64 sv-76) + (vector-float*! sv-72 (-> arg1 move-dist) sv-76) + (vector+! sv-68 sv-64 sv-72) + (cond + ((< (fabs (-> sv-72 z)) (fabs (-> sv-72 x))) + (when (< (-> sv-72 x) 0.0) + (let ((v1-15 (new 'stack-no-clear 'vector))) + (set! (-> v1-15 quad) (-> sv-64 quad)) + (set! (-> sv-64 quad) (-> sv-68 quad)) + (set! (-> sv-68 quad) (-> v1-15 quad)) + ) + (vector-negate! sv-72 sv-72) + ) + (let* ((a0-9 (the int (- (-> sv-64 x) sv-80))) + (v1-20 (the int (+ (-> sv-68 x) sv-80))) + (f0-15 (fmax 1.0 (the float (- v1-20 a0-9)))) + (f30-0 (/ (-> sv-72 y) f0-15)) + (f28-0 (/ (-> sv-72 z) f0-15)) + (f26-0 (+ sv-80 (* 0.5 (fabs f30-0)))) + (f24-0 (+ sv-80 (* 0.5 (fabs f28-0)))) + ) + (cond + ((< a0-9 0) + (+! (-> sv-64 y) (* f30-0 (- (the float a0-9)))) + (+! (-> sv-64 z) (* f28-0 (- (the float a0-9)))) + (set! s3-0 0) + ) + (else + (set! s3-0 (min 511 a0-9)) + ) + ) + (let ((s2-1 (max 0 (min 511 v1-20))) + (s1-0 s3-0) + ) + (while (>= s2-1 s1-0) + (let* ((f0-23 (the float (- s1-0 s3-0))) + (f1-23 (+ (-> sv-64 y) (* f30-0 f0-23))) + (f0-25 (+ (-> sv-64 z) (* f28-0 f0-23))) + (s0-0 (the int (* 4096.0 (+ (- -0.5 f26-0) f1-23)))) + ) + (set! sv-128 (the int (* 4096.0 (+ 0.5 f26-0 f1-23)))) + (let ((a0-15 (the int (- f0-25 f24-0))) + (v1-29 (the int (+ f0-25 f24-0))) + ) + (set! sv-144 0) + (let ((a2-1 sv-144) + (a1-21 (min 511 a0-15)) + ) + (set-on-less-than a0-16 a2-1 a1-21) + (move-if-not-zero a0-17 a1-21 a0-16 a0-16) + ) + (set! sv-144 a0-17) + (set! sv-160 0) + (let ((a1-22 sv-160) + (a0-20 (min 511 v1-29)) + ) + (set-on-less-than v1-30 a1-22 a0-20) + (move-if-not-zero v1-31 a0-20 v1-30 v1-30) + ) + ) + (set! sv-160 v1-31) + (while (>= sv-160 sv-144) + (add-tri-to-collide-cache this arg0 arg1 s1-0 sv-144 s0-0 sv-128) + (set! sv-144 (+ sv-144 1)) + ) + ) + (+! s1-0 1) + ) + ) + ) + ) + (else + (when (< (-> sv-72 z) 0.0) + (let ((v1-42 (new 'stack-no-clear 'vector))) + (set! (-> v1-42 quad) (-> sv-64 quad)) + (set! (-> sv-64 quad) (-> sv-68 quad)) + (set! (-> sv-68 quad) (-> v1-42 quad)) + ) + (vector-negate! sv-72 sv-72) + ) + (let* ((a0-27 (the int (- (-> sv-64 z) sv-80))) + (v1-47 (the int (+ (-> sv-68 z) sv-80))) + (f0-36 (fmax 1.0 (the float (- v1-47 a0-27)))) + (f30-1 (/ (-> sv-72 y) f0-36)) + (f28-1 (/ (-> sv-72 x) f0-36)) + (f26-1 (+ sv-80 (* 0.5 (fabs f30-1)))) + (f24-1 (+ sv-80 (* 0.5 (fabs f28-1)))) + ) + (cond + ((< a0-27 0) + (+! (-> sv-64 y) (* f30-1 (the float (- a0-27)))) + (+! (-> sv-64 x) (* f28-1 (the float (- a0-27)))) + (set! s3-2 0) + ) + (else + (set! s3-2 (min 511 a0-27)) + ) + ) + (let ((s2-3 (max 0 (min 511 v1-47))) + (s1-1 s3-2) + ) + (while (>= s2-3 s1-1) + (let* ((f0-44 (the float (- s1-1 s3-2))) + (f1-47 (+ (-> sv-64 y) (* f30-1 f0-44))) + (f0-46 (+ (-> sv-64 x) (* f28-1 f0-44))) + (s0-1 (the int (* 4096.0 (+ (- -0.5 f26-1) f1-47)))) + ) + (set! sv-176 (the int (* 4096.0 (+ 0.5 f26-1 f1-47)))) + (let ((a0-34 (the int (- f0-46 f24-1))) + (v1-56 (the int (+ f0-46 f24-1))) + ) + (set! sv-192 0) + (let ((a2-3 sv-192) + (a1-41 (min 511 a0-34)) + ) + (set-on-less-than a0-35 a2-3 a1-41) + (move-if-not-zero a0-36 a1-41 a0-35 a0-35) + ) + (set! sv-192 a0-36) + (set! sv-208 0) + (let ((a1-42 sv-208) + (a0-39 (min 511 v1-56)) + ) + (set-on-less-than v1-57 a1-42 a0-39) + (move-if-not-zero v1-58 a0-39 v1-57 v1-57) + ) + ) + (set! sv-208 v1-58) + (while (>= sv-208 sv-192) + (add-tri-to-collide-cache this arg0 arg1 sv-192 s1-1 s0-1 sv-176) + (set! sv-192 (+ sv-192 1)) + ) + ) + (+! s1-1 1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition (debug) for function hfrag-vert-print +;; WARN: Return type mismatch symbol vs none. +(defun-debug hfrag-vert-print ((arg0 int) (arg1 int)) + (let ((s4-0 (-> *hfrag-work* hfrag verts))) + (dotimes (s3-0 16) + (dotimes (s2-0 16) + (let ((v1-3 (+ (* (+ s3-0 arg1) 512) s2-0 arg0))) + (format 0 "#x~2x " (+ (shr (-> s4-0 v1-3 packed-index bit11) 3) -1)) + ) + ) + (format 0 "~%") + ) + ) + (none) + ) + +;; definition for method 13 of type hfragment +;; WARN: Return type mismatch int vs none. +(defmethod collect-stats ((this hfragment)) + "Collect triangle/perf statistics for rendering. + This is only called when viewing stats. + The vis-bits and culling registers are loaded during this time." + (let ((v1-0 *hfrag-work*)) + (+! (-> *terrain-stats* hfrag groups) 1) + (+! (-> *terrain-stats* hfrag fragments) (-> v1-0 count-far) (-> v1-0 count-far-scissor)) + (+! (-> *terrain-stats* hfrag fragments) (* (-> v1-0 count-far-mid) 16)) + (+! (-> *terrain-stats* hfrag fragments) (* (-> v1-0 count-mid) 4)) + (+! (-> *terrain-stats* hfrag fragments) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 64)) + (+! (-> *terrain-stats* hfrag fragments) (* (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 256)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-far) (-> v1-0 count-far-scissor)) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (-> v1-0 count-far-mid) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (-> v1-0 count-mid) 32)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 128)) + (+! (-> *terrain-stats* hfrag tris) (* (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 512)) + (+! (-> *terrain-stats* hfrag dverts) (* (+ (-> v1-0 count-far) (-> v1-0 count-far-scissor)) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (-> v1-0 count-far-mid) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (-> v1-0 count-mid) 64)) + (+! (-> *terrain-stats* hfrag dverts) (* (+ (-> v1-0 count-near-mid) (-> v1-0 count-near-mid-scissor)) 256)) + (+! (-> *terrain-stats* hfrag dverts) (shl (+ (-> v1-0 count-near) (-> v1-0 count-near-scissor)) 10)) + ) + 0 + (none) + ) + +;; definition for method 8 of type hfragment +(defmethod mem-usage ((this hfragment) (usage memory-usage-block) (flags int)) + (let ((v1-0 43)) + (set! (-> usage length) (max (-> usage length) (+ v1-0 1))) + (set! (-> usage data v1-0 name) "hfragment") + (+! (-> usage data v1-0 count) 1) + (let ((a2-9 (-> this size))) + (+! (-> usage data v1-0 used) a2-9) + (+! (-> usage data v1-0 total) (logand -16 (+ a2-9 15))) + ) + ) + this + ) diff --git a/test/decompiler/reference/jak3/engine/gfx/background/tie/tie_REF.gc b/test/decompiler/reference/jak3/engine/gfx/background/tie/tie_REF.gc index e05fe8c6a..edb6c7f4a 100644 --- a/test/decompiler/reference/jak3/engine/gfx/background/tie/tie_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/background/tie/tie_REF.gc @@ -24,8 +24,8 @@ ) ) ) - (when (= (-> s5-0 reg-4) 66) - (set! (-> s5-0 reg-4) (the-as uint 127)) + (when (= (-> s5-0 reg-4) (gs-reg alpha-1)) + (set! (-> s5-0 reg-4) (gs-reg hack)) (set! (-> s5-0 alpha) (new 'static 'gs-miptbp)) 0 ) diff --git a/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc b/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc index dd53829b1..04121be87 100644 --- a/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/foreground/foreground_REF.gc @@ -347,7 +347,7 @@ (bucket-id-16 gmerc-l8-tfrag) (bucket-id-16 tex-l8-tfrag) (bucket-id-16 gmerc2-l8-tfrag) - (bucket-id-16 bucket8) + (bucket-id-16 hfrag) (bucket-id-16 merc-l8-pris) (bucket-id-16 emerc-l8-pris) (bucket-id-16 gmerc-l8-pris) @@ -389,7 +389,7 @@ (bucket-id-16 gmerc-l9-tfrag) (bucket-id-16 tex-l9-tfrag) (bucket-id-16 gmerc2-l9-tfrag) - (bucket-id-16 bucket9) + (bucket-id-16 hfrag-scissor) (bucket-id-16 merc-l9-pris) (bucket-id-16 emerc-l9-pris) (bucket-id-16 gmerc-l9-pris) diff --git a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc index 3055cedd5..9ecc2a2e9 100644 --- a/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/hw/display-h_REF.gc @@ -160,8 +160,8 @@ rn3 rn4 rn5 - rn6 - rn7 + hfrag + hfrag-scissor tfrag tie-scissor tie @@ -196,8 +196,8 @@ rn3 rn4 rn5 - rn6 - rn7 + hfrag + hfrag-scissor tfrag tie-scissor tie diff --git a/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc index 84fdb08df..4e6943e2d 100644 --- a/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc @@ -196,7 +196,7 @@ So mask 0 is needed if segment 0 of the texture is needed, etc..." (h int16) (num-mips uint8) (tex1-control uint8) - (psm uint8) + (psm gs-psm) (mip-shift uint8) (clutpsm uint16) (dest uint16 7) @@ -443,11 +443,11 @@ For example, the texture system will automatically update tbp to point to the lo of the texture." ((quad qword 5 :inline) (prims gs-reg64 10 :overlay-at quad) - (reg-0 uint8 :overlay-at (-> quad 0 data 2)) - (reg-1 uint8 :overlay-at (-> prims 3)) - (reg-2 uint8 :overlay-at (-> prims 5)) - (reg-3 uint8 :overlay-at (-> prims 7)) - (reg-4 uint8 :overlay-at (-> prims 9)) + (reg-0 gs-reg :overlay-at (-> quad 0 data 2)) + (reg-1 gs-reg :overlay-at (-> prims 3)) + (reg-2 gs-reg :overlay-at (-> prims 5)) + (reg-3 gs-reg :overlay-at (-> prims 7)) + (reg-4 gs-reg :overlay-at (-> prims 9)) (tex0 gs-tex0 :overlay-at (-> quad 0 data 0)) (tex1 gs-tex1 :overlay-at (-> prims 2)) (miptbp1 gs-miptbp :overlay-at (-> prims 4)) diff --git a/test/decompiler/reference/jak3/engine/gfx/texture/texture_REF.gc b/test/decompiler/reference/jak3/engine/gfx/texture/texture_REF.gc index a81aed4ee..ec9c2c06f 100644 --- a/test/decompiler/reference/jak3/engine/gfx/texture/texture_REF.gc +++ b/test/decompiler/reference/jak3/engine/gfx/texture/texture_REF.gc @@ -145,7 +145,7 @@ #t "# this name) - (psm->string (the-as gs-psm (-> this psm))) + (psm->string (-> this psm)) (-> this w) (-> this h) (-> this num-mips) @@ -154,7 +154,7 @@ (dotimes (s5-1 (the-as int (-> this num-mips))) (format #t " #x~X/~X" (-> this dest s5-1) (-> this width s5-1)) ) - (if (< (texture-bpp (the-as gs-psm (-> this psm))) 16) + (if (< (texture-bpp (-> this psm)) 16) (format #t " :clut #x~X/1" (-> this clutdest)) ) (format #t " @ #x~X>" this) @@ -1633,7 +1633,7 @@ (bitbltbuf (new 'static 'gs-bitbltbuf :sbp (-> tex dest v1-0) :sbw (-> tex width v1-0) - :spsm (-> tex psm) + :spsm (the-as int (-> tex psm)) :dbp (/ dest 64) :dbw (-> tex width v1-0) :dpsm (the-as int tex-format) @@ -1649,7 +1649,7 @@ (cond ((< clut-dest 0) ) - ((= (-> tex psm) 20) + ((= (-> tex psm) (gs-psm mt4)) (dma-buffer-add-gs-set dma-buf (bitbltbuf (new 'static 'gs-bitbltbuf :sbw #x1 @@ -1666,7 +1666,7 @@ ) (set! (-> tex clutdest) (the-as uint (/ clut-dest 64))) ) - ((= (-> tex psm) 19) + ((= (-> tex psm) (gs-psm mt8)) (dma-buffer-add-gs-set dma-buf (bitbltbuf (new 'static 'gs-bitbltbuf :sbw #x2 @@ -1684,7 +1684,7 @@ (set! (-> tex clutdest) (the-as uint (/ clut-dest 64))) ) ) - (set! (-> tex psm) (the-as uint tex-format)) + (set! (-> tex psm) tex-format) dma-buf ) diff --git a/test/decompiler/reference/jak3/engine/level/level-info_REF.gc b/test/decompiler/reference/jak3/engine/level/level-info_REF.gc index faab293a4..7b95b2c05 100644 --- a/test/decompiler/reference/jak3/engine/level/level-info_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level-info_REF.gc @@ -18252,7 +18252,7 @@ :index #x107 :task-level #xa :master-level #f - :level-flags (level-flags lf7 lf9 lf12 lf13 lf14) + :level-flags (level-flags lf7 lf9 lf12 lf13 low-res-hfrag) :packages '("vehiclep" "nav-graphp" "hvehiclep" "hanga") :run-packages '("common") :memory-mode (level-memory-mode small-edge) @@ -18332,7 +18332,7 @@ :index #x108 :task-level #xa :master-level 'hanga - :level-flags (level-flags lf1 lf9 lf12 lf14) + :level-flags (level-flags lf1 lf9 lf12 low-res-hfrag) :packages '() :run-packages '("common") :memory-mode (level-memory-mode small-center) @@ -20950,7 +20950,3 @@ 4amy ) ) - - - - diff --git a/test/decompiler/reference/jak3/engine/level/level_REF.gc b/test/decompiler/reference/jak3/engine/level/level_REF.gc index 5c45c10b3..d4dea99ca 100644 --- a/test/decompiler/reference/jak3/engine/level/level_REF.gc +++ b/test/decompiler/reference/jak3/engine/level/level_REF.gc @@ -1916,11 +1916,11 @@ (set! (-> sv-96 tex1) (new 'static 'gs-tex1 :mmag #x1 :mmin #x1)) (set! (-> sv-96 clamp) (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp))) (set! (-> sv-96 alpha) (new 'static 'gs-miptbp :tbp1 #x58)) - (set! (-> sv-96 reg-0) (the-as uint 6)) - (set! (-> sv-96 reg-1) (the-as uint 20)) - (set! (-> sv-96 reg-2) (the-as uint 52)) - (set! (-> sv-96 reg-3) (the-as uint 8)) - (set! (-> sv-96 reg-4) (the-as uint 66)) + (set! (-> sv-96 reg-0) (gs-reg tex0-1)) + (set! (-> sv-96 reg-1) (gs-reg tex1-1)) + (set! (-> sv-96 reg-2) (gs-reg miptbp1-1)) + (set! (-> sv-96 reg-3) (gs-reg clamp-1)) + (set! (-> sv-96 reg-4) (gs-reg alpha-1)) ) ) (set! (-> arg1 pos) (the-as uint 0)) diff --git a/tools/level_tools/level_dump/main.cpp b/tools/level_tools/level_dump/main.cpp index f1e0e3eb1..98b3be512 100644 --- a/tools/level_tools/level_dump/main.cpp +++ b/tools/level_tools/level_dump/main.cpp @@ -81,14 +81,12 @@ int main(int argc, char** argv) { return 1; } - level_tools::DrawStats draw_stats; // draw_stats.debug_print_dma_data = true; level_tools::BspHeader bsp_header; - bsp_header.read_from_file(data, dts, &draw_stats, kGameVersion); + bsp_header.read_from_file(data, dts, kGameVersion); level_tools::PrintSettings settings; fmt::print("{}\n", bsp_header.print(settings)); - fmt::print("Stats:\n{}\n", draw_stats.print()); } catch (const std::exception& e) { fmt::print("Error: {}\n", e.what());