[Scummvm-cvs-logs] SF.net SVN: scummvm: [21980] scummvm/trunk/engines/kyra

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Mon Apr 17 10:40:01 CEST 2006


Revision: 21980
Author:   vinterstum
Date:     2006-04-17 10:39:08 -0700 (Mon, 17 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21980&view=rev

Log Message:
-----------
Implements the end credits, and disables fast forwarding in the intro.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/sequences_v1.cpp
Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2006-04-17 14:32:46 UTC (rev 21979)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2006-04-17 17:39:08 UTC (rev 21980)
@@ -817,6 +817,9 @@
 			updateKyragemFading();
 		}
 
+		if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE))
+			_skipFlag = false;
+			
 		if (amount > 0 && !_skipFlag) {
 			_system->delayMillis((amount > 10) ? 10 : amount);
 		}

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2006-04-17 14:32:46 UTC (rev 21979)
+++ scummvm/trunk/engines/kyra/screen.h	2006-04-17 17:39:08 UTC (rev 21980)
@@ -170,6 +170,7 @@
 	int _curPage;
 	uint8 *_currentPalette;
 	uint8 *_shapePages[2];
+	FontId _currentFont;
 
 	const ScreenDim *_curDim;
 	
@@ -186,7 +187,6 @@
 	uint8 *_saveLoadPage[8];
 	uint8 *_screenPalette;
 	uint8 *_palettes[3];
-	FontId _currentFont;
 	Font _fonts[FID_NUM];
 	uint8 _textColorsMap[16];
 	uint8 *_decodeShapeBuffer;

Modified: scummvm/trunk/engines/kyra/sequences_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v1.cpp	2006-04-17 14:32:46 UTC (rev 21979)
+++ scummvm/trunk/engines/kyra/sequences_v1.cpp	2006-04-17 17:39:08 UTC (rev 21980)
@@ -998,24 +998,148 @@
 void KyraEngine::seq_playCredits() {
 	debugC(9, kDebugLevelMain, "KyraEngine::seq_playCredits()");
 	static const uint8 colorMap[] = { 0, 0, 0xC, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+	static const char stringTerms[] = { 0x5, 0xd, 0x0};
+	static const int numStrings = 250;
+	
+	struct {
+		int16 x, y;
+		uint8 code;
+		uint8 unk1;
+		Screen::FontId font;
+		uint8 *str;
+	} strings[numStrings];
+	
+	memset(strings, 0, sizeof(strings));
+	
 	_screen->hideMouse();
 	uint32 sz = 0;
 	if (_features & GF_FLOPPY) {
 		_screen->loadFont(Screen::FID_CRED6_FNT, _res->fileData("CREDIT6.FNT", &sz));
 		_screen->loadFont(Screen::FID_CRED8_FNT, _res->fileData("CREDIT8.FNT", &sz));
-	}
-	loadBitmap("CHALET.CPS", 2, 2, _screen->_currentPalette);
+	} else
+		_screen->setFont(Screen::FID_8_FNT);
+	
+	loadBitmap("CHALET.CPS", 4, 4, _screen->_currentPalette);
 	_screen->setScreenPalette(_screen->_currentPalette);
+	
 	_screen->setCurPage(0);
 	_screen->clearCurPage();
-	_screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0);
 	_screen->setTextColorMap(colorMap);
 	_screen->_charWidth = -1;
 	snd_playWanderScoreViaMap(53, 1);
-	// delete
-	_screen->updateScreen();
-	// XXX
-	delay(120 * _tickLength); // wait until user presses escape normally
+
+	uint8 *buffer = 0;
+	uint32 size;
+	
+	if (_features & GF_FLOPPY) {
+		Common::File file;
+		if (file.open("CREDITS.TXT")) {
+			size = file.size();
+			buffer = new uint8[size];
+			file.read(buffer, size);
+			file.close();
+		}
+	} else {
+		buffer = _res->fileData("CREDITS.TXT", &size);	
+	}
+
+	assert(buffer);
+
+	uint8 *nextString = buffer;
+	uint8 *currentString = buffer;
+	int currentY = 200;
+	
+	for (int i = 0; i < numStrings; i++) {
+		if (*nextString == 0)
+			break;
+			
+		currentString = nextString;
+		nextString = (uint8 *)strpbrk((const char *)currentString, stringTerms);
+		if (!nextString)
+			nextString = (uint8 *)strchr((const char *)currentString, 0);
+		
+		strings[i].code = nextString[0];
+		*nextString = 0;
+		if (strings[i].code != 0)
+			nextString++;
+		
+		if (*currentString == 3 || *currentString == 4) {
+			strings[i].unk1 = *currentString;
+			currentString++;
+		}
+		
+		if (*currentString == 1) {
+		   	currentString++;
+			if (_features & GF_FLOPPY)
+				_screen->setFont(Screen::FID_CRED6_FNT);
+		} else {
+			if (*currentString == 2)
+				currentString++;
+			if (_features & GF_FLOPPY)
+				_screen->setFont(Screen::FID_CRED8_FNT);
+		}
+		strings[i].font = _screen->_currentFont;
+
+		if (strings[i].unk1 == 3) 
+			strings[i].x = 157 - _screen->getTextWidth((const char *)currentString);
+		else if (strings[i].unk1 == 4)
+			strings[i].x = 161;
+		else
+			strings[i].x = (320  - _screen->getTextWidth((const char *)currentString)) / 2 + 1;
+		
+		strings[i].y = currentY;
+		if (strings[i].code != 5)
+			currentY += 10;
+		
+		strings[i].str = currentString;
+	}
+
+	_screen->setCurPage(2);
+
+	OSystem::Event event;	
+	bool finished = false;
+	int bottom = 201;
+	uint32 startLoop, waitTime;
+	while (!finished) {
+		startLoop = _system->getMillis();
+		if (bottom > 175) {
+			_screen->copyRegion(8, 32, 8, 32, 312, 128, 4, 2);
+			bottom = 0;
+			
+			for (int i = 0; i < numStrings; i++) {
+				if (strings[i].y < 200 && strings[i].y > 0) {
+					if (strings[i].font != _screen->_currentFont)
+						_screen->setFont(strings[i].font);
+					_screen->printText((const char *)strings[i].str, strings[i].x, strings[i].y, 15, 0);
+				}
+				strings[i].y--;
+				if (strings[i].y > bottom)
+					bottom = strings[i].y;
+			}
+			_screen->copyRegion(8, 32, 8, 32, 312, 128, 2, 0);
+			_screen->updateScreen();
+		}
+
+		while (_system->pollEvent(event)) {
+			switch (event.type) {
+			case OSystem::EVENT_KEYDOWN:
+				finished = true;
+				break;
+			case OSystem::EVENT_QUIT:
+				quitGame();
+				break;
+			default:
+				break;
+			}
+		}
+		
+		waitTime = startLoop + _tickLength * 5 - _system->getMillis();
+		if (waitTime > 0)
+			_system->delayMillis(waitTime);	
+	}
+	
+	delete[] buffer;
+	
 	_screen->fadeToBlack();
 	_screen->clearCurPage();
 	_screen->showMouse();


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