aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/dialogs_string_input.cpp75
-rw-r--r--engines/xeen/dialogs_string_input.h45
-rw-r--r--engines/xeen/dialogs_whowill.cpp1
-rw-r--r--engines/xeen/dialogs_yesno.cpp1
-rw-r--r--engines/xeen/interface.cpp2
-rw-r--r--engines/xeen/interface.h2
-rw-r--r--engines/xeen/interface_map.h2
-rw-r--r--engines/xeen/items.cpp4
-rw-r--r--engines/xeen/items.h13
-rw-r--r--engines/xeen/map.cpp10
-rw-r--r--engines/xeen/map.h2
-rw-r--r--engines/xeen/module.mk1
-rw-r--r--engines/xeen/party.cpp40
-rw-r--r--engines/xeen/party.h6
-rw-r--r--engines/xeen/resources.cpp4
-rw-r--r--engines/xeen/resources.h4
-rw-r--r--engines/xeen/saves.cpp4
-rw-r--r--engines/xeen/saves.h2
-rw-r--r--engines/xeen/screen.cpp78
-rw-r--r--engines/xeen/screen.h5
-rw-r--r--engines/xeen/scripts.cpp170
-rw-r--r--engines/xeen/scripts.h15
-rw-r--r--engines/xeen/xeen.cpp1
-rw-r--r--engines/xeen/xeen.h3
24 files changed, 467 insertions, 23 deletions
diff --git a/engines/xeen/dialogs_string_input.cpp b/engines/xeen/dialogs_string_input.cpp
new file mode 100644
index 0000000000..03191f877d
--- /dev/null
+++ b/engines/xeen/dialogs_string_input.cpp
@@ -0,0 +1,75 @@
+/* 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.
+ *
+ */
+
+#include "xeen/dialogs_string_input.h"
+#include "xeen/xeen.h"
+
+namespace Xeen {
+
+int StringInput::show(XeenEngine *vm, bool type, const Common::String &msg1,
+ const Common::String &msg2, int opcdoe) {
+ StringInput *dlg = new StringInput(vm);
+ int result = dlg->execute(type, msg1, msg2, opcdoe);
+ delete dlg;
+
+ return result;
+}
+
+int StringInput::execute(bool type, const Common::String &expected,
+ const Common::String &title, int opcode) {
+ Interface &intf = *_vm->_interface;
+ Screen &screen = *_vm->_screen;
+ Window &w = screen._windows[6];
+ SoundManager &sound = *_vm->_sound;
+ int result = 0;
+
+ w.open();
+ w.writeString(Common::String::format("\r\x03""c%s\v024\t000", title.c_str()));
+ w.update();
+
+ Common::String line;
+ if (w.getString(line, 30, 200)) {
+ if (type) {
+ if (line == intf._interfaceText) {
+ result = true;
+ } else if (line == expected) {
+ result = (opcode == 55) ? -1 : 1;
+ }
+ } else {
+ // Load in the mirror list
+ File f(Common::String::format("%smirr.txt",
+ _vm->_files->_isDarkCc ? "dark" : "xeen"));
+ for (int idx = 0; f.pos() < f.size(); ++idx) {
+ if (line == f.readLine()) {
+ result = idx;
+ sound.playFX(_vm->_files->_isDarkCc ? 35 : 61);
+ break;
+ }
+ }
+ }
+ }
+
+ w.close();
+ return result;
+}
+
+} // End of namespace Xeen
diff --git a/engines/xeen/dialogs_string_input.h b/engines/xeen/dialogs_string_input.h
new file mode 100644
index 0000000000..1e18726ff2
--- /dev/null
+++ b/engines/xeen/dialogs_string_input.h
@@ -0,0 +1,45 @@
+/* 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 XEEN_DIALOGS_STRING_INPUT_H
+#define XEEN_DIALOGS_STRING_INPUT_H
+
+#include "xeen/dialogs.h"
+
+namespace Xeen {
+
+class StringInput : public ButtonContainer {
+private:
+ XeenEngine *_vm;
+
+ StringInput(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+
+ int execute(bool type, const Common::String &expected,
+ const Common::String &title, int opcode);
+public:
+ static int show(XeenEngine *vm, bool type, const Common::String &msg1,
+ const Common::String &msg2, int opcdoe);
+};
+
+} // End of namespace Xeen
+
+#endif /* XEEN_DIALOGS_STRING_INPUT_H */
diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp
index 402f5c6107..042214a3dc 100644
--- a/engines/xeen/dialogs_whowill.cpp
+++ b/engines/xeen/dialogs_whowill.cpp
@@ -76,6 +76,7 @@ int WhoWill::execute(int message, int action, bool type) {
}
events.wait(numFrames, true);
+ checkEvents(_vm);
if (!_buttonValue)
continue;
diff --git a/engines/xeen/dialogs_yesno.cpp b/engines/xeen/dialogs_yesno.cpp
index cefafa0feb..6f74d86ca4 100644
--- a/engines/xeen/dialogs_yesno.cpp
+++ b/engines/xeen/dialogs_yesno.cpp
@@ -72,6 +72,7 @@ bool YesNo::execute(bool type, int v2) {
}
events.wait(3, true);
+ checkEvents(_vm);
if (!_buttonValue)
continue;
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 31fe00b0b8..7487d63788 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -485,7 +485,7 @@ void Interface::perform() {
if (_buttonValue == Common::KEYCODE_SPACE ||
(events._leftButton && waitBounds.contains(events._mousePos))) {
int lookupId = map.mazeLookup(party._mazePosition,
- WALL_NUMBERS[party._mazeDirection][2]);
+ WALL_SHIFTS[party._mazeDirection][2]);
bool eventsFlag = true;
switch (lookupId) {
diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h
index 7879da59ed..3d8116d03d 100644
--- a/engines/xeen/interface.h
+++ b/engines/xeen/interface.h
@@ -52,7 +52,6 @@ private:
bool _buttonsLoaded;
int _hiliteChar;
int _steppingFX;
- Common::String _interfaceText;
void initDrawStructs();
@@ -78,6 +77,7 @@ private:
public:
SpriteResource _townSprites[8];
int _intrIndex1;
+ Common::String _interfaceText;
public:
Interface(XeenEngine *vm);
diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h
index 51b82a9445..914120fb2c 100644
--- a/engines/xeen/interface_map.h
+++ b/engines/xeen/interface_map.h
@@ -124,7 +124,6 @@ protected:
int _holyBonusUIFrame;
int _heroismUIFrame;
int _flipUIFrame;
- byte _tillMove;
bool _flag1;
int _overallFrame;
@@ -147,6 +146,7 @@ public:
Common::String _screenText;
int _face1State;
int _face2State;
+ byte _tillMove;
public:
InterfaceMap(XeenEngine *vm);
diff --git a/engines/xeen/items.cpp b/engines/xeen/items.cpp
index e22e8656d7..e9425f7ee9 100644
--- a/engines/xeen/items.cpp
+++ b/engines/xeen/items.cpp
@@ -36,4 +36,8 @@ void XeenItem::synchronize(Common::Serializer &s) {
s.syncAsByte(_equipped);
}
+Treasure::Treasure() {
+ _hasItems = false;
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/items.h b/engines/xeen/items.h
index eba2354da5..6fa57b922a 100644
--- a/engines/xeen/items.h
+++ b/engines/xeen/items.h
@@ -28,6 +28,8 @@
namespace Xeen {
+#define TOTAL_ITEMS 10
+
class XeenItem {
public:
int _material;
@@ -40,6 +42,17 @@ public:
void synchronize(Common::Serializer &s);
};
+class Treasure {
+public:
+ XeenItem _misc[TOTAL_ITEMS];
+ XeenItem _accessories[TOTAL_ITEMS];
+ XeenItem _armor[TOTAL_ITEMS];
+ XeenItem _weapons[TOTAL_ITEMS];
+ bool _hasItems;
+public:
+ Treasure();
+};
+
} // End of namespace Xeen
#endif /* XEEN_ITEMS_H */
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index 5c49e37f4c..7801a050bb 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -1367,6 +1367,14 @@ void Map::setCellSurfaceFlags(const Common::Point &pt, int bits) {
_mazeData[0]._cells[pt.y][pt.x]._surfaceId |= bits;
}
+void Map::setWall(const Common::Point &pt, Direction dir, int v) {
+ const int XOR_MASKS[4] = { 0xFFF, 0xF0FF, 0xFF0F, 0xFFF0 };
+ mazeLookup(pt, 0, 0);
+
+ MazeWallLayers &wallLayer = _mazeData[0]._wallData[pt.y][pt.x];
+ wallLayer._data &= XOR_MASKS[dir];
+ wallLayer._data |= v << WALL_SHIFTS[dir][2];
+}
int Map::getCell(int idx) {
int mapId = _vm->_party->_mazeId;
@@ -1489,7 +1497,7 @@ int Map::getCell(int idx) {
_currentSurfaceId = _mazeData[_mazeDataIndex]._cells[pt.y][pt.x]._surfaceId;
_currentWall = wallLayers;
- return (_currentWall._data >> WALL_NUMBERS[dir][idx]) & 0xF;
+ return (_currentWall._data >> WALL_SHIFTS[dir][idx]) & 0xF;
}
return _currentWall._data;
diff --git a/engines/xeen/map.h b/engines/xeen/map.h
index 58e3aaa39c..51f426d566 100644
--- a/engines/xeen/map.h
+++ b/engines/xeen/map.h
@@ -385,6 +385,8 @@ public:
void setCellSurfaceFlags(const Common::Point &pt, int bits);
+ void setWall(const Common::Point &pt, Direction dir, int v);
+
void saveMaze();
int getCell(int idx);
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index 05a9b23797..ea6ea8c073 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS := \
dialogs.o \
dialogs_error.o \
dialogs_options.o \
+ dialogs_string_input.o \
dialogs_whowill.o \
dialogs_yesno.o \
events.o \
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index c1c4062172..b33318fcdf 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -51,7 +51,7 @@ PlayerStruct::PlayerStruct() {
_dbDay = 0;
_tempAge = 0;
Common::fill(&_skills[0], &_skills[18], 0);
- Common::fill(&_awards[0], &_awards[512], false);
+ Common::fill(&_awards[0], &_awards[128], false);
Common::fill(&_spells[9], &_spells[312], false);
_lloydMap = 0;
_hasSpells = false;
@@ -95,9 +95,21 @@ void PlayerStruct::synchronize(Common::Serializer &s) {
s.syncAsByte(_dbDay);
s.syncAsByte(_tempAge);
- for (int i = 0; i < 18; ++i)
- s.syncAsByte(_skills[i]);
- SavesManager::syncBitFlags(s, &_awards[0], &_awards[512]);
+ // Synchronize the skill list
+ for (int idx = 0; idx < 18; ++idx)
+ s.syncAsByte(_skills[idx]);
+
+ // Synchronize character awards
+ for (int idx = 0; idx < 64; ++idx) {
+ byte b = (_awards[idx] ? 1 : 0) | (_awards[idx + 64] ? 0x10 : 0);
+ s.syncAsByte(b);
+ if (s.isLoading()) {
+ _awards[idx] = (b & 0xF) != 0;
+ _awards[idx + 64] = (b & 0xF0) != 0;
+ }
+ }
+
+ // Synchronize spell list
SavesManager::syncBitFlags(s, &_spells[0], &_spells[312]);
s.syncAsByte(_lloydMap);
@@ -172,6 +184,26 @@ bool PlayerStruct::noActions() {
return false;
}
+void PlayerStruct::setAward(int awardId, bool value) {
+ int v = awardId;
+ if (awardId == 73)
+ v = 126;
+ else if (awardId == 81)
+ v = 127;
+
+ _awards[v] = value;
+}
+
+bool PlayerStruct::hasAward(int awardId) {
+ int v = awardId;
+ if (awardId == 73)
+ v = 126;
+ else if (awardId == 81)
+ v = 127;
+
+ return _awards[v];
+}
+
/*------------------------------------------------------------------------*/
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 19376839af..a00b18910d 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -99,7 +99,7 @@ public:
int _dbDay;
int _tempAge;
int _skills[18];
- bool _awards[512];
+ bool _awards[128];
bool _spells[312];
int _lloydMap;
Common::Point _lloydPosition;
@@ -141,6 +141,10 @@ public:
bool charSavingThrow();
bool noActions();
+
+ bool hasAward(int awardId);
+
+ void setAward(int awardId, bool value);
};
class Roster: public Common::Array<PlayerStruct> {
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 994762bf5b..c167bdbb48 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -71,6 +71,8 @@ const char *const THE_PARTY_NEEDS_REST = "\x0B""012The Party needs rest!";
const char *const WHO_WILL = "\X03""c\X0B""000\x09""000%s\x0A\x0A"
"Who will\x0A%s?\x0A\x0B""055F1 - F%d";
+const char *const WHATS_THE_PASSWORD = "What's the Password?";
+
const char *const TERRAIN_TYPES[6] = {
"town", "cave", "towr", "cstl", "dung", "scfi"
};
@@ -408,7 +410,7 @@ const int DIRECTION_ANIM_POSITIONS[4][4] = {
{ 0, 1, 2, 3 }, { 3, 0, 1, 2 }, { 2, 3, 0, 1 }, { 1, 2, 3, 0 }
};
-const byte WALL_NUMBERS[4][48] = {
+const byte WALL_SHIFTS[4][48] = {
{
12, 0, 12, 8, 12, 12, 0, 12, 8, 12, 12, 0,
12, 0, 12, 8, 12, 8, 12, 12, 0, 12, 0, 12,
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index 28a35543b6..e62454eafd 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -36,6 +36,8 @@ extern const char *const THE_PARTY_NEEDS_REST;
extern const char *const WHO_WILL;
+extern const char *const WHATS_THE_PASSWORD;
+
extern const char *const TERRAIN_TYPES[6];
extern const char *const SURFACE_TYPE_NAMES[15];
@@ -96,7 +98,7 @@ extern const int OUTDOOR_OBJECT_Y[2][12];
extern const int DIRECTION_ANIM_POSITIONS[4][4];
-extern const byte WALL_NUMBERS[4][48];
+extern const byte WALL_SHIFTS[4][48];
extern const int DRAW_NUMBERS[25];
diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp
index c2b15106eb..da791cdd77 100644
--- a/engines/xeen/saves.cpp
+++ b/engines/xeen/saves.cpp
@@ -168,4 +168,8 @@ void SavesManager::writeCharFile() {
warning("TODO: writeCharFile");
}
+void SavesManager::saveChars() {
+ warning("TODO: saveChars");
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/saves.h b/engines/xeen/saves.h
index 6b73625c61..7dea941f8d 100644
--- a/engines/xeen/saves.h
+++ b/engines/xeen/saves.h
@@ -77,6 +77,8 @@ public:
void writeCharFile();
+ void saveChars();
+
// Archive implementation
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
};
diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp
index de591d396d..42182cc7fe 100644
--- a/engines/xeen/screen.cpp
+++ b/engines/xeen/screen.cpp
@@ -182,6 +182,84 @@ void Window::drawList(DrawStruct *items, int count) {
}
}
+/**
+ * Allows the user to enter a string
+ */
+int Window::getString(Common::String &line, int maxLen, int maxWidth) {
+ Interface &intf = *_vm->_interface;
+
+ _vm->_noDirectionSense = true;
+ Common::String msg = Common::String::format("\x03""l\t000\x04%03d\x03""c", maxWidth);
+ writeString(msg);
+ update();
+
+ while (!_vm->shouldQuit()) {
+ Common::KeyCode keyCode = doCursor(msg);
+
+ if ((keyCode == Common::KEYCODE_BACKSPACE || keyCode == Common::KEYCODE_DELETE)
+ && line.size() > 0)
+ line.deleteLastChar();
+ else if (keyCode >= Common::KEYCODE_SPACE && keyCode < Common::KEYCODE_DELETE
+ && line.size() < maxLen && (line.size() > 0 || keyCode != Common::KEYCODE_SPACE)) {
+
+ } else if (keyCode == Common::KEYCODE_RETURN || keyCode == Common::KEYCODE_KP_ENTER) {
+ break;
+ } else if (keyCode == Common::KEYCODE_ESCAPE) {
+ line = "";
+ break;
+ }
+ }
+
+ _vm->_noDirectionSense = false;
+ return line.size();
+}
+
+/**
+ * Draws the cursor and waits until the user presses a key
+ */
+Common::KeyCode Window::doCursor(const Common::String &msg) {
+ EventsManager &events = *_vm->_events;
+ Interface &intf = *_vm->_interface;
+ Screen &screen = *_vm->_screen;
+
+ bool oldUpDoorText = intf._upDoorText;
+ byte oldTillMove = intf._tillMove;
+ intf._upDoorText = false;
+ intf._tillMove = 0;
+
+ bool flag = !_vm->_startupWindowActive && !screen._windows[25]._enabled
+ && _vm->_mode != MODE_FF && _vm->_mode != MODE_17;
+
+ Common::KeyCode ch = Common::KEYCODE_INVALID;
+ while (!_vm->shouldQuit()) {
+ events.updateGameCounter();
+
+ if (flag)
+ intf.draw3d(false);
+ writeString(msg);
+ update();
+
+ if (flag)
+ screen._windows[3].update();
+
+ events.wait(1, true);
+ if (events.isKeyPending()) {
+ Common::KeyState keyState;
+ events.getKey(keyState);
+ ch = keyState.keycode;
+ break;
+ }
+ }
+
+ writeString("");
+ update();
+
+ intf._tillMove = oldTillMove;
+ intf._upDoorText = oldUpDoorText;
+
+ return ch;
+}
+
/*------------------------------------------------------------------------*/
/**
diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h
index adf956e9bc..5e4e46ca21 100644
--- a/engines/xeen/screen.h
+++ b/engines/xeen/screen.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
#include "common/system.h"
#include "common/array.h"
+#include "common/keyboard.h"
#include "common/rect.h"
#include "xeen/font.h"
#include "xeen/sprites.h"
@@ -66,6 +67,8 @@ private:
int _ycL, _ycH;
void open2();
+
+ Common::KeyCode doCursor(const Common::String &msg);
public:
bool _enabled;
public:
@@ -91,6 +94,8 @@ public:
void writeString(const Common::String &s);
void drawList(DrawStruct *items, int count);
+
+ int getString(Common::String &line, int maxLen, int maxWidth);
};
class Screen: public FontSurface {
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 4ccac8b1af..afc86ab433 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -21,8 +21,10 @@
*/
#include "xeen/scripts.h"
+#include "xeen/dialogs_string_input.h"
#include "xeen/dialogs_whowill.h"
#include "xeen/party.h"
+#include "xeen/resources.h"
#include "xeen/xeen.h"
namespace Xeen {
@@ -167,7 +169,7 @@ void Scripts::doOpcode(MazeEvent &event) {
&Scripts::cmdIf, &Scripts::cmdIf, &Scripts::cmdIf,
&Scripts::cmdMoveObj, &Scripts::cmdTakeOrGive, &Scripts::cmdNoAction,
&Scripts::cmdRemove, &Scripts::cmdSetChar, &Scripts::cmdSpawn,
- &Scripts::cmdDoTownEvent, &Scripts::cmdExit, &Scripts::cmdAfterMap,
+ &Scripts::cmdDoTownEvent, &Scripts::cmdExit, &Scripts::cmdAlterMap,
&Scripts::cmdGiveExtended, &Scripts::cmdConfirmWord, &Scripts::cmdDamage,
&Scripts::cmdJumpRnd, &Scripts::cmdAfterEvent, &Scripts::cmdCallEvent,
&Scripts::cmdReturn, &Scripts::cmdSetVar, &Scripts::cmdTakeOrGive,
@@ -180,7 +182,7 @@ void Scripts::doOpcode(MazeEvent &event) {
&Scripts::cmdItemType, &Scripts::cmdMakeNothingHere, &Scripts::cmdNoAction2,
&Scripts::cmdChooseNumeric, &Scripts::cmdDisplayBottomTwoLines,
&Scripts::cmdDisplayLarge, &Scripts::cmdExchObj, &Scripts::cmdFallToMap,
- &Scripts::cmdDisplayMain, &Scripts::cmdGoto, &Scripts::cmdConfirmWord2,
+ &Scripts::cmdDisplayMain, &Scripts::cmdGoto, &Scripts::cmdConfirmWord,
&Scripts::cmdGotoRandom, &Scripts::cmdCutsceneEndDarkside,
&Scripts::cmdCutsceneEdWorld, &Scripts::cmdFlipWorld, &Scripts::cmdPlayCD
};
@@ -287,7 +289,21 @@ void Scripts::cmdIf(Common::Array<byte> &params) {
}
}
-void Scripts::cmdMoveObj(Common::Array<byte> &params) { error("TODO"); }
+/**
+ * Moves the position of an object
+ */
+void Scripts::cmdMoveObj(Common::Array<byte> &params) {
+ MazeObject &mazeObj = _vm->_map->_mobData._objects[params[0]];
+
+ if (mazeObj._position.x == params[1] && mazeObj._position.y == params[2]) {
+ // Already in position, so simply flip it
+ mazeObj._flipped = !mazeObj._flipped;
+ } else {
+ mazeObj._position.x = params[1];
+ mazeObj._position.y = params[2];
+ }
+}
+
void Scripts::cmdTakeOrGive(Common::Array<byte> &params) { error("TODO"); }
/**
@@ -318,7 +334,23 @@ void Scripts::cmdSetChar(Common::Array<byte> &params) {
cmdNoAction(params);
}
-void Scripts::cmdSpawn(Common::Array<byte> &params) { error("TODO"); }
+/**
+ * Spawn a monster
+ */
+void Scripts::cmdSpawn(Common::Array<byte> &params) {
+ MazeMonster &monster = _vm->_map->_mobData._monsters[params[0]];
+ MonsterStruct &monsterData = _vm->_map->_monsterData[monster._spriteId];
+ monster._position.x = params[1];
+ monster._position.y = params[2];
+ monster._frame = _vm->getRandomNumber(7);
+ monster._field7 = 0;
+ monster._isAttacking = params[1] != 0;
+ monster._hp = monsterData._hp;
+
+ _var4F = 1;
+ cmdNoAction(params);
+}
+
void Scripts::cmdDoTownEvent(Common::Array<byte> &params) { error("TODO"); }
/**
@@ -328,9 +360,97 @@ void Scripts::cmdExit(Common::Array<byte> &params) {
_lineNum = -1;
}
-void Scripts::cmdAfterMap(Common::Array<byte> &params) { error("TODO"); }
-void Scripts::cmdGiveExtended(Common::Array<byte> &params) { error("TODO"); }
-void Scripts::cmdConfirmWord(Common::Array<byte> &params) { error("TODO"); }
+/**
+ * Changes the value for the wall on a given cell
+ */
+void Scripts::cmdAlterMap(Common::Array<byte> &params) {
+ Map &map = *_vm->_map;
+
+ if (params[2] == DIR_ALL) {
+ for (int dir = DIR_NORTH; dir <= DIR_WEST; ++dir)
+ map.setWall(Common::Point(params[0], params[1]), (Direction)dir, params[3]);
+ } else {
+ map.setWall(Common::Point(params[0], params[1]), (Direction)params[2], params[3]);
+ }
+
+ _var4F = true;
+ cmdNoAction(params);
+}
+
+void Scripts::cmdGiveExtended(Common::Array<byte> &params) {
+ switch (params[0]) {
+ case 16:
+ case 34:
+ case 100:
+ // TODO
+ break;
+ case 25:
+ case 35:
+ case 101:
+ case 106:
+ // TODO
+ break;
+ default:
+ break;
+ }
+}
+
+void Scripts::cmdConfirmWord(Common::Array<byte> &params) {
+ Map &map = *_vm->_map;
+ Common::String msg1 = params[2] ? map._events._text[params[2]] :
+ _vm->_interface->_interfaceText;
+ Common::String msg2;
+
+ if (_event->_opcode == OP_ConfirmWord_2) {
+ msg2 = map._events._text[params[3]];
+ } else if (params[3]) {
+ msg2 = "";
+ } else {
+ msg2 = WHATS_THE_PASSWORD;
+ }
+
+ int result = StringInput::show(_vm, params[0], msg1, msg2,_event->_opcode);
+ if (result) {
+ if (result == 33 && _vm->_files->_isDarkCc) {
+ doEndGame2();
+ } else if (result == 34 && _vm->_files->_isDarkCc) {
+ doWorldEnd();
+ } else if (result == 35 && _vm->_files->_isDarkCc &&
+ _vm->getGameID() == GType_WorldOfXeen) {
+ doEndGame();
+ } else if (result == 40 && !_vm->_files->_isDarkCc) {
+ doEndGame();
+ } else if (result == 60 && !_vm->_files->_isDarkCc) {
+ doEndGame2();
+ }
+ else if (result == 61 && !_vm->_files->_isDarkCc) {
+ doWorldEnd();
+ } else {
+ if (result == 59 && !_vm->_files->_isDarkCc) {
+ for (int idx = 0; idx < TOTAL_ITEMS; ++idx) {
+ XeenItem &item = _vm->_treasure._weapons[idx];
+ if (!item._name) {
+ item._name = 34;
+ item._material = 0;
+ item._bonusFlags = 0;
+ _vm->_treasure._hasItems = true;
+
+ cmdExit(params);
+ return;
+ }
+ }
+ }
+
+ _lineNum = result == -1 ? params[3] : params[1];
+
+ return;
+ }
+ }
+
+ _var4F = true;
+ cmdNoAction(params);
+}
+
void Scripts::cmdDamage(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdJumpRnd(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdAfterEvent(Common::Array<byte> &params) { error("TODO"); }
@@ -370,11 +490,45 @@ void Scripts::cmdExchObj(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdFallToMap(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdDisplayMain(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdGoto(Common::Array<byte> &params) { error("TODO"); }
-void Scripts::cmdConfirmWord2(Common::Array<byte> &params) { error("TODO"); }
+
void Scripts::cmdGotoRandom(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdCutsceneEndDarkside(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdCutsceneEdWorld(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdFlipWorld(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdPlayCD(Common::Array<byte> &params) { error("TODO"); }
+void Scripts::doEndGame() {
+ doEnding("ENDGAME", 0);
+}
+
+void Scripts::doEndGame2() {
+ Party &party = *_vm->_party;
+ int v2 = 0;
+
+ for (int idx = 0; idx < party._partyCount; ++idx) {
+ PlayerStruct &player = party._activeParty[idx];
+ if (player.hasAward(77)) {
+ v2 = 2;
+ break;
+ }
+ else if (player.hasAward(76)) {
+ v2 = 1;
+ break;
+ }
+ }
+
+ doEnding("ENDGAME2", v2);
+}
+
+void Scripts::doWorldEnd() {
+
+}
+
+void Scripts::doEnding(const Common::String &endStr, int v2) {
+ _vm->_saves->saveChars();
+
+ warning("TODO: doEnding");
+}
+
+
} // End of namespace Xeen
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 2e4996e6be..5f931c1fb5 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -134,8 +134,6 @@ private:
Common::String _paramText;
MazeEvent *_event;
- int whoWill(int v1, int v2, int v3);
-
void doOpcode(MazeEvent &event);
void cmdDisplay1(Common::Array<byte> &params);
void cmdDoorTextSml(Common::Array<byte> &params);
@@ -153,7 +151,7 @@ private:
void cmdSpawn(Common::Array<byte> &params);
void cmdDoTownEvent(Common::Array<byte> &params);
void cmdExit(Common::Array<byte> &params);
- void cmdAfterMap(Common::Array<byte> &params);
+ void cmdAlterMap(Common::Array<byte> &params);
void cmdGiveExtended(Common::Array<byte> &params);
void cmdConfirmWord(Common::Array<byte> &params);
void cmdDamage(Common::Array<byte> &params);
@@ -185,12 +183,21 @@ private:
void cmdFallToMap(Common::Array<byte> &params);
void cmdDisplayMain(Common::Array<byte> &params);
void cmdGoto(Common::Array<byte> &params);
- void cmdConfirmWord2(Common::Array<byte> &params);
void cmdGotoRandom(Common::Array<byte> &params);
void cmdCutsceneEndDarkside(Common::Array<byte> &params);
void cmdCutsceneEdWorld(Common::Array<byte> &params);
void cmdFlipWorld(Common::Array<byte> &params);
void cmdPlayCD(Common::Array<byte> &params);
+
+ int whoWill(int v1, int v2, int v3);
+
+ void doEndGame();
+
+ void doEndGame2();
+
+ void doWorldEnd();
+
+ void doEnding(const Common::String &endStr, int v2);
public:
int _animCounter;
bool _eventSkipped;
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index 2d824e53bc..99adbb3a41 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -54,6 +54,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_moveMonsters = false;
_mode = MODE_0;
_openDoor = 0;
+ _startupWindowActive = false;
}
XeenEngine::~XeenEngine() {
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index cf872b3ede..1065adf9db 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -72,6 +72,7 @@ enum XeenDebugChannels {
};
enum Mode {
+ MODE_FF = -1,
MODE_0 = 0,
MODE_1 = 1,
MODE_2 = 2,
@@ -139,6 +140,7 @@ public:
Screen *_screen;
Scripts *_scripts;
SoundManager *_sound;
+ Treasure _treasure;
Mode _mode;
GameEvent _gameEvent;
Common::SeekableReadStream *_eventData;
@@ -148,6 +150,7 @@ public:
bool _noDirectionSense;
bool _moveMonsters;
int _openDoor;
+ bool _startupWindowActive;
public:
XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc);
virtual ~XeenEngine();