aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-01-13 00:16:26 -0500
committerPaul Gilbert2015-01-13 00:16:26 -0500
commit747ca9eb2ff87b1205d41fcd0cf65a016ade8e0d (patch)
treeffd458b192a5c001a1dea84f7e636e19ca5e2514
parent07f37cedf54d956d9f736012f5b334e26cdbac5d (diff)
downloadscummvm-rg350-747ca9eb2ff87b1205d41fcd0cf65a016ade8e0d.tar.gz
scummvm-rg350-747ca9eb2ff87b1205d41fcd0cf65a016ade8e0d.tar.bz2
scummvm-rg350-747ca9eb2ff87b1205d41fcd0cf65a016ade8e0d.zip
XEEN: Implemented indoor drawing code in draw3d
-rw-r--r--engines/xeen/interface.cpp158
-rw-r--r--engines/xeen/interface.h10
-rw-r--r--engines/xeen/module.mk1
-rw-r--r--engines/xeen/xeen.cpp5
-rw-r--r--engines/xeen/xeen.h4
5 files changed, 166 insertions, 12 deletions
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 2dec248d54..7bbe08e378 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -371,6 +371,7 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(), _vm(vm) {
Common::fill(&_combatCharIds[0], &_combatCharIds[8], 0);
Common::fill(&_wp[0], &_wp[20], 0);
Common::fill(&_wo[0], &_wo[308], 0);
+ Common::fill(&_charsArray1[0], &_charsArray1[12], 0);
initDrawStructs();
}
@@ -408,6 +409,7 @@ void Interface::setup() {
_restoreSprites.load("restorex.icn");
_hpSprites.load("hpbars.icn");
_uiSprites.load("inn.icn");
+ _charPowSprites.load("charpow.icn");
// Get mappings to the active characters in the party
_vm->_party._activeParty.resize(_vm->_party._partyCount);
@@ -855,9 +857,11 @@ void Interface::moveCharacterToRoster() {
error("TODO");
}
-void Interface::draw3d(bool flag) {
+void Interface::draw3d(bool updateFlag) {
+ Combat &combat = *_vm->_combat;
+ EventsManager &events = *_vm->_events;
+ Map &map = *_vm->_map;
Screen &screen = *_vm->_screen;
-// EventsManager &events = *_vm->_events;
if (!screen._windows[11]._enabled)
return;
@@ -871,15 +875,15 @@ void Interface::draw3d(bool flag) {
moveMonsters();
}
- MazeObject &objObject = _vm->_map->_mobData._objects[_objNumber];
+ MazeObject &objObject = map._mobData._objects[_objNumber];
Direction partyDirection = _vm->_party._mazeDirection;
int objNum = _objNumber - 1;
// Loop to update the frame numbers for each maze object, applying the animation frame
// limits as specified by the map's _animationInfo listing
- for (uint i = 0; i < _vm->_map->_mobData._objects.size(); ++i) {
- MazeObject &mazeObject = _vm->_map->_mobData._objects[i];
- AnimationEntry &animEntry = _vm->_map->_animationInfo[mazeObject._spriteId];
+ for (uint i = 0; i < map._mobData._objects.size(); ++i) {
+ MazeObject &mazeObject = map._mobData._objects[i];
+ AnimationEntry &animEntry = map._animationInfo[mazeObject._spriteId];
int directionIndex = DIRECTION_ANIM_POSITIONS[mazeObject._direction][partyDirection];
if (_isAnimReset) {
@@ -899,7 +903,7 @@ void Interface::draw3d(bool flag) {
mazeObject._flipped = animEntry._flipped._flags[directionIndex];
}
- if (_vm->_map->_isOutdoors) {
+ if (map._isOutdoors) {
error("TODO: draw3d outdoors handling");
} else {
// Default all the parts of draw struct not to be drawn by default
@@ -931,11 +935,134 @@ void Interface::draw3d(bool flag) {
}
}
}
+
+ setMazeBits();
+ _isAnimReset = false;
+ const int INDOOR_INDEXES[3] = { 157, 151, 154 };
+ const int INDOOR_COMBAT_POS[3][2] = { { 102, 134 }, { 36, 67 }, { 161, 161 } };
+ const int INDOOR_COMBAT_POS2[4] = { 8, 6, 4, 2 };
+
+ MazeObject &objObject = map._mobData._objects[_objNumber - 1];
+
+ for (int idx = 0; idx < 3; ++idx) {
+ DrawStruct &ds1 = _indoorList[INDOOR_INDEXES[idx]];
+ DrawStruct &ds2 = _indoorList[INDOOR_INDEXES[idx] + 1];
+ ds1._sprites = nullptr;
+ ds2._sprites = nullptr;
+
+ if (_charsArray1[idx]) {
+ int posIndex= combat._attackMon2 && !combat._attackMon3 ? 1 : 0;
+ --combat._charsArray1[idx];
+
+ if (combat._monPow[idx]) {
+ ds1._x = INDOOR_COMBAT_POS[idx][0];
+ ds1._frame = 0;
+ ds1._scale = combat._monsterScale[idx];
+ if (ds1._scale == 0x8000) {
+ ds1._x /= 3;
+ ds1._y = 60;
+ } else {
+ ds1._y = 73;
+ }
+
+ ds1._flags = SPRFLAG_4000 | SPRFLAG_2000;
+ ds1._sprites = &_charPowSprites;
+ }
+
+ if (combat._elemPow[idx]) {
+ ds2._x = INDOOR_COMBAT_POS[idx][posIndex] + INDOOR_COMBAT_POS2[idx];
+ ds2._frame = combat._elemPow[idx];
+ ds2._scale = combat._elemScale[idx];
+ if (ds2._scale == 0x8000)
+ ds2._x /= 3;
+ ds2._flags = SPRFLAG_4000 | SPRFLAG_2000;
+ ds2._sprites = &_charPowSprites;
+ }
+ }
+ }
+
+ setIndoorsMonsters();
+ setIndoorObjects();
+ setIndoorWallPics();
+
+ _indoorList[161]._sprites = nullptr;
+ _indoorList[160]._sprites = nullptr;
+ _indoorList[159]._sprites = nullptr;
+
+ // Handle attacking monsters
+ int monsterIndex = 0;
+ if (combat._attackMon1 != -1 && map._mobData._monsters[combat._attackMon1]._frame >= 0) {
+ _indoorList[159] = _indoorList[156];
+ _indoorList[160] = _indoorList[157];
+ _indoorList[161] = _indoorList[158];
+ _indoorList[158]._sprites = nullptr;
+ _indoorList[156]._sprites = nullptr;
+ _indoorList[157]._sprites = nullptr;
+ monsterIndex = 1;
+ } else if (combat._attackMon2 != -1 && map._mobData._monsters[combat._attackMon2]._frame >= 0) {
+ _indoorList[159] = _indoorList[150];
+ _indoorList[160] = _indoorList[151];
+ _indoorList[161] = _indoorList[152];
+ _indoorList[152]._sprites = nullptr;
+ _indoorList[151]._sprites = nullptr;
+ _indoorList[150]._sprites = nullptr;
+ monsterIndex = 2;
+ } else if (combat._attackMon3 != -1 && map._mobData._monsters[combat._attackMon3]._frame >= 0) {
+ _indoorList[159] = _indoorList[153];
+ _indoorList[160] = _indoorList[154];
+ _indoorList[161] = _indoorList[155];
+ _indoorList[153]._sprites = nullptr;
+ _indoorList[154]._sprites = nullptr;
+ _indoorList[155]._sprites = nullptr;
+ monsterIndex = 3;
+ }
+
+ drawIndoors();
+
+ switch (monsterIndex) {
+ case 1:
+ _indoorList[156] = _indoorList[159];
+ _indoorList[157] = _indoorList[160];
+ _indoorList[158] = _indoorList[161];
+ break;
+ case 2:
+ _indoorList[150] = _indoorList[159];
+ _indoorList[151] = _indoorList[160];
+ _indoorList[152] = _indoorList[161];
+ break;
+ case 3:
+ _indoorList[153] = _indoorList[159];
+ _indoorList[154] = _indoorList[160];
+ _indoorList[155] = _indoorList[161];
+ break;
+ default:
+ break;
+ }
+ }
+
+ animate3d();
+ updateAutoMap();
+
+ if (_vm->_falling == 1) {
+ error("TODO: Indoor falling");
}
- // TODO: more
+ if (_vm->_falling == 2) {
+ screen.saveBackground(1);
+ }
+
+ assembleBorder();
- warning("TODO");
+ // TODO: write strings
+
+ if (updateFlag) {
+ screen._windows[1].update();
+ screen._windows[3].update();
+ }
+
+ // TODO: more stuff
+
+ events.wait(2);
}
void Interface::animate3d() {
@@ -1124,6 +1251,11 @@ void Interface::setIndoorObjects() {
}
}
+void Interface::setIndoorWallPics() {
+ // TODO
+}
+
+
void Interface::setOutdoorsMonsters() {
}
@@ -2691,4 +2823,12 @@ void Interface::setMazeBits() {
}
}
+void Interface::drawIndoors() {
+ // TODO
+}
+
+void Interface::updateAutoMap() {
+ // TODO
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h
index bd2f2af4b7..ec8a384313 100644
--- a/engines/xeen/interface.h
+++ b/engines/xeen/interface.h
@@ -81,6 +81,7 @@ private:
SpriteResource _hpSprites;
SpriteResource _uiSprites;
SpriteResource _iconSprites;
+ SpriteResource _charPowSprites;
SpriteResource _charFaces[TOTAL_CHARACTERS];
SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
DrawStruct _faceDrawStructs[4];
@@ -114,6 +115,7 @@ private:
byte _wp[20];
byte _wo[308];
bool _thinWall;
+ int _charsArray1[12];
void loadSprites();
@@ -137,6 +139,10 @@ private:
void setIndoorObjects();
+ void setIndoorWallPics();
+
+ void drawIndoors();
+
void setOutdoorsMonsters();
void setOutdoorsObjects();
@@ -146,6 +152,8 @@ private:
void setMainButtons();
void setMazeBits();
+
+ void updateAutoMap();
public:
Interface(XeenEngine *vm);
@@ -157,7 +165,7 @@ public:
void loadPartyIcons();
- void draw3d(bool flag);
+ void draw3d(bool updateFlag);
void startup();
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index 076a31a916..2c22322f25 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
clouds\clouds_game.o \
darkside\darkside_game.o \
worldofxeen\worldofxeen_game.o \
+ combat.o \
debugger.o \
detection.o \
dialogs.o \
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index 583a1dd262..c749129678 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -36,6 +36,7 @@ namespace Xeen {
XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
: Engine(syst), _gameDescription(gameDesc), _randomSource("Xeen") {
+ _combat = nullptr;
_debugger = nullptr;
_events = nullptr;
_files = nullptr;
@@ -50,12 +51,13 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_face1State = 0;
_face2State = 0;
_noDirectionSense = false;
- _falling = false;
+ _falling = 0;
_moveMonsters = false;
_mode = MODE_0;
}
XeenEngine::~XeenEngine() {
+ delete _combat;
delete _debugger;
delete _events;
delete _interface;
@@ -76,6 +78,7 @@ void XeenEngine::initialize() {
// Create sub-objects of the engine
_files = new FileManager(this);
+ _combat = new Combat(this);
_debugger = new Debugger(this);
_events = new EventsManager(this);
_interface = new Interface(this);
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index a9b102aec2..59279771d5 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -31,6 +31,7 @@
#include "common/serializer.h"
#include "common/util.h"
#include "engines/engine.h"
+#include "xeen/combat.h"
#include "xeen/debugger.h"
#include "xeen/dialogs.h"
#include "xeen/events.h"
@@ -124,6 +125,7 @@ private:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
+ Combat *_combat;
Debugger *_debugger;
EventsManager *_events;
FileManager *_files;
@@ -142,7 +144,7 @@ public:
int _face1State;
int _face2State;
bool _noDirectionSense;
- bool _falling;
+ int _falling;
bool _moveMonsters;
public:
XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc);