aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Hamm2007-04-28 23:21:13 +0000
committerVincent Hamm2007-04-28 23:21:13 +0000
commitf5c73e1603c98df8a9e0ac1c99e9b4da27eb8132 (patch)
tree93d80cd002b537195632cbd41380a2d8578eb9f7
parent4a4040260982a515cb696453284b7bb585872a12 (diff)
downloadscummvm-rg350-f5c73e1603c98df8a9e0ac1c99e9b4da27eb8132.tar.gz
scummvm-rg350-f5c73e1603c98df8a9e0ac1c99e9b4da27eb8132.tar.bz2
scummvm-rg350-f5c73e1603c98df8a9e0ac1c99e9b4da27eb8132.zip
Implement missing opcode and fix staff intro
svn-id: r26669
-rw-r--r--engines/cruise/backgroundIncrust.cpp66
-rw-r--r--engines/cruise/backgroundIncrust.h3
-rw-r--r--engines/cruise/function.cpp143
3 files changed, 136 insertions, 76 deletions
diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp
index 8547823a7c..99c2fda8c3 100644
--- a/engines/cruise/backgroundIncrust.cpp
+++ b/engines/cruise/backgroundIncrust.cpp
@@ -99,7 +99,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx,
currentHead2->prev = newElement;
newElement->objectIdx = objectIdx;
- newElement->field_6 = param4;
+ newElement->type = param4;
newElement->backgroundIdx = backgroundIdx;
newElement->overlayIdx = overlayIdx;
newElement->scriptNumber = scriptNumber;
@@ -137,9 +137,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx,
* ASSERT(0);
* } */
- addBackgroundIncrustSub1(params.fileIdx, newElement->X,
- newElement->Y, NULL, params.scale, (char *)backgroundPtr,
- (char *)filesDatabase[params.fileIdx].subData.ptr);
+ addBackgroundIncrustSub1(params.fileIdx, newElement->X, newElement->Y, NULL, params.scale, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptr);
}
return newElement;
@@ -164,7 +162,7 @@ void loadBackgroundIncrustFromSave(FILE *fileHandle) {
fseek(fileHandle, 4, SEEK_CUR);
fread(&current->objectIdx, 2, 1, fileHandle);
- fread(&current->field_6, 2, 1, fileHandle);
+ fread(&current->type, 2, 1, fileHandle);
fread(&current->overlayIdx, 2, 1, fileHandle);
fread(&current->X, 2, 1, fileHandle);
fread(&current->Y, 2, 1, fileHandle);
@@ -216,4 +214,62 @@ void freeBackgroundIncrustList(backgroundIncrustStruct *pHead) {
resetBackgroundIncrustList(pHead);
}
+void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead) {
+ objectParamsQuery params;
+ int var_4;
+ int var_6;
+
+ backgroundIncrustStruct *pCurrent;
+ backgroundIncrustStruct *pCurrentHead;
+
+ getMultipleObjectParam(overlay, idx, &params);
+
+ var_4 = params.X;
+ var_6 = params.Y;
+
+ pCurrent = pHead->next;
+
+ while (pCurrent) {
+ if ((pCurrent->overlayIdx == overlay || overlay == -1) &&
+ (pCurrent->objectIdx == idx || idx == -1) &&
+ (pCurrent->X == var_4) && (pCurrent->Y == var_6)) {
+ pCurrent->type = - 1;
+ }
+
+ pCurrent = pCurrent->next;
+ }
+
+ pCurrentHead = pHead;
+ pCurrent = pHead->next;
+
+ while (pCurrent) {
+ if (pCurrent->type == - 1) {
+ backgroundIncrustStruct *pNext = pCurrent->next;
+ backgroundIncrustStruct *bx = pCurrentHead;
+ backgroundIncrustStruct *cx;
+
+ bx->next = pNext;
+ cx = pNext;
+
+ if (!pNext) {
+ cx = pHead;
+ }
+
+ bx = cx;
+ bx->prev = pCurrent->next;
+
+ if (pCurrent->ptr) {
+ free(pCurrent->ptr);
+ }
+
+ free(pCurrent);
+
+ pCurrent = pNext;
+ } else {
+ pCurrentHead = pCurrent;
+ pCurrent = pCurrent->next;
+ }
+ }
+}
+
} // End of namespace Cruise
diff --git a/engines/cruise/backgroundIncrust.h b/engines/cruise/backgroundIncrust.h
index 576cb8ec8b..c1e20609fd 100644
--- a/engines/cruise/backgroundIncrust.h
+++ b/engines/cruise/backgroundIncrust.h
@@ -32,7 +32,7 @@ struct backgroundIncrustStruct {
struct backgroundIncrustStruct *prev;
uint16 objectIdx;
- uint16 field_6;
+ int16 type;
uint16 overlayIdx;
uint16 X;
uint16 Y;
@@ -61,6 +61,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 param2,
void loadBackgroundIncrustFromSave(FILE * fileHandle);
void regenerateBackgroundIncrust(backgroundIncrustStruct * pHead);
void freeBackgroundIncrustList(backgroundIncrustStruct * pHead);
+void removeBackgroundIncrust(int overlay, int idx, backgroundIncrustStruct * pHead);
} // End of namespace Cruise
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index 559cecd189..45aeb0e9f5 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -839,65 +839,6 @@ int16 Op_InitializeStateB(void) {
return si;
}
-void removeBackgroundIncrust(int overlay, int idx,
- backgroundIncrustStruct * pHead) {
- objectParamsQuery params;
- int var_4;
- int var_6;
-
- backgroundIncrustStruct *pCurrent;
- backgroundIncrustStruct *pCurrentHead;
-
- getMultipleObjectParam(overlay, idx, &params);
-
- var_4 = params.X;
- var_6 = params.Y;
-
- pCurrent = pHead->next;
-
- while (pCurrent) {
- if ((pCurrent->overlayIdx == overlay || overlay == -1) &&
- (pCurrent->objectIdx == idx || idx == -1) &&
- (pCurrent->X == var_4) && (pCurrent->Y == var_6)) {
- pCurrent->field_6 = (uint16) - 1;
- }
-
- pCurrent = pCurrent->next;
- }
-
- pCurrentHead = pHead;
- pCurrent = pHead->next;
-
- while (pCurrent) {
- if (pCurrent->field_6 == (uint16) - 1) {
- backgroundIncrustStruct *pNext = pCurrent->next;
- backgroundIncrustStruct *bx = pCurrentHead;
- backgroundIncrustStruct *cx;
-
- bx->next = pNext;
- cx = pNext;
-
- if (!pNext) {
- cx = pHead;
- }
-
- bx = cx;
- bx->prev = pCurrent->next;
-
- if (pCurrent->ptr) {
- free(pCurrent->ptr);
- }
-
- free(pCurrent);
-
- pCurrent = pNext;
- } else {
- pCurrentHead = pCurrent;
- pCurrent = pCurrent->next;
- }
- }
-}
-
int16 Op_RemoveBackgroundIncrust(void) {
int idx = popVar();
int overlay = popVar();
@@ -1001,7 +942,7 @@ int16 Op_61(void) {
return si;
}
-int16 Op_1A(void) {
+int16 Op_SetZoom(void) {
var46 = popVar();
var45 = popVar();
var42 = popVar();
@@ -1028,8 +969,7 @@ int16 Op_22(void) {
return (computeZoom(popVar()));
}
-actorStruct *addAnimation(actorStruct * pHead, int overlay, int objIdx,
- int param, int param2) {
+actorStruct *addAnimation(actorStruct * pHead, int overlay, int objIdx, int param, int param2) {
actorStruct *pPrevious = pHead;
actorStruct *pCurrent = pHead->next;
@@ -1073,6 +1013,68 @@ actorStruct *addAnimation(actorStruct * pHead, int overlay, int objIdx,
return pNewElement;
}
+int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType)
+{
+ actorStruct* pl;
+ actorStruct* pl2;
+ actorStruct* pl3;
+ actorStruct* pl4;
+
+ int dir = 0;
+
+ pl = pHead;
+ pl2 = pl;
+ pl = pl2->next;
+
+ while(pl)
+ {
+ pl2 = pl;
+
+ if(((pl->overlayNumber == overlay) || (overlay == -1)) &&
+ ((pl->idx == objIdx) || (objIdx == -1)) &&
+ ((pl->type == objType) || (objType == -1)))
+ {
+ pl->type = -1;
+ }
+
+ pl = pl2->next;
+ }
+
+ pl = pHead;
+ pl2 = pl;
+ pl = pl2->next;
+
+ while(pl)
+ {
+ if(pl->type == -1)
+ {
+ pl4 = pl->next;
+ pl2->next = pl4;
+ pl3 = pl4;
+
+ if(pl3 == NULL)
+ pl3 = pHead;
+
+ pl3->prev = pl->prev;
+
+ dir = pl->startDirection;
+
+ if(pl->idx >= 0)
+ freePerso(pl->idx);
+
+ free(pl);
+ pl = pl4;
+ }
+ else
+ {
+ pl2 = pl;
+ pl = pl2->next;
+ }
+ }
+
+ return dir;
+}
+
int flag_obstacle; // computedVar14Bis
void checkCollisionWithWalkBoxesBoundingBoxes(int x, int y) {
@@ -1157,8 +1159,7 @@ int16 Op_AddAnimation(void) {
zoom = -zoom;
}
- checkCollisionWithWalkBoxesBoundingBoxes(params.X,
- params.Y);
+ checkCollisionWithWalkBoxesBoundingBoxes(params.X, params.Y);
setObjectPosition(overlay, obj, 3, newFrame + start);
setObjectPosition(overlay, obj, 4, zoom);
@@ -1172,13 +1173,15 @@ int16 Op_AddAnimation(void) {
}
int16 Op_RemoveAnimation(void) {
- popVar();
- popVar();
- popVar();
+ int objType = popVar();
+ int objIdx = popVar();
+ int ovlIdx = popVar();
- printf("Partial op 19 (remove actor)\n");
+ if (!ovlIdx) {
+ ovlIdx = currentScriptPtr->overlayNumber;
+ }
- return 0;
+ return removeAnimation(&actorHead, ovlIdx, objIdx, objType);
}
int16 Op_regenerateBackgroundIncrust(void) {
@@ -1441,7 +1444,7 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x17] = Op_LoadCt;
opcodeTablePtr[0x18] = Op_AddAnimation;
opcodeTablePtr[0x19] = Op_RemoveAnimation;
- opcodeTablePtr[0x1A] = Op_1A;
+ opcodeTablePtr[0x1A] = Op_SetZoom;
opcodeTablePtr[0x1E] = Op_1E;
opcodeTablePtr[0x21] = Op_21;
opcodeTablePtr[0x22] = Op_22;