2011-06-05 09:38:05 +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-05 09:38:05 +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-05 09:38:05 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/func.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/timer.h"
|
2011-06-08 07:26:46 +00:00
|
|
|
#include "common/util.h"
|
2011-06-05 09:38:05 +00:00
|
|
|
|
2012-02-22 17:21:57 +00:00
|
|
|
#include "engines/advancedDetector.h"
|
|
|
|
|
2011-06-05 09:38:05 +00:00
|
|
|
#include "graphics/palette.h"
|
2011-06-08 07:26:46 +00:00
|
|
|
#include "graphics/surface.h"
|
2011-06-05 09:38:05 +00:00
|
|
|
|
2012-05-31 04:16:10 +00:00
|
|
|
#include "dreamweb/sound.h"
|
2011-06-05 09:38:05 +00:00
|
|
|
#include "dreamweb/dreamweb.h"
|
|
|
|
|
|
|
|
namespace DreamWeb {
|
|
|
|
|
2011-06-19 22:59:48 +00:00
|
|
|
DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gameDesc) :
|
2011-12-28 13:07:17 +00:00
|
|
|
Engine(syst), _gameDescription(gameDesc), _rnd("dreamweb"),
|
2011-12-28 15:48:10 +00:00
|
|
|
_exText(kNumExTexts),
|
|
|
|
_setDesc(kNumSetTexts), _blockDesc(kNumBlockTexts),
|
|
|
|
_roomDesc(kNumRoomTexts), _freeDesc(kNumFreeTexts),
|
|
|
|
_personText(kNumPersonTexts) {
|
2011-06-12 14:15:06 +00:00
|
|
|
|
2016-07-28 08:34:34 +00:00
|
|
|
DebugMan.addDebugChannel(kDebugAnimation, "Animation", "Animation Debug Flag");
|
|
|
|
DebugMan.addDebugChannel(kDebugSaveLoad, "SaveLoad", "Track Save/Load Function");
|
|
|
|
|
2012-05-31 04:16:10 +00:00
|
|
|
_sound = 0;
|
2011-06-13 07:35:58 +00:00
|
|
|
_speed = 1;
|
2011-06-14 08:07:59 +00:00
|
|
|
_turbo = false;
|
2011-06-13 09:30:02 +00:00
|
|
|
_oldMouseState = 0;
|
2011-06-25 14:20:19 +00:00
|
|
|
|
2012-02-24 19:43:49 +00:00
|
|
|
_datafilePrefix = "DREAMWEB.";
|
2012-05-08 15:48:01 +00:00
|
|
|
_speechDirName = "SPEECH";
|
2012-04-09 18:38:25 +00:00
|
|
|
// ES and FR CD release use a different data file prefix
|
2012-05-08 15:58:43 +00:00
|
|
|
// and speech directory naming.
|
2012-04-09 18:38:25 +00:00
|
|
|
if (isCD()) {
|
|
|
|
switch(getLanguage()) {
|
|
|
|
case Common::ES_ESP:
|
|
|
|
_datafilePrefix = "DREAMWSP.";
|
2012-05-08 15:58:43 +00:00
|
|
|
_speechDirName = "SPANISH";
|
2012-04-09 18:38:25 +00:00
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
|
|
|
_datafilePrefix = "DREAMWFR.";
|
2012-05-08 15:58:43 +00:00
|
|
|
_speechDirName = "FRENCH";
|
2012-04-09 18:38:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Nothing to do
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-24 04:44:26 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
_openChangeSize = kInventx+(4*kItempicsize);
|
|
|
|
_quitRequested = false;
|
|
|
|
|
|
|
|
_speechLoaded = false;
|
|
|
|
|
|
|
|
_backdropBlocks = 0;
|
|
|
|
_reelList = 0;
|
|
|
|
|
|
|
|
_oldSubject._type = 0;
|
|
|
|
_oldSubject._index = 0;
|
|
|
|
|
|
|
|
// misc variables
|
|
|
|
_speechCount = 0;
|
|
|
|
_charShift = 0;
|
2012-03-03 23:11:50 +00:00
|
|
|
_brightPalette = false;
|
2011-12-28 13:07:17 +00:00
|
|
|
_roomLoaded = 0;
|
|
|
|
_didZoom = 0;
|
|
|
|
_lineSpacing = 10;
|
|
|
|
_textAddressX = 13;
|
|
|
|
_textAddressY = 182;
|
|
|
|
_textLen = 0;
|
|
|
|
_lastXPos = 0;
|
|
|
|
_itemFrame = 0;
|
|
|
|
_withObject = 0;
|
|
|
|
_withType = 0;
|
|
|
|
_lookCounter = 0;
|
|
|
|
_command = 0;
|
|
|
|
_commandType = 0;
|
|
|
|
_objectType = 0;
|
|
|
|
_getBack = 0;
|
|
|
|
_invOpen = 0;
|
|
|
|
_mainMode = 0;
|
|
|
|
_pickUp = 0;
|
|
|
|
_lastInvPos = 0;
|
|
|
|
_examAgain = 0;
|
|
|
|
_newTextLine = 0;
|
|
|
|
_openedOb = 0;
|
|
|
|
_openedType = 0;
|
|
|
|
_mapAdX = 0;
|
|
|
|
_mapAdY = 0;
|
|
|
|
_mapOffsetX = 104;
|
|
|
|
_mapOffsetY = 38;
|
|
|
|
_mapXStart = 0;
|
|
|
|
_mapYStart = 0;
|
|
|
|
_mapXSize = 0;
|
|
|
|
_mapYSize = 0;
|
|
|
|
_haveDoneObs = 0;
|
|
|
|
_manIsOffScreen = 0;
|
|
|
|
_facing = 0;
|
|
|
|
_leaveDirection = 0;
|
|
|
|
_turnToFace = 0;
|
|
|
|
_turnDirection = 0;
|
|
|
|
_mainTimer = 0;
|
|
|
|
_introCount = 0;
|
|
|
|
_currentKey = 0;
|
|
|
|
_timerCount = 0;
|
|
|
|
_mapX = 0;
|
|
|
|
_mapY = 0;
|
|
|
|
_ryanX = 0;
|
|
|
|
_ryanY = 0;
|
|
|
|
_lastFlag = 0;
|
|
|
|
_destPos = 0;
|
|
|
|
_realLocation = 0;
|
|
|
|
_roomNum = 0;
|
|
|
|
_nowInNewRoom = 0;
|
|
|
|
_resetManXY = 0;
|
|
|
|
_newLocation = 0xFF;
|
|
|
|
_autoLocation = 0xFF;
|
|
|
|
_mouseX = 0;
|
|
|
|
_mouseY = 0;
|
|
|
|
_mouseButton = 0;
|
|
|
|
_oldButton = 0;
|
|
|
|
_oldX = 0;
|
|
|
|
_oldY = 0;
|
|
|
|
_oldPointerX = 0;
|
|
|
|
_oldPointerY = 0;
|
|
|
|
_delHereX = 0;
|
|
|
|
_delHereY = 0;
|
|
|
|
_pointerXS = 32;
|
|
|
|
_pointerYS = 32;
|
|
|
|
_delXS = 0;
|
|
|
|
_delYS = 0;
|
|
|
|
_pointerFrame = 0;
|
|
|
|
_pointerPower = 0;
|
|
|
|
_pointerMode = 0;
|
|
|
|
_pointerSpeed = 0;
|
|
|
|
_pointerCount = 0;
|
|
|
|
_inMapArea = 0;
|
|
|
|
_talkMode = 0;
|
|
|
|
_talkPos = 0;
|
|
|
|
_character = 0;
|
|
|
|
_watchDump = 0;
|
|
|
|
_logoNum = 0;
|
|
|
|
_oldLogoNum = 0;
|
|
|
|
_pressed = 0;
|
|
|
|
_pressPointer = 0;
|
|
|
|
_graphicPress = 0;
|
|
|
|
_pressCount = 0;
|
|
|
|
_lightCount = 0;
|
|
|
|
_folderPage = 0;
|
|
|
|
_diaryPage = 0;
|
|
|
|
_menuCount = 0;
|
|
|
|
_symbolTopX = 0;
|
|
|
|
_symbolTopNum = 0;
|
|
|
|
_symbolTopDir = 0;
|
|
|
|
_symbolBotX = 0;
|
|
|
|
_symbolBotNum = 0;
|
|
|
|
_symbolBotDir = 0;
|
|
|
|
_walkAndExam = 0;
|
|
|
|
_walkExamType = 0;
|
|
|
|
_walkExamNum = 0;
|
|
|
|
_cursLocX = 0;
|
|
|
|
_cursLocY = 0;
|
|
|
|
_curPos = 0;
|
|
|
|
_monAdX = 0;
|
|
|
|
_monAdY = 0;
|
|
|
|
_timeCount = 0;
|
|
|
|
_needToDumpTimed = 0;
|
|
|
|
_loadingOrSave = 0;
|
2012-01-08 18:36:59 +00:00
|
|
|
_saveLoadPage = 0;
|
2011-12-28 13:07:17 +00:00
|
|
|
_currentSlot = 0;
|
|
|
|
_cursorPos = 0;
|
2014-02-19 20:41:43 +00:00
|
|
|
_colorPos = 0;
|
2011-12-28 13:07:17 +00:00
|
|
|
_fadeDirection = 0;
|
|
|
|
_numToFade = 0;
|
|
|
|
_fadeCount = 0;
|
|
|
|
_addToGreen = 0;
|
|
|
|
_addToRed = 0;
|
|
|
|
_addToBlue = 0;
|
|
|
|
_lastSoundReel = 0;
|
2012-11-29 01:39:08 +00:00
|
|
|
_lastHardKey = Common::KEYCODE_INVALID;
|
2011-12-28 13:07:17 +00:00
|
|
|
_bufferIn = 0;
|
|
|
|
_bufferOut = 0;
|
|
|
|
_blinkFrame = 23;
|
|
|
|
_blinkCount = 0;
|
|
|
|
_reAssesChanges = 0;
|
|
|
|
_pointersPath = 0;
|
|
|
|
_mansPath = 0;
|
|
|
|
_pointerFirstPath = 0;
|
|
|
|
_finalDest = 0;
|
|
|
|
_destination = 0;
|
|
|
|
_lineStartX = 0;
|
|
|
|
_lineStartY = 0;
|
|
|
|
_lineEndX = 0;
|
|
|
|
_lineEndY = 0;
|
|
|
|
_linePointer = 0;
|
|
|
|
_lineDirection = 0;
|
|
|
|
_lineLength = 0;
|
2013-10-18 13:04:48 +00:00
|
|
|
|
|
|
|
_subtitles = 0;
|
|
|
|
_foreignRelease = 0;
|
|
|
|
_wonGame = 0;
|
|
|
|
_hasSpeech = 0;
|
|
|
|
_roomsSample = 0;
|
|
|
|
_copyProtection = 0;
|
2013-10-29 07:58:36 +00:00
|
|
|
|
|
|
|
for (uint i = 0; i < 128; i++)
|
|
|
|
memset(&_setDat[i], 0, sizeof(SetObject));
|
|
|
|
|
|
|
|
for (uint i = 0; i < 80; i++)
|
|
|
|
memset(&_freeDat[i], 0, sizeof(DynObject));
|
|
|
|
|
|
|
|
for (uint i = 0; i < kNumExObjects; i++)
|
|
|
|
memset(&_exData[i], 0, sizeof(DynObject));
|
2013-11-09 10:59:38 +00:00
|
|
|
|
|
|
|
memset(&_vars, 0, sizeof(GameVars));
|
|
|
|
|
|
|
|
for (uint i = 0; i < 96; i++)
|
|
|
|
memset(&_backdropFlags[i], 0, sizeof(BackdropMapFlag));
|
|
|
|
|
|
|
|
for (uint i = 0; i < kNumReelRoutines+1; i++)
|
|
|
|
memset(&_reelRoutines[i], 0, sizeof(ReelRoutine));
|
|
|
|
|
|
|
|
_personData = 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i < 16; i++)
|
|
|
|
memset(&_openInvList[i], 0, sizeof(ObjectRef));
|
|
|
|
|
|
|
|
for (uint i = 0; i < 30; i++)
|
|
|
|
memset(&_ryanInvList[i], 0, sizeof(ObjectRef));
|
|
|
|
|
|
|
|
for (uint i = 0; i < 11*10; i++)
|
|
|
|
memset(&_mapFlags[i], 0, sizeof(MapFlag));
|
|
|
|
|
|
|
|
for (uint i = 0; i < kNumChanges; i++)
|
|
|
|
memset(&_listOfChanges[i], 0, sizeof(Change));
|
|
|
|
|
|
|
|
_currentCharset = 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i < 36; i++)
|
|
|
|
memset(&_pathData[i], 0, sizeof(RoomPaths));
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DreamWebEngine::~DreamWebEngine() {
|
|
|
|
DebugMan.clearAllDebugChannels();
|
2012-05-31 04:16:10 +00:00
|
|
|
delete _sound;
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 22:35:57 +00:00
|
|
|
void DreamWebEngine::waitForVSync() {
|
|
|
|
const uint32 previousTicks = _system->getMillis();
|
|
|
|
// Originally, this was an interval for a thread that was
|
|
|
|
// called every 1000000 / 70 nanoseconds. It has been
|
|
|
|
// adjusted to be a delay instead.
|
|
|
|
const uint32 delay = 800 / 70 / _speed;
|
2011-06-05 09:38:05 +00:00
|
|
|
|
2020-01-22 22:35:57 +00:00
|
|
|
if (isPaused())
|
|
|
|
return;
|
2011-06-05 09:38:05 +00:00
|
|
|
|
2011-06-08 07:14:12 +00:00
|
|
|
processEvents();
|
2011-06-11 12:52:05 +00:00
|
|
|
|
2020-01-22 22:35:57 +00:00
|
|
|
while (!_turbo && _system->getMillis() - previousTicks < delay) {
|
|
|
|
processEvents(false);
|
|
|
|
_system->delayMillis(10);
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
2011-06-11 12:52:05 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
doShake();
|
|
|
|
doFade();
|
2011-06-11 15:22:21 +00:00
|
|
|
_system->updateScreen();
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
|
|
|
|
2011-06-12 14:58:00 +00:00
|
|
|
void DreamWebEngine::quit() {
|
2011-12-28 13:07:17 +00:00
|
|
|
_quitRequested = true;
|
2012-11-29 01:39:08 +00:00
|
|
|
_lastHardKey = Common::KEYCODE_ESCAPE;
|
2011-06-12 14:58:00 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 22:35:57 +00:00
|
|
|
void DreamWebEngine::processEvents(bool processSoundEvents) {
|
2011-12-09 14:27:33 +00:00
|
|
|
if (_eventMan->shouldQuit()) {
|
2011-06-12 14:58:00 +00:00
|
|
|
quit();
|
|
|
|
return;
|
2011-06-11 14:55:57 +00:00
|
|
|
}
|
2011-06-18 10:29:10 +00:00
|
|
|
|
2020-01-22 22:35:57 +00:00
|
|
|
if (processSoundEvents)
|
|
|
|
_sound->soundHandler();
|
|
|
|
|
2011-06-12 14:58:00 +00:00
|
|
|
Common::Event event;
|
2012-11-29 01:39:08 +00:00
|
|
|
int softKey;
|
2011-12-09 14:27:33 +00:00
|
|
|
while (_eventMan->pollEvent(event)) {
|
2011-06-08 07:14:12 +00:00
|
|
|
switch(event.type) {
|
2011-06-18 09:33:24 +00:00
|
|
|
case Common::EVENT_RTL:
|
|
|
|
quit();
|
|
|
|
break;
|
2011-06-08 07:14:12 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2011-06-14 08:07:59 +00:00
|
|
|
if (event.kbd.flags & Common::KBD_CTRL) {
|
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
|
|
|
|
case Common::KEYCODE_f:
|
|
|
|
setSpeed(_speed != 20? 20: 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::KEYCODE_g:
|
|
|
|
_turbo = !_turbo;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::KEYCODE_c: //skip statue puzzle
|
2011-12-28 13:07:17 +00:00
|
|
|
_symbolBotNum = 3;
|
|
|
|
_symbolTopNum = 5;
|
2011-06-14 08:07:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2011-06-13 19:33:31 +00:00
|
|
|
}
|
2011-06-12 20:24:52 +00:00
|
|
|
|
2011-06-14 08:07:59 +00:00
|
|
|
return; //do not pass ctrl + key to the engine
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
2011-06-12 20:24:52 +00:00
|
|
|
|
2012-11-29 01:39:08 +00:00
|
|
|
// Some parts of the code uses the hardware key
|
|
|
|
// code directly.
|
2011-06-14 20:23:37 +00:00
|
|
|
|
|
|
|
switch (event.kbd.keycode) {
|
2011-06-14 19:52:17 +00:00
|
|
|
case Common::KEYCODE_ESCAPE:
|
2012-11-29 01:39:08 +00:00
|
|
|
_lastHardKey = Common::KEYCODE_ESCAPE;
|
2011-06-14 19:52:17 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_SPACE:
|
2012-11-29 01:39:08 +00:00
|
|
|
_lastHardKey = Common::KEYCODE_SPACE;
|
2011-06-14 19:52:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-11-29 01:39:08 +00:00
|
|
|
_lastHardKey = Common::KEYCODE_INVALID;
|
2011-06-14 19:52:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-06-14 19:53:48 +00:00
|
|
|
|
2011-06-14 20:23:37 +00:00
|
|
|
// The rest of the keys are converted to ASCII. This
|
|
|
|
// is fairly restrictive, and eventually we may want
|
|
|
|
// to let through more keys. I think this is mostly to
|
|
|
|
// keep weird glyphs out of savegame names.
|
|
|
|
|
|
|
|
softKey = 0;
|
2011-06-14 19:53:48 +00:00
|
|
|
|
2012-11-29 04:07:05 +00:00
|
|
|
debug(1, "DreamWebEngine::processEvents() KeyDown keycode:%d ascii:0x%02x", event.kbd.keycode, event.kbd.ascii);
|
2012-12-02 14:41:03 +00:00
|
|
|
if ((event.kbd.ascii >= 'a' && event.kbd.ascii <= 'z') ||
|
|
|
|
(event.kbd.ascii >= 'A' && event.kbd.ascii <= 'Z')) {
|
2012-11-29 04:07:05 +00:00
|
|
|
softKey = event.kbd.ascii & ~0x20; // (& ~0x20) forces ascii codes for a-z to map to A-Z
|
2012-12-02 14:41:03 +00:00
|
|
|
} else if (event.kbd.ascii == '-' ||
|
|
|
|
event.kbd.ascii == ' ' ||
|
|
|
|
(event.kbd.ascii >= '0' && event.kbd.ascii <= '9')) {
|
2011-06-14 20:23:37 +00:00
|
|
|
softKey = event.kbd.ascii;
|
2011-06-14 19:53:48 +00:00
|
|
|
} else if (event.kbd.keycode >= Common::KEYCODE_KP0 && event.kbd.keycode <= Common::KEYCODE_KP9) {
|
2011-06-14 20:23:37 +00:00
|
|
|
softKey = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
|
2011-06-14 19:53:48 +00:00
|
|
|
} else if (event.kbd.keycode == Common::KEYCODE_KP_MINUS) {
|
2011-06-14 20:23:37 +00:00
|
|
|
softKey = '-';
|
2011-06-14 19:53:48 +00:00
|
|
|
} else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE ||
|
|
|
|
event.kbd.keycode == Common::KEYCODE_DELETE) {
|
2011-06-14 20:23:37 +00:00
|
|
|
softKey = 8;
|
2011-06-14 19:53:48 +00:00
|
|
|
} else if (event.kbd.keycode == Common::KEYCODE_RETURN
|
|
|
|
|| event.kbd.keycode == Common::KEYCODE_KP_ENTER) {
|
2011-06-14 20:23:37 +00:00
|
|
|
softKey = 13;
|
2011-06-14 19:53:48 +00:00
|
|
|
}
|
|
|
|
|
2011-06-14 20:23:37 +00:00
|
|
|
if (softKey)
|
|
|
|
keyPressed(softKey);
|
2011-06-08 07:14:12 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-06-08 07:26:46 +00:00
|
|
|
break;
|
2011-06-05 09:38:05 +00:00
|
|
|
}
|
2011-06-08 07:14:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error DreamWebEngine::run() {
|
2011-06-25 14:27:59 +00:00
|
|
|
syncSoundSettings();
|
2020-02-09 05:19:26 +00:00
|
|
|
setDebugger(new DreamWebConsole(this));
|
2012-05-31 04:16:10 +00:00
|
|
|
_sound = new DreamWebSound(this);
|
2011-06-05 09:38:05 +00:00
|
|
|
|
2012-05-08 15:48:01 +00:00
|
|
|
_hasSpeech = Common::File::exists(_speechDirName + "/r01c0000.raw") && !ConfMan.getBool("speech_mute");
|
2012-03-03 23:11:50 +00:00
|
|
|
_brightPalette = ConfMan.getBool("bright_palette");
|
2012-11-15 12:20:53 +00:00
|
|
|
_copyProtection = ConfMan.getBool("copy_protection");
|
2011-06-25 18:05:05 +00:00
|
|
|
|
2011-12-28 13:07:17 +00:00
|
|
|
dreamweb();
|
2011-12-29 02:58:19 +00:00
|
|
|
dreamwebFinalize();
|
2011-12-28 13:07:17 +00:00
|
|
|
_quitRequested = false;
|
2011-06-19 22:59:48 +00:00
|
|
|
|
2011-06-05 09:38:05 +00:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2011-06-13 07:35:58 +00:00
|
|
|
void DreamWebEngine::setSpeed(uint speed) {
|
|
|
|
debug(0, "setting speed %u", speed);
|
|
|
|
_speed = speed;
|
|
|
|
}
|
|
|
|
|
2011-12-09 14:38:49 +00:00
|
|
|
Common::String DreamWebEngine::getSavegameFilename(int slot) const {
|
|
|
|
// TODO: Are saves from all versions of Dreamweb compatible with each other?
|
|
|
|
// Then we can can consider keeping the filenames as DREAMWEB.Dnn.
|
|
|
|
// Otherwise, this must be changed to be target dependent.
|
|
|
|
//Common::String filename = _targetName + Common::String::format(".d%02d", savegameId);
|
|
|
|
Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2011-06-10 07:30:11 +00:00
|
|
|
void DreamWebEngine::keyPressed(uint16 ascii) {
|
2011-06-13 11:50:16 +00:00
|
|
|
debug(2, "key pressed = %04x", ascii);
|
2012-11-29 03:00:17 +00:00
|
|
|
uint16 in = (_bufferIn + 1) % ARRAYSIZE(_keyBuffer);
|
2011-12-28 13:07:17 +00:00
|
|
|
uint16 out = _bufferOut;
|
2011-06-10 07:30:11 +00:00
|
|
|
if (in == out) {
|
|
|
|
warning("keyboard buffer is full");
|
|
|
|
return;
|
|
|
|
}
|
2011-12-28 13:07:17 +00:00
|
|
|
_bufferIn = in;
|
2012-11-29 03:00:17 +00:00
|
|
|
_keyBuffer[in] = ascii;
|
2011-06-10 07:30:11 +00:00
|
|
|
}
|
|
|
|
|
2011-06-11 13:20:00 +00:00
|
|
|
void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) {
|
|
|
|
_system->getPaletteManager()->grabPalette(data, start, count);
|
2011-12-08 09:02:51 +00:00
|
|
|
while (count--)
|
2011-06-11 13:20:00 +00:00
|
|
|
*data++ >>= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamWebEngine::setPalette(const uint8 *data, uint start, uint count) {
|
|
|
|
assert(start + count <= 256);
|
2012-11-30 10:49:25 +00:00
|
|
|
uint8 fixed[3*256];
|
2011-12-08 09:02:51 +00:00
|
|
|
for (uint i = 0; i < count * 3; ++i) {
|
2011-06-11 13:20:00 +00:00
|
|
|
fixed[i] = data[i] << 2;
|
|
|
|
}
|
|
|
|
_system->getPaletteManager()->setPalette(fixed, start, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamWebEngine::blit(const uint8 *src, int pitch, int x, int y, int w, int h) {
|
2012-11-30 10:49:25 +00:00
|
|
|
if (y + h > (int)kScreenheight)
|
|
|
|
h = kScreenheight - y;
|
|
|
|
if (x + w > (int)kScreenwidth)
|
|
|
|
w = kScreenwidth - x;
|
2011-06-11 20:55:23 +00:00
|
|
|
if (h <= 0 || w <= 0)
|
|
|
|
return;
|
2011-06-11 12:08:30 +00:00
|
|
|
_system->copyRectToScreen(src, pitch, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2011-06-12 19:50:19 +00:00
|
|
|
void DreamWebEngine::printUnderMonitor() {
|
2011-12-28 13:12:30 +00:00
|
|
|
uint8 *dst = workspace() + kScreenwidth * 43 + 76;
|
2011-06-12 19:50:19 +00:00
|
|
|
|
|
|
|
Graphics::Surface *s = _system->lockScreen();
|
|
|
|
if (!s)
|
|
|
|
error("lockScreen failed");
|
|
|
|
|
2011-12-08 09:02:51 +00:00
|
|
|
for (uint y = 0; y < 104; ++y) {
|
2011-06-13 08:22:48 +00:00
|
|
|
uint8 *src = (uint8 *)s->getBasePtr(76, 43 + 8 + y);
|
2011-12-08 09:02:51 +00:00
|
|
|
for (uint x = 0; x < 170; ++x) {
|
2011-06-12 19:50:19 +00:00
|
|
|
if (*src < 231)
|
|
|
|
*dst++ = *src++;
|
2011-06-13 08:22:48 +00:00
|
|
|
else {
|
|
|
|
++dst; ++src;
|
|
|
|
}
|
2011-06-12 19:50:19 +00:00
|
|
|
}
|
2011-12-28 13:12:30 +00:00
|
|
|
dst += kScreenwidth - 170;
|
2011-06-12 19:50:19 +00:00
|
|
|
}
|
|
|
|
_system->unlockScreen();
|
|
|
|
}
|
|
|
|
|
2011-06-11 12:08:30 +00:00
|
|
|
void DreamWebEngine::cls() {
|
|
|
|
_system->fillScreen(0);
|
|
|
|
}
|
|
|
|
|
2011-06-25 13:28:51 +00:00
|
|
|
uint8 DreamWebEngine::modifyChar(uint8 c) const {
|
2020-01-28 23:50:19 +00:00
|
|
|
switch (getLanguage()) {
|
2011-06-25 14:20:19 +00:00
|
|
|
case Common::DE_DEU:
|
2020-01-28 23:50:19 +00:00
|
|
|
switch (c) {
|
2011-06-25 14:20:19 +00:00
|
|
|
case 129:
|
|
|
|
return 'Z' + 3;
|
|
|
|
case 132:
|
|
|
|
return 'Z' + 1;
|
|
|
|
case 142:
|
|
|
|
return 'Z' + 4;
|
|
|
|
case 154:
|
|
|
|
return 'Z' + 6;
|
2011-07-07 09:34:10 +00:00
|
|
|
case 225:
|
2011-06-25 14:20:19 +00:00
|
|
|
return 'A' - 1;
|
|
|
|
case 153:
|
|
|
|
return 'Z' + 5;
|
|
|
|
case 148:
|
|
|
|
return 'Z' + 2;
|
|
|
|
default:
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
case Common::ES_ESP:
|
|
|
|
switch(c) {
|
|
|
|
case 160:
|
|
|
|
return 'Z' + 1;
|
|
|
|
case 130:
|
|
|
|
return 'Z' + 2;
|
|
|
|
case 161:
|
|
|
|
return 'Z' + 3;
|
|
|
|
case 162:
|
|
|
|
return 'Z' + 4;
|
|
|
|
case 163:
|
|
|
|
return 'Z' + 5;
|
|
|
|
case 164:
|
|
|
|
return 'Z' + 6;
|
|
|
|
case 165:
|
|
|
|
return ',' - 1;
|
|
|
|
case 168:
|
|
|
|
return 'A' - 1;
|
|
|
|
case 173:
|
|
|
|
return 'A' - 4;
|
|
|
|
case 129:
|
|
|
|
return 'A' - 5;
|
|
|
|
default:
|
|
|
|
return c;
|
|
|
|
}
|
2012-04-09 18:41:13 +00:00
|
|
|
case Common::FR_FRA:
|
2012-05-04 21:33:44 +00:00
|
|
|
case Common::IT_ITA:
|
2012-04-09 18:41:13 +00:00
|
|
|
switch(c) {
|
|
|
|
case 133:
|
2012-09-26 02:17:31 +00:00
|
|
|
return 'Z' + 1;
|
2012-04-09 18:41:13 +00:00
|
|
|
case 130:
|
|
|
|
return 'Z' + 2;
|
|
|
|
case 138:
|
|
|
|
return 'Z' + 3;
|
|
|
|
case 136:
|
|
|
|
return 'Z' + 4;
|
|
|
|
case 140:
|
|
|
|
return 'Z' + 5;
|
|
|
|
case 135:
|
|
|
|
return 'Z' + 6;
|
|
|
|
case 149:
|
|
|
|
return ',' - 1;
|
|
|
|
case 131:
|
|
|
|
return ',' - 2;
|
|
|
|
case 141:
|
|
|
|
return ',' - 3;
|
|
|
|
case 139:
|
|
|
|
return ',' - 4;
|
|
|
|
case 151:
|
|
|
|
return 'A' - 1;
|
|
|
|
case 147:
|
|
|
|
return 'A' - 3;
|
|
|
|
case 150:
|
|
|
|
return 'A' - 4;
|
|
|
|
default:
|
|
|
|
return c;
|
|
|
|
}
|
2020-01-28 23:50:19 +00:00
|
|
|
case Common::RU_RUS:
|
|
|
|
if (c >= 224)
|
|
|
|
c -= 48;
|
|
|
|
// fall through
|
2011-06-25 14:20:19 +00:00
|
|
|
default:
|
|
|
|
return c;
|
|
|
|
}
|
2011-06-25 13:28:51 +00:00
|
|
|
}
|
2012-09-26 02:17:31 +00:00
|
|
|
|
2012-04-16 20:26:55 +00:00
|
|
|
Common::String DreamWebEngine::modifyFileName(const char *name) {
|
2012-04-09 18:38:25 +00:00
|
|
|
Common::String fileName(name);
|
2012-09-26 02:17:31 +00:00
|
|
|
|
2012-04-09 18:38:25 +00:00
|
|
|
// Sanity check
|
2012-04-16 22:21:30 +00:00
|
|
|
if (!fileName.hasPrefix("DREAMWEB."))
|
2012-04-09 18:38:25 +00:00
|
|
|
return fileName;
|
|
|
|
|
2012-04-16 22:21:30 +00:00
|
|
|
// Make sure we use the correct file name as it differs depending on the game variant
|
|
|
|
fileName = _datafilePrefix;
|
|
|
|
fileName += name + 9;
|
2012-04-09 18:38:25 +00:00
|
|
|
return fileName;
|
|
|
|
}
|
2011-06-13 13:33:44 +00:00
|
|
|
|
2011-12-28 16:53:45 +00:00
|
|
|
bool DreamWebEngine::hasSpeech() {
|
|
|
|
return isCD() && _hasSpeech;
|
|
|
|
}
|
2012-02-22 17:21:57 +00:00
|
|
|
|
2011-06-05 09:38:05 +00:00
|
|
|
} // End of namespace DreamWeb
|