void GLWidget::paintEvent ( QPaintEvent * e ) { //QGLWidget::paintEvent(e); if (ALLOW_QPAINTER) { ( void ) e; mainDraw(); } else { QGLWidget::paintEvent(e); } }
void GLWidget::paintGL() { mainDraw(); }
Common::Error loadSavegameData(int saveGameIdx) { int lowMemorySave; Common::String saveName; cellStruct *currentcellHead; Common::SaveFileManager *saveMan = g_system->getSavefileManager(); Common::InSaveFile *f = saveMan->openForLoading(_vm->getSavegameFile(saveGameIdx)); if (f == NULL) { printInfoBlackBox("Savegame not found..."); waitForPlayerInput(); return Common::kNoGameDataFoundError; } printInfoBlackBox("Loading in progress..."); initVars(); _vm->sound().stopMusic(); // Skip over the savegame header CruiseSavegameHeader header; readSavegameHeader(f, header); delete header.thumbnail; // Synchronise the remaining data of the savegame Common::Serializer s(f, NULL); DoSync(s); delete f; // Post processing for (int j = 0; j < 64; j++) preloadData[j].ptr = NULL; for (int j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { overlayTable[j].alreadyLoaded = 0; loadOverlay(overlayTable[j].overlayName); if (overlayTable[j].alreadyLoaded) { ovlDataStruct *ovlData = overlayTable[j].ovlData; // overlay BSS if (ovlRestoreData[j]._sBssSize) { if (ovlData->data4Ptr) { MemFree(ovlData->data4Ptr); } ovlData->data4Ptr = ovlRestoreData[j]._pBss; ovlData->sizeOfData4 = ovlRestoreData[j]._sBssSize; } // overlay object data if (ovlRestoreData[j]._sNumObj) { if (ovlData->arrayObjVar) { MemFree(ovlData->arrayObjVar); } ovlData->arrayObjVar = ovlRestoreData[j]._pObj; ovlData->size9 = ovlRestoreData[j]._sNumObj; } } } } updateAllScriptsImports(); lastAni[0] = 0; lowMemorySave = lowMemory; for (int i = 0; i < NUM_FILE_ENTRIES; i++) { if (filesDatabase[i].subData.ptr) { int j; int k; for (j = i + 1; j < NUM_FILE_ENTRIES && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j - i)); j++) ; for (k = i; k < j; k++) { if (filesDatabase[k].subData.ptrMask) lowMemory = 0; filesDatabase[k].subData.ptr = NULL; filesDatabase[k].subData.ptrMask = NULL; } /*if (j < 2) { error("Unsupported mono file load"); //loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4); } else */ if (strlen(filesDatabase[i].subData.name) > 0) { loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i); } else { filesDatabase[i].subData.ptr = NULL; filesDatabase[i].subData.ptrMask = NULL; } i = j - 1; lowMemory = lowMemorySave; } } lastAni[0] = 0; currentcellHead = cellHead.next; while (currentcellHead) { if (currentcellHead->type == 5) { uint8 *ptr = mainProc14(currentcellHead->overlay, currentcellHead->idx); ASSERT(0); if (ptr) { ASSERT(0); //*(int16 *)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16 *)(currentcellHead->datas+0xE)); } else { ASSERT(0); //*(int16 *)(currentcellHead->datas+0x2E) = 0; } } currentcellHead = currentcellHead->next; } if (strlen(currentCtpName)) { loadCtFromSave = 1; initCt(currentCtpName); loadCtFromSave = 0; } //prepareFadeOut(); //gfxModuleData.gfxFunction8(); for (int j = 0; j < 8; j++) { if (strlen((char *)backgroundTable[j].name)) { loadBackground(backgroundTable[j].name, j); } } regenerateBackgroundIncrust(&backgroundIncrustHead); // to finish changeCursor(CURSOR_NORMAL); mainDraw(1); flipScreen(); return Common::kNoError; }
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); }