2011-06-26 10:09:56 +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:19 +00:00
|
|
|
*
|
2011-06-26 10:09:56 +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:19 +00:00
|
|
|
*
|
2011-06-26 10:09:56 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-05-31 04:16:10 +00:00
|
|
|
#include "dreamweb/sound.h"
|
2011-06-26 10:09:56 +00:00
|
|
|
#include "dreamweb/dreamweb.h"
|
2012-05-31 04:16:10 +00:00
|
|
|
|
2011-06-25 18:05:05 +00:00
|
|
|
#include "engines/metaengine.h"
|
2011-12-18 00:54:51 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
2011-06-25 18:05:05 +00:00
|
|
|
#include "gui/saveload.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/translation.h"
|
2011-12-17 20:30:54 +00:00
|
|
|
#include "common/serializer.h"
|
2011-06-26 10:09:56 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
namespace DreamWeb {
|
2011-06-26 10:09:56 +00:00
|
|
|
|
2011-12-03 19:32:41 +00:00
|
|
|
// Temporary storage for loading the room from a savegame
|
|
|
|
Room g_madeUpRoomDat;
|
|
|
|
|
2011-12-17 20:30:54 +00:00
|
|
|
|
|
|
|
void syncReelRoutine(Common::Serializer &s, ReelRoutine *reel) {
|
|
|
|
s.syncAsByte(reel->reallocation);
|
|
|
|
s.syncAsByte(reel->mapX);
|
|
|
|
s.syncAsByte(reel->mapY);
|
2011-12-17 21:26:17 +00:00
|
|
|
s.syncAsUint16LE(reel->_reelPointer);
|
2011-12-17 20:30:54 +00:00
|
|
|
s.syncAsByte(reel->period);
|
|
|
|
s.syncAsByte(reel->counter);
|
|
|
|
s.syncAsByte(reel->b7);
|
|
|
|
}
|
|
|
|
|
2011-12-28 12:10:22 +00:00
|
|
|
void syncGameVars(Common::Serializer &s, GameVars &vars) {
|
|
|
|
s.syncAsByte(vars._startVars);
|
|
|
|
s.syncAsByte(vars._progressPoints);
|
|
|
|
s.syncAsByte(vars._watchOn);
|
|
|
|
s.syncAsByte(vars._shadesOn);
|
|
|
|
s.syncAsByte(vars._secondCount);
|
|
|
|
s.syncAsByte(vars._minuteCount);
|
|
|
|
s.syncAsByte(vars._hourCount);
|
|
|
|
s.syncAsByte(vars._zoomOn);
|
|
|
|
s.syncAsByte(vars._location);
|
|
|
|
s.syncAsByte(vars._exPos);
|
|
|
|
s.syncAsUint16LE(vars._exFramePos);
|
|
|
|
s.syncAsUint16LE(vars._exTextPos);
|
|
|
|
s.syncAsUint16LE(vars._card1Money);
|
|
|
|
s.syncAsUint16LE(vars._listPos);
|
|
|
|
s.syncAsByte(vars._ryanPage);
|
|
|
|
s.syncAsUint16LE(vars._watchingTime);
|
|
|
|
s.syncAsUint16LE(vars._reelToWatch);
|
|
|
|
s.syncAsUint16LE(vars._endWatchReel);
|
|
|
|
s.syncAsByte(vars._speedCount);
|
|
|
|
s.syncAsByte(vars._watchSpeed);
|
|
|
|
s.syncAsUint16LE(vars._reelToHold);
|
|
|
|
s.syncAsUint16LE(vars._endOfHoldReel);
|
|
|
|
s.syncAsByte(vars._watchMode);
|
|
|
|
s.syncAsByte(vars._destAfterHold);
|
|
|
|
s.syncAsByte(vars._newsItem);
|
|
|
|
s.syncAsByte(vars._liftFlag);
|
|
|
|
s.syncAsByte(vars._liftPath);
|
|
|
|
s.syncAsByte(vars._lockStatus);
|
|
|
|
s.syncAsByte(vars._doorPath);
|
|
|
|
s.syncAsByte(vars._countToOpen);
|
|
|
|
s.syncAsByte(vars._countToClose);
|
|
|
|
s.syncAsByte(vars._rockstarDead);
|
|
|
|
s.syncAsByte(vars._generalDead);
|
|
|
|
s.syncAsByte(vars._sartainDead);
|
|
|
|
s.syncAsByte(vars._aideDead);
|
|
|
|
s.syncAsByte(vars._beenMugged);
|
|
|
|
s.syncAsByte(vars._gunPassFlag);
|
|
|
|
s.syncAsByte(vars._canMoveAltar);
|
|
|
|
s.syncAsByte(vars._talkedToAttendant);
|
|
|
|
s.syncAsByte(vars._talkedToSparky);
|
|
|
|
s.syncAsByte(vars._talkedToBoss);
|
|
|
|
s.syncAsByte(vars._talkedToRecep);
|
|
|
|
s.syncAsByte(vars._cardPassFlag);
|
|
|
|
s.syncAsByte(vars._madmanFlag);
|
|
|
|
s.syncAsByte(vars._keeperFlag);
|
|
|
|
s.syncAsByte(vars._lastTrigger);
|
|
|
|
s.syncAsByte(vars._manDead);
|
|
|
|
s.syncAsByte(vars._seed1);
|
|
|
|
s.syncAsByte(vars._seed2);
|
|
|
|
s.syncAsByte(vars._seed3);
|
|
|
|
s.syncAsByte(vars._needToTravel);
|
|
|
|
s.syncAsByte(vars._throughDoor);
|
|
|
|
s.syncAsByte(vars._newObs);
|
|
|
|
s.syncAsByte(vars._ryanOn);
|
|
|
|
s.syncAsByte(vars._combatCount);
|
|
|
|
s.syncAsByte(vars._lastWeapon);
|
|
|
|
s.syncAsByte(vars._dreamNumber);
|
|
|
|
s.syncAsByte(vars._roomAfterDream);
|
|
|
|
s.syncAsByte(vars._shakeCounter);
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::loadGame() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(41, 246);
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton == _oldButton)
|
2011-06-25 18:05:05 +00:00
|
|
|
return; // "noload"
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton == 1)
|
2011-12-03 15:54:39 +00:00
|
|
|
doLoad(-1);
|
2011-06-26 10:09:56 +00:00
|
|
|
}
|
|
|
|
|
2011-06-25 18:30:16 +00:00
|
|
|
// if -1, open menu to ask for slot to load
|
|
|
|
// if >= 0, directly load from that slot
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::doLoad(int savegameId) {
|
2011-12-28 01:28:27 +00:00
|
|
|
_loadingOrSave = 1;
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2012-03-25 14:50:22 +00:00
|
|
|
if (ConfMan.getBool("originalsaveload") && savegameId == -1) {
|
2011-12-01 19:43:43 +00:00
|
|
|
showOpBox();
|
|
|
|
showLoadOps();
|
2011-12-28 01:28:27 +00:00
|
|
|
_currentSlot = 0;
|
2011-12-01 19:43:43 +00:00
|
|
|
showSlots();
|
|
|
|
showNames();
|
2011-12-28 01:28:27 +00:00
|
|
|
_pointerFrame = 0;
|
2011-12-01 19:43:43 +00:00
|
|
|
workToScreenM();
|
|
|
|
namesToOld();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
while (_getBack == 0) {
|
2011-12-27 03:08:43 +00:00
|
|
|
if (_quitRequested)
|
2011-11-21 16:56:49 +00:00
|
|
|
return;
|
2011-12-01 19:43:43 +00:00
|
|
|
delPointer();
|
|
|
|
readMouse();
|
|
|
|
showPointer();
|
2012-05-30 03:23:34 +00:00
|
|
|
waitForVSync();
|
2011-12-01 19:43:43 +00:00
|
|
|
dumpPointer();
|
|
|
|
dumpTextLine();
|
2011-12-28 15:55:03 +00:00
|
|
|
RectWithCallback loadlist[] = {
|
2011-12-28 13:07:17 +00:00
|
|
|
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },
|
|
|
|
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamWebEngine::actualLoad },
|
|
|
|
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamWebEngine::selectSlot },
|
2012-01-08 18:36:59 +00:00
|
|
|
{ kOpsx+158,kOpsx+158+(18*3),kOpsy-17,kOpsy-1,&DreamWebEngine::selectSaveLoadPage },
|
2011-12-28 13:07:17 +00:00
|
|
|
{ 0,320,0,200,&DreamWebEngine::blank },
|
2011-11-14 20:38:40 +00:00
|
|
|
{ 0xFFFF,0,0,0,0 }
|
|
|
|
};
|
2011-12-01 19:43:43 +00:00
|
|
|
checkCoords(loadlist);
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_getBack == 2)
|
2011-06-25 18:05:05 +00:00
|
|
|
return; // "quitloaded"
|
|
|
|
}
|
|
|
|
} else {
|
2011-06-25 18:30:16 +00:00
|
|
|
|
|
|
|
if (savegameId == -1) {
|
2012-11-06 10:08:55 +00:00
|
|
|
// Wait till both mouse buttons are up. We should wait till the user
|
|
|
|
// releases the mouse button, otherwise the follow-up mouseup event
|
|
|
|
// will trigger a load of the save slot under the mouse cursor. Fixes
|
|
|
|
// bug #3582582.
|
|
|
|
while (_oldMouseState > 0) {
|
|
|
|
readMouse();
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
2011-06-25 18:30:16 +00:00
|
|
|
|
2012-11-06 10:08:55 +00:00
|
|
|
// Open dialog to get savegameId
|
2012-06-10 02:14:17 +00:00
|
|
|
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
|
2012-06-10 02:49:42 +00:00
|
|
|
savegameId = dialog->runModalWithCurrentTarget();
|
2011-06-25 18:30:16 +00:00
|
|
|
delete dialog;
|
|
|
|
}
|
2011-06-25 18:05:05 +00:00
|
|
|
|
|
|
|
if (savegameId < 0) {
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-06-25 18:05:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-01 19:43:43 +00:00
|
|
|
loadPosition(savegameId);
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 1;
|
2011-06-25 18:05:05 +00:00
|
|
|
}
|
|
|
|
|
2011-12-03 15:00:55 +00:00
|
|
|
// If we reach this point, loadPosition() has just been called.
|
2011-12-03 19:32:41 +00:00
|
|
|
// Among other things, it will have filled g_MadeUpRoomDat.
|
2011-12-03 15:00:55 +00:00
|
|
|
|
2012-02-22 18:06:29 +00:00
|
|
|
_saveGraphics.clear();
|
2011-06-25 18:30:16 +00:00
|
|
|
|
2011-12-03 19:32:41 +00:00
|
|
|
startLoading(g_madeUpRoomDat);
|
2012-05-31 04:16:10 +00:00
|
|
|
_sound->loadRoomsSample(_roomsSample);
|
2011-12-28 01:28:27 +00:00
|
|
|
_roomLoaded = 1;
|
|
|
|
_newLocation = 255;
|
2011-12-01 19:43:43 +00:00
|
|
|
clearSprites();
|
|
|
|
initMan();
|
|
|
|
initRain();
|
2011-12-28 01:28:27 +00:00
|
|
|
_textAddressX = 13;
|
|
|
|
_textAddressY = 182;
|
|
|
|
_textLen = 240;
|
2011-06-26 10:09:56 +00:00
|
|
|
startup();
|
2011-12-25 23:59:04 +00:00
|
|
|
workToScreen();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 4;
|
2011-06-26 10:09:56 +00:00
|
|
|
}
|
|
|
|
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::saveGame() {
|
2011-12-28 12:10:22 +00:00
|
|
|
if (_vars._manDead == 2) {
|
2011-06-25 18:05:05 +00:00
|
|
|
blank();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(44, 247);
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton != 1)
|
2011-06-25 18:05:05 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
_loadingOrSave = 2;
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2012-03-25 14:50:22 +00:00
|
|
|
if (ConfMan.getBool("originalsaveload")) {
|
2011-12-01 19:43:43 +00:00
|
|
|
showOpBox();
|
|
|
|
showSaveOps();
|
2011-12-28 01:28:27 +00:00
|
|
|
_currentSlot = 0;
|
2011-12-01 19:43:43 +00:00
|
|
|
showSlots();
|
|
|
|
showNames();
|
|
|
|
workToScreenM();
|
|
|
|
namesToOld();
|
2011-12-28 01:28:27 +00:00
|
|
|
_bufferIn = 0;
|
|
|
|
_bufferOut = 0;
|
|
|
|
_getBack = 0;
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
while (_getBack == 0) {
|
2011-12-27 03:08:43 +00:00
|
|
|
if (_quitRequested)
|
2011-11-21 16:56:49 +00:00
|
|
|
return;
|
2011-12-01 19:43:43 +00:00
|
|
|
delPointer();
|
|
|
|
checkInput();
|
|
|
|
readMouse();
|
|
|
|
showPointer();
|
2012-05-30 03:23:34 +00:00
|
|
|
waitForVSync();
|
2011-12-01 19:43:43 +00:00
|
|
|
dumpPointer();
|
|
|
|
dumpTextLine();
|
2011-11-14 20:38:40 +00:00
|
|
|
|
2011-12-28 15:55:03 +00:00
|
|
|
RectWithCallback savelist[] = {
|
2011-12-28 13:07:17 +00:00
|
|
|
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },
|
|
|
|
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamWebEngine::actualSave },
|
|
|
|
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamWebEngine::selectSlot },
|
2012-01-08 18:36:59 +00:00
|
|
|
{ kOpsx+158,kOpsx+158+(18*3),kOpsy-17,kOpsy-1,&DreamWebEngine::selectSaveLoadPage },
|
2011-12-28 13:07:17 +00:00
|
|
|
{ 0,320,0,200,&DreamWebEngine::blank },
|
2011-11-14 20:38:40 +00:00
|
|
|
{ 0xFFFF,0,0,0,0 }
|
|
|
|
};
|
2011-12-01 19:43:43 +00:00
|
|
|
checkCoords(savelist);
|
2011-06-25 18:05:05 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
} else {
|
2012-11-06 10:08:55 +00:00
|
|
|
// Wait till both mouse buttons are up. We should wait till the user
|
|
|
|
// releases the mouse button, otherwise the follow-up mouseup event
|
|
|
|
// will trigger a save into the save slot under the mouse cursor. Fixes
|
|
|
|
// bug #3582582.
|
|
|
|
while (_oldMouseState > 0) {
|
|
|
|
readMouse();
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
2012-06-10 02:14:17 +00:00
|
|
|
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
|
2012-06-10 02:49:42 +00:00
|
|
|
int savegameId = dialog->runModalWithCurrentTarget();
|
2011-06-25 18:05:05 +00:00
|
|
|
Common::String game_description = dialog->getResultString();
|
|
|
|
if (game_description.empty())
|
|
|
|
game_description = "Untitled";
|
|
|
|
delete dialog;
|
|
|
|
|
|
|
|
if (savegameId < 0) {
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-06-25 18:05:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-11 14:57:03 +00:00
|
|
|
char descbuf[17] = { 2, 0 };
|
2012-02-15 15:53:31 +00:00
|
|
|
Common::strlcpy((char *)descbuf + 1, game_description.c_str(), 16);
|
2011-06-25 18:05:05 +00:00
|
|
|
unsigned int desclen = game_description.size();
|
|
|
|
if (desclen > 15)
|
|
|
|
desclen = 15;
|
|
|
|
// zero terminate, and pad with ones
|
|
|
|
descbuf[++desclen] = 0;
|
2011-12-17 17:30:06 +00:00
|
|
|
while (desclen < 16)
|
2011-06-25 18:05:05 +00:00
|
|
|
descbuf[++desclen] = 1;
|
2011-11-26 17:07:34 +00:00
|
|
|
|
|
|
|
// TODO: The below is copied from actualsave
|
2012-02-22 18:06:29 +00:00
|
|
|
_saveGraphics.clear();
|
2011-12-01 19:43:43 +00:00
|
|
|
restoreAll(); // reels
|
2011-12-28 01:28:27 +00:00
|
|
|
_textAddressX = 13;
|
|
|
|
_textAddressY = 182;
|
|
|
|
_textLen = 240;
|
2011-12-01 19:43:43 +00:00
|
|
|
redrawMainScrn();
|
2011-12-25 23:59:04 +00:00
|
|
|
workToScreen(); // show the main screen without the mouse pointer
|
2011-12-18 00:54:51 +00:00
|
|
|
|
|
|
|
// We need to save after the scene has been redrawn, to capture the
|
|
|
|
// correct screen thumbnail
|
|
|
|
savePosition(savegameId, descbuf);
|
|
|
|
|
2011-12-01 19:43:43 +00:00
|
|
|
workToScreenM();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 4;
|
2011-06-25 18:05:05 +00:00
|
|
|
}
|
2011-06-26 10:09:56 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::namesToOld() {
|
2012-01-08 18:36:59 +00:00
|
|
|
memcpy(_saveNamesOld, _saveNames, 17*21);
|
2011-11-17 14:08:34 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::oldToNames() {
|
2012-01-08 18:36:59 +00:00
|
|
|
memcpy(_saveNames, _saveNamesOld, 17*21);
|
2011-11-17 14:08:34 +00:00
|
|
|
}
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::saveLoad() {
|
2011-12-28 12:10:22 +00:00
|
|
|
if (_vars._watchingTime || (_pointerMode == 2)) {
|
2011-11-21 15:49:45 +00:00
|
|
|
blank();
|
|
|
|
return;
|
|
|
|
}
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(43, 253);
|
2011-12-28 01:28:27 +00:00
|
|
|
if ((_mouseButton != _oldButton) && (_mouseButton & 1))
|
2011-12-01 19:43:43 +00:00
|
|
|
doSaveLoad();
|
2011-11-21 15:49:45 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::doSaveLoad() {
|
2011-12-28 01:28:27 +00:00
|
|
|
_pointerFrame = 0;
|
|
|
|
_textAddressX = 70;
|
|
|
|
_textAddressY = 182-8;
|
|
|
|
_textLen = 181;
|
|
|
|
_manIsOffScreen = 1;
|
2011-12-15 12:41:30 +00:00
|
|
|
clearWork();
|
|
|
|
createPanel2();
|
|
|
|
underTextLine();
|
|
|
|
getRidOfAll();
|
|
|
|
loadSaveBox();
|
|
|
|
showOpBox();
|
|
|
|
showMainOps();
|
2011-12-25 23:59:04 +00:00
|
|
|
workToScreen();
|
2011-12-15 12:41:30 +00:00
|
|
|
|
2011-12-28 15:55:03 +00:00
|
|
|
RectWithCallback opsList[] = {
|
2011-12-28 13:07:17 +00:00
|
|
|
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamWebEngine::getBackFromOps },
|
|
|
|
{ kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamWebEngine::DOSReturn },
|
|
|
|
{ kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamWebEngine::discOps },
|
|
|
|
{ 0,320,0,200,&DreamWebEngine::blank },
|
2011-12-15 12:41:30 +00:00
|
|
|
{ 0xFFFF,0,0,0,0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
bool firstOps = true;
|
|
|
|
|
|
|
|
do { // restart ops
|
|
|
|
if (firstOps) {
|
|
|
|
firstOps = false;
|
|
|
|
} else {
|
|
|
|
showOpBox();
|
|
|
|
showMainOps();
|
|
|
|
workToScreenM();
|
|
|
|
}
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-12-15 12:41:30 +00:00
|
|
|
|
|
|
|
do { // wait ops
|
2011-12-27 03:08:43 +00:00
|
|
|
if (_quitRequested) {
|
2011-12-28 01:28:27 +00:00
|
|
|
_manIsOffScreen = 0;
|
2011-12-15 12:41:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
readMouse();
|
|
|
|
showPointer();
|
2012-05-30 03:23:34 +00:00
|
|
|
waitForVSync();
|
2011-12-15 12:41:30 +00:00
|
|
|
dumpPointer();
|
|
|
|
dumpTextLine();
|
|
|
|
delPointer();
|
|
|
|
checkCoords(opsList);
|
2011-12-28 01:28:27 +00:00
|
|
|
} while (!_getBack);
|
|
|
|
} while (_getBack == 2);
|
2011-12-15 12:41:30 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
_textAddressX = 13;
|
|
|
|
_textAddressY = 182;
|
|
|
|
_textLen = 240;
|
|
|
|
if (_getBack != 4) {
|
2012-02-22 18:06:29 +00:00
|
|
|
_saveGraphics.clear();
|
2011-12-15 12:41:30 +00:00
|
|
|
restoreAll();
|
|
|
|
redrawMainScrn();
|
|
|
|
workToScreenM();
|
2011-12-28 01:28:27 +00:00
|
|
|
_commandType = 200;
|
2011-12-15 12:41:30 +00:00
|
|
|
}
|
2011-12-28 01:28:27 +00:00
|
|
|
_manIsOffScreen = 0;
|
2011-12-15 12:41:30 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::getBackFromOps() {
|
2011-12-28 12:10:22 +00:00
|
|
|
if (_vars._manDead == 2)
|
2011-12-20 08:39:33 +00:00
|
|
|
blank();
|
|
|
|
else
|
|
|
|
getBack1();
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::getBackToOps() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(42, 201);
|
2011-12-20 08:39:33 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton != _oldButton) {
|
|
|
|
if (_mouseButton & 1) {
|
2011-12-20 08:39:33 +00:00
|
|
|
oldToNames();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 2;
|
2011-12-20 08:39:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showMainOps() {
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx+10, kOpsy+10, 8, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx+59, kOpsy+30, 7, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx+128+4, kOpsy+12, 1, 0);
|
2011-11-21 17:10:19 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showDiscOps() {
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx+128+4, kOpsy+12, 1, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx+10, kOpsy+10, 9, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx+59, kOpsy+30, 10, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx+176+2, kOpsy+60-4, 5, 0);
|
2011-11-26 17:31:54 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::discOps() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(43, 249);
|
2011-12-20 08:39:33 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton == _oldButton || !(_mouseButton & 1))
|
2011-12-20 08:39:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
scanForNames();
|
2011-12-28 01:28:27 +00:00
|
|
|
_loadingOrSave = 2;
|
2011-12-20 08:39:33 +00:00
|
|
|
showOpBox();
|
|
|
|
showDiscOps();
|
2011-12-28 01:28:27 +00:00
|
|
|
_currentSlot = 0;
|
2011-12-20 08:39:33 +00:00
|
|
|
workToScreenM();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-12-20 08:39:33 +00:00
|
|
|
|
2011-12-28 15:55:03 +00:00
|
|
|
RectWithCallback discOpsList[] = {
|
2011-12-28 13:07:17 +00:00
|
|
|
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamWebEngine::loadGame },
|
|
|
|
{ kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamWebEngine::saveGame },
|
|
|
|
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },
|
|
|
|
{ 0,320,0,200,&DreamWebEngine::blank },
|
2011-12-20 08:39:33 +00:00
|
|
|
{ 0xFFFF,0,0,0,0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
do {
|
2011-12-27 03:08:43 +00:00
|
|
|
if (_quitRequested)
|
2011-12-20 08:39:33 +00:00
|
|
|
return; // quitdiscops
|
|
|
|
|
|
|
|
delPointer();
|
|
|
|
readMouse();
|
|
|
|
showPointer();
|
2012-05-30 03:23:34 +00:00
|
|
|
waitForVSync();
|
2011-12-20 08:39:33 +00:00
|
|
|
dumpPointer();
|
|
|
|
dumpTextLine();
|
|
|
|
checkCoords(discOpsList);
|
2011-12-28 01:28:27 +00:00
|
|
|
} while (!_getBack);
|
2011-12-20 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::actualSave() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(44, 222);
|
2011-11-26 16:43:50 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (!(_mouseButton & 1))
|
2011-11-26 16:43:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
unsigned int slot = _currentSlot + 7 * _saveLoadPage;
|
2011-11-26 16:43:50 +00:00
|
|
|
|
2011-12-11 14:57:03 +00:00
|
|
|
const char *desc = &_saveNames[17*slot];
|
2011-11-26 17:07:34 +00:00
|
|
|
if (desc[1] == 0) // The actual description string starts at desc[1]
|
2011-11-26 16:43:50 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-01 19:43:43 +00:00
|
|
|
savePosition(slot, desc);
|
2011-11-26 16:43:50 +00:00
|
|
|
|
2012-02-22 18:06:29 +00:00
|
|
|
_saveGraphics.clear();
|
2011-12-01 19:43:43 +00:00
|
|
|
restoreAll(); // reels
|
2011-12-28 01:28:27 +00:00
|
|
|
_textAddressX = 13;
|
|
|
|
_textAddressY = 182;
|
|
|
|
_textLen = 240;
|
2011-12-01 19:43:43 +00:00
|
|
|
redrawMainScrn();
|
|
|
|
workToScreenM();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 4;
|
2011-11-26 16:23:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::actualLoad() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(41, 221);
|
2011-11-26 16:46:50 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton == _oldButton || _mouseButton != 1)
|
2011-11-26 16:46:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
unsigned int slot = _currentSlot + 7 * _saveLoadPage;
|
2011-11-26 16:46:50 +00:00
|
|
|
|
2011-12-11 14:57:03 +00:00
|
|
|
const char *desc = &_saveNames[17*slot];
|
2011-11-26 17:07:34 +00:00
|
|
|
if (desc[1] == 0) // The actual description string starts at desc[1]
|
2011-11-26 16:46:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
loadPosition(slot);
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 1;
|
2011-11-26 16:23:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::savePosition(unsigned int slot, const char *descbuf) {
|
2011-11-26 17:07:34 +00:00
|
|
|
|
2011-12-28 12:10:22 +00:00
|
|
|
const Room ¤tRoom = g_roomData[_vars._location];
|
2011-11-26 17:07:34 +00:00
|
|
|
|
2011-12-03 15:00:55 +00:00
|
|
|
Room madeUpRoom = currentRoom;
|
2011-12-27 04:39:50 +00:00
|
|
|
madeUpRoom.roomsSample = _roomsSample;
|
2011-12-28 01:28:27 +00:00
|
|
|
madeUpRoom.mapX = _mapX;
|
|
|
|
madeUpRoom.mapY = _mapY;
|
2011-12-28 12:10:22 +00:00
|
|
|
madeUpRoom.liftFlag = _vars._liftFlag;
|
2011-12-28 01:28:27 +00:00
|
|
|
madeUpRoom.b21 = _mansPath;
|
|
|
|
madeUpRoom.facing = _facing;
|
2011-12-03 15:00:55 +00:00
|
|
|
madeUpRoom.b27 = 255;
|
2011-11-26 17:07:34 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
Common::String filename = getSavegameFilename(slot);
|
2011-12-09 15:04:45 +00:00
|
|
|
debug(1, "savePosition: slot %d filename %s", slot, filename.c_str());
|
2011-12-28 13:07:17 +00:00
|
|
|
Common::OutSaveFile *outSaveFile = getSaveFileManager()->openForSaving(filename);
|
2011-12-09 14:50:38 +00:00
|
|
|
if (!outSaveFile) // TODO: Do proper error handling!
|
|
|
|
error("save could not be opened for writing");
|
2011-11-26 15:38:06 +00:00
|
|
|
|
2011-12-03 14:47:24 +00:00
|
|
|
// Initialize new header
|
|
|
|
FileHeader header;
|
|
|
|
|
|
|
|
// Note: _desc is not zero-terminated
|
|
|
|
const char *desc = "DREAMWEB DATA FILE COPYRIGHT 1992 CREATIVE REALITY";
|
|
|
|
assert(strlen(desc) == sizeof(header._desc));
|
|
|
|
memcpy(header._desc, desc, sizeof(header._desc));
|
|
|
|
memset(&header._len[0], 0, sizeof(header._len));
|
|
|
|
memset(&header._padding[0], 0, sizeof(header._padding));
|
|
|
|
|
2011-11-26 15:38:06 +00:00
|
|
|
// fill length fields in savegame file header
|
|
|
|
uint16 len[6] = { 17, kLengthofvars, kLengthofextra,
|
2011-12-28 10:15:23 +00:00
|
|
|
4*kNumChanges, 48, kNumReelRoutines*8+1 };
|
2011-11-26 15:38:06 +00:00
|
|
|
for (int i = 0; i < 6; ++i)
|
2011-12-03 14:47:24 +00:00
|
|
|
header.setLen(i, len[i]);
|
2011-11-26 15:38:06 +00:00
|
|
|
|
2011-12-18 00:54:51 +00:00
|
|
|
// Write a new section with data that we need for ScummVM (version,
|
|
|
|
// thumbnail, played time etc). We don't really care for its size,
|
|
|
|
// so we just set it to a magic number.
|
|
|
|
header.setLen(6, SCUMMVM_BLOCK_MAGIC_SIZE);
|
|
|
|
|
2011-12-09 14:50:38 +00:00
|
|
|
outSaveFile->write((const uint8 *)&header, sizeof(FileHeader));
|
|
|
|
outSaveFile->write(descbuf, len[0]);
|
2011-12-28 12:10:22 +00:00
|
|
|
// TODO: Convert more to serializer?
|
|
|
|
Common::Serializer s(0, outSaveFile);
|
|
|
|
syncGameVars(s, _vars);
|
2011-12-27 20:28:37 +00:00
|
|
|
|
|
|
|
// the Extras segment:
|
2011-12-28 15:48:10 +00:00
|
|
|
outSaveFile->write((const uint8 *)_exFrames._frames, kFrameBlocksize);
|
2011-12-27 20:28:37 +00:00
|
|
|
outSaveFile->write((const uint8 *)_exFrames._data, kExframeslen);
|
|
|
|
outSaveFile->write((const uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
|
2011-12-27 20:42:38 +00:00
|
|
|
outSaveFile->write((const uint8 *)_exText._offsetsLE, 2*(kNumExObjects+2));
|
|
|
|
outSaveFile->write((const uint8 *)_exText._text, kExtextlen);
|
2011-12-27 20:28:37 +00:00
|
|
|
|
2011-12-23 21:58:31 +00:00
|
|
|
outSaveFile->write(_listOfChanges, len[3]);
|
2011-12-03 15:00:55 +00:00
|
|
|
|
|
|
|
// len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango'
|
2011-12-09 14:50:38 +00:00
|
|
|
outSaveFile->write((const uint8 *)&madeUpRoom, sizeof(Room));
|
2011-12-26 11:59:20 +00:00
|
|
|
outSaveFile->write(_roomsCanGo, 16);
|
2011-12-09 14:50:38 +00:00
|
|
|
|
2011-12-18 15:53:47 +00:00
|
|
|
for (unsigned int i = 0; i < kNumReelRoutines; ++i) {
|
|
|
|
syncReelRoutine(s, &_reelRoutines[i]);
|
2011-12-17 20:30:54 +00:00
|
|
|
}
|
2011-12-18 11:38:53 +00:00
|
|
|
// Terminator
|
2011-12-18 15:53:47 +00:00
|
|
|
s.syncAsByte(_reelRoutines[kNumReelRoutines].reallocation);
|
2011-12-09 14:50:38 +00:00
|
|
|
|
2011-12-18 00:54:51 +00:00
|
|
|
// ScummVM data block
|
|
|
|
outSaveFile->writeUint32BE(SCUMMVM_HEADER);
|
|
|
|
outSaveFile->writeByte(SAVEGAME_VERSION);
|
|
|
|
TimeDate curTime;
|
|
|
|
g_system->getTimeAndDate(curTime);
|
|
|
|
uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
|
|
|
|
uint32 saveTime = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
|
|
|
|
uint32 playTime = g_engine->getTotalPlayTime() / 1000;
|
|
|
|
outSaveFile->writeUint32LE(saveDate);
|
|
|
|
outSaveFile->writeUint32LE(saveTime);
|
|
|
|
outSaveFile->writeUint32LE(playTime);
|
|
|
|
Graphics::saveThumbnail(*outSaveFile);
|
|
|
|
|
2011-12-09 14:50:38 +00:00
|
|
|
outSaveFile->finalize();
|
|
|
|
if (outSaveFile->err()) {
|
|
|
|
// TODO: Do proper error handling
|
|
|
|
warning("an error occurred while writing the savegame");
|
|
|
|
}
|
2011-12-03 15:00:55 +00:00
|
|
|
|
2011-12-09 14:50:38 +00:00
|
|
|
delete outSaveFile;
|
2011-11-26 14:56:32 +00:00
|
|
|
}
|
|
|
|
|
2012-12-01 11:29:17 +00:00
|
|
|
|
|
|
|
// Utility struct for a savegame sanity check in loadPosition
|
|
|
|
struct FrameExtent {
|
|
|
|
uint16 start;
|
|
|
|
uint16 length;
|
|
|
|
bool operator<(const struct FrameExtent& other) const { return start<other.start; }
|
|
|
|
};
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::loadPosition(unsigned int slot) {
|
2011-12-28 01:28:27 +00:00
|
|
|
_timeCount = 0;
|
2011-12-01 19:43:43 +00:00
|
|
|
clearChanges();
|
2011-11-26 16:07:40 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
Common::String filename = getSavegameFilename(slot);
|
2011-12-09 15:04:45 +00:00
|
|
|
debug(1, "loadPosition: slot %d filename %s", slot, filename.c_str());
|
2011-12-28 13:07:17 +00:00
|
|
|
Common::InSaveFile *inSaveFile = getSaveFileManager()->openForLoading(filename);
|
2011-12-09 15:04:45 +00:00
|
|
|
if (!inSaveFile) // TODO: Do proper error handling!
|
|
|
|
error("save could not be opened for reading");
|
2011-11-26 16:07:40 +00:00
|
|
|
|
2011-12-03 14:47:24 +00:00
|
|
|
FileHeader header;
|
|
|
|
|
2011-12-09 15:04:45 +00:00
|
|
|
inSaveFile->read((uint8 *)&header, sizeof(FileHeader));
|
2011-11-26 16:07:40 +00:00
|
|
|
|
|
|
|
// read segment lengths from savegame file header
|
|
|
|
int len[6];
|
|
|
|
for (int i = 0; i < 6; ++i)
|
2011-12-03 14:47:24 +00:00
|
|
|
len[i] = header.len(i);
|
2011-11-26 16:07:40 +00:00
|
|
|
if (len[0] != 17)
|
|
|
|
::error("Error loading save: description buffer isn't 17 bytes");
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
if (slot < 21) {
|
2011-12-11 14:57:03 +00:00
|
|
|
inSaveFile->read(&_saveNames[17*slot], len[0]);
|
2011-11-26 17:07:34 +00:00
|
|
|
} else {
|
2012-01-08 18:36:59 +00:00
|
|
|
// The savenames buffer only has room for 21 descriptions
|
2011-11-26 17:07:34 +00:00
|
|
|
uint8 namebuf[17];
|
2011-12-09 15:04:45 +00:00
|
|
|
inSaveFile->read(namebuf, 17);
|
2011-11-26 17:07:34 +00:00
|
|
|
}
|
2011-12-28 12:10:22 +00:00
|
|
|
|
|
|
|
// TODO: Use serializer for more?
|
|
|
|
Common::Serializer s(inSaveFile, 0);
|
|
|
|
syncGameVars(s, _vars);
|
2011-12-27 20:28:37 +00:00
|
|
|
|
|
|
|
// the Extras segment:
|
2011-12-28 15:48:10 +00:00
|
|
|
inSaveFile->read((uint8 *)_exFrames._frames, kFrameBlocksize);
|
2011-12-27 20:28:37 +00:00
|
|
|
inSaveFile->read((uint8 *)_exFrames._data, kExframeslen);
|
|
|
|
inSaveFile->read((uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
|
2011-12-27 20:42:38 +00:00
|
|
|
inSaveFile->read((uint8 *)_exText._offsetsLE, 2*(kNumExObjects+2));
|
|
|
|
inSaveFile->read((uint8 *)_exText._text, kExtextlen);
|
2011-12-27 20:28:37 +00:00
|
|
|
|
2011-12-23 21:58:31 +00:00
|
|
|
inSaveFile->read(_listOfChanges, len[3]);
|
2011-12-03 15:00:55 +00:00
|
|
|
|
|
|
|
// len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango'
|
2011-12-03 19:32:41 +00:00
|
|
|
// Note: the values read into g_madeUpRoomDat are only used in actualLoad,
|
2011-12-03 15:30:51 +00:00
|
|
|
// which is (almost) immediately called after this function
|
2011-12-09 15:04:45 +00:00
|
|
|
inSaveFile->read((uint8 *)&g_madeUpRoomDat, sizeof(Room));
|
2011-12-26 11:59:20 +00:00
|
|
|
inSaveFile->read(_roomsCanGo, 16);
|
2011-12-03 15:00:55 +00:00
|
|
|
|
2011-12-18 15:53:47 +00:00
|
|
|
for (unsigned int i = 0; i < kNumReelRoutines; ++i) {
|
|
|
|
syncReelRoutine(s, &_reelRoutines[i]);
|
2011-12-17 20:30:54 +00:00
|
|
|
}
|
2011-12-18 11:38:53 +00:00
|
|
|
// Terminator
|
2011-12-18 15:53:47 +00:00
|
|
|
s.syncAsByte(_reelRoutines[kNumReelRoutines].reallocation);
|
2011-11-26 16:07:40 +00:00
|
|
|
|
2011-12-18 00:54:51 +00:00
|
|
|
// Check if there's a ScummVM data block
|
|
|
|
if (header.len(6) == SCUMMVM_BLOCK_MAGIC_SIZE) {
|
|
|
|
uint32 tag = inSaveFile->readUint32BE();
|
|
|
|
if (tag != SCUMMVM_HEADER) {
|
|
|
|
warning("ScummVM data block found, but the block header is incorrect - skipping");
|
|
|
|
delete inSaveFile;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte version = inSaveFile->readByte();
|
|
|
|
if (version > SAVEGAME_VERSION) {
|
|
|
|
warning("ScummVM data block found, but it has been saved with a newer version of ScummVM - skipping");
|
|
|
|
delete inSaveFile;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
inSaveFile->skip(4); // saveDate
|
|
|
|
inSaveFile->skip(4); // saveTime
|
|
|
|
uint32 playTime = inSaveFile->readUint32LE();
|
|
|
|
g_engine->setTotalPlayTime(playTime * 1000);
|
|
|
|
|
|
|
|
// The thumbnail data follows, but we don't need it here
|
|
|
|
}
|
|
|
|
|
2011-12-09 15:04:45 +00:00
|
|
|
delete inSaveFile;
|
2012-12-01 11:29:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Do a sanity check on exFrames data to detect exFrames corruption
|
|
|
|
// caused by a (now fixed) bug in emergencyPurge. See bug #3591088.
|
|
|
|
// Gather the location of frame data of all used ex object frames.
|
|
|
|
Common::List<FrameExtent> flist;
|
|
|
|
for (unsigned int i = 0; i < kNumexobjects; ++i) {
|
|
|
|
if (_exData[i].mapad[0] != 0xff) {
|
|
|
|
FrameExtent fe;
|
|
|
|
Frame *frame = &_exFrames._frames[3*i+0];
|
|
|
|
fe.start = frame->ptr();
|
|
|
|
fe.length = frame->width * frame->height;
|
|
|
|
flist.push_back(fe);
|
|
|
|
|
|
|
|
frame = &_exFrames._frames[3*i+1];
|
|
|
|
fe.start = frame->ptr();
|
|
|
|
fe.length = frame->width * frame->height;
|
|
|
|
flist.push_back(fe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ...and check if the frames overlap.
|
|
|
|
Common::sort(flist.begin(), flist.end(), Common::Less<FrameExtent>());
|
|
|
|
Common::List<FrameExtent>::const_iterator iter;
|
|
|
|
uint16 curEnd = 0;
|
|
|
|
for (iter = flist.begin(); iter != flist.end(); ++iter) {
|
|
|
|
if (iter->start < curEnd)
|
|
|
|
error("exFrames data corruption in savegame");
|
|
|
|
curEnd = iter->start + iter->length;
|
|
|
|
}
|
|
|
|
if (curEnd > _vars._exFramePos) {
|
|
|
|
if (curEnd > kExframeslen)
|
|
|
|
error("exFrames data corruption in savegame");
|
|
|
|
warning("Fixing up exFramePos");
|
|
|
|
_vars._exFramePos = curEnd;
|
|
|
|
}
|
|
|
|
// (end of sanity check)
|
2011-11-26 14:56:32 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 14:57:03 +00:00
|
|
|
// Count number of save files, and load their descriptions into _saveNames
|
2011-12-28 13:07:17 +00:00
|
|
|
uint DreamWebEngine::scanForNames() {
|
2012-01-11 22:56:20 +00:00
|
|
|
// There are 21 save slots, each of which are 17 bytes. The first byte
|
|
|
|
// doesn't seem to be used. The name starts at the second byte. All the
|
|
|
|
// slots are initialized to be empty.
|
2012-01-08 18:36:59 +00:00
|
|
|
for (unsigned int slot = 0; slot < 21; ++slot) {
|
2011-12-17 17:30:06 +00:00
|
|
|
_saveNames[17 * slot + 0] = 2;
|
|
|
|
_saveNames[17 * slot + 1] = 0;
|
2011-12-11 14:57:03 +00:00
|
|
|
for (int i = 2; i < 17; ++i)
|
2011-12-28 13:07:17 +00:00
|
|
|
_saveNames[17 * slot + i] = 1; // initialize with 1'sdrea
|
2011-12-17 17:30:06 +00:00
|
|
|
}
|
2011-12-03 14:18:45 +00:00
|
|
|
|
2011-12-17 17:30:06 +00:00
|
|
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
|
|
|
Common::StringArray files = saveFileMan->listSavefiles("DREAMWEB.D??");
|
|
|
|
Common::sort(files.begin(), files.end());
|
|
|
|
|
|
|
|
SaveStateList saveList;
|
|
|
|
for (uint i = 0; i < files.size(); ++i) {
|
|
|
|
const Common::String &file = files[i];
|
|
|
|
Common::InSaveFile *stream = saveFileMan->openForLoading(file);
|
|
|
|
if (!stream)
|
|
|
|
error("cannot open save file %s", file.c_str());
|
|
|
|
char name[17] = {};
|
|
|
|
stream->seek(0x61);
|
|
|
|
stream->read(name, sizeof(name) - 1);
|
|
|
|
delete stream;
|
|
|
|
|
|
|
|
int slotNum = atoi(file.c_str() + file.size() - 2);
|
|
|
|
SaveStateDescriptor sd(slotNum, name);
|
|
|
|
saveList.push_back(sd);
|
2012-01-08 18:36:59 +00:00
|
|
|
if (slotNum < 21)
|
2011-12-17 17:30:06 +00:00
|
|
|
Common::strlcpy(&_saveNames[17 * slotNum + 1], name, 16); // the first character is unused
|
2011-12-03 14:18:45 +00:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:33:09 +00:00
|
|
|
// FIXME: Can the following be safely removed?
|
|
|
|
// al = saveList.size() <= 7 ? (uint8)saveList.size() : 7;
|
2011-12-03 14:18:45 +00:00
|
|
|
|
2011-12-17 17:30:06 +00:00
|
|
|
return saveList.size();
|
2011-12-03 14:05:57 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::loadOld() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(48, 252);
|
2011-12-03 15:54:39 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (!(_mouseButton & 1))
|
2011-12-03 15:54:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
doLoad(-1);
|
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_getBack == 4 || _quitRequested)
|
2011-12-03 15:54:39 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-03 15:46:44 +00:00
|
|
|
showDecisions();
|
|
|
|
workToScreenM();
|
2011-12-28 01:28:27 +00:00
|
|
|
_getBack = 0;
|
2011-12-03 15:46:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showDecisions() {
|
2011-12-20 09:27:02 +00:00
|
|
|
createPanel2();
|
|
|
|
showOpBox();
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx + 17, kOpsy + 13, 6, 0);
|
2011-12-20 09:27:02 +00:00
|
|
|
underTextLine();
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::loadSaveBox() {
|
2012-02-24 05:46:00 +00:00
|
|
|
loadGraphicsFile(_saveGraphics, "G08");
|
2011-12-04 23:45:42 +00:00
|
|
|
}
|
2011-12-03 15:46:44 +00:00
|
|
|
|
2011-12-11 14:16:57 +00:00
|
|
|
// show savegame names (original interface), and set kCursorpos
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showNames() {
|
2012-01-08 18:36:59 +00:00
|
|
|
unsigned int offset = 7 * _saveLoadPage;
|
2011-12-11 14:16:57 +00:00
|
|
|
for (int slot = 0; slot < 7; ++slot) {
|
|
|
|
// The first character of the savegame name is unused
|
2012-01-08 18:36:59 +00:00
|
|
|
Common::String name(&_saveNames[17 * (slot + offset) + 1]);
|
2011-12-11 14:16:57 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (slot != _currentSlot) {
|
2011-12-11 14:16:57 +00:00
|
|
|
printDirect((const uint8 *)name.c_str(), kOpsx + 21, kOpsy + 10*slot + 10, 200, false);
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_loadingOrSave != 2) {
|
|
|
|
_charShift = 91;
|
2011-12-11 14:16:57 +00:00
|
|
|
printDirect((const uint8 *)name.c_str(), kOpsx + 21, kOpsy + 10*slot + 10, 200, false);
|
2011-12-28 01:28:27 +00:00
|
|
|
_charShift = 0;
|
2011-12-11 14:16:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pos = name.size();
|
2011-12-28 01:28:27 +00:00
|
|
|
_cursorPos = pos;
|
2011-12-11 14:16:57 +00:00
|
|
|
name += '/'; // cursor character
|
|
|
|
printDirect((const uint8 *)name.c_str(), kOpsx + 21, kOpsy + 10*slot + 10, 200, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::checkInput() {
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_loadingOrSave == 3)
|
2011-12-11 14:45:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
readKey();
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
unsigned int slot = _currentSlot + 7 * _saveLoadPage;
|
|
|
|
|
2011-12-11 14:57:03 +00:00
|
|
|
// The first character of the savegame name is unused
|
2012-01-08 18:36:59 +00:00
|
|
|
char *name = &_saveNames[17*slot + 1];
|
2011-12-11 14:45:53 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_currentKey == 0) {
|
2011-12-11 14:45:53 +00:00
|
|
|
return;
|
2011-12-28 01:28:27 +00:00
|
|
|
} else if (_currentKey == 13) {
|
|
|
|
_loadingOrSave = 3;
|
|
|
|
} else if (_currentKey == 8) {
|
|
|
|
if (_cursorPos == 0)
|
2011-12-11 14:45:53 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
--_cursorPos;
|
|
|
|
name[_cursorPos] = 0;
|
|
|
|
name[_cursorPos+1] = 1;
|
2011-12-11 14:45:53 +00:00
|
|
|
} else {
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_cursorPos == 14)
|
2011-12-11 14:45:53 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
name[_cursorPos] = _currentKey;
|
|
|
|
name[_cursorPos+1] = 0;
|
|
|
|
name[_cursorPos+2] = 1;
|
|
|
|
++_cursorPos;
|
2011-12-11 14:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
showOpBox();
|
|
|
|
showNames();
|
|
|
|
showSlots();
|
|
|
|
showSaveOps();
|
|
|
|
workToScreenM();
|
|
|
|
}
|
|
|
|
|
2012-01-08 18:36:59 +00:00
|
|
|
void DreamWebEngine::selectSaveLoadPage() {
|
2012-01-11 22:38:37 +00:00
|
|
|
commandOnlyCond(31, 254);
|
2012-01-08 18:36:59 +00:00
|
|
|
|
|
|
|
if (_mouseButton != 1 || _mouseButton == _oldButton)
|
|
|
|
return;
|
|
|
|
uint saveLoadPage = (_mouseX - (kOpsx + 158)) / 18;
|
|
|
|
if (saveLoadPage != _saveLoadPage) {
|
|
|
|
_saveLoadPage = saveLoadPage;
|
|
|
|
// This will also make the first slot the selected one, based
|
|
|
|
// on the mouse Y position. I can't decide if this is a feature
|
|
|
|
// or not.
|
|
|
|
selectSlot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::selectSlot() {
|
2011-12-28 19:31:50 +00:00
|
|
|
commandOnlyCond(45, 244);
|
2011-12-15 12:41:30 +00:00
|
|
|
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_mouseButton != 1 || _mouseButton == _oldButton)
|
2011-12-15 12:41:30 +00:00
|
|
|
return; // noselslot
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_loadingOrSave == 3)
|
|
|
|
_loadingOrSave--;
|
2011-12-15 12:41:30 +00:00
|
|
|
|
|
|
|
oldToNames();
|
2011-12-28 01:28:27 +00:00
|
|
|
int y = _mouseY - (kOpsy + 4);
|
2011-12-15 12:41:30 +00:00
|
|
|
if (y < 11)
|
2011-12-28 01:28:27 +00:00
|
|
|
_currentSlot = 0;
|
2011-12-15 12:41:30 +00:00
|
|
|
else
|
2011-12-28 01:28:27 +00:00
|
|
|
_currentSlot = y / 11;
|
2011-12-15 12:41:30 +00:00
|
|
|
|
|
|
|
delPointer();
|
|
|
|
showOpBox();
|
|
|
|
showSlots();
|
|
|
|
showNames();
|
2011-12-28 01:28:27 +00:00
|
|
|
if (_loadingOrSave == 1)
|
2011-12-15 12:41:30 +00:00
|
|
|
showLoadOps();
|
|
|
|
else
|
|
|
|
showSaveOps();
|
|
|
|
readMouse();
|
|
|
|
showPointer();
|
2011-12-25 23:59:04 +00:00
|
|
|
workToScreen();
|
2011-12-15 12:41:30 +00:00
|
|
|
delPointer();
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showSlots() {
|
2012-01-08 18:36:59 +00:00
|
|
|
showFrame(_icons1, kOpsx + 158, kOpsy - 11, 12, 0);
|
|
|
|
showFrame(_icons1, kOpsx + 158 + 18 * _saveLoadPage, kOpsy - 11, 13 + _saveLoadPage, 0);
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx + 7, kOpsy + 8, 2, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
|
|
|
|
uint16 y = kOpsy + 11;
|
|
|
|
|
|
|
|
for (int slot = 0; slot < 7; slot++) {
|
2011-12-28 01:28:27 +00:00
|
|
|
if (slot == _currentSlot)
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx + 10, y, 3, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
|
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showOpBox() {
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx, kOpsy, 0, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
|
2011-12-28 16:53:45 +00:00
|
|
|
// This call displays half of the ops dialog in the CD version. It's not
|
|
|
|
// in the floppy version, and if it's called, a stray red dot is shown in
|
2012-05-21 08:40:35 +00:00
|
|
|
// the game dialogs. It is included in the early UK CD release, which had
|
|
|
|
// similar data files as the floppy release (bug #3528160).
|
|
|
|
if (isCD() && getLanguage() != Common::EN_GRB)
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx, kOpsy + 55, 4, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showLoadOps() {
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
printMessage(kOpsx + 104, kOpsy + 14, 55, 101, (101 & 1));
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
void DreamWebEngine::showSaveOps() {
|
2012-02-22 18:06:29 +00:00
|
|
|
showFrame(_saveGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0);
|
|
|
|
showFrame(_saveGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
|
2011-12-20 08:39:33 +00:00
|
|
|
printMessage(kOpsx + 104, kOpsy + 14, 54, 101, (101 & 1));
|
|
|
|
}
|
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
} // End of namespace DreamWeb
|