Library for decoding and parsing assets from Sierra On-line's SCI-engine.
Full documentation for the library can be found here.
Type | Extract | Parse/Render | Write |
---|---|---|---|
View | ✅ | ✅ | ❌ |
Pic | ✅ | ✅ | ❌ |
Script | ✅ | ❌ | ❌ |
Text | ✅ | ✅ | ❌ |
Sound | ✅ | ❌ | ❌ |
Memory | ✅ | ❌ | ❌ |
Vocab | ✅ | ❌ | ❌ |
Font | ✅ | ✅ | ❌ |
Cursor | ✅ | ✅ | ❌ |
Patch | ✅ | ❌ | ❌ |
import { readFile } from 'fs/promises';
import { parseAllMappings } from '@4bitlabs/sci0';
const resourceMap = await readFile('path/to/RESOURCE.MAP');
const [mapping] = parseAllMappings(resourceMap);
import { Resource } from '@4bitlabs/sci0';
// finding by type
const firstPic = mapping.find((it) => Resource.getTypeStr(it.id) === 'Pic');
// ...or by specific resource number.
const num11 = mapping.find((it) => Resource.getNumber(it.id) === 11);
import { parseHeaderWithPayload, decompress } from '@4bitlabs/sci0';
// Get the resource file that contains this asset, and its offset where the header starts.
const { file, offset } = mapping.find(
(it) => getResourceTypeStr(it.id) === 'Pic',
);
const resource = await readFile(
`path/to/RESOURCE.${file.toString().padStart(3, '0')}}`,
);
// Parse the asset header and payload
const [header, compressed] = parseHeaderWithPayload(resource, offset);
// Decompress the asset data
const data = decompress('sci0', header.compression, compressed);
Example:
todo