[Scummvm-cvs-logs] SF.net SVN: scummvm:[39977] scummvm/trunk/engines/sword2

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Sat Apr 18 10:37:23 CEST 2009


Revision: 39977
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39977&view=rev
Author:   Hkz
Date:     2009-04-18 08:37:22 +0000 (Sat, 18 Apr 2009)

Log Message:
-----------
sword2: add support for BS2 PSX demo

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/resman.cpp
    scummvm/trunk/engines/sword2/screen.cpp
    scummvm/trunk/engines/sword2/sound.cpp
    scummvm/trunk/engines/sword2/sprite.cpp
    scummvm/trunk/engines/sword2/sword2.cpp

Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp	2009-04-18 06:45:08 UTC (rev 39976)
+++ scummvm/trunk/engines/sword2/resman.cpp	2009-04-18 08:37:22 UTC (rev 39977)
@@ -520,6 +520,7 @@
 		} else  {            // In PSX version there is no resource header for audio files,
 			return WAV_FILE; // but hopefully all audio files got first 16 bytes zeroed,
 		}                    // Allowing us to check for this condition.
+							 // Alas, this doesn't work with PSX DEMO audio files.
 
 	}
 }

Modified: scummvm/trunk/engines/sword2/screen.cpp
===================================================================
--- scummvm/trunk/engines/sword2/screen.cpp	2009-04-18 06:45:08 UTC (rev 39976)
+++ scummvm/trunk/engines/sword2/screen.cpp	2009-04-18 08:37:22 UTC (rev 39977)
@@ -549,6 +549,15 @@
 }
 
 void Screen::processImage(BuildUnit *build_unit) {
+
+	// We have some problematic animation frames in PSX demo (looks like there is missing data),
+	// so we just skip them.
+	if ( (Sword2Engine::isPsx() &&  _vm->_logic->readVar(DEMO)) &&
+		 ((build_unit->anim_resource == 369 && build_unit->anim_pc == 0) || 
+		 (build_unit->anim_resource == 296 && build_unit->anim_pc == 5)  ||
+		 (build_unit->anim_resource == 534 && build_unit->anim_pc == 13)) ) 
+		return;
+
 	byte *file = _vm->_resman->openResource(build_unit->anim_resource);
 	byte *colTablePtr = NULL;
 
@@ -662,10 +671,10 @@
 
 	uint32 rv = drawSprite(&spriteInfo);
 	if (rv) {
-		error("Driver Error %.8x with sprite %s (%d) in processImage",
+		error("Driver Error %.8x with sprite %s (%d, %d) in processImage",
 			rv,
 			_vm->_resman->fetchName(build_unit->anim_resource),
-			build_unit->anim_resource);
+			build_unit->anim_resource, build_unit->anim_pc);
 	}
 
 	// release the anim resource

Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp	2009-04-18 06:45:08 UTC (rev 39976)
+++ scummvm/trunk/engines/sword2/sound.cpp	2009-04-18 08:37:22 UTC (rev 39977)
@@ -267,7 +267,11 @@
 		if (!_fxQueue[i].resource) {
 			byte *data = _vm->_resman->openResource(res);
 
-			assert(_vm->_resman->fetchType(data) == WAV_FILE);
+			// Check that we really have a WAV file here, alas this
+			// check is useless with psx demo game, because psx audio files
+			// are headerless and there is no way to check the type
+			if (!(Sword2Engine::isPsx() && (_vm->_features & GF_DEMO)))
+				assert(_vm->_resman->fetchType(data) == WAV_FILE);
 
 			uint32 len = _vm->_resman->fetchLen(res);
 

Modified: scummvm/trunk/engines/sword2/sprite.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sprite.cpp	2009-04-18 06:45:08 UTC (rev 39976)
+++ scummvm/trunk/engines/sword2/sprite.cpp	2009-04-18 08:37:22 UTC (rev 39977)
@@ -527,6 +527,10 @@
 
 				decompData = decompressHIF(s->data, tempBuf);
 
+				// Check that we correctly decompressed data
+				if(!decompData)
+					return RDERR_DECOMPRESSION;
+
 				s->w = (decompData / (s->h / 2)) * 2;
 				byte *tempBuf2 = (byte *)malloc(s->w * s->h * 10);
 				memset(tempBuf2, 0, s->w * s->h * 2);
@@ -562,6 +566,11 @@
 				} else {
 					byte *tempBuf = (byte *)malloc(s->w * s->h);
 					uint32 decompData = decompressHIF(s->data, tempBuf);
+
+					// Check that we correctly decompressed data
+					if(!decompData)
+						return RDERR_DECOMPRESSION;
+
 					s->w = (decompData / (s->h / 2));
 					sprite = (byte *)malloc(s->w * s->h);
 				

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2009-04-18 06:45:08 UTC (rev 39976)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2009-04-18 08:37:22 UTC (rev 39977)
@@ -69,6 +69,7 @@
 	{"sword2", "Broken Sword 2: The Smoking Mirror", 0, "players.clu" },
 	{"sword2alt", "Broken Sword 2: The Smoking Mirror (alt)", 0, "r2ctlns.ocx" },
 	{"sword2psx", "Broken Sword 2: The Smoking Mirror (PlayStation)", 0, "screens.clu"},
+	{"sword2psxdemo", "Broken Sword 2: The Smoking Mirror (PlayStation/Demo)", Sword2::GF_DEMO, "rdemo.str"},
 	{"sword2demo", "Broken Sword 2: The Smoking Mirror (Demo)", Sword2::GF_DEMO, "players.clu" },
 	{NULL, NULL, 0, NULL}
 };
@@ -264,13 +265,13 @@
 	Common::File::addDefaultDirectory(_gameDataDir.getChild("video"));
 	Common::File::addDefaultDirectory(_gameDataDir.getChild("smacks"));
 
-	if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo"))
+	if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo"))
 		_features = GF_DEMO;
 	else
 		_features = 0;
 
 	// Check if we are running PC or PSX version.
-	if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psx"))
+	if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psx") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo"))
 		Sword2Engine::_platform = Common::kPlatformPSX;
 	else
 		Sword2Engine::_platform = Common::kPlatformPC;


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