2009-06-01 18:05:46 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-07-08 19:17:47 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-06-01 18:05:46 +00:00
|
|
|
* 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.
|
2009-06-12 14:19:33 +00:00
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
2009-06-01 18:05:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ASYLUM_ENGINE_H
|
|
|
|
#define ASYLUM_ENGINE_H
|
|
|
|
|
2010-11-27 00:04:04 +00:00
|
|
|
#include "asylum/resources/data.h"
|
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
#include "asylum/console.h"
|
2010-11-27 00:03:32 +00:00
|
|
|
#include "asylum/eventhandler.h"
|
2010-11-03 04:28:19 +00:00
|
|
|
#include "asylum/shared.h"
|
2010-11-03 04:27:47 +00:00
|
|
|
|
2010-03-31 10:01:54 +00:00
|
|
|
#include "common/random.h"
|
2010-11-03 04:27:47 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
2010-03-31 10:01:54 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
#include "engines/advancedDetector.h"
|
2009-06-01 18:05:46 +00:00
|
|
|
#include "engines/engine.h"
|
2009-06-13 14:44:43 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
/**
|
|
|
|
* This is the namespace of the Asylum engine.
|
|
|
|
*
|
|
|
|
* Status of this engine:
|
|
|
|
* - Code for scrolling and showing up objects and actors (properly clipped) is present
|
|
|
|
* - A preliminary script interpreter is implemented, and game scripts are read and partially parsed,
|
|
|
|
* actors are now drawn in the scene, and there is some interaction with the environment (e.g. "examine" actions).
|
|
|
|
* - Movie code is almost complete
|
|
|
|
* - Scene information is partially read, and the scene hotspots are created correctly.
|
|
|
|
* - Mouse cursor is initialized and animated properly
|
|
|
|
* - Game texts and game fonts are read correctly
|
|
|
|
* - Preliminary code for walking around with the mouse.
|
|
|
|
* - Some of the menu screens are working (like, for example, the credits screen)
|
|
|
|
*
|
|
|
|
* Maintainers:
|
|
|
|
* alexbevi, alexandrefontoura, bluegr
|
|
|
|
*
|
|
|
|
* Supported games:
|
|
|
|
* - Sanitarium
|
|
|
|
*/
|
2009-06-01 18:05:46 +00:00
|
|
|
namespace Asylum {
|
|
|
|
|
2010-11-03 04:29:37 +00:00
|
|
|
// If defined, will show the scene update times on the debugger output
|
|
|
|
//#define DEBUG_SCENE_TIMES
|
2009-12-03 21:35:28 +00:00
|
|
|
|
2010-12-07 02:52:44 +00:00
|
|
|
class Puzzle;
|
2010-11-08 21:09:13 +00:00
|
|
|
class Cursor;
|
2010-11-03 04:27:47 +00:00
|
|
|
class Encounter;
|
2010-10-05 19:50:24 +00:00
|
|
|
class MainMenu;
|
2010-11-08 21:09:02 +00:00
|
|
|
class ResourceManager;
|
2010-12-01 19:21:10 +00:00
|
|
|
class Savegame;
|
2009-06-12 22:42:45 +00:00
|
|
|
class Scene;
|
2009-06-05 02:51:23 +00:00
|
|
|
class Screen;
|
2010-12-02 09:29:26 +00:00
|
|
|
class ScriptManager;
|
2010-12-02 09:29:36 +00:00
|
|
|
class Special;
|
|
|
|
class Speech;
|
2009-06-13 23:03:37 +00:00
|
|
|
class Sound;
|
2010-11-03 04:27:47 +00:00
|
|
|
class Text;
|
2009-06-13 23:16:07 +00:00
|
|
|
class Video;
|
2009-06-05 02:51:23 +00:00
|
|
|
|
2009-06-01 18:05:46 +00:00
|
|
|
class AsylumEngine: public Engine {
|
2010-11-03 04:27:47 +00:00
|
|
|
protected:
|
|
|
|
// Engine APIs
|
2009-07-08 19:17:47 +00:00
|
|
|
virtual Common::Error run();
|
2010-11-03 04:27:47 +00:00
|
|
|
virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
|
2009-07-08 19:17:47 +00:00
|
|
|
virtual bool hasFeature(EngineFeature f) const;
|
2010-11-03 04:27:47 +00:00
|
|
|
virtual GUI::Debugger *getDebugger() { return _console; }
|
|
|
|
|
|
|
|
public:
|
2010-11-08 21:09:13 +00:00
|
|
|
enum StartGameType {
|
|
|
|
kStartGamePlayIntro,
|
|
|
|
kStartGameLoad,
|
|
|
|
kStartGameScene
|
|
|
|
};
|
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
AsylumEngine(OSystem *system, const ADGameDescription *gd);
|
|
|
|
virtual ~AsylumEngine();
|
2009-06-08 14:05:49 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
/**
|
2009-12-01 22:42:11 +00:00
|
|
|
* Start a new the game
|
|
|
|
*/
|
2010-11-08 21:09:13 +00:00
|
|
|
void startGame(ResourcePackId sceneId, StartGameType type);
|
|
|
|
|
2010-12-01 19:20:53 +00:00
|
|
|
/**
|
|
|
|
* Restarts the game
|
|
|
|
*/
|
|
|
|
void restart();
|
|
|
|
|
2010-11-08 21:09:13 +00:00
|
|
|
/**
|
|
|
|
* Switch to a new scene
|
|
|
|
*
|
|
|
|
* @param sceneId ResourcePack for the scene
|
|
|
|
*/
|
|
|
|
void switchScene(ResourcePackId sceneId) { startGame(sceneId, kStartGameScene); }
|
2009-12-01 22:42:11 +00:00
|
|
|
|
2010-11-16 14:24:46 +00:00
|
|
|
/**
|
2009-11-17 02:00:35 +00:00
|
|
|
* Wrapper function to the OSystem getMillis() method
|
2010-11-16 14:24:46 +00:00
|
|
|
*/
|
2010-11-16 14:24:17 +00:00
|
|
|
uint32 getTick() { return _system->getMillis(); }
|
2009-11-17 02:00:35 +00:00
|
|
|
|
2010-11-16 14:24:46 +00:00
|
|
|
/**
|
|
|
|
* Gets the shared data.
|
|
|
|
*
|
|
|
|
* @return a pointer to the shared data.
|
|
|
|
*/
|
|
|
|
SharedData *getData() { return &_data; }
|
|
|
|
|
2010-12-03 23:18:36 +00:00
|
|
|
/**
|
|
|
|
* Resets the game
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
2009-11-24 11:46:58 +00:00
|
|
|
/**
|
|
|
|
* This is the global tick counter.
|
|
|
|
*/
|
2010-11-16 14:24:46 +00:00
|
|
|
uint32 screenUpdateCount;
|
|
|
|
uint32 lastScreenUpdate;
|
2009-11-17 02:00:35 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Game
|
2010-11-08 21:09:13 +00:00
|
|
|
Cursor *cursor() { return _cursor; }
|
2010-11-08 21:09:02 +00:00
|
|
|
Encounter *encounter() { return _encounter; }
|
|
|
|
MainMenu *menu() { return _mainMenu; }
|
|
|
|
ResourceManager *resource() { return _resource; }
|
2010-12-01 19:21:10 +00:00
|
|
|
Savegame *savegame() { return _savegame; }
|
2010-11-08 21:09:02 +00:00
|
|
|
Scene *scene() { return _scene; }
|
|
|
|
Screen *screen() { return _screen; }
|
2010-12-02 09:29:26 +00:00
|
|
|
ScriptManager *script() { return _script; }
|
2010-12-02 09:29:36 +00:00
|
|
|
Special *special() { return _special; }
|
|
|
|
Speech *speech() { return _speech; }
|
2010-11-08 21:09:02 +00:00
|
|
|
Sound *sound() { return _sound; }
|
|
|
|
Text *text() { return _text; }
|
|
|
|
Video *video() { return _video; }
|
2010-10-05 19:50:24 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Flags
|
2010-12-02 09:30:15 +00:00
|
|
|
void setGameFlagByIndex(int32 index);
|
|
|
|
int32 getGameFlagByIndex(int32 index);
|
2010-11-03 04:28:19 +00:00
|
|
|
void setGameFlag(GameFlag flag);
|
|
|
|
void clearGameFlag(GameFlag flag);
|
|
|
|
void toggleGameFlag(GameFlag flag);
|
2010-11-16 14:24:17 +00:00
|
|
|
bool isGameFlagSet(GameFlag flag) const;
|
|
|
|
bool isGameFlagNotSet(GameFlag flag) const;
|
2010-12-02 09:30:15 +00:00
|
|
|
void resetFlags();
|
2009-12-01 22:42:11 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Misc
|
|
|
|
uint getRandom(uint max) { return _rnd.getRandomNumber(max); }
|
|
|
|
uint getRandomBit() { return _rnd.getRandomBit(); }
|
2009-06-12 20:38:38 +00:00
|
|
|
|
2010-11-27 00:04:43 +00:00
|
|
|
/**
|
|
|
|
* Switch message handler.
|
|
|
|
*
|
|
|
|
* @param handler If non-null, a pointer to an EventHandler class.
|
|
|
|
*/
|
|
|
|
void switchEventHandler(EventHandler *handler);
|
|
|
|
|
2010-12-02 15:18:56 +00:00
|
|
|
/**
|
|
|
|
* Notifies the current event handler of an event
|
|
|
|
*
|
|
|
|
* @param type The event type.
|
|
|
|
*/
|
|
|
|
void notify(AsylumEventType type);
|
|
|
|
|
2010-11-27 00:04:43 +00:00
|
|
|
/**
|
|
|
|
* Gets a message handler.
|
|
|
|
*
|
|
|
|
* @param index Zero-based index of the message handler
|
|
|
|
*
|
|
|
|
* @return The message handler.
|
|
|
|
*/
|
|
|
|
EventHandler* getPuzzle(uint32 index);
|
2010-11-03 04:29:08 +00:00
|
|
|
|
2010-12-01 19:22:09 +00:00
|
|
|
/**
|
|
|
|
* Updates the reverse stereo scene status from the config
|
|
|
|
*/
|
|
|
|
void updateReverseStereo();
|
|
|
|
|
2010-12-02 19:30:25 +00:00
|
|
|
/**
|
|
|
|
* Gets a sine cosine pair.
|
|
|
|
*
|
|
|
|
* @param index1 The first index.
|
|
|
|
* @param index2 The second index.
|
|
|
|
*
|
|
|
|
* @return The sine cosine values.
|
|
|
|
*/
|
|
|
|
Common::Point getSinCosValues(int32 index1, int32 index2);
|
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
private:
|
|
|
|
const ADGameDescription *_gameDescription;
|
2009-06-05 02:51:23 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Misc
|
|
|
|
Console *_console;
|
|
|
|
Common::RandomSource _rnd;
|
2009-08-09 22:56:13 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Game
|
2010-11-08 21:09:13 +00:00
|
|
|
Cursor *_cursor;
|
2010-11-08 21:09:02 +00:00
|
|
|
Encounter *_encounter;
|
|
|
|
MainMenu *_mainMenu;
|
|
|
|
ResourceManager *_resource;
|
2010-12-01 19:21:10 +00:00
|
|
|
Savegame *_savegame;
|
2010-11-08 21:09:02 +00:00
|
|
|
Scene *_scene;
|
|
|
|
Screen *_screen;
|
2010-12-02 09:29:26 +00:00
|
|
|
ScriptManager *_script;
|
2010-12-02 09:29:36 +00:00
|
|
|
Special *_special;
|
|
|
|
Speech *_speech;
|
2010-11-08 21:09:02 +00:00
|
|
|
Sound *_sound;
|
|
|
|
Text *_text;
|
|
|
|
Video *_video;
|
2009-06-21 12:09:44 +00:00
|
|
|
|
2010-11-27 00:04:43 +00:00
|
|
|
// Current EventHandler class instance
|
|
|
|
EventHandler *_handler;
|
2010-12-07 02:52:44 +00:00
|
|
|
Puzzle *_puzzles[16];
|
2010-11-27 00:04:43 +00:00
|
|
|
|
2010-12-01 19:21:21 +00:00
|
|
|
// Game data
|
2010-11-16 14:24:46 +00:00
|
|
|
SharedData _data;
|
2010-12-02 09:30:15 +00:00
|
|
|
int _gameFlags[145];
|
2010-12-01 19:22:30 +00:00
|
|
|
bool _introPlayed;
|
2010-12-03 00:08:47 +00:00
|
|
|
int32 _sinCosTables[72];
|
2009-09-19 14:25:43 +00:00
|
|
|
|
2010-12-01 19:21:21 +00:00
|
|
|
void handleEvents();
|
2010-11-03 04:27:47 +00:00
|
|
|
void updateMouseCursor();
|
|
|
|
void processDelayedEvents();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the intro
|
|
|
|
*/
|
|
|
|
void playIntro();
|
|
|
|
|
2010-11-27 00:04:43 +00:00
|
|
|
/**
|
|
|
|
* Initializes the puzzles
|
|
|
|
*/
|
|
|
|
void initPuzzles();
|
|
|
|
|
2010-12-01 19:22:30 +00:00
|
|
|
/**
|
|
|
|
* Initializes the sine/cosine tables.
|
|
|
|
*/
|
2010-12-03 00:08:47 +00:00
|
|
|
void initSinCosTables(double a2, int32 a3, int32 a4);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the offset into the sine/cosine tables.
|
|
|
|
*
|
|
|
|
* @param val The value.
|
|
|
|
*
|
|
|
|
* @return The calculated offset.
|
|
|
|
*/
|
|
|
|
int32 computeSinCosOffset(int32 val);
|
2010-12-01 19:22:30 +00:00
|
|
|
|
2009-06-21 12:09:44 +00:00
|
|
|
friend class Console;
|
2009-06-01 18:05:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Asylum
|
|
|
|
|
|
|
|
#endif
|