Beispiel #1
0
bool SaveHeader::read(Common::ReadStream &stream) {
	// Read the header and verify the global IDs
	if (stream.readUint32BE() != kID1)
		return false;
	if (stream.readUint32BE() != kID2)
		return false;

	_type = stream.readUint32BE();
	_version = stream.readUint32LE();
	_size = stream.readUint32LE();

	return !stream.err();
}
Beispiel #2
0
bool SaveHeader::verify(Common::ReadStream &stream) const {
	// Compare the header with the stream's content

	if (stream.readUint32BE() != kID1)
		return false;
	if (stream.readUint32BE() != kID2)
		return false;
	if (stream.readUint32BE() != _type)
		return false;
	if (stream.readUint32LE() != _version)
		return false;
	if (stream.readUint32LE() != _size)
		return false;

	return !stream.err();
}
Beispiel #3
0
XARCMember::XARCMember(const XARCArchive *xarc, Common::ReadStream &stream, uint32 offset) {
	_xarc = xarc;

	// Read the information about this archive member
	_name = readString(stream);
	_offset = offset;
	_length = stream.readUint32LE();
	debugC(20, kDebugArchive, "Stark::XARC Member: \"%s\" starts at offset=%d and has length=%d", _name.c_str(), _offset, _length);

	// Unknown value. English: 0, others: 1
	uint32 unknown = stream.readUint32LE();
	debugC(kDebugUnknown, "Stark::XARC Member: \"%s\" has unknown=%d", _name.c_str(), unknown);
	if (unknown != 0 && unknown != 1) {
		warning("Stark::XARC Member: \"%s\" has unknown=%d with unknown meaning", _name.c_str(), unknown);
	}
}
Beispiel #4
0
bool SaveHeader::verifyReadSize(Common::ReadStream &stream) {
	// Compare the header with the stream's content, expect for the size

	if (stream.readUint32BE() != kID1)
		return false;
	if (stream.readUint32BE() != kID2)
		return false;
	if (stream.readUint32BE() != _type)
		return false;
	if (stream.readUint32LE() != _version)
		return false;

	// Read the size out of the stream instead
	_size = stream.readUint32LE();

	return !stream.err();
}
Beispiel #5
0
bool SavePartSprite::read(Common::ReadStream &stream) {
	SaveHeader header;
	header.read(stream);

	if (_header != header) {
		if (!_trueColor) {
			// Header validation failed, trying again with the old version

			_header.setVersion(1);
			_header.setSize(_header.getSize() - 1);

			if (_header != header)
				// Nope, isn't it either
				return false;

			_oldFormat = true;

			_header.setVersion(kVersion);
			_header.setSize(_header.getSize() + 1);

		} else
			return false;
	}

	// The sprite's dimensions have to fit
	if (stream.readUint32LE() != _width)
		return false;
	if (stream.readUint32LE() != _height)
		return false;

	// If it's in the current format, the true color flag has to be the same too
	if (!_oldFormat)
		if ((stream.readByte() != 0) != _trueColor)
			return false;

	// Sprite data
	if (stream.read(_dataSprite, _spriteSize) != _spriteSize)
		return false;

	// Palette data
	if (stream.read(_dataPalette, 768) != 768)
		return false;

	return !stream.err();
}
Beispiel #6
0
Common::String readLAString(Common::ReadStream &ms) {
	int strLength = ms.readUint32LE();
	char* readString = new char[strLength];
	ms.read(readString, strLength);
	
	Common::String retVal(readString);
	delete[] readString;
	
	return retVal;
}
Beispiel #7
0
bool SaveContainer::read(Common::ReadStream &stream) {
	// Verify the header and get the container's size
	if (!_header.verifyReadSize(stream))
		return false;

	// The part count has to be correct
	if (stream.readUint32LE() != _partCount)
		return false;

	// Iterate over all parts
	for (PartIterator it = _parts.begin(); it != _parts.end(); ++it) {
		// Read the size
		uint32 size = stream.readUint32LE();

		if (stream.err()) {
			clear();
			return false;
		}

		Part *&p = *it;

		delete p;
		// Create a suitable part
		p = new Part(size);
	}

	// Update size
	_header.setSize(calcSize());

	// Iterate over all parts
	for (PartIterator it = _parts.begin(); it != _parts.end(); ++it) {
		Part *&p = *it;

		// Read the part
		if (stream.read(p->data, p->size) != p->size) {
			clear();
			return false;
		}
	}

	return !stream.err();
}
Beispiel #8
0
bool SavePartInfo::read(Common::ReadStream &stream) {
	if (!_header.verify(stream))
		return false;

	if (stream.readUint32LE() != _gameID)
		return false;
	if (stream.readUint32LE() != _gameVersion)
		return false;
	if (stream.readByte() != _endian)
		return false;
	if (stream.readUint32LE() != _varCount)
		return false;
	if (stream.readUint32LE() != _descMaxLength)
		return false;

	if (stream.read(_desc, _descMaxLength) != _descMaxLength)
		return false;

	_desc[_descMaxLength] = 0;

	return !stream.err();
}
Beispiel #9
0
void Display::loadFrameBuffer(Common::ReadStream &stream) {
	byte *dst = _frameBuf;
	for (uint j = 0; j < 8; ++j) {
		for (uint i = 0; i < 8; ++i) {
			stream.read(dst, DISPLAY_PITCH);
			dst += DISPLAY_PITCH * 64;
			stream.read(dst, DISPLAY_PITCH);
			dst += DISPLAY_PITCH * 64;
			stream.read(dst, DISPLAY_PITCH);
			stream.readUint32LE();
			stream.readUint32LE();
			dst -= DISPLAY_PITCH * 120;
		}
		dst -= DISPLAY_PITCH * 63;
	}

	if (stream.eos() || stream.err())
		error("Failed to read frame buffer");
}
Beispiel #10
0
/*-----------------------------------------------------------------------
 * BtPage
 *-----------------------------------------------------------------------*/
void BtPage::readBTree(Common::ReadStream &s) {
	_header._count = s.readUint16LE();
	_header._down = s.readUint16LE();

	if (_header._down == kBtValNone) {
		// Leaf list
		for (int i = 0; i < kBtLeafCount; ++i) {
			s.read(_leaf[i]._key, kBtKeySize);
			_leaf[i]._pos = s.readUint32LE();
			_leaf[i]._size = s.readUint16LE();
		}
	} else {
		// Root index
		for (int i = 0; i < kBtInnerCount; ++i) {
			s.read(_inner[i]._key, kBtKeySize);
			_inner[i]._down = s.readUint16LE();
		}
	}
}
Beispiel #11
0
	void operator()(Uint32& i) const {
		i = _s->readUint32LE();
	}