2013-07-03 17:50:40 -05:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
2013-07-03 17:50:40 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2016-09-03 12:46:38 +02:00
|
|
|
*
|
2013-07-03 17:50:40 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-10-01 18:50:36 -05:00
|
|
|
#ifndef ZVISION_ZVISION_H
|
|
|
|
#define ZVISION_ZVISION_H
|
2013-07-03 17:50:40 -05:00
|
|
|
|
2014-12-16 01:21:57 +02:00
|
|
|
#include "zvision/core/clock.h"
|
2014-12-16 01:14:37 +02:00
|
|
|
#include "zvision/file/search_manager.h"
|
2013-10-01 20:08:41 -05:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
#include "common/random.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
|
|
|
|
#include "engines/engine.h"
|
|
|
|
|
2013-08-04 23:10:27 -05:00
|
|
|
#include "graphics/pixelformat.h"
|
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
#include "gui/debugger.h"
|
2013-08-04 23:10:27 -05:00
|
|
|
|
|
|
|
namespace Video {
|
|
|
|
class VideoDecoder;
|
|
|
|
}
|
|
|
|
|
2014-12-27 14:29:17 +02:00
|
|
|
/**
|
|
|
|
* This is the namespace of the ZVision engine.
|
|
|
|
*
|
|
|
|
* Status of this engine: complete
|
|
|
|
*
|
|
|
|
* Games using this engine:
|
|
|
|
* - Zork Nemesis: The Forbidden Lands
|
|
|
|
* - Zork: Grand Inquisitor
|
|
|
|
*
|
|
|
|
*/
|
2013-07-03 17:50:40 -05:00
|
|
|
namespace ZVision {
|
|
|
|
|
|
|
|
struct ZVisionGameDescription;
|
|
|
|
class Console;
|
2013-07-11 00:08:00 -05:00
|
|
|
class ScriptManager;
|
2013-07-19 11:07:58 -05:00
|
|
|
class RenderManager;
|
2013-08-09 18:33:15 -05:00
|
|
|
class CursorManager;
|
2013-09-15 14:55:59 -05:00
|
|
|
class StringManager;
|
2013-09-04 00:18:05 -05:00
|
|
|
class SaveManager;
|
2014-12-13 03:42:07 +02:00
|
|
|
class RLFDecoder;
|
2014-11-20 14:48:24 +06:00
|
|
|
class MenuHandler;
|
|
|
|
class TextRenderer;
|
2014-03-02 00:03:25 +07:00
|
|
|
class Subtitle;
|
2014-11-20 14:48:24 +06:00
|
|
|
class MidiManager;
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2015-01-10 21:32:15 +02:00
|
|
|
enum {
|
|
|
|
WINDOW_WIDTH = 640,
|
|
|
|
WINDOW_HEIGHT = 480,
|
|
|
|
|
|
|
|
HIRES_WINDOW_WIDTH = 800,
|
|
|
|
HIRES_WINDOW_HEIGHT = 600,
|
|
|
|
|
2015-06-10 16:56:04 +01:00
|
|
|
// Zork Nemesis working window sizes
|
|
|
|
ZNM_WORKING_WINDOW_WIDTH = 512,
|
2015-01-10 21:32:15 +02:00
|
|
|
ZNM_WORKING_WINDOW_HEIGHT = 320,
|
|
|
|
|
|
|
|
// ZGI working window sizes
|
2015-06-10 16:56:04 +01:00
|
|
|
ZGI_WORKING_WINDOW_WIDTH = 640,
|
2015-01-10 21:32:15 +02:00
|
|
|
ZGI_WORKING_WINDOW_HEIGHT = 344,
|
|
|
|
|
|
|
|
ROTATION_SCREEN_EDGE_OFFSET = 60,
|
|
|
|
MAX_ROTATION_SPEED = 400, // Pixels per second
|
|
|
|
|
|
|
|
KEYBUF_SIZE = 20
|
|
|
|
};
|
|
|
|
|
2015-06-10 17:17:34 +01:00
|
|
|
enum ZVisionGameId {
|
|
|
|
GID_NONE = 0,
|
|
|
|
GID_NEMESIS = 1,
|
|
|
|
GID_GRANDINQUISITOR = 2
|
|
|
|
};
|
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
class ZVision : public Engine {
|
|
|
|
public:
|
|
|
|
ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
|
|
|
|
~ZVision();
|
|
|
|
|
2013-08-23 23:50:33 -05:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* A Rectangle centered inside the actual window. All in-game coordinates
|
|
|
|
* are given in this coordinate space. Also, all images are clipped to the
|
|
|
|
* edges of this Rectangle
|
|
|
|
*/
|
2014-12-15 03:15:30 +02:00
|
|
|
Common::Rect _workingWindow;
|
2014-12-24 22:26:23 +02:00
|
|
|
const Graphics::PixelFormat _resourcePixelFormat;
|
|
|
|
const Graphics::PixelFormat _screenPixelFormat;
|
2013-08-23 23:50:33 -05:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
private:
|
|
|
|
Console *_console;
|
|
|
|
const ZVisionGameDescription *_gameDescription;
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2013-08-05 19:07:55 -05:00
|
|
|
const int _desiredFrameTime;
|
2013-07-03 17:50:40 -05:00
|
|
|
|
|
|
|
// We need random numbers
|
|
|
|
Common::RandomSource *_rnd;
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2013-07-08 16:04:18 -05:00
|
|
|
// Managers
|
2013-07-03 17:50:40 -05:00
|
|
|
ScriptManager *_scriptManager;
|
2013-07-19 11:07:58 -05:00
|
|
|
RenderManager *_renderManager;
|
2013-08-09 18:33:15 -05:00
|
|
|
CursorManager *_cursorManager;
|
2013-09-15 14:55:59 -05:00
|
|
|
StringManager *_stringManager;
|
2014-11-20 14:48:24 +06:00
|
|
|
SearchManager *_searchManager;
|
|
|
|
TextRenderer *_textRenderer;
|
|
|
|
MidiManager *_midiManager;
|
2015-06-10 16:56:04 +01:00
|
|
|
SaveManager *_saveManager;
|
|
|
|
MenuHandler *_menu;
|
2013-07-19 11:07:58 -05:00
|
|
|
|
2013-08-04 23:10:27 -05:00
|
|
|
// Clock
|
2013-08-04 23:54:53 -05:00
|
|
|
Clock _clock;
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2013-11-01 16:44:44 +07:00
|
|
|
// Audio ID
|
2014-11-20 14:48:24 +06:00
|
|
|
int _audioId;
|
2013-11-01 16:44:44 +07:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
// To prevent allocation every time we process events
|
|
|
|
Common::Event _event;
|
|
|
|
|
2014-12-19 11:14:10 -06:00
|
|
|
int _frameRenderDelay;
|
2014-12-26 23:18:54 +02:00
|
|
|
int _renderedFrameCount;
|
|
|
|
int _fps;
|
2014-11-12 15:55:10 +06:00
|
|
|
int16 _mouseVelocity;
|
2014-12-19 11:14:10 -06:00
|
|
|
int16 _keyboardVelocity;
|
2014-12-26 12:07:21 +02:00
|
|
|
bool _doubleFPS;
|
2014-12-08 01:08:27 +02:00
|
|
|
bool _videoIsPlaying;
|
2014-11-12 15:47:27 +06:00
|
|
|
|
2014-12-19 11:14:10 -06:00
|
|
|
uint8 _cheatBuffer[KEYBUF_SIZE];
|
2015-06-10 16:56:04 +01:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
public:
|
2013-08-04 23:10:27 -05:00
|
|
|
Common::Error run();
|
2013-08-04 23:55:36 -05:00
|
|
|
void pauseEngineIntern(bool pause);
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2015-07-08 00:16:06 +02:00
|
|
|
ZVisionGameId getGameId() const;
|
|
|
|
Common::Language getLanguage() const;
|
|
|
|
uint32 getFeatures() const;
|
2015-06-10 17:17:34 +01:00
|
|
|
|
2013-10-20 18:39:06 +00:00
|
|
|
ScriptManager *getScriptManager() const {
|
|
|
|
return _scriptManager;
|
|
|
|
}
|
|
|
|
RenderManager *getRenderManager() const {
|
|
|
|
return _renderManager;
|
|
|
|
}
|
|
|
|
CursorManager *getCursorManager() const {
|
|
|
|
return _cursorManager;
|
|
|
|
}
|
|
|
|
SaveManager *getSaveManager() const {
|
|
|
|
return _saveManager;
|
|
|
|
}
|
|
|
|
StringManager *getStringManager() const {
|
|
|
|
return _stringManager;
|
|
|
|
}
|
2014-11-20 14:48:24 +06:00
|
|
|
SearchManager *getSearchManager() const {
|
2014-02-04 08:32:02 +07:00
|
|
|
return _searchManager;
|
|
|
|
}
|
2014-11-20 14:48:24 +06:00
|
|
|
TextRenderer *getTextRenderer() const {
|
2014-02-24 22:31:06 +07:00
|
|
|
return _textRenderer;
|
|
|
|
}
|
2014-11-20 14:48:24 +06:00
|
|
|
MidiManager *getMidiManager() const {
|
2014-10-22 11:44:49 +07:00
|
|
|
return _midiManager;
|
|
|
|
}
|
2014-12-26 13:14:24 +02:00
|
|
|
MenuHandler *getMenuHandler() const {
|
|
|
|
return _menu;
|
|
|
|
}
|
2015-06-10 17:17:34 +01:00
|
|
|
|
2013-10-20 18:39:06 +00:00
|
|
|
Common::RandomSource *getRandomSource() const {
|
|
|
|
return _rnd;
|
|
|
|
}
|
2014-12-26 13:14:24 +02:00
|
|
|
int16 getKeyboardVelocity() const {
|
|
|
|
return _keyboardVelocity;
|
|
|
|
}
|
|
|
|
int16 getMouseVelocity() const {
|
|
|
|
return _mouseVelocity;
|
|
|
|
}
|
2013-07-13 11:34:28 -05:00
|
|
|
|
2014-12-03 02:11:50 +02:00
|
|
|
uint8 getZvisionKey(Common::KeyCode scummKeyCode);
|
|
|
|
|
2014-12-26 12:41:36 +02:00
|
|
|
void startClock() {
|
|
|
|
_clock.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void stopClock() {
|
|
|
|
_clock.stop();
|
|
|
|
}
|
|
|
|
|
2015-01-07 11:22:26 +02:00
|
|
|
void initScreen();
|
2015-01-10 21:32:15 +02:00
|
|
|
void initHiresScreen();
|
2015-01-07 11:22:26 +02:00
|
|
|
|
2013-08-14 12:04:13 -05:00
|
|
|
/**
|
|
|
|
* Play a video until it is finished. This is a blocking call. It will call
|
|
|
|
* _clock.stop() when the video starts and _clock.start() when the video finishes.
|
|
|
|
* It will also consume all events during video playback.
|
|
|
|
*
|
|
|
|
* @param videoDecoder The video to play
|
|
|
|
* @param destRect Where to put the video. (In working window coords)
|
|
|
|
* @param skippable If true, the video can be skipped at any time using [Spacebar]
|
|
|
|
*/
|
2014-03-02 00:03:25 +07:00
|
|
|
void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL);
|
2014-12-16 00:48:16 +02:00
|
|
|
Video::VideoDecoder *loadAnimation(const Common::String &fileName);
|
2013-08-04 23:10:27 -05:00
|
|
|
|
2013-09-04 00:12:41 -05:00
|
|
|
Common::String generateSaveFileName(uint slot);
|
|
|
|
|
2013-12-24 14:38:11 +07:00
|
|
|
void setRenderDelay(uint);
|
|
|
|
bool canRender();
|
2014-12-26 23:18:54 +02:00
|
|
|
static void fpsTimerCallback(void *refCon);
|
|
|
|
void fpsTimer();
|
|
|
|
int getFPS() const {
|
|
|
|
return _fps;
|
|
|
|
}
|
2013-12-24 14:38:11 +07:00
|
|
|
|
2014-12-27 14:29:17 +02:00
|
|
|
GUI::Debugger *getDebugger();
|
|
|
|
void syncSoundSettings();
|
|
|
|
|
2014-11-07 10:21:24 +06:00
|
|
|
void loadSettings();
|
|
|
|
void saveSettings();
|
|
|
|
|
2014-11-12 14:47:12 +06:00
|
|
|
bool ifQuit();
|
|
|
|
|
2014-12-08 01:08:27 +02:00
|
|
|
// Engine features
|
|
|
|
bool hasFeature(EngineFeature f) const;
|
|
|
|
bool canLoadGameStateCurrently();
|
|
|
|
bool canSaveGameStateCurrently();
|
|
|
|
Common::Error loadGameState(int slot);
|
|
|
|
Common::Error saveGameState(int slot, const Common::String &desc);
|
2015-06-10 16:56:04 +01:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
private:
|
|
|
|
void initialize();
|
2013-09-15 14:08:14 -05:00
|
|
|
void initFonts();
|
|
|
|
|
|
|
|
void parseStrFile(const Common::String fileName);
|
2013-07-03 17:50:40 -05:00
|
|
|
|
2013-08-14 12:04:13 -05:00
|
|
|
/** Called every frame from ZVision::run() to process any events from EventMan */
|
2013-07-03 17:50:40 -05:00
|
|
|
void processEvents();
|
2013-08-14 12:04:13 -05:00
|
|
|
|
2013-06-19 14:12:03 -05:00
|
|
|
void onMouseMove(const Common::Point &pos);
|
2014-11-07 10:21:24 +06:00
|
|
|
|
|
|
|
void registerDefaultSettings();
|
2014-11-12 15:50:18 +06:00
|
|
|
void shortKeys(Common::Event);
|
2014-11-12 15:47:27 +06:00
|
|
|
|
|
|
|
void cheatCodes(uint8 key);
|
|
|
|
void pushKeyToCheatBuf(uint8 key);
|
|
|
|
bool checkCode(const char *code);
|
|
|
|
uint8 getBufferedKey(uint8 pos);
|
2013-07-03 17:50:40 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace ZVision
|
2013-10-20 18:39:06 +00:00
|
|
|
|
2013-07-03 17:50:40 -05:00
|
|
|
#endif
|