[Scummvm-cvs-logs] CVS: scummvm/sword2 function.cpp,1.44,1.45

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Wed Dec 31 15:33:04 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv21307

Modified Files:
	function.cpp 
Log Message:
Some tweaking of the new credits code. It is no longer necessary to have
to have the credits.bmp file, though if you don't you won't see the
"Smacker" logo. (Whether or not this is a feature is open to debate.)

Happy New Year!


Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- function.cpp	31 Dec 2003 13:14:07 -0000	1.44
+++ function.cpp	31 Dec 2003 23:32:40 -0000	1.45
@@ -390,7 +390,8 @@
 	Memory *sprite;
 };
 
-#define CREDITS_FONT_HEIGHT 20
+#define CREDITS_FONT_HEIGHT 25
+#define CREDITS_LINE_SPACING 20
 
 int32 Logic::fnPlayCredits(int32 *params) {
 	// This function just quits the game if this is the playable demo, ie.
@@ -455,27 +456,34 @@
 
 	f.open("credits.bmp");
 
-	if (!f.isOpen()) {
-		warning("Can't find credits.bmp");
-		return IR_CONT;
-	}
-
-	uint16 logoWidth = f.readUint16LE();
-	uint16 logoHeight = f.readUint16LE();
-
+	uint16 logoWidth = 0;
+	uint16 logoHeight = 0;
+	uint8 *logoData = NULL;
 	uint8 palette[1024];
 
-	for (i = 0; i < 256; i++) {
-		palette[i * 4 + 0] = f.readByte() << 2;
-		palette[i * 4 + 1] = f.readByte() << 2;
-		palette[i * 4 + 2] = f.readByte() << 2;
-		palette[i * 4 + 3] = 0;
-	}
+	if (f.isOpen()) {
+		logoWidth = f.readUint16LE();
+		logoHeight = f.readUint16LE();
 
-	uint8 *logoData = (uint8 *) malloc(logoWidth * logoHeight);
+		for (i = 0; i < 256; i++) {
+			palette[i * 4 + 0] = f.readByte() << 2;
+			palette[i * 4 + 1] = f.readByte() << 2;
+			palette[i * 4 + 2] = f.readByte() << 2;
+			palette[i * 4 + 3] = 0;
+		}
 
-	f.read(logoData, logoWidth * logoHeight);
-	f.close();
+		logoData = (uint8 *) malloc(logoWidth * logoHeight);
+
+		f.read(logoData, logoWidth * logoHeight);
+		f.close();
+	} else {
+		warning("Can't find credits.bmp");
+		memset(palette, 0, sizeof(palette));
+		palette[14 * 4 + 0] = 252;
+		palette[14 * 4 + 1] = 252;
+		palette[14 * 4 + 2] = 252;
+		palette[14 * 4 + 3] = 0;
+	}
 
 	_vm->_graphics->setPalette(0, 256, palette, RDPAL_INSTANT);
 
@@ -551,7 +559,7 @@
 				lineTop += logoHeight;
 			} else {
 				creditsLines[lineCount].height = CREDITS_FONT_HEIGHT;
-				lineTop += CREDITS_FONT_HEIGHT;
+				lineTop += CREDITS_LINE_SPACING;
 			}
 
 			if (strlen(textLine) > 0)
@@ -608,13 +616,16 @@
 	spriteInfo.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION | RDSPR_TRANS;
 	spriteInfo.blend = 0;
 
+	int startLine = 0;
 	int scrollPos = 0;
 
 	while (scrollPos < lineTop + CREDITS_FONT_HEIGHT) {
+		bool foundStartLine = false;
+
 		_vm->_graphics->clearScene();
 		_vm->_graphics->setNeedFullRedraw();
 
-		for (i = 0; i < lineCount; i++) {
+		for (i = startLine; i < lineCount; i++) {
 			// Free any sprites that have scrolled off the screen
 
 			if (creditsLines[i].top + creditsLines[i].height < scrollPos) {
@@ -628,6 +639,11 @@
 					creditsLines[i].str = NULL;
 				}
 			} else if (creditsLines[i].top < scrollPos + 400) {
+				if (!foundStartLine) {
+					startLine = i;
+					foundStartLine = true;
+				}
+
 				if (!creditsLines[i].sprite) {
 					debug(2, "Creating sprite '%s'", creditsLines[i].str);
 					creditsLines[i].sprite = _vm->_fontRenderer->makeTextSprite((uint8 *) creditsLines[i].str, 600, 14, _vm->_speechFontId, 0);
@@ -658,8 +674,10 @@
 					break;
 				}
 
-				_vm->_graphics->drawSprite(&spriteInfo);
-			}
+				if (spriteInfo.data)
+					_vm->_graphics->drawSprite(&spriteInfo);
+			} else
+				break;
 		}
 
 		_vm->_graphics->updateDisplay();





More information about the Scummvm-git-logs mailing list