[Scummvm-cvs-logs] SF.net SVN: scummvm:[45417] scummvm/trunk/engines/tinsel

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Oct 26 21:36:48 CET 2009


Revision: 45417
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45417&view=rev
Author:   fingolfin
Date:     2009-10-26 20:36:44 +0000 (Mon, 26 Oct 2009)

Log Message:
-----------
TINSEL: cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/handle.cpp
    scummvm/trunk/engines/tinsel/heapmem.cpp
    scummvm/trunk/engines/tinsel/heapmem.h

Modified: scummvm/trunk/engines/tinsel/handle.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/handle.cpp	2009-10-26 20:35:06 UTC (rev 45416)
+++ scummvm/trunk/engines/tinsel/handle.cpp	2009-10-26 20:36:44 UTC (rev 45417)
@@ -87,7 +87,7 @@
 
 //----------------- FORWARD REFERENCES --------------------
 
-static void LoadFile(MEMHANDLE *pH, bool bWarn);	// load a memory block as a file
+static void LoadFile(MEMHANDLE *pH);	// load a memory block as a file
 
 
 /**
@@ -160,7 +160,7 @@
 			assert(pH->_ptr);
 
 			// load the data
-			LoadFile(pH, true);
+			LoadFile(pH);
 		}
 #ifdef BODGE
 		else if ((pH->filesize & FSIZE_MASK) == 8) {
@@ -280,9 +280,8 @@
 /**
  * Loads a memory block as a file.
  * @param pH			Memory block pointer
- * @param bWarn			If set, treat warnings as errors
  */
-void LoadFile(MEMHANDLE *pH, bool bWarn) {
+void LoadFile(MEMHANDLE *pH) {
 	Common::File f;
 	char szFilename[sizeof(pH->szName) + 1];
 
@@ -327,14 +326,12 @@
 			return;
 		}
 
-		if (bWarn)
-			// file is corrupt
-			error(FILE_IS_CORRUPT, szFilename);
+		// file is corrupt
+		error(FILE_IS_CORRUPT, szFilename);
 	}
 
-	if (bWarn)
-		// cannot find file
-		error(CANNOT_FIND_FILE, szFilename);
+	// cannot find file
+	error(CANNOT_FIND_FILE, szFilename);
 }
 
 /**
@@ -364,48 +361,41 @@
 		if (offset < cdBaseHandle || offset >= cdTopHandle)
 			error("Overlapping (in time) CD-plays");
 
-		if (pH->_node->pBaseAddr && (pH->filesize & fLoaded))
-			// already allocated and loaded
-			return pH->_node->pBaseAddr + ((offset - cdBaseHandle) & OFFSETMASK);
-
-		if (pH->_node->pBaseAddr == NULL)
+		if (pH->_node->pBaseAddr == NULL) {
 			// must have been discarded - reallocate the memory
 			MemoryReAlloc(pH->_node, cdTopHandle - cdBaseHandle);
+			assert(pH->_node->pBaseAddr);
+		}
 
-		if (pH->_node->pBaseAddr == NULL)
-			error("Out of memory");
+		if (!(pH->filesize & fLoaded)) {
 
-		LoadCDGraphData(pH);
+			LoadCDGraphData(pH);
 
-		// make sure address is valid
-		assert(pH->_node->pBaseAddr);
+			// update the LRU time (new in this file)
+			pH->_node->lruTime = DwGetCurrentTime();
+		}
 
-		// update the LRU time (new in this file)
-		pH->_node->lruTime = DwGetCurrentTime();
-
 		return pH->_node->pBaseAddr + ((offset - cdBaseHandle) & OFFSETMASK);
 
 	} else {
-		if (pH->_node->pBaseAddr && (pH->filesize & fLoaded))
-			// already allocated and loaded
-			return pH->_node->pBaseAddr + (offset & OFFSETMASK);
-
-		if (pH->_node->pBaseAddr == NULL)
+		if (pH->_node->pBaseAddr == NULL) {
 			// must have been discarded - reallocate the memory
 			MemoryReAlloc(pH->_node, pH->filesize & FSIZE_MASK);
+			assert(pH->_node->pBaseAddr);
+		}
 
-		if (pH->_node->pBaseAddr == NULL)
-			error("Out of memory");
+		if (!(pH->filesize & fLoaded)) {
 
-		if (TinselV2) {
-			SetCD(pH->flags2 & fAllCds);
-			CdCD(nullContext);
+			if (TinselV2) {
+				SetCD(pH->flags2 & fAllCds);
+				CdCD(nullContext);
+			}
+			LoadFile(pH);
+
+			// make sure address is valid
+			assert(pH->filesize & fLoaded);
 		}
-		LoadFile(pH, true);
 
-		// make sure address is valid
-		assert(pH->_node->pBaseAddr);
-
 		return pH->_node->pBaseAddr + (offset & OFFSETMASK);
 	}
 }

Modified: scummvm/trunk/engines/tinsel/heapmem.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/heapmem.cpp	2009-10-26 20:35:06 UTC (rev 45416)
+++ scummvm/trunk/engines/tinsel/heapmem.cpp	2009-10-26 20:36:44 UTC (rev 45417)
@@ -31,6 +31,9 @@
 namespace Tinsel {
 
 
+#define	NUM_MNODES	192	// the number of memory management nodes (was 128, then 192)
+
+
 // internal allocation flags
 #define	DWM_USED		0x0001	///< the objects memory block is in use
 #define	DWM_DISCARDED	0x0100	///< the objects memory block has been discarded
@@ -38,7 +41,6 @@
 #define	DWM_SENTINEL	0x0400	///< the objects memory block is a sentinel
 
 
-
 // Specifies the total amount of memory required for DW1 demo, DW1, or DW2 respectively.
 // Currently this is set at 5MB for the DW1 demo and DW1 and 10MB for DW2
 // This could probably be reduced somewhat

Modified: scummvm/trunk/engines/tinsel/heapmem.h
===================================================================
--- scummvm/trunk/engines/tinsel/heapmem.h	2009-10-26 20:35:06 UTC (rev 45416)
+++ scummvm/trunk/engines/tinsel/heapmem.h	2009-10-26 20:36:44 UTC (rev 45417)
@@ -31,8 +31,6 @@
 
 namespace Tinsel {
 
-#define	NUM_MNODES	192	// the number of memory management nodes (was 128, then 192)
-
 struct MEM_NODE {
 	MEM_NODE *pNext;	// link to the next node in the list
 	MEM_NODE *pPrev;	// link to the previous node in the list
@@ -42,9 +40,7 @@
 	int flags;		// allocation attributes
 };
 
-// allocation flags for the MemoryAlloc function
 
-
 /*----------------------------------------------------------------------*\
 |*			Memory Function Prototypes			*|
 \*----------------------------------------------------------------------*/


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