From c82480461cacab7893053d8e4821b3a6987552c9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 01:36:20 +0200 Subject: ZVISION: Make sure only existing files are dumped --- engines/zvision/core/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 65821b1702..f39c06b57e 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -263,7 +263,8 @@ bool Console::cmdDumpFiles(int argc, const char **argv) { debugPrintf("Dumping %s\n", fileName.c_str()); in = iter->_value.arch->createReadStreamForMember(iter->_value.name); - dumpFile(in, fileName.c_str()); + if (in) + dumpFile(in, fileName.c_str()); delete in; } -- cgit v1.2.3 From 2d0075817ae6203063fb01f61b0828712e0259f0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 01:37:39 +0200 Subject: ZVISION: Remove unused variable --- engines/zvision/graphics/render_manager.h | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index c22f9a78c9..6081e982f9 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -106,7 +106,6 @@ private: // A buffer for subtitles Graphics::Surface _subtitleSurface; - Common::Rect _subtitleSurfaceDirtyRect; // Rectangle for subtitles area Common::Rect _subtitleArea; -- cgit v1.2.3 From 616b34e629686d7bfc3e5a74658c6a76b4a45c94 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 17:30:11 +0200 Subject: ZVISION: Change wording --- engines/zvision/scripting/script_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index ba38d3a0e4..8220d5c37c 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -500,7 +500,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi _nextLocation.node = _node; _nextLocation.view = _view; _nextLocation.offset = offset; - // If next location 0000 - it's indicate to go to previous location. + // If next location is 0000, return to the previous location. if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') { if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { _nextLocation.world = getStateValue(StateKey_LastWorld); -- cgit v1.2.3 From 899cf4813c7e009e1dbee56be8ad10d20650cf10 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 21:32:15 +0200 Subject: ZVISION: Change screen resolution for the hires DVD videos to 800x600 Also, this hooks up the MPEG-PS decoder, but only if libmpeg2 is compiled in. The DVD videos are still disabled until AC3 audio support is implemented. The hires DVD videos are encoded a 720x480 resolution, with double the frame rate of the lowres ones (29.97FPS up from 15FPS) --- engines/zvision/graphics/render_manager.cpp | 57 ++++++++++++++++++----------- engines/zvision/graphics/render_manager.h | 10 ++--- engines/zvision/scripting/actions.cpp | 50 ++++++++++++++++--------- engines/zvision/text/subtitles.cpp | 9 ++++- engines/zvision/text/subtitles.h | 2 +- engines/zvision/video/video.cpp | 8 +--- engines/zvision/zvision.cpp | 6 +++ engines/zvision/zvision.h | 40 +++++++++++--------- 8 files changed, 112 insertions(+), 70 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index a1cc8ac53c..4a43e09b07 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -42,28 +42,25 @@ namespace ZVision { RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat, bool doubleFPS) : _engine(engine), _system(engine->_system), - _workingWidth(workingWindow.width()), - _workingHeight(workingWindow.height()), - _screenCenterX(_workingWidth / 2), - _screenCenterY(_workingHeight / 2), + _screenCenterX(_workingWindow.width() / 2), + _screenCenterY(_workingWindow.height() / 2), _workingWindow(workingWindow), _pixelFormat(pixelFormat), _backgroundWidth(0), _backgroundHeight(0), _backgroundOffset(0), - _renderTable(_workingWidth, _workingHeight), - _doubleFPS(doubleFPS) { + _renderTable(_workingWindow.width(), _workingWindow.height()), + _doubleFPS(doubleFPS), + _subid(0) { - _backgroundSurface.create(_workingWidth, _workingHeight, _pixelFormat); - _effectSurface.create(_workingWidth, _workingHeight, _pixelFormat); - _warpedSceneSurface.create(_workingWidth, _workingHeight, _pixelFormat); + _backgroundSurface.create(_workingWindow.width(), _workingWindow.height(), _pixelFormat); + _effectSurface.create(_workingWindow.width(), _workingWindow.height(), _pixelFormat); + _warpedSceneSurface.create(_workingWindow.width(), _workingWindow.height(), _pixelFormat); _menuSurface.create(windowWidth, workingWindow.top, _pixelFormat); - _subtitleSurface.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); - + _menuArea = Common::Rect(0, 0, windowWidth, workingWindow.top); - _subtitleArea = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight); - _subid = 0; + initSubArea(windowWidth, windowHeight, workingWindow); } RenderManager::~RenderManager() { @@ -83,7 +80,7 @@ void RenderManager::renderSceneToScreen() { // If we have graphical effects, we apply them using a temporary buffer if (!_effects.empty()) { bool copied = false; - Common::Rect windowRect(_workingWidth, _workingHeight); + Common::Rect windowRect(_workingWindow.width(), _workingWindow.height()); for (EffectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { Common::Rect rect = (*it)->getRegion(); @@ -121,7 +118,7 @@ void RenderManager::renderSceneToScreen() { if (!_backgroundSurfaceDirtyRect.isEmpty()) { _renderTable.mutateImage(&_warpedSceneSurface, in); out = &_warpedSceneSurface; - outWndDirtyRect = Common::Rect(_workingWidth, _workingHeight); + outWndDirtyRect = Common::Rect(_workingWindow.width(), _workingWindow.height()); } } else { out = in; @@ -590,7 +587,7 @@ void RenderManager::prepareBackground() { if (state == RenderTable::PANORAMA) { // Calculate the visible portion of the background - Common::Rect viewPort(_workingWidth, _workingHeight); + Common::Rect viewPort(_workingWindow.width(), _workingWindow.height()); viewPort.translate(-(_screenCenterX - _backgroundOffset), 0); Common::Rect drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); @@ -635,7 +632,7 @@ void RenderManager::prepareBackground() { } } else if (state == RenderTable::TILT) { // Tilt doesn't allow wrapping, so we just do a simple clip - Common::Rect viewPort(_workingWidth, _workingHeight); + Common::Rect viewPort(_workingWindow.width(), _workingWindow.height()); viewPort.translate(0, -(_screenCenterY - _backgroundOffset)); Common::Rect drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); @@ -655,7 +652,7 @@ void RenderManager::prepareBackground() { // Clear the dirty rect since everything is clean now _backgroundDirtyRect = Common::Rect(); - _backgroundSurfaceDirtyRect.clip(_workingWidth, _workingHeight); + _backgroundSurfaceDirtyRect.clip(_workingWindow.width(), _workingWindow.height()); } void RenderManager::clearMenuSurface() { @@ -687,6 +684,15 @@ void RenderManager::renderMenuToScreen() { } } +void RenderManager::initSubArea(uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow) { + _workingWindow = workingWindow; + + _subtitleSurface.free(); + + _subtitleSurface.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); + _subtitleArea = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight); +} + uint16 RenderManager::createSubArea(const Common::Rect &area) { _subid++; @@ -791,8 +797,8 @@ Common::Rect RenderManager::transformBackgroundSpaceRectToScreenSpace(const Comm if (state == RenderTable::PANORAMA) { if (_backgroundOffset < _screenCenterX) { - Common::Rect rScreen(_screenCenterX + _backgroundOffset, _workingHeight); - Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight); + Common::Rect rScreen(_screenCenterX + _backgroundOffset, _workingWindow.height()); + Common::Rect lScreen(_workingWindow.width() - rScreen.width(), _workingWindow.height()); lScreen.translate(_backgroundWidth - lScreen.width(), 0); lScreen.clip(src); rScreen.clip(src); @@ -802,8 +808,8 @@ Common::Rect RenderManager::transformBackgroundSpaceRectToScreenSpace(const Comm tmp.translate(_screenCenterX - _backgroundOffset, 0); } } else if (_backgroundWidth - _backgroundOffset < _screenCenterX) { - Common::Rect rScreen(_screenCenterX - (_backgroundWidth - _backgroundOffset), _workingHeight); - Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight); + Common::Rect rScreen(_screenCenterX - (_backgroundWidth - _backgroundOffset), _workingWindow.height()); + Common::Rect lScreen(_workingWindow.width() - rScreen.width(), _workingWindow.height()); lScreen.translate(_backgroundWidth - lScreen.width(), 0); lScreen.clip(src); rScreen.clip(src); @@ -1172,4 +1178,11 @@ void RenderManager::rotateTo(int16 _toPos, int16 _time) { _engine->startClock(); } +void RenderManager::upscaleRect(Common::Rect &rect) { + rect.top = rect.top * HIRES_WINDOW_HEIGHT / WINDOW_HEIGHT; + rect.left = rect.left * HIRES_WINDOW_WIDTH / WINDOW_WIDTH; + rect.bottom = rect.bottom * HIRES_WINDOW_HEIGHT / WINDOW_HEIGHT; + rect.right = rect.right * HIRES_WINDOW_WIDTH / WINDOW_WIDTH; +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 6081e982f9..e3cbbc34ce 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -73,12 +73,8 @@ private: * are given in this coordinate space. Also, all images are clipped to the * edges of this Rectangle */ - const Common::Rect _workingWindow; + Common::Rect _workingWindow; - // Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() - const int _workingWidth; - // Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() - const int _workingHeight; // Center of the screen in the x direction const int _screenCenterX; // Center of the screen in the y direction @@ -241,6 +237,8 @@ public: // Subtitles methods + void initSubArea(uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow); + // Create subtitle area and return ID uint16 createSubArea(const Common::Rect &area); uint16 createSubArea(); @@ -334,6 +332,8 @@ public: void checkBorders(); void rotateTo(int16 to, int16 time); void updateRotation(); + + void upscaleRect(Common::Rect &rect); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index f60fdbb973..e3fc6fa549 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -912,7 +912,15 @@ ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Commo bool ActionStreamVideo::execute() { Video::VideoDecoder *decoder; Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1); + Common::String subname = _fileName; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + bool subtitleExists = _engine->getSearchManager()->hasFile(subname); + bool switchToHires = false; +// NOTE: We only show the hires MPEG2 videos when libmpeg2 is compiled in, +// otherwise we fall back to the lowres ones #ifdef USE_MPEG2 Common::String hiresFileName = _fileName; hiresFileName.setChar('d', hiresFileName.size() - 8); @@ -920,36 +928,44 @@ bool ActionStreamVideo::execute() { hiresFileName.setChar('o', hiresFileName.size() - 2); hiresFileName.setChar('b', hiresFileName.size() - 1); - if (_engine->getScriptManager()->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) - // TODO: Enable once VOB + AC3 support is implemented - //_fileName = hiresFileName; + if (_engine->getScriptManager()->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) { + // TODO: Enable once AC3 support is implemented + if (!_engine->getSearchManager()->hasFile(_fileName)) // Check for the regular video + return true; warning("The hires videos of the DVD version of ZGI aren't supported yet, using lowres"); -#endif - - Common::String subname = _fileName; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); - + //_fileName = hiresFileName; + //switchToHires = true; + } else if (!_engine->getSearchManager()->hasFile(_fileName)) + return true; +#else if (!_engine->getSearchManager()->hasFile(_fileName)) return true; +#endif decoder = _engine->loadAnimation(_fileName); + Subtitle *sub = (subtitleExists) ? new Subtitle(_engine, subname, switchToHires) : NULL; _engine->getCursorManager()->showMouse(false); - Subtitle *sub = NULL; - - if (_engine->getSearchManager()->hasFile(subname)) - sub = new Subtitle(_engine, subname); + if (switchToHires) { + _engine->initHiresScreen(); + destRect = Common::Rect(40, -40, 760, 440); + Common::Rect workingWindow = _engine->_workingWindow; + workingWindow.translate(0, -40); + _engine->getRenderManager()->initSubArea(HIRES_WINDOW_WIDTH, HIRES_WINDOW_HEIGHT, workingWindow); + } _engine->playVideo(*decoder, destRect, _skippable, sub); - delete decoder; + + if (switchToHires) { + _engine->initScreen(); + _engine->getRenderManager()->initSubArea(WINDOW_WIDTH, WINDOW_HEIGHT, _engine->_workingWindow); + } _engine->getCursorManager()->showMouse(true); - if (sub) - delete sub; + delete decoder; + delete sub; return true; } diff --git a/engines/zvision/text/subtitles.cpp b/engines/zvision/text/subtitles.cpp index acf4c37c2f..d549e2a0c6 100644 --- a/engines/zvision/text/subtitles.cpp +++ b/engines/zvision/text/subtitles.cpp @@ -27,7 +27,7 @@ namespace ZVision { -Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : +Subtitle::Subtitle(ZVision *engine, const Common::String &subname, bool upscaleToHires) : _engine(engine), _areaId(-1), _subId(-1) { @@ -44,6 +44,8 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : int32 x1, y1, x2, y2; sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); Common::Rect rct = Common::Rect(x1, y1, x2, y2); + if (upscaleToHires) + _engine->getRenderManager()->upscaleRect(rct); _areaId = _engine->getRenderManager()->createSubArea(rct); } else if (str.matchString("*TextFile*", true)) { char filename[64]; @@ -67,6 +69,11 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : int32 sb; if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { if (sb <= (int32)_subs.size()) { + if (upscaleToHires) { + // Convert from 15FPS (AVI) to 29.97FPS (VOB) + st = st * 29.97 / 15; + en = en * 29.97 / 15; + } _subs[sb].start = st; _subs[sb].stop = en; } diff --git a/engines/zvision/text/subtitles.h b/engines/zvision/text/subtitles.h index c3da6583a4..329339be55 100644 --- a/engines/zvision/text/subtitles.h +++ b/engines/zvision/text/subtitles.h @@ -31,7 +31,7 @@ class ZVision; class Subtitle { public: - Subtitle(ZVision *engine, const Common::String &subname); + Subtitle(ZVision *engine, const Common::String &subname, bool upscaleToHires = false); ~Subtitle(); void process(int32 time); diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 66a567abb2..d5ffbeb536 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -23,9 +23,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "video/video_decoder.h" -// TODO: Enable once VOB + AC3 support is implemented -#if 0 -//#ifdef USE_MPEG2 +#ifdef USE_MPEG2 #include "video/mpegps_decoder.h" #endif #include "engines/util.h" @@ -50,9 +48,7 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { animation = new RLFDecoder(); else if (tmpFileName.hasSuffix(".avi")) animation = new ZorkAVIDecoder(); -// TODO: Enable once VOB + AC3 support is implemented -#if 0 -//#ifdef USE_MPEG2 +#ifdef USE_MPEG2 else if (tmpFileName.hasSuffix(".vob")) animation = new Video::MPEGPSDecoder(); #endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 5b6d63e869..b42906fef3 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -360,4 +360,10 @@ void ZVision::initScreen() { initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); } +void ZVision::initHiresScreen() { + _renderManager->upscaleRect(_workingWindow); + + initGraphics(HIRES_WINDOW_WIDTH, HIRES_WINDOW_HEIGHT, true, &_screenPixelFormat); +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index a3bcb384d1..854cd77bb8 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -67,6 +67,27 @@ class TextRenderer; class Subtitle; class MidiManager; +enum { + WINDOW_WIDTH = 640, + WINDOW_HEIGHT = 480, + + HIRES_WINDOW_WIDTH = 800, + HIRES_WINDOW_HEIGHT = 600, + + // Zork nemesis working window sizes + ZNM_WORKING_WINDOW_WIDTH = 512, + ZNM_WORKING_WINDOW_HEIGHT = 320, + + // ZGI working window sizes + ZGI_WORKING_WINDOW_WIDTH = 640, + ZGI_WORKING_WINDOW_HEIGHT = 344, + + ROTATION_SCREEN_EDGE_OFFSET = 60, + MAX_ROTATION_SPEED = 400, // Pixels per second + + KEYBUF_SIZE = 20 +}; + class ZVision : public Engine { public: ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc); @@ -83,24 +104,6 @@ public: const Graphics::PixelFormat _screenPixelFormat; private: - enum { - WINDOW_WIDTH = 640, - WINDOW_HEIGHT = 480, - - // Zork nemesis working window sizes - ZNM_WORKING_WINDOW_WIDTH = 512, - ZNM_WORKING_WINDOW_HEIGHT = 320, - - // ZGI working window sizes - ZGI_WORKING_WINDOW_WIDTH = 640, - ZGI_WORKING_WINDOW_HEIGHT = 344, - - ROTATION_SCREEN_EDGE_OFFSET = 60, - MAX_ROTATION_SPEED = 400, // Pixels per second - - KEYBUF_SIZE = 20 - }; - Console *_console; const ZVisionGameDescription *_gameDescription; @@ -195,6 +198,7 @@ public: } void initScreen(); + void initHiresScreen(); /** * Play a video until it is finished. This is a blocking call. It will call -- cgit v1.2.3 From 21e9007d80ee60e519896c330324e5e3a95f772f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 10 Jan 2015 22:03:15 +0200 Subject: Revert "ZVISION: Remove ActionRestoreGame and loading of r.svr (restart slot)" This reverts commit 9f642074ba8e17aa23b01bcee82b2293fe84f8f1, as it broke the credits screen in ZGI. This has been rewritten to use the common save code --- engines/zvision/file/save_manager.cpp | 21 +++++++++++++++++---- engines/zvision/file/save_manager.h | 2 +- engines/zvision/scripting/actions.cpp | 19 ++++++++++++++++++- engines/zvision/scripting/actions.h | 9 +++++++++ engines/zvision/scripting/scr_file_handling.cpp | 4 ++-- engines/zvision/scripting/script_manager.cpp | 6 +----- engines/zvision/scripting/script_manager.h | 1 - 7 files changed, 48 insertions(+), 14 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index fb9cceecbe..5e96e4ab5e 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -130,12 +130,25 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S file->writeSint16LE(td.tm_min); } -Common::Error SaveManager::loadGame(uint slot) { - Common::SeekableReadStream *saveFile = getSlotFile(slot); - if (saveFile == 0) { - return Common::kPathDoesNotExist; +Common::Error SaveManager::loadGame(int slot) { + Common::SeekableReadStream *saveFile = NULL; + + if (slot >= 0) { + saveFile = getSlotFile(slot); + } else { + Common::File *saveFile = _engine->getSearchManager()->openFile("r.svr"); + if (!saveFile) { + saveFile = new Common::File; + if (!saveFile->open("r.svr")) { + delete saveFile; + return Common::kPathDoesNotExist; + } + } } + if (!saveFile) + return Common::kPathDoesNotExist; + // Read the header SaveGameHeader header; if (!readSaveGameHeader(saveFile, header)) { diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h index d3f6aaaedc..9e816373ea 100644 --- a/engines/zvision/file/save_manager.h +++ b/engines/zvision/file/save_manager.h @@ -91,7 +91,7 @@ public: * * @param slot The save slot to load. Must be [1, 20] */ - Common::Error loadGame(uint slot); + Common::Error loadGame(int slot); Common::SeekableReadStream *getSlotFile(uint slot); bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index e3fc6fa549..e989478dd1 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -23,11 +23,12 @@ #include "common/scummsys.h" #include "video/video_decoder.h" +#include "zvision/scripting/actions.h" + #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/file/save_manager.h" -#include "zvision/scripting/actions.h" #include "zvision/scripting/menu.h" #include "zvision/scripting/effects/timer_effect.h" #include "zvision/scripting/effects/music_effect.h" @@ -797,6 +798,22 @@ bool ActionRandom::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionRestoreGame +////////////////////////////////////////////////////////////////////////////// + +ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + char buf[128]; + sscanf(line.c_str(), "%s", buf); + _fileName = Common::String(buf); +} + +bool ActionRestoreGame::execute() { + _engine->getSaveManager()->loadGame(-1); + return false; +} + ////////////////////////////////////////////////////////////////////////////// // ActionRotateTo ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index c2350bc83a..8d43309b74 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -340,6 +340,15 @@ private: ValueSlot *_max; }; +class ActionRestoreGame : public ResultAction { +public: + ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + Common::String _fileName; +}; + class ActionRotateTo : public ResultAction { public: ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 7856bf7b2e..b4da61a119 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -271,8 +271,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis actionList.push_back(new ActionRegion(_engine, slot, args)); } else if (act.matchString("restore_game", true)) { // Only used by ZGI to load the restart game slot, r.svr. - _engine->getScriptManager()->reset(); - _engine->getScriptManager()->changeLocation('g', 'a', 'r', 'y', 0); + // Used by the credits screen. + actionList.push_back(new ActionRestoreGame(_engine, slot, args)); } else if (act.matchString("rotate_to", true)) { actionList.push_back(new ActionRotateTo(_engine, slot, args)); } else if (act.matchString("save_game", true)) { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 8220d5c37c..ad049434c3 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -686,7 +686,7 @@ void ScriptManager::serialize(Common::WriteStream *stream) { stream->writeSint16LE(getStateValue(i)); } -void ScriptManager::reset() { +void ScriptManager::deserialize(Common::SeekableReadStream *stream) { // Clear out the current table values _globalState.clear(); _globalStateFlags.clear(); @@ -706,10 +706,6 @@ void ScriptManager::reset() { _activeSideFx.clear(); _referenceTable.clear(); -} - -void ScriptManager::deserialize(Common::SeekableReadStream *stream) { - reset(); if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) { changeLocation('g', 'a', 'r', 'y', 0); diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index a05c112a18..f6201c3572 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -248,7 +248,6 @@ public: void serialize(Common::WriteStream *stream); void deserialize(Common::SeekableReadStream *stream); - void reset(); Location getCurrentLocation() const; Location getLastLocation(); -- cgit v1.2.3 From 5b3705660dd075ed249b3f18ef106e71f259af21 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 11 Jan 2015 04:51:07 +0200 Subject: ZVISION: Avoid using floating point math when upscaling subtitle timing Spotted by clone2727 --- engines/zvision/text/subtitles.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/subtitles.cpp b/engines/zvision/text/subtitles.cpp index d549e2a0c6..ffc9e2b808 100644 --- a/engines/zvision/text/subtitles.cpp +++ b/engines/zvision/text/subtitles.cpp @@ -71,8 +71,8 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname, bool upscaleT if (sb <= (int32)_subs.size()) { if (upscaleToHires) { // Convert from 15FPS (AVI) to 29.97FPS (VOB) - st = st * 29.97 / 15; - en = en * 29.97 / 15; + st = st * 2997 / 1500; + en = en * 2997 / 1500; } _subs[sb].start = st; _subs[sb].stop = en; -- cgit v1.2.3 From 468a26be405f17de00186f51978b00f6b2406726 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sat, 10 Jan 2015 22:19:46 -0600 Subject: ZVISION: Add detection for Nemesis CD - German version CSCR.ZFS is the same between the German and the French versions. Therefore we added a detection entry using the language file NEMESIS.STR --- engines/zvision/detection.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 1295f76705..545ebe35d4 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -82,7 +82,10 @@ static const ZVisionGameDescription gameDescriptions[] = { { "znemesis", 0, - AD_ENTRY1s("CSCR.ZFS", "f04113357b4748c13efcb58b4629887c", 2577873), + {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, + {"NEMESIS.STR", 0, "333bcb17bbb7f57cae742fbbe44f56f3", 9219}, + AD_LISTEND + }, Common::FR_FRA, Common::kPlatformDOS, ADGF_NO_FLAGS, @@ -91,6 +94,23 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_NEMESIS }, + { + // Zork Nemesis German version + { + "znemesis", + 0, + {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, + {"NEMESIS.STR", 0, "3d1a12b907751653866cffc6d4dfb331", 9505}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + { // Zork Nemesis English demo version { -- cgit v1.2.3 From bc959e54dc96b702a0bddaef2b8fc006087c035a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 11 Jan 2015 17:00:00 +0200 Subject: ZVISION: Build the engine by default --- engines/zvision/configure.engine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/configure.engine b/engines/zvision/configure.engine index 02e31943af..38a5959995 100644 --- a/engines/zvision/configure.engine +++ b/engines/zvision/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine zvision "ZVision" no "" "" "freetype2 16bit" +add_engine zvision "ZVision" yes "" "" "freetype2 16bit" -- cgit v1.2.3 From 3f4c924c9e6b26260e06d385a71b874d32371903 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 12 Jan 2015 02:37:27 +0200 Subject: ZVISION: Check for all the required fonts before starting a game --- engines/zvision/text/truetype_font.cpp | 19 ------------------- engines/zvision/text/truetype_font.h | 19 +++++++++++++++++++ engines/zvision/zvision.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 20 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 622a02a6a8..5cb09226e8 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -54,25 +54,6 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st } bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { - struct FontStyle { - const char *zorkFont; - const char *fontBase; - const char *freeFontBase; - const char *freeFontItalicName; - }; - - const FontStyle systemFonts[] = { - { "*times new roman*", "times", "FreeSerif", "Italic" }, - { "*times*", "times", "FreeSerif", "Italic" }, - { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, - { "*garamond*", "gara", "FreeSerif", "Italic" }, - { "*courier new*", "cour", "FreeMono", "Oblique" }, - { "*courier*", "cour", "FreeMono", "Oblique" }, - { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, - { "*arial*", "arial", "FreeSans", "Oblique" }, - { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, - }; - Common::String newFontName; Common::String freeFontName; diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h index b5fac4af8a..f63e09b1fc 100644 --- a/engines/zvision/text/truetype_font.h +++ b/engines/zvision/text/truetype_font.h @@ -34,6 +34,25 @@ struct Surface; namespace ZVision { +struct FontStyle { + const char *zorkFont; + const char *fontBase; + const char *freeFontBase; + const char *freeFontItalicName; +}; + +const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic" }, + { "*times*", "times", "FreeSerif", "Italic" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, + { "*garamond*", "gara", "FreeSerif", "Italic" }, + { "*courier new*", "cour", "FreeMono", "Oblique" }, + { "*courier*", "cour", "FreeMono", "Oblique" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, + { "*arial*", "arial", "FreeSans", "Oblique" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, +}; + class ZVision; // Styled TTF diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b42906fef3..103839158a 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -243,8 +243,36 @@ Common::Error ZVision::run() { if (ConfMan.hasKey("save_slot")) _saveManager->loadGame(ConfMan.getInt("save_slot")); + bool foundAllFonts = true; + // Before starting, make absolutely sure that the user has copied the needed fonts - if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) { + for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { + Common::String freeFontBoldItalic = Common::String("Bold") + systemFonts[i].freeFontItalicName; + + const char *fontSuffixes[4] = { "", "bd", "i", "bi" }; + const char *freeFontSuffixes[4] = { "", "Bold", systemFonts[i].freeFontItalicName, freeFontBoldItalic.c_str() }; + + for (int j = 0; j < 4; j++) { + Common::String fontName = systemFonts[i].fontBase; + fontName += fontSuffixes[j]; + fontName += ".ttf"; + + Common::String freeFontName = systemFonts[i].freeFontBase; + freeFontName += freeFontSuffixes[j]; + freeFontName += ".ttf"; + + if (!Common::File::exists(fontName) && !Common::File::exists(freeFontName) && + !_searchManager->hasFile(fontName) && !_searchManager->hasFile(freeFontName)) { + foundAllFonts = false; + break; + } + } + + if (!foundAllFonts) + break; + } + + if (!foundAllFonts) { GUI::MessageDialog dialog( "Before playing this game, you'll need to copy the required " "fonts into ScummVM's extras directory, or into the game directory. " -- cgit v1.2.3 From b247515c587e1b9da4765b7108ce2ae0321f13c5 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 12 Jan 2015 06:47:12 +0100 Subject: ZVISION: Check eos() after reading from stream, not before This fixes stray character in ZGI game over screen, when it reads an empty line of text. --- engines/zvision/text/text.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index a5ed044424..e0501ae9c8 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -490,8 +490,10 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac Common::String readWideLine(Common::SeekableReadStream &stream) { Common::String asciiString; - while (!stream.eos()) { + while (true) { uint32 value = stream.readUint16LE(); + if (stream.eos()) + break; // Check for CRLF if (value == 0x0A0D) { // Read in the extra NULL char -- cgit v1.2.3 From 1b829b95b42e1123c8079e8d7628307ba5a9103f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 13 Jan 2015 03:07:53 +0200 Subject: ZVISION: Add support for Liberation Fonts These look better than the GNU FreeType fonts, and are thus preferred over them. Many thanks to eriktorbjorn for his work on the different fonts available Also, this commit cleans up the font style array, moving it back into the CPP file --- engines/zvision/text/truetype_font.cpp | 44 +++++++++++++++++++++++++++------- engines/zvision/text/truetype_font.h | 13 ++-------- engines/zvision/zvision.cpp | 31 ++++++++++++++++-------- 3 files changed, 59 insertions(+), 29 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 5cb09226e8..9f4fbe797b 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -36,6 +36,22 @@ namespace ZVision { +const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic", "LiberationSerif" }, + { "*times*", "times", "FreeSerif", "Italic", "LiberationSerif" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic", "LiberationSerif" }, + { "*garamond*", "gara", "FreeSerif", "Italic", "LiberationSerif" }, + { "*courier new*", "cour", "FreeMono", "Oblique", "LiberationMono" }, + { "*courier*", "cour", "FreeMono", "Oblique", "LiberationMono" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique", "LiberationMono" }, + { "*arial*", "arial", "FreeSans", "Oblique", "LiberationSans" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique", "LiberationSans" } +}; + +const FontStyle getSystemFont(int fontIndex) { + return systemFonts[fontIndex]; +} + StyledTTFont::StyledTTFont(ZVision *engine) { _engine = engine; _style = 0; @@ -56,26 +72,35 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { Common::String newFontName; Common::String freeFontName; + Common::String liberationFontName; - for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { - if (fontName.matchString(systemFonts[i].zorkFont, true)) { - newFontName = systemFonts[i].fontBase; - freeFontName = systemFonts[i].freeFontBase; + for (int i = 0; i < FONT_COUNT; i++) { + FontStyle curFont = getSystemFont(i); + if (fontName.matchString(curFont.zorkFont, true)) { + newFontName = curFont.fontBase; + freeFontName = curFont.freeFontBase; + liberationFontName = curFont.liberationFontBase; if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { newFontName += "bi"; freeFontName += "Bold"; - freeFontName += systemFonts[i].freeFontItalicName; + freeFontName += curFont.freeFontItalicName; + liberationFontName += "-BoldItalic"; } else if (_style & STTF_BOLD) { newFontName += "bd"; freeFontName += "Bold"; + liberationFontName += "-Bold"; } else if (_style & STTF_ITALIC) { newFontName += "i"; - freeFontName += systemFonts[i].freeFontItalicName; + freeFontName += curFont.freeFontItalicName; + liberationFontName += "-Italic"; + } else { + liberationFontName += "-Regular"; } newFontName += ".ttf"; freeFontName += ".ttf"; + liberationFontName += ".ttf"; break; } } @@ -84,13 +109,16 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); newFontName = "arial.ttf"; freeFontName = "FreeSans.ttf"; + liberationFontName = "LiberationSans-Regular.ttf"; } bool sharp = (_style & STTF_SHARP) == STTF_SHARP; Common::File file; - if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) - error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); + if (!file.open(newFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && + !file.open(liberationFontName) && !_engine->getSearchManager()->openFile(file, liberationFontName) && + !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) + error("Unable to open font file %s (Liberation Font alternative: %s, FreeFont alternative: %s)", newFontName.c_str(), liberationFontName.c_str(), freeFontName.c_str()); Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display if (_newFont) { diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h index f63e09b1fc..6fbb1f0504 100644 --- a/engines/zvision/text/truetype_font.h +++ b/engines/zvision/text/truetype_font.h @@ -39,19 +39,10 @@ struct FontStyle { const char *fontBase; const char *freeFontBase; const char *freeFontItalicName; + const char *liberationFontBase; }; -const FontStyle systemFonts[] = { - { "*times new roman*", "times", "FreeSerif", "Italic" }, - { "*times*", "times", "FreeSerif", "Italic" }, - { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, - { "*garamond*", "gara", "FreeSerif", "Italic" }, - { "*courier new*", "cour", "FreeMono", "Oblique" }, - { "*courier*", "cour", "FreeMono", "Oblique" }, - { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, - { "*arial*", "arial", "FreeSans", "Oblique" }, - { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, -}; +#define FONT_COUNT 9 class ZVision; diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 103839158a..f9973d2280 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -236,6 +236,8 @@ void ZVision::initialize() { getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); } +extern const FontStyle getSystemFont(int fontIndex); + Common::Error ZVision::run() { initialize(); @@ -246,23 +248,30 @@ Common::Error ZVision::run() { bool foundAllFonts = true; // Before starting, make absolutely sure that the user has copied the needed fonts - for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { - Common::String freeFontBoldItalic = Common::String("Bold") + systemFonts[i].freeFontItalicName; + for (int i = 0; i < FONT_COUNT; i++) { + FontStyle curFont = getSystemFont(i); + Common::String freeFontBoldItalic = Common::String("Bold") + curFont.freeFontItalicName; const char *fontSuffixes[4] = { "", "bd", "i", "bi" }; - const char *freeFontSuffixes[4] = { "", "Bold", systemFonts[i].freeFontItalicName, freeFontBoldItalic.c_str() }; + const char *freeFontSuffixes[4] = { "", "Bold", curFont.freeFontItalicName, freeFontBoldItalic.c_str() }; + const char *liberationFontSuffixes[4] = { "-Regular", "-Bold", "-Italic", "-BoldItalic" }; for (int j = 0; j < 4; j++) { - Common::String fontName = systemFonts[i].fontBase; + Common::String fontName = curFont.fontBase; fontName += fontSuffixes[j]; fontName += ".ttf"; - Common::String freeFontName = systemFonts[i].freeFontBase; + Common::String freeFontName = curFont.freeFontBase; freeFontName += freeFontSuffixes[j]; freeFontName += ".ttf"; - if (!Common::File::exists(fontName) && !Common::File::exists(freeFontName) && - !_searchManager->hasFile(fontName) && !_searchManager->hasFile(freeFontName)) { + Common::String liberationFontName = curFont.liberationFontBase; + liberationFontName += liberationFontSuffixes[j]; + liberationFontName += ".ttf"; + + if (!Common::File::exists(fontName) && !_searchManager->hasFile(fontName) && + !Common::File::exists(liberationFontName) && !_searchManager->hasFile(liberationFontName) && + !Common::File::exists(freeFontName) && !_searchManager->hasFile(freeFontName)) { foundAllFonts = false; break; } @@ -278,9 +287,11 @@ Common::Error ZVision::run() { "fonts into ScummVM's extras directory, or into the game directory. " "On Windows, you'll need the following font files from the Windows " "font directory: Times New Roman, Century Schoolbook, Garamond, " - "Courier New and Arial. Alternatively, you can download the GNU " - "FreeFont package. You'll need all the fonts from that package, " - "i.e., FreeMono, FreeSans and FreeSerif." + "Courier New and Arial. Alternatively, you can download the " + "Liberation Fonts or the GNU FreeFont package. You'll need all the " + "fonts from the font package you choose, i.e., LiberationMono, " + "LiberationSans and LiberationSerif, or FreeMono, FreeSans and " + "FreeSerif respectively." ); dialog.runModal(); quitGame(); -- cgit v1.2.3 From 4b1cec62473c821cf0701a46f3989ff3c82990b9 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Tue, 13 Jan 2015 15:47:30 +0100 Subject: ZVISION: Add detection for the French version of ZGI --- engines/zvision/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 545ebe35d4..82150a6489 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -139,6 +139,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_GRANDINQUISITOR }, + { + // Zork Grand Inquisitor French CD version, reported by ulrichh on IRC + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "4d1ec4ade7ecc9ee9ec591d43ca3d213", 8338133), + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + { // Zork Grand Inquisitor English DVD version { -- cgit v1.2.3 From fb97e58886832f695c8cb217b1d8d4ee2d7958f0 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 13 Jan 2015 19:53:38 -0600 Subject: ZVISION: Add support for German ZGI - CD version Fixes #6760 --- engines/zvision/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 82150a6489..c1592ff5a4 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -153,6 +153,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_GRANDINQUISITOR }, + { + // Zork Grand Inquisitor German CD version, reported by breit in bug #6760 + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "b7ac7e331b9b7f884590b0b325b560c8", 8338133), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + { // Zork Grand Inquisitor English DVD version { -- cgit v1.2.3 From 28e27ea1d94f1df4c8e68216c086cb57c396ccd8 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Thu, 15 Jan 2015 00:31:39 -0600 Subject: ZVISION: Allow multiple sound effects to play at the same time This is the original behavior. This was noted in bug #6761. Specifically, the knocker on the door plays a sound whenever it is a the top of the bottom of the swing. By only allowing one sound effect to play at the same time, the knocker would only play once, even though it bounces at the bottom. --- engines/zvision/scripting/actions.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index e989478dd1..3aab6d8830 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -486,9 +486,6 @@ ActionMusic::~ActionMusic() { } bool ActionMusic::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) - return true; - if (_midi) { _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume)); } else { -- cgit v1.2.3 From 4f28cec6ac7ef68df373f6c1139a852150789851 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Thu, 15 Jan 2015 00:37:39 -0600 Subject: ZVISION: Keep the hand cursor during lever movement We have to explicitly set the cursor each call otherwise the cursor will be reset to the idle cursor. Addresses part of bug #6761 --- engines/zvision/scripting/controls/lever_control.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index bef51f0e91..249c4c6f9b 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -236,6 +236,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common } } } + _engine->getCursorManager()->changeCursor(_cursor); + cursorWasChanged = true; } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_cursor); cursorWasChanged = true; -- cgit v1.2.3 From 89f233f4881589b925e871becbf3ec1b08db108e Mon Sep 17 00:00:00 2001 From: RichieSams Date: Thu, 15 Jan 2015 00:40:07 -0600 Subject: ZVISION: Set the state value for the lever position during user dragging Not just during the "returning" animation. Addresses part of bug #6761 --- engines/zvision/scripting/controls/lever_control.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 249c4c6f9b..0f105b424c 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -232,6 +232,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common if (angle >= (int)iter->angle - ANGLE_DELTA && angle <= (int)iter->angle + ANGLE_DELTA) { _currentFrame = iter->toFrame; renderFrame(_currentFrame); + _engine->getScriptManager()->setStateValue(_key, _currentFrame); break; } } -- cgit v1.2.3 From 4287e2ebcaf2d78d5dd0d112ec8db4a8c916f6d1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Jan 2015 01:44:15 +0200 Subject: ZVISION: Allow empty sound streams. Fixes bugs #6762 and #6763 A regression from commit 07ad10babe --- engines/zvision/sound/zork_raw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 0ef5de2f55..7bdd4875fc 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -256,9 +256,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, actualName.setChar('c', actualName.size() - 1); if (!engine->getSearchManager()->openFile(*file, actualName)) - error("File not found: %s", actualName.c_str()); + return NULL; } else if (!found && !isRaw) { - error("File not found: %s", actualName.c_str()); + return NULL; } // Get the file name -- cgit v1.2.3 From 11e429672e59f69a67820c937269026f651d4998 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Jan 2015 01:52:24 +0200 Subject: ZVISION: Add detection for the Spanish version of ZGI (bug #6764) --- engines/zvision/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index c1592ff5a4..b69eee000a 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -167,6 +167,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_GRANDINQUISITOR }, + { + // Zork Grand Inquisitor Spanish CD version, reported by dianiu in bug #6764 + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "5cdc4b99c1134053af135aae71326fd1", 8338141), + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + { // Zork Grand Inquisitor English DVD version { -- cgit v1.2.3 From 3fe7c645ed11d57cc5f7e1da588fb43cfe1affa3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Jan 2015 03:43:42 +0200 Subject: ZVISION: Fix detection of Windows fonts --- engines/zvision/zvision.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index f9973d2280..3085a79de8 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -258,9 +258,18 @@ Common::Error ZVision::run() { for (int j = 0; j < 4; j++) { Common::String fontName = curFont.fontBase; + if (fontName == "censcbk" && j > 0) + fontName = "schlbk"; fontName += fontSuffixes[j]; fontName += ".ttf"; + if (fontName == "schlbkbd.ttf") + fontName = "schlbkb.ttf"; + if (fontName == "garabi.ttf") + continue; + if (fontName == "garai.ttf") + fontName = "garait.ttf"; + Common::String freeFontName = curFont.freeFontBase; freeFontName += freeFontSuffixes[j]; freeFontName += ".ttf"; -- cgit v1.2.3 From 9f00880aa40abb7584a007e10591ee5aa593ae7a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 16 Jan 2015 14:08:15 +0200 Subject: ZVISION: Properly handle sounds reusing the same sound slot (bug #6761) This is based on Marisa-Chan's observations in commit 28e27ea1d9. Tested with both ZNEM and ZGI --- engines/zvision/scripting/actions.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 3aab6d8830..ce6bd31ee4 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -486,6 +486,11 @@ ActionMusic::~ActionMusic() { } bool ActionMusic::execute() { + if (_engine->getScriptManager()->getSideFX(_slotKey)) { + _engine->getScriptManager()->killSideFx(_slotKey); + _engine->getScriptManager()->setStateValue(_slotKey, 2); + } + if (_midi) { _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume)); } else { -- cgit v1.2.3 From b3c204e2ba5350b81690e48fb7a23accaf257d0a Mon Sep 17 00:00:00 2001 From: Fedor Date: Sat, 17 Jan 2015 19:24:21 +0300 Subject: ZVISION: made error messages more detailed --- engines/zvision/zvision.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 3085a79de8..d50c7d53c4 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -186,12 +186,12 @@ void ZVision::initialize() { if (_gameDescription->gameId == GID_GRANDINQUISITOR) { if (!_searchManager->loadZix("INQUIS.ZIX")) - error("Unable to load the game ZIX file"); + error("Unable to load file INQUIS.ZIX"); } else if (_gameDescription->gameId == GID_NEMESIS) { if (!_searchManager->loadZix("NEMESIS.ZIX")) { // The game might not be installed, try MEDIUM.ZIX instead if (!_searchManager->loadZix("ZNEMSCR/MEDIUM.ZIX")) - error("Unable to load the game ZIX file"); + error("Unable to load the file ZNEMSCR/MEDIUM.ZIX"); } } -- cgit v1.2.3 From 263c5924906b2fcb3303850ad919e158cb06e120 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 17 Jan 2015 23:37:59 +0200 Subject: ZVISION: Fix bug #6769 (the "Alchemical debacle" video in ZGI) --- engines/zvision/scripting/actions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index ce6bd31ee4..758158817e 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -638,6 +638,13 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C _mask = -1; _fileName = Common::String(fileName); + + // WORKAROUND for bug #6769, location me1g.scr (the "Alchemical debacle" + // video in ZGI). We only scale up by 2x, in AnimationEffect::process(), + // but the dimensions of the target frame are off by 2 pixels. We fix that + // here, so that the video can be scaled. + if (_fileName == "me1ga011.avi" && _y2 == 213) + _y2 = 215; } ActionPlayAnimation::~ActionPlayAnimation() { -- cgit v1.2.3 From 7c23eae1027d242c9169b791d99d5f22e3159816 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 18 Jan 2015 21:30:07 +0200 Subject: ZVISION: Fix path handling in case-sensitive file systems (bug #6775) A regression from commit d70503cc98. Thanks to wjp for bisecting. --- engines/zvision/file/search_manager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 9f709dd0a1..1ae1ff71ae 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -183,6 +183,16 @@ bool SearchManager::loadZix(const Common::String &name) { path.deleteChar(0); if (path.size() && path.hasSuffix("/")) path.deleteLastChar(); + + // Handle paths in case-sensitive file systems (bug #6775) + if (path.size()) { + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) { + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + } if (path.matchString("*.zfs", true)) { arc = new ZfsArchive(path); -- cgit v1.2.3 From 3f66f28624812910834600d8a2cecb084dedea9f Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 18 Jan 2015 20:32:55 +0100 Subject: ZVISION: Remove trailing whitespace --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/events.cpp | 2 +- engines/zvision/file/save_manager.cpp | 2 +- engines/zvision/file/search_manager.cpp | 2 +- engines/zvision/graphics/render_manager.cpp | 4 ++-- engines/zvision/graphics/render_manager.h | 4 ++-- engines/zvision/scripting/scripting_effect.h | 2 +- engines/zvision/video/rlf_decoder.cpp | 2 +- engines/zvision/video/video.cpp | 2 +- engines/zvision/zvision.cpp | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index f39c06b57e..e54e986bd7 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -204,7 +204,7 @@ bool Console::cmdLocation(int argc, const char **argv) { Common::String scrFile = Common::String::format("%c%c%c%c.scr", curLocation.world, curLocation.room, curLocation.node, curLocation.view); debugPrintf("Current location: world '%c', room '%c', node '%c', view '%c', offset %d, script %s\n", curLocation.world, curLocation.room, curLocation.node, curLocation.view, curLocation.offset, scrFile.c_str()); - + if (argc != 6) { debugPrintf("Use %s to change your location\n", argv[0]); return true; diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 7804130e2a..4c7d395892 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -336,7 +336,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { mspeed = 25; } _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); - + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 5e96e4ab5e..55be8d2530 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -132,7 +132,7 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S Common::Error SaveManager::loadGame(int slot) { Common::SeekableReadStream *saveFile = NULL; - + if (slot >= 0) { saveFile = getSlotFile(slot); } else { diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 1ae1ff71ae..821b85b053 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -183,7 +183,7 @@ bool SearchManager::loadZix(const Common::String &name) { path.deleteChar(0); if (path.size() && path.hasSuffix("/")) path.deleteLastChar(); - + // Handle paths in case-sensitive file systems (bug #6775) if (path.size()) { for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) { diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 4a43e09b07..da6655b310 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -57,7 +57,7 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH _effectSurface.create(_workingWindow.width(), _workingWindow.height(), _pixelFormat); _warpedSceneSurface.create(_workingWindow.width(), _workingWindow.height(), _pixelFormat); _menuSurface.create(windowWidth, workingWindow.top, _pixelFormat); - + _menuArea = Common::Rect(0, 0, windowWidth, workingWindow.top); initSubArea(windowWidth, windowHeight, workingWindow); @@ -601,7 +601,7 @@ void RenderManager::prepareBackground() { _backgroundSurfaceDirtyRect = _backgroundDirtyRect; _backgroundSurfaceDirtyRect.translate(_screenCenterX - _backgroundOffset, 0); - // Panorama mode allows the user to spin in circles. Therefore, we need to render + // Panorama mode allows the user to spin in circles. Therefore, we need to render // the portion of the image that wrapped to the other side of the screen if (_backgroundOffset < _screenCenterX) { viewPort.moveTo(-(_screenCenterX - (_backgroundOffset + _backgroundWidth)), 0); diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index e3cbbc34ce..33d8a88e78 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -84,7 +84,7 @@ private: Graphics::Surface _currentBackgroundImage; Common::Rect _backgroundDirtyRect; - /** + /** * The x1 or y1 offset of the subRectangle of the background that is currently displayed on the screen * It will be x1 if PANORAMA, or y1 if TILT */ @@ -133,7 +133,7 @@ private: EffectsList _effects; bool _doubleFPS; - + public: void initialize(); diff --git a/engines/zvision/scripting/scripting_effect.h b/engines/zvision/scripting/scripting_effect.h index 0af1d9c21c..2a2153204f 100644 --- a/engines/zvision/scripting/scripting_effect.h +++ b/engines/zvision/scripting/scripting_effect.h @@ -37,7 +37,7 @@ class ZVision; * The base class that represents effects created from Actions. * This class is virtual. * - * Detailed Description: + * Detailed Description: * A scene has Controls. By interacting with the controls, the user * causes Actions to execute. Certain Actions create 'effects', for * example, a sound or an animation. This is the base class for diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index db598a25b6..040582bcf8 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -197,7 +197,7 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() { if (_displayedFrame >= (int)_frameCount) return NULL; - + _displayedFrame++; applyFrameToCurrent(_displayedFrame); diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index d5ffbeb536..1cfd0f4197 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -62,7 +62,7 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { bool loaded = animation->loadStream(_file); if (!loaded) error("Error loading animation %s", tmpFileName.c_str()); - + return animation; } diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index d50c7d53c4..da80ff9d02 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -251,7 +251,7 @@ Common::Error ZVision::run() { for (int i = 0; i < FONT_COUNT; i++) { FontStyle curFont = getSystemFont(i); Common::String freeFontBoldItalic = Common::String("Bold") + curFont.freeFontItalicName; - + const char *fontSuffixes[4] = { "", "bd", "i", "bi" }; const char *freeFontSuffixes[4] = { "", "Bold", curFont.freeFontItalicName, freeFontBoldItalic.c_str() }; const char *liberationFontSuffixes[4] = { "-Regular", "-Bold", "-Italic", "-BoldItalic" }; -- cgit v1.2.3 From a26a9c7268d27cb1f7407f5cf48038303f443197 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 18 Jan 2015 17:06:24 -0600 Subject: ZVISION: Fix formatting and add curlies --- .../zvision/graphics/cursors/cursor_manager.cpp | 31 ++-- engines/zvision/scripting/script_manager.cpp | 196 +++++++++++++-------- 2 files changed, 141 insertions(+), 86 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index 1e048efedf..eeab18f4ba 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -124,31 +124,30 @@ void CursorManager::cursorDown(bool pushed) { } void CursorManager::changeCursor(int id) { - int _id = id; - - if (_item && - (_id == CursorIndex_Active || - _id == CursorIndex_Idle || - _id == CursorIndex_HandPu)) { - - if (_id == CursorIndex_Idle) - _id = CursorIndex_ItemIdle; - else - _id = CursorIndex_ItemAct; + if (_item && (id == CursorIndex_Active || + id == CursorIndex_Idle || + id == CursorIndex_HandPu)) { + if (id == CursorIndex_Idle) { + id = CursorIndex_ItemIdle; + } else { + id = CursorIndex_ItemAct; + } } - if (_currentCursor != _id || - ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) { - _currentCursor = _id; + if (_currentCursor != id || ((id == CursorIndex_ItemAct || id == CursorIndex_ItemIdle) && _lastitem != _item)) { + _currentCursor = id; _lastitem = _item; changeCursor(_cursors[_currentCursor][_cursorIsPushed]); } } int CursorManager::getCursorId(const Common::String &name) { - for (int i = 0; i < NUM_CURSORS; i++) - if (name.equals(_cursorNames[i])) + for (int i = 0; i < NUM_CURSORS; i++) { + if (name.equals(_cursorNames[i])) { return i; + } + } + return CursorIndex_Idle; } diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index ad049434c3..4792a02045 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -72,21 +72,24 @@ void ScriptManager::initialize() { } void ScriptManager::update(uint deltaTimeMillis) { - if (_currentLocation.node != _nextLocation.node || - _currentLocation.room != _nextLocation.room || - _currentLocation.view != _nextLocation.view || - _currentLocation.world != _nextLocation.world) + if (_currentLocation.node != _nextLocation.node || _currentLocation.room != _nextLocation.room || + _currentLocation.view != _nextLocation.view || _currentLocation.world != _nextLocation.world) { ChangeLocationReal(); + } updateNodes(deltaTimeMillis); - if (! execScope(nodeview)) + if (! execScope(nodeview)) { return; - if (! execScope(room)) + } + if (! execScope(room)) { return; - if (! execScope(world)) + } + if (! execScope(world)) { return; - if (! execScope(universe)) + } + if (! execScope(universe)) { return; + } updateControls(deltaTimeMillis); } @@ -97,17 +100,22 @@ bool ScriptManager::execScope(ScriptScope &scope) { scope.scopeQueue = tmp; scope.scopeQueue->clear(); - for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) + for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) { (*PuzzleIter)->addedBySetState = false; + } if (scope.procCount < 2 || getStateValue(StateKey_ExecScopeStyle)) { - for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) - if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) + for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) { + if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) { return false; + } + } } else { - for (PuzzleList::iterator PuzzleIter = scope.execQueue->begin(); PuzzleIter != scope.execQueue->end(); ++PuzzleIter) - if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) + for (PuzzleList::iterator PuzzleIter = scope.execQueue->begin(); PuzzleIter != scope.execQueue->end(); ++PuzzleIter) { + if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) { return false; + } + } } if (scope.procCount < 2) { @@ -119,9 +127,11 @@ bool ScriptManager::execScope(ScriptScope &scope) { void ScriptManager::referenceTableAddPuzzle(uint32 key, PuzzleRef ref) { if (_referenceTable.contains(key)) { Common::Array *arr = &_referenceTable[key]; - for (uint32 i = 0; i < arr->size(); i++) - if ((*arr)[i].puz == ref.puz) + for (uint32 i = 0; i < arr->size(); i++) { + if ((*arr)[i].puz == ref.puz) { return; + } + } } _referenceTable[key].push_back(ref); @@ -139,9 +149,11 @@ void ScriptManager::addPuzzlesToReferenceTable(ScriptScope &scope) { referenceTableAddPuzzle(puzzlePtr->key, ref); // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle - for (Common::List >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter) - for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) + for (Common::List >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter) { + for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { referenceTableAddPuzzle(entryIter->key, ref); + } + } } } @@ -159,8 +171,9 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) { } void ScriptManager::updateControls(uint deltaTimeMillis) { - if (!_activeControls) + if (!_activeControls) { return; + } // Process only one event if (!_controlEvents.empty()) { @@ -187,9 +200,11 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { _controlEvents.pop_front(); } - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) - if ((*iter)->process(deltaTimeMillis)) + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) { + if ((*iter)->process(deltaTimeMillis)) { break; + } + } } bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { @@ -200,8 +215,9 @@ bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { } // Check each Criteria - if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0) + if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0) { return true; + } bool criteriaMet = false; for (Common::List >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) { @@ -210,10 +226,11 @@ bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { // Get the value to compare against int argumentValue; - if (entryIter->argumentIsAKey) + if (entryIter->argumentIsAKey) { argumentValue = getStateValue(entryIter->argument); - else + } else { argumentValue = entryIter->argument; + } // Do the comparison switch (entryIter->criteriaOperator) { @@ -251,8 +268,9 @@ bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { setStateValue(puzzle->key, 1); for (Common::List::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) { - if (!(*resultIter)->execute()) + if (!(*resultIter)->execute()) { return false; + } } } @@ -275,13 +293,15 @@ void ScriptManager::cleanScriptScope(ScriptScope &scope) { scope.privQueueTwo.clear(); scope.scopeQueue = &scope.privQueueOne; scope.execQueue = &scope.privQueueTwo; - for (PuzzleList::iterator iter = scope.puzzles.begin(); iter != scope.puzzles.end(); ++iter) + for (PuzzleList::iterator iter = scope.puzzles.begin(); iter != scope.puzzles.end(); ++iter) { delete(*iter); + } scope.puzzles.clear(); - for (ControlList::iterator iter = scope.controls.begin(); iter != scope.controls.end(); ++iter) + for (ControlList::iterator iter = scope.controls.begin(); iter != scope.controls.end(); ++iter) { delete(*iter); + } scope.controls.clear(); @@ -289,44 +309,49 @@ void ScriptManager::cleanScriptScope(ScriptScope &scope) { } int ScriptManager::getStateValue(uint32 key) { - if (_globalState.contains(key)) + if (_globalState.contains(key)) { return _globalState[key]; - else + } else { return 0; + } } void ScriptManager::queuePuzzles(uint32 key) { if (_referenceTable.contains(key)) { Common::Array *arr = &_referenceTable[key]; - for (int32 i = arr->size() - 1; i >= 0; i--) + for (int32 i = arr->size() - 1; i >= 0; i--) { if (!(*arr)[i].puz->addedBySetState) { (*arr)[i].scope->scopeQueue->push_back((*arr)[i].puz); (*arr)[i].puz->addedBySetState = true; } + } } } void ScriptManager::setStateValue(uint32 key, int value) { - if (value == 0) + if (value == 0) { _globalState.erase(key); - else + } else { _globalState[key] = value; + } queuePuzzles(key); } void ScriptManager::setStateValueSilent(uint32 key, int value) { - if (value == 0) + if (value == 0) { _globalState.erase(key); - else + } else { _globalState[key] = value; + } } uint ScriptManager::getStateFlag(uint32 key) { - if (_globalStateFlags.contains(key)) + if (_globalStateFlags.contains(key)) { return _globalStateFlags[key]; - else + } else { return 0; + } } void ScriptManager::setStateFlag(uint32 key, uint value) { @@ -336,10 +361,11 @@ void ScriptManager::setStateFlag(uint32 key, uint value) { } void ScriptManager::setStateFlagSilent(uint32 key, uint value) { - if (value == 0) + if (value == 0) { _globalStateFlags.erase(key); - else + } else { _globalStateFlags[key] = value; + } } void ScriptManager::unsetStateFlag(uint32 key, uint value) { @@ -348,23 +374,29 @@ void ScriptManager::unsetStateFlag(uint32 key, uint value) { if (_globalStateFlags.contains(key)) { _globalStateFlags[key] &= ~value; - if (_globalStateFlags[key] == 0) + if (_globalStateFlags[key] == 0) { _globalStateFlags.erase(key); + } } } Control *ScriptManager::getControl(uint32 key) { - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) - if ((*iter)->getKey() == key) + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { + if ((*iter)->getKey() == key) { return *iter; + } + } + return nullptr; } void ScriptManager::focusControl(uint32 key) { - if (!_activeControls) + if (!_activeControls) { return; - if (_currentlyFocusedControl == key) + } + if (_currentlyFocusedControl == key) { return; + } for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { uint32 controlKey = (*iter)->getKey(); @@ -443,50 +475,60 @@ void ScriptManager::killSideFxType(ScriptingEffect::ScriptingEffectType type) { } void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_activeControls) + if (!_activeControls) { return; + } for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { - if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos)) + if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos)) { return; + } } } void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_activeControls) + if (!_activeControls) { return; + } for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { - if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos)) + if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos)) { return; + } } } bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_activeControls) + if (!_activeControls) { return false; + } for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { - if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos)) + if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos)) { return true; + } } return false; } void ScriptManager::onKeyDown(Common::KeyState keyState) { - if (!_activeControls) + if (!_activeControls) { return; + } for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - if ((*iter)->onKeyDown(keyState)) + if ((*iter)->onKeyDown(keyState)) { return; + } } } void ScriptManager::onKeyUp(Common::KeyState keyState) { - if (!_activeControls) + if (!_activeControls) { return; + } for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - if ((*iter)->onKeyUp(keyState)) + if ((*iter)->onKeyUp(keyState)) { return; + } } } @@ -539,8 +581,9 @@ void ScriptManager::ChangeLocationReal() { _currentLocation.node = '0'; _currentLocation.view = '0'; _currentLocation.offset = 0; - } else + } else { return; + } } } @@ -563,12 +606,13 @@ void ScriptManager::ChangeLocationReal() { } if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { - if (_nextLocation.node == 's' && _nextLocation.view == 'e' && - _currentLocation.world != 'g' && _currentLocation.room != 'j') + if (_nextLocation.node == 's' && _nextLocation.view == 'e' && _currentLocation.world != 'g' && _currentLocation.room != 'j') { _engine->getSaveManager()->prepareSaveBuffer(); + } } else { - if (_currentLocation.world == 'g' && _currentLocation.room == 'j') + if (_currentLocation.world == 'g' && _currentLocation.room == 'j') { _engine->getSaveManager()->flushSaveBuffer(); + } } setStateValue(StateKey_World, _nextLocation.world); @@ -664,26 +708,30 @@ void ScriptManager::serialize(Common::WriteStream *stream) { stream->writeByte(getStateValue(StateKey_View)); stream->writeUint32LE(getStateValue(StateKey_ViewPos)); - for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { (*iter)->serialize(stream); + } stream->writeUint32BE(MKTAG('F', 'L', 'A', 'G')); int32 slots = 20000; - if (_engine->getGameId() == GID_NEMESIS) + if (_engine->getGameId() == GID_NEMESIS) { slots = 30000; + } stream->writeUint32LE(slots * 2); - for (int32 i = 0; i < slots; i++) + for (int32 i = 0; i < slots; i++) { stream->writeUint16LE(getStateFlag(i)); + } stream->writeUint32BE(MKTAG('P', 'U', 'Z', 'Z')); stream->writeUint32LE(slots * 2); - for (int32 i = 0; i < slots; i++) + for (int32 i = 0; i < slots; i++) { stream->writeSint16LE(getStateValue(i)); + } } void ScriptManager::deserialize(Common::SeekableReadStream *stream) { @@ -700,8 +748,9 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { _currentLocation.room = 0; _currentLocation.view = 0; - for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++) + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++) { delete(*iter); + } _activeSideFx.clear(); @@ -734,20 +783,23 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { case MKTAG('T', 'I', 'M', 'R'): { uint32 key = stream->readUint32LE(); uint32 time = stream->readUint32LE(); - if (_engine->getGameId() == GID_GRANDINQUISITOR) + if (_engine->getGameId() == GID_GRANDINQUISITOR) { time /= 100; - else if (_engine->getGameId() == GID_NEMESIS) + } else if (_engine->getGameId() == GID_NEMESIS) { time /= 1000; + } addSideFX(new TimerNode(_engine, key, time)); } break; case MKTAG('F', 'L', 'A', 'G'): - for (uint32 i = 0; i < tagSize / 2; i++) + for (uint32 i = 0; i < tagSize / 2; i++) { setStateFlagSilent(i, stream->readUint16LE()); + } break; case MKTAG('P', 'U', 'Z', 'Z'): - for (uint32 i = 0; i < tagSize / 2; i++) + for (uint32 i = 0; i < tagSize / 2; i++) { setStateValueSilent(i, stream->readUint16LE()); + } break; default: stream->seek(tagSize, SEEK_CUR); @@ -801,10 +853,11 @@ void ScriptManager::flushEvent(Common::EventType type) { EventList::iterator it = _controlEvents.begin(); while (it != _controlEvents.end()) { - if ((*it).type == type) + if ((*it).type == type) { it = _controlEvents.erase(it); - else + } else { it++; + } } } @@ -833,12 +886,15 @@ ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue): } int16 ValueSlot::getValue() { if (slot) { - if (value >= 0) + if (value >= 0) { return _scriptManager->getStateValue(value); - else + } + else { return 0; - } else + } + } else { return value; + } } } // End of namespace ZVision -- cgit v1.2.3 From b835eacc0cd401bb0d15a33e60d2ac47ebb4d718 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 18 Jan 2015 19:26:49 -0600 Subject: ZVISION: Don't change location when coming back from ScummVM save dialog Fixes bug # 6771 We don't need to change locations, since we use the ScummVM save dialog instead of the original one (which is actually a location). Instead we just need to reset _nextLocation to _currentLocation so the engine can stop trying to save. If we change locations, the StateKey_LastWorld/Room/etc. end up being overwritten with the current room. So if a script refers to location 0, 0, 0, 0 (aka, the last room), the engine will try to change location to the same room. --- engines/zvision/scripting/script_manager.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 4792a02045..a4ab4579b5 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -576,11 +576,8 @@ void ScriptManager::ChangeLocationReal() { _nextLocation.node = _currentLocation.node; _nextLocation.view = _currentLocation.view; _nextLocation.offset = _currentLocation.offset; - _currentLocation.world = '0'; - _currentLocation.room = '0'; - _currentLocation.node = '0'; - _currentLocation.view = '0'; - _currentLocation.offset = 0; + + return; } else { return; } @@ -743,11 +740,6 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { cleanScriptScope(room); cleanScriptScope(world); - _currentLocation.node = 0; - _currentLocation.world = 0; - _currentLocation.room = 0; - _currentLocation.view = 0; - for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++) { delete(*iter); } -- cgit v1.2.3 From 0fafb6a62c13f6f5a4ef6215a4be592ed84f248c Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 18 Jan 2015 20:11:10 -0600 Subject: Revert "ZVISION: Don't change location when coming back from ScummVM save dialog" This reverts commit b835eacc0cd401bb0d15a33e60d2ac47ebb4d718. --- engines/zvision/scripting/script_manager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index a4ab4579b5..4792a02045 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -576,8 +576,11 @@ void ScriptManager::ChangeLocationReal() { _nextLocation.node = _currentLocation.node; _nextLocation.view = _currentLocation.view; _nextLocation.offset = _currentLocation.offset; - - return; + _currentLocation.world = '0'; + _currentLocation.room = '0'; + _currentLocation.node = '0'; + _currentLocation.view = '0'; + _currentLocation.offset = 0; } else { return; } @@ -740,6 +743,11 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { cleanScriptScope(room); cleanScriptScope(world); + _currentLocation.node = 0; + _currentLocation.world = 0; + _currentLocation.room = 0; + _currentLocation.view = 0; + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++) { delete(*iter); } -- cgit v1.2.3 From 3a31e1de96a860b9f971cef939cb8a4aed8bcd5d Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sun, 18 Jan 2015 20:22:02 -0600 Subject: ZVISION: Don't change location when coming back from ScummVM save dialog and do change location when coming back from restore dialog Fixes bug # 6771 We don't need to change locations, since we use the ScummVM save dialog instead of the original one (which is actually a location). Instead we just need to reset _nextLocation to _currentLocation so the engine can stop trying to save. If we change locations, the StateKey_LastWorld/Room/etc. end up being overwritten with the current room. So if a script refers to location 0, 0, 0, 0 (aka, the last room), the engine will try to change location to the same room. On restore, we have to force a location change, just in case we restore to the same room. (Since the logic will only do a location change if _nextLocation != _currentLocation) --- engines/zvision/scripting/script_manager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 4792a02045..b45f17a6f1 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -576,13 +576,14 @@ void ScriptManager::ChangeLocationReal() { _nextLocation.node = _currentLocation.node; _nextLocation.view = _currentLocation.view; _nextLocation.offset = _currentLocation.offset; - _currentLocation.world = '0'; + + return; + } else { + _currentLocation.world = 'g'; _currentLocation.room = '0'; _currentLocation.node = '0'; _currentLocation.view = '0'; _currentLocation.offset = 0; - } else { - return; } } } -- cgit v1.2.3 From 68b7839d994d536c7e65b3bfe5045ba164bbedd5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 19 Jan 2015 05:09:03 +0200 Subject: ZVISION: Fix bug #6768 (unable to save in the prison area) The save buffer preparation code had a bug, which triggered in the jail area because its room is 'j' --- engines/zvision/scripting/script_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index b45f17a6f1..df74fd69dc 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -607,7 +607,7 @@ void ScriptManager::ChangeLocationReal() { } if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { - if (_nextLocation.node == 's' && _nextLocation.view == 'e' && _currentLocation.world != 'g' && _currentLocation.room != 'j') { + if (_nextLocation.node == 's' && _nextLocation.view == 'e' && _currentLocation.world != 'g') { _engine->getSaveManager()->prepareSaveBuffer(); } } else { -- cgit v1.2.3 From 08b6a5b4865453e916709003e3a0b1a032b8e97e Mon Sep 17 00:00:00 2001 From: Fedor Date: Mon, 19 Jan 2015 23:25:40 +0300 Subject: ZVISION: Fix comparison between signed and unsigned integers --- engines/zvision/video/rlf_decoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 040582bcf8..3e11a70f27 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -169,7 +169,7 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { if (distance < 0) { for (uint i = 0; i < _completeFrames.size(); ++i) { - if ((int)_completeFrames[i] > frame) + if (_completeFrames[i] > frame) break; closestFrame = _completeFrames[i]; } -- cgit v1.2.3 From dcac5be493a98764239619d5da60d6bc0f608383 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 19 Jan 2015 23:52:08 +0200 Subject: ZVISION: Simplify the checks in the location changing code --- engines/zvision/scripting/script_manager.cpp | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index df74fd69dc..bcc1f0a5ff 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -564,12 +564,16 @@ void ScriptManager::ChangeLocationReal() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); - if (_nextLocation.world == 'g' && _nextLocation.room == 'j' && !ConfMan.getBool("originalsaveload")) { - if ((_nextLocation.node == 's' || _nextLocation.node == 'r') && _nextLocation.view == 'e') { + const bool enteringMenu = (_nextLocation.world == 'g' && _nextLocation.room == 'j'); + const bool leavingMenu = (_currentLocation.world == 'g' && _currentLocation.room == 'j'); + const bool isSaveScreen = (enteringMenu && _nextLocation.node == 's' && _nextLocation.view == 'e'); + const bool isRestoreScreen = (enteringMenu && _nextLocation.node == 'r' && _nextLocation.view == 'e'); + + if (enteringMenu && !ConfMan.getBool("originalsaveload")) { + if (isSaveScreen || isRestoreScreen) { // Hook up the ScummVM save/restore dialog - bool isSave = (_nextLocation.node == 's'); - bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSave); - if (!gameSavedOrLoaded || isSave) { + bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSaveScreen); + if (!gameSavedOrLoaded || isSaveScreen) { // Reload the current room _nextLocation.world = _currentLocation.world; _nextLocation.room = _currentLocation.room; @@ -590,30 +594,26 @@ void ScriptManager::ChangeLocationReal() { _engine->setRenderDelay(2); - if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { - if (_nextLocation.world != 'g' || _nextLocation.room != 'j') { + if (!enteringMenu) { + if (!leavingMenu) { setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room)); setStateValue(StateKey_LastNode, getStateValue(StateKey_Node)); setStateValue(StateKey_LastView, getStateValue(StateKey_View)); setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos)); - } else { - setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); - setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); - setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); - setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); - setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } + } else { + setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); + setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); + setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); + setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); + setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } - if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { - if (_nextLocation.node == 's' && _nextLocation.view == 'e' && _currentLocation.world != 'g') { - _engine->getSaveManager()->prepareSaveBuffer(); - } - } else { - if (_currentLocation.world == 'g' && _currentLocation.room == 'j') { - _engine->getSaveManager()->flushSaveBuffer(); - } + if (isSaveScreen && !leavingMenu) { + _engine->getSaveManager()->prepareSaveBuffer(); + } else if (leavingMenu) { + _engine->getSaveManager()->flushSaveBuffer(); } setStateValue(StateKey_World, _nextLocation.world); -- cgit v1.2.3 From 5df2e08c1668c6649f7817688ce1ce198e563083 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 19 Jan 2015 23:54:07 +0200 Subject: ZVISION: Fix bug #6771 (unable to leave room when loading a game) Avoid overwriting the previous location when loading a saved game --- engines/zvision/scripting/script_manager.cpp | 8 ++++---- engines/zvision/scripting/script_manager.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index bcc1f0a5ff..34376cee5b 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -74,7 +74,7 @@ void ScriptManager::initialize() { void ScriptManager::update(uint deltaTimeMillis) { if (_currentLocation.node != _nextLocation.node || _currentLocation.room != _nextLocation.room || _currentLocation.view != _nextLocation.view || _currentLocation.world != _nextLocation.world) { - ChangeLocationReal(); + ChangeLocationReal(false); } updateNodes(deltaTimeMillis); @@ -560,7 +560,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi } } -void ScriptManager::ChangeLocationReal() { +void ScriptManager::ChangeLocationReal(bool isLoading) { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); @@ -595,7 +595,7 @@ void ScriptManager::ChangeLocationReal() { _engine->setRenderDelay(2); if (!enteringMenu) { - if (!leavingMenu) { + if (!isLoading && !leavingMenu) { setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room)); setStateValue(StateKey_LastNode, getStateValue(StateKey_Node)); @@ -809,7 +809,7 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { _nextLocation = nextLocation; - ChangeLocationReal(); + ChangeLocationReal(true); _engine->setRenderDelay(10); setStateValue(StateKey_RestoreFlag, 1); diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index f6201c3572..6d025bf2e9 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -273,7 +273,7 @@ private: bool execScope(ScriptScope &scope); /** Perform change location */ - void ChangeLocationReal(); + void ChangeLocationReal(bool isLoading); int8 inventoryGetCount(); void inventorySetCount(int8 cnt); -- cgit v1.2.3 From 5f9858844a24b00e75ef2c504b2d68c189261dd2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 Jan 2015 01:21:16 +0200 Subject: ZVISION: Fix saving when using the original save dialog A regression from commit dcac5be493 --- engines/zvision/scripting/script_manager.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 34376cee5b..a4491103e6 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -594,26 +594,30 @@ void ScriptManager::ChangeLocationReal(bool isLoading) { _engine->setRenderDelay(2); - if (!enteringMenu) { - if (!isLoading && !leavingMenu) { + if (!leavingMenu) { + if (!isLoading && !enteringMenu) { setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room)); setStateValue(StateKey_LastNode, getStateValue(StateKey_Node)); setStateValue(StateKey_LastView, getStateValue(StateKey_View)); setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos)); + } else { + setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); + setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); + setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); + setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); + setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } - } else { - setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); - setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); - setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); - setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); - setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); } - if (isSaveScreen && !leavingMenu) { - _engine->getSaveManager()->prepareSaveBuffer(); - } else if (leavingMenu) { - _engine->getSaveManager()->flushSaveBuffer(); + if (enteringMenu) { + if (isSaveScreen && !leavingMenu) { + _engine->getSaveManager()->prepareSaveBuffer(); + } + } else { + if (leavingMenu) { + _engine->getSaveManager()->flushSaveBuffer(); + } } setStateValue(StateKey_World, _nextLocation.world); -- cgit v1.2.3 From 750d72812b36bfed3043080d633798854dc4008d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 Jan 2015 02:16:21 +0200 Subject: ZVISION: Properly skip commented out puzzle criteria - fixes bug #6776 In the Zork: Nemesis version bundled in the ZGI SE DVD, the bell rope puzzle has been modified so that it's non-interactive, i.e. there isn't a hotspot to click while the video is playing, and the player is transported to the next room. In the patched script, all criteria of that puzzle were commented out, resulting in an invalid criteria list. Skip any commented out criteria, to avoid ending with an invalid list. --- engines/zvision/scripting/scr_file_handling.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index b4da61a119..277702d287 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -104,6 +104,13 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + // Skip any commented out criteria. If all the criteria are commented out, + // we might end up with an invalid criteria list (bug #6776). + while (line.empty()) { + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + } + // Criteria can be empty if (line.contains('}')) { return false; -- cgit v1.2.3 From ad83f033151ac6cf6345e6a83a0903ad6499c0ca Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 20 Jan 2015 19:21:39 +0100 Subject: ZVISION: Fix mis-parsing of criteria, a.k.a bug #6774 A condition in a criteria is made up of three tokens: An id, an operator and an id/value. However, in my copy of ZGI, puzzle:07507 has "[00202] !3 # SPELL_12_IN_BOOK", i.e. there was no space between the second and third tokens. This caused the "glorf" spell to not be properly inscribed in your spell book. To fix this, if the second token is more than one character we use the rest of it as the third token. --- engines/zvision/scripting/scr_file_handling.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 277702d287..8f0f80e39e 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -141,9 +141,17 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li else if (token.c_str()[0] == '<') entry.criteriaOperator = Puzzle::LESS_THAN; + // There are supposed to be three tokens, but there is no + // guarantee that there will be a space between the second and + // the third one (bug #6774) + if (token.size() == 1) { + token = tokenizer.nextToken(); + } else { + token.deleteChar(0); + } + // First determine if the last token is an id or a value // Then parse it into 'argument' - token = tokenizer.nextToken(); if (token.contains('[')) { sscanf(token.c_str(), "[%u]", &(entry.argument)); entry.argumentIsAKey = true; -- cgit v1.2.3 From 1d6a80734969d2475c7d97945a74225b12dae297 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 20 Jan 2015 05:19:44 +0200 Subject: ZVISION: Adapt confirmation dialogs for non-English versions --- engines/zvision/graphics/render_manager.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index da6655b310..a65117f2b5 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -989,14 +989,33 @@ bool RenderManager::askQuestion(const Common::String &str) { Common::Event evnt; while (_engine->getEventManager()->pollEvent(evnt)) { if (evnt.type == Common::EVENT_KEYDOWN) { + // English: yes/no + // German: ja/nein + // Spanish: si/no + // French: F4/any other key switch (evnt.kbd.keycode) { case Common::KEYCODE_y: - result = 2; + if (_engine->getLanguage() == Common::EN_ANY) + result = 2; + break; + case Common::KEYCODE_j: + if (_engine->getLanguage() == Common::DE_DEU) + result = 2; + break; + case Common::KEYCODE_s: + if (_engine->getLanguage() == Common::ES_ESP) + result = 2; + break; + case Common::KEYCODE_F4: + if (_engine->getLanguage() == Common::FR_FRA) + result = 2; break; case Common::KEYCODE_n: result = 1; break; default: + if (_engine->getLanguage() == Common::FR_FRA) + result = 1; break; } } -- cgit v1.2.3 From 0776709f3175da3ebca69f8a4866d4d98a1e9be9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 00:33:54 +0200 Subject: ZVISION: Do not process cheat codes while in the game menus This prevents the cheat codes from being accidentally triggered when using the save screen, for example --- engines/zvision/core/events.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 4c7d395892..9cf5d04a7a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -93,6 +93,11 @@ void ZVision::shortKeys(Common::Event event) { } void ZVision::cheatCodes(uint8 key) { + Location loc = _scriptManager->getCurrentLocation(); + // Do not process cheat codes while in the game menus + if (loc.world == 'g' && loc.room == 'j') + return; + pushKeyToCheatBuf(key); if (getGameId() == GID_GRANDINQUISITOR) { @@ -146,7 +151,6 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("HELLOSAILOR")) { - Location loc = _scriptManager->getCurrentLocation(); Audio::AudioStream *soundStream; if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { soundStream = makeRawZorkStream("v000hpta.raw", this); -- cgit v1.2.3 From 5a6f711d07f64193692451c9969b661c094e2021 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 20 Jan 2015 23:30:32 +0100 Subject: ZVISION: Convert subtitles to UTF-32 before rendering them (bug #6772) Because we use Common::String to store UTF-8 data, the font renderer will draw the wrong glyphs for non-ASCII characters, unless we first convert the string to UTF-32. (I thought the same change would have to be made for the ZGI game over screens, but apparently they work anyway. At least the German version, I'm told.) I've discussed this change with [md5], and while it would probably be more correct to make the engine use UTF-32 throughout, that is also rather painful. --- engines/zvision/text/truetype_font.cpp | 38 +++++++++++++++++++++++++++++++--- engines/zvision/text/truetype_font.h | 2 ++ 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 9f4fbe797b..f7580fb553 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -26,6 +26,7 @@ #include "common/file.h" #include "common/system.h" #include "common/unzip.h" +#include "common/ustr.h" #include "graphics/font.h" #include "graphics/fonts/ttf.h" #include "graphics/surface.h" @@ -168,6 +169,36 @@ int StyledTTFont::getKerningOffset(byte left, byte right) { return 0; } +Common::U32String StyledTTFont::convertUtf8ToUtf32(const Common::String &str) { + // The String class, and therefore the Font class as well, assume one + // character is one byte, but in this case it's actually an UTF-8 + // string with up to 4 bytes per character. To work around this, + // convert it to an U32String before drawing it, because our Font class + // can handle that. + Common::U32String u32str; + uint i = 0; + while (i < str.size()) { + uint32 chr = 0; + if ((str[i] & 0xF8) == 0xF0) { + chr |= (str[i++] & 0x07) << 18; + chr |= (str[i++] & 0x3F) << 12; + chr |= (str[i++] & 0x3F) << 6; + chr |= (str[i++] & 0x3F); + } else if ((str[i] & 0xF0) == 0xE0) { + chr |= (str[i++] & 0x0F) << 12; + chr |= (str[i++] & 0x3F) << 6; + chr |= (str[i++] & 0x3F); + } else if ((str[i] & 0xE0) == 0xC0) { + chr |= (str[i++] & 0x1F) << 6; + chr |= (str[i++] & 0x3F); + } else { + chr = (str[i++] & 0x7F); + } + u32str += chr; + } + return u32str; +} + void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { if (_font) { _font->drawChar(dst, chr, x, y, color); @@ -186,10 +217,11 @@ void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { if (_font) { - _font->drawString(dst, str, x, y, w, color, align); + Common::U32String u32str = convertUtf8ToUtf32(str); + _font->drawString(dst, u32str, x, y, w, color, align); if (_style & STTF_UNDERLINE) { int16 pos = floor(_font->getFontHeight() * 0.87); - int16 wd = MIN(_font->getStringWidth(str), w); + int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; if (align == Graphics::kTextAlignCenter) stX += (w - wd) / 2; @@ -202,7 +234,7 @@ void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, } if (_style & STTF_STRIKEOUT) { int16 pos = floor(_font->getFontHeight() * 0.60); - int16 wd = MIN(_font->getStringWidth(str), w); + int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; if (align == Graphics::kTextAlignCenter) stX += (w - wd) / 2; diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h index 6fbb1f0504..caa9c09a76 100644 --- a/engines/zvision/text/truetype_font.h +++ b/engines/zvision/text/truetype_font.h @@ -77,6 +77,8 @@ public: int getCharWidth(byte chr); int getKerningOffset(byte left, byte right); + Common::U32String convertUtf8ToUtf32(const Common::String &str); + void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); -- cgit v1.2.3 From 1330cb7c99478c67a722ff3bd35567dcd59f8fdf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 01:41:35 +0200 Subject: ZVISION: Remove superfluous check --- engines/zvision/scripting/script_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index a4491103e6..d10cd81438 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -210,7 +210,7 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { // Check if the puzzle is already finished // Also check that the puzzle isn't disabled - if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) { + if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED)) { return true; } -- cgit v1.2.3 From 796fb134f1af6b3617b7687d2a89ab51dd1aa63d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 21 Jan 2015 01:24:59 +0100 Subject: ZVISION: Remove unnecessary spaces --- engines/zvision/scripting/script_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index d10cd81438..71966b3125 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -78,16 +78,16 @@ void ScriptManager::update(uint deltaTimeMillis) { } updateNodes(deltaTimeMillis); - if (! execScope(nodeview)) { + if (!execScope(nodeview)) { return; } - if (! execScope(room)) { + if (!execScope(room)) { return; } - if (! execScope(world)) { + if (!execScope(world)) { return; } - if (! execScope(universe)) { + if (!execScope(universe)) { return; } updateControls(deltaTimeMillis); -- cgit v1.2.3 From 46fe6b64b9bac081384107192b7bcd24fbb255f5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 12:35:12 +0200 Subject: ZVISION: Properly handle confirmation dialogs in the French ver. of ZGI --- engines/zvision/graphics/render_manager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index a65117f2b5..3cd9701b7c 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -992,7 +992,8 @@ bool RenderManager::askQuestion(const Common::String &str) { // English: yes/no // German: ja/nein // Spanish: si/no - // French: F4/any other key + // French Nemesis: F4/any other key + // French ZGI: oui/non switch (evnt.kbd.keycode) { case Common::KEYCODE_y: if (_engine->getLanguage() == Common::EN_ANY) @@ -1006,15 +1007,19 @@ bool RenderManager::askQuestion(const Common::String &str) { if (_engine->getLanguage() == Common::ES_ESP) result = 2; break; + case Common::KEYCODE_o: + if (_engine->getLanguage() == Common::FR_FRA && _engine->getGameId() == GID_GRANDINQUISITOR) + result = 2; + break; case Common::KEYCODE_F4: - if (_engine->getLanguage() == Common::FR_FRA) + if (_engine->getLanguage() == Common::FR_FRA && _engine->getGameId() == GID_NEMESIS) result = 2; break; case Common::KEYCODE_n: result = 1; break; default: - if (_engine->getLanguage() == Common::FR_FRA) + if (_engine->getLanguage() == Common::FR_FRA && _engine->getGameId() == GID_NEMESIS) result = 1; break; } -- cgit v1.2.3 From e66883d5cbae4d92264cd1c2b5784af79d30f152 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 14:06:13 +0200 Subject: ZVISION: Add console commands to manipulate state flags and variables --- engines/zvision/core/console.cpp | 38 ++++++++++++++++++++++++++++++++++++++ engines/zvision/core/console.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index e54e986bd7..f5cacb582c 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -54,6 +54,8 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); registerCmd("dumpimage", WRAP_METHOD(Console, cmdDumpImage)); + registerCmd("statevalue", WRAP_METHOD(Console, cmdStateValue)); + registerCmd("stateflag", WRAP_METHOD(Console, cmdStateFlag)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -329,4 +331,40 @@ bool Console::cmdDumpImage(int argc, const char **argv) { return true; } +bool Console::cmdStateValue(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state variable\n", argv[0]); + debugPrintf("Use %s to set the value of a state variable\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateValue(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateValue(valueNum, newValue); + + return true; +} + +bool Console::cmdStateFlag(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state flag\n", argv[0]); + debugPrintf("Use %s to set the value of a state flag\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateFlag(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateFlag(valueNum, newValue); + + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index ffce87869f..ac834185a0 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -48,6 +48,8 @@ private: bool cmdDumpFile(int argc, const char **argv); bool cmdDumpFiles(int argc, const char **argv); bool cmdDumpImage(int argc, const char **argv); + bool cmdStateValue(int argc, const char **argv); + bool cmdStateFlag(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From f7e0d1e958f3b6a4bfff9ba2c9ade03375e8f9d9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 23 Jan 2015 03:01:29 +0200 Subject: ZVISION: Fix shadowed variable A bug in commit 21e9007d80. Thanks to fingolfin for pointing it out --- engines/zvision/file/save_manager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 55be8d2530..1e0c57e2b3 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -136,13 +136,15 @@ Common::Error SaveManager::loadGame(int slot) { if (slot >= 0) { saveFile = getSlotFile(slot); } else { - Common::File *saveFile = _engine->getSearchManager()->openFile("r.svr"); + saveFile = _engine->getSearchManager()->openFile("r.svr"); if (!saveFile) { - saveFile = new Common::File; - if (!saveFile->open("r.svr")) { - delete saveFile; + Common::File *restoreFile = new Common::File(); + if (!restoreFile->open("r.svr")) { + delete restoreFile; return Common::kPathDoesNotExist; } + + saveFile = restoreFile; } } -- cgit v1.2.3 From 1bd83a96f00c4d25cf4060ba8faffda81865ad7d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 23 Jan 2015 03:02:24 +0200 Subject: ZVISION: Fix script bug #6780 (invalid hotspot at base of tower in ZGI) --- engines/zvision/scripting/scr_file_handling.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 8f0f80e39e..b9cafa77ed 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -358,6 +358,16 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { + // WORKAROUND for a script bug in ZGI: There is an invalid hotspot + // at scene em1h (bottom of tower), which points to a missing + // script em1n. This is a hotspot at the right of the screen. + // In the original, this hotspot doesn't lead anywhere anyway, + // so instead of moving to a missing scene, we just remove the + // hotspot altogether. The alternative would be to just process + // and ignore invalid scenes, but I don't think it's worth the + // effort. Fixes bug #6780. + if (_engine->getGameId() == GID_GRANDINQUISITOR && key == 5653) + return NULL; return new PushToggleControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); -- cgit v1.2.3 From d75fbe79f064e3ee017764024aac173a7d599583 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 23 Jan 2015 03:04:50 +0200 Subject: ZVISION: Error out when a script file can't be found or be parsed This should be an error, as we've effectively reached a non-existing scene (such as in bug #6780), or we haven't parsed script files of a scene fully, thus unexpected behavior will likely occur --- engines/zvision/scripting/scr_file_handling.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index b9cafa77ed..b047c14430 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -47,15 +47,13 @@ namespace ZVision { void ScriptManager::parseScrFile(const Common::String &fileName, ScriptScope &scope) { Common::File file; if (!_engine->getSearchManager()->openFile(file, fileName)) { - warning("Script file not found: %s", fileName.c_str()); - return; + error("Script file not found: %s", fileName.c_str()); } while (!file.eos()) { Common::String line = file.readLine(); if (file.err()) { - warning("Error parsing scr file: %s", fileName.c_str()); - return; + error("Error parsing scr file: %s", fileName.c_str()); } trimCommentsAndWhiteSpace(&line); -- cgit v1.2.3 From d67727a7a452354587fb49e58ac3a61cd4ac1fec Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 23 Jan 2015 11:13:06 +0600 Subject: ZVISION: Fix sound bug #6767 by making pan_track code similar to original --- engines/zvision/scripting/effects/music_effect.cpp | 129 +++++++++++++-------- engines/zvision/scripting/effects/music_effect.h | 26 +++-- 2 files changed, 94 insertions(+), 61 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index 102f330305..3d3fc88751 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -40,12 +40,11 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) { _loop = loop; _volume = volume; + _deltaVolume = 0; + _balance = 0; _crossfade = false; _crossfadeTarget = 0; _crossfadeTime = 0; - _attenuate = 0; - _pantrack = false; - _pantrackPosition = 0; _sub = NULL; _stereo = false; _loaded = false; @@ -97,17 +96,14 @@ MusicNode::~MusicNode() { debug(1, "MusicNode: %d destroyed\n", _key); } -void MusicNode::setPanTrack(int16 pos) { - if (!_stereo) { - _pantrack = true; - _pantrackPosition = pos; - setVolume(_volume); - } +void MusicNode::setDeltaVolume(uint8 volume) { + _deltaVolume = volume; + setVolume(_volume); } -void MusicNode::unsetPanTrack() { - _pantrack = false; - setVolume(_volume); +void MusicNode::setBalance(int8 balance) { + _balance = balance; + _engine->_mixer->setChannelBalance(_handle, _balance); } void MusicNode::setFade(int32 time, uint8 target) { @@ -134,7 +130,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { } } - if (_pantrack || _volume != _newvol) + if (_volume != _newvol) setVolume(_newvol); if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) @@ -146,55 +142,86 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { void MusicNode::setVolume(uint8 newVolume) { if (!_loaded) return; - if (_pantrack) { - int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); - curX -= _pantrackPosition; - int32 _width = _engine->getRenderManager()->getBkgSize().x; - if (curX < (-_width) / 2) - curX += _width; - else if (curX >= _width / 2) - curX -= _width; - - float norm = (float)curX / ((float)_width / 2.0); - float lvl = fabs(norm); - if (lvl > 0.5) - lvl = (lvl - 0.5) * 1.7; - else - lvl = 1.0; - float bal = sin(-norm * 3.1415926) * 127.0; + _volume = newVolume; - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, bal); - _engine->_mixer->setChannelVolume(_handle, newVolume * lvl); - } - } else { - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, 0); - _engine->_mixer->setChannelVolume(_handle, newVolume); - } - } + if (_deltaVolume >= _volume) + _engine->_mixer->setChannelVolume(_handle, 0); + else + _engine->_mixer->setChannelVolume(_handle, _volume - _deltaVolume); +} - _volume = newVolume; +uint8 MusicNode::getVolume() { + return _volume; } PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) : ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) { _slot = slot; + _position = pos; - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot); - if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) { - MusicNodeBASE *mus = (MusicNodeBASE *)fx; - mus->setPanTrack(pos); - } + // Try to set pan value for music node immediately + process(0); } PanTrackNode::~PanTrackNode() { - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot); +} + +bool PanTrackNode::process(uint32 deltaTimeInMillis) { + ScriptManager * scriptManager = _engine->getScriptManager(); + ScriptingEffect *fx = scriptManager->getSideFX(_slot); if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) { MusicNodeBASE *mus = (MusicNodeBASE *)fx; - mus->unsetPanTrack(); + + int curPos = scriptManager->getStateValue(StateKey_ViewPos); + int16 _width = _engine->getRenderManager()->getBkgSize().x; + int16 _halfWidth = _width / 2; + int16 _quarterWidth = _width / 4; + + int tmp = 0; + if (curPos <= _position) + tmp = _position - curPos; + else + tmp = _position - curPos + _width; + + int balance = 0; + + if (tmp > _halfWidth) + tmp -= _width; + + if (tmp > _quarterWidth) { + balance = 1; + tmp = _halfWidth - tmp; + } else if (tmp < -_quarterWidth) { + balance = -1; + tmp = -_halfWidth - tmp; + } + + // Originally it's value -90...90 but we use -127...127 and therefore 360 replaced by 508 + mus->setBalance( (508 * tmp) / _width ); + + tmp = (360 * tmp) / _width; + + int deltaVol = balance; + + // This value sets how fast volume goes off than sound source back of you + // By this value we can hack some "bugs" have place in originall game engine like beat sound in ZGI-dc10 + int volumeCorrection = 2; + + if (_engine->getGameId() == GID_GRANDINQUISITOR) { + Location loc = scriptManager->getCurrentLocation(); + if (loc.world == 'd' && loc.room == 'c' && loc.node == '1' && loc.view == '0') + volumeCorrection = 5; + } + + if (deltaVol != 0) + deltaVol = (mus->getVolume() * volumeCorrection) * (90 - tmp * balance) / 90; + if (deltaVol > 255) + deltaVol = 255; + + mus->setDeltaVolume(deltaVol); } + return false; } MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) @@ -225,10 +252,10 @@ MusicMidiNode::~MusicMidiNode() { _engine->getScriptManager()->setStateValue(_key, 2); } -void MusicMidiNode::setPanTrack(int16 pos) { +void MusicMidiNode::setDeltaVolume(uint8 volume) { } -void MusicMidiNode::unsetPanTrack() { +void MusicMidiNode::setBalance(int8 balance) { } void MusicMidiNode::setFade(int32 time, uint8 target) { @@ -245,4 +272,8 @@ void MusicMidiNode::setVolume(uint8 newVolume) { _volume = newVolume; } +uint8 MusicMidiNode::getVolume() { + return _volume; +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h index 31d538f668..f6cb4a5a1c 100644 --- a/engines/zvision/scripting/effects/music_effect.h +++ b/engines/zvision/scripting/effects/music_effect.h @@ -48,9 +48,9 @@ public: virtual bool process(uint32 deltaTimeInMillis) = 0; virtual void setVolume(uint8 volume) = 0; - - virtual void setPanTrack(int16 pos) = 0; - virtual void unsetPanTrack() = 0; + virtual uint8 getVolume() = 0; + virtual void setDeltaVolume(uint8 volume) = 0; + virtual void setBalance(int8 balance) = 0; virtual void setFade(int32 time, uint8 target) = 0; }; @@ -70,17 +70,16 @@ public: bool process(uint32 deltaTimeInMillis); void setVolume(uint8 volume); - - void setPanTrack(int16 pos); - void unsetPanTrack(); + uint8 getVolume(); + void setDeltaVolume(uint8 volume); + void setBalance(int8 balance); void setFade(int32 time, uint8 target); private: - bool _pantrack; - int32 _pantrackPosition; - int32 _attenuate; uint8 _volume; + uint8 _deltaVolume; + int8 _balance; bool _loop; bool _crossfade; uint8 _crossfadeTarget; @@ -107,9 +106,9 @@ public: bool process(uint32 deltaTimeInMillis); void setVolume(uint8 volume); - - void setPanTrack(int16 pos); - void unsetPanTrack(); + uint8 getVolume(); + void setDeltaVolume(uint8 volume); + void setBalance(int8 balance); void setFade(int32 time, uint8 target); @@ -126,8 +125,11 @@ public: PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); ~PanTrackNode(); + bool process(uint32 deltaTimeInMillis); + private: uint32 _slot; + int16 _position; }; } // End of namespace ZVision -- cgit v1.2.3 From ad2ab98474cecc8f8764697b3aa2acc16912368f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 23 Jan 2015 16:20:59 +0600 Subject: ZVISION: Use correct int type for volume --- engines/zvision/scripting/effects/music_effect.cpp | 2 +- engines/zvision/scripting/effects/music_effect.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index 3d3fc88751..6c1a5f7376 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -36,7 +36,7 @@ namespace ZVision { -MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) +MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, uint8 volume) : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) { _loop = loop; _volume = volume; diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h index f6cb4a5a1c..7657be8e09 100644 --- a/engines/zvision/scripting/effects/music_effect.h +++ b/engines/zvision/scripting/effects/music_effect.h @@ -57,7 +57,7 @@ public: class MusicNode : public MusicNodeBASE { public: - MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); + MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, uint8 volume); ~MusicNode(); /** -- cgit v1.2.3 From 0bc61d3c2130981e06199b60fe553b2095af287a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 23 Jan 2015 16:25:21 +0600 Subject: ZVISION: Volume is not linear value, use dB map to linear for -100...0dB --- engines/zvision/scripting/effects/music_effect.cpp | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index 6c1a5f7376..ee2232d962 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -36,6 +36,24 @@ namespace ZVision { +static const uint8 dbMapLinear[256] = +{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, +2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, +4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, +8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, +14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 24, 25, +26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 40, 41, 43, 45, +46, 48, 50, 52, 53, 55, 57, 60, 62, 64, 67, 69, 72, 74, 77, 80, +83, 86, 89, 92, 96, 99, 103, 107, 111, 115, 119, 123, 128, 133, 137, 143, +148, 153, 159, 165, 171, 177, 184, 191, 198, 205, 212, 220, 228, 237, 245, 255}; + MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, uint8 volume) : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) { _loop = loop; @@ -65,9 +83,9 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, dbMapLinear[_volume]); } else { - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, dbMapLinear[_volume]); } if (_key != StateKey_NotSet) @@ -148,7 +166,7 @@ void MusicNode::setVolume(uint8 newVolume) { if (_deltaVolume >= _volume) _engine->_mixer->setChannelVolume(_handle, 0); else - _engine->_mixer->setChannelVolume(_handle, _volume - _deltaVolume); + _engine->_mixer->setChannelVolume(_handle, dbMapLinear[_volume - _deltaVolume]); } uint8 MusicNode::getVolume() { -- cgit v1.2.3 From 9b498d576ed9b922ef61175310a6b369e4d30e3f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 23 Jan 2015 16:26:17 +0600 Subject: ZVISION: Correct value for attenuate --- engines/zvision/scripting/actions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 758158817e..b12ecf66ee 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -104,7 +104,7 @@ bool ActionAttenuate::execute() { ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNode *mus = (MusicNode *)fx; - mus->setVolume(255 - (abs(_attenuation) >> 7)); + mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 ); } return true; } -- cgit v1.2.3 From 568c13b11531fcfb10b53bbc84d723e6fd1d0e40 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 23 Jan 2015 16:31:10 +0600 Subject: ZVISION: Use correct virtual class type instead of MusicNode --- engines/zvision/scripting/actions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index b12ecf66ee..9a2f1d10ff 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -103,7 +103,7 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S bool ActionAttenuate::execute() { ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { - MusicNode *mus = (MusicNode *)fx; + MusicNodeBASE *mus = (MusicNodeBASE *)fx; mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 ); } return true; @@ -154,7 +154,7 @@ bool ActionCrossfade::execute() { if (_keyOne) { ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { - MusicNode *mus = (MusicNode *)fx; + MusicNodeBASE *mus = (MusicNodeBASE *)fx; if (_oneStartVolume >= 0) mus->setVolume((_oneStartVolume * 255) / 100); @@ -165,7 +165,7 @@ bool ActionCrossfade::execute() { if (_keyTwo) { ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { - MusicNode *mus = (MusicNode *)fx; + MusicNodeBASE *mus = (MusicNodeBASE *)fx; if (_twoStartVolume >= 0) mus->setVolume((_twoStartVolume * 255) / 100); -- cgit v1.2.3 From ca83ecd8c22c132da3f9b8963ffb76702692a272 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 24 Jan 2015 14:54:25 +0100 Subject: ZVISION: Fix lag at beginning of cutscenes We have to update _curChunk when decoding audio, otherwise it will decode the entire audio track on the first frame. For the ZGI intro this would take 700-800 ms, and since the audio started playing before the video it looked to me as if it had to play the first bit faster to catch up. Thanks to fuzzie for setting me on the right track with an off-hand remark about the Zork AVI decoder (I was looking at the standard AVI decoder), and for finding the cause a few seconds before I did. --- engines/zvision/video/zork_avi_decoder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 5618250d79..abf48543c9 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -39,6 +39,7 @@ Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDec } void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { + bool updateCurChunk = true; if (_audStream) { if (_wvInfo.tag == kWaveFormatZorkPCM) { assert(_wvInfo.size == 8); @@ -54,9 +55,17 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); } } else { + updateCurChunk = false; AVIAudioTrack::queueSound(stream); } } + + // The superclass always updates _curChunk, whether or not audio has + // been queued, so we should do that too. Unless the superclass already + // has done it for us. + if (updateCurChunk) { + _curChunk++; + } } void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() { -- cgit v1.2.3 From 4e1ffc9434f771d3f43e66104adeea9e0166123c Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 24 Jan 2015 14:56:48 +0100 Subject: ZVISION: Delete stream if there is no audio stream to queue to This probably never happens, but is consistent with our common AVI decoder. --- engines/zvision/video/zork_avi_decoder.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index abf48543c9..cf8505ec82 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -58,6 +58,8 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s updateCurChunk = false; AVIAudioTrack::queueSound(stream); } + } else { + delete stream; } // The superclass always updates _curChunk, whether or not audio has -- cgit v1.2.3 From 51e90b2422f0bf3b4b9b1a71c23ae12a359dead2 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 26 Jan 2015 19:34:21 +0100 Subject: ZVISION: Fix ActionMusic volume The volume can be either a constant or a state value. The latter is used by ZGI to simulate a sound being heard at different distances, e.g. the beehive in the Dungeon Master's hideout. --- engines/zvision/scripting/actions.cpp | 63 ++++++++++++++++++++++------------- engines/zvision/scripting/actions.h | 3 +- 2 files changed, 42 insertions(+), 24 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 9a2f1d10ff..81d6655fa9 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -21,6 +21,7 @@ */ #include "common/scummsys.h" +#include "common/tokenizer.h" #include "video/video_decoder.h" #include "zvision/scripting/actions.h" @@ -449,33 +450,40 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l _note(0), _prog(0), _universe(global) { - uint type = 0; - char fileNameBuffer[25]; - uint loop = 0; - uint volume = 255; + Common::StringTokenizer tokenizer(line); - sscanf(line.c_str(), "%u %24s %u %u", &type, fileNameBuffer, &loop, &volume); + // Parse the type of action. Type 4 actions are MIDI commands, not + // files. These are only used by Zork: Nemesis, for the flute and piano + // puzzles (tj4e and ve6f, as well as vr) + uint type = atoi(tokenizer.nextToken().c_str()); - // Type 4 actions are MIDI commands, not files. These are only used by - // Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well - // as vr) if (type == 4) { _midi = true; - int note; - int prog; - sscanf(line.c_str(), "%u %d %d %u", &type, &prog, ¬e, &volume); - _volume = volume; - _note = note; - _prog = prog; + _prog = atoi(tokenizer.nextToken().c_str()); + _note = atoi(tokenizer.nextToken().c_str()); + _volume = atoi(tokenizer.nextToken().c_str()); + _volumeIsAKey = false; } else { _midi = false; - _fileName = Common::String(fileNameBuffer); - _loop = loop == 1 ? true : false; - - // Volume is optional. If it doesn't appear, assume full volume - if (volume != 255) { - // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] - _volume = volume * 255 / 100; + _fileName = tokenizer.nextToken(); + _loop = atoi(tokenizer.nextToken().c_str()) == 1; + if (!tokenizer.empty()) { + Common::String token = tokenizer.nextToken(); + if (token.contains('[')) { + sscanf(token.c_str(), "[%u]", &_volume); + _volumeIsAKey = true; + } else { + _volume = atoi(token.c_str()); + if (_volume > 100) { + warning("ActionMusic: Adjusting volume for %s from %d to 100", _fileName.c_str(), _volume); + _volume = 100; + } + _volumeIsAKey = false; + } + } else { + // Volume is optional. If it doesn't appear, assume full volume + _volume = 100; + _volumeIsAKey = false; } } } @@ -491,13 +499,22 @@ bool ActionMusic::execute() { _engine->getScriptManager()->setStateValue(_slotKey, 2); } + uint volume; + if (_volumeIsAKey) { + volume = _engine->getScriptManager()->getStateValue(_volume); + } else { + volume = _volume; + } + if (_midi) { - _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume)); + _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, volume)); } else { if (!_engine->getSearchManager()->hasFile(_fileName)) return true; - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, _volume)); + // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] + + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, volume * 255 / 100)); } return true; diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 8d43309b74..cbb91fa8d3 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -224,7 +224,8 @@ public: private: Common::String _fileName; bool _loop; - byte _volume; + uint32 _volume; + bool _volumeIsAKey; bool _universe; bool _midi; int8 _note; -- cgit v1.2.3 From dd5cd42f2eff7ca320fe507916b65a06c3a0ee74 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 26 Jan 2015 22:07:47 +0100 Subject: ZVISION: Use ValueSlot for volume in ActionMusic As suggested by Marisa-Chan. I had based my earlier implementation on parseCritera(), and was unaware of this alternative. The good thing is that the diff from the old code is now much smaller, which should reduce the risk of regressions. (There is a lot I haven't tested here...) --- engines/zvision/scripting/actions.cpp | 64 +++++++++++++++-------------------- engines/zvision/scripting/actions.h | 3 +- 2 files changed, 28 insertions(+), 39 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 81d6655fa9..d851a74dec 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -21,7 +21,6 @@ */ #include "common/scummsys.h" -#include "common/tokenizer.h" #include "video/video_decoder.h" #include "zvision/scripting/actions.h" @@ -446,51 +445,48 @@ bool ActionMenuBarEnable::execute() { ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) : ResultAction(engine, slotkey), - _volume(255), _note(0), _prog(0), _universe(global) { - Common::StringTokenizer tokenizer(line); + uint type = 0; + char fileNameBuffer[25]; + uint loop = 0; + char volumeBuffer[15]; - // Parse the type of action. Type 4 actions are MIDI commands, not - // files. These are only used by Zork: Nemesis, for the flute and piano - // puzzles (tj4e and ve6f, as well as vr) - uint type = atoi(tokenizer.nextToken().c_str()); + // Volume is optional. If it doesn't appear, assume full volume + strcpy(volumeBuffer, "100"); + sscanf(line.c_str(), "%u %24s %u %14s", &type, fileNameBuffer, &loop, volumeBuffer); + + // Type 4 actions are MIDI commands, not files. These are only used by + // Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well + // as vr) if (type == 4) { _midi = true; - _prog = atoi(tokenizer.nextToken().c_str()); - _note = atoi(tokenizer.nextToken().c_str()); - _volume = atoi(tokenizer.nextToken().c_str()); - _volumeIsAKey = false; + int note; + int prog; + sscanf(line.c_str(), "%u %d %d %14s", &type, &prog, ¬e, volumeBuffer); + _volume = new ValueSlot(_engine->getScriptManager(), volumeBuffer); + _note = note; + _prog = prog; } else { _midi = false; - _fileName = tokenizer.nextToken(); - _loop = atoi(tokenizer.nextToken().c_str()) == 1; - if (!tokenizer.empty()) { - Common::String token = tokenizer.nextToken(); - if (token.contains('[')) { - sscanf(token.c_str(), "[%u]", &_volume); - _volumeIsAKey = true; - } else { - _volume = atoi(token.c_str()); - if (_volume > 100) { - warning("ActionMusic: Adjusting volume for %s from %d to 100", _fileName.c_str(), _volume); - _volume = 100; - } - _volumeIsAKey = false; - } - } else { - // Volume is optional. If it doesn't appear, assume full volume - _volume = 100; - _volumeIsAKey = false; + _fileName = Common::String(fileNameBuffer); + _loop = loop == 1 ? true : false; + if (volumeBuffer[0] != '[' && atoi(volumeBuffer) > 100) { + // I thought I saw a case like this in Zork Nemesis, so + // let's guard against it. + warning("ActionMusic: Adjusting volume for %s from %s to 100", _fileName.c_str(), volumeBuffer); + strcpy(volumeBuffer, "100"); } + _volume = new ValueSlot(engine->getScriptManager(), volumeBuffer); } } ActionMusic::~ActionMusic() { if (!_universe) _engine->getScriptManager()->killSideFx(_slotKey); + delete _volume; } bool ActionMusic::execute() { @@ -499,12 +495,7 @@ bool ActionMusic::execute() { _engine->getScriptManager()->setStateValue(_slotKey, 2); } - uint volume; - if (_volumeIsAKey) { - volume = _engine->getScriptManager()->getStateValue(_volume); - } else { - volume = _volume; - } + uint volume = _volume->getValue(); if (_midi) { _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, volume)); @@ -513,7 +504,6 @@ bool ActionMusic::execute() { return true; // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, volume * 255 / 100)); } diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index cbb91fa8d3..94c2d041fc 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -224,8 +224,7 @@ public: private: Common::String _fileName; bool _loop; - uint32 _volume; - bool _volumeIsAKey; + ValueSlot *_volume; bool _universe; bool _midi; int8 _note; -- cgit v1.2.3 From 8c8261aa2a381c3e7f12c5dd0aaf33a69e1f7eb3 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 26 Jan 2015 22:14:26 +0100 Subject: ZVISION: Cleanup. We usually don't check a pointer before deleting it. --- engines/zvision/scripting/actions.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index d851a74dec..5238561149 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -79,8 +79,7 @@ ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String } ActionAssign::~ActionAssign() { - if (_value) - delete _value; + delete _value; } bool ActionAssign::execute() { @@ -804,8 +803,7 @@ ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String } ActionRandom::~ActionRandom() { - if (_max) - delete _max; + delete _max; } bool ActionRandom::execute() { @@ -1044,8 +1042,7 @@ ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &l } ActionTimer::~ActionTimer() { - if (_time) - delete _time; + delete _time; _engine->getScriptManager()->killSideFx(_slotKey); } -- cgit v1.2.3 From f46af2eded0155a05d0e19717e6c4efd1191dab3 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 28 Jan 2015 09:26:45 +0600 Subject: ZVISION: Fix bug #6787 init lzss window by same values as in original game --- engines/zvision/file/lzss_read_stream.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/file/lzss_read_stream.cpp b/engines/zvision/file/lzss_read_stream.cpp index 6f27eaa765..ca10af7d72 100644 --- a/engines/zvision/file/lzss_read_stream.cpp +++ b/engines/zvision/file/lzss_read_stream.cpp @@ -31,8 +31,9 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) // It's convention to set the starting cursor position to blockSize - 16 _windowCursor(0x0FEE), _eosFlag(false) { - // Clear the window to null - memset(_window, 0, BLOCK_SIZE); + // All values up to _windowCursor inits by 0x20 + memset(_window, 0x20, _windowCursor); + memset(_window + _windowCursor, 0, BLOCK_SIZE - _windowCursor); } uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) { -- cgit v1.2.3 From 76eadc75e27ae5cb64b2114835db0bfacd516768 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 31 Jan 2015 19:43:57 +0100 Subject: ZVISION: Add detection for Italian Zork Nemeis (bug #6786) --- engines/zvision/detection.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index b69eee000a..c817cbf3e9 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -111,6 +111,23 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_NEMESIS }, + { + // Zork Nemesis Italian version + { + "znemesis", + 0, + {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, + {"NEMESIS.STR", 0, "7c568feca8d9f9ae855c47183612c305", 9061}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + { // Zork Nemesis English demo version { -- cgit v1.2.3 From bc2c1c6a3c11c10883e21dde1b68aafc9bf42620 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 2 Feb 2015 01:11:53 +0100 Subject: ZVISION: Remove \n from debug message --- engines/zvision/scripting/effects/music_effect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index ee2232d962..2e2084783d 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -111,7 +111,7 @@ MusicNode::~MusicNode() { _engine->getScriptManager()->setStateValue(_key, 2); if (_sub) delete _sub; - debug(1, "MusicNode: %d destroyed\n", _key); + debug(1, "MusicNode: %d destroyed", _key); } void MusicNode::setDeltaVolume(uint8 volume) { -- cgit v1.2.3 From 1adcb23d71a1f1ef6c4bc3b98fb474959fd14462 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 3 Feb 2015 04:15:11 +0200 Subject: ZVISION: Fix bug #6784 (wrong scaling in the fist control) --- engines/zvision/scripting/controls/fist_control.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 4a8e8b1bbd..f79c82dc79 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -105,7 +105,12 @@ bool FistControl::process(uint32 deltaTimeInMillis) { if (_animation->needsUpdate()) { const Graphics::Surface *frameData = _animation->decodeNextFrame(); if (frameData) - _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect); + // WORKAROUND: Ignore the target frame dimensions for the finger animations. + // The target dimensions specify an area smaller than expected, thus if we + // scale the finger videos to fit these dimensions, they are not aligned + // correctly. Not scaling these videos yields a result identical to the + // original. Fixes bug #6784. + _engine->getRenderManager()->blitSurfaceToBkg(*frameData, _anmRect.left, _anmRect.top); } } -- cgit v1.2.3 From 6c07f918c698ff23a917857434200e51179bc111 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 3 Feb 2015 12:31:30 +0200 Subject: ZVISION: Fix for script bug #6783 (no sound in the ZNem fist puzzle) This is a bug in the original game script of the Zork Nemesis fist puzzle, which we now patch so that the sound checks are correct for the left fist animation --- engines/zvision/scripting/scr_file_handling.cpp | 26 +++++++++++++++++++++++-- engines/zvision/scripting/script_manager.h | 3 ++- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index b047c14430..a9f3a55021 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -83,7 +83,7 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre while (!stream.eos() && !line.contains('}')) { if (line.matchString("criteria {", true)) { - parseCriteria(stream, puzzle->criteriaList); + parseCriteria(stream, puzzle->criteriaList, puzzle->key); } else if (line.matchString("results {", true)) { parseResults(stream, puzzle->resultActions); } else if (line.matchString("flags {", true)) { @@ -97,7 +97,7 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre puzzle->addedBySetState = false; } -bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList) const { +bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList, uint32 key) const { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -117,6 +117,21 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li // Create a new List to hold the CriteriaEntries criteriaList.push_back(Common::List()); + // WORKAROUND for a script bug in Zork: Nemesis, room td9e (fist puzzle) + // Since we patch the script that triggers when manipulating the left fist + // (below), we add an additional check for the left fist sound, so that it + // doesn't get killed immediately when the left fist animation starts. + // Together with the workaround below, it fixes bug #6783. + if (_engine->getGameId() == GID_NEMESIS && key == 3594) { + Puzzle::CriteriaEntry entry; + entry.key = 567; + entry.criteriaOperator = Puzzle::NOT_EQUAL_TO; + entry.argumentIsAKey = false; + entry.argument = 1; + + criteriaList.back().push_back(entry); + } + while (!stream.eos() && !line.contains('}')) { Puzzle::CriteriaEntry entry; @@ -128,6 +143,13 @@ bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::Li token = tokenizer.nextToken(); sscanf(token.c_str(), "[%u]", &(entry.key)); + // WORKAROUND for a script bug in Zork: Nemesis, room td9e (fist puzzle) + // Check for the state of animation 567 (left fist) when manipulating + // the fingers of the left fist (puzzle slots 3582, 3583). + // Together with the workaround above, it fixes bug #6783. + if (_engine->getGameId() == GID_NEMESIS && (key == 3582 || key == 3583) && entry.key == 568) + entry.key = 567; + // Parse the operator out of the second token token = tokenizer.nextToken(); if (token.c_str()[0] == '=') diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 6d025bf2e9..d8e3721d43 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -312,9 +312,10 @@ private: * * @param criteria Pointer to the Criteria object to fill * @param stream Scr file stream + * @param key Puzzle key (for workarounds) * @return Whether any criteria were read */ - bool parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList) const; + bool parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList, uint32 key) const; /** * Parses the stream into a ResultAction objects -- cgit v1.2.3 From b7b4e9cc5899eff0810d97a848ace0fa2ede5548 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 8 Feb 2015 10:13:18 +0100 Subject: ZVISION: Draw transparent text in original save dialog Before this change, text was drawn in black boxes in Zork Nemesis, so while this does make it look better (and more like the original) this may actually make the text slightly harder to read. The original dialogs allowed only upper-case letters, but I think that it's better to leave that to the player. --- engines/zvision/scripting/controls/input_control.cpp | 12 +++++++++++- engines/zvision/scripting/controls/input_control.h | 2 ++ engines/zvision/text/text.cpp | 2 -- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 47da27fa08..b25aa13543 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -39,6 +39,7 @@ namespace ZVision { InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) : Control(engine, key, CONTROL_INPUT), + _background(0), _nextTabstop(0), _focused(false), _textChanged(false), @@ -111,6 +112,11 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } } +InputControl::~InputControl() { + _background->free(); + delete _background; +} + bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; @@ -191,12 +197,16 @@ bool InputControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; + if (!_background) { + _background = _engine->getRenderManager()->getBkgRect(_textRectangle); + } + // First see if we need to render the text if (_textChanged) { // Blit the text using the RenderManager Graphics::Surface txt; - txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_resourcePixelFormat); + txt.copyFrom(*_background); if (!_readOnly || !_focused) _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 99f7f5287d..e23ba0b9de 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -38,8 +38,10 @@ namespace ZVision { class InputControl : public Control { public: InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~InputControl(); private: + Graphics::Surface *_background; Common::Rect _textRectangle; Common::Rect _headerRectangle; cTxtStyle _stringInit; diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index e0501ae9c8..4af3b967f3 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -315,8 +315,6 @@ int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Gra StyledTTFont font(_engine); fontStyle.setFont(font); - dst.fillRect(Common::Rect(dst.w, dst.h), 0); - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue); int16 w; -- cgit v1.2.3 From 8725f2cff2357049a3759f24e3fa530c25644e25 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 8 Feb 2015 13:56:01 +0100 Subject: ZVISION: Limit input text to the width of the input control This is to prevent the player from entering ridiculously long savegame descriptions. --- engines/zvision/scripting/controls/input_control.cpp | 14 +++++++++++++- engines/zvision/scripting/controls/input_control.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index b25aa13543..20c8e7ccbc 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -110,6 +110,10 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } + + _maxTxtWidth = _textRectangle.width(); + if (_animation) + _maxTxtWidth -= _animation->getWidth(); } InputControl::~InputControl() { @@ -208,12 +212,20 @@ bool InputControl::process(uint32 deltaTimeInMillis) { Graphics::Surface txt; txt.copyFrom(*_background); + int32 oldTxtWidth = _txtWidth; + if (!_readOnly || !_focused) _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); else _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt); - _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); + if (_readOnly || _txtWidth <= _maxTxtWidth) + _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); + else { + // Assume the last character caused the overflow. + _currentInputText.deleteLastChar(); + _txtWidth = oldTxtWidth; + } txt.free(); } diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index e23ba0b9de..7f272e8d81 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -56,6 +56,7 @@ private: bool _readOnly; int16 _txtWidth; + int16 _maxTxtWidth; Video::VideoDecoder *_animation; int32 _frameDelay; int16 _frame; -- cgit v1.2.3 From cbbd1a92192ad118897f645f1aa6e968bff01466 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 8 Feb 2015 15:47:20 +0100 Subject: ZVISION: Set safe control state value after animation finishes If we set it before the animation starts, the final turn of the wheel won't be animated, because the puzzle will already be solved. --- engines/zvision/scripting/controls/safe_control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 6ba34106d0..4d2a91a1ad 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -123,6 +123,8 @@ bool SafeControl::process(uint32 deltaTimeInMillis) { _animation->seekToFrame(_animation->getCurFrame() - 1); const Graphics::Surface *frameData = _animation->decodeNextFrame(); + if (_animation->getCurFrame() == _targetFrame) + _engine->getScriptManager()->setStateValue(_key, _curState); if (frameData) _engine->getRenderManager()->blitSurfaceToBkg(*frameData, _rectangle.left, _rectangle.top); } @@ -169,8 +171,6 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P _curState = (_statesCount * 2 + tmp2) % _statesCount; _targetFrame = (_curState + _statesCount - _startPointer) % _statesCount; - - _engine->getScriptManager()->setStateValue(_key, _curState); return true; } } -- cgit v1.2.3 From a851fa8e1aef50334402fec65bf89ee8b582ea62 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Wed, 11 Feb 2015 14:57:05 -0600 Subject: ZVISION: Refactor text rendering code in order to fix word wrapping and clarify the logic. Fixes bug #6801 --- engines/zvision/graphics/render_manager.cpp | 2 +- .../zvision/scripting/controls/input_control.cpp | 8 +- engines/zvision/scripting/controls/input_control.h | 4 +- .../zvision/scripting/controls/titler_control.cpp | 2 +- .../zvision/scripting/effects/ttytext_effect.cpp | 40 +- engines/zvision/scripting/effects/ttytext_effect.h | 2 +- engines/zvision/text/text.cpp | 425 +++++++++++---------- engines/zvision/text/text.h | 52 ++- engines/zvision/text/truetype_font.cpp | 60 ++- engines/zvision/text/truetype_font.h | 14 +- 10 files changed, 308 insertions(+), 301 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 3cd9701b7c..8758097c93 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -755,7 +755,7 @@ void RenderManager::processSubs(uint16 deltatime) { if (sub->txt.size()) { Graphics::Surface *rndr = new Graphics::Surface(); rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); - _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); + _engine->getTextRenderer()->drawTextWithWordWrapping(sub->txt, *rndr); Common::Rect empty; blitSurfaceToSurface(*rndr, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); rndr->free(); diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 20c8e7ccbc..df0c77ba96 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -79,13 +79,13 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(values.c_str(), "%u", &fontFormatNumber); - _stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringInit.readAllStyles(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("chooser_init_string", true)) { uint fontFormatNumber; sscanf(values.c_str(), "%u", &fontFormatNumber); - _stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringChooserInit.readAllStyles(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("next_tabstop", true)) { sscanf(values.c_str(), "%u", &_nextTabstop); } else if (param.matchString("cursor_dimensions", true)) { @@ -215,9 +215,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) { int32 oldTxtWidth = _txtWidth; if (!_readOnly || !_focused) - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); + _txtWidth = _engine->getTextRenderer()->drawText(_currentInputText, _stringInit, txt); else - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt); + _txtWidth = _engine->getTextRenderer()->drawText(_currentInputText, _stringChooserInit, txt); if (_readOnly || _txtWidth <= _maxTxtWidth) _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 7f272e8d81..9b48514e16 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -44,8 +44,8 @@ private: Graphics::Surface *_background; Common::Rect _textRectangle; Common::Rect _headerRectangle; - cTxtStyle _stringInit; - cTxtStyle _stringChooserInit; + TextStyleState _stringInit; + TextStyleState _stringChooserInit; uint32 _nextTabstop; bool _focused; diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index 542e0a0b67..683d6660af 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -82,7 +82,7 @@ TitlerControl::~TitlerControl() { void TitlerControl::setString(int strLine) { if (strLine != _curString && strLine >= 0 && strLine < (int)_strings.size()) { _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0); - _engine->getTextRenderer()->drawTxtInOneLine(_strings[strLine], *_surface); + _engine->getTextRenderer()->drawTextWithWordWrapping(_strings[strLine], *_surface); _engine->getRenderManager()->blitSurfaceToBkg(*_surface, _rectangle.left, _rectangle.top); _curString = strLine; } diff --git a/engines/zvision/scripting/effects/ttytext_effect.cpp b/engines/zvision/scripting/effects/ttytext_effect.cpp index c60b3aa8c5..8d340dae39 100644 --- a/engines/zvision/scripting/effects/ttytext_effect.cpp +++ b/engines/zvision/scripting/effects/ttytext_effect.cpp @@ -57,9 +57,9 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file delete infile; } _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat); - _style._sharp = true; - _style.readAllStyle(_txtbuf); - _style.setFont(_fnt); + _state._sharp = true; + _state.readAllStyles(_txtbuf); + _state.updateFontWithTextState(_fnt); _engine->getScriptManager()->setStateValue(_key, 1); } @@ -74,29 +74,27 @@ bool ttyTextNode::process(uint32 deltaTimeInMillis) { if (_nexttime < 0) { if (_txtpos < _txtbuf.size()) { if (_txtbuf[_txtpos] == '<') { - int32 strt = _txtpos; - int32 endt = 0; + int32 start = _txtpos; + int32 end = 0; int16 ret = 0; while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) _txtpos++; - endt = _txtpos; - if (strt != -1) - if ((endt - strt - 1) > 0) - ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); - - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (ret & TXT_RET_FNTCHG) - _style.setFont(_fnt); - if (ret & TXT_RET_FNTSTL) - _style.setFontStyle(_fnt); - - if (ret & TXT_RET_NEWLN) - newline(); + end = _txtpos; + if (start != -1) { + if ((end - start - 1) > 0) { + ret = _state.parseStyle(_txtbuf.c_str() + start + 1, end - start - 1); + } + } + + if (ret & (TEXT_CHANGE_FONT_TYPE | TEXT_CHANGE_FONT_STYLE)) { + _state.updateFontWithTextState(_fnt); + } else if (ret & TEXT_CHANGE_NEWLINE) { + newline(); } - if (ret & TXT_RET_HASSTBOX) { + if (ret & TEXT_CHANGE_HAS_STATE_BOX) { Common::String buf; - buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox)); + buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_state._statebox)); for (uint8 j = 0; j < buf.size(); j++) outchar(buf[j]); @@ -158,7 +156,7 @@ void ttyTextNode::newline() { } void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue); + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_state._red, _state._green, _state._blue); if (_dx + _fnt.getCharWidth(chr) > _r.width()) newline(); diff --git a/engines/zvision/scripting/effects/ttytext_effect.h b/engines/zvision/scripting/effects/ttytext_effect.h index 8d8a2518c7..18cbbbaee3 100644 --- a/engines/zvision/scripting/effects/ttytext_effect.h +++ b/engines/zvision/scripting/effects/ttytext_effect.h @@ -51,7 +51,7 @@ public: private: Common::Rect _r; - cTxtStyle _style; + TextStyleState _state; StyledTTFont _fnt; Common::String _txtbuf; uint32 _txtpos; diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 4af3b967f3..868ee4f1ae 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -38,7 +38,7 @@ namespace ZVision { -cTxtStyle::cTxtStyle() { +TextStyleState::TextStyleState() { _fontname = "Arial"; _blue = 255; _green = 255; @@ -49,7 +49,7 @@ cTxtStyle::cTxtStyle() { _escapement = 0; #endif _italic = false; - _justify = TXT_JUSTIFY_LEFT; + _justification = TEXT_JUSTIFY_LEFT; _size = 12; #if 0 _skipcolor = false; @@ -60,10 +60,10 @@ cTxtStyle::cTxtStyle() { _sharp = false; } -txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { - Common::String buf = Common::String(strin.c_str(), ln); +TextChange TextStyleState::parseStyle(const Common::String &str, int16 len) { + Common::String buf = Common::String(str.c_str(), len); - int8 retval = TXT_RET_NOTHING; + uint retval = TEXT_CHANGE_NONE; Common::StringTokenizer tokenizer(buf, " "); Common::String token; @@ -89,7 +89,7 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) _fontname = token; } - retval |= TXT_RET_FNTCHG; + retval |= TEXT_CHANGE_FONT_TYPE; } else if (token.matchString("blue", true)) { if (!tokenizer.empty()) { @@ -97,7 +97,7 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { int32 tmp = atoi(token.c_str()); if (_blue != tmp) { _blue = tmp; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } else if (token.matchString("red", true)) { @@ -106,7 +106,7 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { int32 tmp = atoi(token.c_str()); if (_red != tmp) { _red = tmp; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } else if (token.matchString("green", true)) { @@ -115,7 +115,7 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { int32 tmp = atoi(token.c_str()); if (_green != tmp) { _green = tmp; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } else if (token.matchString("newline", true)) { @@ -125,14 +125,14 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { _newline++; #endif - retval |= TXT_RET_NEWLN; + retval |= TEXT_CHANGE_NEWLINE; } else if (token.matchString("point", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); if (_size != tmp) { _size = tmp; - retval |= TXT_RET_FNTCHG; + retval |= TEXT_CHANGE_FONT_TYPE; } } } else if (token.matchString("escapement", true)) { @@ -149,12 +149,12 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (token.matchString("on", true)) { if (_italic != true) { _italic = true; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } else if (token.matchString("off", true)) { if (_italic != false) { _italic = false; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } @@ -164,12 +164,12 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (token.matchString("on", true)) { if (_underline != true) { _underline = true; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } else if (token.matchString("off", true)) { if (_underline != false) { _underline = false; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } @@ -179,12 +179,12 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (token.matchString("on", true)) { if (_strikeout != true) { _strikeout = true; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } else if (token.matchString("off", true)) { if (_strikeout != false) { _strikeout = false; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } @@ -194,12 +194,12 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (token.matchString("on", true)) { if (_bold != true) { _bold = true; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } else if (token.matchString("off", true)) { if (_bold != false) { _bold = false; - retval |= TXT_RET_FNTSTL; + retval |= TEXT_CHANGE_FONT_STYLE; } } } @@ -220,24 +220,24 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); _statebox = atoi(token.c_str()); - retval |= TXT_RET_HASSTBOX; + retval |= TEXT_CHANGE_HAS_STATE_BOX; } } else if (token.matchString("justify", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("center", true)) - _justify = TXT_JUSTIFY_CENTER; + _justification = TEXT_JUSTIFY_CENTER; else if (token.matchString("left", true)) - _justify = TXT_JUSTIFY_LEFT; + _justification = TEXT_JUSTIFY_LEFT; else if (token.matchString("right", true)) - _justify = TXT_JUSTIFY_RIGHT; + _justification = TEXT_JUSTIFY_RIGHT; } } } - return (txtReturn)retval; + return (TextChange)retval; } -void cTxtStyle::readAllStyle(const Common::String &txt) { +void TextStyleState::readAllStyles(const Common::String &txt) { int16 startTextPosition = -1; int16 endTextPosition = -1; @@ -246,243 +246,264 @@ void cTxtStyle::readAllStyle(const Common::String &txt) { startTextPosition = i; else if (txt[i] == '>') { endTextPosition = i; - if (startTextPosition != -1) - if ((endTextPosition - startTextPosition - 1) > 0) + if (startTextPosition != -1) { + if ((endTextPosition - startTextPosition - 1) > 0) { parseStyle(Common::String(txt.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1); + } + } } } } -void cTxtStyle::setFontStyle(StyledTTFont &font) { +void TextStyleState::updateFontWithTextState(StyledTTFont &font) { uint tempStyle = 0; - if (_bold) - tempStyle |= StyledTTFont::STTF_BOLD; - - if (_italic) - tempStyle |= StyledTTFont::STTF_ITALIC; - - if (_underline) - tempStyle |= StyledTTFont::STTF_UNDERLINE; - - if (_strikeout) - tempStyle |= StyledTTFont::STTF_STRIKEOUT; - - if (_sharp) - tempStyle |= StyledTTFont::STTF_SHARP; + if (_bold) { + tempStyle |= StyledTTFont::TTF_STYLE_BOLD; + } + if (_italic) { + tempStyle |= StyledTTFont::TTF_STYLE_ITALIC; + } + if (_underline) { + tempStyle |= StyledTTFont::TTF_STYLE_UNDERLINE; + } + if (_strikeout) { + tempStyle |= StyledTTFont::TTF_STYLE_STRIKETHROUGH; + } + if (_sharp) { + tempStyle |= StyledTTFont::TTF_STYLE_SHARP; + } - font.setStyle(tempStyle); + font.loadFont(_fontname, _size, tempStyle); } -void cTxtStyle::setFont(StyledTTFont &font) { - uint tempStyle = 0; - - if (_bold) - tempStyle |= StyledTTFont::STTF_BOLD; +void TextRenderer::drawTextWithJustification(const Common::String &text, StyledTTFont &font, uint32 color, Graphics::Surface &dest, int lineY, TextJustification justify) { + if (justify == TEXT_JUSTIFY_LEFT) + font.drawString(&dest, text, 0, lineY, dest.w, color, Graphics::kTextAlignLeft); + else if (justify == TEXT_JUSTIFY_CENTER) + font.drawString(&dest, text, 0, lineY, dest.w, color, Graphics::kTextAlignCenter); + else if (justify == TEXT_JUSTIFY_RIGHT) + font.drawString(&dest, text, 0, lineY, dest.w, color, Graphics::kTextAlignRight); +} - if (_italic) - tempStyle |= StyledTTFont::STTF_ITALIC; +int32 TextRenderer::drawText(const Common::String &text, TextStyleState &state, Graphics::Surface &dest) { + StyledTTFont font(_engine); + state.updateFontWithTextState(font); - if (_underline) - tempStyle |= StyledTTFont::STTF_UNDERLINE; + uint32 color = _engine->_resourcePixelFormat.RGBToColor(state._red, state._green, state._blue); + drawTextWithJustification(text, font, color, dest, 0, state._justification); - if (_strikeout) - tempStyle |= StyledTTFont::STTF_STRIKEOUT; + return font.getStringWidth(text); +} - if (_sharp) - tempStyle |= StyledTTFont::STTF_SHARP; +struct TextSurface { + TextSurface(Graphics::Surface *surface, Common::Point surfaceOffset, uint lineNumber) + : _surface(surface), + _surfaceOffset(surfaceOffset), + _lineNumber(lineNumber) { + } - font.loadFont(_fontname, _size, tempStyle); -} + Graphics::Surface *_surface; + Common::Point _surfaceOffset; + uint _lineNumber; +}; -Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) { - style.setFontStyle(fnt); - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(style._red, style._green, style._blue); - return fnt.renderSolidText(txt, clr); -} +void TextRenderer::drawTextWithWordWrapping(const Common::String &text, Graphics::Surface &dest) { + Common::Array textSurfaces; + Common::Array lineWidths; + Common::Array lineJustifications; -void TextRenderer::drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { - if (justify == TXT_JUSTIFY_LEFT) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft); - else if (justify == TXT_JUSTIFY_CENTER) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter); - else if (justify == TXT_JUSTIFY_RIGHT) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight); -} + // Create the initial text state + TextStyleState currentState; -int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst) { + // Create an empty font and bind it to the state StyledTTFont font(_engine); - fontStyle.setFont(font); + currentState.updateFontWithTextState(font); - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue); + Common::String currentSentence; // Not a true 'grammatical' sentence. Rather, it's just a collection of words + Common::String currentWord; + int sentenceWidth = 0; + int wordWidth = 0; + int lineWidth = 0; + int lineHeight = font.getFontHeight(); - int16 w; + uint currentLineNumber = 0u; - w = font.getStringWidth(txt); + uint numSpaces = 0u; + int spaceWidth = 0; - drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle._justify); + // The pixel offset to the currentSentence + Common::Point sentencePixelOffset; - return w; -} + uint i = 0u; + uint stringlen = text.size(); -void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { - const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it - const int TXT_CFG_TEXTURES_PER_LINE = 6; - cTxtStyle style, style2; - int16 startTextPosition = -1; - int16 endTextPosition = -1; - int16 i = 0; - int16 dx = 0, dy = 0; - int16 textPixelWidth; - int16 textPosition = 0; - Common::String buf; - Common::String buf2; - - Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE]; - int16 currentline = 0, currentlineitm = 0; - - int TxtJustify[TXT_CFG_TEXTURES_LINES]; - int TxtPoint[TXT_CFG_TEXTURES_LINES]; - - for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) { - TxtPoint[k] = 0; - for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) - TxtSurfaces[k][j] = NULL; - } - - int16 stringlen = text.size(); + while (i < stringlen) { + if (text[i] == '<') { + // Flush the currentWord to the currentSentence + currentSentence += currentWord; + sentenceWidth += wordWidth; + + // Reset the word variables + currentWord.clear(); + wordWidth = 0; + + // Parse the style tag + uint startTextPosition = i; + while (i < stringlen && text[i] != '>') { + ++i; + } + uint endTextPosition = i; - StyledTTFont font(_engine); + uint32 textColor = currentState.getTextColor(_engine); - style.setFont(font); + uint stateChanges = 0u; + if ((endTextPosition - startTextPosition - 1) > 0) { + stateChanges = currentState.parseStyle(Common::String(text.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1); + } - int16 prevbufspace = 0, prevtxtspace = 0; + if (stateChanges & (TEXT_CHANGE_FONT_TYPE | TEXT_CHANGE_FONT_STYLE)) { + // Use the last state to render out the current sentence + // Styles apply to the text 'after' them + if (!currentSentence.empty()) { + textSurfaces.push_back(TextSurface(font.renderSolidText(currentSentence, textColor), sentencePixelOffset, currentLineNumber)); - while (i < stringlen) { - TxtJustify[currentline] = style._justify; - if (text[i] == '<') { - int16 ret = 0; + lineWidth += sentenceWidth; + sentencePixelOffset.x += sentenceWidth; - startTextPosition = i; - while (i < stringlen && text[i] != '>') - i++; - endTextPosition = i; - if (startTextPosition != -1) - if ((endTextPosition - startTextPosition - 1) > 0) { - style2 = style; - ret = style.parseStyle(Common::String(text.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1); + // Reset the sentence variables + currentSentence.clear(); + sentenceWidth = 0; } - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (buf.size() > 0) { - textPixelWidth = font.getStringWidth(buf); + // Update the current state with the style information + currentState.updateFontWithTextState(font); + + lineHeight = MAX(lineHeight, font.getFontHeight()); + spaceWidth = font.getCharWidth(' '); + } + if (stateChanges & TEXT_CHANGE_NEWLINE) { + // If the current sentence has content, render it out + if (!currentSentence.empty()) { + textSurfaces.push_back(TextSurface(font.renderSolidText(currentSentence, textColor), sentencePixelOffset, currentLineNumber)); + } + + // Set line width + lineWidths.push_back(lineWidth + sentenceWidth - (numSpaces * spaceWidth)); + + currentSentence.clear(); + sentenceWidth = 0; + + // Update the offsets + sentencePixelOffset.x = 0u; + sentencePixelOffset.y += lineHeight; + + // Reset the line variables + lineHeight = font.getFontHeight(); + lineWidth = 0; + ++currentLineNumber; + lineJustifications.push_back(currentState._justification); + } + if (stateChanges & TEXT_CHANGE_HAS_STATE_BOX) { + Common::String temp = Common::String::format("%d", _engine->getScriptManager()->getStateValue(currentState._statebox)); + wordWidth += font.getStringWidth(temp); - TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + // If the word causes the line to overflow, render the sentence and start a new line + if (lineWidth + sentenceWidth + wordWidth > dest.w) { + textSurfaces.push_back(TextSurface(font.renderSolidText(currentSentence, textColor), sentencePixelOffset, currentLineNumber)); - currentlineitm++; + // Set line width + lineWidths.push_back(lineWidth + sentenceWidth - (numSpaces * spaceWidth)); - buf.clear(); - prevbufspace = 0; - textPosition = 0; - dx += textPixelWidth; + currentSentence.clear(); + sentenceWidth = 0; - } - if (ret & TXT_RET_FNTCHG) { - style.setFont(font); - } - if (ret & TXT_RET_FNTSTL) - style.setFontStyle(font); + // Update the offsets + sentencePixelOffset.x = 0u; + sentencePixelOffset.y += lineHeight; - if (ret & TXT_RET_NEWLN) { - currentline++; - currentlineitm = 0; - dx = 0; + // Reset the line variables + lineHeight = font.getFontHeight(); + lineWidth = 0; + ++currentLineNumber; + lineJustifications.push_back(currentState._justification); } } - - if (ret & TXT_RET_HASSTBOX) { - Common::String buf3; - buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style._statebox)); - buf += buf3; - textPosition += buf3.size(); - } - } else { - - buf += text[i]; - textPosition++; + currentWord += text[i]; + wordWidth += font.getCharWidth(text[i]); if (text[i] == ' ') { - prevbufspace = textPosition - 1; - prevtxtspace = i; - } + // When we hit the first space, flush the current word to the sentence + if (!currentWord.empty()) { + currentSentence += currentWord; + sentenceWidth += wordWidth; - if (font.isLoaded()) { - textPixelWidth = font.getStringWidth(buf); - if (textPixelWidth + dx > dst.w) { - if (prevbufspace == 0) { - prevtxtspace = i; - prevbufspace = textPosition - 1; - } - buf2 = Common::String(buf.c_str(), prevbufspace + 1); + currentWord.clear(); + wordWidth = 0; + } - if (buf2.size() > 0) { - TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + // We track the number of spaces so we can disregard their width in lineWidth calculations + ++numSpaces; + } else { + // If the word causes the line to overflow, render the sentence and start a new line + if (lineWidth + sentenceWidth + wordWidth > dest.w) { + // Only render out content + if (!currentSentence.empty()) { + textSurfaces.push_back(TextSurface(font.renderSolidText(currentSentence, currentState.getTextColor(_engine)), sentencePixelOffset, currentLineNumber)); } - buf.clear(); - i = prevtxtspace; - prevbufspace = 0; - textPosition = 0; - currentline++; - currentlineitm = 0; - dx = 0; + // Set line width + lineWidths.push_back(lineWidth + sentenceWidth - (numSpaces * spaceWidth)); + + currentSentence.clear(); + sentenceWidth = 0; + + // Update the offsets + sentencePixelOffset.x = 0u; + sentencePixelOffset.y += lineHeight; + + // Reset the line variables + lineHeight = font.getFontHeight(); + lineWidth = 0; + ++currentLineNumber; + lineJustifications.push_back(currentState._justification); } + + numSpaces = 0u; } } + i++; } - if (buf.size() > 0) { - TxtSurfaces[currentline][currentlineitm] = render(font, buf, style); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + // Render out any remaining words/sentences + if (!currentWord.empty() || !currentSentence.empty()) { + currentSentence += currentWord; + sentenceWidth += wordWidth; + + textSurfaces.push_back(TextSurface(font.renderSolidText(currentSentence, currentState.getTextColor(_engine)), sentencePixelOffset, currentLineNumber)); } - dy = 0; - for (i = 0; i <= currentline; i++) { - int16 j = 0; - int16 width = 0; - while (TxtSurfaces[i][j] != NULL) { - width += TxtSurfaces[i][j]->w; - j++; - } - dx = 0; - Common::Rect empty; - for (int32 jj = 0; jj < j; jj++) { - if (TxtJustify[i] == TXT_JUSTIFY_LEFT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); - - else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + lineWidths.push_back(lineWidth + sentenceWidth); + lineJustifications.push_back(currentState._justification); - else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + for (Common::Array::iterator iter = textSurfaces.begin(); iter != textSurfaces.end(); ++iter) { + Common::Rect empty; - dx += TxtSurfaces[i][jj]->w; + if (lineJustifications[iter->_lineNumber] == TEXT_JUSTIFY_LEFT) { + _engine->getRenderManager()->blitSurfaceToSurface(*iter->_surface, empty, dest, iter->_surfaceOffset.x, iter->_surfaceOffset.y, 0); + } else if (lineJustifications[iter->_lineNumber] == TEXT_JUSTIFY_CENTER) { + _engine->getRenderManager()->blitSurfaceToSurface(*iter->_surface, empty, dest, ((dest.w - lineWidths[iter->_lineNumber]) / 2) + iter->_surfaceOffset.x, iter->_surfaceOffset.y, 0); + } else if (lineJustifications[iter->_lineNumber] == TEXT_JUSTIFY_RIGHT) { + _engine->getRenderManager()->blitSurfaceToSurface(*iter->_surface, empty, dest, dest.w - lineWidths[iter->_lineNumber] + iter->_surfaceOffset.x, iter->_surfaceOffset.y, 0); } - dy += TxtPoint[i]; + // Release memory + iter->_surface->free(); + delete iter->_surface; } - - for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++) - for (int32 j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) - if (TxtSurfaces[i][j] != NULL) { - TxtSurfaces[i][j]->free(); - delete TxtSurfaces[i][j]; - } } Common::String readWideLine(Common::SeekableReadStream &stream) { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index c942b8141a..d35b90499d 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -32,59 +32,53 @@ namespace ZVision { class ZVision; -enum txtJustify { - TXT_JUSTIFY_CENTER = 0, - TXT_JUSTIFY_LEFT = 1, - TXT_JUSTIFY_RIGHT = 2 +enum TextJustification { + TEXT_JUSTIFY_CENTER = 0, + TEXT_JUSTIFY_LEFT = 1, + TEXT_JUSTIFY_RIGHT = 2 }; -enum txtReturn { - TXT_RET_NOTHING = 0x0, - TXT_RET_FNTCHG = 0x1, - TXT_RET_FNTSTL = 0x2, - TXT_RET_NEWLN = 0x4, - TXT_RET_HASSTBOX = 0x8 +enum TextChange { + TEXT_CHANGE_NONE = 0x0, + TEXT_CHANGE_FONT_TYPE = 0x1, + TEXT_CHANGE_FONT_STYLE = 0x2, + TEXT_CHANGE_NEWLINE = 0x4, + TEXT_CHANGE_HAS_STATE_BOX = 0x8 }; -class cTxtStyle { +class TextStyleState { public: - cTxtStyle(); - txtReturn parseStyle(const Common::String &strin, int16 len); - void readAllStyle(const Common::String &txt); - void setFontStyle(StyledTTFont &font); - void setFont(StyledTTFont &font); + TextStyleState(); + TextChange parseStyle(const Common::String &str, int16 len); + void readAllStyles(const Common::String &txt); + void updateFontWithTextState(StyledTTFont &font); + + uint32 getTextColor(ZVision *engine) { + return engine->_resourcePixelFormat.RGBToColor(_red, _green, _blue); + } public: Common::String _fontname; - txtJustify _justify; // 0 - center, 1-left, 2-right + TextJustification _justification; // 0 - center, 1-left, 2-right int16 _size; uint8 _red; // 0-255 uint8 _green; // 0-255 uint8 _blue; // 0-255 -#if 0 - int8 _newline; - int8 _escapement; -#endif bool _italic; bool _bold; bool _underline; bool _strikeout; -#if 0 - bool _skipcolor; -#endif int32 _statebox; bool _sharp; - // char image ?? }; class TextRenderer { public: TextRenderer(ZVision *engine): _engine(engine) {}; - void drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); - int32 drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst); - Graphics::Surface *render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style); - void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst); + void drawTextWithJustification(const Common::String &text, StyledTTFont &font, uint32 color, Graphics::Surface &dest, int lineY, TextJustification jusification); + int32 drawText(const Common::String &text, TextStyleState &state, Graphics::Surface &dest); + void drawTextWithWordWrapping(const Common::String &text, Graphics::Surface &dest); private: ZVision *_engine; diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index f7580fb553..8e402efc08 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -56,21 +56,23 @@ const FontStyle getSystemFont(int fontIndex) { StyledTTFont::StyledTTFont(ZVision *engine) { _engine = engine; _style = 0; - _font = NULL; + _font = nullptr; _lineHeight = 0; } StyledTTFont::~StyledTTFont() { - if (_font) - delete _font; + delete _font; } bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { _style = style; - return loadFont(fontName, point); -} -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + // Don't re-load the font if we've already loaded it + // We have to check for empty so we can default to Arial + if (!fontName.empty() && _fontName.equalsIgnoreCase(fontName)) { + return true; + } + Common::String newFontName; Common::String freeFontName; Common::String liberationFontName; @@ -82,16 +84,16 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { freeFontName = curFont.freeFontBase; liberationFontName = curFont.liberationFontBase; - if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { + if ((_style & TTF_STYLE_BOLD) && (_style & TTF_STYLE_ITALIC)) { newFontName += "bi"; freeFontName += "Bold"; freeFontName += curFont.freeFontItalicName; liberationFontName += "-BoldItalic"; - } else if (_style & STTF_BOLD) { + } else if (_style & TTF_STYLE_BOLD) { newFontName += "bd"; freeFontName += "Bold"; liberationFontName += "-Bold"; - } else if (_style & STTF_ITALIC) { + } else if (_style & TTF_STYLE_ITALIC) { newFontName += "i"; freeFontName += curFont.freeFontItalicName; liberationFontName += "-Italic"; @@ -113,7 +115,7 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { liberationFontName = "LiberationSans-Regular.ttf"; } - bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + bool sharp = (_style & TTF_STYLE_SHARP) == TTF_STYLE_SHARP; Common::File file; if (!file.open(newFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && @@ -121,51 +123,45 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) error("Unable to open font file %s (Liberation Font alternative: %s, FreeFont alternative: %s)", newFontName.c_str(), liberationFontName.c_str(), freeFontName.c_str()); - Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; + Graphics::Font *newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (newFont == nullptr) { + return false; } - _fntName = fontName; - _lineHeight = point; + delete _font; + _font = newFont; - if (_font) - return true; - return false; -} + _fontName = fontName; + _lineHeight = point; -void StyledTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { - _style = newStyle; - loadFont(_fntName, _lineHeight); - } else { - _style = newStyle; - } + return true; } int StyledTTFont::getFontHeight() { if (_font) return _font->getFontHeight(); + return 0; } int StyledTTFont::getMaxCharWidth() { if (_font) return _font->getMaxCharWidth(); + return 0; } int StyledTTFont::getCharWidth(byte chr) { if (_font) return _font->getCharWidth(chr); + return 0; } int StyledTTFont::getKerningOffset(byte left, byte right) { if (_font) return _font->getKerningOffset(left, right); + return 0; } @@ -202,12 +198,12 @@ Common::U32String StyledTTFont::convertUtf8ToUtf32(const Common::String &str) { void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { if (_font) { _font->drawChar(dst, chr, x, y, color); - if (_style & STTF_UNDERLINE) { + if (_style & TTF_STYLE_UNDERLINE) { int16 pos = floor(_font->getFontHeight() * 0.87); int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); } - if (_style & STTF_STRIKEOUT) { + if (_style & TTF_STYLE_STRIKETHROUGH) { int16 pos = floor(_font->getFontHeight() * 0.60); int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); @@ -219,7 +215,7 @@ void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, if (_font) { Common::U32String u32str = convertUtf8ToUtf32(str); _font->drawString(dst, u32str, x, y, w, color, align); - if (_style & STTF_UNDERLINE) { + if (_style & TTF_STYLE_UNDERLINE) { int16 pos = floor(_font->getFontHeight() * 0.87); int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; @@ -232,7 +228,7 @@ void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); } - if (_style & STTF_STRIKEOUT) { + if (_style & TTF_STYLE_STRIKETHROUGH) { int16 pos = floor(_font->getFontHeight() * 0.60); int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h index caa9c09a76..6abe05cda6 100644 --- a/engines/zvision/text/truetype_font.h +++ b/engines/zvision/text/truetype_font.h @@ -53,11 +53,11 @@ public: ~StyledTTFont(); enum { - STTF_BOLD = 1, - STTF_ITALIC = 2, - STTF_UNDERLINE = 4, - STTF_STRIKEOUT = 8, - STTF_SHARP = 16 + TTF_STYLE_BOLD = 0x01, + TTF_STYLE_ITALIC = 0x02, + TTF_STYLE_UNDERLINE = 0x04, + TTF_STYLE_STRIKETHROUGH = 0x08, + TTF_STYLE_SHARP = 0x10 }; private: @@ -65,12 +65,10 @@ private: Graphics::Font *_font; int _lineHeight; uint _style; - Common::String _fntName; + Common::String _fontName; public: - bool loadFont(const Common::String &fontName, int32 point); bool loadFont(const Common::String &fontName, int32 point, uint style); - void setStyle(uint newStyle); int getFontHeight(); int getMaxCharWidth(); -- cgit v1.2.3 From cff81cd70cbd2453619f43ec0e3cc5cab826d91e Mon Sep 17 00:00:00 2001 From: RichieSams Date: Wed, 11 Feb 2015 15:01:46 -0600 Subject: ZVISION: Remove forced render to screen timedMessage() is always called from the scripting system. Which is updated before the rendering system. Therefore, the message will already be rendered this frame, when the renderingManager->update() is called. --- engines/zvision/graphics/render_manager.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 8758097c93..b8fa16bc1b 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -971,8 +971,6 @@ void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) { void RenderManager::timedMessage(const Common::String &str, uint16 milsecs) { uint16 msgid = createSubArea(); updateSubArea(msgid, str); - processSubs(0); - renderSceneToScreen(); deleteSubArea(msgid, milsecs); } -- cgit v1.2.3 From 8ecc5e52c5ad49d9fe40490d666d47349569d151 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Wed, 11 Feb 2015 15:03:21 -0600 Subject: ZVISION: Handle question text rendering manually, rather than forcing an entire screen refresh --- engines/zvision/graphics/render_manager.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index b8fa16bc1b..67410b4b6a 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -975,10 +975,11 @@ void RenderManager::timedMessage(const Common::String &str, uint16 milsecs) { } bool RenderManager::askQuestion(const Common::String &str) { - uint16 msgid = createSubArea(); - updateSubArea(msgid, str); - processSubs(0); - renderSceneToScreen(); + Graphics::Surface textSurface; + textSurface.create(_subtitleArea.width(), _subtitleArea.height(), _engine->_resourcePixelFormat); + _engine->getTextRenderer()->drawTextWithWordWrapping(str, textSurface); + copyToScreen(textSurface, _subtitleArea, 0, 0); + _engine->stopClock(); int result = 0; @@ -1029,7 +1030,14 @@ bool RenderManager::askQuestion(const Common::String &str) { else _system->delayMillis(66); } - deleteSubArea(msgid); + + // Draw over the text in order to clear it + textSurface.fillRect(Common::Rect(_subtitleArea.width(), _subtitleArea.height()), 0); + copyToScreen(textSurface, _subtitleArea, 0, 0); + + // Free the surface + textSurface.free(); + _engine->startClock(); return result == 2; } -- cgit v1.2.3 From 2d2cfbe005b93397f1e121888b0358e137ccc863 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Wed, 11 Feb 2015 15:08:32 -0600 Subject: ZVISION: Create temporary subtitle surfaces on the stack rather than the heap --- engines/zvision/graphics/render_manager.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 67410b4b6a..3772d5909e 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -753,13 +753,12 @@ void RenderManager::processSubs(uint16 deltatime) { for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { OneSubtitle *sub = &it->_value; if (sub->txt.size()) { - Graphics::Surface *rndr = new Graphics::Surface(); - rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); - _engine->getTextRenderer()->drawTextWithWordWrapping(sub->txt, *rndr); + Graphics::Surface subtitleSurface; + subtitleSurface.create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); + _engine->getTextRenderer()->drawTextWithWordWrapping(sub->txt, subtitleSurface); Common::Rect empty; - blitSurfaceToSurface(*rndr, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); - rndr->free(); - delete rndr; + blitSurfaceToSurface(subtitleSurface, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); + subtitleSurface.free(); } sub->redraw = false; } -- cgit v1.2.3 From 14914b2a31399ceb6b2e4d7616535e346ee3acd6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Feb 2015 14:45:08 +0200 Subject: ZVISION: Add custom equality operators for game location This makes the location checks more readable --- engines/zvision/core/events.cpp | 2 +- engines/zvision/scripting/effects/music_effect.cpp | 3 +-- engines/zvision/scripting/script_manager.cpp | 7 +++---- engines/zvision/scripting/script_manager.h | 22 ++++++++++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 9cf5d04a7a..cc1c00b6d0 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -152,7 +152,7 @@ void ZVision::cheatCodes(uint8 key) { if (checkCode("HELLOSAILOR")) { Audio::AudioStream *soundStream; - if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { + if (loc == "vb10") { soundStream = makeRawZorkStream("v000hpta.raw", this); } else { soundStream = makeRawZorkStream("v000hnta.raw", this); diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index 2e2084783d..ad3c0f6d22 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -227,8 +227,7 @@ bool PanTrackNode::process(uint32 deltaTimeInMillis) { int volumeCorrection = 2; if (_engine->getGameId() == GID_GRANDINQUISITOR) { - Location loc = scriptManager->getCurrentLocation(); - if (loc.world == 'd' && loc.room == 'c' && loc.node == '1' && loc.view == '0') + if (scriptManager->getCurrentLocation() == "dc10") volumeCorrection = 5; } diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 71966b3125..70eaab2a0a 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -72,8 +72,7 @@ void ScriptManager::initialize() { } void ScriptManager::update(uint deltaTimeMillis) { - if (_currentLocation.node != _nextLocation.node || _currentLocation.room != _nextLocation.room || - _currentLocation.view != _nextLocation.view || _currentLocation.world != _nextLocation.world) { + if (_currentLocation != _nextLocation) { ChangeLocationReal(false); } @@ -543,7 +542,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi _nextLocation.view = _view; _nextLocation.offset = offset; // If next location is 0000, return to the previous location. - if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') { + if (_nextLocation == "0000") { if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { _nextLocation.world = getStateValue(StateKey_LastWorld); _nextLocation.room = getStateValue(StateKey_LastRoom); @@ -680,7 +679,7 @@ void ScriptManager::ChangeLocationReal(bool isLoading) { // Change the background position _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); - if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) { + if (_currentLocation == "0000") { _currentLocation = _nextLocation; execScope(world); execScope(room); diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index d8e3721d43..7c276bf917 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -113,6 +113,28 @@ struct Location { uint32 offset; }; +inline bool operator==(const Location& lhs, const Location& rhs) { + return ( + lhs.world == rhs.world && + lhs.room == rhs.room && + lhs.node == rhs.node && + lhs.view == rhs.view + ); +} + +inline bool operator==(const Location& lhs, const char* rhs) { + Common::String lhsStr = Common::String::format("%c%c%c%c", lhs.world, lhs.room, lhs.node, lhs.view); + return lhsStr == rhs; +} + +inline bool operator!=(const Location& lhs, const Location& rhs) { + return !(lhs == rhs); +} + +inline bool operator!=(const Location& lhs, const char* rhs) { + return !(lhs == rhs); +} + typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; -- cgit v1.2.3 From 60c06b84b68a5711db442d8fd296f3978d685da5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Feb 2015 14:55:09 +0200 Subject: ZVISION: Fix script bug #6794 - "ZVISION: Yoruk's coffin instant death" Fixes an edge case where the player goes to the dark room with the grue without holding a torch, and then quickly runs away before the grue's sound effect finishes. Many thanks to eriktorbjorn for the original workaround --- engines/zvision/scripting/actions.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 5238561149..248ebaec49 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -480,6 +480,14 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l } _volume = new ValueSlot(engine->getScriptManager(), volumeBuffer); } + + // WORKAROUND for a script bug in Zork Nemesis, rooms mq70/mq80. + // Fixes an edge case where the player goes to the dark room with the grue + // without holding a torch, and then quickly runs away before the grue's + // sound effect finishes. Fixes script bug #6794. + if (engine->getGameId() == GID_NEMESIS && _slotKey == 14822 && engine->getScriptManager()->getStateValue(_slotKey) == 2) + engine->getScriptManager()->setStateValue(_slotKey, 0); + } ActionMusic::~ActionMusic() { -- cgit v1.2.3 From 9ce285a11e1bfc981c518e89f2401b1896b4a367 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Feb 2015 15:07:15 +0200 Subject: ZVISION: Also reference the script manager in ResultAction members --- engines/zvision/scripting/actions.cpp | 127 +++++++++++++++++----------------- engines/zvision/scripting/actions.h | 4 +- 2 files changed, 68 insertions(+), 63 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 248ebaec49..90d32e47ce 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -47,6 +47,9 @@ namespace ZVision { +ResultAction::ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey), _scriptManager(engine->getScriptManager()) { +} + ////////////////////////////////////////////////////////////////////////////// // ActionAdd ////////////////////////////////////////////////////////////////////////////// @@ -60,7 +63,7 @@ ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) } bool ActionAdd::execute() { - _engine->getScriptManager()->setStateValue(_key, _engine->getScriptManager()->getStateValue(_key) + _value); + _scriptManager->setStateValue(_key, _scriptManager->getStateValue(_key) + _value); return true; } @@ -75,7 +78,7 @@ ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String char buf[64]; memset(buf, 0, 64); sscanf(line.c_str(), "%u, %s", &_key, buf); - _value = new ValueSlot(_engine->getScriptManager(), buf); + _value = new ValueSlot(_scriptManager, buf); } ActionAssign::~ActionAssign() { @@ -83,7 +86,7 @@ ActionAssign::~ActionAssign() { } bool ActionAssign::execute() { - _engine->getScriptManager()->setStateValue(_key, _value->getValue()); + _scriptManager->setStateValue(_key, _value->getValue()); return true; } @@ -100,7 +103,7 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S } bool ActionAttenuate::execute() { - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key); + ScriptingEffect *fx = _scriptManager->getSideFX(_key); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNodeBASE *mus = (MusicNodeBASE *)fx; mus->setVolume(255 * (10000 - abs(_attenuation)) / 10000 ); @@ -125,7 +128,7 @@ ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const bool ActionChangeLocation::execute() { // We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking - _engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset); + _scriptManager->changeLocation(_world, _room, _node, _view, _offset); // Tell the puzzle system to stop checking any more puzzles return false; } @@ -151,7 +154,7 @@ ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::S bool ActionCrossfade::execute() { if (_keyOne) { - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne); + ScriptingEffect *fx = _scriptManager->getSideFX(_keyOne); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNodeBASE *mus = (MusicNodeBASE *)fx; if (_oneStartVolume >= 0) @@ -162,7 +165,7 @@ bool ActionCrossfade::execute() { } if (_keyTwo) { - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo); + ScriptingEffect *fx = _scriptManager->getSideFX(_keyTwo); if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNodeBASE *mus = (MusicNodeBASE *)fx; if (_twoStartVolume >= 0) @@ -233,7 +236,7 @@ ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const } bool ActionDisableControl::execute() { - _engine->getScriptManager()->setStateFlag(_key, Puzzle::DISABLED); + _scriptManager->setStateFlag(_key, Puzzle::DISABLED); return true; } @@ -250,7 +253,7 @@ ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const } bool ActionDisplayMessage::execute() { - Control *ctrl = _engine->getScriptManager()->getControl(_control); + Control *ctrl = _scriptManager->getControl(_control); if (ctrl && ctrl->getType() == Control::CONTROL_TITLER) { TitlerControl *titler = (TitlerControl *)ctrl; titler->setString(_msgid); @@ -289,14 +292,14 @@ ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::Strin } ActionDistort::~ActionDistort() { - _engine->getScriptManager()->killSideFx(_distSlot); + _scriptManager->killSideFx(_distSlot); } bool ActionDistort::execute() { - if (_engine->getScriptManager()->getSideFX(_distSlot)) + if (_scriptManager->getSideFX(_distSlot)) return true; - _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _startAngle, _endAngle, _startLineScale, _endLineScale)); + _scriptManager->addSideFX(new DistortNode(_engine, _distSlot, _speed, _startAngle, _endAngle, _startLineScale, _endLineScale)); return true; } @@ -313,7 +316,7 @@ ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const C } bool ActionEnableControl::execute() { - _engine->getScriptManager()->unsetStateFlag(_key, Puzzle::DISABLED); + _scriptManager->unsetStateFlag(_key, Puzzle::DISABLED); return true; } @@ -326,8 +329,8 @@ ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotkey) : } bool ActionFlushMouseEvents::execute() { - _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONUP); - _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONDOWN); + _scriptManager->flushEvent(Common::EVENT_LBUTTONUP); + _scriptManager->flushEvent(Common::EVENT_LBUTTONDOWN); return true; } @@ -360,22 +363,22 @@ ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::S bool ActionInventory::execute() { switch (_type) { case 0: // add - _engine->getScriptManager()->inventoryAdd(_key); + _scriptManager->inventoryAdd(_key); break; case 1: // addi - _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(_key)); + _scriptManager->inventoryAdd(_scriptManager->getStateValue(_key)); break; case 2: // drop if (_key >= 0) - _engine->getScriptManager()->inventoryDrop(_key); + _scriptManager->inventoryDrop(_key); else - _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem)); + _scriptManager->inventoryDrop(_scriptManager->getStateValue(StateKey_InventoryItem)); break; case 3: // dropi - _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(_key)); + _scriptManager->inventoryDrop(_scriptManager->getStateValue(_key)); break; case 4: // cycle - _engine->getScriptManager()->inventoryCycle(); + _scriptManager->inventoryCycle(); break; default: break; @@ -416,9 +419,9 @@ ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &lin bool ActionKill::execute() { if (_type) - _engine->getScriptManager()->killSideFxType((ScriptingEffect::ScriptingEffectType)_type); + _scriptManager->killSideFxType((ScriptingEffect::ScriptingEffectType)_type); else - _engine->getScriptManager()->killSideFx(_key); + _scriptManager->killSideFx(_key); return true; } @@ -465,7 +468,7 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l int note; int prog; sscanf(line.c_str(), "%u %d %d %14s", &type, &prog, ¬e, volumeBuffer); - _volume = new ValueSlot(_engine->getScriptManager(), volumeBuffer); + _volume = new ValueSlot(_scriptManager, volumeBuffer); _note = note; _prog = prog; } else { @@ -478,40 +481,40 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l warning("ActionMusic: Adjusting volume for %s from %s to 100", _fileName.c_str(), volumeBuffer); strcpy(volumeBuffer, "100"); } - _volume = new ValueSlot(engine->getScriptManager(), volumeBuffer); + _volume = new ValueSlot(_scriptManager, volumeBuffer); } // WORKAROUND for a script bug in Zork Nemesis, rooms mq70/mq80. // Fixes an edge case where the player goes to the dark room with the grue // without holding a torch, and then quickly runs away before the grue's // sound effect finishes. Fixes script bug #6794. - if (engine->getGameId() == GID_NEMESIS && _slotKey == 14822 && engine->getScriptManager()->getStateValue(_slotKey) == 2) - engine->getScriptManager()->setStateValue(_slotKey, 0); + if (engine->getGameId() == GID_NEMESIS && _slotKey == 14822 && _scriptManager->getStateValue(_slotKey) == 2) + _scriptManager->setStateValue(_slotKey, 0); } ActionMusic::~ActionMusic() { if (!_universe) - _engine->getScriptManager()->killSideFx(_slotKey); + _scriptManager->killSideFx(_slotKey); delete _volume; } bool ActionMusic::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) { - _engine->getScriptManager()->killSideFx(_slotKey); - _engine->getScriptManager()->setStateValue(_slotKey, 2); + if (_scriptManager->getSideFX(_slotKey)) { + _scriptManager->killSideFx(_slotKey); + _scriptManager->setStateValue(_slotKey, 2); } uint volume = _volume->getValue(); if (_midi) { - _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, volume)); + _scriptManager->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, volume)); } else { if (!_engine->getSearchManager()->hasFile(_fileName)) return true; // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, volume * 255 / 100)); + _scriptManager->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, volume * 255 / 100)); } return true; @@ -530,14 +533,14 @@ ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::Str } ActionPanTrack::~ActionPanTrack() { - _engine->getScriptManager()->killSideFx(_slotKey); + _scriptManager->killSideFx(_slotKey); } bool ActionPanTrack::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) + if (_scriptManager->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotKey, _musicSlot, _pos)); + _scriptManager->addSideFX(new PanTrackNode(_engine, _slotKey, _musicSlot, _pos)); return true; } @@ -587,18 +590,18 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c } ActionPreloadAnimation::~ActionPreloadAnimation() { - _engine->getScriptManager()->deleteSideFx(_slotKey); + _scriptManager->deleteSideFx(_slotKey); } bool ActionPreloadAnimation::execute() { - AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey); + AnimationEffect *nod = (AnimationEffect *)_scriptManager->getSideFX(_slotKey); if (!nod) { nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate, false); - _engine->getScriptManager()->addSideFX(nod); + _scriptManager->addSideFX(nod); } else nod->stop(); - _engine->getScriptManager()->setStateValue(_slotKey, 2); + _scriptManager->setStateValue(_slotKey, 2); return true; } @@ -614,10 +617,10 @@ ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, con } bool ActionUnloadAnimation::execute() { - AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_key); + AnimationEffect *nod = (AnimationEffect *)_scriptManager->getSideFX(_key); if (nod && nod->getType() == ScriptingEffect::SCRIPTING_EFFECT_ANIM) - _engine->getScriptManager()->deleteSideFx(_key); + _scriptManager->deleteSideFx(_key); return true; } @@ -662,15 +665,15 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C } ActionPlayAnimation::~ActionPlayAnimation() { - _engine->getScriptManager()->deleteSideFx(_slotKey); + _scriptManager->deleteSideFx(_slotKey); } bool ActionPlayAnimation::execute() { - AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey); + AnimationEffect *nod = (AnimationEffect *)_scriptManager->getSideFX(_slotKey); if (!nod) { nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate); - _engine->getScriptManager()->addSideFX(nod); + _scriptManager->addSideFX(nod); } else nod->stop(); @@ -701,7 +704,7 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 sl } bool ActionPlayPreloadAnimation::execute() { - AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_controlKey); + AnimationEffect *nod = (AnimationEffect *)_scriptManager->getSideFX(_controlKey); if (nod) nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); @@ -742,11 +745,11 @@ ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String } ActionRegion::~ActionRegion() { - _engine->getScriptManager()->killSideFx(_slotKey); + _scriptManager->killSideFx(_slotKey); } bool ActionRegion::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) + if (_scriptManager->getSideFX(_slotKey)) return true; GraphicsEffect *effect = NULL; @@ -791,7 +794,7 @@ bool ActionRegion::execute() { } if (effect) { - _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effect, _delay)); + _scriptManager->addSideFX(new RegionNode(_engine, _slotKey, effect, _delay)); _engine->getRenderManager()->addEffect(effect); } @@ -807,7 +810,7 @@ ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String char maxBuffer[64]; memset(maxBuffer, 0, 64); sscanf(line.c_str(), "%s", maxBuffer); - _max = new ValueSlot(_engine->getScriptManager(), maxBuffer); + _max = new ValueSlot(_scriptManager, maxBuffer); } ActionRandom::~ActionRandom() { @@ -816,7 +819,7 @@ ActionRandom::~ActionRandom() { bool ActionRandom::execute() { uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); - _engine->getScriptManager()->setStateValue(_slotKey, randNumber); + _scriptManager->setStateValue(_slotKey, randNumber); return true; } @@ -923,7 +926,7 @@ ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &lin } bool ActionStop::execute() { - _engine->getScriptManager()->stopSideFx(_key); + _scriptManager->stopSideFx(_key); return true; } @@ -967,7 +970,7 @@ bool ActionStreamVideo::execute() { hiresFileName.setChar('o', hiresFileName.size() - 2); hiresFileName.setChar('b', hiresFileName.size() - 1); - if (_engine->getScriptManager()->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) { + if (_scriptManager->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) { // TODO: Enable once AC3 support is implemented if (!_engine->getSearchManager()->hasFile(_fileName)) // Check for the regular video return true; @@ -1026,14 +1029,14 @@ ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::S } bool ActionSyncSound::execute() { - ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_syncto); + ScriptingEffect *fx = _scriptManager->getSideFX(_syncto); if (!fx) return true; if (!(fx->getType() & ScriptingEffect::SCRIPTING_EFFECT_ANIM)) return true; - _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); + _scriptManager->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); return true; } @@ -1046,18 +1049,18 @@ ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &l char timeBuffer[64]; memset(timeBuffer, 0, 64); sscanf(line.c_str(), "%s", timeBuffer); - _time = new ValueSlot(_engine->getScriptManager(), timeBuffer); + _time = new ValueSlot(_scriptManager, timeBuffer); } ActionTimer::~ActionTimer() { delete _time; - _engine->getScriptManager()->killSideFx(_slotKey); + _scriptManager->killSideFx(_slotKey); } bool ActionTimer::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) + if (_scriptManager->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotKey, _time->getValue())); + _scriptManager->addSideFX(new TimerNode(_engine, _slotKey, _time->getValue())); return true; } @@ -1077,13 +1080,13 @@ ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::Strin } ActionTtyText::~ActionTtyText() { - _engine->getScriptManager()->killSideFx(_slotKey); + _scriptManager->killSideFx(_slotKey); } bool ActionTtyText::execute() { - if (_engine->getScriptManager()->getSideFX(_slotKey)) + if (_scriptManager->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotKey, _filename, _r, _delay)); + _scriptManager->addSideFX(new ttyTextNode(_engine, _slotKey, _filename, _r, _delay)); return true; } diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 94c2d041fc..ff19fc54fc 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -32,6 +32,7 @@ namespace ZVision { // Forward declaration of ZVision. This file is included before ZVision is declared class ZVision; +class ScriptManager; class ValueSlot; /** @@ -40,7 +41,7 @@ class ValueSlot; */ class ResultAction { public: - ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey) {} + ResultAction(ZVision *engine, int32 slotkey); virtual ~ResultAction() {} /** * This is called by the script system whenever a Puzzle's criteria are found to be true. @@ -53,6 +54,7 @@ public: virtual bool execute() = 0; protected: ZVision *_engine; + ScriptManager *_scriptManager; int32 _slotKey; }; -- cgit v1.2.3 From 53a2c30cb014997887e29f5fd0db1348d05990f0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Feb 2015 15:27:01 +0200 Subject: ZVISION: Fix script bug #6791 (max value of delay_render) This fixes the delay outside the Frobozz Electric building. In all other places, delay_render is called with a value ranging from 1 to 10, so the 100 here looks to be a script bug, and causes an unnecessary long pause in that scene. Thus, we're capping the frame delay value to 10. --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 90d32e47ce..21c97e766b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -217,6 +217,9 @@ ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Commo ResultAction(engine, slotkey) { _framesToDelay = 0; sscanf(line.c_str(), "%u", &_framesToDelay); + // Limit to 10 frames maximum. This fixes the script bug in ZGI scene px10 + // (outside Frobozz Electric building), where this is set to 100 (bug #6791). + _framesToDelay = MIN(_framesToDelay, 10); } bool ActionDelayRender::execute() { -- cgit v1.2.3 From 52adf5135b7b075c1cfc63ce8094538edf279039 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Sat, 14 Feb 2015 12:06:14 -0600 Subject: ZVISION: Check for point and style changes when early breaking from a font change --- engines/zvision/text/truetype_font.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 8e402efc08..7ad8d6db61 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -65,14 +65,14 @@ StyledTTFont::~StyledTTFont() { } bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { - _style = style; - // Don't re-load the font if we've already loaded it // We have to check for empty so we can default to Arial - if (!fontName.empty() && _fontName.equalsIgnoreCase(fontName)) { + if (!fontName.empty() && _fontName.equalsIgnoreCase(fontName) && _lineHeight == point && _style == style) { return true; } + _style = style; + Common::String newFontName; Common::String freeFontName; Common::String liberationFontName; -- cgit v1.2.3 From f04ef8b7282477cda5121b6c8a6e838eb35a1760 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 16 Feb 2015 12:11:50 +0200 Subject: ZVISION: Fix script bug #6793 in Zork Nemesis --- engines/zvision/file/save_manager.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 1e0c57e2b3..63b54269de 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -165,6 +165,27 @@ Common::Error SaveManager::loadGame(int slot) { if (header.thumbnail) delete header.thumbnail; + if (_engine->getGameId() == GID_NEMESIS && scriptManager->getCurrentLocation() == "tv2f") { + // WORKAROUND for script bug #6793: location tv2f (stairs) has two states: + // one at the top of the stairs, and one at the bottom. When the player + // goes to the bottom of the stairs, the screen changes, and hotspot + // 4652 (exit opposite the stairs) is enabled. However, the variable that + // controls the state (2408) is reset when the player goes down the stairs. + // Furthermore, the room's initialization script disables the stair exit + // control (4652). This leads to an impossible situation, where all the + // exit controls are disabled, and the player can't more anywhere. Thus, + // when loading a game in that room, we check for that impossible + // situation, which only occurs after the player has moved down the stairs, + // and fix it here by setting the correct background, and enabling the + // stair exit hotspot. + if ((scriptManager->getStateFlag(2411) & Puzzle::DISABLED) && + (scriptManager->getStateFlag(2408) & Puzzle::DISABLED) && + (scriptManager->getStateFlag(4652) & Puzzle::DISABLED)) { + _engine->getRenderManager()->setBackgroundImage("tv2fb21c.tga"); + scriptManager->unsetStateFlag(4652, Puzzle::DISABLED); + } + } + return Common::kNoError; } -- cgit v1.2.3 From b45e706012d7131035867fdd1e6f7109db1ae635 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Feb 2015 01:49:59 +0200 Subject: ZVISION: Fix script bug #6803 (tuning fork box state) --- engines/zvision/scripting/scr_file_handling.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index a9f3a55021..edc1b8622c 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -86,6 +86,15 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre parseCriteria(stream, puzzle->criteriaList, puzzle->key); } else if (line.matchString("results {", true)) { parseResults(stream, puzzle->resultActions); + + // WORKAROUND for a script bug in Zork Nemesis, room ve5e (tuning + // fork box closeup). If the player leaves the screen while the + // box is open, puzzle 19398 shows the animation where the box + // closes, but the box state (state variable 19397) is not updated. + // We insert the missing assignment for the box state here. + // Fixes bug #6803. + if (_engine->getGameId() == GID_NEMESIS && puzzle->key == 19398) + puzzle->resultActions.push_back(new ActionAssign(_engine, 11, "19397, 0")); } else if (line.matchString("flags {", true)) { setStateFlag(puzzle->key, parseFlags(stream)); } -- cgit v1.2.3 From 53cd90b32c7ad6fe7e1ac5f4c781c5e776bd9348 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 5 Mar 2015 07:28:40 +0100 Subject: ZVISION: Fix GCC signed/unsigned warning --- engines/zvision/video/rlf_decoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 3e11a70f27..3bbf22edff 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -159,7 +159,7 @@ RLFDecoder::RLFVideoTrack::Frame RLFDecoder::RLFVideoTrack::readNextFrame() { bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { uint frame = getFrameAtTime(time); - assert(frame < (int)_frameCount); + assert(frame < _frameCount); if ((uint)_displayedFrame == frame) return true; -- cgit v1.2.3 From ec16861ec981eadbcef55454fb67b22502c6c65b Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 22 Mar 2015 08:14:18 +0100 Subject: ZVISION: Silence Cppcheck warning --- engines/zvision/scripting/actions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 21c97e766b..9a8b734e0c 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -1077,7 +1077,7 @@ ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::Strin char filename[64]; int32 x1 = 0, y1 = 0, x2 = 0, y2 = 0; - sscanf(line.c_str(), "%d %d %d %d %64s %u", &x1, &y1, &x2, &y2, filename, &_delay); + sscanf(line.c_str(), "%d %d %d %d %63s %u", &x1, &y1, &x2, &y2, filename, &_delay); _r = Common::Rect(x1, y1, x2, y2); _filename = Common::String(filename); } -- cgit v1.2.3 From ddf170de4a33fac4cac3093bf6dd97d253216092 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 11 Apr 2015 16:11:21 -0400 Subject: ZVISION: Silence gcc warnings --- engines/zvision/graphics/effects/fog.cpp | 6 ++--- engines/zvision/graphics/effects/wave.cpp | 2 +- engines/zvision/graphics/render_manager.cpp | 4 ++-- .../zvision/scripting/effects/distort_effect.cpp | 2 +- engines/zvision/scripting/effects/music_effect.cpp | 2 +- engines/zvision/scripting/menu.cpp | 26 +++++++++++----------- engines/zvision/text/truetype_font.cpp | 8 +++---- 7 files changed, 25 insertions(+), 25 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp index 32a01915d3..7b65f60f24 100644 --- a/engines/zvision/graphics/effects/fog.cpp +++ b/engines/zvision/graphics/effects/fog.cpp @@ -142,9 +142,9 @@ void FogFx::update() { for (uint8 i = 0; i < 31; i++) { float perc = (float)i / 31.0; - uint8 cr = (float)_r * perc; - uint8 cg = (float)_g * perc; - uint8 cb = (float)_b * perc; + uint8 cr = (uint8)((float)_r * perc); + uint8 cg = (uint8)((float)_g * perc); + uint8 cb = (uint8)((float)_b * perc); _colorMap[i] = _engine->_resourcePixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3); } } diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp index cec631611b..d2887b3112 100644 --- a/engines/zvision/graphics/effects/wave.cpp +++ b/engines/zvision/graphics/effects/wave.cpp @@ -54,7 +54,7 @@ WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, in int16 dx = (x - quarterWidth); int16 dy = (y - quarterHeight); - _ampls[i][x + y * _halfWidth] = ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase); + _ampls[i][x + y * _halfWidth] = (int8)(ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase)); } phase += spd; } diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 3772d5909e..ce0a02a1ad 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -1108,7 +1108,7 @@ void RenderManager::updateRotation() { int16 newPosition = startPosition + _velocity; int16 screenHeight = getBkgSize().y; - int16 tiltGap = _renderTable.getTiltGap(); + int16 tiltGap = (int16)_renderTable.getTiltGap(); if (newPosition >= (screenHeight - tiltGap)) newPosition = screenHeight - tiltGap; @@ -1143,7 +1143,7 @@ void RenderManager::checkBorders() { int16 newPosition = startPosition; int16 screenHeight = getBkgSize().y; - int16 tiltGap = _renderTable.getTiltGap(); + int16 tiltGap = (int16)_renderTable.getTiltGap(); if (newPosition >= (screenHeight - tiltGap)) newPosition = screenHeight - tiltGap; diff --git a/engines/zvision/scripting/effects/distort_effect.cpp b/engines/zvision/scripting/effects/distort_effect.cpp index 78c4a1b9a8..113b5d048d 100644 --- a/engines/zvision/scripting/effects/distort_effect.cpp +++ b/engines/zvision/scripting/effects/distort_effect.cpp @@ -52,7 +52,7 @@ DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAn _diffLinScale = endLineScale - startLineScale; _frmSpeed = (float)speed / 15.0; - _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); + _frames = (int)ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); if (_frames <= 0) _frames = 1; diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp index ad3c0f6d22..e3fdc96dba 100644 --- a/engines/zvision/scripting/effects/music_effect.cpp +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -140,7 +140,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { if (_crossfadeTime > 0) { if ((int32)deltaTimeInMillis > _crossfadeTime) deltaTimeInMillis = _crossfadeTime; - _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis; + _newvol += (int)(floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis); _crossfadeTime -= deltaTimeInMillis; } else { _crossfade = false; diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp index 16aa57e3ae..e7775cbe3f 100644 --- a/engines/zvision/scripting/menu.cpp +++ b/engines/zvision/scripting/menu.cpp @@ -50,9 +50,9 @@ MenuZGI::MenuZGI(ZVision *engine) : scrolled[0] = false; scrolled[1] = false; scrolled[2] = false; - scrollPos[0] = 0.0; - scrollPos[1] = 0.0; - scrollPos[2] = 0.0; + scrollPos[0] = 0; + scrollPos[1] = 0; + scrollPos[2] = 0; mouseOnItem = -1; redraw = false; clean = false; @@ -361,11 +361,11 @@ void MenuZGI::process(uint32 deltatime) { if (scrl == 0) scrl = 1.0; - scrollPos [kMenuItem] += scrl; + scrollPos[kMenuItem] += (int)scrl; if (scrollPos[kMenuItem] >= 0) { scrolled[kMenuItem] = true; - scrollPos [kMenuItem] = 0; + scrollPos[kMenuItem] = 0; } } if (redraw) { @@ -430,11 +430,11 @@ void MenuZGI::process(uint32 deltatime) { if (scrl == 0) scrl = 1.0; - scrollPos [kMenuMagic] += scrl; + scrollPos[kMenuMagic] += (int)scrl; if (scrollPos[kMenuMagic] >= 600) { scrolled[kMenuMagic] = true; - scrollPos [kMenuMagic] = 600; + scrollPos[kMenuMagic] = 600; } } if (redraw) { @@ -495,11 +495,11 @@ void MenuZGI::process(uint32 deltatime) { if (scrl == 0) scrl = 1.0; - scrollPos [kMenuMain] += scrl; + scrollPos[kMenuMain] += (int)scrl; if (scrollPos[kMenuMain] >= 0) { scrolled[kMenuMain] = true; - scrollPos [kMenuMain] = 0; + scrollPos[kMenuMain] = 0; } } if (redraw) { @@ -553,7 +553,7 @@ MenuNemesis::MenuNemesis(ZVision *engine) : MenuHandler(engine) { inmenu = false; scrolled = false; - scrollPos = 0.0; + scrollPos = 0; mouseOnItem = -1; redraw = false; delay = 0; @@ -696,7 +696,7 @@ void MenuNemesis::process(uint32 deltatime) { if (scrl == 0) scrl = 1.0; - scrollPos += scrl; + scrollPos += (int)scrl; redraw = true; } @@ -743,10 +743,10 @@ void MenuNemesis::process(uint32 deltatime) { if (scrl == 0) scrl = 1.0; - Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); + Common::Rect cl(64, (int16)(32 + scrollPos - scrl), 64 + 512, 32 + scrollPos + 1); _engine->getRenderManager()->clearMenuSurface(cl); - scrollPos -= scrl; + scrollPos -= (int)scrl; redraw = true; } else scrollPos = -32; diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 7ad8d6db61..acb053ea8d 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -199,12 +199,12 @@ void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint if (_font) { _font->drawChar(dst, chr, x, y, color); if (_style & TTF_STYLE_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); + int16 pos = (int16)floor(_font->getFontHeight() * 0.87); int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); } if (_style & TTF_STYLE_STRIKETHROUGH) { - int16 pos = floor(_font->getFontHeight() * 0.60); + int16 pos = (int16)floor(_font->getFontHeight() * 0.60); int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); } @@ -216,7 +216,7 @@ void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, Common::U32String u32str = convertUtf8ToUtf32(str); _font->drawString(dst, u32str, x, y, w, color, align); if (_style & TTF_STYLE_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); + int16 pos = (int16)floor(_font->getFontHeight() * 0.87); int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; if (align == Graphics::kTextAlignCenter) @@ -229,7 +229,7 @@ void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); } if (_style & TTF_STYLE_STRIKETHROUGH) { - int16 pos = floor(_font->getFontHeight() * 0.60); + int16 pos = (int16)floor(_font->getFontHeight() * 0.60); int16 wd = MIN(_font->getStringWidth(u32str), w); int16 stX = x; if (align == Graphics::kTextAlignCenter) -- cgit v1.2.3 From 0c09973a7058a38d09a1fb526124e905a72dec3f Mon Sep 17 00:00:00 2001 From: David Russo Date: Sat, 16 May 2015 18:51:44 +0100 Subject: ZVISION: Correct function documentation --- engines/zvision/core/clock.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/core/clock.h b/engines/zvision/core/clock.h index cbf52be560..ae8c968111 100644 --- a/engines/zvision/core/clock.h +++ b/engines/zvision/core/clock.h @@ -67,14 +67,14 @@ public: } /** - * Pause the clock. Any future delta times will take this pause into account. - * Has no effect if the clock is already paused. - */ + * Un-pause the clock. + * Has no effect if the clock is already un-paused. + */ void start(); /** - * Un-pause the clock. - * Has no effect if the clock is already un-paused. + * Pause the clock. Any future delta times will take this pause into account. + * Has no effect if the clock is already paused. */ void stop(); }; -- cgit v1.2.3 From fd8ac7ea79441b5c4a85234e2e875444d47f3f79 Mon Sep 17 00:00:00 2001 From: David Russo Date: Sat, 16 May 2015 19:24:31 +0100 Subject: ZVISION: Change mentions of ZVision to Z-Vision To match official documentation (e.g. game manual, credits). --- engines/zvision/configure.engine | 2 +- engines/zvision/core/console.cpp | 2 +- engines/zvision/detection.cpp | 6 +++--- engines/zvision/file/save_manager.cpp | 2 +- engines/zvision/graphics/render_manager.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/configure.engine b/engines/zvision/configure.engine index 38a5959995..226870c3fd 100644 --- a/engines/zvision/configure.engine +++ b/engines/zvision/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine zvision "ZVision" yes "" "" "freetype2 16bit" +add_engine zvision "Z-Vision" yes "" "" "freetype2 16bit" diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index f5cacb582c..336541d82a 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -275,7 +275,7 @@ bool Console::cmdDumpFiles(int argc, const char **argv) { bool Console::cmdDumpImage(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use %s to dump a ZVision TGA/TGZ image into a regular BMP image\n", argv[0]); + debugPrintf("Use %s to dump a Z-Vision TGA/TGZ image into a regular BMP image\n", argv[0]); return true; } diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index c817cbf3e9..9e7f21c5ba 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -47,7 +47,7 @@ Common::Language ZVision::getLanguage() const { } // End of namespace ZVision static const PlainGameDescriptor zVisionGames[] = { - {"zvision", "ZVision Game"}, + {"zvision", "Z-Vision Game"}, {"znemesis", "Zork Nemesis: The Forbidden Lands"}, {"zgi", "Zork: Grand Inquisitor"}, {0, 0} @@ -302,11 +302,11 @@ public: } virtual const char *getName() const { - return "ZVision"; + return "Z-Vision"; } virtual const char *getOriginalCopyright() const { - return "ZVision Activision (C) 1996"; + return "Z-Vision (C) 1996 Activision"; } virtual bool hasFeature(MetaEngineFeature f) const; diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 63b54269de..d169679e28 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -205,7 +205,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea return true; } if (tag != SAVEGAME_ID) { - warning("File is not a ZVision save file. Aborting load"); + warning("File is not a Z-Vision save file. Aborting load"); return false; } diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index ce0a02a1ad..f978ef7844 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -196,7 +196,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: uint32 imageHeight; Image::TGADecoder tga; uint16 *buffer; - // All ZVision images are in RGB 555 + // All Z-Vision images are in RGB 555 destination.format = _engine->_resourcePixelFormat; bool isTGZ; -- cgit v1.2.3 From fdc4edfa9902322ee9792d513ae09f30aa03fbe1 Mon Sep 17 00:00:00 2001 From: David Russo Date: Wed, 10 Jun 2015 16:56:04 +0100 Subject: ZVISION: Correct code style --- engines/zvision/scripting/actions.cpp | 137 +++++++++++++++++----------------- engines/zvision/scripting/menu.cpp | 74 +++++++++--------- engines/zvision/scripting/menu.h | 16 ++-- engines/zvision/sound/zork_raw.cpp | 6 +- engines/zvision/text/text.h | 2 +- engines/zvision/zvision.h | 13 ++-- 6 files changed, 127 insertions(+), 121 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 9a8b734e0c..e1380b0eb2 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -47,15 +47,18 @@ namespace ZVision { -ResultAction::ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey), _scriptManager(engine->getScriptManager()) { +ResultAction::ResultAction(ZVision *engine, int32 slotKey) : + _engine(engine), + _slotKey(slotKey), + _scriptManager(engine->getScriptManager()) { } ////////////////////////////////////////////////////////////////////////////// // ActionAdd ////////////////////////////////////////////////////////////////////////////// -ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionAdd::ActionAdd(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; _value = 0; @@ -71,8 +74,8 @@ bool ActionAdd::execute() { // ActionAssign ////////////////////////////////////////////////////////////////////////////// -ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionAssign::ActionAssign(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; char buf[64]; @@ -94,8 +97,8 @@ bool ActionAssign::execute() { // ActionAttenuate ////////////////////////////////////////////////////////////////////////////// -ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; _attenuation = 0; @@ -115,8 +118,8 @@ bool ActionAttenuate::execute() { // ActionChangeLocation ////////////////////////////////////////////////////////////////////////////// -ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _world = 'g'; _room = 'a'; _node = 'r'; @@ -137,8 +140,8 @@ bool ActionChangeLocation::execute() { // ActionCrossfade ////////////////////////////////////////////////////////////////////////////// -ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _keyOne = 0; _keyTwo = 0; _oneStartVolume = 0; @@ -181,8 +184,8 @@ bool ActionCrossfade::execute() { // ActionCursor ////////////////////////////////////////////////////////////////////////////// -ActionCursor::ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionCursor::ActionCursor(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { Common::String up = line; up.toUppercase(); _action = 0; @@ -213,8 +216,8 @@ bool ActionCursor::execute() { // ActionDelayRender ////////////////////////////////////////////////////////////////////////////// -ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _framesToDelay = 0; sscanf(line.c_str(), "%u", &_framesToDelay); // Limit to 10 frames maximum. This fixes the script bug in ZGI scene px10 @@ -231,8 +234,8 @@ bool ActionDelayRender::execute() { // ActionDisableControl ////////////////////////////////////////////////////////////////////////////// -ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; sscanf(line.c_str(), "%u", &_key); @@ -247,8 +250,8 @@ bool ActionDisableControl::execute() { // ActionDisplayMessage ////////////////////////////////////////////////////////////////////////////// -ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _control = 0; _msgid = 0; @@ -282,8 +285,8 @@ bool ActionDissolve::execute() { // ActionDistort - only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30) ////////////////////////////////////////////////////////////////////////////// -ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionDistort::ActionDistort(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _distSlot = 0; _speed = 0; _startAngle = 60.0; @@ -311,8 +314,8 @@ bool ActionDistort::execute() { // ActionEnableControl ////////////////////////////////////////////////////////////////////////////// -ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; sscanf(line.c_str(), "%u", &_key); @@ -327,8 +330,8 @@ bool ActionEnableControl::execute() { // ActionFlushMouseEvents ////////////////////////////////////////////////////////////////////////////// -ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotkey) : - ResultAction(engine, slotkey) { +ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotKey) : + ResultAction(engine, slotKey) { } bool ActionFlushMouseEvents::execute() { @@ -341,8 +344,8 @@ bool ActionFlushMouseEvents::execute() { // ActionInventory ////////////////////////////////////////////////////////////////////////////// -ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionInventory::ActionInventory(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _type = -1; _key = 0; @@ -393,8 +396,8 @@ bool ActionInventory::execute() { // ActionKill - only used by ZGI ////////////////////////////////////////////////////////////////////////////// -ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionKill::ActionKill(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; _type = 0; char keytype[25]; @@ -432,8 +435,8 @@ bool ActionKill::execute() { // ActionMenuBarEnable ////////////////////////////////////////////////////////////////////////////// -ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _menus = 0xFFFF; sscanf(line.c_str(), "%hu", &_menus); @@ -448,8 +451,8 @@ bool ActionMenuBarEnable::execute() { // ActionMusic ////////////////////////////////////////////////////////////////////////////// -ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) : - ResultAction(engine, slotkey), +ActionMusic::ActionMusic(ZVision *engine, int32 slotKey, const Common::String &line, bool global) : + ResultAction(engine, slotKey), _note(0), _prog(0), _universe(global) { @@ -527,8 +530,8 @@ bool ActionMusic::execute() { // ActionPanTrack ////////////////////////////////////////////////////////////////////////////// -ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey), +ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey), _pos(0), _musicSlot(0) { @@ -552,8 +555,8 @@ bool ActionPanTrack::execute() { // ActionPreferences ////////////////////////////////////////////////////////////////////////////// -ActionPreferences::ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionPreferences::ActionPreferences(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { if (line.compareToIgnoreCase("save") == 0) _save = true; else @@ -573,8 +576,8 @@ bool ActionPreferences::execute() { // ActionPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _mask = 0; _framerate = 0; @@ -612,8 +615,8 @@ bool ActionPreloadAnimation::execute() { // ActionUnloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; sscanf(line.c_str(), "%u", &_key); @@ -632,8 +635,8 @@ bool ActionUnloadAnimation::execute() { // ActionPlayAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _x = 0; _y = 0; _x2 = 0; @@ -690,8 +693,8 @@ bool ActionPlayAnimation::execute() { // ActionPlayPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _controlKey = 0; _x1 = 0; _y1 = 0; @@ -729,8 +732,8 @@ bool ActionQuit::execute() { // ActionRegion - only used by Zork: Nemesis ////////////////////////////////////////////////////////////////////////////// -ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionRegion::ActionRegion(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _delay = 0; _type = 0; _unk1 = 0; @@ -808,8 +811,8 @@ bool ActionRegion::execute() { // ActionRandom ////////////////////////////////////////////////////////////////////////////// -ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionRandom::ActionRandom(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { char maxBuffer[64]; memset(maxBuffer, 0, 64); sscanf(line.c_str(), "%s", maxBuffer); @@ -830,8 +833,8 @@ bool ActionRandom::execute() { // ActionRestoreGame ////////////////////////////////////////////////////////////////////////////// -ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { char buf[128]; sscanf(line.c_str(), "%s", buf); _fileName = Common::String(buf); @@ -846,8 +849,8 @@ bool ActionRestoreGame::execute() { // ActionRotateTo ////////////////////////////////////////////////////////////////////////////// -ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _time = 0; _toPos = 0; @@ -864,8 +867,8 @@ bool ActionRotateTo::execute() { // ActionSetPartialScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _x = 0; _y = 0; @@ -904,8 +907,8 @@ bool ActionSetPartialScreen::execute() { // ActionSetScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { char fileName[25]; sscanf(line.c_str(), "%24s", fileName); @@ -922,8 +925,8 @@ bool ActionSetScreen::execute() { // ActionStop ////////////////////////////////////////////////////////////////////////////// -ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionStop::ActionStop(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _key = 0; sscanf(line.c_str(), "%u", &_key); } @@ -937,8 +940,8 @@ bool ActionStop::execute() { // ActionStreamVideo ////////////////////////////////////////////////////////////////////////////// -ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _x1 = 0; _x2 = 0; _y1 = 0; @@ -1019,8 +1022,8 @@ bool ActionStreamVideo::execute() { // ActionSyncSound ////////////////////////////////////////////////////////////////////////////// -ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _syncto = 0; char fileName[25]; @@ -1047,8 +1050,8 @@ bool ActionSyncSound::execute() { // ActionTimer ////////////////////////////////////////////////////////////////////////////// -ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionTimer::ActionTimer(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { char timeBuffer[64]; memset(timeBuffer, 0, 64); sscanf(line.c_str(), "%s", timeBuffer); @@ -1071,8 +1074,8 @@ bool ActionTimer::execute() { // ActionTtyText ////////////////////////////////////////////////////////////////////////////// -ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { +ActionTtyText::ActionTtyText(ZVision *engine, int32 slotKey, const Common::String &line) : + ResultAction(engine, slotKey) { _delay = 0; char filename[64]; diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp index e7775cbe3f..064bd1b57d 100644 --- a/engines/zvision/scripting/menu.cpp +++ b/engines/zvision/scripting/menu.cpp @@ -46,7 +46,7 @@ MenuHandler::MenuHandler(ZVision *engine) { MenuZGI::MenuZGI(ZVision *engine) : MenuHandler(engine) { menuMouseFocus = -1; - inmenu = false; + inMenu = false; scrolled[0] = false; scrolled[1] = false; scrolled[2] = false; @@ -60,15 +60,15 @@ MenuZGI::MenuZGI(ZVision *engine) : char buf[24]; for (int i = 1; i < 4; i++) { sprintf(buf, "gmzau%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); + _engine->getRenderManager()->readImageToSurface(buf, menuBack[i - 1][0], false); sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); + _engine->getRenderManager()->readImageToSurface(buf, menuBack[i - 1][1], false); } for (int i = 0; i < 4; i++) { sprintf(buf, "gmzmu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); + _engine->getRenderManager()->readImageToSurface(buf, menuBar[i][0], false); sprintf(buf, "gmznu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); + _engine->getRenderManager()->readImageToSurface(buf, menuBar[i][1], false); } for (int i = 0; i < 50; i++) { @@ -86,12 +86,12 @@ MenuZGI::MenuZGI(ZVision *engine) : MenuZGI::~MenuZGI() { for (int i = 0; i < 3; i++) { - menuback[i][0].free(); - menuback[i][1].free(); + menuBack[i][0].free(); + menuBack[i][1].free(); } for (int i = 0; i < 4; i++) { - menubar[i][0].free(); - menubar[i][1].free(); + menuBar[i][0].free(); + menuBar[i][1].free(); } for (int i = 0; i < 50; i++) { if (items[i][0]) { @@ -208,9 +208,9 @@ void MenuZGI::onMouseUp(const Common::Point &Pos) { void MenuZGI::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { - if (!inmenu) + if (!inMenu) redraw = true; - inmenu = true; + inMenu = true; switch (menuMouseFocus) { case kMenuItem: if (menuBarFlag & kMenubarItems) { @@ -311,7 +311,7 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) { if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main menuMouseFocus = kMenuMain; scrolled[kMenuMain] = false; - scrollPos[kMenuMain] = menuback[kMenuMain][1].h - menuback[kMenuMain][0].h; + scrollPos[kMenuMain] = menuBack[kMenuMain][1].h - menuBack[kMenuMain][0].h; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); } @@ -337,9 +337,9 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) { break; } } else { - if (inmenu) + if (inMenu) clean = true; - inmenu = false; + inMenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); menuMouseFocus = -1; @@ -369,7 +369,7 @@ void MenuZGI::process(uint32 deltatime) { } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][0], scrollPos[kMenuItem], 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuItem][0], scrollPos[kMenuItem], 0); int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); if (itemCount == 0) @@ -438,7 +438,7 @@ void MenuZGI::process(uint32 deltatime) { } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][0], 640 - scrollPos[kMenuMagic], 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuMagic][0], 640 - scrollPos[kMenuMagic], 0); for (int i = 0; i < 12; i++) { bool inrect = false; @@ -503,45 +503,45 @@ void MenuZGI::process(uint32 deltatime) { } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][0], 30, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuMain][0], 30, scrollPos[kMenuMain]); if (menuBarFlag & kMenubarExit) { if (mouseOnItem == kMainMenuExit) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][1], 320 + 135, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuExit][1], 320 + 135, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][0], 320 + 135, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuExit][0], 320 + 135, scrollPos[kMenuMain]); } if (menuBarFlag & kMenubarSettings) { if (mouseOnItem == kMainMenuPrefs) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][1], 320, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuPrefs][1], 320, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][0], 320, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuPrefs][0], 320, scrollPos[kMenuMain]); } if (menuBarFlag & kMenubarRestore) { if (mouseOnItem == kMainMenuLoad) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][1], 320 - 135, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuLoad][1], 320 - 135, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][0], 320 - 135, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuLoad][0], 320 - 135, scrollPos[kMenuMain]); } if (menuBarFlag & kMenubarSave) { if (mouseOnItem == kMainMenuSave) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][1], 320 - 135 * 2, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuSave][1], 320 - 135 * 2, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][0], 320 - 135 * 2, scrollPos[kMenuMain]); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar[kMainMenuSave][0], 320 - 135 * 2, scrollPos[kMenuMain]); } redraw = false; } break; default: if (redraw) { - if (inmenu) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][1], 30, 0); + if (inMenu) { + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuMain][1], 30, 0); if (menuBarFlag & kMenubarItems) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][1], 0, 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuItem][1], 0, 0); if (menuBarFlag & kMenubarMagic) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][1], 640 - 28, 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuBack[kMenuMagic][1], 640 - 28, 0); } redraw = false; } @@ -551,7 +551,7 @@ void MenuZGI::process(uint32 deltatime) { MenuNemesis::MenuNemesis(ZVision *engine) : MenuHandler(engine) { - inmenu = false; + inMenu = false; scrolled = false; scrollPos = 0; mouseOnItem = -1; @@ -565,7 +565,7 @@ MenuNemesis::MenuNemesis(ZVision *engine) : _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); } - _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); + _engine->getRenderManager()->readImageToSurface("bar.tga", menuBar, false); frm = 0; } @@ -575,7 +575,7 @@ MenuNemesis::~MenuNemesis() { for (int j = 0; j < 6; j++) but[i][j].free(); - menubar.free(); + menuBar.free(); } static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; @@ -631,7 +631,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) { void MenuNemesis::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { - inmenu = true; + inMenu = true; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); @@ -681,7 +681,7 @@ void MenuNemesis::onMouseMove(const Common::Point &Pos) { delay = 200; } } else { - inmenu = false; + inMenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); mouseOnItem = -1; @@ -689,7 +689,7 @@ void MenuNemesis::onMouseMove(const Common::Point &Pos) { } void MenuNemesis::process(uint32 deltatime) { - if (inmenu) { + if (inMenu) { if (!scrolled) { float scrl = 32.0 * 2.0 * (deltatime / 1000.0); @@ -715,7 +715,7 @@ void MenuNemesis::process(uint32 deltatime) { } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar, 64, scrollPos); if (menuBarFlag & kMenubarExit) if (mouseOnItem == kMainMenuExit) @@ -752,7 +752,7 @@ void MenuNemesis::process(uint32 deltatime) { scrollPos = -32; if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + _engine->getRenderManager()->blitSurfaceToMenu(menuBar, 64, scrollPos); redraw = false; } } diff --git a/engines/zvision/scripting/menu.h b/engines/zvision/scripting/menu.h index a88587966f..f6b21b9c97 100644 --- a/engines/zvision/scripting/menu.h +++ b/engines/zvision/scripting/menu.h @@ -68,8 +68,8 @@ public: void onMouseUp(const Common::Point &Pos); void process(uint32 deltaTimeInMillis); private: - Graphics::Surface menuback[3][2]; - Graphics::Surface menubar[4][2]; + Graphics::Surface menuBack[3][2]; + Graphics::Surface menuBar[4][2]; Graphics::Surface *items[50][2]; uint itemId[50]; @@ -77,11 +77,11 @@ private: uint magicId[12]; int menuMouseFocus; - bool inmenu; + bool inMenu; int mouseOnItem; - bool scrolled[3]; + bool scrolled[3]; int16 scrollPos[3]; bool clean; @@ -98,13 +98,13 @@ public: void process(uint32 deltaTimeInMillis); private: Graphics::Surface but[4][6]; - Graphics::Surface menubar; + Graphics::Surface menuBar; - bool inmenu; + bool inMenu; int mouseOnItem; - bool scrolled; + bool scrolled; int16 scrollPos; bool redraw; @@ -114,6 +114,6 @@ private: }; -} +} // End of namespace ZVision #endif diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 7bdd4875fc..a14a31aa7c 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -136,7 +136,8 @@ int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream return bytesRead; } -const SoundParams RawZorkStream::_zNemSoundParamLookupTable[32] = {{'0', 0x1F40, false, false, false}, +const SoundParams RawZorkStream::_zNemSoundParamLookupTable[32] = { + {'0', 0x1F40, false, false, false}, {'1', 0x1F40, true, false, false}, {'2', 0x1F40, false, false, true}, {'3', 0x1F40, true, false, true}, @@ -170,7 +171,8 @@ const SoundParams RawZorkStream::_zNemSoundParamLookupTable[32] = {{'0', 0x1F40, {'x', 0xAC44, true, true, true} }; -const SoundParams RawZorkStream::_zgiSoundParamLookupTable[24] = {{'4', 0x2B11, false, false, false}, +const SoundParams RawZorkStream::_zgiSoundParamLookupTable[24] = { + {'4', 0x2B11, false, false, false}, {'5', 0x2B11, true, false, false}, {'6', 0x2B11, false, false, true}, {'7', 0x2B11, true, false, true}, diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index d35b90499d..9c170a3816 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -59,7 +59,7 @@ public: public: Common::String _fontname; - TextJustification _justification; // 0 - center, 1-left, 2-right + TextJustification _justification; int16 _size; uint8 _red; // 0-255 uint8 _green; // 0-255 diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 854cd77bb8..6cfc0f5d54 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -51,7 +51,6 @@ class VideoDecoder; * - Zork: Grand Inquisitor * */ - namespace ZVision { struct ZVisionGameDescription; @@ -74,12 +73,12 @@ enum { HIRES_WINDOW_WIDTH = 800, HIRES_WINDOW_HEIGHT = 600, - // Zork nemesis working window sizes - ZNM_WORKING_WINDOW_WIDTH = 512, + // Zork Nemesis working window sizes + ZNM_WORKING_WINDOW_WIDTH = 512, ZNM_WORKING_WINDOW_HEIGHT = 320, // ZGI working window sizes - ZGI_WORKING_WINDOW_WIDTH = 640, + ZGI_WORKING_WINDOW_WIDTH = 640, ZGI_WORKING_WINDOW_HEIGHT = 344, ROTATION_SCREEN_EDGE_OFFSET = 60, @@ -116,12 +115,12 @@ private: ScriptManager *_scriptManager; RenderManager *_renderManager; CursorManager *_cursorManager; - SaveManager *_saveManager; StringManager *_stringManager; - MenuHandler *_menu; SearchManager *_searchManager; TextRenderer *_textRenderer; MidiManager *_midiManager; + SaveManager *_saveManager; + MenuHandler *_menu; // Clock Clock _clock; @@ -141,6 +140,7 @@ private: bool _videoIsPlaying; uint8 _cheatBuffer[KEYBUF_SIZE]; + public: uint32 getFeatures() const; Common::Language getLanguage() const; @@ -236,6 +236,7 @@ public: bool canSaveGameStateCurrently(); Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const Common::String &desc); + private: void initialize(); void initFonts(); -- cgit v1.2.3 From e32385359839f573e7b55c2aba59390a7dd2c7de Mon Sep 17 00:00:00 2001 From: David Russo Date: Wed, 10 Jun 2015 17:17:34 +0100 Subject: ZVISION: Reorganize detection data Migrated static detection data to detection_tables.h and removed the need for detection.h includes. Also edited game option descriptions. --- engines/zvision/detection.cpp | 267 ++------------------------------ engines/zvision/detection.h | 43 ------ engines/zvision/detection_tables.h | 277 ++++++++++++++++++++++++++++++++++ engines/zvision/sound/zork_raw.cpp | 1 - engines/zvision/text/string_manager.h | 1 - engines/zvision/text/text.h | 1 - engines/zvision/zvision.cpp | 13 +- engines/zvision/zvision.h | 17 ++- 8 files changed, 309 insertions(+), 311 deletions(-) delete mode 100644 engines/zvision/detection.h create mode 100644 engines/zvision/detection_tables.h (limited to 'engines/zvision') diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 9e7f21c5ba..f44e653c2a 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -24,8 +24,9 @@ #include "base/plugins.h" +#include "engines/advancedDetector.h" + #include "zvision/zvision.h" -#include "zvision/detection.h" #include "zvision/file/save_manager.h" #include "zvision/scripting/script_manager.h" @@ -36,268 +37,30 @@ namespace ZVision { -uint32 ZVision::getFeatures() const { - return _gameDescription->desc.flags; -} +struct ZVisionGameDescription { + ADGameDescription desc; + ZVisionGameId gameId; +}; +ZVisionGameId ZVision::getGameId() const { + return _gameDescription->gameId; +} Common::Language ZVision::getLanguage() const { return _gameDescription->desc.language; } +uint32 ZVision::getFeatures() const { + return _gameDescription->desc.flags; +} } // End of namespace ZVision -static const PlainGameDescriptor zVisionGames[] = { - {"zvision", "Z-Vision Game"}, - {"znemesis", "Zork Nemesis: The Forbidden Lands"}, - {"zgi", "Zork: Grand Inquisitor"}, - {0, 0} -}; - -namespace ZVision { - -#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 -#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2 -#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3 -#define GAMEOPTION_DISABLE_ANIM_WHILE_TURNING GUIO_GAMEOPTIONS4 -#define GAMEOPTION_USE_HIRES_MPEG_MOVIES GUIO_GAMEOPTIONS5 - -static const ZVisionGameDescription gameDescriptions[] = { - - { - // Zork Nemesis English version - { - "znemesis", - 0, - AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741), - Common::EN_ANY, - Common::kPlatformDOS, - ADGF_NO_FLAGS, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_NEMESIS - }, - - { - // Zork Nemesis French version - { - "znemesis", - 0, - {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, - {"NEMESIS.STR", 0, "333bcb17bbb7f57cae742fbbe44f56f3", 9219}, - AD_LISTEND - }, - Common::FR_FRA, - Common::kPlatformDOS, - ADGF_NO_FLAGS, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_NEMESIS - }, - - { - // Zork Nemesis German version - { - "znemesis", - 0, - {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, - {"NEMESIS.STR", 0, "3d1a12b907751653866cffc6d4dfb331", 9505}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformDOS, - ADGF_NO_FLAGS, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_NEMESIS - }, - - { - // Zork Nemesis Italian version - { - "znemesis", - 0, - {{"CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873}, - {"NEMESIS.STR", 0, "7c568feca8d9f9ae855c47183612c305", 9061}, - AD_LISTEND - }, - Common::IT_ITA, - Common::kPlatformDOS, - ADGF_NO_FLAGS, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_NEMESIS - }, - - { - // Zork Nemesis English demo version - { - "znemesis", - "Demo", - AD_ENTRY1s("SCRIPTS.ZFS", "64f1e881394e9462305104f99513c833", 380539), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_DEMO, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_NEMESIS - }, - - { - // Zork Grand Inquisitor English CD version - { - "zgi", - "CD", - AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_NO_FLAGS, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_GRANDINQUISITOR - }, - - { - // Zork Grand Inquisitor French CD version, reported by ulrichh on IRC - { - "zgi", - "CD", - AD_ENTRY1s("SCRIPTS.ZFS", "4d1ec4ade7ecc9ee9ec591d43ca3d213", 8338133), - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_NO_FLAGS, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_GRANDINQUISITOR - }, - - { - // Zork Grand Inquisitor German CD version, reported by breit in bug #6760 - { - "zgi", - "CD", - AD_ENTRY1s("SCRIPTS.ZFS", "b7ac7e331b9b7f884590b0b325b560c8", 8338133), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_NO_FLAGS, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_GRANDINQUISITOR - }, - - { - // Zork Grand Inquisitor Spanish CD version, reported by dianiu in bug #6764 - { - "zgi", - "CD", - AD_ENTRY1s("SCRIPTS.ZFS", "5cdc4b99c1134053af135aae71326fd1", 8338141), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_NO_FLAGS, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_GRANDINQUISITOR - }, - - { - // Zork Grand Inquisitor English DVD version - { - "zgi", - "DVD", - AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_NO_FLAGS, - GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING, GAMEOPTION_USE_HIRES_MPEG_MOVIES) - }, - GID_GRANDINQUISITOR - }, - - { - // Zork Grand Inquisitor English demo version - { - "zgi", - "Demo", - AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_DEMO, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) - }, - GID_GRANDINQUISITOR - }, - - { - AD_TABLE_END_MARKER, - GID_NONE - } -}; - -} // End of namespace ZVision - -static const char *directoryGlobs[] = { - "znemscr", - 0 -}; - -static const ADExtraGuiOptionsMap optionsList[] = { - { - GAMEOPTION_ORIGINAL_SAVELOAD, - { - _s("Use original save/load screens"), - _s("Use the original save/load screens, instead of the ScummVM ones"), - "originalsaveload", - false - } - }, - - { - GAMEOPTION_DOUBLE_FPS, - { - _s("Double FPS"), - _s("Increase game FPS from 30 to 60"), - "doublefps", - false - } - }, - - { - GAMEOPTION_ENABLE_VENUS, - { - _s("Enable Venus"), - _s("Enable the Venus help system"), - "venusenabled", - true - } - }, - - { - GAMEOPTION_DISABLE_ANIM_WHILE_TURNING, - { - _s("Disable animation while turning"), - _s("Disable animation while turning in panoramic mode"), - "noanimwhileturning", - false - } - }, - - { - GAMEOPTION_USE_HIRES_MPEG_MOVIES, - { - _s("Use the hires MPEG movies"), - _s("Use the hires MPEG movies of the DVD version, instead of the lowres AVI ones"), - "mpegmovies", - true - } - }, - - AD_EXTRA_GUI_OPTIONS_TERMINATOR -}; +#include "zvision/detection_tables.h" class ZVisionMetaEngine : public AdvancedMetaEngine { public: - ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames, optionsList) { + ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), ZVision::zVisionGames, ZVision::optionsList) { _maxScanDepth = 2; - _directoryGlobs = directoryGlobs; + _directoryGlobs = ZVision::directoryGlobs; _singleid = "zvision"; } diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h deleted file mode 100644 index f80cac79ec..0000000000 --- a/engines/zvision/detection.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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. - * - */ - -#ifndef ZVISION_DETECTION_H -#define ZVISION_DETECTION_H - -#include "engines/advancedDetector.h" - -namespace ZVision { - -enum ZVisionGameId { - GID_NONE = 0, - GID_NEMESIS = 1, - GID_GRANDINQUISITOR = 2 -}; - -struct ZVisionGameDescription { - ADGameDescription desc; - ZVisionGameId gameId; -}; - -} - -#endif diff --git a/engines/zvision/detection_tables.h b/engines/zvision/detection_tables.h new file mode 100644 index 0000000000..06bc58ee7f --- /dev/null +++ b/engines/zvision/detection_tables.h @@ -0,0 +1,277 @@ +/* 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. + * + */ + +#ifndef ZVISION_DETECTION_TABLES_H +#define ZVISION_DETECTION_TABLES_H + +namespace ZVision { + +static const PlainGameDescriptor zVisionGames[] = { + { "zvision", "Z-Vision Game" }, + { "znemesis", "Zork Nemesis: The Forbidden Lands" }, + { "zgi", "Zork: Grand Inquisitor" }, + { 0, 0 } +}; + +static const char *directoryGlobs[] = { + "znemscr", + 0 +}; + +#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 +#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2 +#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3 +#define GAMEOPTION_DISABLE_ANIM_WHILE_TURNING GUIO_GAMEOPTIONS4 +#define GAMEOPTION_USE_HIRES_MPEG_MOVIES GUIO_GAMEOPTIONS5 + +static const ADExtraGuiOptionsMap optionsList[] = { + + { + GAMEOPTION_ORIGINAL_SAVELOAD, + { + _s("Use original save/load screens"), + _s("Use the original save/load screens instead of the ScummVM interface"), + "originalsaveload", + false + } + }, + + { + GAMEOPTION_DOUBLE_FPS, + { + _s("Double FPS"), + _s("Increase framerate from 30 to 60 FPS"), + "doublefps", + false + } + }, + + { + GAMEOPTION_ENABLE_VENUS, + { + _s("Enable Venus"), + _s("Enable the Venus help system"), + "venusenabled", + true + } + }, + + { + GAMEOPTION_DISABLE_ANIM_WHILE_TURNING, + { + _s("Disable animation while turning"), + _s("Disable animation while turning in panorama mode"), + "noanimwhileturning", + false + } + }, + + { + GAMEOPTION_USE_HIRES_MPEG_MOVIES, + { + _s("Use high resolution MPEG video"), + _s("Use MPEG video from the DVD version, instead of lower resolution AVI"), + "mpegmovies", + true + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR +}; + +static const ZVisionGameDescription gameDescriptions[] = { + + { + // Zork Nemesis English version + { + "znemesis", + 0, + AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741), + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + + { + // Zork Nemesis French version + { + "znemesis", + 0, + { + { "CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873 }, + { "NEMESIS.STR", 0, "333bcb17bbb7f57cae742fbbe44f56f3", 9219 }, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + + { + // Zork Nemesis German version + { + "znemesis", + 0, + { + { "CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873 }, + { "NEMESIS.STR", 0, "3d1a12b907751653866cffc6d4dfb331", 9505 }, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + + { + // Zork Nemesis Italian version + { + "znemesis", + 0, + { + { "CSCR.ZFS", 0, "f04113357b4748c13efcb58b4629887c", 2577873 }, + { "NEMESIS.STR", 0, "7c568feca8d9f9ae855c47183612c305", 9061 }, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + + { + // Zork Nemesis English demo version + { + "znemesis", + "Demo", + AD_ENTRY1s("SCRIPTS.ZFS", "64f1e881394e9462305104f99513c833", 380539), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_DEMO, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_NEMESIS + }, + + { + // Zork Grand Inquisitor English CD version + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + + { + // Zork Grand Inquisitor French CD version, reported by ulrichh on IRC + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "4d1ec4ade7ecc9ee9ec591d43ca3d213", 8338133), + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + + { + // Zork Grand Inquisitor German CD version, reported by breit in bug #6760 + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "b7ac7e331b9b7f884590b0b325b560c8", 8338133), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + + { + // Zork Grand Inquisitor Spanish CD version, reported by dianiu in bug #6764 + { + "zgi", + "CD", + AD_ENTRY1s("SCRIPTS.ZFS", "5cdc4b99c1134053af135aae71326fd1", 8338141), + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + + { + // Zork Grand Inquisitor English DVD version + { + "zgi", + "DVD", + AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING, GAMEOPTION_USE_HIRES_MPEG_MOVIES) + }, + GID_GRANDINQUISITOR + }, + + { + // Zork Grand Inquisitor English demo version + { + "zgi", + "Demo", + AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_DEMO, + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) + }, + GID_GRANDINQUISITOR + }, + + { + AD_TABLE_END_MARKER, + GID_NONE + } +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index a14a31aa7c..124235e0e0 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -33,7 +33,6 @@ #include "zvision/sound/zork_raw.h" #include "zvision/zvision.h" -#include "zvision/detection.h" namespace ZVision { diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index f4564ee1ec..2c31cf7afe 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -23,7 +23,6 @@ #ifndef ZVISION_STRING_MANAGER_H #define ZVISION_STRING_MANAGER_H -#include "zvision/detection.h" #include "zvision/text/truetype_font.h" namespace Graphics { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index 9c170a3816..5dd872a440 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -24,7 +24,6 @@ #ifndef ZVISION_TEXT_H #define ZVISION_TEXT_H -#include "zvision/detection.h" #include "zvision/text/truetype_font.h" #include "zvision/zvision.h" diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index da80ff9d02..779fdc4464 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -29,7 +29,6 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/file/save_manager.h" #include "zvision/text/string_manager.h" -#include "zvision/detection.h" #include "zvision/scripting/menu.h" #include "zvision/file/search_manager.h" #include "zvision/text/text.h" @@ -184,10 +183,10 @@ void ZVision::initialize() { _searchManager->addDir("FONTS"); _searchManager->addDir("addon"); - if (_gameDescription->gameId == GID_GRANDINQUISITOR) { + if (getGameId() == GID_GRANDINQUISITOR) { if (!_searchManager->loadZix("INQUIS.ZIX")) error("Unable to load file INQUIS.ZIX"); - } else if (_gameDescription->gameId == GID_NEMESIS) { + } else if (getGameId() == GID_NEMESIS) { if (!_searchManager->loadZix("NEMESIS.ZIX")) { // The game might not be installed, try MEDIUM.ZIX instead if (!_searchManager->loadZix("ZNEMSCR/MEDIUM.ZIX")) @@ -209,7 +208,7 @@ void ZVision::initialize() { _textRenderer = new TextRenderer(this); _midiManager = new MidiManager(); - if (_gameDescription->gameId == GID_GRANDINQUISITOR) + if (getGameId() == GID_GRANDINQUISITOR) _menu = new MenuZGI(this); else _menu = new MenuNemesis(this); @@ -217,7 +216,7 @@ void ZVision::initialize() { // Initialize the managers _cursorManager->initialize(); _scriptManager->initialize(); - _stringManager->initialize(_gameDescription->gameId); + _stringManager->initialize(getGameId()); registerDefaultSettings(); @@ -396,8 +395,8 @@ void ZVision::fpsTimer() { } void ZVision::initScreen() { - uint16 workingWindowWidth = (_gameDescription->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; - uint16 workingWindowHeight = (_gameDescription->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; + uint16 workingWindowWidth = (getGameId() == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; + uint16 workingWindowHeight = (getGameId() == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; _workingWindow = Common::Rect( (WINDOW_WIDTH - workingWindowWidth) / 2, (WINDOW_HEIGHT - workingWindowHeight) / 2, diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 6cfc0f5d54..7a331ce37a 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -24,7 +24,6 @@ #ifndef ZVISION_ZVISION_H #define ZVISION_ZVISION_H -#include "zvision/detection.h" #include "zvision/core/clock.h" #include "zvision/file/search_manager.h" @@ -87,6 +86,12 @@ enum { KEYBUF_SIZE = 20 }; +enum ZVisionGameId { + GID_NONE = 0, + GID_NEMESIS = 1, + GID_GRANDINQUISITOR = 2 +}; + class ZVision : public Engine { public: ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc); @@ -142,11 +147,13 @@ private: uint8 _cheatBuffer[KEYBUF_SIZE]; public: - uint32 getFeatures() const; - Common::Language getLanguage() const; Common::Error run(); void pauseEngineIntern(bool pause); + ZVisionGameId ZVision::getGameId() const; + Common::Language ZVision::getLanguage() const; + uint32 ZVision::getFeatures() const; + ScriptManager *getScriptManager() const { return _scriptManager; } @@ -174,12 +181,10 @@ public: MenuHandler *getMenuHandler() const { return _menu; } + Common::RandomSource *getRandomSource() const { return _rnd; } - ZVisionGameId getGameId() const { - return _gameDescription->gameId; - } int16 getKeyboardVelocity() const { return _keyboardVelocity; } -- cgit v1.2.3 From b9ecc5546229b88b1946719cd6653cb621e2f05d Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 8 Jul 2015 00:16:06 +0200 Subject: ZVISION: Fix build --- engines/zvision/zvision.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 7a331ce37a..4c948faaa4 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -150,9 +150,9 @@ public: Common::Error run(); void pauseEngineIntern(bool pause); - ZVisionGameId ZVision::getGameId() const; - Common::Language ZVision::getLanguage() const; - uint32 ZVision::getFeatures() const; + ZVisionGameId getGameId() const; + Common::Language getLanguage() const; + uint32 getFeatures() const; ScriptManager *getScriptManager() const { return _scriptManager; -- cgit v1.2.3 From 856475067a0f78449db213afb79390e8fb7c095d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 19 Jul 2015 17:09:43 +0200 Subject: MISC: Remove some unused private member variables --- engines/zvision/scripting/actions.h | 1 - engines/zvision/scripting/controls/input_control.cpp | 1 - engines/zvision/scripting/controls/input_control.h | 3 --- 3 files changed, 5 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index ff19fc54fc..bde1baa291 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -269,7 +269,6 @@ public: bool execute(); private: - uint32 _animationKey; uint32 _controlKey; uint32 _x1; uint32 _y1; diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index df0c77ba96..9525333ef0 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -43,7 +43,6 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _nextTabstop(0), _focused(false), _textChanged(false), - _cursorOffset(0), _enterPressed(false), _readOnly(false), _txtWidth(0), diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 9b48514e16..6abdb3c692 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -51,15 +51,12 @@ private: Common::String _currentInputText; bool _textChanged; - uint _cursorOffset; bool _enterPressed; bool _readOnly; int16 _txtWidth; int16 _maxTxtWidth; Video::VideoDecoder *_animation; - int32 _frameDelay; - int16 _frame; public: void focus() { -- cgit v1.2.3 From ba4469da6a111e208d40808cba50e797180a8edd Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 12 Aug 2015 19:18:07 -0400 Subject: ZVISION: Cleanup the AVI decoder subclass --- engines/zvision/video/zork_avi_decoder.cpp | 44 +++++++++++------------------- engines/zvision/video/zork_avi_decoder.h | 12 ++------ 2 files changed, 19 insertions(+), 37 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index cf8505ec82..e69b27baf6 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -34,44 +34,32 @@ namespace ZVision { Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) { - ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType); - return (Video::AVIDecoder::AVIAudioTrack *)audioTrack; + if (wvInfo.tag != kWaveFormatZorkPCM) + return new AVIAudioTrack(sHeader, wvInfo, _soundType); + + assert(wvInfo.size == 8); + return new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType); } -void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { - bool updateCurChunk = true; - if (_audStream) { - if (_wvInfo.tag == kWaveFormatZorkPCM) { - assert(_wvInfo.size == 8); - RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream); - delete stream; +void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { + RawChunkStream::RawChunk chunk = _decoder.readNextChunk(stream); + delete stream; - if (chunk.data) { - byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; + if (chunk.data) { + byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; #ifdef SCUMM_LITTLE_ENDIAN - // RawChunkStream produces native endianness int16 - flags |= Audio::FLAG_LITTLE_ENDIAN; + // RawChunkStream produces native endianness int16 + flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); - } - } else { - updateCurChunk = false; - AVIAudioTrack::queueSound(stream); - } - } else { - delete stream; + _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); } - // The superclass always updates _curChunk, whether or not audio has - // been queued, so we should do that too. Unless the superclass already - // has done it for us. - if (updateCurChunk) { - _curChunk++; - } + _curChunk++; } void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() { - decoder->init(); + AVIAudioTrack::resetStream(); + _decoder.init(); } } // End of namespace ZVision diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index 89c0d1e4b9..8e7be710ee 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -41,20 +41,14 @@ private: public: ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), - decoder(NULL) { - if (_audStream) { - decoder = new RawChunkStream(_audStream->isStereo()); - } - } - virtual ~ZorkAVIAudioTrack() { - if (decoder) - delete decoder; + _decoder(waveFormat.channels == 2) { } void queueSound(Common::SeekableReadStream *stream); void resetStream(); + private: - RawChunkStream *decoder; + RawChunkStream _decoder; }; Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo); -- cgit v1.2.3 From de2f4e698270937251f0655c19555fb9099df55f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 9 Aug 2015 20:05:40 -0400 Subject: VIDEO: Add support for MP3 in AVI --- engines/zvision/video/zork_avi_decoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index e69b27baf6..53b0a9a0c5 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -51,7 +51,7 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s // RawChunkStream produces native endianness int16 flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); + _queueStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); } _curChunk++; -- cgit v1.2.3 From 561d1a1d62b8abd3f5ff51d66e0c32ea436e68de Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 11 Aug 2015 22:54:00 -0400 Subject: VIDEO: Switch to all packetized streams for AVI ZVision does not currently, but that's OK --- engines/zvision/video/zork_avi_decoder.cpp | 9 +++++++++ engines/zvision/video/zork_avi_decoder.h | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 53b0a9a0c5..fb6bdbab91 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -41,6 +41,15 @@ Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDec return new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType); } +ZorkAVIDecoder::ZorkAVIAudioTrack::ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : + Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), _queueStream(0), _decoder(waveFormat.channels == 2) { +} + +void ZorkAVIDecoder::ZorkAVIAudioTrack::createAudioStream() { + _queueStream = Audio::makeQueuingAudioStream(_wvInfo.samplesPerSec, _wvInfo.channels == 2); + _audioStream = _queueStream; +} + void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { RawChunkStream::RawChunk chunk = _decoder.readNextChunk(stream); delete stream; diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index 8e7be710ee..afcdb05676 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -39,15 +39,14 @@ public: private: class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack { public: - ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : - Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), - _decoder(waveFormat.channels == 2) { - } + ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType); + void createAudioStream(); void queueSound(Common::SeekableReadStream *stream); void resetStream(); private: + Audio::QueuingAudioStream *_queueStream; RawChunkStream _decoder; }; -- cgit v1.2.3 From b046479cabd33bf8d11ef3b3bdce841ab0521c59 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Sun, 6 Sep 2015 15:21:13 +0200 Subject: I18N: Add missing files in list of files to parse. Regenerate translation files. --- engines/zvision/POTFILES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/POTFILES b/engines/zvision/POTFILES index 48e2782648..61cf42ded2 100644 --- a/engines/zvision/POTFILES +++ b/engines/zvision/POTFILES @@ -1 +1 @@ -engines/zvision/detection.cpp +engines/zvision/detection_tables.h -- cgit v1.2.3 From 2dc27b57a68cfa9ddab48b193f9a7bb6276aff58 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 9 Sep 2015 17:23:23 +0300 Subject: ZVISION: Properly handle monophonic videos in the demo version of ZGI --- engines/zvision/video/zork_avi_decoder.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/zvision') diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index fb6bdbab91..1d23546551 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -55,7 +55,9 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s delete stream; if (chunk.data) { - byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; + byte flags = Audio::FLAG_16BITS; + if (_wvInfo.channels == 2) + flags |= Audio::FLAG_STEREO; #ifdef SCUMM_LITTLE_ENDIAN // RawChunkStream produces native endianness int16 flags |= Audio::FLAG_LITTLE_ENDIAN; -- cgit v1.2.3