[Scummvm-cvs-logs] SF.net SVN: scummvm:[35704] scummvm/trunk/engines/saga/introproc_fta2.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Jan 3 17:01:58 CET 2009


Revision: 35704
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35704&view=rev
Author:   thebluegr
Date:     2009-01-03 16:01:58 +0000 (Sat, 03 Jan 2009)

Log Message:
-----------
Simplified the Smacker video playing code for FTA2

Modified Paths:
--------------
    scummvm/trunk/engines/saga/introproc_fta2.cpp

Modified: scummvm/trunk/engines/saga/introproc_fta2.cpp
===================================================================
--- scummvm/trunk/engines/saga/introproc_fta2.cpp	2009-01-03 14:27:19 UTC (rev 35703)
+++ scummvm/trunk/engines/saga/introproc_fta2.cpp	2009-01-03 16:01:58 UTC (rev 35704)
@@ -45,25 +45,18 @@
 	virtual void setPalette(byte *pal);
 public:
 	MoviePlayerSMK(SagaEngine *vm): _vm(vm), SMKPlayer(vm->_mixer) {
-		_frameSkipped = 0;
-		_ticks = 0;
+		_eventMan = _vm->_system->getEventManager();
 	}
-	~MoviePlayerSMK(void) { closeFile(); }
+	~MoviePlayerSMK(void) { }
 
-	bool load(const char *filename) {
-		_skipVideo = false;
-		return loadFile(filename);
-	}
-	void playVideo();
-	void stopVideo() { closeFile(); }
+	bool playVideo(const char *filename);
 private:
-	bool processFrame();
+	void processFrame();
+	void processEvents();
 	PalEntry _smkPalette[256];
-	uint32 _ticks;
-	uint16 _frameSkipped;
 	bool _skipVideo;
 	SagaEngine *_vm;
-	Common::Event _event;
+	Common::EventManager *_eventMan;
 };
 
 void MoviePlayerSMK::setPalette(byte *pal) {
@@ -76,31 +69,43 @@
 	_vm->_gfx->setPalette(_smkPalette, true);
 }
 
-void MoviePlayerSMK::playVideo() {
-	while (getCurFrame() < getFrameCount() && !_skipVideo && !_vm->shouldQuit()) {
-		Common::EventManager *eventMan = _vm->_system->getEventManager();
-		// process events, and skip video if esc is pressed
-		while (eventMan->pollEvent(_event)) {
-			switch (_event.type) {
-				case Common::EVENT_KEYDOWN:
-					if (_event.kbd.keycode == Common::KEYCODE_ESCAPE)
-						_skipVideo = true;
-					break;
-				case Common::EVENT_RTL:
-				case Common::EVENT_QUIT:
+void MoviePlayerSMK::processEvents() {
+	Common::Event curEvent;
+	// Process events, and skip video if esc is pressed
+	while (_eventMan->pollEvent(curEvent)) {
+		switch (curEvent.type) {
+			case Common::EVENT_KEYDOWN:
+				if (curEvent.kbd.keycode == Common::KEYCODE_ESCAPE)
 					_skipVideo = true;
-					break;
-				default:
-					break;
-			}
+				break;
+			case Common::EVENT_RTL:
+			case Common::EVENT_QUIT:
+				_skipVideo = true;
+				break;
+			default:
+				break;
 		}
-		decodeNextFrame();
-		if (processFrame())
-			_vm->_system->updateScreen();
 	}
 }
 
-bool MoviePlayerSMK::processFrame() {
+bool MoviePlayerSMK::playVideo(const char *filename) {
+	_skipVideo = false;
+	if (!loadFile(filename))
+		return false;
+
+	while (getCurFrame() < getFrameCount() && !_skipVideo && !_vm->shouldQuit()) {
+		processEvents();
+		processFrame();			
+	}
+
+	closeFile();
+
+	return true;
+}
+
+void MoviePlayerSMK::processFrame() {
+	decodeNextFrame();
+
 	Graphics::Surface *screen = _vm->_system->lockScreen();
 	copyFrameToBuffer((byte *)screen->pixels,
 						(_vm->getDisplayInfo().width - getWidth()) / 2,
@@ -108,32 +113,18 @@
 						_vm->getDisplayInfo().width);
 	_vm->_system->unlockScreen();
 
-	if (!getAudioLag() || getFrameWaitTime() || _frameSkipped > getFrameRate()) {
-		if (_frameSkipped > getFrameRate()) {
-			warning("force frame %i redraw", getCurFrame());
-			_frameSkipped = 0;
-		}
+	uint32 waitTime = getFrameWaitTime();
 
-		if (getAudioLag() > 0) {
-			while (getAudioLag() > 0) {
-				_vm->_system->delayMillis(10);
-			}
-			// In case the background sound ends prematurely, update
-			// _ticks so that we can still fall back on the no-sound
-			// sync case for the subsequent frames.
-			_ticks = _vm->_system->getMillis();
-		} else {
-			_ticks += getFrameDelay();
-			//while (_vm->_system->getMillis() < _ticks)	// FIXME
-				_vm->_system->delayMillis(10);
-		}
-
-		return true;
+	if (!waitTime) {
+		warning("dropped frame %i", getCurFrame());
+		return;
 	}
 
-	warning("dropped frame %i", getCurFrame());
-	_frameSkipped++;
-	return false;
+	// Update the screen
+	_vm->_system->updateScreen();
+
+	// Wait before showing the net frame
+	_vm->_system->delayMillis(waitTime);
 }
 
 int Scene::FTA2StartProc() {
@@ -142,21 +133,15 @@
 	_vm->_gfx->showCursor(false);
 
 	// Show Ignite logo
-	if (smkPlayer->load("trimark.smk")) {
-		debug(0, "Playing video trimark.smk");
-		smkPlayer->playVideo();
-		smkPlayer->stopVideo();
-	} else {
+	debug(0, "Playing video trimark.smk");
+	if (!smkPlayer->playVideo("trimark.smk")) {
 		warning("Failed to load video file trimark.smk");
 	}
 
 	// Play introduction
-	if (smkPlayer->load("intro.smk")) {
-		debug(0, "Playing video intro.smk");
-		smkPlayer->playVideo();
-		smkPlayer->stopVideo();
-	} else {
-		warning("Failed to load video file intro.smk");
+	debug(0, "Playing video intro.smk");
+	if (!smkPlayer->playVideo("intro.smk")) {
+		warning("Failed to load video file intro.smk");	
 	}
 
 	// Cleanup
@@ -196,11 +181,8 @@
 	_vm->_gfx->showCursor(false);
 
 	// Play ending
-	if (smkPlayer->load(videoName)) {
-		debug(0, "Playing video %s", videoName);
-		smkPlayer->playVideo();
-		smkPlayer->stopVideo();
-	} else {
+	debug(0, "Playing video %s", videoName);
+	if (!smkPlayer->playVideo(videoName)) {
 		warning("Failed to load video file %s", videoName);
 	}
 


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