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-03 04:27:47 +00:00
|
|
|
#include "asylum/console.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 {
|
|
|
|
|
2009-09-25 13:19:46 +00:00
|
|
|
// XXX
|
2010-01-13 11:53:51 +00:00
|
|
|
// If defined, this will play the scene title loading up
|
2009-09-25 13:19:46 +00:00
|
|
|
// progress before the scene is entered. This is
|
|
|
|
// just a convenience, as there's no need for the type
|
|
|
|
// of pre-loading that was performed in the original
|
2010-11-03 04:29:32 +00:00
|
|
|
#define SHOW_SCENE_LOADING
|
2009-09-25 01:05:23 +00:00
|
|
|
|
2010-11-03 04:28:14 +00:00
|
|
|
//#define SHOW_SCENE_TIMES
|
|
|
|
|
2009-12-03 21:35:28 +00:00
|
|
|
// XXX If defined, this flag will prevent the intro movies
|
|
|
|
// from being played whenever the engine is started
|
2010-01-13 11:53:51 +00:00
|
|
|
#define SKIP_INTRO
|
2009-12-03 21:35:28 +00:00
|
|
|
|
2009-09-20 21:10:43 +00:00
|
|
|
// XXX
|
|
|
|
// I'm not sure if system endian-ness would have any
|
2009-09-25 13:19:46 +00:00
|
|
|
// effect on the byte order of the data files, but I guess
|
2009-09-20 21:10:43 +00:00
|
|
|
// it won't hurt to keep this here until we can test
|
|
|
|
// on a big-endian system
|
|
|
|
#ifndef SCUMM_BIG_ENDIAN
|
|
|
|
#define LOBYTE(word) (word & 0xFF)
|
|
|
|
#else
|
|
|
|
#define LOBYTE(word) ((word >> 24) & 0xFF)
|
|
|
|
#endif
|
|
|
|
|
2010-11-03 04:28:19 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Flags
|
|
|
|
enum FlagType {
|
|
|
|
kFlagType1 = 0,
|
2010-11-03 04:28:35 +00:00
|
|
|
kFlagType2,
|
|
|
|
kFlagTypeSkipDraw,
|
|
|
|
kFlagTypeSceneRectChanged
|
2010-11-03 04:28:19 +00:00
|
|
|
};
|
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
class Encounter;
|
2010-10-05 19:50:24 +00:00
|
|
|
class MainMenu;
|
2009-06-12 22:42:45 +00:00
|
|
|
class Scene;
|
2009-06-05 02:51:23 +00:00
|
|
|
class Screen;
|
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-03 04:29:08 +00:00
|
|
|
typedef Common::Functor1<Common::Event &, void> MessageHandler;
|
|
|
|
|
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-10-05 19:50:24 +00:00
|
|
|
void startGame();
|
2009-12-01 22:42:11 +00:00
|
|
|
|
2009-11-17 02:00:35 +00:00
|
|
|
/**
|
|
|
|
* Wrapper function to the OSystem getMillis() method
|
|
|
|
*/
|
2009-12-04 03:14:07 +00:00
|
|
|
int32 getTick() { return (int32)_system->getMillis(); }
|
2009-11-17 02:00:35 +00:00
|
|
|
|
2009-11-24 11:46:58 +00:00
|
|
|
/**
|
|
|
|
* This is the global tick counter.
|
|
|
|
*/
|
2010-11-03 04:29:24 +00:00
|
|
|
uint32 globalTickValue;
|
|
|
|
uint32 globalTickValue_2;
|
2009-11-17 02:00:35 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
// Game
|
2010-11-03 04:29:18 +00:00
|
|
|
Encounter *encounter() { return _encounter; }
|
|
|
|
MainMenu *menu() { return _mainMenu; }
|
|
|
|
Scene *scene() { return _scene; }
|
|
|
|
Screen *screen() { return _screen; }
|
|
|
|
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-11-03 04:28:19 +00:00
|
|
|
void setGameFlag(GameFlag flag);
|
|
|
|
void clearGameFlag(GameFlag flag);
|
|
|
|
void toggleGameFlag(GameFlag flag);
|
|
|
|
bool isGameFlagSet(GameFlag flag);
|
|
|
|
bool isGameFlagNotSet(GameFlag flag);
|
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-03 04:28:02 +00:00
|
|
|
// Flags
|
|
|
|
void setFlag(FlagType flag) { setFlag(flag, true); }
|
|
|
|
void clearFlag(FlagType flag) { setFlag(flag, false); }
|
|
|
|
|
2010-11-03 04:29:08 +00:00
|
|
|
// Message handler
|
|
|
|
void switchMessageHandler(MessageHandler *handler);
|
|
|
|
MessageHandler *getMessageHandler(uint32 index);
|
|
|
|
|
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-03 04:29:08 +00:00
|
|
|
Encounter *_encounter;
|
2010-10-05 19:50:24 +00:00
|
|
|
MainMenu *_mainMenu;
|
2010-11-03 04:27:47 +00:00
|
|
|
Scene *_scene;
|
2009-08-07 12:03:23 +00:00
|
|
|
Screen *_screen;
|
|
|
|
Sound *_sound;
|
2009-09-25 01:05:23 +00:00
|
|
|
Text *_text;
|
2010-11-03 04:27:47 +00:00
|
|
|
Video *_video;
|
2009-06-21 12:09:44 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
bool _introPlaying;
|
2009-09-19 14:25:43 +00:00
|
|
|
int _gameFlags[1512];
|
2010-11-03 04:28:35 +00:00
|
|
|
bool _flags[4];
|
2009-09-19 14:25:43 +00:00
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
void handleEvents(bool doUpdate);
|
|
|
|
void waitForTimer(int msec_delay);
|
|
|
|
void updateMouseCursor();
|
|
|
|
void processDelayedEvents();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Play the intro
|
|
|
|
*/
|
|
|
|
void playIntro();
|
|
|
|
|
2010-11-03 04:28:02 +00:00
|
|
|
void setFlag(FlagType flag, bool isSet);
|
|
|
|
|
2009-06-21 12:09:44 +00:00
|
|
|
friend class Console;
|
2009-06-01 18:05:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Asylum
|
|
|
|
|
|
|
|
#endif
|