diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 8 | ||||
-rw-r--r-- | engines/access/access.h | 7 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 1 | ||||
-rw-r--r-- | engines/access/amazon/amazon_resources.cpp | 21 | ||||
-rw-r--r-- | engines/access/amazon/amazon_resources.h | 2 | ||||
-rw-r--r-- | engines/access/inventory.cpp | 61 | ||||
-rw-r--r-- | engines/access/inventory.h | 56 | ||||
-rw-r--r-- | engines/access/module.mk | 1 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 26 | ||||
-rw-r--r-- | engines/access/scripts.h | 4 |
10 files changed, 172 insertions, 15 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c98588f5ce..ee524d7afe 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -35,6 +35,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; + _inventory = nullptr; _player = nullptr; _room = nullptr; _screen = nullptr; @@ -56,10 +57,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _music = nullptr; _title = nullptr; _converseMode = 0; - _startInvItem = 0; - _startAboutItem = 0; - _startTravelItem = 0; - _startInvBox = 0; _startAboutBox = 0; _startTravelBox = 0; _numImages = 0; @@ -104,7 +101,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _antFlag = false; _allenFlag = false; _noSound = false; - Common::fill(&inv[0], &inv[85], 0); Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); Common::fill(&_help1[0], &_help3[366], 0); @@ -126,6 +122,7 @@ AccessEngine::~AccessEngine() { delete _debugger; delete _events; delete _files; + delete _inventory; delete _player; delete _room; delete _screen; @@ -170,6 +167,7 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); + _inventory = new InventoryManager(this); _player = new Player(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); diff --git a/engines/access/access.h b/engines/access/access.h index 56600e4fb8..0fa2c149cd 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -35,6 +35,7 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" +#include "access/inventory.h" #include "access/player.h" #include "access/room.h" #include "access/screen.h" @@ -105,6 +106,7 @@ public: Debugger *_debugger; EventsManager *_events; FileManager *_files; + InventoryManager *_inventory; Player *_player; Room *_room; Screen *_screen; @@ -139,10 +141,8 @@ public: byte *_music; byte *_title; int _converseMode; - int _startInvItem; int _startAboutItem; int _startTravelItem; - int _startInvBox; int _startAboutBox; int _startTravelBox; bool _currentCharFlag; @@ -164,7 +164,7 @@ public: int _intTim[3]; int _timer[3]; bool _timerFlag; - byte _flags[99]; + Common::Array<int> _flags; byte _useItem[23]; int _guardLoc; int _guardFind; @@ -181,7 +181,6 @@ public: bool _antFlag; bool _allenFlag; bool _noSound; - int inv[85]; byte _help1[366]; byte _help2[366]; byte _help3[366]; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 7a16036ff3..8267c8549a 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -47,6 +47,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rawInactiveY = 0; _inactiveYOff = 0; Common::fill(&_esTabTable[0], &_esTabTable[100], 0); + _flags.resize(122); } AmazonEngine::~AmazonEngine() { diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 2f9fe0277a..87f2966d8e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -986,6 +986,27 @@ extern const byte *CHARTBL[] = { CRACK, LETTER }; +const char *const INVENTORY_NAMES[] = { + "RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM", + "VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY", + "DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY", + "DISPLAY CASE KEY", "FLITCH', 27h, 'S CAR KEYS", "COAT HANGER", + "CROWBAR", "COMPASS", "MAP", "LETTER OPENER", "LETTER", + "DECODER", "DIPPED DART", "LOADED BLOWGUN", "CARD", "JERRYCAN", + "CIGARETTES", "BIKE PUMP", "PARACHUTE", "PESO", "PEPPERS", + "MACHETE", "POISON ROOT", "AMMUNITION", "PADDLE", "FISHING NET", + "RAT TRAP", "CHEESE", "LOADED TRAP", "KNIFE", "CHOPPED PEPPERS", + "LIGHTER", "LADDER", "SMALL POLE", "JEEP KEY", "CHAIN", "ARROW", + "FILLED JERRY CAN", "EXPLOSIVES", "GEIGER COUNTER", "VINE", + "GOLD NUGGET", "HOLLOW REED", "AMAZON QUEEN KEYS", "FISHING POLE", + "HARPOON", "RAG", "BOTTLE OF RUM", "RAG IN BOTTLE", "MOLOTOV COCKTAIL", + "JUNGLE PLANT", "LADLE", "WORM", "FISH", "FIREWORKS", "BAITED POLE", + "FILLED LADLE", "EMERALD", "SMALL KEY", "SCROLL", "LIT EXPLOSIVES", + "LIGHTER", "BROKEN SPEAR", "SHOE LACES", "TORCH", "LACES AND SPEAR", + "KNIFE SPEAR", "GARBAGE CAN", "RAFT", "INFLATED RAFT", + "JASON'S CAR KEYS", "PESO BILLS", "PLANK" +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 7601138835..c9e3fe98e6 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -39,6 +39,8 @@ extern const byte *ROOM_TABLE[]; extern const byte *CHARTBL[]; +extern const char *const INVENTORY_NAMES[]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp new file mode 100644 index 0000000000..b36c5346a5 --- /dev/null +++ b/engines/access/inventory.cpp @@ -0,0 +1,61 @@ +/* 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 "access/inventory.h" +#include "access/access.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { + _startInvItem = 0; + _startInvBox = 0; + _invChangeFlag = true; + _startAboutItem = 0; + _startTravelItem = 0; + + const char *const *names = Amazon::INVENTORY_NAMES; + switch (vm->getGameID()) { + case GType_Amazon: + _inv.resize(85); + break; + default: + error("Unknown game"); + } + + for (uint i = 0; i < _inv.size(); ++i) + _names.push_back(names[i]); +} + +int &InventoryManager::operator[](int idx) { + return _inv[idx]; +} + +int InventoryManager::useItem() { + return _vm->_flags[USE_ITEM_FLAG_INDEX]; +} + +void InventoryManager::setUseItem(int itemId) { + _vm->_flags[USE_ITEM_FLAG_INDEX] = itemId; +} + +} // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h new file mode 100644 index 0000000000..2f1248e8b2 --- /dev/null +++ b/engines/access/inventory.h @@ -0,0 +1,56 @@ +/* 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 ACCESS_INVENTORY_H +#define ACCESS_INVENTORY_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "common/str-array.h" +#include "access/data.h" + +namespace Access { + +#define USE_ITEM_FLAG_INDEX 100 + +class InventoryManager : public Manager { +public: + Common::Array<int> _inv; + Common::StringArray _names; + int _startInvItem; + int _startInvBox; + bool _invChangeFlag; + int _startAboutItem; + int _startTravelItem; +public: + InventoryManager(AccessEngine *vm); + + int &operator[](int idx); + + int useItem(); + void setUseItem(int itemId); +}; + +} // End of namespace Access + +#endif /* ACCESS_INVENTORY_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 24c237a18f..7c089fefb3 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -10,6 +10,7 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ + inventory.o \ player.o \ resources.o \ room.o \ diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bc86e09fcb..66b16e9826 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, - &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, + &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, @@ -175,7 +175,7 @@ void Scripts::CMDANIM() { } void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); byte flagVal = _data->readByte(); - assert(flagNum < 100); + _vm->_flags[flagNum] = flagVal; } @@ -195,8 +195,26 @@ void Scripts::cmdGoto() { searchForSequence(); } -void Scripts::CMDSETINV() { } -void Scripts::CMDCHECKINV() { } +void Scripts::cmdSetInventory() { + int itemId = _data->readByte(); + int itemVal = _data->readByte(); + + (*_vm->_inventory)[itemId] = itemVal; + _vm->_inventory->_startInvItem = 0; + _vm->_inventory->_startInvBox = 0; + _vm->_inventory->_invChangeFlag = true; +} + +void Scripts::cmdCheckInventory() { + int itemId = _data->readUint16LE(); + int itemVal = _data->readUint16LE(); + + if ((*_vm->_inventory)[itemId] == itemVal) + cmdGoto(); + else + _data->skip(2); +} + void Scripts::CMDSETTEX() { } void Scripts::CMDNEWROOM() { } void Scripts::CMDCONVERSE() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 4375934b7c..6bf69c4ee3 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -61,8 +61,8 @@ protected: */ void cmdGoto(); - void CMDSETINV(); - void CMDCHECKINV(); + void cmdSetInventory(); + void cmdCheckInventory(); void CMDSETTEX(); void CMDNEWROOM(); void CMDCONVERSE(); |