aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-10-26 20:36:44 +0000
committerMax Horn2009-10-26 20:36:44 +0000
commitd2e64a350ae9aa6955b2dd7a3715958cdb5477f5 (patch)
treeb76bffaf3c9be57f4ce5a4e0cc41448a87f20af5 /engines
parente1de772e721a7dc0d62223c17617f72af3d2308f (diff)
downloadscummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.tar.gz
scummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.tar.bz2
scummvm-rg350-d2e64a350ae9aa6955b2dd7a3715958cdb5477f5.zip
TINSEL: cleanup
svn-id: r45417
Diffstat (limited to 'engines')
-rw-r--r--engines/tinsel/handle.cpp64
-rw-r--r--engines/tinsel/heapmem.cpp4
-rw-r--r--engines/tinsel/heapmem.h4
3 files changed, 30 insertions, 42 deletions
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index cbfd782942..038fc831b4 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -87,7 +87,7 @@ static char szCdPlayFile[100];
//----------------- 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 @@ void SetupHandleTable(void) {
assert(pH->_ptr);
// load the data
- LoadFile(pH, true);
+ LoadFile(pH);
}
#ifdef BODGE
else if ((pH->filesize & FSIZE_MASK) == 8) {
@@ -280,9 +280,8 @@ void SetCdPlayHandle(int fileNum) {
/**
* 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 @@ void LoadFile(MEMHANDLE *pH, bool bWarn) {
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,47 +361,40 @@ byte *LockMem(SCNHANDLE offset) {
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);
- }
- LoadFile(pH, true);
+ if (TinselV2) {
+ SetCD(pH->flags2 & fAllCds);
+ CdCD(nullContext);
+ }
+ LoadFile(pH);
- // make sure address is valid
- assert(pH->_node->pBaseAddr);
+ // make sure address is valid
+ assert(pH->filesize & fLoaded);
+ }
return pH->_node->pBaseAddr + (offset & OFFSETMASK);
}
diff --git a/engines/tinsel/heapmem.cpp b/engines/tinsel/heapmem.cpp
index 42584d5f67..6ba5fd5a88 100644
--- a/engines/tinsel/heapmem.cpp
+++ b/engines/tinsel/heapmem.cpp
@@ -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 @@ namespace Tinsel {
#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
diff --git a/engines/tinsel/heapmem.h b/engines/tinsel/heapmem.h
index 5ebf2e7062..9fbee0d61f 100644
--- a/engines/tinsel/heapmem.h
+++ b/engines/tinsel/heapmem.h
@@ -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,8 +40,6 @@ struct MEM_NODE {
int flags; // allocation attributes
};
-// allocation flags for the MemoryAlloc function
-
/*----------------------------------------------------------------------*\
|* Memory Function Prototypes *|