aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Hamm2007-11-11 01:04:40 +0000
committerVincent Hamm2007-11-11 01:04:40 +0000
commit1bae92f2e1ba13a57239024942676cf33fec82b0 (patch)
treeb146e65d3bb0593fb0f866adc80e9e898e6d8134
parent31d04d98dcfe9113b39520568bde07737a718f09 (diff)
downloadscummvm-rg350-1bae92f2e1ba13a57239024942676cf33fec82b0.tar.gz
scummvm-rg350-1bae92f2e1ba13a57239024942676cf33fec82b0.tar.bz2
scummvm-rg350-1bae92f2e1ba13a57239024942676cf33fec82b0.zip
Implement dialogues
Detect french 256 colors version svn-id: r29473
-rw-r--r--engines/cruise/cruise_main.cpp187
-rw-r--r--engines/cruise/detection.cpp14
-rw-r--r--engines/cruise/function.cpp80
-rw-r--r--engines/cruise/object.cpp14
-rw-r--r--engines/cruise/object.h2
-rw-r--r--engines/cruise/saveload.cpp4
-rw-r--r--engines/cruise/vars.cpp5
-rw-r--r--engines/cruise/vars.h5
8 files changed, 291 insertions, 20 deletions
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index f076fcc0d6..c2948f0c3d 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -858,6 +858,117 @@ menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu) {
return NULL;
}
+bool createDialog(int objOvl, int objIdx, int x, int y) {
+ bool found = false;
+ bool first = true;
+ int testState1 = -1;
+ int testState2 = -1;
+ int j;
+ int16 objectState;
+ int16 objectState2;
+
+ getSingleObjectParam(objOvl, objIdx, 5, &objectState);
+
+ menuTable[0] = createMenu(x, y, "Parler de...");
+
+ for (j = 1; j < numOfLoadedOverlay; j++) {
+ if (overlayTable[j].alreadyLoaded) {
+ int idHeader = overlayTable[j].ovlData->numMsgRelHeader;
+
+ for (int i=0; i<idHeader; i++) {
+ linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i];
+ int thisOvl = ptrHead->obj1Overlay;
+
+ if (!thisOvl) {
+ thisOvl = j;
+ }
+
+ objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number);
+
+ getSingleObjectParam(thisOvl, ptrHead->obj1Number, 5, &objectState2);
+
+ if (pObject && (pObject->_class == THEME) && (objectState2 <-1)) {
+
+ thisOvl = ptrHead->obj2Overlay;
+ if (!thisOvl) {
+ thisOvl = j;
+ }
+
+ if((thisOvl==objOvl) && (ptrHead->obj2Number==objIdx)) {
+ int verbeOvl = ptrHead->verbOverlay;
+ int obj1Ovl = ptrHead->obj1Overlay;
+ int obj2Ovl = ptrHead->obj2Overlay;
+
+ if (!verbeOvl) verbeOvl=j;
+ if (!obj1Ovl) obj1Ovl=j;
+ if (!obj2Ovl) obj2Ovl=j;
+
+ char verbe_name[80];
+ char obj1_name[80];
+ char obj2_name[80];
+ char r_verbe_name[80];
+ char r_obj1_name[80];
+ char r_obj2_name[80];
+
+ verbe_name[0] =0;
+ obj1_name[0] =0;
+ obj2_name[0] =0;
+ r_verbe_name[0] =0;
+ r_obj1_name[0] =0;
+ r_obj2_name[0] =0;
+
+ ovlDataStruct *ovl2 = NULL;
+ ovlDataStruct *ovl3 = NULL;
+ ovlDataStruct *ovl4 = NULL;
+
+ if (verbeOvl > 0)
+ ovl2 = overlayTable[verbeOvl].ovlData;
+
+ if (obj1Ovl > 0)
+ ovl3 = overlayTable[obj1Ovl].ovlData;
+
+ if (obj2Ovl > 0)
+ ovl4 = overlayTable[obj2Ovl].ovlData;
+
+ if ((ovl3) && (ptrHead->obj1Number >= 0)) {
+ testState1 = ptrHead->obj1OldState;
+ }
+ if ((ovl4) && (ptrHead->obj2Number >= 0)) {
+ testState2 = ptrHead->obj2OldState;
+ }
+
+ if ((ovl4) && (ptrHead->verbNumber>=0) &&
+ ((testState1 == -1) || (testState1 == objectState2)) &&
+ ((testState2 == -1) || (testState2 == objectState)) ) {
+ if (ovl2->nameVerbGlob) {
+ const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob);
+ strcpy(verbe_name, ptr);
+
+ if (!strlen(verbe_name))
+ attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL);
+ else if (ovl2->nameVerbGlob) {
+ found = true;
+ int color;
+
+ if(objectState2==-2)
+ color = colorOfSelectedSaveDrive;
+ else
+ color = -1;
+
+ ptr = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj);
+ addSelectableMenuEntry(j, i, menuTable[0], 1, color, ptr);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return found;
+}
+
bool findRelation(int objOvl, int objIdx, int x, int y) {
bool found = false;
bool first = true;
@@ -1094,7 +1205,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) {
}
if (pHeader->obj1NewState != -1) {
- ASSERT(0);
+ objInit(obj1Ovl, pHeader->obj1Number, pHeader->obj1NewState);
}
}
@@ -1141,6 +1252,25 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) {
}
}
+void closeAllMenu(void) {
+ if(menuTable[0]) {
+ freeMenu(menuTable[0]);
+ menuTable[0] = NULL;
+ }
+
+ if(menuTable[1]) {
+ freeMenu(menuTable[1]);
+ menuTable[1] = NULL;
+ }
+ if (linkedMsgList) {
+ ASSERT(0);
+// freeMsgList(linkedMsgList);
+ }
+
+ linkedMsgList = NULL;
+ linkedRelation = NULL;
+}
+
int processInput(void) {
int16 mouseX = 0;
int16 mouseY = 0;
@@ -1187,7 +1317,55 @@ int processInput(void) {
}
if (dialogueEnabled) {
- ASSERT(0);
+
+ if( menuDown || selectDown || linkedRelation ) {
+ closeAllMenu();
+ menuDown = 0;
+ selectDown = 0;
+ currentActiveMenu = -1;
+ changeCursor(CURSOR_NORMAL);
+ }
+
+ if((menuTable[0]==NULL) && (!buttonDown)) {
+ int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0);
+
+ if(menuTable[0]) {
+ if(dialogFound) {
+ currentActiveMenu = 0;
+ }
+ else {
+ freeMenu(menuTable[0]);
+ menuTable[0] = NULL;
+ currentActiveMenu = -1;
+ }
+ }
+ else {
+ menuDown = 0;
+ }
+ }
+ else {
+ if((button & 1) && (buttonDown == 0)) {
+ if(menuTable[0]) {
+ callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj);
+
+ freeMenu(menuTable[0]);
+ menuTable[0] = NULL;
+
+ if (linkedMsgList) {
+ ASSERT(0);
+ // freeMsgList(linkedMsgList);
+ }
+
+ linkedMsgList = NULL;
+ linkedRelation = NULL;
+
+ changeCursor(CURSOR_NORMAL);
+ currentActiveMenu = -1;
+ }
+ buttonDown = 1;
+ }
+ }
+
} else if ((button & 1) && (buttonDown == 0)) {
// left click
buttonDown = 1;
@@ -1220,6 +1398,8 @@ int processInput(void) {
} else { // call sub relation when clicking in inventory
ASSERT(0);
}
+ selectDown = 0;
+ menuDown = 0;
} else {
// manage click on object menu
if (menuDown == 0) {
@@ -1281,6 +1461,9 @@ int processInput(void) {
changeCursor(CURSOR_CROSS);
}
}
+
+ currentActiveMenu = -1;
+ selectDown = 0;
}
} else {
// Handle left click in inventory
diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp
index 1c311dc39d..c1f6d1e377 100644
--- a/engines/cruise/detection.cpp
+++ b/engines/cruise/detection.cpp
@@ -64,7 +64,7 @@ static const CRUISEGameDescription gameDescriptions[] = {
{
{
"cruise",
- "",
+ "16 colors",
AD_ENTRY1("D1", "41a7a4d426dbd048eb369cfee4bb2717"),
Common::FR_FRA,
Common::kPlatformPC,
@@ -74,6 +74,18 @@ static const CRUISEGameDescription gameDescriptions[] = {
0,
},
{
+ {
+ "cruise",
+ "256 colors",
+ AD_ENTRY1("D1", "e258865807ea31b2d523340e6f0a606b"),
+ Common::FR_FRA,
+ Common::kPlatformPC,
+ Common::ADGF_NO_FLAGS
+ },
+ GType_CRUISE,
+ 0,
+ },
+ {
{
"cruise",
"256 colors",
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index b05d80874d..46d938b849 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -1360,26 +1360,47 @@ int16 Op_60(void) {
}
int16 Op_6F(void) {
- int numArgs = popVar();
+ int nbp = popVar();
+ int param[160];
+ char txt[40];
+ char format[30];
+ char nbf[20];
- assert(numArgs == 0);
+ for(int i=nbp-1; i>= 0; i--)
+ param[i] = popVar();
- {
- popVar();
- char *string = (char *)popPtr();
+ int val = popVar();
+ char* pDest = (char*)popPtr();
- printf("partial opcode 6F sprintf (%s)\n", string);
+ if(!nbp)
+ sprintf(txt, "%d", val);
+ else
+ {
+ strcpy(format, "%");
+ sprintf(nbf, "%d", param[0]);
+ strcat(format, nbf );
+ strcat(format, "d");
+ sprintf(txt, format, val);
}
+ for(int i=0; txt[i]; i++)
+ *(pDest++) = txt[i];
+ *(pDest++) = '\0';
+
return 0;
}
int16 Op_6E(void) {
- char *ptr0 = (char *)popPtr();
- char *ptr1 = (char *)popPtr();
+ char *pSource = (char *)popPtr();
+ char *pDest = (char *)popPtr();
- printf("partial opcode 6E (%s)(%s)\n", ptr0, ptr1);
+ while(*pDest)
+ pDest++;
+ while(*pSource)
+ *(pDest++) = *(pSource++);
+ *(pDest++) = '\0';
+
return 0;
}
@@ -1419,7 +1440,7 @@ int16 Op_SetObjectAtNode(void) {
int16 ovl = popVar();
if (!ovl)
- ovl = currentScriptPtr->overlayNumber;;
+ ovl = currentScriptPtr->overlayNumber;
int nodeInfo[2];
@@ -1476,6 +1497,42 @@ int16 Op_SetNodeColor(void) {
return 0;
}
+int16 Op_SetXDial(void) {
+ int16 old;
+
+ old = xdial;
+ xdial = popVar();
+
+ return old;
+}
+
+int16 Op_DialogOn(void) {
+ dialogueObj = popVar();
+ dialogueOvl = popVar();
+
+ if(dialogueOvl == 0)
+ dialogueOvl = currentScriptPtr->overlayNumber;
+
+ dialogueEnabled = true;
+
+ return 0;
+}
+
+int16 Op_DialogOff(void) {
+ dialogueEnabled = false;
+
+ objectReset();
+
+ if(menuTable[0]) {
+ freeMenu(menuTable[0]);
+ menuTable[0] = NULL;
+ changeCursor(CURSOR_NORMAL);
+ currentActiveMenu = -1;
+ }
+
+ return 0;
+}
+
void setupOpcodeTable(void) {
int i;
@@ -1528,6 +1585,8 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x30] = Op_RemoveBackgroundIncrust;
opcodeTablePtr[0x31] = Op_UnmergeBackgroundIncrust;
opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList;
+ opcodeTablePtr[0x33] = Op_DialogOn;
+ opcodeTablePtr[0x34] = Op_DialogOff;
opcodeTablePtr[0x37] = Op_37;
opcodeTablePtr[0x38] = Op_removeBackground;
opcodeTablePtr[0x39] = Op_SetActiveBackgroundPlane;
@@ -1568,6 +1627,7 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x70] = Op_comment;
opcodeTablePtr[0x71] = Op_SetColorrawLine;
opcodeTablePtr[0x72] = Op_InitializeState2;
+ opcodeTablePtr[0x73] = Op_SetXDial;
opcodeTablePtr[0x74] = Op_GetInitVar1;
opcodeTablePtr[0x76] = Op_InitializeState6;
opcodeTablePtr[0x79] = Op_PlayFXnterPlayerMenu;
diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp
index 79caf06986..fdcf51323e 100644
--- a/engines/cruise/object.cpp
+++ b/engines/cruise/object.cpp
@@ -308,4 +308,18 @@ int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 *
return 0;
}
+void objectReset(void) {
+ for(int i=1; i<numOfLoadedOverlay; i++) {
+ if(overlayTable[i].alreadyLoaded && overlayTable[i].ovlData) {
+ if(overlayTable[i].ovlData->arrayObject) {
+ for(int j=0; j<overlayTable[i].ovlData->numObj; j++) {
+ int stateIdx = overlayTable[i].state + overlayTable[i].ovlData->arrayObject[j]._stateTableIdx;
+ if((overlayTable[i].ovlData->arrayObject[j]._class == THEME) && (globalVars[stateIdx] == -2))
+ globalVars[stateIdx] = 0;
+ }
+ }
+ }
+ }
+}
+
} // End of namespace Cruise
diff --git a/engines/cruise/object.h b/engines/cruise/object.h
index 8d2a432b2e..ecfc61d879 100644
--- a/engines/cruise/object.h
+++ b/engines/cruise/object.h
@@ -51,7 +51,7 @@ struct objectParamsQuery {
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 * returnParam);
int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuery * returnParam);
-
+void objectReset(void);
} // End of namespace Cruise
#endif
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp
index 8e30909ae4..310545e02f 100644
--- a/engines/cruise/saveload.cpp
+++ b/engines/cruise/saveload.cpp
@@ -230,8 +230,8 @@ int loadSavegameData(int saveGameIdx) {
userEnabled = currentSaveFile.readSint16LE();
dialogueEnabled = currentSaveFile.readSint16LE();
- var7 = currentSaveFile.readSint16LE();
- var8 = currentSaveFile.readSint16LE();
+ dialogueOvl = currentSaveFile.readSint16LE();
+ dialogueObj = currentSaveFile.readSint16LE();
userDelay = currentSaveFile.readSint16LE();
sysKey = currentSaveFile.readSint16LE();
sysX = currentSaveFile.readSint16LE();
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index 36bf02a3a4..34a67d34b8 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -92,6 +92,7 @@ int16 positionInStack;
actorStruct actorHead;
int16 stateID;
+int16 xdial = 0;
uint8 *currentData3DataPtr;
uint8 *scriptDataPtrTable[7];
@@ -110,8 +111,8 @@ int16 var4;
int16 userEnabled;
int16 var5;
int16 dialogueEnabled;
-int16 var7;
-int16 var8;
+int16 dialogueOvl;
+int16 dialogueObj;
int16 userDelay;
int16 sysKey = -1;
diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h
index 886fe10470..6bebf75101 100644
--- a/engines/cruise/vars.h
+++ b/engines/cruise/vars.h
@@ -185,6 +185,7 @@ extern int16 positionInStack;
extern actorStruct actorHead;
extern int16 stateID;
+extern int16 xdial;
extern uint8 *currentData3DataPtr;
extern uint8 *scriptDataPtrTable[7];
@@ -203,8 +204,8 @@ extern int16 var4;
extern int16 userEnabled;
extern int16 var5;
extern int16 dialogueEnabled;
-extern int16 var7;
-extern int16 var8;
+extern int16 dialogueOvl;
+extern int16 dialogueObj;
extern int16 userDelay;
extern int16 sysKey;
extern int16 sysX;