Beispiel #1
0
void Surface::loadScreen(MemoryBlock *rawData) {
	PictureDecoder decoder;
	uint16 v = READ_BE_UINT16(rawData->data());
	bool is5Bit = (v & 0xfffe) == 0x140;
	MemoryBlock *tmpScreen;

	if (is5Bit)
		// 5-bit decompression
		tmpScreen = decoder.egaDecode(rawData, FULL_SCREEN_HEIGHT * FULL_SCREEN_WIDTH + 1);
	else
		// VGA decompression
		tmpScreen = decoder.vgaDecode(rawData, FULL_SCREEN_HEIGHT * FULL_SCREEN_WIDTH + 1);

	empty();
	_data->copyFrom(tmpScreen, 0, MENUBAR_Y_SIZE * FULL_SCREEN_WIDTH,
		(FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE) * FULL_SCREEN_WIDTH);
	delete tmpScreen;
}
Beispiel #2
0
AnimationSequence::AnimationSequence(uint16 screenId, Palette &palette,  bool fadeIn, int frameDelay,
					 const AnimSoundSequence *soundList): _screenId(screenId), _palette(palette),
					 _frameDelay(frameDelay), _soundList(soundList) {
	Screen &screen = Screen::getReference();
	PictureDecoder decoder;
	Disk &d = Disk::getReference();

	// Get the data and decode it. Note that VGA decompression is used
	// even if the decompressed contents is actually EGA data
	MemoryBlock *data = d.getEntry(_screenId);
	_decodedData = decoder.vgaDecode(data, MAX_ANIM_DECODER_BUFFER_SIZE);
	delete data;

	_isEGA = LureEngine::getReference().isEGA();
	if (_isEGA) {
		// Setup for EGA animation
		_lineRefs = NULL;

		// Reset the palette and clear the screen for EGA decoding
		screen.setPaletteEmpty(RES_PALETTE_ENTRIES);
		screen.screen().empty();

		// Load the screen - each four bytes contain the four planes
		// worth of data for 8 sequential pixels
		byte *pSrc = _decodedData->data();
		byte *pDest = screen.screen().data().data() +
			(FULL_SCREEN_WIDTH * MENUBAR_Y_SIZE);

		for (int ctr = 0; ctr < FULL_SCREEN_WIDTH * (FULL_SCREEN_HEIGHT -
				MENUBAR_Y_SIZE) / 8; ++ctr, pDest += EGA_PIXELS_PER_BYTE) {
			for (int planeCtr = 0; planeCtr < EGA_NUM_LAYERS; ++planeCtr, ++pSrc) {
				byte v = *pSrc;
				for (int bitCtr = 0; bitCtr < 8; ++bitCtr, v <<= 1) {
					if ((v & 0x80) != 0)
					*(pDest + bitCtr) |= 1 << planeCtr;
				}
			}
		}

		screen.update();
		screen.setPalette(&_palette, 0, _palette.numEntries());

		// Set pointers for animation
		_pPixels = pSrc;
		_pPixelsEnd = _decodedData->data() + _decodedData->size() - 1;
		_pLines = NULL;
		_pLinesEnd = NULL;

	} else {
		// Setup for VGA animation
		_lineRefs = d.getEntry(_screenId + 1);

		// Reset the palette and set the initial starting screen
		screen.setPaletteEmpty(RES_PALETTE_ENTRIES);
		screen.screen().data().copyFrom(_decodedData, 0, 0, FULL_SCREEN_HEIGHT * FULL_SCREEN_WIDTH);
		screen.update();

		// Set the palette
		if (fadeIn)	screen.paletteFadeIn(&_palette);
		else screen.setPalette(&_palette, 0, _palette.numEntries());

		// Set up frame pointers
		_pPixels = _decodedData->data() + SCREEN_SIZE;
		_pPixelsEnd = _decodedData->data() + _decodedData->size() - 1;
		_pLines = _lineRefs->data();
		_pLinesEnd = _lineRefs->data() + _lineRefs->size() - 1;
	}
}