[Scummvm-cvs-logs] SF.net SVN: scummvm: [22136] scummvm/trunk/engines/simon

kirben at users.sourceforge.net kirben at users.sourceforge.net
Mon Apr 24 03:26:01 CEST 2006


Revision: 22136
Author:   kirben
Date:     2006-04-24 03:24:56 -0700 (Mon, 24 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22136&view=rev

Log Message:
-----------
Add support for OmniTV

Modified Paths:
--------------
    scummvm/trunk/engines/simon/animation.cpp
    scummvm/trunk/engines/simon/animation.h
    scummvm/trunk/engines/simon/simon.cpp
Modified: scummvm/trunk/engines/simon/animation.cpp
===================================================================
--- scummvm/trunk/engines/simon/animation.cpp	2006-04-24 07:45:57 UTC (rev 22135)
+++ scummvm/trunk/engines/simon/animation.cpp	2006-04-24 10:24:56 UTC (rev 22136)
@@ -41,10 +41,9 @@
 
 MoviePlayer::MoviePlayer(SimonEngine *vm, Audio::Mixer *mixer)
 	: _vm(vm), _mixer(mixer) {
-	_frameNum = 0;
-	_frameSkipped = 0;
+	_omniTV = false;
+	_playing = false;
 
-	_playing = false;
 	_leftButtonDown = false;
 	_rightButtonDown = false;
 
@@ -97,6 +96,7 @@
 	_width = _fd.readUint16BE();
 	_height = _fd.readUint16BE();
 	debug(0, "frames_count %d width %d height %d rate %d ticks %d", _framesCount, _width, _height, _frameRate, _frameTicks);
+
 	_frameSize = _width * _height;
 	_frameBuffer1 = (uint8 *)malloc(_frameSize);
 	_frameBuffer2 = (uint8 *)malloc(_frameSize);
@@ -110,70 +110,46 @@
 	return true;
 }
 
+void MoviePlayer::playOmniTV() {
+	// Load OmniTV video
+	if (_fd.isOpen() == false) {
+		_vm->_variableArray[254] = 6747;
+		return;
+	} else {
+		_vm->setBitFlag(42, false);
+		_omniTV = true;
+		startSound();
+		return;
+	}
+}
+
 void MoviePlayer::play() {
+	if (_vm->getBitFlag(40)) {
+		playOmniTV();
+		return;
+	}
+
 	if (_fd.isOpen() == false) {
-		// Load OmniTV video
-		if (_vm->getBitFlag(40)) {
-			_vm->_variableArray[254] = 6747;
-			return;
-		} else {
-			debug(0, "MoviePlayer::play: No file loaded");
-			return;
-		}
+		debug(0, "MoviePlayer::play: No file loaded");
+		return;
 	}
 
-	_mixer->stopAll();
-
 	_leftButtonDown = false;
 	_rightButtonDown = false;
 
-	_ticks = _vm->_system->getMillis();
+	_mixer->stopAll();
 
-	uint32 tag = _fd.readUint32BE();
-	if (tag == MKID_BE('WAVE')) {
-		uint32 size = _fd.readUint32BE();
-		byte *buffer = (byte *)malloc(size);
-		_fd.read(buffer, size);
-
-		Common::MemoryReadStream stream(buffer, size);
-		_bgSoundStream = makeWAVStream(stream);
-		_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
-		free(buffer);
-	}
-
 	// Resolution is smaller in Amiga verison so always clear screen
 	if (_width == 384 && _height == 280)
 		_vm->dx_clear_surfaces(480);
 
+	_ticks = _vm->_system->getMillis();
+
+	startSound();
+
 	while (_frameNum < _framesCount) {
-		decodeFrame();
-		processFrame();
-		_vm->_system->updateScreen();
-		_frameNum++;
+		handleNextFrame();
 
-		OSystem::Event event;
-		while (_vm->_system->pollEvent(event)) {
-			switch (event.type) {
-			case OSystem::EVENT_LBUTTONDOWN:
-				_leftButtonDown = true;
-				break;
-			case OSystem::EVENT_RBUTTONDOWN:
-				_rightButtonDown = true;
-				break;
-			case OSystem::EVENT_LBUTTONUP:
-				_leftButtonDown = false;
-				break;
-			case OSystem::EVENT_RBUTTONUP:
-				_rightButtonDown = false;
-				break;
-			case OSystem::EVENT_QUIT:
-				_vm->_system->quit();
-				break;
-			default:
-				break;
-			}
-		}
-
 		if (_leftButtonDown && _rightButtonDown && !_vm->getBitFlag(41)) {
 			_frameNum = _framesCount;
 		}
@@ -190,12 +166,102 @@
 	}
 }
 
+void MoviePlayer::startSound() {
+	uint32 tag = _fd.readUint32BE();
+	if (tag == MKID_BE('WAVE')) {
+		uint32 size = _fd.readUint32BE();
+		byte *buffer = (byte *)malloc(size);
+		_fd.read(buffer, size);
+
+		Common::MemoryReadStream stream(buffer, size);
+		_bgSoundStream = makeWAVStream(stream);
+		_mixer->stopHandle(_bgSound);
+		_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
+		free(buffer);
+	}
+}
+
 void MoviePlayer::close() {
 	_fd.close();
 	free(_frameBuffer1);
 	free(_frameBuffer2);
 }
 
+void MoviePlayer::nextFrame() {
+	if (!_omniTV)
+		return;
+
+	// FIXME: Never triggered!
+	if (_vm->getBitFlag(42)) {
+		_omniTV = false;
+		return;
+	}
+
+	if (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * _frameRate) / 1000 < _frameNum) {
+		copyFrame(_vm->getBackBuf(), 465, 222);
+		return;
+	}
+
+	if (_frameNum < _framesCount) {
+		decodeFrame();
+		copyFrame(_vm->getBackBuf(), 465, 222);
+		_frameNum++;
+	} else {
+		_omniTV = false;
+		close();
+		_vm->_variableArray[254] = 6747;
+	}
+}
+
+void MoviePlayer::handleNextFrame() {
+	decodeFrame();
+	processFrame();
+
+	_vm->_system->updateScreen();
+	_frameNum++;
+
+	OSystem::Event event;
+	while (_vm->_system->pollEvent(event)) {
+		switch (event.type) {
+		case OSystem::EVENT_LBUTTONDOWN:
+			_leftButtonDown = true;
+			break;
+		case OSystem::EVENT_RBUTTONDOWN:
+			_rightButtonDown = true;
+			break;
+		case OSystem::EVENT_LBUTTONUP:
+			_leftButtonDown = false;
+			break;
+		case OSystem::EVENT_RBUTTONUP:
+			_rightButtonDown = false;
+			break;
+		case OSystem::EVENT_QUIT:
+			_vm->_system->quit();
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (_leftButtonDown && _rightButtonDown && !_vm->getBitFlag(41)) {
+		_frameNum = _framesCount;
+	}
+}
+
+void MoviePlayer::copyFrame(byte *dst, uint x, uint y) {
+	uint h = _height;
+	uint w = _width;
+
+	dst += y * _vm->_screenWidth + x;
+	byte *src = _frameBuffer1;
+
+	do {
+		memcpy(dst, src, w);
+		dst += _vm->_screenWidth;
+		src += _width;
+	} while (--h);
+}
+
 void MoviePlayer::decodeZlib(uint8 *data, int size, int totalSize) {
 #ifdef USE_ZLIB
 	uint8 *temp = (uint8 *)malloc(size);
@@ -219,7 +285,9 @@
 }
 
 void MoviePlayer::decodeFrame() {
-	uint32 tag = _fd.readUint32BE();
+	uint32 tag;
+
+	tag = _fd.readUint32BE();
 	if (tag == MKID_BE('CMAP')) {
 		uint8 rgb[768];
 		byte palette[1024];
@@ -240,7 +308,9 @@
 		uint8 type = _fd.readByte();
 		uint32 size = _fd.readUint32BE();
 		debug(0, "frame %d type %d size %d", _frameNum, type, size);
+
 		_fd.read(_frameBuffer2, size);
+
 		switch (type) {
 		case 2:
 		case 3:
@@ -263,12 +333,9 @@
 }
 
 void MoviePlayer::processFrame() {
-	uint x = (_vm->_screenWidth - _width) / 2;
-	uint y = (_vm->_screenHeight - _height) / 2;
+	copyFrame(_vm->getFrontBuf(), (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2);
+	_vm->_system->copyRectToScreen(_vm->getFrontBuf(), _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
 
-	memcpy(_vm->_frontBuf, _frameBuffer1, _frameSize);
-	_vm->_system->copyRectToScreen(_vm->_frontBuf, _width, x, y, _width, _height);
-
 	if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * _frameRate) / 1000 < _frameNum + 1) ||
 		_frameSkipped > _frameRate) {
 		if (_frameSkipped > _frameRate) {

Modified: scummvm/trunk/engines/simon/animation.h
===================================================================
--- scummvm/trunk/engines/simon/animation.h	2006-04-24 07:45:57 UTC (rev 22135)
+++ scummvm/trunk/engines/simon/animation.h	2006-04-24 10:24:56 UTC (rev 22136)
@@ -40,6 +40,7 @@
 	Audio::SoundHandle _bgSound;
 	AudioStream *_bgSoundStream;
 
+	bool _omniTV;
 	bool _playing;
 	bool _leftButtonDown;
 	bool _rightButtonDown;
@@ -62,11 +63,16 @@
 
 	bool load(const char *filename);
 	void play();
+	void nextFrame();
 private:
+	void playOmniTV();
 	void close();
 
+	void copyFrame(byte *dst, uint x, uint y);
 	void decodeFrame();
+	void handleNextFrame();
 	void processFrame();
+	void startSound();
 	void decodeZlib(uint8 *data, int size, int totalSize);
 };
 

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-04-24 07:45:57 UTC (rev 22135)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-04-24 10:24:56 UTC (rev 22136)
@@ -2168,24 +2168,6 @@
 	}
 }
 
-void SimonEngine::checkZonePtrs(byte *end) {
-	uint count = ARRAYSIZE(_vgaBufferPointers);
-	VgaPointersEntry *vpe = _vgaBufferPointers;
-	do {
-		if (vpe->vgaFile1 < end && vpe->vgaFile1End > _vgaBufFreeStart ||
-				vpe->vgaFile2 < end && vpe->vgaFile2End > _vgaBufFreeStart ||
-				vpe->sfxFile < end && vpe->sfxFileEnd > _vgaBufFreeStart) {
-			vpe->vgaFile1 = NULL;
-			vpe->vgaFile1End = NULL;
-			vpe->vgaFile2 = NULL;
-			vpe->vgaFile2End = NULL;
-			vpe->sfxFile = NULL;
-			vpe->sfxFileEnd = NULL;
-		}
-
-	} while (++vpe, --count);
-}
-
 void SimonEngine::checkAnims(uint a, byte *end) {
 	VgaPointersEntry *vpe;
 
@@ -2205,6 +2187,24 @@
 	}
 }
 
+void SimonEngine::checkZonePtrs(byte *end) {
+	uint count = ARRAYSIZE(_vgaBufferPointers);
+	VgaPointersEntry *vpe = _vgaBufferPointers;
+	do {
+		if (vpe->vgaFile1 < end && vpe->vgaFile1End > _vgaBufFreeStart ||
+				vpe->vgaFile2 < end && vpe->vgaFile2End > _vgaBufFreeStart ||
+				vpe->sfxFile < end && vpe->sfxFileEnd > _vgaBufFreeStart) {
+			vpe->vgaFile1 = NULL;
+			vpe->vgaFile1End = NULL;
+			vpe->vgaFile2 = NULL;
+			vpe->vgaFile2End = NULL;
+			vpe->sfxFile = NULL;
+			vpe->sfxFileEnd = NULL;
+		}
+
+	} while (++vpe, --count);
+}
+
 void SimonEngine::set_video_mode_internal(uint16 mode, uint16 vga_res_id) {
 	uint num, num_lines;
 	VgaPointersEntry *vpe;
@@ -2812,6 +2812,9 @@
 		}
 	}
 
+	if (getGameType() == GType_FF)
+		_moviePlay->nextFrame();
+
 	animateSprites();
 	if (_drawImagesDebug)
 		animateSpritesDebug();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list