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 members | 7,283 (162 loose, 7,121 in WADs) |
WAD members starting with SHPI but not named .fsh, or the reverse | 0 |
Header id G231, one image | 7,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 present | 6,649 (634 without) |
Other attached records (0x6F comment, etc.) | 0 |
| Image sizes | 26 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.
Header (16 bytes):
SHPI, u32 total size (equal to the file length in all 7,283), u32 image count, four-character directory id (G231).Directory: per image a four-character tag and a u32 offset. In 7,101 files the tag is the first four characters of the file name (ignoring case); in the other 182 it is not. In all 7,283 the 88 bytes between the directory and the image hold
Buy ERTSfollowed by zeros, and the image starts at offset 112. The reader accepts any gap and does not interpret it.Image record (16-byte header): code byte, 24-bit offset from this record to the next attached record (0 = last), u16 width, u16 height and four u16 words (EA's centre and position fields). The four words are 0 in all 7,283 images.
Pixels: width × height palette indices, row-major from the top row (the decoded images are upright; see Evidence). Raw
0x7Bblocks are exactly width × height bytes; all 547 have a pixel count that is a multiple of 16.Compression (
0xFB): RefPack with the 5-byte header10 FB+ 24-bit big-endian decoded size (the only header form in the corpus). The decoded size is the pixel count rounded up to a multiple of 16: for the 135 images whose pixel count is not a multiple of 16 (sizes 22×22, 26×26, 30×30, 38×38 and 250×250) it is 12 bytes more than width × height. The rows are not padded (the extra bytes are fewer than one row); only the end is. The compressed block is followed by up to 15 alignment bytes before the next record; these are not always zero (36 of the 162 loose files) and are ignored.Palette record: directly after the image, code
0x24,0x2Aor0x2D, then u16 entry count, u16 height (1) and four more words (in the 162 loose files checked: the entry count again, then zeros). Entries follow, then alignment bytes up to the next record.0x24: 3 bytes per entry, R, G, B.0x2A: 4 bytes per entry, B, G, R, A.0x2D: u16 per entry, read as A1 R5 G5 B5 (see Approximations). No pixel uses an index beyond the palette's entry count.
Name record
0x70: a NUL-terminated name. In the loose files it follows the palette and is the last record (next offset 0), bounded by the end of the file. The reader accepts the palette and name in either order.
Evidence for colour order and alpha#
Thumbnails. 70 loose TPI textures ship next to a small TGA of the same name (8×8 or 16×16 pixels). The asset test decodes the TGA with StbImageSharp, box-filters the decoded FSH to its size and compares (mean absolute error per channel, 0–255):
Palette / TGA Images R G B A R/B swapped 0x2A/ 32-bit23 1.7 1.9 1.1 1.2 100.7 0x24/ 24-bit43 7.5 10.0 7.7 – 92.0 0x24/ 32-bit4 8.1 8.1 8.1 255 8.1 This fixes the byte order of both common palettes and shows that the
0x2Aalpha byte is the texture's alpha. The four0x24images with 32-bit thumbnails are two badge textures, each shipped twice; their TGA alpha is 0 everywhere (see the retired COMPAT-014 note below).Duplicate textures. Many objects ship a texture twice, in
stexture/andtextures/, often at different sizes and with different palette codes. For the 12 such pairs whose0x2Acopy is mostly opaque (mean alpha ≥ 200), the mean colours of the0x24and0x2Acopies differ by less than 2 per channel, and swapping red and blue in one copy is worse in all 12 (by more than 5 levels in 11; the twelfth is nearly grey).0x2D. The only file decodes to a mean colour of (134, 197, 221), next to (134, 194, 217) and (107, 188, 216) foricewall3andicewall2(0x24) in the same archive. All 256 entries have bit 15 set.Visual check. A few loose textures (award ribbon, Mutant eye, tiara, bear badge, golden ticket with the "theme PARK Inc." logo, snow, flower, TP logo) were viewed after decoding: upright, readable and with plausible colours. This is a check of the decoder, not of how the game shows them.
Approximations#
APPROX:COMPAT-014retired:0x24palettes store no alpha and decode fully opaque (4,308 images), with no colour key or transparent index. The Theme Park Inc executable's palette converter (Game.exe0x6B7000) reads three bytes R, G, B per0x24entry and stores alpha0xFF(0x6B7211); its alpha scan (0x6B73A0) returns 0 for such a palette, a surface without an alpha mask, and the pixel loops (0x6B76BDon) copy the table entry of every index without a transparent index. The four 32-bit thumbnails above (alpha 0) and the opaque0x24copy of a texture whose0x2Acopy is fully transparent (e.g.fruitb.wadgrape.fsh) are data the loader does not look at.[EXT:fsh-0x2d-palette](formerlyAPPROX:COMPAT-015, retired) The single0x2Dpalette (watersnowtrac.wadicewall1.fsh) is read as A1R5G5B5 with bit 15 meaning opaque: OpenTPW's own choice, as there is no original reading to match. The colour order is supported only by the mean-colour match above; the alpha bit has no effect on this file. The Theme Park Inc executable's palette converter (Game.exe0x6B7000) handles only the codes0x24and0x2A(cmpat0x6B70FBand0x6B7108) and returns at0x6B72D6for any other code (0x22included) with its 256-entry table unwritten. That table is a stack buffer of the fill routine0x6B75D0(sub esp, 0x404at0x6B75D8) that nothing before the converter writes, so the pixel loops copy whatever it held: the original's colours for this file are undefined, and there is no reading of a0x2Dpalette to match. Its alpha scan0x6B73A0(the live one, through0x40A11E, called by0x6C0AA8and0x7B1748; the copy0x6B73F0is unreferenced) reads the first entry as a u32,0xAB1D90CD, whose top byte is below0xF0, so it marksicewall1as an alpha texture. The loader always takes the palette as the first record after the image (0x6B7684), which holds for every file in the corpus. A0x2Apalette whose alphas are all0xF0or more is classed as opaque by that scan; OpenTPW keeps its alpha values.
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):
| Fixture | Palette | Size | Code | File SHA-256 | RGBA SHA-256 |
|---|---|---|---|---|---|
generic/shadow/alphkid.fsh | 0x2A | 64×64 | 0xFB | 3d9aa0ad6957cc5558066418de7bdd8061fa77ce7d1588aa3fb1400996822122 | d9adb81b8d57c9a4f34c4ea0592e6f47b04e9eae4736a6eabacccddfbe907bd9 |
levels/water/rides/snowtrac.wad stexture/icewall1.fsh | 0x2D | 32×32 | 0xFB | 1a3ecb2f79537ad8d23091fa049e64d98c40ea8aff746ef258a48359f02f6dd0 | aefb6b56c12487f023746a8b057edda235ac5ce59189af41c50bea2b8eb57b4e |
ui.wad stexture/tb_camera.fsh (padded) | 0x2A | 38×38 | 0xFB | 1bad3bed574e7f823d0166e70a17d89f6c9f11a51b819f3b4395734bf302957d | 75d874e1d3fc656e115c7626e796ac8b94a948963f5d4244be277434f5c3d9e7 |
levels/arabian/Sharetex.wad an_g07.fsh | 0x24 | 128×128 | 0x7B | 6246087bd4c5803d728d5b2c1dbe4b13a8d5d6e84862a7d3effd5ea9cfc1a057 | 35175b6940013fd3c99f1494e5741d1f839c6d7735f0637a99919fc4ca409baa |
global/Advisor/textures/Mutant_Eye.fsh | 0x24 | 64×64 | 0xFB | 3ee747db7a0f9bb0a80a2c3ffd3ac0591782e884b8511c07c202c6222b0eb91c | 1f0bd89426b4cf12b72316f1b1c3967821355c70d6e4ecb806219111dfaf3b1a |
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#
How TPI uses or draws these textures: filtering, mipmaps, blending, alpha test, or what a colour key on the uploaded surface does (the loader sets none: COMPAT-014 retired).
The meaning of the directory gap (
Buy ERTS), the four position words and the repeated palette entry count; the reader keeps them raw or ignores them.Which of the
stexture/andtextures/copies Theme Park Inc loads, and when (Theme Park World loadsstextureandsshareteexactly with the Low detail preset, TEXTUREQUALITY 0 or 1: docs/OBJECTS.md).FSH variants outside this corpus (other EA image codes, multi-image banks, other RefPack headers) are rejected, not supported.
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#
Format facts are from the corpus above. The record layout and palette code names agree with the EA Graphics Manager implementation cited in TPI-COMPARISON.md (bartlomiejduda/EA-Graphics-Manager at
dce358bc1d34102ea2c72b74210b6ca627a46cc4,dir_entry.pyandpalette_entry.py); no code from it was copied or run.RefPack command set: the existing
TreCompression.Refpack(docs/AUTORUN.md).No original executable was run or inspected for this work, and the third-party no-CD patches on the TPI CD were not used.
Source: docs/FSH.md in the project repository.