mirror of
https://github.com/TheBozos/PS2Recomp.git
synced 2026-12-01 12:54:12 -10:00
A PS2 game's models are prebuilt VIF / GIF packets and its textures GS rasters; a native port converts them offline from the user's disc into packs in its build tree and draws them without reading a packet. TMB had all of it in its own runtime and tools; what is not TMB's moves here. Runtime (ps2xRuntime, all in ps2_runtime): - runtime/native/native_mesh_pack.h (ps2x::native::packs): MeshPack, the PS2XMSH1 container's loader (every count checked against the file's size) and object store: per file (named as the port's runtime names a loaded file, with the image's size and CRC32) its objects by offset (a port-defined kind and attributes, x y z w positions, PS2 triangle strips as a VU program reads them: StripHeader with PRIM, GIF flags, a material word and a texture slot, 16-byte StripVertex with position index, raw normal, flags, RGBA, raw s t; and port-defined tagged sections) and its GS register blocks (A+D writes recorded at their offset in the image). MeshFile::object / block find them; StripCursor walks strips. LoadedImages: where the game loaded each file in EE memory (bind checks size and CRC32 against the pack, find resolves an address to file and offset, forEach under its lock). crc32. - runtime/native/native_mesh_draw.h (ps2x::native): MeshBatch / MeshDraw (an object's batches with their GS register writes, object-to-screen matrix, clip volume, context block, interpolation key), MeshGsState (ALPHA, TEST, ZBUF.ZMSK as context and register blocks leave them), MeshViewList<D> (a view's opaque objects in traversal order and its alpha ordering table: pending until the game links it, link(bucket), forEachInOrder: opaque, then the buckets from the farthest, each newest first), MeshSubmitter (the GS state followed in submission order into each batch's material, clipMeshTriangles: cut to the clip volume, |x| |y| |z| <= w, and to w > 1e-3, colour / UV / fog along the cuts; FOGCOL by a port callback, an Observer for a port's checks, MeshLiveToggles: nodepth, nofog, noclip, flat, opaque, noatest, notex, noguard, dump from a file of words), meshBlend. - runtime/native/native_texture_pack.h (ps2x::native::packs): TexturePack, the PS2XTEX1 loader (per file its records in order: PSM, size, texels unpacked), file / nth lookup, ct16ToRgba and recordColour (TEXA alpha for CT24 / CT16 as the GS), csm1Palette (an indexed texture's palette from the port's CLUT lookup, CSA for T4), decodeRecord (the RGBA image a TEX0 shows). Tools: tools/native_pack (mesh.py: MeshPackWriter, MeshFile, MeshObject, Strip, read_pack; texture.py: PSM constants, unpack_texels, record, TexturePackWriter, read_pack; ps2.py: vif_codes, unpack_size, dma_chain / chain_stream / image_offset for a DMA chain in an image linked at a fixed address, find_gs_register_blocks, elf_bytes). Docs: docs/native_packs.md: the formats, what a port implements (converter, file binding hook, per-object hook and its EE state, the game's order, texture keys), TMB as the worked example, a game whose models sit in an archive. The code is TMB's, moved without a change in behaviour: TMB (TMB_Recomp, packs branch) now uses these, with packs whose contents equal its old ones field for field and the same checks and pictures (numbers in its commit). Co-Authored-By: Claude Opus 5.5 <[email protected]>