2007-05-30 21:56:52 +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.
|
2005-04-05 15:07:40 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-04-05 15:07:40 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 15:07:40 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 15:07:40 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-04-05 18:08:02 +00:00
|
|
|
#ifndef GOB_GOB_H
|
|
|
|
#define GOB_GOB_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "common/system.h"
|
2006-11-19 17:52:52 +00:00
|
|
|
#include "common/savefile.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-09-23 00:42:35 +00:00
|
|
|
#include "engines/engine.h"
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
class Game;
|
|
|
|
class Snd;
|
|
|
|
class Video;
|
|
|
|
class Global;
|
|
|
|
class Draw;
|
|
|
|
class CDROM;
|
|
|
|
class DataIO;
|
|
|
|
class Goblin;
|
2007-07-30 15:53:38 +00:00
|
|
|
class VideoPlayer;
|
2006-01-03 23:14:39 +00:00
|
|
|
class Init;
|
|
|
|
class Inter;
|
|
|
|
class Map;
|
|
|
|
class Mult;
|
|
|
|
class PalAnim;
|
|
|
|
class Parse;
|
|
|
|
class Scenery;
|
|
|
|
class Util;
|
2007-04-08 00:08:26 +00:00
|
|
|
class SaveLoad;
|
2007-01-23 19:40:28 +00:00
|
|
|
class Adlib;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-11-27 14:19:30 +00:00
|
|
|
#define VARP(offs) (_vm->_global->_inter_variables + (offs))
|
|
|
|
#define WRITE_VARO_UINT32(offs, val) _vm->_global->writeVar(offs, (uint32) (val))
|
|
|
|
#define WRITE_VARO_UINT16(offs, val) _vm->_global->writeVar(offs, (uint16) (val))
|
|
|
|
#define WRITE_VARO_UINT8(offs, val) _vm->_global->writeVar(offs, (uint8) (val))
|
|
|
|
#define WRITE_VARO_STR(offs, str) _vm->_global->writeVar(offs, (const char *) (str))
|
|
|
|
#define WRITE_VAR_UINT32(var, val) WRITE_VARO_UINT32((var) << 2, (val))
|
|
|
|
#define WRITE_VAR_UINT16(var, val) WRITE_VARO_UINT16((var) << 2, (val))
|
|
|
|
#define WRITE_VAR_UINT8(var, val) WRITE_VARO_UINT8((var) << 2, (val))
|
|
|
|
#define WRITE_VAR_STR(var, str) WRITE_VARO_STR((var) << 2, (str))
|
2007-10-19 23:00:43 +00:00
|
|
|
#define READ_VARO_UINT32(offs) READ_UINT32(VARP(offs))
|
|
|
|
#define READ_VARO_UINT16(offs) READ_UINT16(VARP(offs))
|
2006-11-27 14:19:30 +00:00
|
|
|
#define READ_VARO_UINT8(offs) (*((uint8 *) VARP(offs)))
|
|
|
|
#define READ_VAR_UINT32(var) READ_VARO_UINT32((var) << 2)
|
|
|
|
#define READ_VAR_UINT16(var) READ_VARO_UINT16((var) << 2)
|
|
|
|
#define READ_VAR_UINT8(var) READ_VARO_UINT8((var) << 2)
|
|
|
|
#define GET_VARO_STR(offs) ((char *) VARP(offs))
|
|
|
|
#define GET_VAR_STR(var) GET_VARO_STR((var) << 2)
|
|
|
|
|
|
|
|
#define WRITE_VAR_OFFSET(offs, val) WRITE_VARO_UINT32((offs), (val))
|
|
|
|
#define WRITE_VAR(var, val) WRITE_VAR_UINT32((var), (val))
|
|
|
|
#define VAR_OFFSET(offs) READ_VARO_UINT32(offs)
|
|
|
|
#define VAR(var) READ_VAR_UINT32(var)
|
|
|
|
#define VAR_ADDRESS(var) ((uint32 *) VARP((var) << 2))
|
2005-04-10 17:13:17 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
enum GameType {
|
|
|
|
kGameTypeNone = 0,
|
|
|
|
kGameTypeGob1,
|
|
|
|
kGameTypeGob2,
|
|
|
|
kGameTypeGob3,
|
|
|
|
kGameTypeWoodruff,
|
|
|
|
kGameTypeBargon,
|
2007-08-02 22:12:20 +00:00
|
|
|
kGameTypeWeen,
|
2008-03-02 23:57:29 +00:00
|
|
|
kGameTypeLostInTime,
|
|
|
|
kGameTypeInca2
|
2007-07-24 23:24:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Features {
|
|
|
|
kFeaturesNone = 0,
|
|
|
|
kFeaturesCD = 1 << 0,
|
|
|
|
kFeaturesEGA = 1 << 1,
|
|
|
|
kFeaturesAdlib = 1 << 2,
|
|
|
|
kFeatures640 = 1 << 3
|
2005-05-13 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2006-02-24 23:31:31 +00:00
|
|
|
enum {
|
2007-01-13 15:35:02 +00:00
|
|
|
kDebugFuncOp = 1 << 0,
|
|
|
|
kDebugDrawOp = 1 << 1,
|
|
|
|
kDebugGobOp = 1 << 2,
|
2007-01-23 19:40:28 +00:00
|
|
|
kDebugMusic = 1 << 3, // CD, Adlib and Infogrames music
|
2007-01-13 15:35:02 +00:00
|
|
|
kDebugParser = 1 << 4,
|
|
|
|
kDebugGameFlow = 1 << 5,
|
|
|
|
kDebugFileIO = 1 << 6,
|
|
|
|
kDebugGraphics = 1 << 7,
|
|
|
|
kDebugCollisions = 1 << 8
|
2006-02-24 23:31:31 +00:00
|
|
|
};
|
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
inline char *strncpy0(char *dest, const char *src, size_t n) {
|
|
|
|
strncpy(dest, src, n);
|
|
|
|
dest[n] = 0;
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// A "smart" reference counting templated class
|
|
|
|
template<typename T>
|
|
|
|
class ReferenceCounter {
|
|
|
|
public:
|
|
|
|
class Ptr {
|
|
|
|
public:
|
2007-03-29 17:55:39 +00:00
|
|
|
bool operator==(const Ptr &p) const { return _p == p._p; }
|
|
|
|
bool operator==(const ReferenceCounter *p) const { return _p == p; }
|
|
|
|
|
|
|
|
T *operator-> () { return _p; }
|
|
|
|
T &operator* () { return *_p; }
|
2007-03-20 14:51:57 +00:00
|
|
|
operator T*() { return _p; }
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
Ptr(T *p) : _p(p) { ++_p->_references; }
|
2007-03-20 14:51:57 +00:00
|
|
|
Ptr() : _p(0) { }
|
|
|
|
|
|
|
|
~Ptr() {
|
|
|
|
if (_p && (--_p->_references == 0))
|
|
|
|
delete _p;
|
|
|
|
}
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
Ptr(const Ptr &p) : _p(p._p) { ++_p->_references; }
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
Ptr &operator= (const Ptr &p) {
|
2007-03-20 14:51:57 +00:00
|
|
|
++p._p->_references;
|
|
|
|
if (_p && (--_p->_references == 0))
|
|
|
|
delete _p;
|
|
|
|
_p = p._p;
|
|
|
|
return *this;
|
|
|
|
}
|
2007-03-29 17:55:39 +00:00
|
|
|
Ptr *operator= (const Ptr *p) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (p)
|
|
|
|
++p->_p->_references;
|
|
|
|
if (_p && (--_p->_references == 0))
|
|
|
|
delete _p;
|
|
|
|
|
|
|
|
_p = p ? p->_p : 0;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2007-03-29 17:55:39 +00:00
|
|
|
T *_p;
|
2007-03-20 14:51:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ReferenceCounter() : _references(0) { }
|
|
|
|
virtual ~ReferenceCounter() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned _references;
|
|
|
|
friend class Ptr;
|
|
|
|
};
|
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
struct GOBGameDescription;
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
class GobEngine : public Engine {
|
|
|
|
protected:
|
2007-03-20 14:51:57 +00:00
|
|
|
GobEngine *_vm;
|
2006-11-27 14:19:30 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
int go();
|
2006-04-15 20:36:41 +00:00
|
|
|
int init();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
bool initGameParts();
|
|
|
|
void deinitGameParts();
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
public:
|
2007-03-20 14:51:57 +00:00
|
|
|
static const Common::Language _gobToScummVMLang[];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2005-04-29 15:01:03 +00:00
|
|
|
Common::RandomSource _rnd;
|
2005-05-13 21:24:30 +00:00
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
GameType _gameType;
|
2005-05-13 21:24:30 +00:00
|
|
|
int32 _features;
|
2006-04-18 12:39:02 +00:00
|
|
|
Common::Language _language;
|
2007-01-30 22:32:51 +00:00
|
|
|
Common::Platform _platform;
|
2007-07-24 23:24:40 +00:00
|
|
|
|
|
|
|
uint16 _width;
|
|
|
|
uint16 _height;
|
|
|
|
uint8 _mode;
|
|
|
|
|
2006-08-12 12:35:18 +00:00
|
|
|
char *_startTot;
|
|
|
|
char *_startTot0;
|
2006-01-14 09:57:20 +00:00
|
|
|
bool _copyProtection;
|
2007-01-25 14:18:12 +00:00
|
|
|
bool _noMusic;
|
2006-05-31 08:44:14 +00:00
|
|
|
bool _quitRequested;
|
2006-01-14 09:57:20 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
Global *_global;
|
|
|
|
Util *_util;
|
|
|
|
DataIO *_dataIO;
|
2006-01-03 23:14:39 +00:00
|
|
|
Game *_game;
|
|
|
|
Snd *_snd;
|
|
|
|
Video *_video;
|
|
|
|
Draw *_draw;
|
|
|
|
CDROM *_cdrom;
|
|
|
|
Goblin *_goblin;
|
|
|
|
Init *_init;
|
|
|
|
Map *_map;
|
|
|
|
Mult *_mult;
|
2007-03-20 14:51:57 +00:00
|
|
|
PalAnim *_palAnim;
|
2006-01-03 23:14:39 +00:00
|
|
|
Parse *_parse;
|
|
|
|
Scenery *_scenery;
|
2006-01-05 16:06:55 +00:00
|
|
|
Inter *_inter;
|
2007-04-08 00:08:26 +00:00
|
|
|
SaveLoad *_saveLoad;
|
2007-01-23 19:40:28 +00:00
|
|
|
Adlib *_adlib;
|
2007-07-30 15:53:38 +00:00
|
|
|
VideoPlayer *_vidPlayer;
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void shutdown();
|
2006-11-27 14:19:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
const char *getLangDesc(int16 language) {
|
|
|
|
if ((language < 0) || (language > 8))
|
|
|
|
language = 2;
|
|
|
|
return Common::getLanguageDescription(_gobToScummVMLang[language]);
|
|
|
|
}
|
|
|
|
void validateLanguage();
|
|
|
|
void validateVideoMode(int16 videoMode);
|
|
|
|
|
2007-07-24 23:24:40 +00:00
|
|
|
GameType getGameType() { return _gameType; }
|
|
|
|
bool isCD() { return (_features & kFeaturesCD) != 0; }
|
|
|
|
bool isEGA() { return (_features & kFeaturesEGA) != 0; }
|
|
|
|
bool is640() { return (_features & kFeatures640) != 0; }
|
|
|
|
bool hasAdlib() { return (_features & kFeaturesAdlib) != 0; }
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
GobEngine(OSystem *syst);
|
|
|
|
virtual ~GobEngine();
|
2007-11-03 21:06:58 +00:00
|
|
|
|
|
|
|
void initGame(const GOBGameDescription *gd);
|
2005-04-05 15:07:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Gob
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
#endif // GOB_GOB_H
|