models: map objects
The world model objects, CMapObj: the root file of a .wmo with its materials, groups, portals,
lights and doodad sets, and its groups, CMapObjGroup, each a file of its own with geometry, a
BSP tree and liquid. This doc covers how the files are read and what the rest of the client asks
of them.
Four object files hold the code: MapObj.cpp from 0x6a2c90 through 0x6a6710, the group file
from 0x6b83c0 through 0x6bcff0, the reader from 0x6c3840 through 0x6c4c20, and AaBsp.cpp
from 0x692ba0 through 0x693e80. The group file has no source path and is named after the
VertArray@CMapObjGroup type it allocates; the reader is named for what it does. The world's
map code (terrain) creates, places and draws map objects; the collision code queries them.
Roots: 0x693ca0, 0x693ce0, 0x693d20, 0x6a3040, 0x6a3100, 0x6a3160, 0x6a3230, 0x6a33f0, 0x6a3410, 0x6a3420, 0x6a3430, 0x6a34b0, 0x6a35b0, 0x6a36d0, 0x6a37b0, 0x6a3a40, 0x6a3b10, 0x6a3c20, 0x6a3cf0, 0x6a3dc0, 0x6a3ee0, 0x6a3f10, 0x6a3f80, 0x6a4200, 0x6a4270, 0x6a42b0, 0x6a4310, 0x6a4420, 0x6a44b0, 0x6a45b0, 0x6a4640, 0x6a4670, 0x6a47b0, 0x6a47e0, 0x6a4830, 0x6a4990, 0x6a4a00, 0x6a4a30, 0x6a4a50, 0x6a4a90, 0x6a4ad0, 0x6a4b10, 0x6a4cc0, 0x6a4dc0, 0x6a4e00, 0x6a4fb0, 0x6a5200, 0x6a5620, 0x6a5650, 0x6a5710, 0x6a57d0, 0x6a6710, 0x6b87c0, 0x6b8810, 0x6b8880, 0x6b92b0, 0x6b98c0, 0x6b9d50, 0x6b9f10, 0x6ba410, 0x6ba660, 0x6ba770, 0x6ba920, 0x6ba970, 0x6c3840, 0x6c3f50, 0x6c43d0, 0x6c4c20
Root file chunks
A root file is parsed in a fixed chunk order without reading the tags: after the version chunk,
MOHD, MOTX, MOMT, MOGN, MOGI, MOSB, MOPV, MOPT, MOPR, MOVV, MOVB, MOLT,
MODS, MODN, MODD and MFOG follow one another, each pointer stored and each record count
derived from the chunk size. Only the last, MCVP, is tested: it is taken when it lies inside the
file and carries its tag.
| chunk | record | chunk | record |
|---|---|---|---|
MOMT | 64 bytes | MOVV | 12 bytes |
MOGI | 32 bytes | MOVB | 4 bytes |
MOPV | 12 bytes | MOLT | 48 bytes |
MOPT | 20 bytes | MODS | 32 bytes |
MOPR | 8 bytes | MODD | 40 bytes |
MFOG | 48 bytes | MCVP | 16 bytes |
Addresses: 0x6c3a60, 0x6c3a00, 0x6c3a20, 0x6c3990, 0x6c3b2d, 0x6c39d0, 0x6a3496, 0x6c39e0, 0x6a5650
Confidence: verified
Proof: one
Test: none
0x6c3a60 starts at file +0xc (the data at map object +0x1c0) and calls 0x6c3a00 with each
tag; 0x6c3a00 returns the cursor and adds 8, ignoring the tag, and the caller adds the chunk size.
The counts are size >> 6, size >> 5, and multiplications by 0xaaaaaaab or 0xcccccccd followed by
shifts, which divide by 12, 48, 20 and 40. 0x6c3a20 compares the cursor with +0x1c0 + +0x1c4 and
the tag with MCVP. The MOGI count size >> 5 goes to +0x168 (0x6c3b2d); 0x6c3990 then
stores it at +0x1f0, which the reset 0x6a3430 seeds to 384 (0x6a3496), and allocates a group
object for each group into the pointers from +0x1f4, 384 of which end the 0x7f4 fixed bytes;
0x6a5650 allocates 0x7f4 plus the caller's extra bytes. The loop at 0x6c39e0 runs to the MOGI
count with no cap at 384, so a file of more than 384 groups writes its pointers past the fixed part,
into the extra bytes and beyond.
Group file chunks
A group file's required chunks also follow in a fixed order without tag checks: MOPY (2-byte
face records), MOVI (2-byte indices), MOVT and MONR (12-byte vectors), MOTV (8-byte
coordinates) and MOBA (24-byte batches). The vertex stride is 32 bytes when the group's flags
have 8 or 0x40 and 36 otherwise; the optional chunks follow by the group's flags.
Addresses: 0x6c40c0, 0x6c4530, 0x6c3f80
Confidence: verified
Proof: one
Test: none
0x6c40c0 takes the first chunk at its argument and stores each data pointer from +0xc4 and
each count from +0x124: size >> 1 twice, size·0xaaaaaaab >> 35 twice (12 bytes), size >> 3,
and size·0xaaaaaaab >> 36 (24 bytes). It tests group +0x10 with 0x48 and stores 32 or 36 times
the vertex count at +0xec, then calls 0x6c4530. The index byte count +0xf0 is twice +0x12c
when +0xcc and a global flag are set, else twice +0x128.
Group header
A group file is the version chunk and one MOGP chunk whose data opens with a 0x44-byte header;
the geometry chunks start right after it. The header fields land in the group:
| header | group | holds |
|---|---|---|
+0x00 | +0xc0 | name, an offset into the root's MOGN turned into a pointer |
+0x08 | +0x10 | flags |
+0x0c | +0x14 | bounding box, six floats |
+0x24, +0x26 | +0x2c, +0x30 | first portal reference and count, 16-bit |
+0x28 to +0x2c | +0x3c to +0x40 | three batch counts, 16-bit |
+0x30, +0x34, +0x38 | +0x34, +0x38, +0x14c | fog indices, liquid word, group id |
After the chunks, every batch resolves the textures of its material, the batch's byte +0x17.
Addresses: 0x6c3f80, 0x6c3fa6, 0x6c3ff5, 0x6c4053, 0x6c4080, 0x6c3db0
Confidence: verified
Proof: one
Test: none
0x6c3f80 advances the file pointer +0x150 by 0x14 (version chunk and the MOGP header), reads
the fields above with rep movs for the box, then add eax, 0x44 and calls 0x6c40c0. It first
unlinks the group's node and links it again into the root's group list (+0x1e4, which holds the
node's offset in the group), and last sets +0x164 to 1 and +0xbc to 0. The loop at 0x6c4080 steps the batches by 0x18.
Material textures
A material record is the file's 64-byte MOMT record, used in place. Its first texture is the
MOTX string at offset +0xc, or createcrappygreentexture.blp when that string is empty; its
second, at +0x18, is loaded only when its string is not empty. The handles go to +0x38 and
+0x3c, once: a material whose first handle is set is skipped.
Addresses: 0x6c3db0, 0x6c3d70, 0x6c4c20, 0x86c3c0
Confidence: verified
Proof: one
Test: none
0x6c3db0(index) takes record +0x1d8 + 64·index, returns at once when +0x38 is non-zero, and
calls 0x6c4c20 with MOTX (+0x124) plus the offset, or with the string at 0x86c3c0; an empty
second string stores 0 at +0x3c. 0x6c3d70 zeroes both handles of every material.
Loading
A map object is looked up by name in a cache and created on a miss; its root file is read,
asynchronously when asked, and parsed when the read completes. Each group file, named after the
root with _%03d and .wmo, loads the same way when first needed.
Addresses: 0x6a3230, 0x6c3890, 0x6c3840, 0x6c3990, 0x6a4a30, 0x6c3e20, 0x6c3f50, 0x6c3f80
Confidence: inferred
Proof: none
Test: none
0x6a3230 hashes the name into the cache and calls 0x6c3890 for a new entry; 0x6c3e20 formats
the group name with _%03d. The completion paths 0x6c3840 and 0x6c3f50 close the read request
and the file before parsing.
Queries
The collision and world code ask a map object for segment and box hits, facets in a box or a volume, liquid heights, and the vertex colour under a point. A group answers through its axis-aligned BSP, whose leaves are welded into cached meshes on first use, and through its liquid grid of 4.1666665-yard tiles.
Addresses: 0x6a37b0, 0x6a3b10, 0x6a3c20, 0x6a3dc0, 0x6b92b0, 0x6bc370, 0x6bc1c0, 0x693d60, 0x6b9f10, 0x6b9a50
Confidence: inferred
Proof: none
Test: models::aabsp_box_query_difftest, models::bspdispatch_normalize_difftest, models::mliq_liquid_height_difftest, models::seg_face_cross_difftest, models::seg_face_dot_difftest, models::seg_normal_scale_difftest, models::wmo_mocv_barycentric_color_difftest
Each map object query guards on +0x1d4 and each group through 0x6a4a00. The segment walk is
BSP segment descent; the liquid grid scales by 1/4.1666665.
Of 0x6a37b0, seg_face_cross_difftest runs 0x6a3920–0x6a39b8, seg_face_dot_difftest
0x6a39bd–0x6a39f4, seg_normal_scale_difftest 0x6a3a11–0x6a3a36; of 0x6b92b0,
bspdispatch_normalize_difftest runs 0x6b9354–0x6b9388; wmo_mocv_barycentric_color_difftest
runs 0x6b9a50 whole; mliq_liquid_height_difftest runs 0x6b9f10 whole;
aabsp_box_query_difftest runs 0x6bc1c0 whole.
BSP segment descent
A group's BSP node is 16 bytes: a 16-bit flags word (0x4 leaf, low two bits the split axis), the
negative and positive children (+0x2, +0x4, 0xffff for none), the face count +0x6, the first
face reference +0x8, and the split distance +0xc. A segment descends with the node's box: it
stops when both ends lie more than 0.01 beyond the box on the split axis; with f0 and f1 the
ends' distances from the split, it visits both children whole when either is within 0.01, one
child when both are beyond 0.01 on one side, and otherwise splits at t = f0/(f0 − f1), the
start's side first. A leaf tests its cached mesh, else each face.
Addresses: 0x6bc370, 0x6bc394, 0x6bc3e9, 0x6bc4c5, 0x6bc4fc, 0x6bc535, 0x6bc56e, 0x6b88e0, 0x6bc700, 0x810ccc
Confidence: verified
Proof: one
Test: models::aabsp_leaf_tscale_difftest, models::aabsp_segment_clip_difftest, models::aabsp_segment_split_difftest, models::wmobsp_leaf_tscale_difftest
0x6bc3e9 masks the axis with 3 and compares p − box.min with −0.01 (0x810ccc) and
box.max − p with 0.01. The child boxes copy the parent's with min[axis] or max[axis] set to
the split. 0x6bc56e computes f0/(f0 − f1) with fdivr and the midpoint p0 + (p1 − p0)·t;
f0 > 0 takes the positive child first. A leaf calls 0x6b88e0, and on 0 0x6bc700 for each of
its +0x6 face indices.
Of 0x6b88e0, aabsp_segment_clip_difftest runs 0x6b88e0–0x6b88f4,
wmobsp_leaf_tscale_difftest 0x6b8af8–0x6b8b2a; aabsp_segment_clip_difftest runs 0x6bc370
whole; of 0x6bc370, aabsp_segment_split_difftest runs 0x6bc56e–0x6bc5bc; of 0x6bc700,
aabsp_segment_clip_difftest runs 0x6bc700–0x6bc719, aabsp_leaf_tscale_difftest
0x6bc78d–0x6bc7bb.
Bounding spheres and volume
A loaded map object's bounding sphere is centred at (min + max)·0.5 of its box, the sum rounded
to a float before the halving, with radius |max − centre|; a group's comes the same way from its
group record's box. An unloaded map object gives a zero sphere. A point is inside the map object's
convex volume when every plane gives n·p + d ≤ 0, a NaN counting as inside, and with no planes
it is inside; an unloaded map object contains nothing.
Addresses: 0x6a4310, 0x6a44b0, 0x6a4990, 0x6a49d7
Confidence: verified
Proof: one
Test: models::wmo_bounding_sphere_difftest, models::wmo_point_in_convex_volume_difftest
0x6a4310 adds +0x1ac to +0x1a0 and so on into a stored vector, multiplies by 0.5, and takes
sqrt of the squared distance from the centre to +0x1ac. 0x6a44b0(out, index) reads the
32-byte record at +0x130, box at +0x4 and +0x10. 0x6a4990 walks +0x194 planes of 16
bytes at +0x15c (the MCVP chunk), computes ((ny·py + nz·pz) + nx·px) + d and returns 0 at the
first plane where test ah,0x41 finds neither C0 nor C3 (0x6a49d7).
wmo_bounding_sphere_difftest runs 0x6a4310 whole; wmo_bounding_sphere_difftest runs 0x6a44b0
whole; wmo_point_in_convex_volume_difftest runs 0x6a4990 whole.
Portal vertex fade
When a group's MOCV colours are read, every vertex of a face whose MOPY flags lack bit 0 gets
alpha 0xff, unless a global switch is set. On the group's first draw, each vertex up to the
highest vertex of the batches its first batch count covers is faded toward the outside: d is its least distance to a portal
of the group that leads to a group with flags 0x8 or 0x40. At d = 0 the colour becomes
0xffffffff; for 0 < d < 6.666667 with alpha 0, with t = 1 − 0.15·d, each of r, g, b becomes
c + (255 − c)·t and alpha 255·t, each byte taken as (x + 512) >> 14.
Addresses: 0x6c41e0, 0x6c4605, 0x6c43d0, 0x6c4340, 0x6c4240, 0x6c443e, 0x6c4449, 0x6c4468, 0x6b3fb5
Confidence: verified
Proof: one
Test: models::aabsp_nearest_dist_difftest, models::wmo_vertex_fog_blend_difftest
0x6c4605 calls 0x6c41e0 unless the byte at 0xca8064 is set. 0x6b3fb5 calls 0x6c43d0 while
group +0xbc is 0; it sets +0xbc and loops vertices 0 through batch +0x14 of batch
+0x3c − 1. 0x6c4340 walks the group's +0x30 portal references from +0x2c, testing the other
group's record flags with 0x48. 0x6c4240 returns 0 when the squared plane distance is under
1/36 and the point lies in the portal polygon, else the least edge distance. The constants are
6.666667, 0.15 and 255.0.
aabsp_nearest_dist_difftest runs 0x6c4240 whole; of 0x6c4340, wmo_vertex_fog_blend_difftest
runs 0x6c4340–0x6c435a; wmo_vertex_fog_blend_difftest runs 0x6c43d0 whole.
Vertex buffer pools
The group file also holds the vertex buffer pools the world draws terrain and map objects from: blocks of a device vertex and index buffer, split, merged and evicted by size.
Addresses: 0x6ba1e0, 0x6ba340, 0x6ba410, 0x6ba5a0, 0x6ba660, 0x6ba770, 0x6b87c0
Confidence: inferred
Proof: none
Test: none
0x6ba1e0 creates the buffers named VBBList_vtx and VBBList_idx; 0x6b87c0, called from the
map code, creates two pools.
Group flag tests
A group's flags exist twice: the first dword of its 32-byte MOGI record ([root+0x130] + 0x20·index)
and the group's +0x10, stored from the MOGP header at +0x08. The seeds' loops test the record
copy; the portal walk, the drawer router and the loader test the group's. The tests with an
immediate in the map object code, 0x680000 to 0x6c5000:
| bit | tested at | effect |
|---|---|---|
| 0x1 | 0x6c4579 | the load parses the BSP chunks |
| 0x4 | 0x6c45d9 | the load stores the vertex colours (+0xf4, count +0x148) |
| 0x8 | 0x6a880d, 0x6b3d13, 0x6b3f40, 0x6b44f8 | exterior: a flood root, a portal into it records a window, and the entity claim leaves the indoors bit clear |
| 0x40, 0x48 | 0x6a8823 (0x40); 0x6b3be8, 0x6b3fe8, 0x6b63c9 (0x48) | exterior-lit: the entity claim lights it by the sun, the drawer choice, no interior chain |
| 0x200 | 0x6c453d | the load stores the light references (+0xe4, count +0x140) |
| 0x800 | 0x6c455b | the load stores the doodad references (+0xe8, count +0x144) |
| 0x1000 | 0x6b4176, 0x6b4220, 0x6c460d, 0x6b9e5c, 0x6b9f68, 0x6baa7f, 0x6bb17f, 0x6bb6bf | liquid: latches the parity, the load stores the grid, and the liquid queries of a group read it |
| 0x2000 | 0x6a4e2f | skips the group in the liquid query |
| 0x10000 | 0x6b3d0b, 0x6b3d8b, 0x6b3f1b, 0x6b4215 | the group draws through the callback and is never walked |
| 0x20000 | 0x6c46a6 | the load stores the strip index chunk (+0xcc, count +0x12c) |
| 0x40000 | 0x6b42e0 | the walk publishes the root's sky box name |
| 0x148 | 0x6b42d0 | the walk sets the render-global byte 0xca80c4 |
Addresses: 0x6c400b, 0x6c400e, 0x6a4b10, 0x6b3be8, 0x6b3d0b, 0x6b3d13, 0x6b3d8b, 0x6b3f1b, 0x6b3f40, 0x6b3fe8, 0x6b4176, 0x6b4215, 0x6b4220, 0x6b42d0, 0x6b42e0, 0x6b44f8, 0x6b63c9, 0x6a880d, 0x6a8823, 0x6b9e5c, 0x6b9f68, 0x6baa7f, 0x6bb17f, 0x6bb6bf, 0x688a25, 0x688a4a, 0x697b94, 0x6a6971, 0x6a6c31, 0x6c4530, 0x6c453d, 0x6c455b, 0x6c4579, 0x6c45d9, 0x6c460d, 0x6c46a6, 0x6a4e00, 0x6a4e2f, 0x69b570, 0x69b575, 0xca80c4
Confidence: verified
Proof: one
Test: none
0x6c400b loads the header word and 0x6c400e stores it at +0x10. The loader 0x6c4530 reads that
copy: 0x200 and 0x800 each take a chunk of 16-bit entries, 0x1 the BSP chunks, 0x4 the colours,
0x1000 the liquid grid and 0x20000 the chunk at +0xcc, which the batch draw reads as indices
(0x6b4e64). The seeds read [eax+edi] of the record array at +0x130; 0x6b3be8 and the
recursion read the group. The mask of 0x6a4e00 is its first argument, the literal 0x2000 its sole
caller pushes (0x69b570). A scan of 0x680000 to 0x6c5000 for test, and and bt with an
immediate above 0x10000 on the flags finds exactly 0x6b42e0 and 0x6c46a6, and sees no mask held in
a register. Bit 0x8000 is read by shr eax,0xf; and al,1 at 0x670735
(terrain/world#entity-outdoors-test), the only shr by 0xf from 0x66f000 to 0x6c5000; there the other immediates 0x8000 are
or stores (0x670df1, 0x671052, 0x6713c2, 0x688a5a) and one compare (0x68b5cc), and the image has no
test ah,0x80, test byte [reg+0x11],0x80 or bt reg,0xf (test ah,0x41 finds 1218 for control). The scan
skips test ah,ah; js and jns: its five hits there test 0xc7b2a4 (0x688a25, 0x688a4a) or a node's +0x8
(0x697b94, 0x6a6971, 0x6a6c31), not group flags.
Portal crossing
0x6a3f80(segment, fraction, groups) finds the nearest portal a segment crosses and the two groups
beside it. The ray runs from the segment's start along its unit direction for length × fraction. For
each group the segment's box meets and each of its portal references, the portal plane meets the ray
with tolerance 0.1; a hit at 0 or more and at most the shortest so far, inside the portal polygon,
becomes the shortest. The first group out is the reference's own group when (n·start + d ≥ 0)
equals (side > 0), else its other group; the second is the other. The fraction becomes the
shortest over the length; the result is 1 when a portal counted.
Addresses: 0x6a3f80, 0x6a3fb2, 0x6a3ff2, 0x6a4018, 0x6a406e, 0x6a4083, 0x6a40c0, 0x6a40ed, 0x6a40fd, 0x6a4111, 0x6a4121, 0x6a4144, 0x6a4150, 0x6a4171, 0x6a4181, 0x6a41ec, 0x6a47e0, 0x6a4a00, 0x7c22b0, 0x7c23e0, 0x7bf680, 0x7ffd74
Confidence: verified
Proof: one
Test: models::portal_extent_scale_difftest, models::portal_plane_side_difftest, models::portal_result_scale_difftest, models::portal_seg_normalize_difftest
ret 0xc. 0x6a3fb2 takes the segment's end less its start; 0x6a3ff2 forms 1/length and the unit
direction; 0x6a4018 multiplies the length by *fraction. 0x6a406e is the box test of 0x6a47e0
and 0x6a40c0 pushes 0.1 (0x3dcccccd) for 0x7c22b0, which hits a parallel ray at 0 when the
start lies within that tolerance of the plane. 0x6a40fd and 0x6a4111 keep a hit with
test ah,5; jnp (reject below 0) and test ah,0x41; je (reject above the shortest): equal and NaN
stay. 0x6a4121 takes the plane's dominant axis for the polygon test 0x7c23e0. The side sum is
n.y·s.y + n.z·s.z + n.x·s.x + d (0x6a4150 to 0x6a416e); 0x6a4171 sends a negative or NaN
sum to the 0x6a4193 arm. The tests run the slices 0x6a3f8a to 0x6a4018, 0x6a4018 to 0x6a4045, 0x6a414d to
0x6a4179 and 0x6a41ec to 0x6a41f5.
Group liquid scope
0x6a4e00(mask, point, type, height, vector) asks the groups of one map object, in index order,
for liquid at a point in the object's space, and the first group that answers wins. A group is asked
only when its flags and the mask share no bit, the point is strictly inside its MOGI box on all
three axes (a NaN fails each test), and the group is loaded. The sole caller passes 0x2000 (Group flag tests). The box bounds the point above and below; inside it the group's grid has no floor.
Addresses: 0x6a4e00, 0x6a4e23, 0x6a4e2f, 0x6a4e39, 0x6a4e53, 0x6a4e5f, 0x6a4e79, 0x6a4e86, 0x6a4e94, 0x6a4eac, 0x6a4b10, 0x6a42b0, 0x6a4a00, 0x69b575
Confidence: verified
Proof: one
Test: none
ret 0x14. 0x6a4b10 returns the record +0x130 + 0x20·index. The lower bounds are fcomp with test ah,0x41; jne (rejects below, equal and NaN); the upper bounds test ah,5; jp (rejects above,
equal and NaN). 0x6a42b0 reads the group's loaded byte (+0x164), 0x6a4a00 returns the group, and
0x6a4eac calls 0x6b9f10; its true result returns 1.
Group liquid override
0x6b9f10(point, type, height, vector) answers a group's liquid at a point in the group's space. A
group whose +0x38 (the MOGP header's liquid word, +0x34) is not 0xf is liquid at every point:
the type is that word, the height FLT_MAX (0x7f7fffff), the vector zero, and the result 1. Without
flag 0x1000 the result is 0 and nothing is written. Otherwise the tile under the point has a nibble:
0xf is a hole; the type written is nibble & 3; a tile of type 0 accepts when z < h + 0.01, type 1 never, type 2 and 3
when z < h, with h the interpolated surface, written unbiased.
Addresses: 0x6b9f10, 0x6b9f1a, 0x6b9f21, 0x6b9f2e, 0x6b9f65, 0x6b9f68, 0x6ba00b, 0x6ba035, 0x6ba04e, 0x6ba055, 0x6ba085, 0x6ba08d, 0x6ba0d9, 0x6ba109, 0x6ba153, 0x6ba160, 0x6ba16c, 0x8029d0, 0x6c404a
Confidence: verified
Proof: one
Test: models::mliq_liquid_height_difftest
ret 0x10. 0x6c404a loads the word from the header's +0x34 into +0x38. 0x6b9f65 tests ah,0x10
of the flags. 0x6ba035 masks the nibble with 3 and 0x6ba04e jumps through 0x6ba160 by the byte
0x6ba16c gives (00 02 01 01 00 02 01 01 00): 0 to 0x6ba055, 1 to 0x6ba153 (the miss), 2 to
0x6ba0d9. 0x6ba085 adds 0.01 (0x8029d0) to the surface for fcomp against z, rejecting with test ah,0x41; jne unless the sum is above z; 0x6ba109 compares the surface itself. Both store the
unbiased surface and edx (the masked nibble) as the type, so the water tile 4 reports 0.
Material texture request
0x6c4c20(name) makes a material's texture with the flags word 0x58a980(3, 1, 1, 0, 0, 0, aniso, 0)
(filter mode 3, repeat in both axes, aniso the map's 0xc6297c) and calls the texture creator
0x449d90 with its force argument 1, so the creator replaces the filter mode and the anisotropy
with its two globals. The group draws change only the wrap bits afterwards: per batch bit 3 of the
stage's flags is the complement of material flag 0x40 and bit 4 of 0x80, so a set flag clamps.
Nothing else in the group draws sets the filter, the anisotropy or the alpha reference.
Addresses: 0x6c4c20, 0x6c4c26, 0x6c4c48, 0x6c4c65, 0x6c4c6f, 0x6c4c77, 0x58a980, 0x449d90, 0x449ae0, 0xc6297c, 0x6b503e, 0x6b5066, 0x6b53e3, 0x6b540b, 0x58ade0, 0x58ad30
Confidence: verified
Proof: one
Test: none
0x6c4c26 loads the anisotropy and 0x6c4c48 pushes the filter mode, the last argument on the stack
and so the first parameter of the packer; 0x6c4c6f push 1 is the creator's force argument and
0x6c4c77 its call. 0x6b503e to 0x6b5066 (exterior) and 0x6b53e3 to 0x6b540b (interior) read
the stage flags (0x58ade0), compute (~flags >> 3) into bits 3 and 4 and write them back with
0x58ad30; the materials' words are [esi]. The reference alpha comes only from the blend state
(terrain/groupdraw#interior-batch-states).
BSP tree setup
A group whose flags have 1 reads MOBN and MOBR among its optional chunks and points its tree
at group +0x44 at them: 0x692f20(nodes, nodeCount, refs, refCount, bounds) stores the
nodes at tree +0x0 and +0x4, the face references at +0x8, the two counts at +0xc and
+0x10 and 0 at +0x48, and copies the group's bounding box to +0x4c. The node count is the
MOBN size over 16, the reference count the MOBR size over 2.
Addresses: 0x692f20, 0x692f3c, 0x692f51, 0x6c4579, 0x6c459e, 0x6c45a4, 0x6c45ad
Confidence: verified
Proof: one
Test: none
0x6c4579 tests flag bit 0. The caller pushes group +0x14, size >> 1 (0x6c459e), the
MOBR data, size >> 4 (0x6c45a4) and the MOBN data, with ecx at group +0x44.
0x692f20 stores the first argument at +0x4 and +0x0, 0x692f3c stores 0 at +0x48, and
0x692f51 rep movs copies six dwords to +0x4c; ret 0x14.
Group liquid draw type
0x6ba970 gives the type a group's liquid draws as (terrain/groupdraw#group-liquid): the low
nibble of the first tile byte whose nibble is not 0xf among the first x tiles bytes of the MLIQ
tile flags, else 0xf. Only the grid's first row of tiles is scanned, so a group whose first row is
all holes takes type 0xf, whose frame the draw requests before bounding it, a client fault
(terrain/groupdraw#group-liquid); the header's liquid word +0x38 is not read.
The parse stores MLIQ's vertex and tile counts at +0xf8 to +0x104, the corner at +0x108,
the material at +0x114, the vertices at +0x118 and the tile flags at +0x11c.
Addresses: 0x6ba970, 0x6ba971, 0x6ba981, 0x6ba993, 0x6c460d, 0x6c461c, 0x6c4631, 0x6c464d, 0x6c466f, 0x6c4686, 0x6c468f, 0x6b62ef
Confidence: verified
Proof: one
Test: models::first_liquid_tile_type_difftest
0x6c460d tests flag 0x1000. 0x6c461c to 0x6c463a store the data's dwords +0x0 to +0xc
(x and y vertices, x and y tiles), 0x6c464d the corner +0x10, 0x6c466f the word +0x1c;
0x6c4686 stores data + 0x1e and 0x6c468f that plus 8·xverts·yverts. 0x6ba971 loads
+0x100, the x tile count; 0x6ba981 jle returns 0xf for 0 or below; 0x6ba993 is and al,0xf; cmp al,0xf; jne over [+0x11c]. The one caller is 0x6b62ef, and 0x6b62e0 loads no +0x38.
first_liquid_tile_type_difftest runs 0x6ba970 whole.