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.
|
2004-04-09 12:36:06 +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
|
2005-01-09 16:06:29 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-04-09 12:36:06 +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.
|
2004-04-09 12:36:06 +00:00
|
|
|
*
|
2006-02-09 12:19:53 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-09 12:36:06 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-05-11 23:16:50 +00:00
|
|
|
#ifndef KYRA_KYRA_V1_H
|
|
|
|
#define KYRA_KYRA_V1_H
|
2004-04-09 12:36:06 +00:00
|
|
|
|
2006-09-23 00:42:35 +00:00
|
|
|
#include "engines/engine.h"
|
2008-04-20 15:47:11 +00:00
|
|
|
|
2007-05-05 12:18:02 +00:00
|
|
|
#include "common/array.h"
|
2007-06-22 23:03:12 +00:00
|
|
|
#include "common/events.h"
|
2005-10-12 19:15:32 +00:00
|
|
|
|
2008-04-20 15:47:11 +00:00
|
|
|
#include "kyra/script.h"
|
2005-08-19 22:12:09 +00:00
|
|
|
|
2008-03-17 18:10:52 +00:00
|
|
|
namespace Common {
|
|
|
|
class InSaveFile;
|
|
|
|
class OutSaveFile;
|
|
|
|
} // end of namespace Common
|
|
|
|
|
2008-03-27 18:03:00 +00:00
|
|
|
class KyraMetaEngine;
|
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
namespace Kyra {
|
2006-01-22 09:34:12 +00:00
|
|
|
|
2006-09-17 20:21:40 +00:00
|
|
|
struct GameFlags {
|
|
|
|
Common::Language lang;
|
|
|
|
Common::Platform platform;
|
2008-04-29 14:22:04 +00:00
|
|
|
|
|
|
|
bool isDemo : 1;
|
|
|
|
bool useAltShapeHeader : 1; // alternative shape header (uses 2 bytes more, those are unused though)
|
|
|
|
bool isTalkie : 1;
|
|
|
|
bool useHiResOverlay : 1;
|
|
|
|
bool useDigSound : 1;
|
|
|
|
|
2006-09-17 20:21:40 +00:00
|
|
|
byte gameID;
|
2004-11-11 13:37:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2006-05-01 00:25:41 +00:00
|
|
|
GI_KYRA1 = 0,
|
2006-05-12 23:57:53 +00:00
|
|
|
GI_KYRA2 = 1,
|
|
|
|
GI_KYRA3 = 2
|
2004-10-15 06:06:47 +00:00
|
|
|
};
|
|
|
|
|
2008-01-03 14:42:49 +00:00
|
|
|
struct AudioDataStruct {
|
|
|
|
const char * const *_fileList;
|
2008-01-27 19:47:41 +00:00
|
|
|
const int _fileListLen;
|
2008-01-03 14:42:49 +00:00
|
|
|
const void * const _cdaTracks;
|
2008-01-10 23:25:19 +00:00
|
|
|
const int _cdaNumTracks;
|
2008-01-03 14:42:49 +00:00
|
|
|
};
|
|
|
|
|
2006-02-14 01:19:30 +00:00
|
|
|
// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable
|
|
|
|
// in the future we maybe merge some flags and/or create new ones
|
|
|
|
enum kDebugLevels {
|
2007-07-29 16:33:11 +00:00
|
|
|
kDebugLevelScriptFuncs = 1 << 0, // prints debug output of o#_* functions
|
2008-04-29 15:12:09 +00:00
|
|
|
kDebugLevelScript = 1 << 1, // prints debug output of "EMCInterpreter" functions
|
2006-02-14 01:19:30 +00:00
|
|
|
kDebugLevelSprites = 1 << 2, // prints debug output of "Sprites" functions
|
|
|
|
kDebugLevelScreen = 1 << 3, // prints debug output of "Screen" functions
|
|
|
|
kDebugLevelSound = 1 << 4, // prints debug output of "Sound" functions
|
|
|
|
kDebugLevelAnimator = 1 << 5, // prints debug output of "ScreenAnimator" functions
|
2007-07-29 16:33:11 +00:00
|
|
|
kDebugLevelMain = 1 << 6, // prints debug output of common "KyraEngine(_v#)" functions && "TextDisplayer" functions
|
2006-02-14 01:19:30 +00:00
|
|
|
kDebugLevelGUI = 1 << 7, // prints debug output of "KyraEngine*" gui functions
|
|
|
|
kDebugLevelSequence = 1 << 8, // prints debug output of "SeqPlayer" functions
|
2007-07-29 16:33:11 +00:00
|
|
|
kDebugLevelMovie = 1 << 9, // prints debug output of movie specific funtions
|
|
|
|
kDebugLevelTimer = 1 << 10 // prints debug output of "TimerManager" functions
|
2006-02-14 01:19:30 +00:00
|
|
|
};
|
|
|
|
|
2008-03-21 16:18:27 +00:00
|
|
|
enum kMusicDataID {
|
|
|
|
kMusicIntro = 0,
|
|
|
|
kMusicIngame,
|
|
|
|
kMusicFinale
|
|
|
|
};
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
class Screen;
|
|
|
|
class Resource;
|
|
|
|
class Sound;
|
|
|
|
class Movie;
|
|
|
|
class TextDisplayer;
|
|
|
|
class StaticResource;
|
2007-07-29 16:33:11 +00:00
|
|
|
class TimerManager;
|
2008-05-06 20:50:27 +00:00
|
|
|
class Debugger;
|
2006-01-22 09:34:12 +00:00
|
|
|
|
2008-05-11 23:16:50 +00:00
|
|
|
class KyraEngine_v1 : public Engine {
|
2008-03-27 16:12:48 +00:00
|
|
|
friend class Debugger;
|
2008-03-27 18:03:00 +00:00
|
|
|
friend class ::KyraMetaEngine;
|
2008-04-04 06:24:49 +00:00
|
|
|
friend class GUI;
|
2004-10-15 06:06:47 +00:00
|
|
|
public:
|
2008-05-11 23:16:50 +00:00
|
|
|
KyraEngine_v1(OSystem *system, const GameFlags &flags);
|
|
|
|
virtual ~KyraEngine_v1();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-05-06 20:50:27 +00:00
|
|
|
::GUI::Debugger *getDebugger();
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
bool quit() const { return _quitFlag; }
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
uint8 game() const { return _flags.gameID; }
|
|
|
|
const GameFlags &gameFlags() const { return _flags; }
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// access to Kyra specific functionallity
|
2005-08-19 22:12:09 +00:00
|
|
|
Resource *resource() { return _res; }
|
2007-07-29 16:31:29 +00:00
|
|
|
virtual Screen *screen() = 0;
|
2008-03-30 18:27:46 +00:00
|
|
|
virtual TextDisplayer *text() { return _text; }
|
2006-01-13 23:06:04 +00:00
|
|
|
Sound *sound() { return _sound; }
|
2006-03-18 14:43:18 +00:00
|
|
|
StaticResource *staticres() { return _staticres; }
|
2007-07-29 16:33:11 +00:00
|
|
|
TimerManager *timer() { return _timer; }
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-01-03 19:03:09 +00:00
|
|
|
uint32 tickLength() const { return _tickLength; }
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
Common::RandomSource _rnd;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-12 23:17:21 +00:00
|
|
|
// input
|
2008-04-16 20:28:27 +00:00
|
|
|
void setMousePos(int x, int y);
|
2008-04-12 23:17:21 +00:00
|
|
|
Common::Point getMousePos() const;
|
|
|
|
|
2008-03-23 20:55:42 +00:00
|
|
|
// config specific
|
|
|
|
bool speechEnabled();
|
|
|
|
bool textEnabled();
|
|
|
|
|
2008-04-04 18:02:50 +00:00
|
|
|
enum kVolumeEntry {
|
|
|
|
kVolumeMusic = 0,
|
|
|
|
kVolumeSfx = 1,
|
|
|
|
kVolumeSpeech = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
// volume reaches from 2 to 97
|
|
|
|
void setVolume(kVolumeEntry vol, uint8 value);
|
|
|
|
uint8 getVolume(kVolumeEntry vol);
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// quit handling
|
|
|
|
virtual void quitGame();
|
2007-03-18 18:27:52 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// game flag handling
|
2007-01-31 23:48:12 +00:00
|
|
|
int setGameFlag(int flag);
|
2007-07-29 16:31:29 +00:00
|
|
|
int queryGameFlag(int flag) const;
|
2007-01-31 23:48:12 +00:00
|
|
|
int resetGameFlag(int flag);
|
2007-10-10 09:06:15 +00:00
|
|
|
|
|
|
|
// sound
|
2008-04-10 15:41:06 +00:00
|
|
|
virtual void snd_playTheme(int file, int track);
|
2008-04-29 14:08:08 +00:00
|
|
|
virtual void snd_playSoundEffect(int id, int volume=0xFF);
|
2007-10-10 09:06:15 +00:00
|
|
|
virtual void snd_playWanderScoreViaMap(int command, int restart);
|
2007-10-13 06:57:47 +00:00
|
|
|
virtual void snd_playVoiceFile(int id) = 0;
|
|
|
|
virtual bool snd_voiceIsPlaying();
|
|
|
|
virtual void snd_stopVoice();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// delay functionallity
|
|
|
|
virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false);
|
|
|
|
virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false);
|
|
|
|
virtual void delayWithTicks(int ticks);
|
2006-03-08 13:15:13 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
protected:
|
|
|
|
virtual int go() = 0;
|
|
|
|
virtual int init();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// quit Handling
|
2005-08-19 22:12:09 +00:00
|
|
|
bool _quitFlag;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// intern
|
2005-08-19 22:12:09 +00:00
|
|
|
Resource *_res;
|
2006-01-13 23:06:04 +00:00
|
|
|
Sound *_sound;
|
2006-01-02 22:58:59 +00:00
|
|
|
TextDisplayer *_text;
|
2006-03-18 14:43:18 +00:00
|
|
|
StaticResource *_staticres;
|
2007-07-29 16:33:11 +00:00
|
|
|
TimerManager *_timer;
|
2008-04-29 15:12:09 +00:00
|
|
|
EMCInterpreter *_emc;
|
2008-05-06 20:50:27 +00:00
|
|
|
Debugger *_debugger;
|
2008-01-27 15:30:53 +00:00
|
|
|
|
|
|
|
// config specific
|
|
|
|
virtual void registerDefaultSettings();
|
|
|
|
virtual void readSettings();
|
|
|
|
virtual void writeSettings();
|
|
|
|
|
|
|
|
uint8 _configWalkspeed;
|
|
|
|
|
|
|
|
int _configMusic;
|
|
|
|
bool _configSounds;
|
|
|
|
uint8 _configVoice;
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// game speed
|
2008-03-16 14:32:49 +00:00
|
|
|
virtual bool skipFlag() const = 0;
|
|
|
|
virtual void resetSkipFlag(bool removeEvent = true) = 0;
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
uint16 _tickLength;
|
2007-07-29 16:33:11 +00:00
|
|
|
uint16 _gameSpeed;
|
2008-01-27 15:30:53 +00:00
|
|
|
|
2008-05-12 12:57:42 +00:00
|
|
|
// run
|
|
|
|
int8 _deathHandler;
|
|
|
|
|
2008-01-27 15:30:53 +00:00
|
|
|
// timer
|
2008-01-27 15:56:56 +00:00
|
|
|
virtual void setupTimers() = 0;
|
|
|
|
|
2008-01-27 15:30:53 +00:00
|
|
|
virtual void setWalkspeed(uint8 speed) = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// detection
|
|
|
|
GameFlags _flags;
|
|
|
|
int _lang;
|
2007-01-29 18:15:14 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// opcode
|
|
|
|
virtual void setupOpcodeTable() = 0;
|
|
|
|
Common::Array<const Opcode*> _opcodes;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-05-12 12:42:10 +00:00
|
|
|
int o1_queryGameFlag(EMCState *script);
|
|
|
|
int o1_setGameFlag(EMCState *script);
|
|
|
|
int o1_resetGameFlag(EMCState *script);
|
|
|
|
int o1_getRand(EMCState *script);
|
|
|
|
int o1_hideMouse(EMCState *script);
|
|
|
|
int o1_showMouse(EMCState *script);
|
|
|
|
int o1_setMousePos(EMCState *script);
|
|
|
|
int o1_setHandItem(EMCState *script);
|
|
|
|
int o1_removeHandItem(EMCState *script);
|
|
|
|
int o1_getMouseState(EMCState *script);
|
2008-05-12 12:57:42 +00:00
|
|
|
int o1_setDeathHandler(EMCState *script);
|
|
|
|
int o1_playWanderScoreViaMap(EMCState *script);
|
2008-05-12 12:42:10 +00:00
|
|
|
|
|
|
|
// items
|
|
|
|
int _mouseState;
|
|
|
|
|
|
|
|
virtual void setHandItem(uint16 item) = 0;
|
|
|
|
virtual void removeHandItem() = 0;
|
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
// game flags
|
|
|
|
uint8 _flagsTable[100]; // TODO: check this value
|
2007-10-10 09:06:15 +00:00
|
|
|
|
|
|
|
// sound
|
2008-03-21 16:18:27 +00:00
|
|
|
Common::String _speechFile;
|
|
|
|
|
2007-10-10 09:06:15 +00:00
|
|
|
int _curMusicTheme;
|
|
|
|
int _curSfxFile;
|
|
|
|
int16 _lastMusicCommand;
|
|
|
|
|
|
|
|
const int8 *_trackMap;
|
|
|
|
int _trackMapSize;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
// pathfinder
|
|
|
|
virtual int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize);
|
|
|
|
int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end);
|
|
|
|
int getFacingFromPointToPoint(int x, int y, int toX, int toY);
|
|
|
|
int getOppositeFacingDirection(int dir);
|
|
|
|
void changePosTowardsFacing(int &x, int &y, int facing);
|
|
|
|
int getMoveTableSize(int *moveTable);
|
|
|
|
virtual bool lineIsPassable(int x, int y) = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
static const int8 _addXPosTable[];
|
|
|
|
static const int8 _addYPosTable[];
|
2008-03-17 18:10:52 +00:00
|
|
|
|
|
|
|
// save/load
|
2008-03-28 00:53:54 +00:00
|
|
|
int _gameToLoad;
|
|
|
|
|
2008-03-17 18:10:52 +00:00
|
|
|
const char *getSavegameFilename(int num);
|
2008-03-28 00:53:54 +00:00
|
|
|
bool saveFileLoadable(int slot);
|
2008-03-27 18:03:00 +00:00
|
|
|
|
|
|
|
struct SaveHeader {
|
|
|
|
Common::String description;
|
|
|
|
uint32 version;
|
|
|
|
byte gameID;
|
|
|
|
uint32 flags;
|
|
|
|
|
|
|
|
bool originalSave; // savegame from original interpreter
|
|
|
|
bool oldHeader; // old scummvm save header
|
|
|
|
};
|
|
|
|
|
|
|
|
enum kReadSaveHeaderError {
|
|
|
|
kRSHENoError = 0,
|
|
|
|
kRSHEInvalidType = 1,
|
|
|
|
kRSHEInvalidVersion = 2,
|
|
|
|
kRSHEIoError = 3
|
|
|
|
};
|
2008-03-28 00:53:54 +00:00
|
|
|
|
2008-03-27 18:03:00 +00:00
|
|
|
static kReadSaveHeaderError readSaveHeader(Common::InSaveFile *file, SaveHeader &header);
|
|
|
|
|
|
|
|
Common::InSaveFile *openSaveForReading(const char *filename, SaveHeader &header);
|
2008-03-17 18:10:52 +00:00
|
|
|
Common::OutSaveFile *openSaveForWriting(const char *filename, const char *saveName) const;
|
2004-04-09 12:36:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Kyra
|
|
|
|
|
|
|
|
#endif
|
2007-04-15 16:41:20 +00:00
|
|
|
|