Esempio n. 1
0
void UserInterface::load(const Common::String &resName) {
	File f(resName);
	MadsPack madsPack(&f);

	// Load in the palette
	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);

	uint32 *gamePalP = &_vm->_palette->_palFlags[0];
	byte *palP = &_vm->_palette->_mainPalette[0];

	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
		RGB6 rgb;
		rgb.load(palStream);
		palP[0] = rgb.r;
		palP[1] = rgb.g;
		palP[2] = rgb.b;
		*gamePalP |= 1;
	}
	delete palStream;

	// Read in the surface data
	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
	pixelsStream->read(_surface.getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
	delete pixelsStream;
}
Esempio n. 2
0
void Scene::loadHotspots() {
	_hotspots.clear();

	Common::File f;
	if (f.open(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"))) {
		MadsPack madsPack(&f);
		bool isV2 = (_vm->getGameID() != GType_RexNebular);

		Common::SeekableReadStream *stream = madsPack.getItemStream(0);
		int count = stream->readUint16LE();
		delete stream;

		stream = madsPack.getItemStream(1);
		for (int i = 0; i < count; ++i)
			_hotspots.push_back(Hotspot(*stream, isV2));

		delete stream;
		f.close();
	}
}
Esempio n. 3
0
void Animation::load(MSurface &backSurface, DepthSurface &depthSurface,
		const Common::String &resName, int flags, Common::Array<PaletteCycle> *palCycles,
		SceneInfo *sceneInfo) {
	Common::String resourceName = resName;
	if (!resourceName.contains("."))
		resourceName += ".AA";

	File f(resourceName);
	MadsPack madsPack(&f);

	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
	_header.load(stream);
	delete stream;

	if (_header._bgType == ANIMBG_INTERFACE)
		flags |= PALFLAG_RESERVED;
	_flags = flags;

	if (flags & ANIMFLAG_LOAD_BACKGROUND) {
		loadBackground(backSurface, depthSurface, _header, flags, palCycles, sceneInfo);
	}
	if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) {
		// No data
		_header._messagesCount = 0;
		_header._frameEntriesCount = 0;
		_header._miscEntriesCount = 0;
	}

	// Initialize the reference list
	_spriteListIndexes.clear();
	for (int i = 0; i < _header._spriteSetsCount; ++i)
		_spriteListIndexes.push_back(-1);

	int streamIndex = 1;
	_messages.clear();
	if (_header._messagesCount > 0) {
		// Chunk 2: Following is a list of any messages for the animation
		Common::SeekableReadStream *msgStream = madsPack.getItemStream(streamIndex++);

		for (int i = 0; i < _header._messagesCount; ++i) {
			AnimMessage rec;
			rec.load(msgStream);
			_messages.push_back(rec);
		}

		delete msgStream;
	}

	_frameEntries.clear();
	if (_header._frameEntriesCount > 0) {
		// Chunk 3: animation frame info
		Common::SeekableReadStream *frameStream = madsPack.getItemStream(streamIndex++);

		for (int i = 0; i < _header._frameEntriesCount; i++) {
			AnimFrameEntry rec;
			rec.load(frameStream, _header._bgType == ANIMBG_INTERFACE);
			_frameEntries.push_back(rec);
		}

		delete frameStream;
	}

	_miscEntries.clear();
	_uiEntries.clear();
	if (_header._miscEntriesCount > 0) {
		// Chunk 4: Misc Data
		Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++);

		if (_header._bgType == ANIMBG_INTERFACE) {
			for (int i = 0; i < _header._miscEntriesCount; ++i) {
				AnimUIEntry rec;
				rec.load(miscStream);
				_uiEntries.push_back(rec);
			}
		} else {
			for (int i = 0; i < _header._miscEntriesCount; ++i) {
				AnimMiscEntry rec;
				rec.load(miscStream);
				_miscEntries.push_back(rec);
			}
		}

		delete miscStream;
	}

	// If the animation specifies a font, then load it for access
	delete _font;
	if (_header._loadFlags & ANIMFLAG_CUSTOM_FONT) {
		Common::String fontName = "*" + _header._fontResource;
		_font = _vm->_font->getFont(fontName.c_str());
	} else {
		_font = nullptr;
	}

	// Load all the sprite sets for the animation
	for (uint i = 0; i < _spriteSets.size(); ++i)
		delete _spriteSets[i];
	_spriteSets.clear();
	_spriteSets.resize(_header._spriteSetsCount);

	for (int i = 0; i < _header._spriteSetsCount; ++i) {
		if (_header._manualFlag && (i == _header._spritesIndex)) {
			// Skip over field, since it's manually loaded
			_spriteSets[i] = nullptr;
		} else {
			_spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags);
			_spriteListIndexes[i] = _vm->_game->_scene._sprites.add(_spriteSets[i]);
		}
	}

	if (_header._manualFlag) {
		Common::String assetResName = "*" + _header._spriteSetNames[_header._spritesIndex];
		SpriteAsset *sprites = new SpriteAsset(_vm, assetResName, flags);
		_spriteSets[_header._spritesIndex] = sprites;

		_spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites);
	}

	Common::Array<int> usageList;
	for (int idx = 0; idx < _header._spriteSetsCount; ++idx)
		usageList.push_back(_spriteSets[idx]->_usageIndex);

	if (usageList.size() > 0) {
		int spritesUsageIndex = _spriteSets[0]->_usageIndex;
		_vm->_palette->_paletteUsage.updateUsage(usageList, spritesUsageIndex);
	}

	// Remaps the sprite list indexes for frames to the loaded sprite list indexes
	for (uint i = 0; i < _frameEntries.size(); ++i) {
		int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
		_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
	}

	f.close();
}