diff options
-rw-r--r-- | engines/draci/game.cpp | 8 | ||||
-rw-r--r-- | engines/draci/game.h | 6 | ||||
-rw-r--r-- | engines/draci/script.cpp | 50 | ||||
-rw-r--r-- | engines/draci/script.h | 6 |
4 files changed, 61 insertions, 9 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 4d6c77a169..e7f1b2d454 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -144,7 +144,7 @@ void Game::init() { changeRoom(0); } -void Game::loadRoom(uint roomNum) { +void Game::loadRoom(int roomNum) { BAFile *f; f = _vm->_roomsArchive->getFile(roomNum * 4); @@ -208,7 +208,7 @@ int Game::loadAnimation(uint animNum, uint z) { BAFile *animFile = _vm->_animationsArchive->getFile(animNum); Common::MemoryReadStream animationReader(animFile->_data, animFile->_length); - int numFrames = animationReader.readByte(); + uint numFrames = animationReader.readByte(); // FIXME: handle these properly animationReader.readByte(); // Memory logic field, not used @@ -356,6 +356,10 @@ void Game::setVariable(int numVar, int value) { _variables[numVar] = value; } +int Game::getIconStatus(int iconID) { + return _iconStatus[iconID]; +} + Game::~Game() { delete[] _persons; delete[] _variables; diff --git a/engines/draci/game.h b/engines/draci/game.h index da12771fc7..c9f913dbc8 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -58,7 +58,7 @@ struct GameObject { Common::Array<int> _anims; GPL2Program _program; byte *_title; - byte _location; + int _location; bool _visible; }; @@ -132,7 +132,7 @@ public: _currentRoom._roomNum = n; } - void loadRoom(uint roomNum); + void loadRoom(int roomNum); int loadAnimation(uint animNum, uint z); void loadOverlays(); void loadObject(uint numObj); @@ -142,6 +142,8 @@ public: int getVariable(int varNum); void setVariable(int varNum, int value); + int getIconStatus(int iconID); + private: DraciEngine *_vm; int *_variables; diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index e9d35226ba..e2c902cf6f 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -118,13 +118,13 @@ void Script::setupCommandList() { static const GPL2Function gplFunctions[] = { { "Not", &Script::funcNot }, { "Random", &Script::funcRandom }, - { "IsIcoOn", NULL }, + { "IsIcoOn", &Script::funcIsIcoOn }, { "IsIcoAct", NULL }, - { "IcoStat", NULL }, + { "IcoStat", &Script::funcIcoStat }, { "ActIco", NULL }, - { "IsObjOn", NULL }, - { "IsObjOff", NULL }, - { "IsObjAway", NULL }, + { "IsObjOn", &Script::funcIsObjOn }, + { "IsObjOff", &Script::funcIsObjOff }, + { "IsObjAway", &Script::funcIsObjAway }, { "ObjStat", NULL }, { "LastBlock", NULL }, { "AtBegin", NULL }, @@ -222,6 +222,46 @@ int Script::funcNot(int n) { return !n; } +int Script::funcIsIcoOn(int iconID) { + iconID -= 1; + + return _vm->_game->getIconStatus(iconID) == 1; +} + +int Script::funcIcoStat(int iconID) { + iconID -= 1; + + int status = _vm->_game->getIconStatus(iconID); + return (status == 1) ? 1 : 2; +} + +int Script::funcIsObjOn(int objID) { + objID -= 1; + + GameObject *obj = _vm->_game->getObject(objID); + + return obj->_visible; +} + +int Script::funcIsObjOff(int objID) { + objID -= 1; + + GameObject *obj = _vm->_game->getObject(objID); + + // We index locations from 0 (as opposed to the original player where it was from 1) + // That's why the "invalid" location 0 from the data files is converted to -1 + return !obj->_visible && obj->_location != -1; +} + +int Script::funcIsObjAway(int objID) { + objID -= 1; + + GameObject *obj = _vm->_game->getObject(objID); + + // see Script::funcIsObjOff + return !obj->_visible && obj->_location == -1; +} + /* GPL commands */ void Script::load(Common::Queue<int> ¶ms) { diff --git a/engines/draci/script.h b/engines/draci/script.h index 7007e563c4..d8e9a2f49f 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -122,6 +122,12 @@ private: int funcRandom(int n); int funcNot(int n); + int funcIsIcoOn(int iconID); + int funcIcoStat(int iconID); + int funcIsObjOn(int objID); + int funcIsObjOff(int objID); + int funcIsObjAway(int objID); + void setupCommandList(); const GPL2Command *findCommand(byte num, byte subnum); |