2008-07-23 09:02:47 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2008-07-23 09:02:47 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2008-07-23 09:02:47 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Save and restore scene and game.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "tinsel/actors.h"
|
|
|
|
#include "tinsel/background.h"
|
|
|
|
#include "tinsel/config.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/drives.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/dw.h"
|
|
|
|
#include "tinsel/faders.h" // FadeOutFast()
|
|
|
|
#include "tinsel/graphics.h" // ClearScreen()
|
|
|
|
#include "tinsel/handle.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/dialogs.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/music.h"
|
|
|
|
#include "tinsel/pid.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/play.h"
|
2008-07-25 09:18:39 +00:00
|
|
|
#include "tinsel/polygons.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/rince.h"
|
|
|
|
#include "tinsel/savescn.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/scene.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/sched.h"
|
|
|
|
#include "tinsel/scroll.h"
|
|
|
|
#include "tinsel/sound.h"
|
2008-12-01 20:35:36 +00:00
|
|
|
#include "tinsel/sysvar.h"
|
2008-07-23 09:02:47 +00:00
|
|
|
#include "tinsel/tinlib.h"
|
|
|
|
#include "tinsel/token.h"
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
namespace Tinsel {
|
|
|
|
|
|
|
|
//----------------- EXTERN FUNCTIONS --------------------
|
|
|
|
|
|
|
|
// In DOS_DW.C
|
2008-07-25 09:18:39 +00:00
|
|
|
void RestoreMasterProcess(INT_CONTEXT *pic);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// in EVENTS.C (declared here and not in events.h because of strange goings-on)
|
2008-07-25 09:18:39 +00:00
|
|
|
void RestoreProcess(INT_CONTEXT *pic);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// in SCENE.C
|
2009-11-02 21:54:57 +00:00
|
|
|
extern SCNHANDLE GetSceneHandle();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
//----------------- LOCAL DEFINES --------------------
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RS_COUNT = 5, // Restore scene count
|
|
|
|
|
|
|
|
MAX_NEST = 4
|
|
|
|
};
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
//----------------- EXTERNAL GLOBAL DATA --------------------
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
extern int g_thingHeld;
|
|
|
|
extern int g_restoreCD;
|
|
|
|
extern SRSTATE g_SRstate;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
//----------------- LOCAL GLOBAL DATA --------------------
|
|
|
|
|
2020-10-03 17:10:38 +00:00
|
|
|
// These vars are reset upon engine destruction
|
2010-11-16 09:53:55 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
bool g_ASceneIsSaved = false;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static int g_savedSceneCount = 0;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static bool g_bNotDoneYet = false;
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2020-02-23 13:43:48 +00:00
|
|
|
static SAVED_DATA *g_ssData = nullptr;
|
2012-02-22 22:14:29 +00:00
|
|
|
static SAVED_DATA g_sgData;
|
2020-10-03 17:10:38 +00:00
|
|
|
static SAVED_DATA *g_rsd = nullptr;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static int g_RestoreSceneCount = 0;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
static bool g_bNoFade = false;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2020-10-03 17:10:38 +00:00
|
|
|
void ResetVarsSaveScn() {
|
|
|
|
g_ASceneIsSaved = false;
|
|
|
|
|
|
|
|
g_savedSceneCount = 0;
|
|
|
|
|
|
|
|
g_bNotDoneYet = false;
|
|
|
|
|
|
|
|
free(g_ssData);
|
|
|
|
g_ssData = nullptr;
|
|
|
|
|
|
|
|
memset(&g_sgData, 0, sizeof(g_sgData));
|
|
|
|
g_rsd = nullptr;
|
|
|
|
|
|
|
|
g_RestoreSceneCount = 0;
|
|
|
|
g_bNoFade = false;
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save current scene.
|
|
|
|
* @param sd Pointer to the scene data
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void DoSaveScene(SAVED_DATA *sd) {
|
2008-07-23 09:02:47 +00:00
|
|
|
sd->SavedSceneHandle = GetSceneHandle();
|
2020-02-22 16:17:57 +00:00
|
|
|
sd->SavedBgroundHandle = _vm->_bg->GetBgroundHandle();
|
2008-07-23 09:02:47 +00:00
|
|
|
SaveMovers(sd->SavedMoverInfo);
|
2020-10-03 11:04:24 +00:00
|
|
|
sd->NumSavedActors = _vm->_actor->SaveActors(sd->SavedActorInfo);
|
2020-02-22 16:17:57 +00:00
|
|
|
_vm->_bg->PlayfieldGetPos(FIELD_WORLD, &sd->SavedLoffset, &sd->SavedToffset);
|
2008-07-23 09:02:47 +00:00
|
|
|
SaveInterpretContexts(sd->SavedICInfo);
|
2008-12-01 20:35:36 +00:00
|
|
|
sd->SavedControl = ControlIsOn();
|
|
|
|
sd->SavedNoBlocking = GetNoBlocking();
|
2020-10-03 16:04:44 +00:00
|
|
|
_vm->_scroll->GetNoScrollData(&sd->SavedNoScrollData);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2) {
|
|
|
|
// Tinsel 2 specific data save
|
2020-10-03 11:04:24 +00:00
|
|
|
_vm->_actor->SaveActorZ(sd->savedActorZ);
|
|
|
|
_vm->_actor->SaveZpositions(sd->zPositions);
|
2008-12-01 20:35:36 +00:00
|
|
|
SavePolygonStuff(sd->SavedPolygonStuff);
|
|
|
|
_vm->_pcmMusic->getTunePlaying(sd->SavedTune, sizeof(sd->SavedTune));
|
|
|
|
sd->bTinselDim = _vm->_pcmMusic->getMusicTinselDimmed();
|
2020-10-03 16:04:44 +00:00
|
|
|
sd->SavedScrollFocus = _vm->_scroll->GetScrollFocus();
|
2008-12-01 20:35:36 +00:00
|
|
|
SaveSysVars(sd->SavedSystemVars);
|
|
|
|
SaveSoundReels(sd->SavedSoundReels);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Tinsel 1 specific data save
|
|
|
|
SaveDeadPolys(sd->SavedDeadPolys);
|
2020-02-23 12:50:45 +00:00
|
|
|
_vm->_music->CurrentMidiFacts(&sd->SavedMidi, &sd->SavedLoop);
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
g_ASceneIsSaved = true;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initiate restoration of the saved scene.
|
|
|
|
* @param sd Pointer to the scene data
|
|
|
|
* @param bFadeOut Flag to perform a fade out
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void DoRestoreScene(SAVED_DATA *sd, bool bFadeOut) {
|
2012-02-22 22:14:29 +00:00
|
|
|
g_rsd = sd;
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
if (bFadeOut)
|
2012-02-22 22:14:29 +00:00
|
|
|
g_RestoreSceneCount = RS_COUNT + COUNTOUT_COUNT; // Set restore scene count
|
2008-07-23 09:02:47 +00:00
|
|
|
else
|
2012-02-22 22:14:29 +00:00
|
|
|
g_RestoreSceneCount = RS_COUNT; // Set restore scene count
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 15:17:11 +00:00
|
|
|
void InitializeSaveScenes() {
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_ssData == NULL) {
|
|
|
|
g_ssData = (SAVED_DATA *)calloc(MAX_NEST, sizeof(SAVED_DATA));
|
|
|
|
if (g_ssData == NULL) {
|
2008-12-01 20:35:36 +00:00
|
|
|
error("Cannot allocate memory for scene changes");
|
|
|
|
}
|
|
|
|
} else {
|
2011-05-25 15:17:11 +00:00
|
|
|
// Re-initialize - no scenes saved
|
2012-02-22 22:14:29 +00:00
|
|
|
g_savedSceneCount = 0;
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void FreeSaveScenes() {
|
2012-02-22 22:14:29 +00:00
|
|
|
free(g_ssData);
|
2020-02-23 13:43:48 +00:00
|
|
|
g_ssData = nullptr;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks that all non-moving actors are playing the same reel as when
|
|
|
|
* the scene was saved.
|
|
|
|
* Also 'stand' all the moving actors at their saved positions.
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void sortActors(SAVED_DATA *sd) {
|
|
|
|
assert(!TinselV2);
|
|
|
|
for (int i = 0; i < sd->NumSavedActors; i++) {
|
2020-10-03 11:04:24 +00:00
|
|
|
_vm->_actor->ActorsLife(sd->SavedActorInfo[i].actorID, sd->SavedActorInfo[i].bAlive);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Should be playing the same reel.
|
2008-12-01 20:35:36 +00:00
|
|
|
if (sd->SavedActorInfo[i].presFilm != 0) {
|
2020-10-03 11:04:24 +00:00
|
|
|
if (!_vm->_actor->actorAlive(sd->SavedActorInfo[i].actorID))
|
2008-07-23 09:02:47 +00:00
|
|
|
continue;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
RestoreActorReels(sd->SavedActorInfo[i].presFilm, sd->SavedActorInfo[i].presRnum, sd->SavedActorInfo[i].zFactor,
|
|
|
|
sd->SavedActorInfo[i].presPlayX, sd->SavedActorInfo[i].presPlayY);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
RestoreAuxScales(sd->SavedMoverInfo);
|
2008-07-23 09:02:47 +00:00
|
|
|
for (int i = 0; i < MAX_MOVERS; i++) {
|
2008-12-01 20:35:36 +00:00
|
|
|
if (sd->SavedMoverInfo[i].bActive)
|
2012-05-11 13:10:12 +00:00
|
|
|
Stand(Common::nullContext, sd->SavedMoverInfo[i].actorID, sd->SavedMoverInfo[i].objX,
|
2008-12-01 20:35:36 +00:00
|
|
|
sd->SavedMoverInfo[i].objY, sd->SavedMoverInfo[i].hLastfilm);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
/**
|
|
|
|
* Stand all the moving actors at their saved positions.
|
|
|
|
* Not called from the foreground.
|
|
|
|
*/
|
|
|
|
static void SortMAProcess(CORO_PARAM, const void *) {
|
|
|
|
CORO_BEGIN_CONTEXT;
|
|
|
|
int i;
|
|
|
|
int viaActor;
|
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
|
|
|
|
// Disable via actor for the stands
|
|
|
|
_ctx->viaActor = SysVar(ISV_DIVERT_ACTOR);
|
|
|
|
SetSysVar(ISV_DIVERT_ACTOR, 0);
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
RestoreAuxScales(g_rsd->SavedMoverInfo);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
for (_ctx->i = 0; _ctx->i < MAX_MOVERS; _ctx->i++) {
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd->SavedMoverInfo[_ctx->i].bActive) {
|
|
|
|
CORO_INVOKE_ARGS(Stand, (CORO_SUBCTX, g_rsd->SavedMoverInfo[_ctx->i].actorID,
|
|
|
|
g_rsd->SavedMoverInfo[_ctx->i].objX, g_rsd->SavedMoverInfo[_ctx->i].objY,
|
|
|
|
g_rsd->SavedMoverInfo[_ctx->i].hLastfilm));
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd->SavedMoverInfo[_ctx->i].bHidden)
|
|
|
|
HideMover(GetMover(g_rsd->SavedMoverInfo[_ctx->i].actorID));
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
ActorPalette(g_rsd->SavedMoverInfo[_ctx->i].actorID,
|
|
|
|
g_rsd->SavedMoverInfo[_ctx->i].startColor, g_rsd->SavedMoverInfo[_ctx->i].paletteLength);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS)
|
|
|
|
ActorBrightness(g_rsd->SavedMoverInfo[_ctx->i].actorID, g_rsd->SavedMoverInfo[_ctx->i].brightness);
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Restore via actor
|
|
|
|
SetSysVar(ISV_DIVERT_ACTOR, _ctx->viaActor);
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
g_bNotDoneYet = false;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void ResumeInterprets() {
|
2008-07-23 09:02:47 +00:00
|
|
|
// Master script only affected on restore game, not restore scene
|
2012-02-22 22:14:29 +00:00
|
|
|
if (!TinselV2 && (g_rsd == &g_sgData)) {
|
2012-05-11 13:10:12 +00:00
|
|
|
CoroScheduler.killMatchingProcess(PID_MASTER_SCR, -1);
|
2008-07-23 09:02:47 +00:00
|
|
|
FreeMasterInterpretContext();
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
for (int i = 0; i < NUM_INTERPRET; i++) {
|
2012-02-22 22:14:29 +00:00
|
|
|
switch (g_rsd->SavedICInfo[i].GSort) {
|
2008-07-23 09:02:47 +00:00
|
|
|
case GS_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GS_INVENTORY:
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd->SavedICInfo[i].event != POINTED) {
|
|
|
|
RestoreProcess(&g_rsd->SavedICInfo[i]);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GS_MASTER:
|
|
|
|
// Master script only affected on restore game, not restore scene
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd == &g_sgData)
|
|
|
|
RestoreMasterProcess(&g_rsd->SavedICInfo[i]);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
case GS_PROCESS:
|
|
|
|
// Tinsel 2 process
|
2012-02-22 22:14:29 +00:00
|
|
|
RestoreSceneProcess(&g_rsd->SavedICInfo[i]);
|
2008-12-01 20:35:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GS_GPROCESS:
|
|
|
|
// Tinsel 2 Global processes only affected on restore game, not restore scene
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_rsd == &g_sgData)
|
|
|
|
RestoreGlobalProcess(&g_rsd->SavedICInfo[i]);
|
2008-12-01 20:35:36 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
case GS_ACTOR:
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2)
|
2012-02-22 22:14:29 +00:00
|
|
|
RestoreProcess(&g_rsd->SavedICInfo[i]);
|
2008-12-01 20:35:36 +00:00
|
|
|
else
|
2012-02-22 22:14:29 +00:00
|
|
|
RestoreActorProcess(g_rsd->SavedICInfo[i].idActor, &g_rsd->SavedICInfo[i], g_rsd == &g_sgData);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GS_POLYGON:
|
|
|
|
case GS_SCENE:
|
2012-02-22 22:14:29 +00:00
|
|
|
RestoreProcess(&g_rsd->SavedICInfo[i]);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
warning("Unhandled GSort in ResumeInterprets");
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do restore scene
|
|
|
|
* @param n Id
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
|
2008-07-23 09:02:47 +00:00
|
|
|
switch (n) {
|
|
|
|
case RS_COUNT + COUNTOUT_COUNT:
|
|
|
|
// Trigger pre-load and fade and start countdown
|
2013-04-12 03:41:29 +00:00
|
|
|
FadeOutFast();
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_COUNT:
|
|
|
|
_vm->_sound->stopAllSamples();
|
2008-07-25 09:18:39 +00:00
|
|
|
ClearScreen();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2) {
|
2009-11-02 21:57:16 +00:00
|
|
|
|
|
|
|
// Master script only affected on restore game, not restore scene
|
2012-02-22 22:14:29 +00:00
|
|
|
if (sd == &g_sgData) {
|
2012-05-11 13:10:12 +00:00
|
|
|
CoroScheduler.killMatchingProcess(PID_MASTER_SCR);
|
2009-11-02 21:57:16 +00:00
|
|
|
KillGlobalProcesses();
|
|
|
|
FreeMasterInterpretContext();
|
|
|
|
}
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
RestorePolygonStuff(sd->SavedPolygonStuff);
|
|
|
|
|
|
|
|
// Abandon temporarily if different CD
|
2012-02-22 22:14:29 +00:00
|
|
|
if (sd == &g_sgData && g_restoreCD != GetCurrentCD()) {
|
|
|
|
g_SRstate = SR_IDLE;
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
EndScene();
|
2012-02-22 22:14:29 +00:00
|
|
|
SetNextCD(g_restoreCD);
|
|
|
|
CDChangeForRestore(g_restoreCD);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RestoreDeadPolys(sd->SavedDeadPolys);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start up the scene
|
|
|
|
StartNewScene(sd->SavedSceneHandle, NO_ENTRY_NUM);
|
|
|
|
|
2020-02-22 16:17:57 +00:00
|
|
|
_vm->_bg->SetDoFadeIn(!g_bNoFade);
|
2012-02-22 22:14:29 +00:00
|
|
|
g_bNoFade = false;
|
2020-02-22 16:17:57 +00:00
|
|
|
_vm->_bg->StartupBackground(Common::nullContext, sd->SavedBgroundHandle);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
Offset(EX_USEXY, sd->SavedLoffset, sd->SavedToffset);
|
|
|
|
} else {
|
2020-10-03 16:04:44 +00:00
|
|
|
_vm->_scroll->KillScroll();
|
2020-02-22 16:17:57 +00:00
|
|
|
_vm->_bg->PlayfieldSetPos(FIELD_WORLD, sd->SavedLoffset, sd->SavedToffset);
|
2008-12-01 20:35:36 +00:00
|
|
|
SetNoBlocking(sd->SavedNoBlocking);
|
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2020-10-03 16:04:44 +00:00
|
|
|
_vm->_scroll->RestoreNoScrollData(&sd->SavedNoScrollData);
|
2008-12-01 20:35:36 +00:00
|
|
|
|
|
|
|
if (TinselV2) {
|
|
|
|
// create process to sort out the moving actors
|
2012-05-11 13:10:12 +00:00
|
|
|
CoroScheduler.createProcess(PID_MOVER, SortMAProcess, NULL, 0);
|
2012-02-22 22:14:29 +00:00
|
|
|
g_bNotDoneYet = true;
|
2008-12-01 20:35:36 +00:00
|
|
|
|
2020-10-03 11:04:24 +00:00
|
|
|
_vm->_actor->RestoreActorZ(sd->savedActorZ);
|
|
|
|
_vm->_actor->RestoreZpositions(sd->zPositions);
|
2008-12-01 20:35:36 +00:00
|
|
|
RestoreSysVars(sd->SavedSystemVars);
|
2020-10-03 11:04:24 +00:00
|
|
|
_vm->_actor->RestoreActors(sd->NumSavedActors, sd->SavedActorInfo);
|
2008-12-01 20:35:36 +00:00
|
|
|
RestoreSoundReels(sd->SavedSoundReels);
|
|
|
|
return 1;
|
|
|
|
}
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
sortActors(sd);
|
2008-07-23 09:02:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2008-12-01 20:35:36 +00:00
|
|
|
if (TinselV2) {
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_bNotDoneYet)
|
2008-12-01 20:35:36 +00:00
|
|
|
return n;
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
if (sd == &g_sgData)
|
2020-10-03 21:10:38 +00:00
|
|
|
_vm->_dialogs->HoldItem(g_thingHeld, true);
|
2008-12-01 20:35:36 +00:00
|
|
|
if (sd->bTinselDim)
|
|
|
|
_vm->_pcmMusic->dim(true);
|
|
|
|
_vm->_pcmMusic->restoreThatTune(sd->SavedTune);
|
2020-10-03 16:04:44 +00:00
|
|
|
_vm->_scroll->ScrollFocus(sd->SavedScrollFocus);
|
2008-12-01 20:35:36 +00:00
|
|
|
} else {
|
2020-02-23 12:50:45 +00:00
|
|
|
_vm->_music->RestoreMidiFacts(sd->SavedMidi, sd->SavedLoop);
|
2008-12-01 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->SavedControl)
|
|
|
|
ControlOn(); // Control was on
|
|
|
|
ResumeInterprets();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return n - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore game
|
|
|
|
* @param num num
|
|
|
|
*/
|
2008-12-20 23:08:37 +00:00
|
|
|
void RestoreGame(int num) {
|
2020-10-03 21:10:38 +00:00
|
|
|
_vm->_dialogs->KillInventory();
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
RequestRestoreGame(num, &g_sgData, &g_savedSceneCount, g_ssData);
|
2008-12-12 15:48:38 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
// Actual restoring is performed by ProcessSRQueue
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save game
|
|
|
|
* @param name Name of savegame
|
|
|
|
* @param desc Description of savegame
|
|
|
|
*/
|
|
|
|
void SaveGame(char *name, char *desc) {
|
|
|
|
// Get current scene data
|
2012-02-22 22:14:29 +00:00
|
|
|
DoSaveScene(&g_sgData);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
RequestSaveGame(name, desc, &g_sgData, &g_savedSceneCount, g_ssData);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
// Actual saving is performed by ProcessSRQueue
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool IsRestoringScene() {
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_RestoreSceneCount) {
|
|
|
|
g_RestoreSceneCount = DoRestoreSceneFrame(g_rsd, g_RestoreSceneCount);
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
return g_RestoreSceneCount ? true : false;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-12-01 20:35:36 +00:00
|
|
|
* Restores Scene
|
2008-07-23 09:02:47 +00:00
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void TinselRestoreScene(bool bFade) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// only called by restore_scene PCODE
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_RestoreSceneCount == 0) {
|
|
|
|
assert(g_savedSceneCount >= 1); // No saved scene to restore
|
2008-07-23 09:02:47 +00:00
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_ASceneIsSaved)
|
|
|
|
DoRestoreScene(&g_ssData[--g_savedSceneCount], bFade);
|
2008-07-23 09:02:47 +00:00
|
|
|
if (!bFade)
|
2012-02-22 22:14:29 +00:00
|
|
|
g_bNoFade = true;
|
2008-07-23 09:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Please Save Scene
|
|
|
|
*/
|
2008-12-01 20:35:36 +00:00
|
|
|
void TinselSaveScene(CORO_PARAM) {
|
2008-07-23 09:02:47 +00:00
|
|
|
// only called by save_scene PCODE
|
|
|
|
CORO_BEGIN_CONTEXT;
|
|
|
|
CORO_END_CONTEXT(_ctx);
|
|
|
|
|
|
|
|
CORO_BEGIN_CODE(_ctx);
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
assert(g_savedSceneCount < MAX_NEST); // nesting limit reached
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
// Don't save the same thing multiple times!
|
|
|
|
// FIXME/TODO: Maybe this can be changed to an assert?
|
2012-02-22 22:14:29 +00:00
|
|
|
if (g_savedSceneCount && g_ssData[g_savedSceneCount-1].SavedSceneHandle == GetSceneHandle())
|
2008-07-23 09:02:47 +00:00
|
|
|
CORO_KILL_SELF();
|
|
|
|
|
2012-02-22 22:14:29 +00:00
|
|
|
DoSaveScene(&g_ssData[g_savedSceneCount++]);
|
2008-07-23 09:02:47 +00:00
|
|
|
|
|
|
|
CORO_END_CODE;
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Tinsel
|