2013-07-03 17:50:40 -05: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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
* 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/scummsys.h"
|
|
|
|
|
2013-10-01 20:08:41 -05:00
|
|
|
#include "zvision/zvision.h"
|
2014-06-14 15:18:24 +07:00
|
|
|
#include "zvision/core/console.h"
|
|
|
|
#include "zvision/scripting/script_manager.h"
|
|
|
|
#include "zvision/graphics/render_manager.h"
|
|
|
|
#include "zvision/cursors/cursor_manager.h"
|
|
|
|
#include "zvision/core/save_manager.h"
|
2014-07-02 19:50:55 +00:00
|
|
|
#include "zvision/text/string_manager.h"
|
2013-10-01 20:08:41 -05:00
|
|
|
#include "zvision/detection.h"
|
2014-06-14 15:18:24 +07:00
|
|
|
#include "zvision/core/menu.h"
|
2014-07-02 19:50:55 +00:00
|
|
|
#include "zvision/core/search_manager.h"
|
|
|
|
#include "zvision/text/text.h"
|
2014-12-03 02:29:08 +02:00
|
|
|
#include "zvision/graphics/truetype_font.h"
|
2014-10-22 11:44:49 +07:00
|
|
|
#include "zvision/core/midi.h"
|
2014-12-03 02:16:14 +02:00
|
|
|
#include "zvision/utility/zfs_archive.h"
|
2013-10-01 20:08:41 -05:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
#include "common/config-manager.h"
|
2014-02-04 08:32:02 +07:00
|
|
|
#include "common/str.h"
|
2013-07-03 17:50:40 -05:00
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
2013-07-06 01:52:45 -05:00
|
|
|
#include "common/textconsole.h"
|
2013-07-03 17:50:40 -05:00
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
|
|
|
|
#include "engines/util.h"
|
2013-08-04 23:10:27 -05:00
|
|
|
|
|
|
|
#include "audio/mixer.h"
|
2013-07-03 17:50:40 -05:00
|
|
|
|
|
|
|
namespace ZVision {
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2014-11-04 10:12:13 +06:00
|
|
|
#define ZVISION_SETTINGS_KEYS_COUNT 17
|
|
|
|
|
|
|
|
struct zvisionIniSettings {
|
|
|
|
const char *name;
|
|
|
|
int16 slot;
|
|
|
|
int16 deflt;
|
|
|
|
} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = {
|
|
|
|
{"ZVision_KeyboardTurnSpeed", StateKey_KbdRotateSpeed, 5},
|
|
|
|
{"ZVision_PanaRotateSpeed", StateKey_RotateSpeed, 540},
|
|
|
|
{"ZVision_QSoundEnabled", StateKey_Qsound, 1},
|
|
|
|
{"ZVision_VenusEnabled", StateKey_VenusEnable, 1},
|
|
|
|
{"ZVision_HighQuality", StateKey_HighQuality, 1},
|
|
|
|
{"ZVision_Platform", StateKey_Platform, 0},
|
|
|
|
{"ZVision_InstallLevel", StateKey_InstallLevel, 0},
|
|
|
|
{"ZVision_CountryCode", StateKey_CountryCode, 0},
|
|
|
|
{"ZVision_CPU", StateKey_CPU, 1},
|
|
|
|
{"ZVision_MovieCursor", StateKey_MovieCursor, 1},
|
|
|
|
{"ZVision_NoAnimWhileTurning", StateKey_NoTurnAnim, 0},
|
|
|
|
{"ZVision_Win958", StateKey_WIN958, 0},
|
|
|
|
{"ZVision_ShowErrorDialogs", StateKey_ShowErrorDlg, 0},
|
|
|
|
{"ZVision_ShowSubtitles", StateKey_Subtitles, 1},
|
|
|
|
{"ZVision_DebugCheats", StateKey_DebugCheats, 0},
|
|
|
|
{"ZVision_JapaneseFonts", StateKey_JapanFonts, 0},
|
|
|
|
{"ZVision_Brightness", StateKey_Brightness, 0}
|
|
|
|
};
|
|
|
|
|
2013-07-08 16:04:18 -05:00
|
|
|
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
|
2013-10-20 18:39:06 +00:00
|
|
|
: Engine(syst),
|
|
|
|
_gameDescription(gameDesc),
|
|
|
|
_workingWindow_ZGI((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT),
|
|
|
|
_workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT),
|
|
|
|
_workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI),
|
|
|
|
_pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/
|
|
|
|
_desiredFrameTime(33), /* ~30 fps */
|
|
|
|
_clock(_system),
|
|
|
|
_scriptManager(nullptr),
|
|
|
|
_renderManager(nullptr),
|
|
|
|
_saveManager(nullptr),
|
|
|
|
_stringManager(nullptr),
|
2013-11-01 16:44:44 +07:00
|
|
|
_cursorManager(nullptr),
|
2014-10-22 11:44:49 +07:00
|
|
|
_midiManager(nullptr),
|
2014-11-20 14:48:24 +06:00
|
|
|
_audioId(0),
|
2014-01-07 18:39:16 +07:00
|
|
|
_rendDelay(2),
|
2014-11-12 15:55:10 +06:00
|
|
|
_kbdVelocity(0),
|
|
|
|
_mouseVelocity(0) {
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-09-29 21:57:35 -05:00
|
|
|
debug(1, "ZVision::ZVision");
|
2014-11-12 15:47:27 +06:00
|
|
|
|
|
|
|
memset(_cheatBuff, 0, sizeof(_cheatBuff));
|
2013-07-03 17:50:40 -05:00
|
|
|
}
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
ZVision::~ZVision() {
|
2013-09-29 21:57:35 -05:00
|
|
|
debug(1, "ZVision::~ZVision");
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
// Dispose of resources
|
2013-07-06 01:52:45 -05:00
|
|
|
delete _console;
|
2013-08-09 18:33:15 -05:00
|
|
|
delete _cursorManager;
|
2013-09-15 16:27:19 -05:00
|
|
|
delete _stringManager;
|
|
|
|
delete _saveManager;
|
2013-08-04 23:10:27 -05:00
|
|
|
delete _renderManager;
|
2013-07-03 17:50:40 -05:00
|
|
|
delete _scriptManager;
|
|
|
|
delete _rnd;
|
2014-10-22 11:44:49 +07:00
|
|
|
delete _midiManager;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
// Remove all of our debug levels
|
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
}
|
|
|
|
|
2014-11-04 10:12:13 +06:00
|
|
|
void ZVision::registerDefaultSettings() {
|
|
|
|
for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
|
|
|
|
ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].deflt);
|
|
|
|
ConfMan.registerDefault("doublefps", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZVision::loadSettings() {
|
|
|
|
for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
|
|
|
|
_scriptManager->setStateValue(settingsKeys[i].slot, ConfMan.getInt(settingsKeys[i].name));
|
|
|
|
|
|
|
|
if (getGameId() == GID_NEMESIS)
|
|
|
|
_scriptManager->setStateValue(StateKey_ExecScopeStyle, 1);
|
|
|
|
else
|
|
|
|
_scriptManager->setStateValue(StateKey_ExecScopeStyle, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZVision::saveSettings() {
|
|
|
|
for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++)
|
|
|
|
ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot));
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
}
|
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
void ZVision::initialize() {
|
2013-08-11 15:08:22 -05:00
|
|
|
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
2014-02-04 08:32:02 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
_searchManager = new SearchManager(ConfMan.get("path"), 6);
|
2014-02-04 08:32:02 +07:00
|
|
|
|
2014-02-24 22:31:06 +07:00
|
|
|
_searchManager->addDir("FONTS");
|
2014-02-04 08:32:02 +07:00
|
|
|
_searchManager->addDir("addon");
|
|
|
|
|
|
|
|
if (_gameDescription->gameId == GID_GRANDINQUISITOR) {
|
|
|
|
_searchManager->loadZix("INQUIS.ZIX");
|
|
|
|
_searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC");
|
|
|
|
_searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC");
|
|
|
|
_searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC");
|
|
|
|
_searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC");
|
|
|
|
_searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC");
|
|
|
|
_searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC");
|
|
|
|
_searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC");
|
|
|
|
_searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC");
|
|
|
|
} else if (_gameDescription->gameId == GID_NEMESIS)
|
|
|
|
_searchManager->loadZix("NEMESIS.ZIX");
|
2013-07-03 17:50:40 -05:00
|
|
|
|
2013-08-14 10:25:50 -05:00
|
|
|
initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat);
|
2013-07-03 17:50:40 -05:00
|
|
|
|
2013-09-29 21:45:57 -05:00
|
|
|
// Register random source
|
|
|
|
_rnd = new Common::RandomSource("zvision");
|
|
|
|
|
|
|
|
// Create managers
|
|
|
|
_scriptManager = new ScriptManager(this);
|
2014-02-04 08:32:02 +07:00
|
|
|
_renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat);
|
2013-09-29 21:45:57 -05:00
|
|
|
_saveManager = new SaveManager(this);
|
|
|
|
_stringManager = new StringManager(this);
|
2013-08-16 12:17:29 -05:00
|
|
|
_cursorManager = new CursorManager(this, &_pixelFormat);
|
2014-11-20 14:48:24 +06:00
|
|
|
_textRenderer = new TextRenderer(this);
|
|
|
|
_midiManager = new MidiManager();
|
2013-09-29 21:45:57 -05:00
|
|
|
|
2014-01-12 19:27:11 +07:00
|
|
|
if (_gameDescription->gameId == GID_GRANDINQUISITOR)
|
2014-11-20 14:48:24 +06:00
|
|
|
_menu = new MenuZGI(this);
|
2014-01-12 19:27:11 +07:00
|
|
|
else
|
2014-11-20 14:48:24 +06:00
|
|
|
_menu = new MenuNemesis(this);
|
2014-01-12 19:27:11 +07:00
|
|
|
|
2013-09-29 21:45:57 -05:00
|
|
|
// Initialize the managers
|
2013-08-09 18:33:15 -05:00
|
|
|
_cursorManager->initialize();
|
2013-08-14 10:46:12 -05:00
|
|
|
_scriptManager->initialize();
|
2013-09-16 00:15:10 -05:00
|
|
|
_stringManager->initialize(_gameDescription->gameId);
|
2013-07-03 17:50:40 -05:00
|
|
|
|
2014-11-04 10:12:13 +06:00
|
|
|
registerDefaultSettings();
|
|
|
|
|
|
|
|
loadSettings();
|
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
// Create debugger console. It requires GFX to be initialized
|
|
|
|
_console = new Console(this);
|
2014-10-23 17:13:56 +07:00
|
|
|
_halveDelay = ConfMan.getBool("doublefps");
|
2013-07-03 17:50:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error ZVision::run() {
|
|
|
|
initialize();
|
|
|
|
|
|
|
|
// Main loop
|
|
|
|
while (!shouldQuit()) {
|
2013-08-04 23:54:53 -05:00
|
|
|
_clock.update();
|
|
|
|
uint32 currentTime = _clock.getLastMeasuredTime();
|
2013-08-14 10:46:12 -05:00
|
|
|
uint32 deltaTime = _clock.getDeltaTime();
|
|
|
|
|
2013-12-04 14:00:48 +00:00
|
|
|
_cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem));
|
|
|
|
|
2013-08-04 23:10:27 -05:00
|
|
|
processEvents();
|
2014-01-07 18:39:16 +07:00
|
|
|
updateRotation();
|
2013-07-08 16:08:16 -05:00
|
|
|
|
2013-10-20 18:39:06 +00:00
|
|
|
// Call _renderManager->update() first so the background renders
|
2013-08-19 23:55:36 -05:00
|
|
|
// before anything that puzzles/controls will render
|
|
|
|
_scriptManager->update(deltaTime);
|
2014-01-12 19:27:11 +07:00
|
|
|
_menu->process(deltaTime);
|
2013-07-24 11:33:58 -05:00
|
|
|
|
2013-09-06 22:29:19 -05:00
|
|
|
// Render the backBuffer to the screen
|
2014-01-07 18:39:16 +07:00
|
|
|
_renderManager->prepareBkg();
|
|
|
|
_renderManager->renderMenuToScreen();
|
2014-02-24 22:46:00 +07:00
|
|
|
_renderManager->processSubs(deltaTime);
|
2013-09-06 22:29:19 -05:00
|
|
|
_renderManager->renderBackbufferToScreen();
|
|
|
|
|
2013-08-09 12:16:43 -05:00
|
|
|
// Update the screen
|
2013-12-24 14:38:11 +07:00
|
|
|
if (_rendDelay <= 0)
|
|
|
|
_system->updateScreen();
|
|
|
|
else
|
|
|
|
_rendDelay--;
|
2013-08-09 12:16:43 -05:00
|
|
|
|
2013-07-24 11:33:58 -05:00
|
|
|
// Calculate the frame delay based off a desired frame time
|
2013-08-05 19:07:55 -05:00
|
|
|
int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
|
2013-07-03 17:50:40 -05:00
|
|
|
// Ensure non-negative
|
|
|
|
delay = delay < 0 ? 0 : delay;
|
2014-10-23 17:13:56 +07:00
|
|
|
if (_halveDelay)
|
|
|
|
delay >>= 1;
|
2013-07-03 17:50:40 -05:00
|
|
|
_system->delayMillis(delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2014-07-12 19:09:08 +00:00
|
|
|
bool ZVision::askQuestion(const Common::String &str) {
|
|
|
|
uint16 msgid = _renderManager->createSubArea();
|
|
|
|
_renderManager->updateSubArea(msgid, str);
|
|
|
|
_renderManager->processSubs(0);
|
|
|
|
_renderManager->renderBackbufferToScreen();
|
|
|
|
_clock.stop();
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
while (result == 0) {
|
|
|
|
Common::Event evnt;
|
|
|
|
while (_eventMan->pollEvent(evnt)) {
|
|
|
|
if (evnt.type == Common::EVENT_KEYDOWN) {
|
|
|
|
switch (evnt.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_y:
|
|
|
|
result = 2;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_n:
|
|
|
|
result = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_system->updateScreen();
|
2014-11-12 16:02:35 +06:00
|
|
|
if (_halveDelay)
|
|
|
|
_system->delayMillis(33);
|
|
|
|
else
|
|
|
|
_system->delayMillis(66);
|
2014-07-12 19:09:08 +00:00
|
|
|
}
|
|
|
|
_renderManager->deleteSubArea(msgid);
|
|
|
|
_clock.start();
|
|
|
|
return result == 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) {
|
|
|
|
uint16 msgid = _renderManager->createSubArea();
|
|
|
|
_renderManager->updateSubArea(msgid, str);
|
|
|
|
_renderManager->processSubs(0);
|
|
|
|
_renderManager->renderBackbufferToScreen();
|
|
|
|
_clock.stop();
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
uint32 stopTime = _system->getMillis() + milsecs;
|
|
|
|
while (_system->getMillis() < stopTime) {
|
2014-07-12 19:09:08 +00:00
|
|
|
Common::Event evnt;
|
|
|
|
while (_eventMan->pollEvent(evnt)) {
|
|
|
|
if (evnt.type == Common::EVENT_KEYDOWN &&
|
|
|
|
(evnt.kbd.keycode == Common::KEYCODE_SPACE ||
|
|
|
|
evnt.kbd.keycode == Common::KEYCODE_RETURN ||
|
|
|
|
evnt.kbd.keycode == Common::KEYCODE_ESCAPE))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_system->updateScreen();
|
2014-11-12 16:02:35 +06:00
|
|
|
if (_halveDelay)
|
|
|
|
_system->delayMillis(33);
|
|
|
|
else
|
|
|
|
_system->delayMillis(66);
|
2014-07-12 19:09:08 +00:00
|
|
|
}
|
|
|
|
_renderManager->deleteSubArea(msgid);
|
|
|
|
_clock.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZVision::timedMessage(const Common::String &str, uint16 milsecs) {
|
|
|
|
uint16 msgid = _renderManager->createSubArea();
|
|
|
|
_renderManager->updateSubArea(msgid, str);
|
|
|
|
_renderManager->processSubs(0);
|
|
|
|
_renderManager->renderBackbufferToScreen();
|
|
|
|
_renderManager->deleteSubArea(msgid, milsecs);
|
|
|
|
}
|
|
|
|
|
2013-08-04 23:55:36 -05:00
|
|
|
void ZVision::pauseEngineIntern(bool pause) {
|
|
|
|
_mixer->pauseAll(pause);
|
|
|
|
|
|
|
|
if (pause) {
|
|
|
|
_clock.stop();
|
|
|
|
} else {
|
|
|
|
_clock.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 00:12:41 -05:00
|
|
|
Common::String ZVision::generateSaveFileName(uint slot) {
|
|
|
|
return Common::String::format("%s.%02u", _targetName.c_str(), slot);
|
2013-07-03 17:50:40 -05:00
|
|
|
}
|
|
|
|
|
2013-09-04 00:12:41 -05:00
|
|
|
Common::String ZVision::generateAutoSaveFileName() {
|
|
|
|
return Common::String::format("%s.auto", _targetName.c_str());
|
2013-07-13 11:34:28 -05:00
|
|
|
}
|
|
|
|
|
2013-12-24 14:38:11 +07:00
|
|
|
void ZVision::setRenderDelay(uint delay) {
|
|
|
|
_rendDelay = delay;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ZVision::canRender() {
|
|
|
|
return _rendDelay <= 0;
|
|
|
|
}
|
|
|
|
|
2014-01-07 18:39:16 +07:00
|
|
|
void ZVision::updateRotation() {
|
2014-11-12 15:55:10 +06:00
|
|
|
int16 _velocity = _mouseVelocity + _kbdVelocity;
|
|
|
|
|
|
|
|
if (_halveDelay)
|
|
|
|
_velocity /= 2;
|
|
|
|
|
2014-01-07 18:39:16 +07:00
|
|
|
if (_velocity) {
|
|
|
|
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
|
|
|
|
if (renderState == RenderTable::PANORAMA) {
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 newPosition = startPosition + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity);
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 zeroPoint = _renderManager->getRenderTable()->getPanoramaZeroPoint();
|
|
|
|
if (startPosition >= zeroPoint && newPosition < zeroPoint)
|
2014-01-07 18:39:16 +07:00
|
|
|
_scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1);
|
2014-11-20 14:48:24 +06:00
|
|
|
if (startPosition <= zeroPoint && newPosition > zeroPoint)
|
2014-01-07 18:39:16 +07:00
|
|
|
_scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1);
|
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 screenWidth = _renderManager->getBkgSize().x;
|
|
|
|
if (screenWidth)
|
|
|
|
newPosition %= screenWidth;
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (newPosition < 0)
|
|
|
|
newPosition += screenWidth;
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
_renderManager->setBackgroundPosition(newPosition);
|
2014-01-07 18:39:16 +07:00
|
|
|
} else if (renderState == RenderTable::TILT) {
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 newPosition = startPosition + _velocity;
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 screenHeight = _renderManager->getBkgSize().y;
|
|
|
|
int16 tiltGap = _renderManager->getRenderTable()->getTiltGap();
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (newPosition >= (screenHeight - tiltGap))
|
|
|
|
newPosition = screenHeight - tiltGap;
|
|
|
|
if (newPosition <= tiltGap)
|
|
|
|
newPosition = tiltGap;
|
2014-01-07 18:39:16 +07:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
_renderManager->setBackgroundPosition(newPosition);
|
2014-01-07 18:39:16 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 15:58:35 +06:00
|
|
|
void ZVision::checkBorders() {
|
|
|
|
RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState();
|
|
|
|
if (renderState == RenderTable::PANORAMA) {
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 newPosition = startPosition;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 screenWidth = _renderManager->getBkgSize().x;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (screenWidth)
|
|
|
|
newPosition %= screenWidth;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (newPosition < 0)
|
|
|
|
newPosition += screenWidth;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (startPosition != newPosition)
|
|
|
|
_renderManager->setBackgroundPosition(newPosition);
|
2014-11-12 15:58:35 +06:00
|
|
|
} else if (renderState == RenderTable::TILT) {
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos);
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 newPosition = startPosition;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
int16 screenHeight = _renderManager->getBkgSize().y;
|
|
|
|
int16 tiltGap = _renderManager->getRenderTable()->getTiltGap();
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (newPosition >= (screenHeight - tiltGap))
|
|
|
|
newPosition = screenHeight - tiltGap;
|
|
|
|
if (newPosition <= tiltGap)
|
|
|
|
newPosition = tiltGap;
|
2014-11-12 15:58:35 +06:00
|
|
|
|
2014-11-20 14:48:24 +06:00
|
|
|
if (startPosition != newPosition)
|
|
|
|
_renderManager->setBackgroundPosition(newPosition);
|
2014-11-12 15:58:35 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-07 10:25:11 +06:00
|
|
|
void ZVision::rotateTo(int16 _toPos, int16 _time) {
|
|
|
|
if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_time == 0)
|
|
|
|
_time = 1;
|
|
|
|
|
|
|
|
int32 maxX = _renderManager->getBkgSize().x;
|
|
|
|
int32 curX = _renderManager->getCurrentBackgroundOffset();
|
|
|
|
int32 dx = 0;
|
|
|
|
|
|
|
|
if (curX == _toPos)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (curX > _toPos) {
|
|
|
|
if (curX - _toPos > maxX / 2)
|
|
|
|
dx = (_toPos + (maxX - curX)) / _time;
|
|
|
|
else
|
|
|
|
dx = -(curX - _toPos) / _time;
|
|
|
|
} else {
|
|
|
|
if (_toPos - curX > maxX / 2)
|
|
|
|
dx = -((maxX - _toPos) + curX) / _time;
|
|
|
|
else
|
|
|
|
dx = (_toPos - curX) / _time;
|
|
|
|
}
|
|
|
|
|
|
|
|
_clock.stop();
|
|
|
|
|
|
|
|
for (int16 i = 0; i <= _time; i++) {
|
|
|
|
if (i == _time)
|
|
|
|
curX = _toPos;
|
|
|
|
else
|
|
|
|
curX += dx;
|
|
|
|
|
|
|
|
if (curX < 0)
|
|
|
|
curX = maxX - curX;
|
|
|
|
else if (curX >= maxX)
|
|
|
|
curX %= maxX;
|
|
|
|
|
|
|
|
_renderManager->setBackgroundPosition(curX);
|
|
|
|
|
|
|
|
_renderManager->prepareBkg();
|
|
|
|
_renderManager->renderBackbufferToScreen();
|
|
|
|
|
|
|
|
_system->updateScreen();
|
|
|
|
|
|
|
|
_system->delayMillis(500 / _time);
|
|
|
|
}
|
|
|
|
|
|
|
|
_clock.start();
|
|
|
|
}
|
|
|
|
|
2014-11-08 13:02:48 +06:00
|
|
|
void ZVision::menuBarEnable(uint16 menus) {
|
|
|
|
if (_menu)
|
|
|
|
_menu->setEnable(menus);
|
|
|
|
}
|
|
|
|
|
2014-11-12 15:34:55 +06:00
|
|
|
uint16 ZVision::getMenuBarEnable() {
|
|
|
|
if (_menu)
|
|
|
|
return _menu->getEnable();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-12 14:47:12 +06:00
|
|
|
bool ZVision::ifQuit() {
|
|
|
|
if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) {
|
|
|
|
quitGame();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-12 15:47:27 +06:00
|
|
|
|
|
|
|
void ZVision::pushKeyToCheatBuf(uint8 key) {
|
|
|
|
for (int i = 0; i < KEYBUF_SIZE - 1; i++)
|
|
|
|
_cheatBuff[i] = _cheatBuff[i + 1];
|
|
|
|
|
|
|
|
_cheatBuff[KEYBUF_SIZE - 1] = key;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ZVision::checkCode(const char *code) {
|
|
|
|
int codeLen = strlen(code);
|
|
|
|
|
|
|
|
if (codeLen > KEYBUF_SIZE)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (int i = 0; i < codeLen; i++)
|
|
|
|
if (code[i] != _cheatBuff[KEYBUF_SIZE - codeLen + i] && code[i] != '?')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 ZVision::getBufferedKey(uint8 pos) {
|
|
|
|
if (pos >= KEYBUF_SIZE)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return _cheatBuff[KEYBUF_SIZE - pos - 1];
|
|
|
|
}
|
|
|
|
|
2014-11-12 15:40:54 +06:00
|
|
|
void ZVision::showDebugMsg(const Common::String &msg, int16 delay) {
|
|
|
|
uint16 msgid = _renderManager->createSubArea();
|
|
|
|
_renderManager->updateSubArea(msgid, msg);
|
|
|
|
_renderManager->deleteSubArea(msgid, delay);
|
|
|
|
}
|
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
} // End of namespace ZVision
|