5.0.1 • Published 11 months ago

@4bitlabs/sci0 v5.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

@4bitlabs/sci0 License NPM Version NPM Downloads

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

Supported SCI0 resource types

TypeExtractParse/RenderWrite
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 { getResourceNumber, getResourceTypeStr } from '@4bitlabs/sci0';

// finding by type
const firstPic = mapping.find((it) => getResourceTypeStr(it.id) === 'Pic');

// ...or by specific resource number.
const num11 = mapping.find((it) => getResourceNumber(it.id) === 11);

Getting the actual data

import { parseHeaderFrom, 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
const header = parseHeaderFrom(resFile.subarray(offset, offset + 8));
// Determine the payload length
const payloadLength = getPayloadLength(header);
// Snip out the bytes from the payload.
const compressed = resFile.subarray(offset + 8, start + payloadLength);
// Decompress the asset data
const data = decompress('sci0', header.compression, compressed);

VIEW Resource

Example:

todo

PIC Resource

Example:

import { renderPic } from '@4bitlabs/sci0';
import { RAW_CGA, generateSciDitherPairs, CGA_PAIRS } from '@4bitlabs/color';
import { createDitherFilter, renderPixelData } from '@4bitlabs/image';

const picData = Pic.parseFrom(data);
const { visible, priority, control } = renderPic(picData);
const image = renderPixelData(visible, {
  dither: createDitherFilter(CGA_PAIRS),
});
5.0.1

11 months ago

5.0.0

11 months ago

2.7.0

1 year ago

2.6.0

1 year ago

3.1.3

12 months ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

4.0.1

12 months ago

4.0.0

12 months ago

2.5.1

1 year ago

2.5.0

1 year ago

2.4.5

1 year ago

2.4.6

1 year ago

2.4.4

1 year ago

2.4.1

1 year ago

2.4.3

1 year ago

2.4.2

1 year ago

2.3.0

1 year ago

2.2.0

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago