aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cine/anim.cpp33
-rw-r--r--engines/cine/anim.h4
-rw-r--r--engines/cine/main_loop.cpp1
-rw-r--r--engines/cine/object.cpp15
-rw-r--r--engines/cine/pal.cpp2
-rw-r--r--engines/cine/part.cpp23
-rw-r--r--engines/cine/part.h1
-rw-r--r--engines/cine/script.cpp2
-rw-r--r--engines/cine/various.cpp3
-rw-r--r--engines/cine/various.h1
10 files changed, 39 insertions, 46 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp
index a30c2bdff3..609050426e 100644
--- a/engines/cine/anim.cpp
+++ b/engines/cine/anim.cpp
@@ -45,7 +45,7 @@ struct animHeader2Struct {
uint16 field_E;
};
-uint16 frameVar0 = 0;
+static uint16 animDataCount = 0;
animHeaderStruct animHeader;
@@ -183,7 +183,30 @@ animDataEntry animData[] = {
{"FIN", 0x9},
};
-byte getAnimTransparentColor(const char *animName) {
+static void freeAnimData(byte idx) {
+ assert(idx < NUM_MAX_ANIMDATA);
+ if (animDataTable[idx].ptr1) {
+ free(animDataTable[idx].ptr1);
+ free(animDataTable[idx].ptr2);
+ memset(&animDataTable[idx], 0, sizeof(AnimData));
+ animDataTable[idx].fileIdx = -1;
+ animDataTable[idx].frameIdx = -1;
+ if (animDataCount > 0)
+ animDataCount--;
+ }
+}
+
+void freeAnimDataRange(byte startIdx, byte numIdx) {
+ for (byte i = 0; i < numIdx; i++) {
+ freeAnimData(i + startIdx);
+ }
+}
+
+void freeAnimDataTable() {
+ freeAnimDataRange(0, NUM_MAX_ANIMDATA);
+}
+
+static byte getAnimTransparentColor(const char *animName) {
char name[15];
removeExtention(name, animName);
@@ -237,7 +260,7 @@ int16 allocFrame(uint16 width, uint16 height, int8 isMask) {
animDataTable[i].frameIdx = -1;
}
- frameVar0++;
+ animDataCount++;
return i;
}
@@ -287,7 +310,7 @@ int16 allocFrame2(uint16 width, uint16 height, uint16 type) {
animDataTable[i].fileIdx = -1;
animDataTable[i].frameIdx = -1;
- frameVar0++;
+ animDataCount++;
return i;
}
@@ -331,7 +354,7 @@ int16 reserveFrame(uint16 width, uint16 height, uint16 type, uint16 idx) {
animDataTable[i].fileIdx = -1;
animDataTable[i].frameIdx = -1;
- frameVar0++;
+ animDataCount++;
return i;
}
diff --git a/engines/cine/anim.h b/engines/cine/anim.h
index 13100eec62..7ac7f1d6f4 100644
--- a/engines/cine/anim.h
+++ b/engines/cine/anim.h
@@ -27,8 +27,6 @@
namespace Cine {
-extern uint16 frameVar0;
-
struct animHeaderStruct {
byte field_0;
byte field_1;
@@ -57,6 +55,8 @@ struct animDataEntry {
extern animDataEntry animData[];
+void freeAnimDataTable(void);
+void freeAnimDataRange(byte startIdx, byte numIdx);
void loadResource(const char *animName);
void loadAbs(const char *resourceName, uint16 idx);
void loadResourcesFromSave();
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index 5f601b8aa7..24220a8518 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -146,7 +146,6 @@ void manageEvents(int count) {
}
int i;
-
for (i = 0; i < count; i++) {
//FIXME(?): Maybe there's a better way to "fix" this?
//
diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp
index 980bcfe5d7..eafd197d53 100644
--- a/engines/cine/object.cpp
+++ b/engines/cine/object.cpp
@@ -133,12 +133,11 @@ int8 removeOverlayElement(uint16 objIdx, uint16 param) {
int16 freeOverlay(uint16 objIdx, uint16 param) {
overlayHeadElement *currentHeadPtr = overlayHead.next;
- overlayHeadElement *tempHead = &overlayHead;
- overlayHeadElement *tempPtr2;
+ overlayHeadElement *previousPtr = &overlayHead;
while (currentHeadPtr && ((currentHeadPtr->objIdx != objIdx) || (currentHeadPtr->type != param))) {
- tempHead = currentHeadPtr;
- currentHeadPtr = tempHead->next;
+ previousPtr = currentHeadPtr;
+ currentHeadPtr = previousPtr->next;
}
if (!currentHeadPtr) {
@@ -149,8 +148,8 @@ int16 freeOverlay(uint16 objIdx, uint16 param) {
return -1;
}
- tempHead->next = currentHeadPtr->next;
- tempPtr2 = currentHeadPtr->next;
+ previousPtr->next = currentHeadPtr->next;
+ overlayHeadElement *tempPtr2 = currentHeadPtr->next;
if (!tempPtr2) {
tempPtr2 = &overlayHead;
@@ -158,9 +157,7 @@ int16 freeOverlay(uint16 objIdx, uint16 param) {
tempPtr2->previous = currentHeadPtr->previous;
- //TODO: fix !
- //free(currentHeadPtr);
-
+ free(currentHeadPtr);
return 0;
}
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index 6d3845ad78..a5b94d1034 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -36,7 +36,7 @@ uint16 palEntriesCount;
Common::File *palFileHandleP = NULL;
-PalEntry *palPtr;
+PalEntry *palPtr = NULL;
byte paletteBuffer1[16];
byte paletteBuffer2[16];
diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp
index 7ef81f5069..5b7016b91b 100644
--- a/engines/cine/part.cpp
+++ b/engines/cine/part.cpp
@@ -72,29 +72,8 @@ void loadPart(const char *partName) {
loadPal(partName);
}
-void freePartEntry(byte idx) {
- if (animDataTable[idx].ptr1) {
- //free(animDataTable[idx].ptr1);
-
- animDataTable[idx].ptr1 = NULL;
- animDataTable[idx].ptr2 = NULL;
-
- // TODO: finish
-
- if (frameVar0 > 0)
- frameVar0--;
- }
-}
-
-void freePartRange(byte startIdx, byte numIdx) {
- byte i;
-
- for (i = 0; i < numIdx; i++) {
- freePartEntry(i + startIdx);
- }
-}
-
void closePart(void) {
+ // TODO
}
static const char *bundleNamesDOSEN[] = {
diff --git a/engines/cine/part.h b/engines/cine/part.h
index b8abd7620c..2a02d37a81 100644
--- a/engines/cine/part.h
+++ b/engines/cine/part.h
@@ -57,7 +57,6 @@ extern AnimData *animDataTable;
extern PartBuffer *partBuffer;
void loadPart(const char *partName);
-void freePartRange(byte startIdx, byte numIdx);
void closePart(void);
int16 findFileInBundle(const char *fileName);
diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp
index 738ade2834..cf4ade58ca 100644
--- a/engines/cine/script.cpp
+++ b/engines/cine/script.cpp
@@ -1434,7 +1434,7 @@ void o1_freePartRange() {
assert(startIdx + numIdx <= NUM_MAX_ANIMDATA);
debugC(5, kCineDebugScript, "Line: %d: freePartRange(%d,%d)", _currentLine, startIdx, numIdx);
- freePartRange(startIdx, numIdx);
+ freeAnimDataRange(startIdx, numIdx);
}
void o1_unloadAllMasks() {
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index f6bf1197ea..fcf67a23b7 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -61,9 +61,6 @@ Common::File *partFileHandleP = NULL;
void waitPlayerInput(void) {
}
-void freeAnimDataTable(void) {
-}
-
void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4) {
}
diff --git a/engines/cine/various.h b/engines/cine/various.h
index bb95657f1c..578aed0ef5 100644
--- a/engines/cine/various.h
+++ b/engines/cine/various.h
@@ -86,7 +86,6 @@ extern Common::File *partFileHandleP;
#define partFileHandle (*partFileHandleP)
-void freeAnimDataTable(void);
void mainLoopSub1(void);
void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4);