Exemplo n.º 1
0
void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) {
	// The PSX videos have half resolution

	Graphics::Surface scaledFrame;
	scaledFrame.create(frame->getWidth(), frame->getHeight() * 2, frame->getFormat());

	for (int y = 0; y < scaledFrame.getHeight(); y++)
		memcpy(scaledFrame.getBasePtr(0, y), frame->getBasePtr(0, y / 2), scaledFrame.getWidth() * scaledFrame.getFormat().bytesPerPixel);

	uint16 x = (g_system->getWidth() - scaledFrame.getWidth()) / 2;
	uint16 y = (g_system->getHeight() - scaledFrame.getHeight()) / 2;

	_vm->_system->copyRectToScreen(scaledFrame.getPixels(), scaledFrame.getPitch(), x, y, scaledFrame.getWidth(), scaledFrame.getHeight());
}
Exemplo n.º 2
0
void Animation::drawFontFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy, byte *colorMap) {
	debugC(4, kDebugAnim, "drawFontFrame(surface, %d, %d, %d, colorMap)", frame, xx, yy);
	if (frame < 0)
		frame = 0;

	if (frame >= _numFrames)
		frame = _numFrames - 1;

	if (_numFrames == 0)
		return;

	int16 dataFrame = frame;

	if (_frames[frame]._ref != -1)
		dataFrame = _frames[frame]._ref;

	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;

	if ((xx + _x1 + _frames[frame]._x1 < 0) || (yy + _y1 + _frames[frame]._y1 < 0))
		return;

	if (rectX + xx + _x1 + _frames[frame]._x1 >= surface.getWidth())
		rectX = surface.getWidth() - xx - _x1 - _frames[frame]._x1;

	if (rectX < 0)
		return;

	if (rectY + yy + _y1 + _frames[frame]._y1 >= surface.getHeight())
		rectY = surface.getHeight() - yy - _y1 - _frames[frame]._y1;

	if (rectY < 0)
		return;

	int32 destPitch = surface.getPitch();
	uint8 *c = _frames[dataFrame]._data;
	uint8 *curRow = (uint8 *)surface.getBasePtr(xx + _x1 + _frames[frame]._x1, yy + _frames[frame]._y1 + _y1);
	for (int16 y = 0; y < rectY; y++) {
		unsigned char *cur = curRow;
		for (int16 x = 0; x < rectX; x++) {
			if (*c && *c < 4)
				*cur = colorMap[*c];
			c++;
			cur++;
		}
		curRow += destPitch;
	}
}
Exemplo n.º 3
0
bool SlotControl::process(uint32 deltaTimeInMillis) {
	if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
		return false;

	if (_engine->canRender()) {
		int curItem = _engine->getScriptManager()->getStateValue(_key);
		if (curItem != _renderedItem) {
			if (_renderedItem != 0 && curItem == 0) {
				_engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
				_renderedItem = curItem;
			} else {
				if (_renderedItem == 0) {
					if (_bkg)
						delete _bkg;

					_bkg = _engine->getRenderManager()->getBkgRect(_rectangle);
				} else {
					_engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top);
				}

				char buf[16];
				if (_engine->getGameId() == GID_NEMESIS)
					sprintf(buf, "%d%cobj.tga", curItem, _distanceId);
				else
					sprintf(buf, "g0z%cu%2.2x1.tga", _distanceId, curItem);

				Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf);

				int16 drawx = _rectangle.left;
				int16 drawy = _rectangle.top;

				if (_rectangle.width() > srf->getWidth())
					drawx = _rectangle.left + (_rectangle.width() - srf->getWidth()) / 2;

				if (_rectangle.height() > srf->getHeight())
					drawy = _rectangle.top + (_rectangle.height() - srf->getHeight()) / 2;

				_engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0);

				delete srf;

				_renderedItem = curItem;
			}
		}
	}
	return false;
}
Exemplo n.º 4
0
int16 ScriptFunctions::sfLoadMouseCursor(int16 argc, int16 *argv) {
	PictureResource *flex = _vm->_res->getPicture(argv[2]);
	if (flex) {
		Graphics::Surface *surf = flex->getPicture();
		CursorMan.replaceCursor(surf->getPixels(), surf->getWidth(), surf->getHeight(), argv[1], argv[0], 0);
		_vm->_res->freeResource(flex);
	}
	return 0;
}
Exemplo n.º 5
0
bool LBGraphics::imageIsTransparentAt(uint16 image, bool useOffsets, int x, int y) {
	MohawkSurface *mhkSurface = findImage(image);

	if (useOffsets) {
		x += mhkSurface->getOffsetX();
		y += mhkSurface->getOffsetY();
	}

	if (x < 0 || y < 0)
		return true;

	Graphics::Surface *surface = mhkSurface->getSurface();
	if (x >= surface->getWidth() || y >= surface->getHeight())
		return true;

	return *(byte *)surface->getBasePtr(x, y) == 0;
}
Exemplo n.º 6
0
void H263Codec::decodeFrame(Graphics::Surface &surface, Common::SeekableReadStream &dataStream) {
	// NOTE: When asking libxvidcore to decode the video into BGRA, it fills the alpha
	//       values with 0x00, rendering the output invisible (!).
	//       Since we, surprise, actually want to see the video, we would have to pass
	//       over the whole video data and fix-up the alpha values ourselves. Or
	//       alternatively do the YUV->BGRA conversion ourselves. We chose the latter.

	int dataSize = dataStream.size();
	byte *data = new byte[dataSize];
	dataStream.read(data, dataSize);

	xvid_dec_frame_t xvid_dec_frame;
	memset(&xvid_dec_frame, 0, sizeof(xvid_dec_frame_t));
	xvid_dec_frame.version    = XVID_VERSION;
	xvid_dec_frame.general    = XVID_DEBLOCKY | XVID_DEBLOCKUV | XVID_DERINGY | XVID_DERINGUV;
	xvid_dec_frame.bitstream  = data;
	xvid_dec_frame.length     = dataSize;
	xvid_dec_frame.output.csp = XVID_CSP_INTERNAL;

	xvid_dec_stats_t xvid_dec_stats;
	memset(&xvid_dec_stats, 0, sizeof(xvid_dec_stats_t));
	xvid_dec_stats.version = XVID_VERSION;

	int c = xvid_decore(_decHandle, XVID_DEC_DECODE, &xvid_dec_frame, &xvid_dec_stats);
	if ((dataSize - c) > 1)
		warning("H263Codec::decodeFrame(): %d bytes left in frame", dataSize - c);

	delete[] data;

	if (xvid_dec_frame.output.plane[0] &&
	    xvid_dec_frame.output.plane[1] &&
	    xvid_dec_frame.output.plane[2])
		YUVToRGBMan.convert420(Graphics::YUVToRGBManager::kScaleFull,
				surface.getData(), surface.getWidth() * 4,
				(const byte *) xvid_dec_frame.output.plane[0],
				(const byte *) xvid_dec_frame.output.plane[1],
				(const byte *) xvid_dec_frame.output.plane[2], _width, _height,
				xvid_dec_frame.output.stride[0], xvid_dec_frame.output.stride[1]);
}
Exemplo n.º 7
0
void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) {
	Common::Rect dst = destRect;
	// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
	if (dst.isEmpty())
		dst = Common::Rect(vid.getWidth(), vid.getHeight());

	Graphics::Surface scaled;

	if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height())
		scaled.create(dst.width(), dst.height(), vid.getPixelFormat());

	uint16 x = _workingWindow.left + dst.left;
	uint16 y = _workingWindow.top + dst.top;
	uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width();
	uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height();
	bool showSubs = (_scriptManager->getStateValue(StateKey_Subtitles) == 1);

	_clock.stop();
	vid.start();
	_videoIsPlaying = true;

	// Only continue while the video is still playing
	while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
		// Check for engine quit and video stop key presses
		while (_eventMan->pollEvent(_event)) {
			switch (_event.type) {
			case Common::EVENT_KEYDOWN:
				switch (_event.kbd.keycode) {
				case Common::KEYCODE_q:
					if (_event.kbd.hasFlags(Common::KBD_CTRL))
						quitGame();
					break;
				case Common::KEYCODE_SPACE:
					if (skippable) {
						vid.stop();
					}
					break;
				default:
					break;
				}
			default:
				break;
			}
		}

		if (vid.needsUpdate()) {
			const Graphics::Surface *frame = vid.decodeNextFrame();
			if (sub && showSubs)
				sub->process(vid.getCurFrame());

			if (frame) {
				if (scaled.getPixels()) {
					_renderManager->scaleBuffer(frame->getPixels(), scaled.getPixels(), frame->getWidth(), frame->getHeight(), frame->getFormat().bytesPerPixel, scaled.getWidth(), scaled.getHeight());
					frame = &scaled;
				}
				Common::Rect rect = Common::Rect(x, y, x + finalWidth, y + finalHeight);
				_renderManager->copyToScreen(*frame, rect, 0, 0);
				_renderManager->processSubs(0);
			}
		}

		// Always update the screen so the mouse continues to render
		_system->updateScreen();

		_system->delayMillis(vid.getTimeToNextFrame() / 2);
	}

	_videoIsPlaying = false;
	_clock.start();
}
Exemplo n.º 8
0
void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int16 xx, int16 yy) {
	debugC(3, kDebugAnim, "drawFrame(surface, %d, %d, %d)", frame, xx, yy);
	if (frame < 0)
		frame = 0;

	if (frame >= _numFrames)
		frame = _numFrames - 1;

	if (_numFrames == 0)
		return;

	int16 dataFrame = frame;

	if (_frames[frame]._ref != -1)
		dataFrame = _frames[frame]._ref;

	if (!_frames[dataFrame]._data)
		return;

	int16 rectX = _frames[frame]._x2 - _frames[frame]._x1;
	int16 rectY = _frames[frame]._y2 - _frames[frame]._y1;
	int16 offsX = 0;
	int16 offsY = 0;

	_vm->addDirtyRect(xx + _x1 + _frames[frame]._x1, yy + _y1 + _frames[frame]._y1, xx + rectX + _x1 + _frames[frame]._x1 , yy + rectY + _y1 + _frames[frame]._y1);

	if (xx + _x1 + _frames[frame]._x1 < 0) {
		offsX = -(xx + _x1 + _frames[frame]._x1);
	}

	if (offsX >= rectX)
		return;
	else
		rectX -= offsX;

	if (yy + _y1 + _frames[frame]._y1 < 0) {
		offsY = -(yy + _y1 + _frames[frame]._y1);
	}

	if (offsY >= rectY)
		return;
	else
		rectY -= offsY;

	if (rectX + xx + _x1 + _frames[frame]._x1 >= surface.getWidth())
		rectX = surface.getWidth() - xx - _x1 - _frames[frame]._x1;

	if (rectX < 0)
		return;

	if (rectY + yy + _y1 + _frames[frame]._y1 >= surface.getHeight())
		rectY = surface.getHeight() - yy - _y1 - _frames[frame]._y1;

	if (rectY < 0)
		return;

	int32 destPitch = surface.getPitch();
	uint8 *srcRow = _frames[dataFrame]._data + offsX + (_frames[frame]._x2 - _frames[frame]._x1) * offsY;
	uint8 *curRow = (uint8 *)surface.getBasePtr(xx + _x1 + _frames[frame]._x1 + offsX, yy + _frames[frame]._y1 + _y1 + offsY);
	for (int16 y = 0; y < rectY; y++) {
		uint8 *cur = curRow;
		uint8 *c = srcRow + y * (_frames[frame]._x2 - _frames[frame]._x1);
		for (int16 x = 0; x < rectX; x++) {
			if (*c)
				*cur = *c;
			c++;
			cur++;
		}
		curRow += destPitch;
	}
}