예제 #1
0
const HunkPalette::EntryHeader HunkPalette::getEntryHeader() const {
    const byte *const data = getPalPointer();

    EntryHeader header;
    header.startColor = data[10];
    header.numColors = READ_SCI11ENDIAN_UINT16(data + 14);
    header.used = data[16];
    header.sharedUsed = data[17];
    header.version = READ_SCI11ENDIAN_UINT32(data + kEntryVersionOffset);

    return header;
}
예제 #2
0
void HunkPalette::setVersion(const uint32 version) const {
    if (_numPalettes != _data[10]) {
        error("Invalid HunkPalette");
    }

    if (_numPalettes) {
        const EntryHeader header = getEntryHeader();
        if (header.version != _version) {
            error("Invalid HunkPalette");
        }

        WRITE_SCI11ENDIAN_UINT32(getPalPointer() + kEntryVersionOffset, version);
        _version = version;
    }
}
예제 #3
0
void HunkPalette::setVersion(const uint32 version) const {
	if (_numPalettes != _data.getUint8At(kNumPaletteEntriesOffset)) {
		error("Invalid HunkPalette");
	}

	if (_numPalettes) {
		const EntryHeader header = getEntryHeader();
		if (header.version != _version) {
			error("Invalid HunkPalette");
		}

		byte *palette = const_cast<byte *>(getPalPointer().getUnsafeDataAt(kEntryVersionOffset, sizeof(uint32)));
		WRITE_SCI11ENDIAN_UINT32(palette, version);
		_version = version;
	}
}
예제 #4
0
const Palette HunkPalette::toPalette() const {
	Palette outPalette;

	for (int16 i = 0; i < ARRAYSIZE(outPalette.colors); ++i) {
		outPalette.colors[i].used = false;
		outPalette.colors[i].r = 0;
		outPalette.colors[i].g = 0;
		outPalette.colors[i].b = 0;
	}

	if (_numPalettes) {
		const EntryHeader header = getEntryHeader();
		const uint32 dataSize = header.numColors * (/* RGB */ 3 + (header.sharedUsed ? 0 : 1));
		const byte *data = getPalPointer().getUnsafeDataAt(kEntryHeaderSize, dataSize);

		const int16 end = header.startColor + header.numColors;
		assert(end <= 256);

		if (header.sharedUsed) {
			for (int16 i = header.startColor; i < end; ++i) {
				outPalette.colors[i].used = header.used;
				outPalette.colors[i].r = *data++;
				outPalette.colors[i].g = *data++;
				outPalette.colors[i].b = *data++;
			}
		} else {
			for (int16 i = header.startColor; i < end; ++i) {
				outPalette.colors[i].used = *data++;
				outPalette.colors[i].r = *data++;
				outPalette.colors[i].g = *data++;
				outPalette.colors[i].b = *data++;
			}
		}
	}

	return outPalette;
}