diff options
Diffstat (limited to 'engines/cruise')
-rw-r--r-- | engines/cruise/cell.cpp | 15 | ||||
-rw-r--r-- | engines/cruise/cell.h | 2 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 84 | ||||
-rw-r--r-- | engines/cruise/dataLoader.cpp | 4 | ||||
-rw-r--r-- | engines/cruise/function.cpp | 18 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 153 | ||||
-rw-r--r-- | engines/cruise/menu.cpp | 33 | ||||
-rw-r--r-- | engines/cruise/object.cpp | 13 | ||||
-rw-r--r-- | engines/cruise/perso.h | 1 |
9 files changed, 197 insertions, 126 deletions
diff --git a/engines/cruise/cell.cpp b/engines/cruise/cell.cpp index 9ef2912ef5..bd86af7884 100644 --- a/engines/cruise/cell.cpp +++ b/engines/cruise/cell.cpp @@ -279,6 +279,21 @@ void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, i } } +void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2) { + while (pHead) { + if ((pHead->overlay == ovl) || (ovl == -1)) { + if ((pHead->idx == obj) || (obj == -1)) { + if ((pHead->type == type) || (type == -1)) { + pHead->followObjectIdx = obj2; + pHead->followObjectOverlayIdx = ovl2; + } + } + } + + pHead = pHead->next; + } +} + void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze ) { while (pObject) { if ((pObject->overlay == overlayIdx) || (overlayIdx == -1)) { diff --git a/engines/cruise/cell.h b/engines/cruise/cell.h index 3806286ca7..655daacc21 100644 --- a/engines/cruise/cell.h +++ b/engines/cruise/cell.h @@ -71,6 +71,8 @@ void createTextObject(cellStruct *pObject, int overlayIdx, int messageIdx, int x void removeCell(cellStruct *objPtr, int ovlNumber, int objectIdx, int objType, int backgroundPlane ); void freezeCell(cellStruct * pObject, int overlayIdx, int objIdx, int objType, int backgroundPlane, int oldFreeze, int newFreeze ); void sortCells(int16 param1, int16 param2, cellStruct *objPtr); +void linkCell(cellStruct *pHead, int ovl, int obj, int type, int ovl2, int obj2); + } // End of namespace Cruise diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index c2948f0c3d..e315925aba 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -644,11 +644,12 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { int j2 = 0; if ((objOvl != linkedObjOvl) || (objIdx != linkedObjIdx)) { - getMultipleObjectParam(linkedObjOvl, linkedObjIdx, ¶ms); + objectParamsQuery params2; + getMultipleObjectParam(linkedObjOvl, linkedObjIdx, ¶ms2); - x2 = params.X; - y2 = params.Y; - j2 = params.fileIdx; + x2 = params2.X; + y2 = params2.Y; + j2 = params2.fileIdx; } if (params.var5 >= 0 && params.fileIdx >= 0) { @@ -696,8 +697,8 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { } if (dataPtr && findPoly((char*)dataPtr, x, y, zoom, mouseX, mouseY)) { - *outObjOvl = objOvl; - *outObjIdx = objIdx; + *outObjOvl = linkedObjOvl; + *outObjIdx = linkedObjIdx; return (currentObject->type); } @@ -715,8 +716,8 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { if ((offsetX >= 0) && (offsetX < nWidth) && (offsetY >= 0) && (offsetY <= nHeight) && filesDatabase[j].subData.ptr) { if(testMask(offsetX, offsetY, filesDatabase[j].subData.ptrMask, filesDatabase[j].width/8)) { - *outObjOvl = objOvl; - *outObjIdx = objIdx; + *outObjOvl = linkedObjOvl; + *outObjIdx = linkedObjIdx; return currentObject->type; } } @@ -728,8 +729,8 @@ int findObject(int mouseX, int mouseY, int *outObjOvl, int *outObjIdx) { int height = params.scale; if ((mouseX >= x) && (mouseX <= x+width) && (mouseY >= y) && (mouseY <= y+height)) { - *outObjOvl = objOvl; - *outObjIdx = objIdx; + *outObjOvl = linkedObjOvl; + *outObjIdx = linkedObjIdx; return (currentObject->type); } @@ -990,6 +991,8 @@ bool findRelation(int objOvl, int objIdx, int x, int y) { thisOvl = j; } + const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj); + objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); if ((thisOvl == objOvl) && (objIdx == ptrHead->obj1Number) && pObject && (pObject->_class != THEME)) { @@ -1116,9 +1119,41 @@ void callSubRelation(menuElementSubStruct *pMenuElement, int nOvl, int nObj) { getMultipleObjectParam(obj2Ovl, pHeader->obj2Number, ¶ms); } - if ((pHeader->obj2OldState != -1) || (params.scale == pHeader->obj2OldState)) { - if (pHeader->type == 30) { - ASSERT(0); + if ((pHeader->obj2OldState == -1) || (params.scale == pHeader->obj2OldState)) { + if (pHeader->type == 30) { // REL + attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); + + if ((narratorOvl > 0) && (pHeader->trackX != -1) && (pHeader->trackY != -1)) { + actorStruct* pTrack = findActor(&actorHead, narratorOvl, narratorIdx, 0); + + if (pTrack) { + animationStart = false; + + if (pHeader->trackDirection == 9999) { + objectParamsQuery naratorParams; + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0); + } else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) { + objectParamsQuery naratorParams; + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = pHeader->trackDirection; + } else { + pTrack->x_dest = pHeader->trackX; + pTrack->y_dest = pHeader->trackY; + pTrack->endDirection = pHeader->trackDirection; + } + + pTrack->flag = 1; + + autoTrack = true; + userEnabled = 0; + changeScriptParamInList(ovlIdx, pHeader->id, &relHead, 0, 9998); + } + } } else if (pHeader->type == 50) { ASSERT(0); } @@ -1158,7 +1193,11 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { animationStart = false; if (pHeader->trackDirection == 9999) { - ASSERT(0); + objectParamsQuery naratorParams; + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0); } else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) { objectParamsQuery naratorParams; getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); @@ -1222,7 +1261,11 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { animationStart = false; if (pHeader->trackDirection == 9999) { - ASSERT(0); + objectParamsQuery naratorParams; + getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); + pTrack->x_dest = naratorParams.X; + pTrack->y_dest = naratorParams.Y; + pTrack->endDirection = direction(naratorParams.X, naratorParams.Y, pTrack->x_dest, pTrack->y_dest, 0, 0); } else if ((pHeader->trackX == 9999) && (pHeader->trackY == 9999)) { objectParamsQuery naratorParams; getMultipleObjectParam(narratorOvl, narratorIdx, &naratorParams); @@ -1389,14 +1432,21 @@ int processInput(void) { } if (linkedMsgList) { - ASSERT(0); // freeMsgList(linkedMsgList); } linkedMsgList = NULL; linkedRelation = NULL; changeCursor(CURSOR_NORMAL); } else { // call sub relation when clicking in inventory - ASSERT(0); + if(menuTable[0] && menuTable[1]) { + menuElementSubStruct * p0 = getSelectedEntryInMenu(menuTable[1]); + + if(p0) + callSubRelation(linkedRelation, p0->ovlIdx, p0->header); + + closeAllMenu(); + changeCursor(CURSOR_NORMAL); + } } selectDown = 0; menuDown = 0; diff --git a/engines/cruise/dataLoader.cpp b/engines/cruise/dataLoader.cpp index 4b8d4072dc..bc13810364 100644 --- a/engines/cruise/dataLoader.cpp +++ b/engines/cruise/dataLoader.cpp @@ -505,8 +505,8 @@ int loadSetEntry(const char *name, uint8 *ptr, int currentEntryIdx, int currentD { if (sec == 0) { // TODO sec type 5 needs special conversion. cut out 2 bytes at every width/5 position. - ASSERT(0); - return -1; +// ASSERT(0); +// return -1; } filesDatabase[fileIndex].subData.resourceType = 4; diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 46d938b849..d63f362c62 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -1533,6 +1533,23 @@ int16 Op_DialogOff(void) { return 0; } +int16 Op_LinkObjects(void) { + int type = popVar(); + int obj2 = popVar(); + int ovl2 = popVar(); + int obj = popVar(); + int ovl = popVar(); + + if(!ovl) + ovl = currentScriptPtr->overlayNumber; + if(!ovl2) + ovl2 = currentScriptPtr->overlayNumber; + + linkCell(&cellHead, ovl, obj, type, ovl2, obj2); + + return 0; +} + void setupOpcodeTable(void) { int i; @@ -1600,6 +1617,7 @@ void setupOpcodeTable(void) { opcodeTablePtr[0x41] = Op_isFileLoaded2; opcodeTablePtr[0x43] = Op_songExist; opcodeTablePtr[0x45] = Op_45; + opcodeTablePtr[0x4B] = Op_LinkObjects; opcodeTablePtr[0x54] = Op_SetFontFileIndex; opcodeTablePtr[0x56] = Op_changeCutSceneState; opcodeTablePtr[0x57] = Op_GetMouseX; diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index a2c3cd6d62..687f27a2dd 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -1097,7 +1097,7 @@ void mainDrawPolygons(int fileIndex, cellStruct *plWork, int X, int scale, int Y buildPolyModel(newX, newY, newScale, (char*)polygonMask, destBuffer, newFrame); } -void mainSprite(int globalX, int globalY, gfxEntryStruct *pGfxPtr, uint8 *ouputPtr, int newColor, int idx) { +void drawMessage(gfxEntryStruct *pGfxPtr, int globalX, int globalY, int idx, int newColor, uint8 *ouputPtr) { // this is used for font only if (pGfxPtr) { @@ -1231,101 +1231,83 @@ void drawCtp(void) { #endif void drawMenu(menuStruct *pMenu) { - if (pMenu && pMenu->numElements) { - int height; - int x; - int y; - int var_10; - int bx; - int newX; - int var_6; - int currentY; - int var_8; - int di; - menuElementStruct *si; - - height = pMenu->gfx->height; - x = pMenu->x; - y = pMenu->y; + if (pMenu == NULL) + return; + + if(pMenu->numElements == 0) + return; - var_10 = pMenu->gfx->width / (199 - (pMenu->gfx->width * 2)); + int hline = pMenu->gfx->height; + int x = pMenu->x; + int y = pMenu->y + hline; - bx = var_10 / (pMenu->numElements + 1); // rustine... + int numItemByLine = (199 - hline * 2) / hline; + int nbcol = pMenu->numElements / numItemByLine; - if (!bx) { - bx++; + if (!nbcol) { + nbcol++; - if ((pMenu->numElements * height) + y > 199 - height) { - y = ((-1 - pMenu->numElements) * height) + 200; - } - } else { - if (var_10 % pMenu->numElements) { - bx++; - } - - y = height; + if (y+pMenu->numElements*hline > 199-hline) { + y = 200 - (pMenu->numElements * hline) - hline; } - - newX = 320 * (2 - bx); - - if (newX < x) { - x = newX; + } else { + if (pMenu->numElements % numItemByLine) { + nbcol++; } - if (x < 0) { - x = 0; - } + y = hline; + } - var_6 = (80 * (bx - 1)) + x; + if (x > (320-(nbcol*160))) + x = 320-(nbcol*160); - if (var_6 <= 320) { - mainSprite(var_6, y - height, pMenu->gfx, - gfxModuleData.pPage10, video4, 320); - } + if (x < 0) + x = 0; - currentY = y; - var_8 = 0; - di = x; + int wx = x + (nbcol - 1) * (160/2); - si = pMenu->ptrNextElement; + if (wx <= 320 - 160) { + drawMessage(pMenu->gfx, wx, y - hline, 160, video4, gfxModuleData.pPage10); + } - if (si) { - do { - int color; + wx = x; + int wy = y; + int wc = 0; + menuElementStruct* p1 = pMenu->ptrNextElement; - gfxEntryStruct *var_2 = si->gfx; + while(p1) { + gfxEntryStruct *p2 = p1->gfx; - si->x = di; - si->y = currentY; - si->varA = 320; + p1->x = wx; + p1->y = wy; + p1->varA = 160; - if (si->varC) { - color = video3; - } else { - if (si->color != 255) { - color = si->color; - } else { - color = video2; - } - } + int color; - if (di < 320) { - mainSprite(di, currentY, var_2, - gfxModuleData.pPage10, color, 320); - } + if (p1->varC) { + color = video3; + } else { + if (p1->color != 255) { + color = p1->color; + } else { + color = video2; + } + } - currentY += height; - var_8++; + if (wx <= (320-160)) { + drawMessage(p2, wx, wy, 160, color, gfxModuleData.pPage10); + } - if (var_8 == var_10) { - var_8 = 0; - di += 320; - currentY = y; - } + wy += hline; + wc ++; - si = si->next; - } while (si); + if (wc == numItemByLine) { + wc = 0; + wx += 160; + wy = y; } + + p1 = p1->next; } } @@ -1361,9 +1343,9 @@ void mainDraw(int16 param) { int16 objX1 = 0; int16 objY1 = 0; int16 objZ1 = 0; - int16 objX2; - int16 objY2; - int16 objZ2; + int16 objX2 = 0; + int16 objY2 = 0; + int16 objZ2 = 0; int16 spriteHeight; if (fadeVar) { @@ -1524,7 +1506,7 @@ void mainDraw(int16 param) { while (currentObjPtr) { if (currentObjPtr->type == OBJ_TYPE_MSG && currentObjPtr->freeze == 0) { - mainSprite(currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->gfxPtr, gfxModuleData.pPage10, currentObjPtr->color, currentObjPtr->spriteIdx); + drawMessage(currentObjPtr->gfxPtr, currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->spriteIdx, currentObjPtr->color, gfxModuleData.pPage10); var20 = 1; } currentObjPtr = currentObjPtr->next; @@ -1538,8 +1520,15 @@ void mainDraw(int16 param) { return; } } else if ((linkedRelation) && (linkedMsgList)) { - ASSERT(0); - // TODO: draw mouse here + int16 mouseX; + int16 mouseY; + int16 button; + getMouseStatus(&main10, &mouseX, &button, &mouseY); + + if(mouseY>(linkedMsgList->height)*2) + drawMessage(linkedMsgList, 0, 0, 320, findHighColor(), gfxModuleData.pPage10); + else + drawMessage(linkedMsgList, 0, 200, 320, findHighColor(), gfxModuleData.pPage10); } } diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index ffbf287978..324c17d023 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -35,7 +35,7 @@ menuStruct *createMenu(int X, int Y, const char *menuName) { entry = (menuStruct *) malloc(sizeof(menuStruct)); ASSERT(entry); - entry->x = X - 80; + entry->x = X - 160/2; entry->y = Y; entry->stringPtr = menuName; entry->numElements = 0; @@ -62,38 +62,27 @@ void addSelectableMenuEntry(int ovlIdx, int headerIdx, menuStruct *pMenu, int pa if (param2) { if (!strcmp(var_6->string, menuText)) { pNewElement = var_6; - pSubStruct = - (menuElementSubStruct *) - allocAndZero(sizeof - (menuElementSubStruct)); + pSubStruct = (menuElementSubStruct *)allocAndZero(sizeof(menuElementSubStruct)); ASSERT(pSubStruct); pSubStruct->pNext = NULL; pSubStruct->ovlIdx = ovlIdx; pSubStruct->header = headerIdx; - pSubStructCurrent = - pNewElement->ptrSub; + pSubStructCurrent = pNewElement->ptrSub; if (!pSubStructCurrent) { - pNewElement->ptrSub = - pSubStruct; + pNewElement->ptrSub = pSubStruct; return; } if (pSubStructCurrent->pNext) { do { - pSubStructCurrent - = - pSubStructCurrent-> - pNext; - } while - (pSubStructCurrent-> - pNext); + pSubStructCurrent = pSubStructCurrent->pNext; + } while(pSubStructCurrent->pNext); } - pSubStructCurrent->pNext = - pSubStruct; + pSubStructCurrent->pNext = pSubStruct; return; } } @@ -104,13 +93,9 @@ void addSelectableMenuEntry(int ovlIdx, int headerIdx, menuStruct *pMenu, int pa var_6 = di; } - pNewElement = - (menuElementStruct *) - allocAndZero(sizeof(menuElementStruct)); + pNewElement = (menuElementStruct *)allocAndZero(sizeof(menuElementStruct)); ASSERT(pNewElement); - pSubStruct = - (menuElementSubStruct *) - allocAndZero(sizeof(menuElementSubStruct)); + pSubStruct = (menuElementSubStruct *)allocAndZero(sizeof(menuElementSubStruct)); ASSERT(pSubStruct); pNewElement->string = menuText; diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp index fdcf51323e..4119044880 100644 --- a/engines/cruise/object.cpp +++ b/engines/cruise/object.cpp @@ -128,7 +128,18 @@ void setObjectPosition(int16 ovlIdx, int16 objIdx, int16 param3, int16 param4) { //overlayTable[param1].ovlData switch (ptr->_class) { - case 1: + case THEME: + case MULTIPLE: + { + if(param3 != 5) + return; + globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = param4; + sortCells(ovlIdx, objIdx, &cellHead); + break; + } + case UNIQUE: + return; + case VARIABLE: { ptr2 = &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->_varTableIdx]; diff --git a/engines/cruise/perso.h b/engines/cruise/perso.h index aa9f59a1a3..d77697378b 100644 --- a/engines/cruise/perso.h +++ b/engines/cruise/perso.h @@ -51,6 +51,7 @@ extern int16 computedVar14; void freePerso(int persoIdx); void freeAllPerso(void); void affiche_chemin(int16 persoIdx, int16 * returnVar); +int direction(int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2); } // End of namespace Cruise |