/** * Called from scroll process - Scrolls the image as appropriate. */ static void ScrollImage() { int OldLoffset = 0, OldToffset = 0; // Used when keeping cursor on a tag int Loffset, Toffset; int curX, curY; // get background offsets PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); /* * Keeping cursor on a tag? */ if (g_ScrollCursor) { GetCursorXYNoWait(&curX, &curY, true); if (InPolygon(curX, curY, TAG) != NOPOLY || InPolygon(curX, curY, EXIT) != NOPOLY) { OldLoffset = Loffset; OldToffset = Toffset; } else g_ScrollCursor = false; } /* * Horizontal scrolling */ if (g_LeftScroll > 0) { g_LeftScroll -= g_scrollPixelsX; if (g_LeftScroll < 0) { Loffset += g_LeftScroll; g_LeftScroll = 0; } Loffset += g_scrollPixelsX; // Move right if (Loffset > g_ImageW - SCREEN_WIDTH) Loffset = g_ImageW - SCREEN_WIDTH;// Now at extreme right /*** New feature to prop up rickety scroll boundaries ***/ if (TinselV2 && SysVar(SV_MaximumXoffset) && (Loffset > SysVar(SV_MaximumXoffset))) Loffset = SysVar(SV_MaximumXoffset); } else if (g_LeftScroll < 0) { g_LeftScroll += g_scrollPixelsX; if (g_LeftScroll > 0) { Loffset += g_LeftScroll; g_LeftScroll = 0; } Loffset -= g_scrollPixelsX; // Move left if (Loffset < 0) Loffset = 0; // Now at extreme left /*** New feature to prop up rickety scroll boundaries ***/ if (TinselV2 && SysVar(SV_MinimumXoffset) && (Loffset < SysVar(SV_MinimumXoffset))) Loffset = SysVar(SV_MinimumXoffset); } /* * Vertical scrolling */ if (g_DownScroll > 0) { g_DownScroll -= g_scrollPixelsY; if (g_DownScroll < 0) { Toffset += g_DownScroll; g_DownScroll = 0; } Toffset += g_scrollPixelsY; // Move down if (Toffset > g_ImageH - SCREEN_HEIGHT) Toffset = g_ImageH - SCREEN_HEIGHT;// Now at extreme bottom /*** New feature to prop up rickety scroll boundaries ***/ if (TinselV2 && SysVar(SV_MaximumYoffset) && Toffset > SysVar(SV_MaximumYoffset)) Toffset = SysVar(SV_MaximumYoffset); } else if (g_DownScroll < 0) { g_DownScroll += g_scrollPixelsY; if (g_DownScroll > 0) { Toffset += g_DownScroll; g_DownScroll = 0; } Toffset -= g_scrollPixelsY; // Move up if (Toffset < 0) Toffset = 0; // Now at extreme top /*** New feature to prop up rickety scroll boundaries ***/ if (TinselV2 && SysVar(SV_MinimumYoffset) && Toffset < SysVar(SV_MinimumYoffset)) Toffset = SysVar(SV_MinimumYoffset); } /* * Move cursor if keeping cursor on a tag. */ if (g_ScrollCursor) AdjustCursorXY(OldLoffset - Loffset, OldToffset - Toffset); PlayfieldSetPos(FIELD_WORLD, Loffset, Toffset); }
/** * 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; }