diff options
Diffstat (limited to 'engines/cruise')
-rw-r--r-- | engines/cruise/actor.cpp | 8 | ||||
-rw-r--r-- | engines/cruise/backgroundIncrust.cpp | 4 | ||||
-rw-r--r-- | engines/cruise/backgroundIncrust.h | 2 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 401 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/menu.cpp | 14 | ||||
-rw-r--r-- | engines/cruise/mouse.cpp | 3 | ||||
-rw-r--r-- | engines/cruise/saveload.cpp | 10 | ||||
-rw-r--r-- | engines/cruise/vars.cpp | 14 | ||||
-rw-r--r-- | engines/cruise/vars.h | 12 |
10 files changed, 259 insertions, 211 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp index c4af217117..57a2c0c1ca 100644 --- a/engines/cruise/actor.cpp +++ b/engines/cruise/actor.cpp @@ -580,7 +580,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 } } -//computePathfinding(returnVar2, params.X, params.Y, var34, var35, currentActor->stepX, currentActor->stepY); +//computePathfinding(returnVar2, params.X, params.Y, aniX, aniY, currentActor->stepX, currentActor->stepY); int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 destY, int16 stepX, int16 stepY, int16 oldPathId) { persoStruct *perso; @@ -776,8 +776,8 @@ void processAnimation(void) { if (((animationStart && !currentActor->flag) || (!animationStart && currentActor->x_dest != -1 && currentActor->y_dest != -1)) && (currentActor->type == 0)) { // mouse animation if (!animationStart) { - var34 = currentActor->x_dest; - var35 = currentActor->y_dest; + aniX = currentActor->x_dest; + aniY = currentActor->y_dest; currentActor->x_dest = -1; currentActor->y_dest = -1; @@ -785,7 +785,7 @@ void processAnimation(void) { currentActor->flag = 1; } - currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, var34, var35, currentActor->stepX, currentActor->stepY, currentActor->pathId); + currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, aniX, aniY, currentActor->stepX, currentActor->stepY, currentActor->pathId); if (currentActor->pathId == -1) { if ((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection)) { diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp index 4145ef0b44..0bcdbe12db 100644 --- a/engines/cruise/backgroundIncrust.cpp +++ b/engines/cruise/backgroundIncrust.cpp @@ -109,7 +109,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, newElement->Y = params.Y; newElement->scale = params.scale; newElement->field_E = params.fileIdx; - newElement->var34 = filesDatabase[params.fileIdx].subData.index; + newElement->aniX = filesDatabase[params.fileIdx].subData.index; newElement->ptr = NULL; strcpy(newElement->name, filesDatabase[params.fileIdx].subData.name); @@ -176,7 +176,7 @@ void loadBackgroundIncrustFromSave(FILE *fileHandle) { fread(¤t->field_22, 2, 1, fileHandle); fread(¤t->field_24, 2, 1, fileHandle); fread(current->name, 14, 1, fileHandle); - fread(¤t->var34, 2, 1, fileHandle); + fread(¤t->aniX, 2, 1, fileHandle); if (current->size) { current->ptr = (uint8 *) mallocAndZero(current->size); diff --git a/engines/cruise/backgroundIncrust.h b/engines/cruise/backgroundIncrust.h index 6de30978fd..1e55e366c8 100644 --- a/engines/cruise/backgroundIncrust.h +++ b/engines/cruise/backgroundIncrust.h @@ -48,7 +48,7 @@ struct backgroundIncrustStruct { uint16 field_22; uint16 field_24; char name[14]; - uint16 var34; + uint16 aniX; }; extern backgroundIncrustStruct backgroundIncrustHead; diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 202504a297..ab9e4ce646 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -605,9 +605,9 @@ int removeFinishedScripts(scriptInstanceStruct *ptrHandle) { return (0); } -int nePasAffichierMenuDialogue; -int var37 = 0; -int var38 = 0; +int buttonDown; +int selectDown = 0; +int menuDown = 0; int getCursorFromObject(int mouseX, int mouseY, int *outX, int *outY) { int16 var_2; @@ -626,99 +626,101 @@ int getCursorFromObject(int mouseX, int mouseY, int *outX, int *outY) { cellStruct *currentObject = cellHead.prev; - while (currentObject) { - if (currentObject->overlay >= 0 && overlayTable[currentObject->overlay].alreadyLoaded - && (currentObject->type == 4 || currentObject->type == 1 - || currentObject->type == 9 || currentObject->type == 3)) { - strcpy(objectName, - getObjectName(currentObject->idx, - overlayTable[currentObject->overlay].ovlData->specialString2)); - - if (strlen(objectName)) { - if (currentObject->freeze == 0) { - var_2 = currentObject->idx; - var_4 = currentObject->overlay; - var_14 = currentObject->followObjectIdx; - var_16 = currentObject->followObjectOverlayIdx; - - getMultipleObjectParam(currentObject->overlay, currentObject->idx, ¶ms); - - var_10 = 0; - var_E = 0; - var_C = 0; - - if ((var_4 != var_16) - && (var_2 != var_14)) { - getMultipleObjectParam - (var_16, var_14, ¶ms); - - var_C = params.X; - var_E = params.Y; - var_10 = params.fileIdx; - } + while (currentObject) + { + if (currentObject->overlay >= 0 && overlayTable[currentObject->overlay].alreadyLoaded && (currentObject->type == 4 || currentObject->type == 1 || currentObject->type == 9 || currentObject->type == 3)) + { + char* pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->specialString2); + if(pObjectName) + { + strcpy(objectName, pObjectName); - if (params.var5 >= 0 && params.fileIdx >= 0) { - if (currentObject->type == 3) { - assert(0); + if (strlen(objectName)) { + if (currentObject->freeze == 0) { + var_2 = currentObject->idx; + var_4 = currentObject->overlay; + var_14 = currentObject->followObjectIdx; + var_16 = currentObject->followObjectOverlayIdx; - var_2 = params.scale; - var_A = params.X + var_C; + getMultipleObjectParam(currentObject->overlay, currentObject->idx, ¶ms); - // TODO: this var3 is stupid, investigate... - if ((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) { - *outX = var_16; - *outY = var_14; + var_10 = 0; + var_E = 0; + var_C = 0; - return (currentObject->type); - } - } else if (currentObject->type == 4 || - currentObject->type == 1 || - currentObject->type == 9) { - int si; - int var_8; - int di; + if ((var_4 != var_16) + && (var_2 != var_14)) { + getMultipleObjectParam + (var_16, var_14, ¶ms); - var_A = params.X + var_C; - var_6 = params.Y + var_E; + var_C = params.X; + var_E = params.Y; + var_10 = params.fileIdx; + } - di = params.fileIdx; + if (params.var5 >= 0 && params.fileIdx >= 0) { + if (currentObject->type == 3) { + assert(0); - if (di < 0) { - di += var_10; - } + var_2 = params.scale; + var_A = params.X + var_C; -/* if ((filesDatabase[di].subData.resourceType == 8) && (filesDatabase[di].subData.ptr)) { - assert(0); - } -*/ - { - var_4 = filesDatabase[di].resType; - - if (var_4 == 1) { - var_C = filesDatabase[di].widthInColumn / 2; - } else { - var_C = filesDatabase[di].width; + // TODO: this var3 is stupid, investigate... + if ((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) { + *outX = var_16; + *outY = var_14; + + return (currentObject->type); } + } else if (currentObject->type == 4 || + currentObject->type == 1 || + currentObject->type == 9) { + int si; + int var_8; + int di; - var_8 = filesDatabase[di].height; + var_A = params.X + var_C; + var_6 = params.Y + var_E; - var_2 = mouseX - var_A; - si = mouseY - var_6; + di = params.fileIdx; - if (var_2 > 0 && var_C > var_2 && si > 0 && var_8 >= si) { - if (filesDatabase[di].subData.ptr) { - if (var_4 == 1) { - } else { - } + if (di < 0) { + di += var_10; + } + + /* if ((filesDatabase[di].subData.resourceType == 8) && (filesDatabase[di].subData.ptr)) { + assert(0); + } + */ + { + var_4 = filesDatabase[di].resType; + + if (var_4 == 1) { + var_C = filesDatabase[di].widthInColumn / 2; + } else { + var_C = filesDatabase[di].width; + } - printf("should compare to mask in getCursorFromObject...\n"); + var_8 = filesDatabase[di].height; - *outX = var_16; - *outY = var_14; + var_2 = mouseX - var_A; + si = mouseY - var_6; - printf("Selected: %s\n", objectName); + if (var_2 > 0 && var_C > var_2 && si > 0 && var_8 >= si) { + if (filesDatabase[di].subData.ptr) { + if (var_4 == 1) { + } else { + } + + printf("should compare to mask in getCursorFromObject...\n"); + + *outX = var_16; + *outY = var_14; - return currentObject->type; + printf("Selected: %s\n", objectName); + + return currentObject->type; + } } } } @@ -1038,9 +1040,8 @@ int processInventory(void) { return 0; } -int processInput(void) { - menuStruct *var_5C; - +int processInput(void) +{ int16 mouseX = 0; int16 mouseY = 0; int16 button = 0; @@ -1052,28 +1053,31 @@ int processInput(void) { button = 0; - if (sysKey != -1) { + if (sysKey != -1) + { button = sysKey; - mouseX = var11; - mouseY = var12; + mouseX = sysX; + mouseY = sysY; sysKey = -1; - } else { - if (automaticMode == 0) { - getMouseStatus(&main10, &mouseX, &button, &mouseY); - } + } + else if (automaticMode == 0) + { + getMouseStatus(&main10, &mouseX, &button, &mouseY); } - if (button) { - nePasAffichierMenuDialogue = 0; + if (!button) + { + buttonDown = 0; } if (userDelay) { userDelay--; return 0; } - // test both buttons - if (((button & 3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53) { + // test both buttons + if (((button & 3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53) + { changeCursor(0); keyboardVar = 0; return (playerMenu(mouseX, mouseY)); @@ -1083,100 +1087,118 @@ int processInput(void) { return 0; } - if (currentActiveMenu != -1) { - var_5C = menuTable[currentActiveMenu]; - - if (var_5C) { - updateMenuMouse(mouseX, mouseY, var_5C); - } + if ((currentActiveMenu != -1) && menuTable[currentActiveMenu]) + { + updateMenuMouse(mouseX, mouseY, menuTable[currentActiveMenu]); } - if (var6) { + if (dialogueEnabled) + { ASSERT(0); } + else + { + // not in dialogue - if (button & 1) { - if (nePasAffichierMenuDialogue == 0) { - nePasAffichierMenuDialogue = 1; + // left click + if ((button & 1) && (buttonDown == 0)) + { + buttonDown = 1; - if (mouseVar1) { + // is there a relation + if (linkedRelation) + { ASSERT(0); } - - if (var38 == 0) { // are we in inventory mode ? - if (menuTable[0] == 0) { - int X; - int Y; - int objIdx; - - objIdx = - getCursorFromObject(mouseX, mouseY, - &X, &Y); - - if (objIdx != -1) { - //ASSERT(0); - //moveActor(X,Y,mouseVar1); - } else { - var34 = mouseX; - var35 = mouseY; - animationStart = true; - var38 = 0; + else + { + // manage click on object menu + if (menuDown == 0) + { + // Handle left click on an object + if (menuTable[0] == 0) + { + int X; + int Y; + int objIdx; + + objIdx = getCursorFromObject(mouseX, mouseY, &X, &Y); + + if (objIdx != -1) + { + ASSERT(0); + }else { + // No object found, we move the character to the cursor + aniX = mouseX; + aniY = mouseY; + animationStart = true; + menuDown = 0; + } + } + else + { + ASSERT(0); } } - //ASSERT(0); - } else { - if (processInventory()) { - var37 = 1; - currentActiveMenu = 0; - var38 = 0; - } else { - currentActiveMenu = -1; - var38 = 0; + else + { + // Handle left click in inventory + if (processInventory()) + { + currentActiveMenu = 0; + selectDown = 1; + menuDown = 0; + } else { + currentActiveMenu = -1; + menuDown = 0; + } } - - return 0; } - - //ASSERT(0); } - } - - if ((button & 2) || (keyboardVar == 0x43) || (keyboardVar == 0x52)) { - if (nePasAffichierMenuDialogue == 0) { - keyboardVar = 0; - - if ((mouseVar1 == 0) && (menuTable[0])) { - ASSERT(0); - freeMenu(menuTable[0]); - menuTable[0] = NULL; - var37 = 0; - var38 = 0; - currentActiveMenu = -1; - } - - if (var37 || var38 || menuTable[1]) { - nePasAffichierMenuDialogue = 1; - return 0; - } + // test right button + else if ((button & 2) || (keyboardVar == 0x43) || (keyboardVar == 0x52)) + { + if (buttonDown == 0) + { + keyboardVar = 0; + + // close object menu if there is no linked relation + if ((linkedRelation == 0) && (menuTable[0])) { + freeMenu(menuTable[0]); + menuTable[0] = NULL; + selectDown = 0; + menuDown = 0; + currentActiveMenu = -1; + } - buildInventory(mouseX, mouseY); + if ((!selectDown) && (!menuDown) && (menuTable[1] == NULL)) + { + buildInventory(mouseX, mouseY); - if (menuTable[1]) { - currentActiveMenu = 1; - var38 = 1; - } else { - var38 = 1; + if (menuTable[1]) { + currentActiveMenu = 1; + menuDown = 1; + } else { + menuDown = 1; + } + } + buttonDown = 1; } - - nePasAffichierMenuDialogue = 1; - return 0; } } return 0; } -int oldMouseX; -int oldMouseY; +int currentMouseX = 0; +int currentMouseY = 0; +int currentMouseButton = 0; + +void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY) +{ + *pMouseX = currentMouseX; + *pMouseY = currentMouseY; + *pMouseButton = currentMouseButton; +} bool bFastMode = false; @@ -1186,18 +1208,41 @@ void manageEvents() { Common::EventManager * eventMan = g_system->getEventManager(); while (eventMan->pollEvent(event)) { switch (event.type) { - /* case Common::EVENT_LBUTTONDOWN: - * mouseLeft = 1; - * break; - * case Common::EVENT_RBUTTONDOWN: - * mouseRight = 1; - * break; - * case Common::EVENT_MOUSEMOVE: - * break; */ + case Common::EVENT_LBUTTONDOWN: + currentMouseButton |= 1; + break; + case Common::EVENT_LBUTTONUP: + currentMouseButton &= ~1; + break; + case Common::EVENT_RBUTTONDOWN: + currentMouseButton |= 2; + break; + case Common::EVENT_RBUTTONUP: + currentMouseButton &= ~2; + break; + case Common::EVENT_MOUSEMOVE: + currentMouseX = event.mouse.x; + currentMouseY = event.mouse.y; + break; case Common::EVENT_QUIT: g_system->quit(); break; + case Common::EVENT_KEYUP: + switch(event.kbd.keycode) + { + case 27: // ESC + currentMouseButton &= ~4; + break; + } + break; case Common::EVENT_KEYDOWN: + switch(event.kbd.keycode) + { + case 27: // ESC + currentMouseButton |= 4; + break; + } + /* * switch (event.kbd.keycode) { * case '\n': @@ -1297,10 +1342,6 @@ void manageEvents() { } void mainLoop(void) { -#define SPEED 40 /* Ticks per Frame */ -#define SLEEP_MIN 20 /* Minimum time a sleep takes, usually 2*GRAN */ -#define SLEEP_GRAN 1 /* Granularity of sleep */ - int frames = 0; /* Number of frames displayed */ //int32 t_start,t_left; //uint32 t_end; @@ -1316,7 +1357,7 @@ void mainLoop(void) { initVar4[0] = 0; currentActiveMenu = -1; main14 = -1; - mouseVar1 = 0; + linkedRelation = 0; main21 = 0; main22 = 0; main7 = 0; diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index fb191ee8b2..72372f62a6 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -1007,7 +1007,7 @@ void mainDraw(int16 param) { } } - if (mouseVar1) { + if (linkedRelation) { ASSERT(0); // TODO: draw mouse here } diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index 1a3b5c6521..6a3fc4efea 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -168,6 +168,8 @@ void updateMenuMouse(int mouseX, int mouseY, menuStruct *pMenu) { } } +void manageEvents(); + int processMenu(menuStruct *pMenu) { int16 mouseX; int16 mouseY; @@ -198,6 +200,8 @@ int processMenu(menuStruct *pMenu) { mainDraw(1); flipScreen(); + manageEvents(); + // readKeyboard(); } while (!si); @@ -224,16 +228,16 @@ int playerMenu(int menuX, int menuY) { if (currentMenu) { freeMenu(currentMenu); currentMenu = 0; - var37 = 0; - var38 = 0; + selectDown = 0; + menuDown = 0; main9 = -1; } if (inventoryMenu) { freeMenu(inventoryMenu); inventoryMenu = 0; - var37 = 0; - var38 = 0; + selectDown = 0; + menuDown = 0; main9 = -1; }*/ @@ -242,7 +246,7 @@ int playerMenu(int menuX, int menuY) { } */ /* mouseVar2 = 0; - mouseVar1 = 0; */ + linkedRelation = 0; */ freeDisk(); menuTable[0] = createMenu(menuX, menuY, "Menu Joueur"); diff --git a/engines/cruise/mouse.cpp b/engines/cruise/mouse.cpp index e7a3fc3f98..0dcd41fa9d 100644 --- a/engines/cruise/mouse.cpp +++ b/engines/cruise/mouse.cpp @@ -28,7 +28,7 @@ namespace Cruise { int16 main10; - +#if 0 void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY) { // mouseStatusStruct localStatus; @@ -48,5 +48,6 @@ void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, *pMouseButton |= 4; */ } +#endif } // End of namespace Cruise diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index 189bde1ea1..b0ebc58453 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -197,13 +197,13 @@ int loadSavegameData(int saveGameIdx) { fread(&var3, 2, 1, fileHandle); fread(&var4, 2, 1, fileHandle); fread(&userEnabled, 2, 1, fileHandle); - fread(&var6, 2, 1, fileHandle); + fread(&dialogueEnabled, 2, 1, fileHandle); fread(&var7, 2, 1, fileHandle); fread(&var8, 2, 1, fileHandle); fread(&userDelay, 2, 1, fileHandle); fread(&sysKey, 2, 1, fileHandle); - fread(&var11, 2, 1, fileHandle); - fread(&var12, 2, 1, fileHandle); + fread(&sysX, 2, 1, fileHandle); + fread(&sysY, 2, 1, fileHandle); fread(&var13, 2, 1, fileHandle); fread(&var14, 2, 1, fileHandle); fread(&affichePasMenuJoueur, 2, 1, fileHandle); @@ -224,8 +224,8 @@ int loadSavegameData(int saveGameIdx) { fread(&var30, 2, 1, fileHandle); fread(&var31, 2, 1, fileHandle); - fread(&var34, 2, 1, fileHandle); - fread(&var35, 2, 1, fileHandle); + fread(&aniX, 2, 1, fileHandle); + fread(&aniY, 2, 1, fileHandle); int16 bTemp; fread(&bTemp, 2, 1, fileHandle); animationStart = bTemp != 0; diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp index 094680f0bb..bdd46da022 100644 --- a/engines/cruise/vars.cpp +++ b/engines/cruise/vars.cpp @@ -57,7 +57,7 @@ int16 numOfDisks; uint8 scriptNameBuffer[15]; int16 currentActiveMenu; int16 main14; -int16 mouseVar1; +int16 linkedRelation; int16 main21; int16 main22; int16 main7; @@ -114,21 +114,23 @@ int16 var3; int16 var4; int16 userEnabled; int16 var5; -int16 var6; +int16 dialogueEnabled; int16 var7; int16 var8; int16 userDelay; + int16 sysKey = -1; -int16 var11 = 0; -int16 var12; +int16 sysX = 0; +int16 sysY = 0; + int16 var13; int16 var14; int16 var20; int16 var23; int16 var24; int16 automaticMode; -int16 var34; -int16 var35; +int16 aniX; +int16 aniY; bool animationStart; int16 main17; diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h index dbace8bdf3..1d747d94b8 100644 --- a/engines/cruise/vars.h +++ b/engines/cruise/vars.h @@ -159,7 +159,7 @@ extern int16 numOfDisks; extern uint8 scriptNameBuffer[15]; extern int16 currentActiveMenu; extern int16 main14; -extern int16 mouseVar1; +extern int16 linkedRelation; extern int16 main21; extern int16 main22; extern int16 main7; @@ -215,21 +215,21 @@ extern int16 var3; extern int16 var4; extern int16 userEnabled; extern int16 var5; -extern int16 var6; +extern int16 dialogueEnabled; extern int16 var7; extern int16 var8; extern int16 userDelay; extern int16 sysKey; -extern int16 var11; -extern int16 var12; +extern int16 sysX; +extern int16 sysY; extern int16 var13; extern int16 var14; extern int16 var20; extern int16 var23; extern int16 var24; extern int16 automaticMode; -extern int16 var34; -extern int16 var35; +extern int16 aniX; +extern int16 aniY; extern bool animationStart; extern int16 main17; |