archive/vswap (Wolfenstein 3D pages: walls, sprites and sounds through a palette passed in) and vector/gamemaps (GAMEMAPS + MAPHEAD, Carmack + RLEW, into a TileMap); test data from the fixture's own writers

This commit is contained in:
4DBug committed 2026-11-01 18:50:33 -06:00
1 parent 719abb97c0
commit e51fd3585e
15 files changed
+3139 -1085

No files matched your search

+18 -1
View File
@@ -254,6 +254,22 @@ local named = assert(F.archive.load(mpqBytes, { names = { "war3map.w3e" } }))
assert(#named:list() >= 2)
```
Wolfenstein 3D's page file (`VSWAP.WL6`, also `.WL1`, Spear of Destiny's `.SOD` / `.SDM`) loads as an Archive of
its pages (`walls/000`, `sprites/000`, `sounds/000`, `soundinfo`). The format module turns walls and sprites into
64 x 64 Images and the digitized sounds into Audio. The game's palette is not part of the file (nor redistributable):
pass its 768 bytes as `palette` (6-bit VGA values are scaled up); without it the images are grey.
```luau
local Vswap = F.format("vswap")
local pages = assert(F.archive.load(vswapBytes, { name = "VSWAP.WL6" }))
assert(pages:list()[1].name == "walls/000")
local wall = assert(Vswap.image(pages, "wall", 0, { palette = wolfPaletteBytes }))
local guard = assert(Vswap.image(pages, "sprite", 0, { palette = wolfPaletteBytes })) -- alpha 0 = hole
assert(wall.width == 64 and guard.height == 64)
local sound = assert(Vswap.sound(pages, 1)) -- u8 PCM at 7042 Hz, as f32 Audio
assert(sound.sampleRate == 7042 and Vswap.sounds(pages) == 2)
```
## Unix, package and disc archives
### cpio
@@ -431,7 +447,8 @@ assert(F.archive.load(out):list()[1].method == "store")
| bzip2 (`.bz2`, `.tbz2`) | yes | - | single stream |
| Brotli (`.br`) | yes | - | single stream; no magic number, so pass a `.br` name or `format = "br"` |
| PAK (`.pak`) | yes | yes | Quake / Quake II / Half-Life (and SiN `SPAK`) |
| WAD (`.wad`) | yes | yes | IWAD / PWAD; lumps, graphics, wall textures and maps through `F.format("wad")` |
| WAD (`.wad`) | yes | yes | IWAD / PWAD; lumps, graphics, wall textures and maps (binary and UDMF) through `F.format("wad")` |
| VSWAP (Wolfenstein 3D `.wl6` / `.wl1` / `.sod` / `.sdm`) | yes | | pages; walls, sprites and sounds through `F.format("vswap")` |
| GRP (`.grp`) | yes | yes | Build engine |
| VPK (`.vpk`) | yes | yes | versions 1 / 2, multi-part reading, preload bytes; writes one directory file |
| MPQ (`.mpq`, `.w3x`, `.sc2map`, ...) | yes | - | versions 1-4 (classic tables), encryption; no Huffman / ADPCM (WAVE) sectors |
+20 -1
View File
@@ -194,14 +194,33 @@ local back = assert(F.load(tmx))
assert(back.layers[1].data[6] == 0x80000009)
```
## Wolfenstein 3D maps
Wolfenstein 3D / Spear of Destiny maps are two files: `GAMEMAPS.WL6` (the Carmack + RLEW compressed planes) and
`MAPHEAD.WL6` (the RLEW tag and where each map starts). Load either one: the other comes through `files` /
`resolve` (loading a path finds it next to the file) or `mapHead` / `gameMaps`. A map loads as a TileMap with one
tile layer per plane (`walls`, `objects`, `plane3`) holding the raw tile values (1..63 walls, 90..101 doors, 106+
floor areas; things in `objects`), without a tileset; `map` picks the slot (default: the first present) and
`F.format("gamemaps").maps` lists them.
```luau
local files = { ["MAPHEAD.WL6"] = mapheadBytes }
local level = assert(F.load(gamemapsBytes, { name = "GAMEMAPS.WL6", files = files }))
assert(level.kind == "tilemap" and level.width == 16 and level.properties.name == "Tiny map")
assert(level.layers[1].name == "walls" and level.layers[1].data[1] == 1) -- the border wall
local maps = assert(F.format("gamemaps").maps(F.Bytes.reader(mapheadBytes), { gameMaps = gamemapsBytes }))
assert(#maps == 1 and maps[1].slot == 1)
```
## Formats
| Format | Read | Write | Notes |
|---|---|---|---|
| TMX / TSX | yes | yes | CSV, base64 (raw, zlib, gzip) and `<tile>` data; zstd data returns `UNSUPPORTED` |
| TMJ / TSJ | yes | yes | |
| Wolfenstein 3D GAMEMAPS + MAPHEAD | yes | | the `gamemaps` format: raw tile values, no tileset |
Both are the `tiled` format in [FORMATS.md](../FORMATS.md). Wang sets and terrains are dropped.
TMX and TMJ are the `tiled` format in [FORMATS.md](../FORMATS.md). Wang sets and terrains are dropped.
## Gotchas