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.
This commit is contained in:
water111 2024-05-09 20:11:43 -04:00 committed by GitHub
parent 949508d0ed
commit 5b04be2fa0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
80 changed files with 13081 additions and 977 deletions

View File

@ -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<size_t>(buckets.size());
} else {
buckets.resize(ser.load<size_t>());
}
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;

View File

@ -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<u8, 4> 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<u8> 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;
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];
}
}
return true;
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,7 +329,7 @@ struct TfragTree {
TFragmentTreeKind kind; // our tfrag kind
std::vector<StripDraw> draws; // the actual topology and settings
PackedTfragVertices packed_vertices;
std::vector<TimeOfDayColor> colors; // vertex colors (pre-interpolation)
PackedTimeOfDay colors; // vertex colors (pre-interpolation)
BVH bvh; // the bvh for frustum culling
bool use_strips = true;
@ -401,7 +411,7 @@ struct TieTree {
std::array<u32, kNumTieCategories + 1> category_draw_indices;
PackedTieVertices packed_vertices;
std::vector<TimeOfDayColor> colors; // vertex colors (pre-interpolation)
PackedTimeOfDay colors; // vertex colors (pre-interpolation)
std::vector<InstancedStripDraw> instanced_wind_draws;
std::vector<TieWindInstance> wind_instance_info;
@ -422,7 +432,7 @@ struct TieTree {
struct ShrubTree {
// todo some visibility structure
std::vector<TimeOfDayColor> time_of_day_colors; // multiplier colors
PackedTimeOfDay time_of_day_colors; // multiplier colors
PackedShrubVertices packed_vertices;
std::vector<ShrubDraw> 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<float, 4> bsphere;
u32 vis_id = 0;
u32 index_start = 0;
u32 index_length = 0;
u32 num_tris = 0;
};
struct HfragmentBucket {
std::vector<u32> corners;
std::array<u16, 16> montage_table;
void serialize(Serializer& ser);
};
struct Hfragment {
std::vector<HfragmentVertex> vertices;
std::vector<u32> indices;
std::vector<HfragmentCorner> corners;
std::vector<HfragmentBucket> buckets;
PackedTimeOfDay time_of_day_colors;
std::array<s32, 4> 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<std::vector<TfragTree>, TFRAG_GEOS> tfrag_trees;
std::array<std::vector<TieTree>, TIE_GEOS> tie_trees;
std::vector<ShrubTree> shrub_trees;
Hfragment hfrag;
CollisionMesh collision;
MercModelGroup merc_data;
u16 version2 = TFRAG3_VERSION;

View File

@ -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

View File

@ -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 ;;

View File

@ -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]
]
}

View File

@ -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"]
]
}

View File

@ -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<Drawable> 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<DrawNode>();
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<TFragment>();
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<InstanceTie>();
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<DrawableActor>();
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<shrub_types::InstanceShrubbery>();
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<u8> 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<s16>(ref, "id", dts);
color_index = read_plain_data_field<s16>(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<u16>(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<u16>(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<u16>(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<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<DrawableInlineArray> 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<DrawableInlineArrayNode>();
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<DrawableInlineArrayTFrag>();
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<DrawableInlineArrayTransTFrag>();
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<DrawableInlineArrayTFragTrans>();
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<DrawableInlineArrayTFragWater>();
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<DrawableInlineArrayInstanceTie>();
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<shrub_types::DrawableInlineArrayInstanceShrub>();
result->read_from_file(ref, dts, stats, version);
result->read_from_file(ref, dts, version);
return result;
}
auto result = std::make_unique<DrawableInlineArrayUnknown>();
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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<u32>(ref, "length", dts);
allocated_length = read_plain_data_field<u32>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(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<s16>(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<u16>(ref, "strip-data-len", dts);
poly_count = read_plain_data_field<u16>(ref, "poly-count", dts);
vertex_count = read_plain_data_field<u8>(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<s16>(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<u16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<s16>(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<s16>(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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<u8>* 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<u8>(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<u8>(ref, "cnt-qwc", dts);
vtx_qwc = read_plain_data_field<u8>(ref, "vtx-qwc", dts);
@ -1797,82 +1731,80 @@ void GenericShrubFragment::read_from_file(TypedRef ref,
std::unique_ptr<DrawableTree> 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<DrawableTreeTfrag>();
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<DrawableTreeTransTfrag>();
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<DrawableTreeLowresTfrag>();
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<DrawableTreeDirtTfrag>();
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<DrawableTreeIceTfrag>();
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<DrawableTreeInstanceTie>();
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<DrawableTreeTfragTrans>();
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<DrawableTreeTfragWater>();
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<DrawableTreeActor>();
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<shrub_types::DrawableTreeInstanceShrub>();
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<DrawableTreeCollideFragment>();
tree->read_from_file(ref, dts, stats, version);
tree->read_from_file(ref, dts, version);
return tree;
}
auto tree = std::make_unique<DrawableTreeUnknown>();
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<s16>(ref, "id", dts);
length = read_plain_data_field<s16>(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<u32>(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<int16_t>(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<uint32_t>(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<u16>(ref, "num-buckets-far", dts);
num_buckets_mid = read_plain_data_field<u16>(ref, "num-buckets-mid", dts);
num_buckets_near = read_plain_data_field<u16>(ref, "num-buckets-near", dts);
size = read_plain_data_field<u32>(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<s16>(ref, "visible-list-length", dts);
extra_vis_list_length = read_plain_data_field<s16>(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);
}
}
}

View File

@ -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<u32> 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<DrawableActor> 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<level_tools::Vector> spheres; // array of bspheres for each "corner"
std::vector<s16> vis_ids; // precomputed vis id for each "corner"
AdGifData shaders[3];
TimeOfDayPalette colors;
HFragmentMontage montage[17];
// buckets??
std::vector<u32> 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<HFragment> hfrag;
void read_from_file(const decompiler::LinkedObjectFile& file,
const decompiler::DecompilerTypeSystem& dts,
DrawStats* stats,
GameVersion version,
bool only_read_texture_remap = false);

View File

@ -2,6 +2,7 @@
#include <cstddef>
namespace decompiler {
u32 clean_up_vertex_indices(std::vector<u32>& idx) {
std::vector<u32> fixed;
u32 num_tris = 0;
@ -44,3 +45,41 @@ u32 clean_up_vertex_indices(std::vector<u32>& idx) {
return num_tris;
}
// 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

View File

@ -2,5 +2,11 @@
#include <vector>
#include "common/common_types.h"
#include "common/custom_data/Tfrag3Data.h"
#include "decompiler/level_extractor/BspHeader.h"
namespace decompiler {
u32 clean_up_vertex_indices(std::vector<u32>& idx);
tfrag3::PackedTimeOfDay pack_colors(const level_tools::TimeOfDayPalette& in);
} // namespace decompiler

View File

@ -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

View File

@ -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);
}

View File

@ -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<level_tools::TextureRemap> 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;

View File

@ -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);

View File

@ -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<tfrag3::StripDraw::VisGroup>& grps) {

View File

@ -356,6 +356,10 @@ struct TieFrag {
} prog_info;
};
struct TimeOfDayColor {
math::Vector<u8, 4> rgba[8];
};
// main instance type
// unlike the GOAL type, we store all instances info in here too.
struct TieProtoInfo {
@ -364,7 +368,7 @@ struct TieProtoInfo {
u32 proto_flag;
float stiffness = 0; // wind
std::optional<AdgifInfo> envmap_adgif;
std::vector<tfrag3::TimeOfDayColor> time_of_day_colors; // c++ type for time of day data
std::vector<TimeOfDayColor> time_of_day_colors; // c++ type for time of day data
std::vector<TieFrag> frags; // the fragments of the prototype
};
@ -2094,7 +2098,7 @@ std::string dump_full_to_obj(const std::vector<TieProtoInfo>& protos) {
// and this tells us an index in the time of day palette.
struct BigPalette {
std::vector<tfrag3::TimeOfDayColor> colors;
std::vector<TimeOfDayColor> colors;
};
// combine all individual time of day palettes into one giant one.
@ -2124,6 +2128,21 @@ BigPalette make_big_palette(std::vector<TieProtoInfo>& 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));
}
}

View File

@ -246,9 +246,9 @@ int make_color_buffer_accessor(const std::vector<tfrag3::PreloadedVertex>& verti
std::vector<float> 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<tfrag3::PreloadedVertex>& verti
std::vector<float> 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<tfrag3::ShrubGpuVertex>& vertic
std::vector<float> 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);
}

View File

@ -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));

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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<OceanMidAndFar>("ocean-mid-far", BucketCategory::OCEAN,
BucketId::OCEAN_MID_FAR);
// 8 (in tfrag category for now, just for stat reporting.)
init_bucket_renderer<Hfrag>("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))

View File

@ -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");

View File

@ -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
};

View File

@ -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<u32> 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);
}

View File

@ -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<HfragLevel, kMaxLevels> m_levels;
static constexpr int TIME_OF_DAY_COLOR_COUNT = 8192;
std::vector<math::Vector<u8, 4>> m_color_result;
bool m_bucket_used[kNumBuckets];
bool m_corner_vis[kNumCorners];
GLuint m_montage_indices = 0;
};

View File

@ -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);

View File

@ -39,9 +39,8 @@ class Shrub : public BucketRenderer {
u32 vert_count;
const std::vector<tfrag3::ShrubDraw>* draws = nullptr;
const std::vector<tfrag3::TieWindInstance>* instance_info = nullptr;
const std::vector<tfrag3::TimeOfDayColor>* colors = nullptr;
const tfrag3::PackedTimeOfDay* colors = nullptr;
const u32* index_data = nullptr;
SwizzledTimeOfDay tod_cache;
std::vector<bool> proto_vis_mask;
std::unordered_map<std::string, std::vector<u32>> 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<std::pair<int, int>> draw_idx_temp;

View File

@ -267,7 +267,7 @@ void TFragment::update_load(const std::vector<tfrag3::TFragmentTreeKind>& 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<tfrag3::TFragmentTreeKind>& 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<tfrag3::TFragmentTreeKind>& 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);

View File

@ -122,10 +122,9 @@ class TFragment : public BucketRenderer {
GLuint vao = -1;
u32 vert_count = 0;
const std::vector<tfrag3::StripDraw>* draws = nullptr;
const std::vector<tfrag3::TimeOfDayColor>* 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<DebugVertex> m_debug_vert_data;
bool m_has_level = false;
bool m_use_fast_time_of_day = true;
const std::vector<GLuint>* m_anim_slot_array;
};

View File

@ -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,

View File

@ -115,10 +115,9 @@ class Tie3 : public BucketRenderer {
const std::vector<tfrag3::StripDraw>* draws = nullptr;
const std::vector<tfrag3::InstancedStripDraw>* wind_draws = nullptr;
const std::vector<tfrag3::TieWindInstance>* instance_info = nullptr;
const std::vector<tfrag3::TimeOfDayColor>* colors = nullptr;
const tfrag3::PackedTimeOfDay* colors = nullptr;
const tfrag3::BVH* vis = nullptr;
const u32* index_data = nullptr;
SwizzledTimeOfDay tod_cache;
std::vector<std::array<math::Vector4f, 4>> wind_matrix_cache;
GLuint wind_vertex_index_buffer;
std::vector<u32> wind_vertex_index_offsets;

View File

@ -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<s32, 4> itimes[4],
const std::vector<tfrag3::TimeOfDayColor>& in,
const tfrag3::PackedTimeOfDay& in,
math::Vector<u8, 4>* out) {
// Timer interp_timer;
math::Vector4f weights[8];
math::Vector<u16, 4> 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<s32, 4> 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<float>() * weights[component];
math::Vector<u16, 4> 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<u8>();
}
}
// 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<tfrag3::TimeOfDayColor>& 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++;
}
}
}
}
out.color_count = (in.size() + 3) & (~3);
return out;
}
#ifndef __aarch64__
void interp_time_of_day_fast(const math::Vector<s32, 4> itimes[4],
const SwizzledTimeOfDay& swizzled_colors,
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);
}
}
}
void interp_time_of_day(const math::Vector<s32, 4> itimes[4],
const tfrag3::PackedTimeOfDay& packed_colors,
math::Vector<u8, 4>* out) {
#ifdef __aarch64__
interp_time_of_day_slow(itimes, packed_colors, out);
#else
math::Vector<u16, 4> 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<s32, 4> 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<s32, 4> 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<s32, 4> 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 =

View File

@ -43,27 +43,14 @@ 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<s32, 4> itimes[4],
const std::vector<tfrag3::TimeOfDayColor>& in,
void interp_time_of_day(const math::Vector<s32, 4> itimes[4],
const tfrag3::PackedTimeOfDay& packed_colors,
math::Vector<u8, 4>* out);
struct SwizzledTimeOfDay {
std::vector<u8> data;
u32 color_count = 0;
};
SwizzledTimeOfDay swizzle_time_of_day(const std::vector<tfrag3::TimeOfDayColor>& in);
#ifndef __aarch64__
void interp_time_of_day_fast(const math::Vector<s32, 4> itimes[4],
const SwizzledTimeOfDay& swizzled_colors,
math::Vector<u8, 4>* out);
#endif
void cull_check_all_slow(const math::Vector4f* planes,
const std::vector<tfrag3::VisNode>& nodes,
const u8* level_occlusion_string,

View File

@ -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,

View File

@ -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<std::mutex> 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);

View File

@ -26,6 +26,7 @@ class Loader {
void set_active_levels(const std::vector<std::string>& levels);
std::vector<LevelData*> get_in_use_levels();
void draw_debug_window();
void debug_print_loaded_levels();
private:
void loader_thread();

View File

@ -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<std::unique_ptr<LoaderStage>> make_loader_stages() {
ret.push_back(std::make_unique<ShrubLoadStage>());
ret.push_back(std::make_unique<CollideLoaderStage>());
ret.push_back(std::make_unique<MercLoaderStage>());
ret.push_back(std::make_unique<HfragLoaderStage>());
ret.push_back(std::make_unique<StallLoaderStage>());
return ret;
}

View File

@ -28,6 +28,9 @@ struct LevelData {
GLuint merc_indices;
std::unordered_map<std::string, const tfrag3::MercModel*> merc_model_lookup;
GLuint hfrag_vertices;
GLuint hfrag_indices;
int frames_since_last_used = 0;
};

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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--;

View File

@ -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)

View File

@ -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)
)
)
)

View File

@ -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))
)

View File

@ -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!)

View File

@ -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))
)
)
@ -173,11 +178,11 @@
(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))
(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))
)
)
@ -215,14 +220,14 @@
(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))
(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)
)
)
@ -296,16 +301,16 @@
(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)
(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 dma-packet 2 :inline)
(next-tmpl dma-packet :inline :offset 1696)
(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)
@ -316,45 +321,45 @@
(adgif-tmpl2 dma-gif-packet :inline)
(sprite-tmpl dma-gif-packet :inline)
(mip-tmpl dma-gif-packet :inline)
(color uint128 6)
(color vector4w 6 :inline)
(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)
(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 uint128 9)
(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 uint32)
(call-poly9-mid uint32)
(call-poly9-near uint32)
(call-poly25-far uint32)
(call-poly25-mid uint32)
(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)
(lowres-flag symbol)
(hfrag hfragment :inline)
(next-far int16)
(next-far-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)
(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 uint16 1024 :offset 8456)
(corners uint128 1024)
(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)
)
)

View File

@ -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)
)
)

View File

@ -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)
)

View File

@ -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)
)
)
)

View File

@ -5,9 +5,614 @@
;; name in dgo: hfrag
;; dgos: HGA, WIN, DST
(define-extern *hfrag-work* hfrag-work)
;; DECOMP BEGINS
(defmethod hfragment-method-20 ((this hfragment)
(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)
@ -44,7 +649,7 @@
(none)
)
(defmethod hfragment-method-21 ((this hfragment)
(defmethod add-tri-b-xy-zzz-to-collide-cache ((this hfragment)
(arg0 collide-cache)
(arg1 int)
(arg2 int)
@ -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
)

View File

@ -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)))

View File

@ -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))

View File

@ -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
)

View File

@ -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)

View File

@ -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

View File

@ -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*))

View File

@ -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))

View File

@ -147,7 +147,7 @@
#t
"#<texture ~20S psm: ~6S ~4D x ~4D num-mips: ~D :size ~4DK "
(-> 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
)

View File

@ -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)

View File

@ -185,7 +185,7 @@
(lf11 11)
(lf12 12)
(lf13 13)
(lf14 14)
(low-res-hfrag 14)
(lf15 15)
(lf16 16)
(lf17 17)

View File

@ -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)

View File

@ -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))

View File

@ -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;
}

View File

@ -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)
)
)
)

View File

@ -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))
)

View File

@ -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))
)
)
@ -502,11 +507,11 @@
(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))
(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))
@ -611,14 +616,14 @@
(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))
(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
)
@ -773,16 +778,16 @@
(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)
(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 dma-packet 2 :inline)
(next-tmpl dma-packet :inline :offset 1696)
(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)
@ -793,45 +798,45 @@
(adgif-tmpl2 dma-gif-packet :inline)
(sprite-tmpl dma-gif-packet :inline)
(mip-tmpl dma-gif-packet :inline)
(color uint128 6)
(color vector4w 6 :inline)
(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)
(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 uint128 9)
(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 uint32)
(call-poly9-mid uint32)
(call-poly9-near uint32)
(call-poly25-far uint32)
(call-poly25-mid uint32)
(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)
(lowres-flag symbol)
(hfrag hfragment :inline)
(next-far int16)
(next-far-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)
(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 uint16 1024 :offset 8456)
(corners uint128 1024)
(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)
)
)

View File

@ -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: #<dma-packet @ #x~X>~%" (-> this height-tag))
(format #t "~1Tbase: #<vector @ #x~X>~%" (-> this base))
(format #t "~1Theights[4] @ #x~X~%" (-> this heights))
(format #t "~1Tcolor-tag: #<dma-packet @ #x~X>~%" (-> this color-tag))
(format #t "~1Tcolors[4] @ #x~X~%" (-> this colors))
(format #t "~1Tnext: #<dma-packet @ #x~X>~%" (-> 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: #<dma-packet @ #x~X>~%" (-> this height-tag))
(format #t "~1Tbase: #<vector3 @ #x~X>~%" (-> this base))
(format #t "~1Theights[9] @ #x~X~%" (-> this heights))
(format #t "~1Tcolor-tag: #<dma-packet @ #x~X>~%" (-> this color-tag))
(format #t "~1Tcolors[12] @ #x~X~%" (-> this colors))
(format #t "~1Tnext: #<dma-packet @ #x~X>~%" (-> 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: #<dma-packet @ #x~X>~%" (-> this height-tag))
(format #t "~1Tbase: #<vector3 @ #x~X>~%" (-> this base))
(format #t "~1Theights[25] @ #x~X~%" (-> this heights))
(format #t "~1Tcolor-tag: #<dma-packet @ #x~X>~%" (-> this color-tag))
(format #t "~1Tcolors[28] @ #x~X~%" (-> this colors))
(format #t "~1Tnext: #<dma-packet @ #x~X>~%" (-> 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: #<vector @ #x~X>~%" (-> this tex))
(format #t "~1Tclr: #<vector @ #x~X>~%" (-> this clr))
(format #t "~1Tpos: #<vector @ #x~X>~%" (-> 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: #<vector @ #x~X>~%" (-> 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: #<vector @ #x~X>~%" (-> this giftag0))
(format #t "~1Tverts0[6] @ #x~X~%" (-> this verts0))
(format #t "~1Tgiftag1: #<vector @ #x~X>~%" (-> 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: #<vector @ #x~X>~%" (-> this giftag0))
(format #t "~1Tverts0[10] @ #x~X~%" (-> this verts0))
(format #t "~1Tgiftag1: #<vector @ #x~X>~%" (-> this giftag1))
(format #t "~1Tverts1[10] @ #x~X~%" (-> this verts1))
(format #t "~1Tgiftag2: #<vector @ #x~X>~%" (-> this giftag2))
(format #t "~1Tverts2[10] @ #x~X~%" (-> this verts2))
(format #t "~1Tgiftag3: #<vector @ #x~X>~%" (-> 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: #<hfrag-vu1-constants-base @ #x~X>~%" (-> 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: #<qword @ #x~X>~%" (-> this drw-strip4))
(format #t "~1Tdrw-strip9-0: #<qword @ #x~X>~%" (-> this drw-strip9-0))
(format #t "~1Tdrw-strip9-1: #<qword @ #x~X>~%" (-> this drw-strip9-1))
(format #t "~1Tdrw-strip25-0: #<qword @ #x~X>~%" (-> this drw-strip25-0))
(format #t "~1Tdrw-strip25-1: #<qword @ #x~X>~%" (-> this drw-strip25-1))
(format #t "~1Tmatrix: #<matrix @ #x~X>~%" (-> this matrix))
(format #t "~1Thvdf-offset: #<vector @ #x~X>~%" (-> this hvdf-offset))
(format #t "~1Thmge-scale: #<vector @ #x~X>~%" (-> this hmge-scale))
(format #t "~1Tfog: #<vector @ #x~X>~%" (-> this fog))
(format #t "~1Tstores: #<qword @ #x~X>~%" (-> this stores))
(label cfg-4)
this
)
;; failed to figure out what this is:
0

View File

@ -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)
)

View File

@ -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)
)
)
)

File diff suppressed because it is too large Load Diff

View File

@ -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
)

View File

@ -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)

View File

@ -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

View File

@ -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))

View File

@ -145,7 +145,7 @@
#t
"#<texture ~20S psm: ~6S ~4D x ~4D num-mips: ~D :size ~4DK "
(-> 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
)

View File

@ -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
)
)

View File

@ -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))

View File

@ -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());