OpenTPW

FSH (EA SHPI) textures: Theme Park Inc reader#

October 10, 2026. Status: FshFile decodes every .fsh file and WAD member of the Theme Park Inc (TPI) retail data to RGBA on the CPU. Nothing in OpenTPW loads these textures yet; TPI is not playable. No visual comparison with the original game was made. No asset is included in the repository.

This is step 1 toward offering TPI in the launcher. Theme Park World does not use .fsh; it stores textures as .wct (see THEME-PARK-INC.md).

Corpus#

The TPI Data folder from the Dutch/Benelux retail CD (InstallShield cabinets extracted with unshield; see THEME-PARK-INC.md), read in place. Every member of all 303 WADs was enumerated with OpenTPW's own WadArchive.

Count
.fsh files and members7,283 (162 loose, 7,121 in WADs)
WAD members starting with SHPI but not named .fsh, or the reverse0
Header id G231, one image7,283
Image code 0x7B (raw 8-bit indices)547
Image code 0xFB (0x7B + 0x80: RefPack-compressed indices)6,736
Palette 0x24 (24-bit)4,308, all with 256 entries
Palette 0x2A (32-bit with alpha)2,974 (414 with 256 entries, 2,560 with fewer)
Palette 0x2D (16-bit)1: water snowtrac.wad stexture/icewall1.fsh
Name record 0x70 present6,649 (634 without)
Other attached records (0x6F comment, etc.)0
Image sizes26 distinct; 32×32 (3,001), 128×128 (2,009) and 64×64 (1,840) are most common; the largest are 384×344 and 250×250

The older note in THEME-PARK-INC.md that all files have "record code 0x7B" is true only after masking off the compression flag (format byte 251 = 0xFB in TPI-COMPARISON.md).

Layout established from the corpus#

All values are little-endian unless stated otherwise.

Evidence for colour order and alpha#

Approximations#

Reader#

FshFile (source/OpenTPW.Files/Public/FshFile.cs) follows the other bounded readers: input capped at 16 MiB and read through non-seekable or short-read streams without closing them; at most 256 images, 4096 × 4096 per image and 16,777,216 pixels in total, all checked before any pixel allocation. Every record is bounded by its next-record offset, the next image or the end of the file. The RefPack body is decoded by the existing strict TreCompression.Refpack, which rejects truncated commands, back-references before the start and output beyond the declared size. Size mismatches, out-of-range offsets and indices, a missing, duplicate or truncated palette, an unterminated name and duplicate directory offsets throw InvalidDataException. Image codes other than 0x7B/0xFB, palette codes other than 0x24/0x2A/0x2D, other attached records (including 0x6F) and other RefPack header flags throw NotSupportedException. The reader supports several images per file, although the corpus only has one.

FshImage exposes the tag, size, raw position words, compression flag, palette code and entry count, the indices, the palette as RGBA, the name and the decoded RGBA pixels.

Inspection (no game path needed):

dotnet source/OpenTPW/bin/Debug/net11.0/OpenTPW.dll --inspect-fsh '/path/to/TPI/Data/levels/water/rides/snowtrac.wad!stexture/icewall1.fsh'

A plain path reads a loose file; archive.wad!member/path reads a WAD member (case-insensitive). It prints the header, each image's size, codes and palette, and the SHA-256 of the decoded RGBA.

Tests#

FshFileTests builds files in the test: raw and compressed images, all three palette codes, padded RefPack sizes with non-zero trailing bytes, back-references, several images, short non-seekable reads, and rejection of bad magic, size and count, directory and next-record offsets, truncated pixel, palette and name records, oversize input, dimensions and aggregate pixels, unsupported image, palette and attached record codes, duplicate records, palette index overflow and bad RefPack streams.

The asset tests need OPENTPW_TPI_PATH set to a TPI installation or its Data folder, read in place. Without it they are inconclusive (not passes). They check the corpus counts above, the thumbnail and duplicate-texture comparisons, and five fixtures pinned by file and decoded-RGBA SHA-256 (hashes only):

FixturePaletteSizeCodeFile SHA-256RGBA SHA-256
generic/shadow/alphkid.fsh0x2A64×640xFB3d9aa0ad6957cc5558066418de7bdd8061fa77ce7d1588aa3fb1400996822122d9adb81b8d57c9a4f34c4ea0592e6f47b04e9eae4736a6eabacccddfbe907bd9
levels/water/rides/snowtrac.wad stexture/icewall1.fsh0x2D32×320xFB1a3ecb2f79537ad8d23091fa049e64d98c40ea8aff746ef258a48359f02f6dd0aefb6b56c12487f023746a8b057edda235ac5ce59189af41c50bea2b8eb57b4e
ui.wad stexture/tb_camera.fsh (padded)0x2A38×380xFB1bad3bed574e7f823d0166e70a17d89f6c9f11a51b819f3b4395734bf302957d75d874e1d3fc656e115c7626e796ac8b94a948963f5d4244be277434f5c3d9e7
levels/arabian/Sharetex.wad an_g07.fsh0x24128×1280x7B6246087bd4c5803d728d5b2c1dbe4b13a8d5d6e84862a7d3effd5ea9cfc1a05735175b6940013fd3c99f1494e5741d1f839c6d7735f0637a99919fc4ca409baa
global/Advisor/textures/Mutant_Eye.fsh0x2464×640xFB3ee747db7a0f9bb0a80a2c3ffd3ac0591782e884b8511c07c202c6222b0eb91c1f0bd89426b4cf12b72316f1b1c3967821355c70d6e4ecb806219111dfaf3b1a

The alphkid and Mutant_Eye RGBA hashes were also produced by a separate throwaway Python decoder written for this check.

Exporting one decoded image#

The CPU-only command exports an explicitly selected image from a local FSH file:

dotnet run --project source/OpenTPW/OpenTPW.csproj -c Release -- --export-fsh-png texture.fsh 0 selected.png

The image index is zero-based directory order (--inspect-fsh lists that order). An index is always required: multi-image files do not silently select image zero. This route runs before game-folder, window and profile setup, and needs no game installation or graphics device. It uses FshFile's existing bounded decoder and PngImage to preserve the selected image's current RGBA pixels and dimensions; the raw/RefPack and palette rules, including the retired COMPAT-014 and the extension [EXT:fsh-0x2d-palette] (COMPAT-015), are unchanged. The existing reader still validates and decodes the complete bounded FSH file; the selected index controls which image is written, not which records are parsed.

The input is read-only. The output must be a new .png file; existing files are never overwritten. Decode, index validation and encoding finish before output directories or temporary files are created. A complete sibling temporary file is flushed and moved without overwrite, so a file appearing at the destination also refuses replacement. Failure cleanup deletes only that owned temporary path. Directory creation can remain after a later I/O refusal. This is ordinary local I/O integrity, not a power-loss, disk-full or concurrent-permission-change guarantee. Local-file export only: no archive extraction, batch conversion, upscaler, texture-pack enumeration or renderer behavior is added.

Synthetic tests run the actual CLI and decoder-to-PNG-to-STB path, including both images, raw/RefPack storage, all three supported palettes, and BGRA alpha values. Invalid index, malformed/truncated or oversized input and existing/blocked output controls preserve source/output/foreign files. These prove current decoded pixels, not original-game alpha, filtering, appearance, or large-image performance.

Independent controls additionally run every truncated synthetic input prefix and assert that the actual CLI leaves game filesystems, renderer, shader flags and an existing profile record untouched. A Darwin-only FIFO probe held the real desktop CLI after its destination precheck, created a foreign destination, then fed a valid synthetic FSH: the final move refused, the foreign bytes remained, the owned temporary file disappeared, and no profile directory was created. This is host-specific race evidence, not Windows or power-loss qualification.

Not verified#

Use in the game#

Since October 11, 2026 the experimental Theme Park Inc level viewer loads these textures: Texture decodes .fsh files and WAD members through FshFile (first image) and uploads the RGBA pixels through the normal texture path, and terrain, object and path textures are found by name without extension, so MD2 texture names resolve to .fsh (or .tga) members. See THEME-PARK-INC.md. The extended TPWS save header and the new Standard.sam keys remain follow-up work.

Sources#

Source: docs/FSH.md in the project repository.