/** * Store the facts pertaining to a scene change. */ void SetNewScene(SCNHANDLE scene, int entrance, int transition) { if (!bCuttingScene && TinselV2) WrapScene(); // If we're loading from the GMM, load the scene as a delayed one if (loadingFromGMM) { DelayedScene.scene = scene; DelayedScene.entry = entrance; DelayedScene.trans = transition; loadingFromGMM = false; return; } // If CD change will be required, stick in the scene change scene if (CdNumber(scene) != GetCurrentCD()) { // This scene gets delayed DelayedScene.scene = scene; DelayedScene.entry = entrance; DelayedScene.trans = transition; NextScene.scene = hCdChangeScene; NextScene.entry = CdNumber(scene) - '0'; NextScene.trans = TRANS_FADE; return; } if (HookScene.scene == 0 || bCuttingScene) { // This scene comes next NextScene.scene = scene; NextScene.entry = entrance; NextScene.trans = transition; } else { // This scene gets delayed DelayedScene.scene = scene; DelayedScene.entry = entrance; DelayedScene.trans = transition; // The hooked scene comes next NextScene.scene = HookScene.scene; NextScene.entry = HookScene.entry; NextScene.trans = HookScene.trans; HookScene.scene = 0; } // Workaround for "Missing Red Dragon in square" bug in Discworld 1 PSX, act IV. // This happens with the original interpreter on PSX too: the red dragon in Act IV // doesn't show up inside the square at the right time. Original game required the // player to go in and out the square until the dragon appears (wasting hours). // I'm forcing the load of the right scene by checking that the player has (or has not) the // right items: player must have Mambo the swamp dragon, and mustn't have fireworks (used on // the swamp dragon previously to "load it up"). if (TinselV1PSX && NextScene.scene == 0x1800000 && NextScene.entry == 2) { if ((IsInInventory(261, INV_1) || IsInInventory(261, INV_2)) && (!IsInInventory(232, INV_1) && !IsInInventory(232, INV_2))) NextScene.entry = 1; } }
static bool DoSync(Common::Serializer &s, int numInterp) { int sg = 0; if (TinselV2) { if (s.isSaving()) g_restoreCD = GetCurrentCD(); s.syncAsSint16LE(g_restoreCD); } if (TinselV2 && s.isLoading()) HoldItem(INV_NOICON); syncSavedData(s, *g_srsd, numInterp); syncGlobInfo(s); // Glitter globals syncInvInfo(s); // Inventory data // Held object if (s.isSaving()) sg = WhichItemHeld(); s.syncAsSint32LE(sg); if (s.isLoading()) { if (sg != -1 && !GetIsInvObject(sg)) // Not a valid inventory object, so return false return false; if (TinselV2) g_thingHeld = sg; else HoldItem(sg); } syncTimerInfo(s); // Timer data if (!TinselV2) syncPolyInfo(s); // Dead polygon data syncSCdata(s); // Hook Scene and delayed scene s.syncAsSint32LE(*g_SaveSceneSsCount); if (*g_SaveSceneSsCount != 0) { SAVED_DATA *sdPtr = g_SaveSceneSsData; for (int i = 0; i < *g_SaveSceneSsCount; ++i, ++sdPtr) syncSavedData(s, *sdPtr, numInterp); // Flag that there is a saved scene to return to. Note that in this context 'saved scene' // is a stored scene to return to from another scene, such as from the Summoning Book close-up // in Discworld 1 to whatever scene Rincewind was in prior to that g_ASceneIsSaved = true; } if (!TinselV2) syncAllActorsAlive(s); return true; }
int GetCD(int flags) { int i; char cd = '\0'; if (flags & cdFlags[g_currentCD - '1']) return GetCurrentCD(); for (i = 0; i < 8; i++) { if (flags & cdFlags[i]) { cd = (char)(i + '1'); break; } } assert(i != 8); g_nextCD = cd; return cd; }
const char *TinselEngine::getTextFile(LANGUAGE lang) { assert(((unsigned int) lang) < NUM_LANGUAGES); int cd; if (TinselV2) { cd = GetCurrentCD(); assert((cd == 1) || (cd == 2)); if (lang == TXT_ENGLISH) if (_vm->getLanguage() == Common::EN_USA) lang = TXT_US; } else cd = 0; return _textFiles[lang][cd]; }
static void DoSync(Common::Serializer &s) { int sg = 0; if (TinselV2) { if (s.isSaving()) restoreCD = GetCurrentCD(); s.syncAsSint16LE(restoreCD); } if (TinselV2 && s.isLoading()) HoldItem(INV_NOICON); syncSavedData(s, *srsd); syncGlobInfo(s); // Glitter globals syncInvInfo(s); // Inventory data // Held object if (s.isSaving()) sg = WhichItemHeld(); s.syncAsSint32LE(sg); if (s.isLoading()) { if (TinselV2) thingHeld = sg; else HoldItem(sg); } syncTimerInfo(s); // Timer data if (!TinselV2) syncPolyInfo(s); // Dead polygon data syncSCdata(s); // Hook Scene and delayed scene s.syncAsSint32LE(*SaveSceneSsCount); if (*SaveSceneSsCount != 0) { SAVED_DATA *sdPtr = SaveSceneSsData; for (int i = 0; i < *SaveSceneSsCount; ++i, ++sdPtr) syncSavedData(s, *sdPtr); } if (!TinselV2) syncAllActorsAlive(s); }
const char *TinselEngine::getSampleIndex(LANGUAGE lang) { int cd; if (TinselV2) { cd = GetCurrentCD(); assert((cd == 1) || (cd == 2)); assert(((unsigned int) lang) < NUM_LANGUAGES); if (lang == TXT_ENGLISH) if (_vm->getLanguage() == Common::EN_USA) lang = TXT_US; } else { cd = 0; lang = TXT_ENGLISH; } return _sampleIndices[lang][cd]; }
/** * Do restore scene * @param n Id */ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) { switch (n) { case RS_COUNT + COUNTOUT_COUNT: // Trigger pre-load and fade and start countdown FadeOutFast(NULL); break; case RS_COUNT: _vm->_sound->stopAllSamples(); ClearScreen(); // Master script only affected on restore game, not restore scene if (TinselV2 && (sd == &sgData)) { g_scheduler->killMatchingProcess(PID_MASTER_SCR); KillGlobalProcesses(); FreeMasterInterpretContext(); } if (TinselV2) { RestorePolygonStuff(sd->SavedPolygonStuff); // Abandon temporarily if different CD if (sd == &sgData && restoreCD != GetCurrentCD()) { SRstate = SR_IDLE; EndScene(); SetNextCD(restoreCD); CDChangeForRestore(restoreCD); return 0; } } else { RestoreDeadPolys(sd->SavedDeadPolys); } // Start up the scene StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM); SetDoFadeIn(!bNoFade); bNoFade = false; StartupBackground(nullContext, sd->SavedBgroundHandle); if (TinselV2) { Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset); } else { KillScroll(); PlayfieldSetPos(FIELD_WORLD, sd->SavedLoffset, sd->SavedToffset); SetNoBlocking(sd->SavedNoBlocking); } RestoreNoScrollData(&sd->SavedNoScrollData); if (TinselV2) { // create process to sort out the moving actors g_scheduler->createProcess(PID_MOVER, SortMAProcess, NULL, 0); bNotDoneYet = true; RestoreActorZ(sd->savedActorZ); RestoreZpositions(sd->zPositions); RestoreSysVars(sd->SavedSystemVars); CreateGhostPalette(BgPal()); RestoreActors(sd->NumSavedActors, sd->SavedActorInfo); RestoreSoundReels(sd->SavedSoundReels); return 1; } sortActors(sd); break; case 2: break; case 1: if (TinselV2) { if (bNotDoneYet) return n; if (sd == &sgData) HoldItem(thingHeld, true); if (sd->bTinselDim) _vm->_pcmMusic->dim(true); _vm->_pcmMusic->restoreThatTune(sd->SavedTune); ScrollFocus(sd->SavedScrollFocus); } else { RestoreMidiFacts(sd->SavedMidi, sd->SavedLoop); } if (sd->SavedControl) ControlOn(); // Control was on ResumeInterprets(); break; default: break; } return n - 1; }