示例#1
0
void XEOSITEX::readHeader(Common::SeekableReadStream &xeositex) {
	const uint32 magic1 = xeositex.readUint32BE();
	const uint32 magic2 = xeositex.readUint32BE();
	if ((magic1 != kXEOSID) || (magic2 != kITEXID))
		throw Common::Exception("Not a valid XEOSITEX (%s, %s)",
				Common::debugTag(magic1).c_str(), Common::debugTag(magic2).c_str());

	const uint32 version = xeositex.readUint32LE();
	if (version != 0)
		throw Common::Exception("Invalid XEOSITEX version %u", version);

	const uint32 pixelFormat = xeositex.readUint32LE();
	if ((pixelFormat != 3) && (pixelFormat != 4))
		throw Common::Exception("Invalid XEOSITEX pixel format %u", pixelFormat);

	if        (pixelFormat == 3) {
	_format    = kPixelFormatBGR;
	_formatRaw = kPixelFormatRGB8;
	_dataType  = kPixelDataType8;
	} else if (pixelFormat == 4) {
	_format    = kPixelFormatBGRA;
	_formatRaw = kPixelFormatRGBA8;
	_dataType  = kPixelDataType8;
	}

	_wrapX = xeositex.readByte() != 0;
	_wrapY = xeositex.readByte() != 0;
	_flipX = xeositex.readByte() != 0;
	_flipY = xeositex.readByte() != 0;

	_coordTransform = xeositex.readByte();

	const uint32 mipMaps = xeositex.readUint32LE();
	_mipMaps.resize(mipMaps, 0);
}
示例#2
0
void GameModule::loadActions(Common::SeekableReadStream &s) {
	debug(0, "GameModule::loadActions()");

	s.seek(0x180);
	_actionsCount = s.readUint32LE();
	uint32 offs = s.readUint32LE();
	_actions = new Action[_actionsCount];
	for (int i = 0; i < _actionsCount; ++i) {
		s.seek(offs + i * 72);
		debug(0, "Action(%d) offs: %08X", i, offs + i * 72);
		_actions[i].conditions = readConditions(s);
		for (int j = 0; j < 8; ++j) {
			_actions[i].results.actionResults[j].kind = s.readByte();
			_actions[i].results.actionResults[j].value1 = s.readByte();
			_actions[i].results.actionResults[j].value2 = s.readUint16LE();
		}
		const int actionListCount = s.readUint32LE();
		const uint32 actionListOffs = s.readUint32LE();
		s.seek(actionListOffs);
		for (int j = 0; j < actionListCount; ++j) {
			ActionCommand actionCommand;
			actionCommand.cmd = s.readUint16LE();
			actionCommand.sceneObjectIndex = s.readUint16LE();
			actionCommand.timeStamp = s.readUint32LE();
			actionCommand.walkDest = readPoint(s);
			actionCommand.param = s.readUint32LE();
			_actions[i].actionCommands.push_back(actionCommand);
		}
	}
}
示例#3
0
void Font::setFontMads(const char *filename) {
	MadsPack fontData(filename, _vm);
	Common::SeekableReadStream *fontFile = fontData.getItemStream(0);

	_maxHeight = fontFile->readByte();
	_maxWidth = fontFile->readByte();

	_charWidths = new uint8[128];
	// Char data is shifted by 1
	_charWidths[0] = 0;
	fontFile->read(_charWidths + 1, 127);
	fontFile->readByte();	// remainder

	_charOffs = new uint16[128];

	uint32 startOffs = 2 + 128 + 256;
	uint32 fontSize = fontFile->size() - startOffs;

	// Char data is shifted by 1
	_charOffs[0] = 0;
	for (int i = 1; i < 128; i++)
		_charOffs[i] = fontFile->readUint16LE() - startOffs;
	fontFile->readUint16LE();	// remainder

	_charData = new uint8[fontSize];
	fontFile->read(_charData, fontSize);

	delete fontFile;
}
示例#4
0
文件: resource.cpp 项目: klusark/twin
void Resource::loadGridDefaults() {
	Common::SeekableReadStream *stream = _bkg->createReadStreamForIndex(0);
	_firstGrid = stream->readUint16LE();
	_firstGridFragment = stream->readUint16LE();
	_firstLibrary = stream->readUint16LE();
	_firstBlock = stream->readUint16LE();
	_numBlocks = stream->readUint16LE();
	_numScenes = 0;
	delete stream;
	stream = _bkg->createReadStreamForIndex(_firstBlock + _numBlocks);
	for (;;) {
		byte opcode = stream->readByte();
		byte id = stream->readByte();
		if (opcode == 0) {
			break;
		} else if (opcode == 1) {
			_scenes[_numScenes]._isIsland = false;
		} else if (opcode == 2) {
			_scenes[_numScenes]._isIsland = true;
		}
		_scenes[_numScenes]._id = id;
		++_numScenes;
	}
	delete stream;
}
示例#5
0
Common::String MohawkEngine_Riven::getName(uint16 nameResource, uint16 nameID) {
	Common::SeekableReadStream* nameStream = getResource(ID_NAME, nameResource);
	uint16 fieldCount = nameStream->readUint16BE();
	uint16* stringOffsets = new uint16[fieldCount];
	Common::String name;
	char c;

	if (nameID < fieldCount) {
		for (uint16 i = 0; i < fieldCount; i++)
			stringOffsets[i] = nameStream->readUint16BE();
		for (uint16 i = 0; i < fieldCount; i++)
			nameStream->readUint16BE();	// Skip unknown values

		nameStream->seek(stringOffsets[nameID], SEEK_CUR);
		c = (char)nameStream->readByte();

		while (c) {
			name += c;
			c = (char)nameStream->readByte();
		}
	}

	delete nameStream;
	delete[] stringOffsets;
	return name;
}
示例#6
0
文件: tga.cpp 项目: AReim1982/scummvm
bool TGADecoder::readColorMap(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth) {
	_colorMap = new byte[3 * _colorMapLength];
	for (int i = 0; i < _colorMapLength * 3; i += 3) {
		byte r, g, b;
		if (_colorMapEntryLength == 32) {
			byte a;
			Graphics::PixelFormat format(4, 8, 8, 8, 0, 16, 8, 0, 24);
			uint32 color = tga.readUint32LE();
			format.colorToARGB(color, a, r, g, b);
		} else if (_colorMapEntryLength == 24) {
			r = tga.readByte();
			g = tga.readByte();
			b = tga.readByte();
		} else if (_colorMapEntryLength == 16) {
			byte a;
			Graphics::PixelFormat format(2, 5, 5, 5, 0, 10, 5, 0, 15);
			uint16 color = tga.readUint16LE();
			format.colorToARGB(color, a, r, g, b);
		} else {
			warning("Unsupported image type: %d", imageType);
			r = g = b = 0;
		}
#ifdef SCUMM_LITTLE_ENDIAN
		_colorMap[i] = r;
		_colorMap[i + 1] = g;
		_colorMap[i + 2] = b;
#else
		_colorMap[i] = b;
		_colorMap[i + 1] = g;
		_colorMap[i + 2] = r;
#endif
	}
	return true;
}
示例#7
0
void ImageFile::loadPalette(Common::SeekableReadStream &stream) {
	// Check for palette
	uint16 width        = stream.readUint16LE() + 1;
	uint16 height       = stream.readUint16LE() + 1;
	byte   paletteBase  = stream.readByte();
	byte   rleEncoded   = stream.readByte();
	byte   offsetX      = stream.readByte();
	byte   offsetY      = stream.readByte();
	uint32 palSignature = 0;

	if ((width == 390) && (height == 2) && (!paletteBase) && (!rleEncoded) && (!offsetX) && (!offsetY)) {
		// We check for these specific values
		// We can't do "width * height", because at least the first German+Spanish menu bar is 60 x 13
		// which is 780, which is the size of the palette. We obviously don't want to detect it as palette.

		// As another security measure, we also check for the signature text
		palSignature = stream.readUint32BE();
		if (palSignature != MKTAG('V', 'G', 'A', ' ')) {
			// signature mismatch, rewind
			stream.seek(-12, SEEK_CUR);
			return;
		}
		// Found palette, so read it in
		stream.seek(8, SEEK_CUR); // Skip over the rest of the signature text "VGA palette"
		for (int idx = 0; idx < PALETTE_SIZE; ++idx)
			_palette[idx] = VGA_COLOR_TRANS(stream.readByte());
	} else {
		// Not a palette, so rewind to start of frame data for normal frame processing
		stream.seek(-8, SEEK_CUR);
	}
}
示例#8
0
void DrasculaEngine::loadPic(const char *NamePcc, byte *targetSurface, int colorCount) {
	debug(5, "loadPic(%s)", NamePcc);

	uint dataSize = 0;
	byte *pcxData;

	Common::SeekableReadStream *stream = _archives.open(NamePcc);
	if (!stream)
		error("missing game data %s %c", NamePcc, 7);

	dataSize = stream->size() - 128 - (256 * 3);
	pcxData = (byte *)malloc(dataSize);

	stream->seek(128, SEEK_SET);
	stream->read(pcxData, dataSize);

	decodeRLE(pcxData, targetSurface);
	free(pcxData);

	for (int i = 0; i < 256; i++) {
		cPal[i * 3 + 0] = stream->readByte();
		cPal[i * 3 + 1] = stream->readByte();
		cPal[i * 3 + 2] = stream->readByte();
	}

	delete stream;

	setRGB((byte *)cPal, colorCount);
}
示例#9
0
void ActorType::load(byte *dataStart, Common::SeekableReadStream &stream) {
	_actorTypeId = stream.readUint32LE();
	_surfInfo.load(stream);
	uint32 pointsConfigOffs = stream.readUint32LE();
	uint namedPointsCount = stream.readUint16LE();
	stream.skip(2); // Skip padding
	uint32 namedPointsOffs = stream.readUint32LE();
	_color.r = stream.readByte();
	_color.g = stream.readByte();
	_color.b = stream.readByte();
	stream.readByte(); // Skip padding
	_scale = stream.readByte();
	_priority = stream.readByte();
	_value1E = stream.readUint16LE();
	_pathWalkPointsIndex = stream.readUint16LE();
	_scaleLayerIndex = stream.readUint16LE();
	_pathWalkRectIndex = stream.readUint16LE();
	_priorityLayerIndex = stream.readUint16LE();
	_regionLayerIndex = stream.readUint16LE();
	_flags = stream.readUint16LE();
	_pointsConfig = dataStart + pointsConfigOffs;
	stream.seek(namedPointsOffs);
	_namedPoints.load(namedPointsCount, stream);
	debug(5, "ActorType::load() _actorTypeId: %08X; _color(%d,%d,%d); _scale: %d; _priority: %d; _value1E: %d",
		_actorTypeId, _color.r, _color.g, _color.b, _scale, _priority, _value1E);
	debug(5, "ActorType::load() _pathWalkPointsIndex: %d; _scaleLayerIndex: %d; _pathWalkRectIndex: %d",
		_pathWalkPointsIndex, _scaleLayerIndex, _pathWalkRectIndex);
	debug(5, "ActorType::load() _priorityLayerIndex: %d; _regionLayerIndex: %d; _flags: %04X",
		_priorityLayerIndex, _regionLayerIndex,_flags);
}
示例#10
0
void Graphics::setBackgroundImage(Common::String filename) {
	delete[] _palette;
	_palette = new byte[256 * 3];

	Common::SeekableReadStream *scrStream = _vm->data.openFile(filename);
	for (uint16 i = 0; i < 128; i++) {
		_palette[i * 3] = scrStream->readByte();
		_palette[i * 3 + 1] = scrStream->readByte();
		_palette[i * 3 + 2] = scrStream->readByte();
	}
	memcpy(_palette + 128*3, _basePalette, 128*3);

	for (uint16 i = 0; i < 256; i++) {
		for (byte j = 0; j < 3; j++) {
			_palette[i * 3 + j] = _palette[i * 3 + j] << 2;
		}
	}

	_vm->_system->getPaletteManager()->setPalette(_palette, 0, 256);

	// some of the files seem to be 480 high, but just padded with black
	_background.width = 640;
	_background.height = 480;

	delete[] _background.data;
	_background.data = new byte[_background.width * _background.height];
	scrStream->read(_background.data, _background.width * _background.height);
	delete scrStream;
}
示例#11
0
文件: images.cpp 项目: 86400/scummvm
bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
	int x = 0, y = 0;

	// If the stream has exactly the required number of bits for this image,
	// we assume it is uncompressed.
	if (stream.size() * 8 == _surface->pitch * _surface->h) {
		debugC(3, kDebugImages, "Skipping compression");
		for (y = 0; y < _surface->h; y++) {
			for (x = 0; x < _surface->pitch; ) {
				byte color = stream.readByte();
				for (int c = 0; c < 8; c++)
					*((byte *)_surface->getBasePtr(x++, y)) = (color & (1 << (7 - c))) ? 0 : 0xff;
			}
		}

		return true;
	}

	while (y < _surface->h) {
		int n = stream.readSByte();
		int count;
		int b = 0;
		int state = 0;

		if (stream.eos())
			break;

		if ((n >= 0) && (n <= 127)) { // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
			count = n + 1;
			state = 1;
		} else if ((n >= -127) && (n <= -1)) { // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
			b = stream.readByte();
			count = -n + 1;
			state = 2;
		} else { // Else if n is -128, noop.
			count = 0;
		}

		for (int i = 0; i < count && y < _surface->h; i++) {
			byte color = 0;
			if (state == 1) {
				color = stream.readByte();
			} else if (state == 2)
				color = b;

			for (int c = 0; c < 8; c++) {
				*((byte *)_surface->getBasePtr(x, y)) = (color & (1 << (7 - c))) ? 0 : 0xff;
				x++;
				if (x == _surface->pitch) {
					y++;
					x = 0;
					break;
				}
			}
		}
	}

	return true;
}
示例#12
0
void AmazonResources::load(Common::SeekableReadStream &s) {
	Resources::load(s);
	uint count;

	// Load the version specific data
	NO_HELP_MESSAGE = readString(s);
	NO_HINTS_MESSAGE = readString(s);
	RIVER_HIT1 = readString(s);
	RIVER_HIT2 = readString(s);
	BAR_MESSAGE = readString(s);

	for (int idx = 0; idx < 3; ++idx)
		HELPLVLTXT[idx] = readString(s);
	for (int idx = 0; idx < 9; ++idx)
		IQLABELS[idx] = readString(s);

	CANT_GET_THERE = readString(s);

	// Get the offset of the general shared data for the game
	uint entryOffset = findEntry(_vm->getGameID(), 2, 0, (Common::Language)0);
	s.seek(entryOffset);

	// Read in the cursor list
	count = s.readUint16LE();
	CURSORS.resize(count);
	for (uint idx = 0; idx < count; ++idx) {
		uint count2 = s.readUint16LE();
		CURSORS[idx].resize(count2);
		s.read(&CURSORS[idx][0], count2);
	}

	// Load font data
	count = s.readUint16LE();
	Common::Array<int> index;
	Common::Array<byte> data;

	index.resize(count);
	for (uint idx = 0; idx < count; ++idx)
		index[idx] = s.readSint16LE();

	count = s.readUint16LE();
	data.resize(count);
	for (uint idx = 0; idx < count; ++idx)
		data[idx] = s.readByte();
	_font3x5 = new AmazonFont(&index[0], &data[0]);

	count = s.readUint16LE();
	index.resize(count);
	for (uint idx = 0; idx < count; ++idx)
		index[idx] = s.readSint16LE();

	count = s.readUint16LE();
	data.resize(count);
	for (uint idx = 0; idx < count; ++idx)
		data[idx] = s.readByte();
	_font6x6 = new AmazonFont(&index[0], &data[0]);
}
示例#13
0
Common::String DirectorEngine::readPascalString(Common::SeekableReadStream &stream) {
	byte length = stream.readByte();
	Common::String x;

	while (length--)
		x += (char)stream.readByte();

	return x;
}
示例#14
0
Conditions GameModule::readConditions(Common::SeekableReadStream &s) {
	Conditions c;
	for (int i = 0; i < 8; ++i) {
		c.conditions[i].cond = s.readByte();
		c.conditions[i].value1 = s.readByte();
		c.conditions[i].value2 = s.readUint16LE();
	}
	return c;
}
示例#15
0
void Map_v2::loadGoblinStates(Common::SeekableReadStream &data, int index) {
	Mult::Mult_GobState *statesPtr;
	Mult::Mult_GobState *gobState;
	int8 indices[102];
	uint8 statesCount;
	uint8 dataCount;
	int16 state;
	uint32 tmpPos;

	memset(indices, -1, 101);
	_vm->_mult->_objects[index].goblinStates = new Mult::Mult_GobState*[101];
	memset(_vm->_mult->_objects[index].goblinStates, 0,
			101 * sizeof(Mult::Mult_GobState *));

	data.read(indices, 100);
	tmpPos = data.pos();
	statesCount = 0;
	for (int i = 0; i < 100; i++) {
		if (indices[i] != -1) {
			statesCount++;
			data.skip(4);
			dataCount = data.readByte();
			statesCount += dataCount;
			data.skip(dataCount * 9);
		}
	}

	data.seek(tmpPos);

	statesPtr = new Mult::Mult_GobState[statesCount];
	_vm->_mult->_objects[index].goblinStates[0] = statesPtr;
	for (int i = 0; i < 100; i++) {
		state = indices[i];
		if (state != -1) {
			_vm->_mult->_objects[index].goblinStates[state] = statesPtr++;
			gobState = _vm->_mult->_objects[index].goblinStates[state];

			gobState[0].animation = data.readSint16LE();
			gobState[0].layer = data.readSint16LE();
			dataCount = data.readByte();
			gobState[0].dataCount = dataCount;
			for (uint8 j = 1; j <= dataCount; j++) {
				data.skip(1);
				gobState[j].sndItem = data.readSByte();
				data.skip(1);
				gobState[j].sndFrame = data.readByte();
				data.skip(1);
				gobState[j].freq = data.readSint16LE();
				gobState[j].repCount = data.readSByte();
				gobState[j].speaker = data.readByte();
				statesPtr++;
			}
		}
	}
}
示例#16
0
// Reads a null-terminated string
static Common::String readString(Common::SeekableReadStream &stream) {
	Common::String string;

	char c = stream.readByte();
	while (c && stream.pos() < stream.size()) {
		string += c;
		c = stream.readByte();
	}

	return string;
}
示例#17
0
文件: iff.cpp 项目: AReim1982/scummvm
void IFFDecoder::loadPaletteRange(Common::SeekableReadStream &stream, const uint32 size) {
	PaletteRange range;

	range.timer = stream.readSint16BE();
	range.step = stream.readSint16BE();
	range.flags = stream.readSint16BE();
	range.first = stream.readByte();
	range.last = stream.readByte();

	_paletteRanges.push_back(range);
}
示例#18
0
/* Simple LZSS decompression.
 *
 * Code loosely based on DSDecmp by Barubary, released under the terms of the MIT license.
 *
 * See <https://github.com/gravgun/dsdecmp/blob/master/CSharp/DSDecmp/Formats/Nitro/LZ10.cs#L121>
 * and <https://code.google.com/p/dsdecmp/>.
 */
static void decompress10(Common::SeekableReadStream &small, Common::WriteStream &out, uint32 size) {
	byte   buffer[0x10000];
	uint32 bufferPos = 0;

	uint16 flags = 0xFF00;

	uint32 outSize = 0;
	while (outSize < size) {
		// Only our canaries left => Read flags for the next 8 blocks
		if (flags == 0xFF00)
			flags = (small.readByte() << 8) | 0x00FF;

		if (flags & 0x8000) {
			// Copy from buffer

			const byte data1 = small.readByte();
			const byte data2 = small.readByte();

			// Copy how many bytes from where (relative) in the buffer?
			const uint8  length = (data1 >> 4) + 3;
			const uint16 offset = (((data1 & 0x0F) << 8) | data2) + 1;

			// Direct offset. Add size of the buffer once, to protect from overroll
			uint32 copyOffset = bufferPos + sizeof(buffer) - offset;

			// Copy length bytes (and store each back into the buffer)
			for (uint8 i = 0; i < length; i++, copyOffset++) {
				if ((copyOffset % sizeof(buffer)) > outSize)
					throw Common::Exception("Tried to copy past the buffer");

				const byte data = buffer[copyOffset % sizeof(buffer)];

				out.writeByte(data);
				outSize++;

				buffer[bufferPos] = data;
				bufferPos = (bufferPos + 1) % sizeof(buffer);
			}

		} else {
			// Read literal byte

			const byte data = small.readByte();

			out.writeByte(data);
			outSize++;

			buffer[bufferPos] = data;
			bufferPos = (bufferPos + 1) % sizeof(buffer);
		}

		flags <<= 1;
	}
示例#19
0
void Graphics::loadPalette() {
	delete[] _basePalette;
	// read the standard palette entries
	_basePalette = new byte[128 * 3];
	Common::SeekableReadStream *palStream = _vm->data.openFile("STANDARD.PAL");
	for (uint16 i = 0; i < 128; i++) {
		_basePalette[i * 3] = palStream->readByte();
		_basePalette[i * 3 + 1] = palStream->readByte();
		_basePalette[i * 3 + 2] = palStream->readByte();
	}
	delete palStream;
}
示例#20
0
void CBaseStarEntry::load(Common::SeekableReadStream &s) {
	_field0 = s.readByte();
	_field1 = s.readByte();
	_field2 = s.readByte();
	_field3 = s.readByte();
	*((uint32 *)&_value) = s.readUint32LE();		// FIXME
	_val._v1 = s.readUint32LE();
	_val._v2 = s.readUint32LE();
	_val._v3 = s.readUint32LE();

	for (int idx = 0; idx < 5; ++idx)
		_data[idx] = s.readUint32LE();
}
示例#21
0
void PLTFile::readData(Common::SeekableReadStream &plt) {
	uint32 size = _width * _height;

	_dataImage  = new uint8[size];
	_dataLayers = new uint8[size];

	uint8 *image = _dataImage;
	uint8 *layer = _dataLayers;
	while (size-- > 0) {
		*image++ = plt.readByte();
		*layer++ = MIN<uint8>(plt.readByte(), kLayerMAX - 1);
	}
}
示例#22
0
void TGA::readHeader(Common::SeekableReadStream &tga, ImageType &imageType, byte &pixelDepth, byte &imageDesc) {
	tga.seek(0);

	// TGAs have an optional "id" string in the header
	uint32 idLength = tga.readByte();

	// Number of colors in the color map / palette
	if (tga.readByte() != 0)
		throw Common::Exception("Unsupported feature: Color map");

	// Image type. 2 == unmapped RGB, 3 == Grayscale
	imageType = (ImageType)tga.readByte();
	if (!isSupportedImageType(imageType))
		throw Common::Exception("Unsupported image type: %d", imageType);

	// Color map specifications + X + Y
	tga.skip(5 + 2 + 2);

	_mipMaps.push_back(new MipMap);

	// Image dimensions
	_mipMaps[0]->width  = tga.readUint16LE();
	_mipMaps[0]->height = tga.readUint16LE();

	// Bits per pixel
	pixelDepth = tga.readByte();

	if (imageType == kImageTypeTrueColor || imageType == kImageTypeRLETrueColor) {
		if (pixelDepth == 24) {
			_format = kPixelFormatB8G8R8;
		} else if (pixelDepth == 16 || pixelDepth == 32) {
			_format = kPixelFormatB8G8R8A8;
		} else if (pixelDepth == 8) {
			imageType = kImageTypeBW;
			_format = kPixelFormatB8G8R8A8;
		} else
			throw Common::Exception("Unsupported pixel depth: %d, %d", imageType, pixelDepth);
	} else if (imageType == kImageTypeBW) {
		if (pixelDepth != 8)
			throw Common::Exception("Unsupported pixel depth: %d, %d", imageType, pixelDepth);

		_format = kPixelFormatB8G8R8A8;
	}

	// Image descriptor
	imageDesc = tga.readByte();

	// Skip the id string
	tga.skip(idLength);
}
示例#23
0
void ABCFont::readCharDesc(Char &c, Common::SeekableReadStream &abc) {
	uint32 offset = abc.readUint32LE();
	byte   plane  = abc.readByte();

	c.spaceL = abc.readByte();
	c.width  = abc.readByte();
	c.spaceR = abc.readByte();

	if (((offset % 1024) != 0) || (plane > 3))
		throw Common::Exception("Invalid char data (%d, %d)", offset, plane);

	c.dataX =  plane          * 32;
	c.dataY = (offset / 1024) * 32;
}
示例#24
0
文件: view.cpp 项目: Fyre91/scummvm
void NewFeature::resetScript() {
	// FIXME: registrations, etc
	Common::SeekableReadStream *ourSCRB = _view->getSCRB(_data.scrbIndex, _scrbId);
	ourSCRB->seek(16);
	Common::Point scriptBase, scriptSize;
	scriptBase.x = ourSCRB->readUint16BE();
	scriptBase.y = ourSCRB->readUint16BE();
	scriptSize.x = ourSCRB->readUint16BE();
	scriptSize.y = ourSCRB->readUint16BE();
	ourSCRB->seek(26);
	Common::Point one, two;
	while (true) {
		if (ourSCRB->pos() == ourSCRB->size())
			error("resetScript (getNewXYAndReg) ran out of script");
		byte opcode = ourSCRB->readByte();
		byte size = ourSCRB->readByte();
		if (opcode != 0x10) {
			ourSCRB->skip(size - 2);
		} else if (size) {
			assert(size >= 1);
			ourSCRB->skip(2);
			int16 x = ourSCRB->readUint16BE();
			int16 y = ourSCRB->readUint16BE();
			one.x = -x;
			one.y = -y;
			two.x = scriptBase.x + x;
			two.y = scriptBase.y + y;
			break;
		}
	}
	delete ourSCRB;

	if ((_needsReset || false /* TODO: param */) && (_unknown168 == 0x7FFFFFFF || false /* TODO: param */)) {
		_data.currentPos = two;
		_data.nextPos = one;
		_unknown168 = 0;
		if (_needsReset || false /* TODO: param */) {
			_data.bounds = Common::Rect(scriptBase.x, scriptBase.y, scriptSize.x, scriptSize.y);
		}
	} else {
		if (false /* FIXME: 0 shapes? */) {
			_data.nextPos.x = one.x + two.x - _data.currentPos.x;
			_data.nextPos.y = one.y + two.y - _data.currentPos.y;
		} else if (_unknown168 != 0x7FFFFFFF) {
			_data.nextPos = one;
		}
	}
	// _needsReset = 0; (handled by caller)
}
示例#25
0
void Sprite::loadPalette(Common::SeekableReadStream &stream, uint32 count) {
	if (count == 0)
		return;

	byte *palette = new byte[count * 3];
	for (uint32 i = 0; i < count ; i++) {
		palette[i * 3 + 2] = stream.readByte();
		palette[i * 3 + 1] = stream.readByte();
		palette[i * 3 + 0] = stream.readByte();

		stream.skip(1);
	}
	_palette.copyFrom(palette, count);
	delete[] palette;
}
示例#26
0
bool Mob::loadFromStream(Common::SeekableReadStream &stream) {
	int32 pos = stream.pos();

	uint16 visible = stream.readUint16LE();

	if (visible == 0xFFFF)
		return false;

	_visible = visible;
	_type = stream.readUint16LE();
	_rect.left = stream.readUint16LE();
	_rect.top = stream.readUint16LE();
	_rect.right = stream.readUint16LE();
	_rect.bottom = stream.readUint16LE();

	_mask = stream.readUint16LE();

	_examPosition.x = stream.readUint16LE();
	_examPosition.y = stream.readUint16LE();
	_examDirection = (Direction)stream.readUint16LE();

	_usePosition.x = stream.readByte();
	_usePosition.y = stream.readByte();
	_useDirection = (Direction)stream.readUint16LE();

	uint32 nameOffset = stream.readUint32LE();
	uint32 examTextOffset = stream.readUint32LE();

	byte c;
	stream.seek(nameOffset);
	_name.clear();
	while ((c = stream.readByte()))
		_name += c;

	stream.seek(examTextOffset);
	_examText.clear();
	c = stream.readByte();
	if (c) {
		_examText += c;
		do {
			c = stream.readByte();
			_examText += c;
		} while (c != 255);
	}
	stream.seek(pos + 32);

	return true;
}
示例#27
0
bool StaticResource::loadFlyingObjectData(Common::SeekableReadStream &stream, void *&ptr, int &size) {
	size = stream.size() / 5;
	FlyingObjectShape *defs = new FlyingObjectShape[size];

	for (int i = 0; i < size; i++) {
		FlyingObjectShape *t = &defs[i];
		t->shapeFront = stream.readByte();
		t->shapeBack = stream.readByte();
		t->shapeLeft = stream.readByte();
		t->drawFlags = stream.readByte();
		t->flipFlags = stream.readByte();
	};

	ptr = defs;
	return true;
}
示例#28
0
bool StaticResource::loadCompassData(Common::SeekableReadStream &stream, void *&ptr, int &size) {
	size = stream.size() / 4;
	CompassDef *defs = new CompassDef[size];

	for (int i = 0; i < size; i++) {
		CompassDef *t = &defs[i];
		t->shapeIndex = stream.readByte();
		t->x = stream.readByte();
		t->y = stream.readByte();
		t->flags = stream.readByte();
	};


	ptr = defs;
	return true;
}
示例#29
0
bool Sprite::loadFromSaturnCursor(Common::SeekableReadStream &cursor) {
	if (cursor.size() != 260)
		return false;

	_fromCursor = true;

	create(16, 16);

	cursor.seek(0);

	_feetX = cursor.readUint16BE();
	_feetY = cursor.readUint16BE();

	byte *img = (byte *) _surfaceTrueColor.pixels;
	for (int32 y = 0; y < 16; y++) {
		for (int32 x = 0; x < 16; x++) {
			const uint8  p = cursor.readByte();
			const uint32 c = (p == 0) ? ImgConv.getColor(0, 0, 255) : ImgConv.getColor(255 - p, 255 - p, 255 - p);

			ImgConv.writeColor(img, c);

			img += _surfaceTrueColor.bytesPerPixel;
		}
	}

	return true;
}
示例#30
0
文件: tga.cpp 项目: AReim1982/scummvm
bool TGADecoder::readDataColorMapped(Common::SeekableReadStream &tga, byte imageType, byte indexDepth) {
	// Color-mapped
	if (imageType == TYPE_CMAP) {
		_surface.create(_surface.w, _surface.h, _format);
		if (indexDepth == 8) {
			for (int i = 0; i < _surface.h; i++) {
				byte *dst;
				if (!_originTop) {
					dst = (byte *)_surface.getBasePtr(0, _surface.h - i - 1);
				} else {
					dst = (byte *)_surface.getBasePtr(0, i);
				}
				for (int j = 0; j < _surface.w; j++) {
					byte index = tga.readByte();
					*dst++ = index;
				}
			}
		} else if (indexDepth == 16) {
			warning("16 bit indexes not supported");
			return false;
		}
	} else {
		return false;
	}
	return true;
}