[Scummvm-cvs-logs] SF.net SVN: scummvm: [26836] scummvm/trunk/engines/cine

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun May 13 18:07:34 CEST 2007


Revision: 26836
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26836&view=rev
Author:   cyx
Date:     2007-05-13 09:07:33 -0700 (Sun, 13 May 2007)

Log Message:
-----------
removed duplicated code (BASESON datafiles can be loaded with the existing bundle related functions)

Modified Paths:
--------------
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cine/cine.h
    scummvm/trunk/engines/cine/module.mk
    scummvm/trunk/engines/cine/object.cpp
    scummvm/trunk/engines/cine/part.cpp
    scummvm/trunk/engines/cine/part.h
    scummvm/trunk/engines/cine/sfx_player.cpp

Removed Paths:
-------------
    scummvm/trunk/engines/cine/resource.cpp
    scummvm/trunk/engines/cine/resource.h

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/cine.cpp	2007-05-13 16:07:33 UTC (rev 26836)
@@ -113,9 +113,6 @@
 
 	mainLoop(1);
 
-	if (g_cine->getGameType() == Cine::GType_FW)
-		snd_clearBasesonEntries();
-
 	delete g_sfxPlayer;
 	delete g_soundDriver;
 	return 0;
@@ -138,16 +135,9 @@
 	
 	loadTextData("texte.dat", textDataPtr);
 
-	switch (g_cine->getGameType()) {
-	case Cine::GType_FW:
-		snd_loadBasesonEntries("BASESON.SND");
-		break;
-	case Cine::GType_OS:
-		if (!(g_cine->getFeatures() & GF_DEMO)) {
-			loadPoldatDat("poldat.dat");
-			loadErrmessDat("errmess.dat");
-		}
-		break;
+	if (g_cine->getGameType() == Cine::GType_OS && !(g_cine->getFeatures() & GF_DEMO)) {
+		loadPoldatDat("poldat.dat");
+		loadErrmessDat("errmess.dat");
 	}
 
 	for (i = 0; i < NUM_MAX_OBJECT; i++) {

Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/cine.h	2007-05-13 16:07:33 UTC (rev 26836)
@@ -36,7 +36,6 @@
 #include "cine/script.h"
 #include "cine/part.h"
 #include "cine/prc.h"
-#include "cine/resource.h"
 #include "cine/msg.h"
 #include "cine/bg.h"
 #include "cine/pal.h"

Modified: scummvm/trunk/engines/cine/module.mk
===================================================================
--- scummvm/trunk/engines/cine/module.mk	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/module.mk	2007-05-13 16:07:33 UTC (rev 26836)
@@ -14,7 +14,6 @@
 	part.o \
 	prc.o \
 	rel.o \
-	resource.o \
 	script.o \
 	sfx_player.o \
 	sound_driver.o \

Modified: scummvm/trunk/engines/cine/object.cpp
===================================================================
--- scummvm/trunk/engines/cine/object.cpp	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/object.cpp	2007-05-13 16:07:33 UTC (rev 26836)
@@ -30,7 +30,6 @@
 #include "cine/cine.h"
 #include "cine/object.h"
 #include "cine/part.h"
-#include "cine/resource.h"
 #include "cine/various.h"
 
 namespace Cine {

Modified: scummvm/trunk/engines/cine/part.cpp
===================================================================
--- scummvm/trunk/engines/cine/part.cpp	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/part.cpp	2007-05-13 16:07:33 UTC (rev 26836)
@@ -68,7 +68,7 @@
 		partFileHandle.readUint32BE(); // unused
 	}
 
-	if (g_cine->getGameType() == Cine::GType_FW && g_cine->getPlatform() == Common::kPlatformPC)
+	if (g_cine->getGameType() == Cine::GType_FW && g_cine->getPlatform() == Common::kPlatformPC && strcmp(partName, "BASESON.SND") != 0)
 		loadPal(partName);
 }
 
@@ -420,6 +420,25 @@
 	return dataPtr;
 }
 
+byte *readBundleSoundFile(const char *entryName) {
+	int16 index;
+	byte *data = 0;
+	char previousPartName[15] = "";
+
+	if (g_cine->getGameType() == Cine::GType_FW) {
+		strcpy(previousPartName, currentPartName);
+		loadPart("BASESON.SND");
+	}
+	index = findFileInBundle((const char *)entryName);
+	if (index != -1) {
+		data = readBundleFile(index);
+	}
+	if (g_cine->getGameType() == Cine::GType_FW) {
+		loadPart(previousPartName);
+	}
+	return data;
+}
+
 byte *readFile(const char *filename) {
 	Common::File in;
 
@@ -437,6 +456,9 @@
 	return dataPtr;
 }
 
+void checkDataDisk(int16 param) {
+}
+
 void dumpBundle(const char *fileName) {
 	char tmpPart[15];
 

Modified: scummvm/trunk/engines/cine/part.h
===================================================================
--- scummvm/trunk/engines/cine/part.h	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/part.h	2007-05-13 16:07:33 UTC (rev 26836)
@@ -65,8 +65,11 @@
 void readFromPart(int16 idx, byte *dataPtr);
 
 byte *readBundleFile(int16 foundFileIdx);
+byte *readBundleSoundFile(const char *entryName);
 byte *readFile(const char *filename);
 
+void checkDataDisk(int16 param);
+
 void dumpBundle(const char *filename);
 
 } // End of namespace Cine

Deleted: scummvm/trunk/engines/cine/resource.cpp
===================================================================
--- scummvm/trunk/engines/cine/resource.cpp	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/resource.cpp	2007-05-13 16:07:33 UTC (rev 26836)
@@ -1,126 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2006 The ScummVM project
- *
- * cinE Engine is (C) 2004-2005 by CinE Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/file.h"
-
-#include "cine/cine.h"
-#include "cine/resource.h"
-#include "cine/unpack.h"
-#include "cine/various.h"
-
-namespace Cine {
-
-void checkDataDisk(int16 param) {
-}
-
-/* FW specific */
-static Common::File *snd_baseSndFile = NULL;
-static uint16 snd_numBasesonEntries = 0;
-static BasesonEntry *snd_basesonEntries = NULL;
-
-int snd_loadBasesonEntries(const char *fileName) {
-	int i;
-
-	snd_baseSndFile = new Common::File();
-	snd_baseSndFile->open(fileName);
-	if (!snd_baseSndFile->isOpen())
-		return -1;
-
-	snd_numBasesonEntries = snd_baseSndFile->readUint16BE();
-	snd_baseSndFile->readUint16BE();	/* entry_size */
-	snd_basesonEntries = (BasesonEntry *)malloc(snd_numBasesonEntries * sizeof(BasesonEntry));
-	if (snd_basesonEntries) {
-		for (i = 0; i < snd_numBasesonEntries; ++i) {
-			BasesonEntry *be = &snd_basesonEntries[i];
-			snd_baseSndFile->read(be->name, 14);
-			be->offset = snd_baseSndFile->readUint32BE();
-			be->size = snd_baseSndFile->readUint32BE();
-			be->unpackedSize = snd_baseSndFile->readUint32BE();
-			snd_baseSndFile->readUint32BE();	/* unused */
-		}
-	}
-	return 0;
-}
-
-void snd_clearBasesonEntries() {
-	snd_baseSndFile->close();
-	delete snd_baseSndFile;
-	free(snd_basesonEntries);
-	snd_basesonEntries = NULL;
-	snd_numBasesonEntries = 0;
-}
-
-static int snd_findBasesonEntry(const char *entryName) {
-	int i;
-	char *p;
-	char basesonEntryName[20];
-
-	assert(strlen(entryName) < 20);
-	strcpy(basesonEntryName, entryName);
-	for (p = basesonEntryName; *p; ++p) {
-		if (*p >= 'a' && *p <= 'z')
-			*p += 'A' - 'a';
-	}
-
-	for (i = 0; i < snd_numBasesonEntries; ++i) {
-		if (strcmp(snd_basesonEntries[i].name, basesonEntryName) == 0)
-			return i;
-	}
-	return -1;
-}
-
-byte *snd_loadBasesonEntry(const char *entryName) {
-	int entryNum;
-	byte *entryData = NULL;
-
-	if (g_cine->getGameType() == Cine::GType_OS) {
-		entryNum = findFileInBundle((const char *)entryName);
-		if (entryNum != -1)
-			entryData = readBundleFile(entryNum);
-	} else {
-		entryNum = snd_findBasesonEntry(entryName);
-		if (entryNum != -1 && entryNum < snd_numBasesonEntries) {
-			const BasesonEntry *be = &snd_basesonEntries[entryNum];
-			entryData = (byte *)malloc(be->unpackedSize);
-			if (entryData) {
-				if (be->unpackedSize > be->size) {
-					byte *tempData = (byte *)malloc(be->size);
-					if (tempData) {
-						snd_baseSndFile->seek(be->offset, SEEK_SET);
-						snd_baseSndFile->read(tempData, be->size);
-						delphineUnpack(entryData, tempData, be->size);
-						free(tempData);
-					}
-				} else {
-					snd_baseSndFile->seek(be->offset, SEEK_SET);
-					snd_baseSndFile->read(entryData, be->size);
-				}
-			}
-		}
-	}
-
-	return entryData;
-}
-
-} // End of namespace Cine

Deleted: scummvm/trunk/engines/cine/resource.h
===================================================================
--- scummvm/trunk/engines/cine/resource.h	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/resource.h	2007-05-13 16:07:33 UTC (rev 26836)
@@ -1,47 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2006 The ScummVM project
- *
- * cinE Engine is (C) 2004-2005 by CinE Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef CINE_RESOURCE_H
-#define CINE_RESOURCE_H
-
-#include "common/stdafx.h"
-#include "common/scummsys.h"
-
-namespace Cine {
-
-struct BasesonEntry {
-	char name[14];
-	uint32 offset;
-	uint32 size;
-	uint32 unpackedSize;
-};
-
-void checkDataDisk(int16 param);
-extern int snd_loadBasesonEntries(const char *fileName);
-extern void snd_clearBasesonEntries();
-extern byte *snd_loadBasesonEntry(const char *entryName);
-
-} // End of namespace Cine
-
-#endif

Modified: scummvm/trunk/engines/cine/sfx_player.cpp
===================================================================
--- scummvm/trunk/engines/cine/sfx_player.cpp	2007-05-13 14:56:44 UTC (rev 26835)
+++ scummvm/trunk/engines/cine/sfx_player.cpp	2007-05-13 16:07:33 UTC (rev 26836)
@@ -67,7 +67,7 @@
 		return 0;
 	}
 		
-	_sfxData = snd_loadBasesonEntry(song);
+	_sfxData = readBundleSoundFile(song);
 	if (!_sfxData) {
 		warning("Unable to load soundfx module '%s'", song);
 		return 0;
@@ -86,7 +86,7 @@
 				*dot = '\0';
 			}
 			strcat(instrument, _driver->getInstrumentExtension());
-			_instrumentsData[i] = snd_loadBasesonEntry(instrument);
+			_instrumentsData[i] = readBundleSoundFile(instrument);
 			if (!_instrumentsData[i]) {
 				warning("Unable to load soundfx instrument '%s'", instrument);
 			}


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