TypeScript library for parsing and manipulating Dark Ages (DOOMVAS v1) game client files.
Translated from eriscorp/dalib, the original C# implementation, under the MIT license.
npm install @eriscorp/dalib-ts| Format | Class(es) | Description |
|---|---|---|
.dat |
DataArchive, DataArchiveEntry |
Game data archives |
.map |
MapFile |
Map layout files |
.meta |
MetaFile, MetaFileEntry |
Metadata files |
.hpf |
HpfFile |
Tile graphics |
.spf |
SpfFile, SpfFrame |
Sprite frames |
.epf |
EpfFile, EpfFrame |
Entity / mob sprites |
.mpf |
MpfFile, MpfFrame |
Map sprites |
.efa |
EfaFile, EfaFrame |
Effect animations |
.fnt / .hea |
FntFile, HeaFile |
Bitmap fonts |
.tbl |
PaletteTable, ColorTable, TileAnimationTable, EffectTable |
Lookup tables |
.control |
ControlFile, Control |
UI layout files |
import { DataArchive } from '@eriscorp/dalib-ts';
const archive = DataArchive.fromFile('path/to/archive.dat');
// List all .spf entries
const sprites = archive.getEntriesByExtension('.spf');
// Get a specific entry's raw bytes
const entry = archive.get('sprite001.spf');
if (entry) {
const buffer = archive.getEntryBuffer(entry);
}import { DataArchive } from '@eriscorp/dalib-ts';
const response = await fetch('archive.dat');
const buffer = await response.arrayBuffer();
const archive = DataArchive.fromBuffer(buffer);import { DataArchive, SpfFile, Palette } from '@eriscorp/dalib-ts';
const archive = DataArchive.fromFile('seo.dat');
const spfEntry = archive.get('sprite001.spf')!;
const palEntry = archive.get('sprite001.pal')!;
const spf = SpfFile.fromBuffer(archive.getEntryBuffer(spfEntry));
const palette = Palette.fromBuffer(archive.getEntryBuffer(palEntry));import { renderSpfPalettized } from '@eriscorp/dalib-ts';
const frame = spf.frames[0];
const rgbaFrame = renderSpfPalettized(frame, palette);
// rgbaFrame.data is a Uint8ClampedArray — pass directly to ImageData
const imageData = new ImageData(rgbaFrame.data, rgbaFrame.width, rgbaFrame.height);
ctx.putImageData(imageData, 0, 0);SpanReader— low-level binary reader (LE/BE integers, fixed-length ASCII, byte spans)SpanWriter— low-level binary writercompressHpf/decompressHpf— HPF tile compression
crc16(data)— CRC-16 checksumcrc32(data)— CRC-32 checksum
decodeRgb555/encodeRgb555— RGB555 color codecdecodeRgb565/encodeRgb565— RGB565 color codecquantizeFrames— palette quantization for image exportcropTransparentPixels— trim transparent borders from frames
For large archives, avoid decoding everything upfront:
SpfView,EpfView,MpfView,EfaView,TilesetView
These decode individual frames on demand rather than parsing the entire file.