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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Jul 31 18:37:43 CEST 2006


Revision: 23648
Author:   lordhoto
Date:     2006-07-31 09:37:34 -0700 (Mon, 31 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23648&view=rev

Log Message:
-----------
Yet more kyra3 init code.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra3.cpp
    scummvm/trunk/engines/kyra/kyra3.h
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/resource.h
    scummvm/trunk/engines/kyra/staticres.cpp
Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-31 14:50:44 UTC (rev 23647)
+++ scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-31 16:37:34 UTC (rev 23648)
@@ -47,6 +47,13 @@
 	_itemBuffer1 = _itemBuffer2 = 0;
 	_mouseSHPBuf = 0;
 	_tableBuffer1 = _tableBuffer2 = 0;
+	_unkBuffer5 = _unkBuffer6 = _unkBuffer7 = _unkBuffer9 = 0;
+	_costpalData = 0;
+	_unkWSAPtr = 0;
+	memset(_unkShapeTable, 0, sizeof(_unkShapeTable));
+	_scoreFile = 0;
+	_cCodeFile = 0;
+	_scenesList = 0;
 }
 
 KyraEngine_v3::~KyraEngine_v3() {
@@ -63,6 +70,18 @@
 	delete [] _shapePoolBuffer;
 
 	delete [] _mouseSHPBuf;
+
+	delete [] _unkBuffer5;
+	delete [] _unkBuffer6;
+	delete [] _unkBuffer7;
+	delete [] _unkBuffer9;
+
+	delete [] _costpalData;
+	delete [] _unkWSAPtr;
+
+	delete [] _scoreFile;
+	delete [] _cCodeFile;
+	delete [] _scenesList;
 }
 
 int KyraEngine_v3::setupGameFlags() {
@@ -408,10 +427,6 @@
 			if (_mousePressFlag) {
 				// TODO: Flash the text
 				command = item;
-
-				// TODO: For now, only playing the intro and quitting is supported
-				if (command != 1 && command != 3)
-					command = -1;
 			}
 		}
 	}
@@ -525,6 +540,31 @@
 
 void KyraEngine_v3::realInit() {
 	debugC(9, kDebugLevelMain, "KyraEngine::realInit()");
+
+	// XXX sound specific stuff
+
+	_unkBuffer5 = new uint8[500];
+	_unkBuffer6 = new uint8[200];
+	_unkBuffer7 = new uint8[600];
+	_costpalData = new uint8[864];
+	_unkBuffer9 = new uint8[3618];
+	_unkWSAPtr = new uint8[624];
+
+	musicUpdate(0);
+
+	_unkPage2 = new uint8[64000];
+
+	musicUpdate(0);
+	musicUpdate(0);
+
+	assert(loadLanguageFile("ITEMS.", _itemList));
+	assert(loadLanguageFile("C_CODE.", _cCodeFile));
+	assert(loadLanguageFile("SCENES.", _scenesList));
+
+	assert(_unkBuffer5 && _unkBuffer6 && _unkBuffer7 && _costpalData && _unkBuffer9 &&
+			_unkWSAPtr && _unkPage2 && _itemList && _cCodeFile && _scenesList);
+
+	musicUpdate(0);
 }
 
 #pragma mark -
@@ -770,4 +810,50 @@
 	_screen->_curPage = 0;
 }
 
+#pragma mark -
+
+int KyraEngine_v3::getMaxFileSize(const char *file) {
+	debugC(9, kDebugLevelMain, "KyraEngine::getMaxFileSize(%s)", file);
+	int size = 0;
+
+	char buffer[32];
+
+	for (int i = 0; i < _languageExtensionSize; ++i) {
+		strncpy(buffer, file, 32);
+		size = MAX<uint32>(size, _res->getFileSize(appendLanguage(buffer, i, sizeof(buffer))));
+	}
+
+	return size + 20;
+}
+
+char *KyraEngine_v3::appendLanguage(char *buf, int lang, int bufSize) {
+	debugC(9, kDebugLevelMain, "KyraEngine::appendLanguage([%p|'%s'], %d, %d)", (const void*)buf, buf, lang, bufSize);
+	assert(lang < _languageExtensionSize);
+
+	int size = strlen(buf) + strlen(_languageExtension[lang]);
+
+	if (size > bufSize) {
+		warning("buffer too small to append language extension");
+		return 0;
+	}
+
+	char *temp = buf + strlen(buf);
+	bufSize -= strlen(buf);
+
+	strncat(temp, _languageExtension[lang], bufSize);
+
+	return buf;
+}
+
+bool KyraEngine_v3::loadLanguageFile(const char *file, uint8 *&buffer) {
+	debugC(9, kDebugLevelMain, "KyraEngine::loadLanguageFile('%s', %p)", file, (const void*)buffer);
+
+	uint32 size = 0;
+	char nBuf[32];
+	strncpy(nBuf, file, 32);
+	buffer = _res->fileData(appendLanguage(nBuf, _lang, sizeof(nBuf)), &size);
+
+	return size != 0 && buffer != 0;
+}
+
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/kyra3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.h	2006-07-31 14:50:44 UTC (rev 23647)
+++ scummvm/trunk/engines/kyra/kyra3.h	2006-07-31 16:37:34 UTC (rev 23648)
@@ -85,6 +85,22 @@
 	uint8 *_unkPage1;
 	uint8 *_unkPage2;
 
+	uint8 *_unkBuffer5;
+	uint8 *_unkBuffer6;
+	uint8 *_unkBuffer7;
+	uint8 *_unkBuffer9;
+
+	uint8 *_costpalData;
+
+	uint8 *_unkWSAPtr;
+
+	uint8 *_unkShapeTable[20];
+
+	// translation stuff
+	uint8 *_scoreFile;
+	uint8 *_cCodeFile;
+	uint8 *_scenesList;
+
 	// interface?
 	uint8 *_interfaceCPS1;
 	uint8 *_interfaceCPS2;
@@ -99,6 +115,8 @@
 	uint8 *_itemBuffer1;
 	uint8 *_itemBuffer2;
 
+	uint8 *_itemList;
+
 	void initItems();
 
 	// used for CSH loading and some sound stuff (maybe voice files?)
@@ -116,6 +134,16 @@
 
 	int addShapeToTable(uint8 *buf, int id, int shapeNum);
 	uint8 *findShapeInTable(int id);
+
+	// resource specific
+private:
+	static const char *_languageExtension[];
+	static const int _languageExtensionSize;
+
+	int getMaxFileSize(const char *file);
+	char *appendLanguage(char *buf, int lang, int bufSize);
+
+	bool loadLanguageFile(const char *file, uint8 *&buffer);
 };
 
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2006-07-31 14:50:44 UTC (rev 23647)
+++ scummvm/trunk/engines/kyra/resource.cpp	2006-07-31 16:37:34 UTC (rev 23648)
@@ -214,6 +214,38 @@
 	return false;
 }
 
+uint32 Resource::getFileSize(const char *file) {
+	Common::List<ResourceFile*>::iterator start = _pakfiles.begin();
+
+	Common::File temp;
+	if (temp.open(file))
+		return temp.size();
+
+	for (;start != _pakfiles.end(); ++start) {
+		uint32 size = (*start)->getFileSize(file);
+		
+		if (size)
+			return size;
+	}
+
+	return 0;
+}
+
+bool Resource::loadFileToBuf(const char *file, void *buf, uint32 maxSize) {
+	Common::File tempHandle;
+	uint32 size = 0;
+	if (!fileHandle(file, &size, tempHandle))
+		return false;
+
+	if (size > maxSize)
+		return false;
+
+	memset(buf, 0, maxSize);
+	tempHandle.read(buf, size);
+
+	return true;
+}
+
 ///////////////////////////////////////////
 // Pak file manager
 #define PAKFile_Iterate Common::List<PakChunk>::iterator start=_files.begin();start != _files.end(); ++start

Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h	2006-07-31 14:50:44 UTC (rev 23647)
+++ scummvm/trunk/engines/kyra/resource.h	2006-07-31 16:37:34 UTC (rev 23648)
@@ -105,12 +105,15 @@
 	void unloadPakFile(const Common::String &filename);
 	bool isInPakList(const Common::String &filename);
 
+	uint32 getFileSize(const char *file);
 	uint8* fileData(const char *file, uint32 *size);
 	// it gives back a file handle (used for the speech player)
 	// it could be that the needed file is embedded in the returned
 	// handle
 	bool fileHandle(const char *file, uint32 *size, Common::File &filehandle);
 
+	bool loadFileToBuf(const char *file, void *buf, uint32 maxSize); 
+
 protected:
 	KyraEngine *_engine;
 	Common::List<ResourceFile*> _pakfiles;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2006-07-31 14:50:44 UTC (rev 23647)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2006-07-31 16:37:34 UTC (rev 23648)
@@ -1289,4 +1289,14 @@
 
 const int KyraEngine_v3::_soundListSize = ARRAYSIZE(KyraEngine_v3::_soundList);
 
+const char *KyraEngine_v3::_languageExtension[] = {
+	"TRE",
+	"TRF",
+	"TRG"/*,
+	"TRI",		Italian and Spanish was never included
+	"TRS"*/
+};
+
+const int KyraEngine_v3::_languageExtensionSize = ARRAYSIZE(KyraEngine_v3::_languageExtension);
+
 } // End of namespace Kyra


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