2008-04-20 14:47:37 +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
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef M4_GLOBALS_H
|
|
|
|
#define M4_GLOBALS_H
|
|
|
|
|
2010-05-04 12:00:16 +00:00
|
|
|
#include "common/scummsys.h"
|
2008-04-20 14:47:37 +00:00
|
|
|
#include "common/array.h"
|
2010-07-01 12:01:17 +00:00
|
|
|
#include "common/hashmap.h"
|
2008-04-20 14:47:37 +00:00
|
|
|
#include "common/rect.h"
|
2010-05-04 12:00:16 +00:00
|
|
|
#include "common/list.h"
|
2009-11-04 08:38:32 +00:00
|
|
|
#include "common/ptr.h"
|
|
|
|
|
2010-11-28 23:39:02 +00:00
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
|
|
|
}
|
|
|
|
|
2008-04-20 14:47:37 +00:00
|
|
|
namespace M4 {
|
|
|
|
|
2010-01-30 09:21:07 +00:00
|
|
|
class MadsM4Engine;
|
2010-01-30 23:03:07 +00:00
|
|
|
class M4Engine;
|
|
|
|
class MadsEngine;
|
2008-04-20 14:47:37 +00:00
|
|
|
class ScriptInterpreter;
|
|
|
|
class ScriptFunction;
|
|
|
|
|
|
|
|
// Globals
|
|
|
|
enum WoodScriptGlobals {
|
|
|
|
kGlobTime = 0,
|
|
|
|
kGlobTimeDelta = 1,
|
|
|
|
kGlobMinY = 2,
|
|
|
|
kGlobMaxY = 3,
|
|
|
|
kGlobMinScale = 4,
|
|
|
|
kGlobMaxScale = 5,
|
|
|
|
kGlobScaler = 6,
|
|
|
|
kGlobTemp1 = 7,
|
|
|
|
kGlobTemp2 = 8,
|
|
|
|
kGlobTemp3 = 9,
|
|
|
|
kGlobTemp4 = 10,
|
|
|
|
kGlobTemp5 = 11,
|
|
|
|
kGlobTemp6 = 12,
|
|
|
|
kGlobTemp7 = 13,
|
|
|
|
kGlobTemp8 = 14,
|
|
|
|
kGlobTemp9 = 15,
|
|
|
|
kGlobTemp10 = 16,
|
|
|
|
kGlobTemp11 = 17,
|
|
|
|
kGlobTemp12 = 18,
|
|
|
|
kGlobTemp13 = 19,
|
|
|
|
kGlobTemp14 = 20,
|
|
|
|
kGlobTemp15 = 21,
|
|
|
|
kGlobTemp16 = 22,
|
|
|
|
kGlobTemp17 = 23,
|
|
|
|
kGlobTemp18 = 24,
|
|
|
|
kGlobTemp19 = 25,
|
|
|
|
kGlobTemp20 = 26,
|
|
|
|
kGlobTemp21 = 27,
|
|
|
|
kGlobTemp22 = 28,
|
|
|
|
kGlobTemp23 = 29,
|
|
|
|
kGlobTemp24 = 30,
|
|
|
|
kGlobTemp25 = 31,
|
|
|
|
kGlobTemp26 = 32,
|
|
|
|
kGlobTemp27 = 33,
|
|
|
|
kGlobTemp28 = 34,
|
|
|
|
kGlobTemp29 = 35,
|
|
|
|
kGlobTemp30 = 36,
|
|
|
|
kGlobTemp31 = 37,
|
|
|
|
kGlobTemp32 = 38
|
|
|
|
};
|
|
|
|
|
2009-03-07 19:24:31 +00:00
|
|
|
const uint32 SERIES_FORWARD = 0;
|
|
|
|
const uint32 SERIES_PINGPONG = 1;
|
|
|
|
const uint32 SERIES_BACKWARD = 2;
|
|
|
|
const uint32 SERIES_RANDOM = 4;
|
|
|
|
const uint32 SERIES_NO_TOSS = 8;
|
|
|
|
const uint32 SERIES_STICK = 16;
|
2008-04-20 14:47:37 +00:00
|
|
|
const uint32 SERIES_LOOP_TRIGGER = 32;
|
|
|
|
const uint32 SERIES_LOAD_PALETTE = 64;
|
|
|
|
const uint32 SERIES_HORZ_FLIP =128;
|
|
|
|
|
|
|
|
enum KernelTriggerType {
|
|
|
|
KT_PARSE = 1,
|
|
|
|
KT_DAEMON,
|
|
|
|
KT_PREPARSE
|
|
|
|
};
|
|
|
|
|
|
|
|
class Kernel {
|
|
|
|
private:
|
2010-01-30 09:21:07 +00:00
|
|
|
MadsM4Engine *_vm;
|
2008-04-20 14:47:37 +00:00
|
|
|
ScriptFunction *_globalDaemonFn, *_globalParserFn;
|
|
|
|
ScriptFunction *_sectionInitFn, *_sectionDaemonFn, *_sectionParserFn;
|
|
|
|
ScriptFunction *_roomInitFn, *_roomDaemonFn, *_roomPreParserFn, *_roomParserFn;
|
|
|
|
void pauseEngines();
|
|
|
|
void unpauseEngines();
|
|
|
|
public:
|
2010-01-30 09:21:07 +00:00
|
|
|
Kernel(MadsM4Engine *vm);
|
2008-04-20 14:47:37 +00:00
|
|
|
|
|
|
|
// TODO: Move to some palette/fading class
|
|
|
|
int fadeUpDuration, firstFadeColorIndex;
|
|
|
|
int minPalEntry, maxPalEntry;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-20 14:47:37 +00:00
|
|
|
bool paused;
|
|
|
|
//machine* myWalker;
|
|
|
|
bool repeatedlyCallDeamon;
|
|
|
|
bool daemonTriggerAvailable;
|
|
|
|
bool betweenRooms;
|
|
|
|
int currentSection, newSection, previousSection;
|
|
|
|
int currentRoom, newRoom, previousRoom;
|
|
|
|
|
|
|
|
int32 trigger;
|
|
|
|
KernelTriggerType triggerMode;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-20 14:47:37 +00:00
|
|
|
int32 createTrigger(int32 triggerNum);
|
|
|
|
bool sendTrigger(int32 triggerNum);
|
|
|
|
bool handleTrigger(int32 triggerNum);
|
|
|
|
|
|
|
|
void loadGlobalScriptFunctions();
|
|
|
|
void loadSectionScriptFunctions();
|
|
|
|
void loadRoomScriptFunctions();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-20 14:47:37 +00:00
|
|
|
void globalDaemon();
|
|
|
|
void globalParser();
|
|
|
|
|
|
|
|
void sectionInit();
|
|
|
|
void sectionDaemon();
|
|
|
|
void sectionParser();
|
|
|
|
|
|
|
|
void roomInit();
|
|
|
|
void roomDaemon();
|
|
|
|
void roomPreParser();
|
|
|
|
void roomParser();
|
|
|
|
|
|
|
|
void pauseGame(bool value);
|
|
|
|
};
|
|
|
|
|
2010-07-06 11:32:10 +00:00
|
|
|
#define TOTAL_NUM_VARIABLES 210
|
2008-04-20 14:47:37 +00:00
|
|
|
|
2009-11-04 08:38:32 +00:00
|
|
|
#define PLAYER_INVENTORY 2
|
|
|
|
|
2009-11-12 10:07:44 +00:00
|
|
|
enum MADSArticles {
|
|
|
|
kArticleNone = 0,
|
|
|
|
kArticleWith = 1,
|
|
|
|
kArticleTo = 2,
|
|
|
|
kArticleAt = 3,
|
|
|
|
kArticleFrom = 4,
|
|
|
|
kArticleOn = 5,
|
|
|
|
kArticleIn = 6,
|
|
|
|
kArticleUnder = 7,
|
|
|
|
kArticleBehind = 8
|
|
|
|
};
|
|
|
|
|
2009-11-04 08:38:32 +00:00
|
|
|
struct VocabEntry {
|
2010-03-19 09:19:23 +00:00
|
|
|
uint8 flags1;
|
|
|
|
uint8 flags2;
|
2009-11-04 08:38:32 +00:00
|
|
|
uint16 vocabId;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MadsObject {
|
|
|
|
public:
|
2010-03-22 20:28:08 +00:00
|
|
|
MadsObject() {}
|
2009-11-04 08:38:32 +00:00
|
|
|
MadsObject(Common::SeekableReadStream *stream);
|
2010-02-27 05:30:53 +00:00
|
|
|
void load(Common::SeekableReadStream *stream);
|
2011-05-29 11:02:06 +00:00
|
|
|
bool isInInventory() const { return _roomNumber == PLAYER_INVENTORY; }
|
|
|
|
void setRoom(int roomNumber);
|
|
|
|
|
|
|
|
uint16 _descId;
|
|
|
|
uint16 _roomNumber;
|
|
|
|
MADSArticles _article;
|
|
|
|
uint8 _vocabCount;
|
|
|
|
VocabEntry _vocabList[3];
|
2009-11-04 08:38:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::Array<Common::SharedPtr<MadsObject> > MadsObjectArray;
|
|
|
|
|
2010-01-30 23:03:07 +00:00
|
|
|
class Globals {
|
|
|
|
private:
|
|
|
|
MadsM4Engine *_vm;
|
|
|
|
public:
|
|
|
|
Globals(MadsM4Engine *vm);
|
2010-03-22 20:28:08 +00:00
|
|
|
virtual ~Globals() {}
|
2010-01-30 23:03:07 +00:00
|
|
|
|
|
|
|
bool isInterfaceVisible();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2010-01-31 00:47:29 +00:00
|
|
|
class M4Globals : public Globals {
|
2010-01-30 23:03:07 +00:00
|
|
|
private:
|
|
|
|
M4Engine *_vm;
|
|
|
|
public:
|
|
|
|
M4Globals(M4Engine *vm);
|
2010-03-22 20:28:08 +00:00
|
|
|
virtual ~M4Globals() {}
|
2010-01-30 23:03:07 +00:00
|
|
|
|
|
|
|
bool invSuppressClickSound;
|
|
|
|
};
|
|
|
|
|
2010-02-13 11:49:18 +00:00
|
|
|
enum RexPlayerSex { SEX_MALE = 0, SEX_FEMALE = 2, SEX_UNKNOWN = 1};
|
|
|
|
|
2010-03-21 10:51:11 +00:00
|
|
|
enum MadsDialogType { DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3, DIALOG_OPTIONS = 4,
|
|
|
|
DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6};
|
|
|
|
|
2010-03-27 10:44:38 +00:00
|
|
|
struct MadsConfigData {
|
|
|
|
bool musicFlag;
|
|
|
|
bool soundFlag;
|
|
|
|
bool easyMouse;
|
|
|
|
bool invObjectsStill;
|
|
|
|
bool textWindowStill;
|
|
|
|
int storyMode;
|
|
|
|
int screenFades;
|
|
|
|
};
|
|
|
|
|
2010-07-06 11:32:10 +00:00
|
|
|
#define GET_GLOBAL(x) (_madsVm->globals()->_globals[x])
|
|
|
|
#define GET_GLOBAL32(x) (((uint32)_madsVm->globals()->_globals[x + 1] << 16) | _madsVm->globals()->_globals[x])
|
|
|
|
#define SET_GLOBAL(x,y) _madsVm->globals()->_globals[x] = y
|
|
|
|
#define SET_GLOBAL32(x,y) { _madsVm->globals()->_globals[x] = (y) & 0xffff; _madsVm->globals()->_globals[(x) + 1] = (y) >> 16; }
|
|
|
|
|
2010-11-02 00:15:18 +00:00
|
|
|
typedef int (*IntFunctionPtr)();
|
|
|
|
|
2010-08-25 06:42:54 +00:00
|
|
|
union DataMapEntry {
|
|
|
|
bool *boolValue;
|
|
|
|
uint16 *uint16Value;
|
|
|
|
int *intValue;
|
2010-11-02 00:15:18 +00:00
|
|
|
IntFunctionPtr fnPtr;
|
2010-08-25 06:42:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<uint16, uint16> DataMapHash;
|
|
|
|
|
2010-01-31 00:47:29 +00:00
|
|
|
class MadsGlobals : public Globals {
|
2008-04-20 14:47:37 +00:00
|
|
|
private:
|
|
|
|
struct MessageItem {
|
|
|
|
uint32 id;
|
|
|
|
uint32 offset;
|
|
|
|
uint16 uncompSize;
|
|
|
|
uint16 compSize;
|
|
|
|
};
|
|
|
|
|
2010-01-30 23:03:07 +00:00
|
|
|
MadsEngine *_vm;
|
2008-04-20 14:47:37 +00:00
|
|
|
Common::Array<char* > _madsVocab;
|
|
|
|
Common::Array<char* > _madsQuotes;
|
2010-06-14 05:27:54 +00:00
|
|
|
Common::Array<MessageItem> _madsMessages;
|
2009-11-04 08:38:32 +00:00
|
|
|
MadsObjectArray _madsObjects;
|
2010-02-13 11:49:18 +00:00
|
|
|
Common::List<int> _visitedScenes;
|
2008-04-20 14:47:37 +00:00
|
|
|
public:
|
2010-01-30 23:03:07 +00:00
|
|
|
MadsGlobals(MadsEngine *vm);
|
2010-01-30 09:21:07 +00:00
|
|
|
~MadsGlobals();
|
2008-04-20 14:47:37 +00:00
|
|
|
|
2009-11-15 08:22:14 +00:00
|
|
|
// MADS variables
|
2010-07-06 11:32:10 +00:00
|
|
|
uint16 _globals[TOTAL_NUM_VARIABLES];
|
2010-03-27 10:44:38 +00:00
|
|
|
MadsConfigData _config;
|
2010-02-13 11:49:18 +00:00
|
|
|
bool playerSpriteChanged;
|
2010-03-21 10:51:11 +00:00
|
|
|
MadsDialogType dialogType;
|
|
|
|
int sceneNumber;
|
|
|
|
int previousScene;
|
2010-07-03 11:50:42 +00:00
|
|
|
int16 _nextSceneId;
|
2010-06-14 06:33:24 +00:00
|
|
|
uint16 actionNouns[3];
|
2011-05-14 23:23:02 +00:00
|
|
|
DataMapHash _dataMap;
|
2010-07-06 11:32:10 +00:00
|
|
|
int _difficultyLevel;
|
2008-04-20 14:47:37 +00:00
|
|
|
|
|
|
|
void loadMadsVocab();
|
|
|
|
uint32 getVocabSize() { return _madsVocab.size(); }
|
2010-01-25 01:39:44 +00:00
|
|
|
const char *getVocab(uint32 index) {
|
2009-11-11 09:55:05 +00:00
|
|
|
// Vocab list is 1-based, so always subtract one from index provided
|
|
|
|
assert((index > 0) && (index <= _madsVocab.size()));
|
2010-01-25 01:39:44 +00:00
|
|
|
return _madsVocab[index - 1];
|
2009-11-11 09:55:05 +00:00
|
|
|
}
|
2008-04-20 14:47:37 +00:00
|
|
|
|
2010-03-21 10:51:11 +00:00
|
|
|
void loadQuotes();
|
2008-04-20 14:47:37 +00:00
|
|
|
uint32 getQuotesSize() { return _madsQuotes.size(); }
|
2010-03-24 11:47:08 +00:00
|
|
|
const char *getQuote(uint32 index) { return _madsQuotes[index - 1]; }
|
2010-03-21 10:51:11 +00:00
|
|
|
// DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
|
2010-04-01 15:03:08 +00:00
|
|
|
void clearQuotes() {}
|
|
|
|
void loadQuoteRange(int startNum, int endNum) {}
|
2010-05-23 07:20:40 +00:00
|
|
|
void loadQuoteSet(...) {}
|
2010-04-01 15:03:08 +00:00
|
|
|
void loadQuote(int quoteNum) {}
|
2008-04-20 14:47:37 +00:00
|
|
|
|
|
|
|
void loadMadsMessagesInfo();
|
|
|
|
uint32 getMessagesSize() { return _madsMessages.size(); }
|
2009-12-11 09:41:27 +00:00
|
|
|
int messageIndexOf(uint32 messageId);
|
2009-11-04 08:38:32 +00:00
|
|
|
const char *loadMessage(uint index);
|
|
|
|
|
|
|
|
void loadMadsObjects();
|
|
|
|
uint32 getObjectsSize() { return _madsObjects.size(); }
|
2009-12-05 05:44:46 +00:00
|
|
|
MadsObject *getObject(uint32 index) { return _madsObjects[index].get(); }
|
2011-08-22 10:10:55 +00:00
|
|
|
int getObjectIndex(uint16 descId);
|
|
|
|
int getObjectFolder(uint32 folderId) { warning("TODO: getObjectFolder"); return -1; }
|
2010-02-13 11:49:18 +00:00
|
|
|
|
|
|
|
void addVisitedScene(int sceneNumber);
|
|
|
|
bool isSceneVisited(int sceneNumber);
|
|
|
|
void removeVisitedScene(int sceneNumber);
|
2008-04-20 14:47:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PLAYER_FIELD_LENGTH 40
|
|
|
|
|
|
|
|
class Player {
|
|
|
|
public:
|
2010-01-30 09:21:07 +00:00
|
|
|
Player(MadsM4Engine *vm);
|
2008-04-20 14:47:37 +00:00
|
|
|
void setCommandsAllowed(bool value);
|
|
|
|
|
|
|
|
// Variables
|
|
|
|
Common::Point position; // Player's current position
|
|
|
|
int facing; // Facing direction
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-20 14:47:37 +00:00
|
|
|
char verb[PLAYER_FIELD_LENGTH]; // Action strings
|
2009-01-01 15:06:43 +00:00
|
|
|
char noun[PLAYER_FIELD_LENGTH];
|
|
|
|
char prep[PLAYER_FIELD_LENGTH];
|
2008-04-20 14:47:37 +00:00
|
|
|
char object[PLAYER_FIELD_LENGTH];
|
|
|
|
Common::String assetName, shadowName;
|
|
|
|
int walkerType, shadowType;
|
|
|
|
bool needToWalk, readyToWalk, waitingForWalk;
|
|
|
|
bool commandsAllowed;
|
|
|
|
bool commandReady;
|
|
|
|
bool visible;
|
|
|
|
bool beenInRoomBefore;
|
|
|
|
bool walkerInCurrentRoom;
|
|
|
|
int32 walkerTriggerNum;
|
|
|
|
int walkFacing;
|
|
|
|
bool setCommandsAllowedFlag;
|
|
|
|
|
|
|
|
bool said(const char *word1, const char *word2 = NULL, const char *word3 = NULL);
|
|
|
|
bool saidAny(const char *word1, const char *word2, const char *word3,
|
|
|
|
const char *word4, const char *word5, const char *word6, const char *word7,
|
|
|
|
const char *word8, const char *word9, const char *word10);
|
|
|
|
|
|
|
|
private:
|
2010-01-30 09:21:07 +00:00
|
|
|
MadsM4Engine *_vm;
|
2008-04-20 14:47:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace M4
|
|
|
|
|
|
|
|
#endif
|