[Scummvm-cvs-logs] SF.net SVN: scummvm:[45430] scummvm/trunk/engines/tinsel/handle.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Oct 27 01:38:41 CET 2009
Revision: 45430
http://scummvm.svn.sourceforge.net/scummvm/?rev=45430&view=rev
Author: fingolfin
Date: 2009-10-27 00:38:41 +0000 (Tue, 27 Oct 2009)
Log Message:
-----------
TINSEL: Add some debugging code; fix LockMem() regression
Modified Paths:
--------------
scummvm/trunk/engines/tinsel/handle.cpp
Modified: scummvm/trunk/engines/tinsel/handle.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/handle.cpp 2009-10-27 00:38:19 UTC (rev 45429)
+++ scummvm/trunk/engines/tinsel/handle.cpp 2009-10-27 00:38:41 UTC (rev 45430)
@@ -41,7 +41,7 @@
//----------------- EXTERNAL GLOBAL DATA --------------------
#ifdef DEBUG
-static bool bLockedScene = 0;
+static uint32 s_lockedScene = 0;
#endif
@@ -322,7 +322,7 @@
}
/**
- * Returns the address of a image, given its memory handle.
+ * Compute and return the address specified by a SCNHANDLE.
* @param offset Handle and offset to data
*/
byte *LockMem(SCNHANDLE offset) {
@@ -332,6 +332,11 @@
// range check the memory handle
assert(handle < numHandles);
+#ifdef DEBUG
+ if (handle != s_lockedScene)
+ warning(" Calling LockMem(0x%x), handle %d differs from active scene %d", offset, handle, s_lockedScene);
+#endif
+
pH = handleTable + handle;
if (pH->filesize & fPreload) {
@@ -341,33 +346,35 @@
if (offset < cdBaseHandle || offset >= cdTopHandle)
error("Overlapping (in time) CD-plays");
- // may have been discarded, make sure memory is allocated
- MemoryReAlloc(pH->_node, cdTopHandle - cdBaseHandle);
+ // May have been discarded, if so, we have to reload
+ if (!MemoryDeref(pH->_node)) {
+ // Data was discarded, we have to reload
+ MemoryReAlloc(pH->_node, cdTopHandle - cdBaseHandle);
- if (!(pH->filesize & fLoaded)) {
-
LoadCDGraphData(pH);
// update the LRU time (new in this file)
MemoryTouch(pH->_node);
}
+ // make sure address is valid
+ assert(pH->filesize & fLoaded);
+
offset -= cdBaseHandle;
} else {
- // may have been discarded, make sure memory is allocated
- MemoryReAlloc(pH->_node, pH->filesize & FSIZE_MASK);
+ if (!MemoryDeref(pH->_node)) {
+ // Data was discarded, we have to reload
+ MemoryReAlloc(pH->_node, pH->filesize & FSIZE_MASK);
- if (!(pH->filesize & fLoaded)) {
-
if (TinselV2) {
SetCD(pH->flags2 & fAllCds);
CdCD(nullContext);
}
LoadFile(pH);
+ }
- // make sure address is valid
- assert(pH->filesize & fLoaded);
- }
+ // make sure address is valid
+ assert(pH->filesize & fLoaded);
}
return MemoryDeref(pH->_node) + (offset & OFFSETMASK);
@@ -383,7 +390,7 @@
MEMHANDLE *pH; // points to table entry
#ifdef DEBUG
- assert(!bLockedScene); // Trying to lock more than one scene
+ assert(0 == s_lockedScene); // Trying to lock more than one scene
#endif
// range check the memory handle
@@ -399,7 +406,7 @@
MemoryLock(pH->_node);
#ifdef DEBUG
- bLockedScene = true;
+ s_lockedScene = handle;
#endif
}
}
@@ -423,7 +430,7 @@
MemoryUnlock(pH->_node);
#ifdef DEBUG
- bLockedScene = false;
+ s_lockedScene = 0;
#endif
}
}
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