2016-08-26 22:36:31 +02: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Based on the Reverse Engineering work of Christophe Fontanel,
|
|
|
|
* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
|
|
|
|
*/
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
#ifndef DM_H
|
|
|
|
#define DM_H
|
|
|
|
|
|
|
|
#include "common/random.h"
|
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "gui/debugger.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-05-21 12:55:37 +02:00
|
|
|
class Console;
|
|
|
|
class DisplayMan;
|
|
|
|
class DungeonMan;
|
2016-06-15 22:42:08 +02:00
|
|
|
class EventManager;
|
2016-06-17 14:29:05 +02:00
|
|
|
class MenuMan;
|
2016-06-18 11:36:31 +02:00
|
|
|
class ChampionMan;
|
|
|
|
class LoadsaveMan;
|
2016-06-19 00:54:28 +02:00
|
|
|
class ObjectMan;
|
2016-06-19 16:17:28 +02:00
|
|
|
class InventoryMan;
|
2016-06-22 20:32:30 +02:00
|
|
|
class TextMan;
|
2016-08-26 22:37:14 +02:00
|
|
|
class MovesensMan;
|
2016-08-26 22:41:19 +02:00
|
|
|
class GroupMan;
|
2016-06-30 19:59:35 +02:00
|
|
|
class Timeline;
|
2016-05-21 12:55:37 +02:00
|
|
|
|
|
|
|
|
2016-05-06 18:13:23 +02:00
|
|
|
enum direction {
|
|
|
|
kDirNorth = 0,
|
|
|
|
kDirEast = 1,
|
|
|
|
kDirSouth = 2,
|
|
|
|
kDirWest = 3
|
|
|
|
};
|
|
|
|
|
2016-05-21 21:09:09 +02:00
|
|
|
void turnDirRight(direction &dir);
|
|
|
|
void turnDirLeft(direction &dir);
|
2016-06-30 15:48:23 +02:00
|
|
|
direction returnOppositeDir(direction dir); // @ M18_OPPOSITE
|
|
|
|
uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS
|
|
|
|
uint16 returnNextVal(uint16 val); // @ M17_NEXT
|
|
|
|
bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST
|
2016-05-21 21:09:09 +02:00
|
|
|
|
2016-06-21 17:45:10 +02:00
|
|
|
|
2016-06-29 22:08:10 +02:00
|
|
|
uint16 getFlag(uint16 val, uint16 mask);
|
|
|
|
void setFlag(uint16 &val, uint16 mask);
|
|
|
|
void clearFlag(uint16 &val, uint16 mask);
|
|
|
|
|
|
|
|
|
2016-05-21 12:55:37 +02:00
|
|
|
enum ThingType {
|
2016-08-26 22:43:17 +02:00
|
|
|
kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value
|
|
|
|
k0_DoorThingType = 0,
|
|
|
|
k1_TeleporterThingType = 1,
|
|
|
|
k2_TextstringType = 2,
|
|
|
|
k3_SensorThingType = 3,
|
|
|
|
k4_GroupThingType = 4,
|
|
|
|
k5_WeaponThingType = 5,
|
|
|
|
k6_ArmourThingType = 6,
|
|
|
|
k7_ScrollThingType = 7,
|
|
|
|
k8_PotionThingType = 8,
|
|
|
|
k9_ContainerThingType = 9,
|
|
|
|
k10_JunkThingType = 10,
|
|
|
|
k14_ProjectileThingType = 14,
|
|
|
|
k15_ExplosionThingType = 15,
|
|
|
|
k16_ThingTypeTotal = 16 // +1 than the last (explosionThingType)
|
2016-05-21 12:55:37 +02:00
|
|
|
}; // @ C[00..15]_THING_TYPE_...
|
|
|
|
|
2016-06-23 17:11:53 +02:00
|
|
|
enum Cell {
|
2016-08-26 22:43:17 +02:00
|
|
|
kM1_CellAny = -1, // @ CM1_CELL_ANY
|
|
|
|
k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST
|
|
|
|
k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST
|
|
|
|
k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST
|
|
|
|
k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST
|
2016-06-23 17:11:53 +02:00
|
|
|
};
|
|
|
|
|
2016-07-02 23:10:05 +02:00
|
|
|
#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE
|
|
|
|
#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE
|
|
|
|
|
2016-05-21 12:55:37 +02:00
|
|
|
class Thing {
|
2016-06-18 17:48:48 +02:00
|
|
|
uint16 _data;
|
2016-05-21 12:55:37 +02:00
|
|
|
public:
|
2016-06-30 13:29:42 +02:00
|
|
|
static const Thing _none; // @ C0xFFFF_THING_NONE
|
|
|
|
static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST
|
|
|
|
static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION
|
|
|
|
static const Thing _explFireBall; // @ C0xFF80_THING_EXPLOSION_FIREBALL
|
|
|
|
static const Thing _explSlime; // @ C0xFF81_THING_EXPLOSION_SLIME
|
|
|
|
static const Thing _explLightningBolt; // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT
|
|
|
|
static const Thing _explHarmNonMaterial; // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL
|
|
|
|
static const Thing _explOpenDoor; // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR
|
|
|
|
static const Thing _explPoisonBolt; // @ C0xFF86_THING_EXPLOSION_POISON_BOLT
|
|
|
|
static const Thing _explPoisonCloud; // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD
|
|
|
|
static const Thing _explSmoke; // @ C0xFFA8_THING_EXPLOSION_SMOKE
|
|
|
|
static const Thing _explFluxcage; // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE
|
|
|
|
static const Thing _explRebirthStep1; // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1
|
|
|
|
static const Thing _explRebirthStep2; // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2
|
|
|
|
static const Thing _party; // @ C0xFFFF_THING_PARTY
|
2016-05-21 12:55:37 +02:00
|
|
|
|
2016-06-18 17:48:48 +02:00
|
|
|
Thing() : _data(0) {}
|
2016-06-22 07:47:41 +02:00
|
|
|
explicit Thing(uint16 d) { set(d); }
|
2016-05-21 12:55:37 +02:00
|
|
|
|
|
|
|
void set(uint16 d) {
|
2016-06-18 17:48:48 +02:00
|
|
|
_data = d;
|
2016-05-21 12:55:37 +02:00
|
|
|
}
|
|
|
|
|
2016-06-18 17:48:48 +02:00
|
|
|
byte getCell() const { return _data >> 14; }
|
|
|
|
ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); }
|
2016-06-28 00:30:32 +02:00
|
|
|
uint16 getIndex() const { return _data & 0x3FF; }
|
2016-06-18 17:48:48 +02:00
|
|
|
uint16 toUint16() const { return _data; } // I don't like 'em cast operators
|
|
|
|
bool operator==(const Thing &rhs) const { return _data == rhs._data; }
|
|
|
|
bool operator!=(const Thing &rhs) const { return _data != rhs._data; }
|
2016-05-21 12:55:37 +02:00
|
|
|
}; // @ THING
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
// engine debug channels
|
2016-07-02 17:46:05 +02:00
|
|
|
kDMDebugExample = 1 << 0,
|
2016-07-02 19:24:13 +02:00
|
|
|
kDMDebugUselessCode = 1 << 1,
|
|
|
|
kDMDebugOftenCalledWarning = 2 << 2
|
2016-04-26 14:44:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DMEngine : public Engine {
|
2016-08-26 22:47:44 +02:00
|
|
|
void f462_startGame(); // @ F0462_START_StartGame_CPSF
|
|
|
|
void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE
|
|
|
|
void f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
|
2016-07-02 19:24:13 +02:00
|
|
|
void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF
|
2016-08-26 22:47:44 +02:00
|
|
|
void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF
|
2016-06-29 22:51:40 +02:00
|
|
|
void initArrays();
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
public:
|
2016-06-22 07:47:41 +02:00
|
|
|
explicit DMEngine(OSystem *syst);
|
2016-04-26 14:44:01 +02:00
|
|
|
~DMEngine();
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX
|
|
|
|
int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL
|
2016-06-18 17:18:01 +02:00
|
|
|
virtual Common::Error run(); // @ main
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
Console *_console;
|
2016-05-07 23:27:16 +02:00
|
|
|
public:
|
2016-05-15 15:53:00 +02:00
|
|
|
Common::RandomSource *_rnd;
|
2016-05-02 20:58:55 +02:00
|
|
|
DisplayMan *_displayMan;
|
2016-05-03 17:55:04 +02:00
|
|
|
DungeonMan *_dungeonMan;
|
2016-06-15 10:41:33 +02:00
|
|
|
EventManager *_eventMan;
|
2016-06-17 14:29:05 +02:00
|
|
|
MenuMan *_menuMan;
|
2016-06-18 11:36:31 +02:00
|
|
|
ChampionMan *_championMan;
|
|
|
|
LoadsaveMan *_loadsaveMan;
|
2016-06-19 00:54:28 +02:00
|
|
|
ObjectMan *_objectMan;
|
2016-06-19 16:17:28 +02:00
|
|
|
InventoryMan *_inventoryMan;
|
2016-06-22 20:32:30 +02:00
|
|
|
TextMan *_textMan;
|
2016-08-26 22:37:14 +02:00
|
|
|
MovesensMan *_movsens;
|
2016-08-26 22:41:19 +02:00
|
|
|
GroupMan *_groupMan;
|
2016-06-30 19:59:35 +02:00
|
|
|
Timeline *_timeline;
|
2016-06-22 20:32:30 +02:00
|
|
|
|
2016-07-02 13:47:19 +02:00
|
|
|
|
|
|
|
bool _g298_newGame; // @ G0298_B_NewGame
|
|
|
|
bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested
|
|
|
|
|
2016-07-04 01:49:58 +02:00
|
|
|
bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput
|
2016-08-26 22:43:17 +02:00
|
|
|
bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking
|
|
|
|
bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed
|
|
|
|
uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here
|
|
|
|
bool _g331_pressingEye; // @ G0331_B_PressingEye
|
|
|
|
bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye
|
|
|
|
bool _g333_pressingMouth; // @ G0333_B_PressingMouth
|
|
|
|
bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth
|
|
|
|
bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested
|
2016-06-29 22:51:40 +02:00
|
|
|
|
|
|
|
// TODO: refactor direction into a class
|
2016-07-04 01:49:58 +02:00
|
|
|
int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount
|
|
|
|
int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
|
2016-04-26 14:44:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Console : public GUI::Debugger {
|
|
|
|
public:
|
2016-06-22 07:47:41 +02:00
|
|
|
explicit Console(DMEngine *vm) {}
|
2016-04-26 14:44:01 +02:00
|
|
|
virtual ~Console(void) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace DM
|
|
|
|
|
|
|
|
#endif
|