@4bitlabs/sci0
TypeScript icon, indicating that this package has built-in type declarations

5.0.1 • Public • Published

@4bitlabs/sci0 License NPM Version NPM Downloads

Library for decoding and parsing assets from Sierra On-line's SCI-engine.

Documentation

Full documentation for the library can be found here.

Supported SCI0 resource types

Type Extract Parse/Render Write
View
Pic
Script
Text
Sound
Memory
Vocab
Font
Cursor
Patch

Parse RESOURCE.MAP file

import { readFile } from 'fs/promises';
import { parseAllMappings } from '@4bitlabs/sci0';

const resourceMap = await readFile('path/to/RESOURCE.MAP');
const [mapping] = parseAllMappings(resourceMap);

Working ResourceMap Entires

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);

Getting the actual data

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);

VIEW Resource

Example:

todo

Readme

Keywords

none

Package Sidebar

Install

npm i @4bitlabs/sci0

Weekly Downloads

8

Version

5.0.1

License

ISC

Unpacked Size

87.5 kB

Total Files

131

Last publish

Collaborators

  • 32bitkid