Entry 617
F_Obj records as DecodeF_Obj sets them and the engine's glam matrices as the game's setters
Documented in Animation playback, Bosses - ccBoss and Skeith, The ALTIMIT desktop, The Flag Race - menu 88, the race's task and its flags, In-engine streams.
Linked from piney-apples: the launcher, the builder and the game in one portable program.
Files58 in 29 directories
boss.rscrates/piney-battle/src/boss/corbenik/eff.rssecond.rsthird.rscrates/piney-battle/src/boss/gorre/brother.rscrates/piney-battle/src/boss/kyvia/core.rscrates/piney-battle/src/boss/macha.rstarvos.rscrates/piney-data/src/anim.rsscene.rsvu0.rscrates/piney-data/src/dungeon/place.rscrates/piney-data/src/statics/mod.rscrates/piney-data/tests/anim.rsdisc.rscrates/piney-demo/src/draw.rsnames.rsopening.rscrates/piney-desktop/src/anm.rsdesktop.rsframes.rsmail.rsview.rscrates/piney-fieldui/src/menus/hack.rscrates/piney-game/src/gameover.rscrates/piney-game/src/session/tests/kyvia_stage.rscrates/piney-gs/src/convert.rscrates/piney-stream/examples/fobj_probe.rscrates/piney-stream/src/load.rsscene.rscrates/piney-viewer/src/mesh.rscrates/piney-world/src/chara/body.rsfoe.rspose.rscrates/piney-world/src/combat/boss.rsbreath.rsstage.rsweapon.rscrates/piney-world/src/draw.rsworld.rscrates/piney-world/src/field/area.rscrates/piney-world/src/grunty/mod.rsrace.rscrates/piney-world/src/story_map/disc.rsmod.rstruths_core.rscrates/piney-world/src/systems/fireflies.rslake_sky.rssky.rsstatics.rscrates/piney-world/src/town/mod.rsdocs/README.mddocs/engine/animation.mdboss.mddesktop.mdflag-race.mdstream.mdtools/test_fobj_rs.pyMentioned incrates/piney-world/src/combat/boss.rs:207
616 noticed that the desktop built an F_Obj record's matrix from
glam's host-float Euler turns, and asked whether it differed from the
game. It did, and so did the other path: the bodies' F_Obj poses
(ObjRecord::pose) multiplied the scale into a finished rotation, which
is not what the game does either. Both now go through one function,
piney_data::anim::FObj, which is DecodeF_Obj's arithmetic, and a new
harness compares every F_Obj record of the four discs with the game's
own code. The same review turned up a dozen other matrices built in glam
that the game builds with VU0; each now calls the game's setter.
What the game does with an F_Obj record
ccStream::DecodeF_Obj (INF 0x0014e950, MUT 0x0014e9d0, OUT 0x0014d7a0,
QUA 0x0014d560; OUT's and QUA's are recompiled, 872 bytes instead of 904,
with the same arithmetic) runs when DecodeFrameChunk reaches the
record's frame. The desktop's ccAnm::_AnimateForward, the bodies'
animations and the streams all reach it.
ccRingBufferTh::ReadStructreads the 52 bytes whole.- Three stack vectors are built. The position gets w 1. Each rotation
lane is
mul.sby π (0x40490fdb), thendiv.sby 180 (0x43340000), with w 0. The scale gets w 1. - The transparency is held to 0..1:
c.lt.sagainst 0, thenc.le.sagainst 1. - The object's type (+0x8e) picks the branch:
- 0x100, a plain object:
dispSW(+0xa2) is the flags' low bit, with bit 1 set unless +0xa1 bit 0 (the part flag, whichccObj::Init0x0013b5c0 takes from Obj2 flag bit 1) is set and every position lane is 0 (c.eq.s). ThenccCoord::SetMatrix_PosRotZYXScale(pos, rot, scale)(INF 0x00138120), andlocaltp(+0x88) is the held transparency, as isworldtp(+0x84) unless +0x8c bit 0 (succession) is set. - 0xd00, a particle: the setter alone.
- 0xe00, an effect: the stream's effect branch, already ported.
- 0x100, a plain object:
SetMatrix_PosRotZYXScaleputs the scale on the unit matrix's diagonal, turns it withsceVu0RotMatrix(z, then y, then x, each on the left, each rounded) and moves it withsceVu0TransMatrix. It setsmatCalcSW(+0x8d).
vu0::pos_rot_zyx_scale was already this setter, and the streams' scene
already used it. The desktop and the bodies did not.
Whether the old paths differed
To measure, the old formulas were put back for one run of the probe:
| path | records differing from the game |
|---|---|
desktop (fobj_matrix, glam) | xddesk01 2,873 of 2,928; eex1 100 of 108; eii1 154 of 169; elgx 169 of 183; ending 17,853 of 17,853 |
bodies (ObjRecord::pose, rotation times scale) | xddesk01 1,382 of 2,928; eex1 36 of 108; eii1 33 of 169; elgx 43 of 183; ending 280 of 17,853 |
The glam path was wrong in the low bits nearly everywhere. It also put a tiny value where the game has an exact 0, and the reverse. The bodies' path was off by a few ulps where the scale is not exactly 1. The xddesk01 column shows what that path would have given the desktop.
One home
piney_data::anim::FObjis the record:from_words,local,localtpanddisp_sw(part).ObjRecordholds anFObj(set).ObjRecord::poseand the glamPose::transformare gone.Animation::obj_records_atreplacesobj_poses_at.entry_locals_atreplacesentry_poses_atand returns aLocal(matrix bits and alpha), so a track's pose and a record's matrix reach the bodies the same way.transforms_at, which nothing used, is gone.- The desktop's own F_Obj parser (
frames::fobj_records,fobj_objects, itsFObj) andfobj_matrixare gone.AnmappliesAnimation::objs. ItsdispSWisFObj::disp_sw, with the part flag read from the scene's Obj2 chunks (Scene::parts, new). Its locals,local_ofandset_localare bits. - The streams'
f_objreads anFObjtoo. Its effect branch now usesTransMatrixon the unit matrix (a -0 or denormal place lands as +0, as on the EE) and the EE clamp.
The other glam matrices
Every from_rotation_*, Mat4::from_* and Mat3::from_* in the engine
was checked against the game's code. These were built in glam where the
game uses a ccCoord setter or libvu0, and now call the same routine:
- The ccAnm's own matrix.
Anm::set_pos_rot(glam, XYZ order) becomesset_root(M4), which the owner fills with its own setter:- the NEW mark:
SetMatrix_PosRotXYZ(desktop 0x00402280); - the title's panels:
UnitMatrix+TransMatrix, orSetMatrix_PosRotXYZ; - the boot card:
SetMatrix_PosRotXYZScale(0, 0, scale), which was a glam scale product indraw_anm_scaled(now gone); - the Flag Race's clips:
SetMatrix_PosRotZYX(MUT gcmn 0x005fe590). The port turned them in XYZ order, which is the wrong composition whenever the camera's pitch and heading are both set.
- the NEW mark:
- The hack menu's crystal roll:
sceVu0RotMatrixZon the unit matrix, thenMulMatrix(mat, it)(gcmn 0x005656c4). - The drained enemy in Data Drain's movie:
SetMatrix_PosRotZYX((0, -900, 130), (0, 0, π))(gcmn 0x00432000). - The mail photo:
SetPhot'sUnitMatrix+TransMatrix(desktop 0x00409438). - The boss waves.
Out::Wavecarries aWavePlace(the setter) instead of a scale:SetMatrix_PosRotZYX: the base's, Tarvos's, a Gorre brother's, Macha's Epitaph wave, and Corbenik's second and third forms';SetMatrix_PosRotXYZ: Kyvia's core (MUT 0x004f90f0);SetMatrix_PosRotZYXScaleat 2: Macha's own wave (QUA 0x003a6ca4);- the unit matrix moved: Corbenik's
ccBossEffWave(QUA 0x00377ccc).
- The boss after-images:
SetMatrix_PosRotZYXScale(QUA 0x0035f810), where the port multiplied a glam scale into the turned matrix. Their per-draw steps were host floats with a fixed fade. They now followccBossAfterImageEx::Draw(MUT 0x00471320) on theENTRYAFTERIMAGE_Tit keeps (AfterImage::p):maxFramedown to 0;colorAlphabycolorSpd, held to 0-100;- the transparency by
transSpd, dying at 0 or at 1 and drawn that once more. The old step never killed an image whose transparency rose. - the scale by
(es - ss) * (1 / scaleTime)in VU0 vectors, each lane held ates's once larger in size (fabsand_dpfgt).
- The Grunty's scaled root:
SetMatrix_PosRotZYXScale. - The story map's rocks:
SetMatrix_PosRotXYZ(pos, (rot, 0, 0))(MUT gcmn 0x0041f27c). The port had T·Rx in glam. - The story map's bodies and their hit matrices, the static models
(
STATICMODEL::Draw), the field's ground tiles (FIELD_MESH::draw) and covers (FCOVER::Draw):UnitMatrix+TransMatrix(vu0::translation, new). - The skies' dummy and bob clumps: each
DrawBG'sSetMatrix_PosRotZYXat a zero turn. - The lake sky:
DUNGEON::DrawBG'sSetMatrix_PosRotZYXScale((x, y, 0), 0, (s, s, s))(gcmn 0x005ce824). STATICOBJECT's root (StaticObj::root) now uses the samePosition::bits(moved from piney-world'stown::dummy_bits) andvu0::pos_rot_zyxas piney-world's static objects.combat::stage::mat4, a copy ofvu0::to_mat4, is gone.
For the matrices that were pure translations, sceVu0RotMatrix at a zero
turn gives the unit matrix exactly (run in eemu), so the only difference
was a -0 or denormal place lane.
These stay in host floats. Each says so in one line where it is:
- the XYOFFSET matrices (
View::to_screen, worlddraw::screen), the GS converter's bone normals and the game-over squeeze. These are the renderer's side, applied to draw commands past every game value. - piney-viewer's scene geometry:
Transform::matrix,Scene::world,controller_worlds,anim::worldanddungeon::place::room_matrix. For one runTransform::matrixused the game's setter. With it,dungeon_place's geometry checks failed: they hold facing doors to 1e-4, and VU0's sine is coarser than that at a quarter turn. That geometry is the viewer's, and no game value reads it. - tests and probes.
The harness
tools/test_fobj_rs.py (follows PINEY_VOLUME) uses the new
piney-stream example fobj_probe. The probe lists every F_Obj record
on the disc:
- DATA.BIN's, by member and animation;
- every stream file's that the tables name in either language, or that
Outbreak's
STREAM/STRT.BINholds. A stream record is listed only if it is distinct, with each file's count.
For each record the probe prints FObj's matrix, localtp and dispSW
as a plain object and as a part. For DATA.BIN it also prints, at each
frame where a record holds, what the desktop's Anm::local_of gives
after a step and what local_bits_at and entry_locals_at give.
The harness runs DecodeF_Obj itself in eemu on each record, with only
ReadStruct hooked. Each record runs twice, part flag 0 and 1. It
compares the matrix, localtp, worldtp, dispSW and matCalcSW word
for word, and every user's held matrix against the game's for that
record.
| volume | records | run in the game | DATA.BIN held (anm / bits / entry) | time |
|---|---|---|---|---|
| Infection | 16,689,166 | 4,972,326 | 3,366 / 1,908 / 3,366 | 139 s |
| Mutation | 41,842,922 | 14,236,934 | 3,366 / 1,908 / 3,366 | 372 s |
| Outbreak | 30,688,675 | 18,850,890 | 21,186 / 14,868 / 21,186 | 501 s |
| Quarantine | 41,516,146 | 25,002,027 | 21,186 / 14,868 / 21,186 | 676 s |
Every record matched on every disc. The stream counts include each
archive's copy (a file in both the Japanese and the English archive is
counted twice). Some stream objects are parts (479,489 records on
Infection to 2,150,779 on Quarantine). No DATA.BIN object is a part, and
every DATA.BIN record has flag bit 0 set, so every one leaves dispSW 3.
The bodies draw every object a record places, and do not need to read
dispSW; this closes animation.md's unknown about the flag byte.
The stream rows with Infection's lengths
Outbreak's and Quarantine's English rows for streams 2-11 give
Infection's inflated lengths. Their STR1E.BIN members are larger,
because they carry two PCM tracks. For str0001 the member inflates to
38,134,224 bytes; the row says 25,023,360. The question was what the
game plays from such a row. On Outbreak:
RequestStrPlay's entry builder (0x001a2b60) copies the row's name, type, flag,gzip,ofsandsizeinto theccsTbl.ReadThread(0x001a30b0) readssizebytes from the row's sector. It testsgziponly against zero (0x001a3264), to choose the Gzip ring.GzipDecodeThread(0x001a3430) again testsgziponly for zero (0x001a34a0). It then callsccUngzip::Decode(size)(0x00155a30), which inflates until the gzip stream ends; no output length is passed.DecodeThread(0x001a3570) reads only the row's type. The scene plays its own frame section to its end.
So the game plays the whole member, and the stale length changes
nothing. The port already does the same. load::read_in reads size
bytes, and the streams inflate through Archive whole: same bytes, same
frames, same end. Nothing called load::Member::inflate, the one place
that compared the length, so it is removed. load.rs's module doc and
stream.md now say that gzip is only a flag. The probe reads the files
the same way the streams do.
The shots
A same-day base from a clean worktree of main 0c29dc3 equals
world2/shots/base: 4,550 files, 0 differ. The tip against that base
gives 4,550 files with 16 different, in three groups. Every difference is
1 or 2 levels in a few pixels.
| group | shots | pixels | cause |
|---|---|---|---|
flag_race_shots | mut-race-result | 234, max 2, in the clip's box | the race clips' root |
kyvia_stage_shots | fight-0400, -0800, -1000 | 2-7, max 1 | the core's wave root |
story_map_shots | field 09 at 010 and 280, field 10 at 280, all four discs | 6-53, max 1 | the rocks' matrix |
The evidence:
- Each change reverted. One build put back the race clips' glam XYZ
root, the rocks' glam
T·Rxand the waves' old roots (the exact ZYX times a glam scale of 1, or of 2). With them, all three groups equal the base again: 5, 6 and 380 files, 0 differ. - Order versus arithmetic. A second build kept the exact maths but turned the race clips in XYZ order, and placed the core's wave with ZYX. Both groups then equal the tip, not the base. So the pixels come from the arithmetic (glam's host floats, and a glam product with a scale of 1 that flips zero signs). The turn order makes no visible difference in these frames: the clips' pitch is small and the core turns about one axis.
- Fields 9-11 are
EVENTAREAB8, whoseDrawRockplaces each rock.
No other shot changed.
Checks
On 62c8733, the code of this entry before the stream clean-up:
- The sweep: 416 of 416 rc 0. Every line is as in
summary-main.txt, plus four newtest_fobj_rsruns. - Battle pins: 291 calls, 0 differ (probe wt-fobj at 62c8733).
- Crate tests: 786 passed, 0 failed.
- The piney-game suite: 351 / 0 / 153.
- The shots, as above.
On b7264f6 (with Member::inflate removed and the docs):
- The sweep again: 416 of 416 rc 0, each line as in the first sweep.
piney-stream's tests: 47 passed.piney-gen gen,symsandcarry --check: all current.- Clippy (all targets and features): clean. fmt: clean.
tools/docs.py check: passes.
During both sweeps a harness replaced the worktree's tools/eemu_rs.so
symlink with a build. The symlink was put back each time, and main's
file is untouched. After the sweeps only a comment changed (the
after-image constant's, below) along with this entry. The base worktree
and its target were removed.
The clock ran through an eight-day pause, from about 2026-11-19 23:00
to 2026-11-27 22:25 (191h 25m). took: is the clock's 204h 52m less
that pause.
Noticed, not changed
Every boss's Out::AfterImage is drawn with one set of parameters:
white at 100, 20 frames, 1 by -0.05. That is combat::boss::BOSS_EAI,
and it was the old code's value too. The game's own m_eai differs by
boss, as each constructor writes it:
- Skeith (INF gcmn 0x0047bc04), Fidchell (OUT 0x004a3ac4) and Magus (MUT 0x0049e59c): colour -1, so no fog blend at all.
- Innis (MUT 0x004948c0): 0x00187500 at 30, transparency 0.5 by -0.02, 80 frames.
- Corbenik's second form (QUA 0x003b22ec): 0x00505000 at 100.
Some calls pass other parameters entirely. Macha's EntryAfterImage(0)
takes the manager's null default, AfterImageParams::ENTRY. So the port
blends these after-images where the game does not. The fix is to have
each producer of Out::AfterImage carry the parameters its call passes.
- What
scaleTime,ssandeshold in each boss'sm_eai. Skeith's, Fidchell's, Innis's and Corbenik's constructors write the six fields above (Skeith's and Fidchell's alsossy and z), notscaleTime.ENTRYAFTERIMAGE_Thas no constructor, and heap.md says nothing clears a block. Magus's copies 80 bytes in first (memcpy, MUT 0x0049e584) from a source not traced. Init scales the image only ifscaleTimeis above 0, and the port assumes it is not. Settling it needs each source, or the heap model's view of those bytes. - Which parameters Tarvos's
Out::AfterImagecalls pass. Its constructor holds nom_eaiblock of the shape above.