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
|
|
|
#include "common/scummsys.h"
|
2016-05-02 20:58:55 +02:00
|
|
|
#include "common/system.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
|
|
|
|
#include "engines/util.h"
|
2016-05-02 20:58:55 +02:00
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "graphics/palette.h"
|
|
|
|
#include "common/file.h"
|
2016-05-21 21:09:09 +02:00
|
|
|
#include "common/events.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
#include "dm/dm.h"
|
2016-06-15 22:42:08 +02:00
|
|
|
#include "gfx.h"
|
|
|
|
#include "dungeonman.h"
|
|
|
|
#include "eventman.h"
|
2016-06-17 14:29:05 +02:00
|
|
|
#include "menus.h"
|
2016-06-18 11:36:31 +02:00
|
|
|
#include "champion.h"
|
|
|
|
#include "loadsave.h"
|
2016-06-19 00:54:28 +02:00
|
|
|
#include "objectman.h"
|
2016-06-19 16:17:28 +02:00
|
|
|
#include "inventory.h"
|
2016-06-22 20:32:30 +02:00
|
|
|
#include "text.h"
|
2016-08-26 22:37:14 +02:00
|
|
|
#include "movesens.h"
|
2016-08-26 22:41:19 +02:00
|
|
|
#include "group.h"
|
2016-06-30 19:59:35 +02:00
|
|
|
#include "timeline.h"
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-05-21 21:09:09 +02:00
|
|
|
void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
|
|
|
|
void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
|
2016-08-26 22:07:38 +02:00
|
|
|
direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); }
|
2016-06-30 15:48:23 +02:00
|
|
|
|
|
|
|
uint16 returnPrevVal(uint16 val) {
|
|
|
|
return (direction)((val + 3) & 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 returnNextVal(uint16 val) {
|
|
|
|
return (val + 1) & 0x3;
|
|
|
|
}
|
|
|
|
|
2016-05-21 21:09:09 +02:00
|
|
|
bool isOrientedWestEast(direction dir) { return dir & 1; }
|
|
|
|
|
2016-06-29 22:08:10 +02:00
|
|
|
uint16 getFlag(uint16 val, uint16 mask) {
|
|
|
|
return val & mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFlag(uint16 &val, uint16 mask) {
|
|
|
|
val |= mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearFlag(uint16 &val, uint16 mask) {
|
|
|
|
val &= ~mask;
|
|
|
|
}
|
2016-05-04 12:50:06 +02:00
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) {
|
2016-06-29 22:08:10 +02:00
|
|
|
// Do not load data files
|
|
|
|
// Do not initialize graphics here
|
|
|
|
// Do not initialize audio devices here
|
|
|
|
// Do these from run
|
|
|
|
|
|
|
|
//Specify all default directories
|
|
|
|
//const Common::FSNode gameDataDir(ConfMan.get("example"));
|
|
|
|
//SearchMan.addSubDirectoryMatching(gameDataDir, "example2");
|
2016-04-26 14:44:01 +02:00
|
|
|
DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc");
|
|
|
|
|
2016-05-04 11:23:52 +02:00
|
|
|
// register random source
|
2016-04-26 14:44:01 +02:00
|
|
|
_rnd = new Common::RandomSource("quux");
|
|
|
|
|
2016-06-17 23:08:04 +02:00
|
|
|
_dungeonMan = nullptr;
|
2016-06-18 11:36:31 +02:00
|
|
|
_displayMan = nullptr;
|
2016-06-17 23:08:04 +02:00
|
|
|
_eventMan = nullptr;
|
|
|
|
_menuMan = nullptr;
|
2016-06-18 11:36:31 +02:00
|
|
|
_championMan = nullptr;
|
|
|
|
_loadsaveMan = nullptr;
|
2016-06-19 00:54:28 +02:00
|
|
|
_objectMan = nullptr;
|
2016-06-19 16:17:28 +02:00
|
|
|
_inventoryMan = nullptr;
|
2016-06-22 20:32:30 +02:00
|
|
|
_textMan = nullptr;
|
2016-08-26 22:37:14 +02:00
|
|
|
_movsens = nullptr;
|
2016-08-26 22:41:19 +02:00
|
|
|
_groupMan = nullptr;
|
2016-06-30 19:59:35 +02:00
|
|
|
_timeline = nullptr;
|
2016-06-17 23:08:04 +02:00
|
|
|
_stopWaitingForPlayerInput = false;
|
|
|
|
_gameTimeTicking = false;
|
2016-08-26 22:33:28 +02:00
|
|
|
_restartGameAllowed = false;
|
|
|
|
_pressingEye = false;
|
|
|
|
_pressingMouth = false;
|
|
|
|
_stopPressingEye = false;
|
|
|
|
_stopPressingMouth = false;
|
|
|
|
_highlightBoxInversionRequested = false;
|
2016-06-17 23:08:04 +02:00
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
debug("DMEngine::DMEngine");
|
|
|
|
}
|
|
|
|
|
|
|
|
DMEngine::~DMEngine() {
|
|
|
|
debug("DMEngine::~DMEngine");
|
|
|
|
|
|
|
|
// dispose of resources
|
|
|
|
delete _rnd;
|
2016-05-02 20:58:55 +02:00
|
|
|
delete _console;
|
|
|
|
delete _displayMan;
|
2016-05-03 17:55:04 +02:00
|
|
|
delete _dungeonMan;
|
2016-06-15 10:41:33 +02:00
|
|
|
delete _eventMan;
|
2016-06-17 14:29:05 +02:00
|
|
|
delete _menuMan;
|
2016-06-18 11:36:31 +02:00
|
|
|
delete _championMan;
|
|
|
|
delete _loadsaveMan;
|
2016-06-19 00:54:28 +02:00
|
|
|
delete _objectMan;
|
2016-06-19 16:17:28 +02:00
|
|
|
delete _inventoryMan;
|
2016-06-22 20:32:30 +02:00
|
|
|
delete _textMan;
|
2016-08-26 22:37:14 +02:00
|
|
|
delete _movsens;
|
2016-08-26 22:41:19 +02:00
|
|
|
delete _groupMan;
|
2016-06-30 19:59:35 +02:00
|
|
|
delete _timeline;
|
2016-04-26 14:44:01 +02:00
|
|
|
|
|
|
|
// clear debug channels
|
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
}
|
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
void DMEngine::initializeGame() {
|
|
|
|
_displayMan->loadGraphics();
|
|
|
|
// DUMMY CODE: next line
|
|
|
|
_displayMan->loadPalette(gPalCredits);
|
|
|
|
|
|
|
|
_eventMan->initMouse();
|
|
|
|
|
|
|
|
while (_loadsaveMan->loadgame() != kLoadgameSuccess) {
|
2016-06-19 00:24:19 +02:00
|
|
|
warning("TODO: F0441_STARTEND_ProcessEntrance");
|
2016-06-18 17:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_displayMan->loadFloorSet(kFloorSetStone);
|
|
|
|
_displayMan->loadWallSet(kWallSetStone);
|
2016-06-28 18:04:32 +02:00
|
|
|
_objectMan->loadObjectNames();
|
2016-06-18 17:18:01 +02:00
|
|
|
|
|
|
|
startGame();
|
|
|
|
warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)");
|
|
|
|
_eventMan->showMouse(true);
|
|
|
|
warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DMEngine::startGame() {
|
2016-06-18 19:42:05 +02:00
|
|
|
_pressingEye = false;
|
|
|
|
_stopPressingEye = false;
|
|
|
|
_pressingMouth = false;
|
|
|
|
_stopPressingMouth = false;
|
|
|
|
_highlightBoxInversionRequested = false;
|
|
|
|
_eventMan->_highlightBoxEnabled = false;
|
|
|
|
_championMan->_partyIsSleeping = false;
|
|
|
|
_championMan->_actingChampionOrdinal = indexToOrdinal(kChampionNone);
|
|
|
|
_menuMan->_actionAreaContainsIcons = true;
|
|
|
|
_eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kChampionNone);
|
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
|
|
|
|
_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
|
2016-06-18 19:42:05 +02:00
|
|
|
warning("MISSING CODE: set primary/secondary keyboard input");
|
|
|
|
|
2016-06-18 19:58:19 +02:00
|
|
|
processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex);
|
2016-06-18 17:18:01 +02:00
|
|
|
|
2016-06-18 19:42:05 +02:00
|
|
|
if (!_dungeonMan->_messages._newGame) {
|
2016-06-19 00:24:19 +02:00
|
|
|
warning("TODO: loading game");
|
2016-06-19 00:49:23 +02:00
|
|
|
} else {
|
2016-06-18 19:42:05 +02:00
|
|
|
_displayMan->_useByteBoxCoordinates = false;
|
2016-06-19 00:24:19 +02:00
|
|
|
warning("TODO: clear screen");
|
2016-06-18 19:42:05 +02:00
|
|
|
}
|
2016-06-18 17:18:01 +02:00
|
|
|
|
2016-06-19 00:24:19 +02:00
|
|
|
warning("TODO: build copper");
|
2016-06-18 17:18:01 +02:00
|
|
|
_menuMan->drawMovementArrows();
|
2016-06-18 20:27:31 +02:00
|
|
|
_championMan->resetDataToStartGame();
|
2016-06-18 17:18:01 +02:00
|
|
|
_gameTimeTicking = true;
|
|
|
|
}
|
2016-05-03 17:55:04 +02:00
|
|
|
|
2016-06-18 19:58:19 +02:00
|
|
|
void DMEngine::processNewPartyMap(uint16 mapIndex) {
|
|
|
|
warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups");
|
|
|
|
_dungeonMan->setCurrentMapAndPartyMap(mapIndex);
|
|
|
|
_displayMan->loadCurrentMapGraphics();
|
|
|
|
warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups");
|
|
|
|
warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette");
|
|
|
|
}
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
Common::Error DMEngine::run() {
|
2016-06-29 23:17:04 +02:00
|
|
|
initArrays();
|
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
// scummvm/engine specific
|
2016-04-26 14:44:01 +02:00
|
|
|
initGraphics(320, 200, false);
|
|
|
|
_console = new Console(this);
|
2016-05-02 20:58:55 +02:00
|
|
|
_displayMan = new DisplayMan(this);
|
2016-05-03 17:55:04 +02:00
|
|
|
_dungeonMan = new DungeonMan(this);
|
2016-06-15 10:41:33 +02:00
|
|
|
_eventMan = new EventManager(this);
|
2016-06-17 14:29:05 +02:00
|
|
|
_menuMan = new MenuMan(this);
|
2016-06-18 11:36:31 +02:00
|
|
|
_championMan = new ChampionMan(this);
|
|
|
|
_loadsaveMan = new LoadsaveMan(this);
|
2016-06-19 00:54:28 +02:00
|
|
|
_objectMan = new ObjectMan(this);
|
2016-06-19 16:17:28 +02:00
|
|
|
_inventoryMan = new InventoryMan(this);
|
2016-06-22 20:32:30 +02:00
|
|
|
_textMan = new TextMan(this);
|
2016-06-30 15:48:23 +02:00
|
|
|
_movsens = new MovesensMan(this);
|
2016-08-26 22:41:19 +02:00
|
|
|
_groupMan = new GroupMan(this);
|
2016-06-30 19:59:35 +02:00
|
|
|
_timeline = new Timeline(this);
|
2016-05-15 17:52:39 +02:00
|
|
|
_displayMan->setUpScreens(320, 200);
|
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
initializeGame(); // @ F0463_START_InitializeGame_CPSADEF
|
|
|
|
while (true) {
|
|
|
|
gameloop();
|
2016-06-19 00:24:19 +02:00
|
|
|
warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);");
|
2016-06-18 17:18:01 +02:00
|
|
|
}
|
2016-06-16 23:48:18 +02:00
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2016-06-16 23:48:18 +02:00
|
|
|
|
2016-06-18 17:18:01 +02:00
|
|
|
void DMEngine::gameloop() {
|
2016-08-26 22:09:29 +02:00
|
|
|
warning("DUMMY CODE SETTING PARTY POS AND DIRECTION");
|
|
|
|
_dungeonMan->_currMap._partyPosX = 10;
|
|
|
|
_dungeonMan->_currMap._partyPosY = 4;
|
|
|
|
_dungeonMan->_currMap._partyDir = kDirNorth;
|
2016-06-29 22:08:10 +02:00
|
|
|
|
2016-06-20 14:34:31 +02:00
|
|
|
|
|
|
|
warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero");
|
|
|
|
_inventoryMan->_inventoryChampionOrdinal = 0;
|
2016-08-26 22:38:51 +02:00
|
|
|
warning("DUMMY CODE: clearing screen to black"); // in loop below
|
2016-05-02 20:58:55 +02:00
|
|
|
while (true) {
|
2016-06-17 14:29:05 +02:00
|
|
|
_stopWaitingForPlayerInput = false;
|
2016-08-26 22:38:51 +02:00
|
|
|
|
|
|
|
_menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived();
|
|
|
|
|
2016-06-17 14:29:05 +02:00
|
|
|
//do {
|
2016-06-18 17:18:01 +02:00
|
|
|
_eventMan->processInput();
|
|
|
|
_eventMan->processCommandQueue();
|
2016-06-17 14:29:05 +02:00
|
|
|
//} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
|
|
|
|
|
2016-06-20 14:34:31 +02:00
|
|
|
if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) {
|
2016-06-25 13:31:47 +02:00
|
|
|
Box box(0, 224, 0, 126);
|
|
|
|
_displayMan->clearScreenBox(kColorBlack, box, gDungeonViewport); // dummy code
|
2016-06-20 14:34:31 +02:00
|
|
|
_displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY);
|
|
|
|
}
|
2016-06-18 17:18:01 +02:00
|
|
|
// DUMMY CODE: next line
|
2016-06-17 14:29:05 +02:00
|
|
|
_menuMan->drawMovementArrows();
|
2016-05-02 20:58:55 +02:00
|
|
|
_displayMan->updateScreen();
|
2016-05-21 21:09:09 +02:00
|
|
|
_system->delayMillis(10);
|
2016-05-02 20:58:55 +02:00
|
|
|
}
|
2016-06-16 23:48:18 +02:00
|
|
|
}
|
|
|
|
|
2016-06-23 23:12:39 +02:00
|
|
|
int16 DMEngine::ordinalToIndex(int16 val) {
|
|
|
|
return val - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 DMEngine::indexToOrdinal(int16 val) {
|
|
|
|
return val + 1;
|
|
|
|
}
|
|
|
|
|
2016-04-26 14:44:01 +02:00
|
|
|
} // End of namespace DM
|