int16 Op_FreezeCell() { int newFreezz = popVar(); int oldFreeze = popVar(); int backgroundPlante = popVar(); int objType = popVar(); int objIdx = popVar(); int overlayIdx = popVar(); if (!overlayIdx) { overlayIdx = currentScriptPtr->overlayNumber; } freezeCell(&cellHead, overlayIdx, objIdx, objType, backgroundPlante, oldFreeze, newFreezz); return 0; }
void CruiseEngine::mainLoop() { //int32 t_start,t_left; //uint32 t_end; //int32 q=0; /* Dummy */ int16 mouseX, mouseY; int16 mouseButton; int enableUser = 0; strcpy(nextOverlay, ""); strcpy(lastOverlay, ""); strcpy(cmdLine, ""); currentActiveMenu = -1; autoMsg = -1; linkedRelation = 0; main21 = 0; main22 = 0; userWait = 0; autoTrack = false; initAllData(); playerDontAskQuit = 0; int quitValue2 = 1; int quitValue = 0; if (ConfMan.hasKey("save_slot")) loadGameState(ConfMan.getInt("save_slot")); do { // Handle frame delay uint32 currentTick = g_system->getMillis(); if (!bFastMode) { // Delay for the specified amount of time, but still respond to events bool skipEvents = false; do { g_system->delayMillis(10); currentTick = g_system->getMillis(); if (!skipEvents) skipEvents = manageEvents(); if (playerDontAskQuit) break; _vm->getDebugger()->onFrame(); } while (currentTick < lastTick + _gameSpeed); } else { manageEvents(); if (currentTick >= (lastTickDebug + 10)) { lastTickDebug = currentTick; _vm->getDebugger()->onFrame(); } } if (playerDontAskQuit) break; lastTick = g_system->getMillis(); // Handle switchover in game speed after intro if (!_speedFlag && canLoadGameStateCurrently()) { _speedFlag = true; _gameSpeed = GAME_FRAME_DELAY_2; } // Handle the next frame // frames++; // t_start=Osystem_GetTicks(); // readKeyboard(); bool isUserWait = userWait != 0; playerDontAskQuit = processInput(); if (playerDontAskQuit) break; if (enableUser) { userEnabled = 1; enableUser = 0; } if (userDelay && !userWait) { userDelay--; continue; } if (isUserWait & !userWait) { // User waiting has ended changeScriptParamInList(-1, -1, &procHead, 9999, 0); changeScriptParamInList(-1, -1, &relHead, 9999, 0); // Disable any mouse click used to end the user wait currentMouseButton = 0; } // FIXME: I suspect that the original game does multiple script executions between game frames; the bug with // Raoul appearing when looking at the book is being there are 3 script iterations separation between the // scene being changed to the book, and the Raoul actor being frozen/disabled. This loop is a hack to ensure // that when a background changes, a few extra script executions are done bool bgChanged; int numIterations = 1; while (numIterations-- > 0) { bgChanged = backgroundChanged[masterScreen]; manageScripts(&relHead); manageScripts(&procHead); removeFinishedScripts(&relHead); removeFinishedScripts(&procHead); if (!bgChanged && backgroundChanged[masterScreen]) { bgChanged = true; numIterations += 2; } } processAnimation(); if (remdo) { // ASSERT(0); /* main3 = 0; * var24 = 0; * var23 = 0; * * freeStuff2(); */ } if (cmdLine[0]) { ASSERT(0); /* redrawStrings(0,&cmdLine,8); waitForPlayerInput(); cmdLine = 0; */ } if (displayOn) { if (doFade) PCFadeFlag = 0; /*if (!PCFadeFlag)*/ mainDraw(userWait); flipScreen(); if (userEnabled && !userWait && !autoTrack) { if (currentActiveMenu == -1) { static int16 oldMouseX = -1; static int16 oldMouseY = -1; getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); if (mouseX != oldMouseX || mouseY != oldMouseY) { int objectType; int newCursor1; int newCursor2; oldMouseX = mouseX; oldMouseY = mouseY; objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2); if (objectType == 9) { changeCursor(CURSOR_EXIT); } else if (objectType != -1) { changeCursor(CURSOR_MAGNIFYING_GLASS); } else { changeCursor(CURSOR_WALK); } } } else { changeCursor(CURSOR_NORMAL); } } else { changeCursor(CURSOR_NORMAL); } if (userWait == 1) { // Waiting for press - original wait loop has been integrated into the // main event loop continue; } // wait for character to finish auto track if (autoTrack) { if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) { if (autoMsg != -1) { freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0); char* pText = getText(autoMsg, autoOvl); if (strlen(pText)) userWait = 1; } changeScriptParamInList(-1, -1, &relHead, 9998, 0); autoTrack = false; enableUser = 1; } else { userEnabled = false; } } else if (autoMsg != -1) { removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen); autoMsg = -1; } } else { // Keep ScummVM being responsive even when displayOn is false g_system->updateScreen(); } } while (!playerDontAskQuit && quitValue2 && quitValue != 7); // Free data removeAllScripts(&relHead); removeAllScripts(&procHead); resetActorPtr(&actorHead); freeOverlayTable(); closeCnf(); closeBase(); resetFileEntryRange(0, NUM_FILE_ENTRIES); freeObjectList(&cellHead); freeBackgroundIncrustList(&backgroundIncrustHead); }
void initVars() { closeAllMenu(); resetFileEntryRange(0, NUM_FILE_ENTRIES); resetPreload(); freeCTP(); freeBackgroundIncrustList(&backgroundIncrustHead); freezeCell(&cellHead, -1, -1, -1, -1, -1, 0); // TODO: unfreeze anims freeObjectList(&cellHead); removeAnimation(&actorHead, -1, -1, -1); removeAllScripts(&relHead); removeAllScripts(&procHead); changeScriptParamInList(-1, -1, &procHead, -1, 0); removeFinishedScripts(&procHead); changeScriptParamInList(-1, -1, &relHead, -1, 0); removeFinishedScripts(&relHead); for (unsigned long int i = 0; i < 90; i++) { if (strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded) { unloadOverlay(overlayTable[i].overlayName, i); } } // TODO: // stopSound(); // removeSound(); closeBase(); closeCnf(); initOverlayTable(); stateID = 0; masterScreen = 0; freeDisk(); soundList[0].frameNum = -1; soundList[1].frameNum = -1; soundList[2].frameNum = -1; soundList[3].frameNum = -1; for (unsigned long int i = 0; i < 8; i++) { menuTable[i] = NULL; } for (unsigned long int i = 0; i < 2000; i++) { globalVars[i] = 0; } for (unsigned long int i = 0; i < 8; i++) { backgroundTable[i].name[0] = 0; } for (unsigned long int i = 0; i < NUM_FILE_ENTRIES; i++) { filesDatabase[i].subData.ptr = NULL; filesDatabase[i].subData.ptrMask = NULL; } initBigVar3(); resetPtr2(&procHead); resetPtr2(&relHead); resetPtr(&cellHead); resetActorPtr(&actorHead); resetBackgroundIncrustList(&backgroundIncrustHead); vblLimit = 0; remdo = 0; songLoaded = 0; songPlayed = 0; songLoop = 1; activeMouse = 0; userEnabled = 1; dialogueEnabled = 0; dialogueOvl = 0; dialogueObj = 0; userDelay = 0; sysKey = -1; sysX = 0; sysY = 0; automoveInc = 0; automoveMax = 0; displayOn = true; // here used to init clip isMessage = 0; fadeFlag = 0; automaticMode = 0; // video param (vga and mcga mode) titleColor = 2; itemColor = 1; selectColor = 3; subColor = 5; // narratorOvl = 0; narratorIdx = 0; aniX = 0; aniY = 0; animationStart = false; selectDown = 0; menuDown = 0; buttonDown = 0; var41 = 0; playerMenuEnabled = 0; PCFadeFlag = 0; }
void callRelation(menuElementSubStruct *pMenuElement, int nObj2) { if (pMenuElement == NULL) return; menuElementSubStruct* pCurrent = pMenuElement; while (pCurrent != NULL) { int ovlIdx = pCurrent->ovlIdx; int header = pCurrent->header; linkDataStruct* pHeader = &overlayTable[ovlIdx].ovlData->arrayMsgRelHeader[header]; if (pHeader->obj2Number == nObj2) { // REL if (pHeader->type == RT_REL) { if (currentScriptPtr) { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); } else { attacheNewScriptToTail(&relHead, ovlIdx, pHeader->id, 30, 0, 0, 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 == RT_MSG) { // MSG int obj1Ovl = pHeader->obj1Overlay; if (!obj1Ovl) obj1Ovl = ovlIdx; int x = 60; int y = 40; if (pHeader->obj1Number >= 0) { objectParamsQuery params; getMultipleObjectParam(obj1Ovl, pHeader->obj1Number, ¶ms); if (narratorOvl > 0) { if ((pHeader->trackX != -1) && (pHeader->trackY != -1) && (pHeader->trackX != 9999) && (pHeader->trackY != 9999)) { x = pHeader->trackX - 100; y = pHeader->trackY - 150; } else { getMultipleObjectParam(narratorOvl, narratorIdx, ¶ms); x = params.X - 100; y = params.Y - 150; } } else if (params.scale >= 0) { x = params.X - 100; y = params.Y - 40; } if (pHeader->obj1NewState != -1) { objInit(obj1Ovl, pHeader->obj1Number, pHeader->obj1NewState); } } if (currentScriptPtr) { createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, currentScriptPtr->overlayNumber, currentScriptPtr->scriptNumber); } else { createTextObject(&cellHead, ovlIdx, pHeader->id, x, y, 200, findHighColor(), masterScreen, 0, 0); } userWait = 1; autoOvl = ovlIdx; autoMsg = pHeader->id; 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; userWait = 0; userEnabled = 0; freezeCell(&cellHead, ovlIdx, pHeader->id, 5, -1, 0, 9998); } } } } else { linkedRelation = pMenuElement; } pCurrent = pCurrent->pNext; } }