diff options
| -rw-r--r-- | engines/kyra/items_lol.cpp | 27 | ||||
| -rw-r--r-- | engines/kyra/lol.cpp | 4 | ||||
| -rw-r--r-- | engines/kyra/lol.h | 34 | ||||
| -rw-r--r-- | engines/kyra/saveload_lol.cpp | 8 | ||||
| -rw-r--r-- | engines/kyra/screen.h | 1 | ||||
| -rw-r--r-- | engines/kyra/screen_hof.h | 1 | ||||
| -rw-r--r-- | engines/kyra/screen_lok.h | 1 | ||||
| -rw-r--r-- | engines/kyra/screen_lol.h | 3 | ||||
| -rw-r--r-- | engines/kyra/screen_mr.h | 1 | ||||
| -rw-r--r-- | engines/kyra/script_lol.cpp | 7 | ||||
| -rw-r--r-- | engines/kyra/sprites_lol.cpp | 6 | ||||
| -rw-r--r-- | engines/kyra/text_lol.cpp | 5 | ||||
| -rw-r--r-- | engines/kyra/text_lol.h | 2 | 
13 files changed, 52 insertions, 48 deletions
diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp index 5db4ff9f26..7ad9747bb6 100644 --- a/engines/kyra/items_lol.cpp +++ b/engines/kyra/items_lol.cpp @@ -110,10 +110,10 @@ void LoLEngine::takeCredits(int credits, int redraw) {  	}  } -int LoLEngine::makeItem(int itemType, int curFrame, int flags) { +Item LoLEngine::makeItem(int itemType, int curFrame, int flags) {  	int cnt = 0;  	int r = 0; -	int i = 1; +	Item i = 1;  	for (; i < 400; i++) {  		if (_itemsInPlay[i].shpCurFrame_flg & 0x8000) { @@ -130,7 +130,7 @@ int LoLEngine::makeItem(int itemType, int curFrame, int flags) {  			continue;  		bool t = false; -		int ii = i; +		Item ii = i;  		while (ii && !t) {  			t = testUnkItemFlags(ii);  			if (t) @@ -145,7 +145,7 @@ int LoLEngine::makeItem(int itemType, int curFrame, int flags) {  		}  	} -	int slot = i; +	Item slot = i;  	if (cnt) {  		slot = r;  		if (testUnkItemFlags(r)) { @@ -178,7 +178,7 @@ int LoLEngine::makeItem(int itemType, int curFrame, int flags) {  	return slot;  } -void LoLEngine::placeMoveLevelItem(int itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight) { +void LoLEngine::placeMoveLevelItem(Item itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight) {  	calcCoordinates(_itemsInPlay[itemIndex].x, _itemsInPlay[itemIndex].y, block, xOffs, yOffs);  	if (_itemsInPlay[itemIndex].block) @@ -194,7 +194,7 @@ void LoLEngine::placeMoveLevelItem(int itemIndex, int level, int block, int xOff  	}  } -bool LoLEngine::addItemToInventory(int itemIndex) { +bool LoLEngine::addItemToInventory(Item itemIndex) {  	int pos = 0;  	int i = 0; @@ -222,7 +222,7 @@ bool LoLEngine::addItemToInventory(int itemIndex) {  	return true;  } -bool LoLEngine::testUnkItemFlags(int itemIndex) { +bool LoLEngine::testUnkItemFlags(Item itemIndex) {  	if (!(_itemsInPlay[itemIndex].shpCurFrame_flg & 0x4000))  		return false; @@ -233,7 +233,7 @@ bool LoLEngine::testUnkItemFlags(int itemIndex) {  } -void LoLEngine::deleteItem(int itemIndex) { +void LoLEngine::deleteItem(Item itemIndex) {  	memset(&_itemsInPlay[itemIndex], 0, sizeof(ItemInPlay));  	_itemsInPlay[itemIndex].shpCurFrame_flg |= 0x8000;  } @@ -245,7 +245,7 @@ ItemInPlay *LoLEngine::findObject(uint16 index) {  		return &_itemsInPlay[index];  } -void LoLEngine::runItemScript(int charNum, int item, int flags, int next, int reg4) { +void LoLEngine::runItemScript(int charNum, Item item, int flags, int next, int reg4) {  	EMCState scriptState;  	memset(&scriptState, 0, sizeof(EMCState)); @@ -271,9 +271,6 @@ void LoLEngine::runItemScript(int charNum, int item, int flags, int next, int re  }  void LoLEngine::setHandItem(Item itemIndex) { -	if (itemIndex == -1) -		return; -  	if (itemIndex && _itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].flags & 0x80) {  		runItemScript(-1, itemIndex, 0x400, 0, 0);  		if (_itemsInPlay[itemIndex].shpCurFrame_flg & 0x8000) @@ -310,7 +307,7 @@ bool LoLEngine::itemEquipped(int charNum, uint16 itemType) {  	return false;  } -void LoLEngine::setItemPosition(int item, uint16 x, uint16 y, int flyingHeight, int b) { +void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b) {  	if (!flyingHeight) {  		x = (x & 0xffc0) | 0x40;  		y = (y & 0xffc0) | 0x40; @@ -337,7 +334,7 @@ void LoLEngine::setItemPosition(int item, uint16 x, uint16 y, int flyingHeight,  	checkSceneUpdateNeed(block);  } -void LoLEngine::removeLevelItem(int item, int block) { +void LoLEngine::removeLevelItem(Item item, int block) {  	removeAssignedObjectFromBlock(&_levelBlockProperties[block], item);  	removeDrawObjectFromBlock(&_levelBlockProperties[block], item);  	runLevelScriptCustom(block, 0x100, -1, item, 0, 0); @@ -345,7 +342,7 @@ void LoLEngine::removeLevelItem(int item, int block) {  	_itemsInPlay[item].level = 0;  } -bool LoLEngine::launchObject(int objectType, int item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c) { +bool LoLEngine::launchObject(int objectType, Item item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c) {  	int sp = checkDrawObjectSpace(_partyPosX, _partyPosY, startX, startY);  	FlyingObject *t = _flyingObjects;  	int slot = -1; diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 03d52ec4ac..f6ac8a1a73 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -1930,11 +1930,11 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait  	return 1;  } -void LoLEngine::giveItemToMonster(MonsterInPlay *monster, uint16 item) { +void LoLEngine::giveItemToMonster(MonsterInPlay *monster, Item item) {  	uint16 *c = &monster->assignedItems;  	while (*c)  		c = &_itemsInPlay[*c].nextAssignedObject; -	*c = item; +	*c = (uint16)item;  	_itemsInPlay[item].nextAssignedObject = 0;  } diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 3d8c6b610e..d0f1fcda0d 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -225,7 +225,7 @@ struct FlyingObject {  	uint8 enable;  	uint8 objectType;  	uint16 attackerId; -	uint16 item; +	Item item;  	uint16 x;  	uint16 y;  	uint8 flyingHeight; @@ -1202,19 +1202,19 @@ private:  	// items  	void giveCredits(int credits, int redraw);  	void takeCredits(int credits, int redraw); -	int makeItem(int itemType, int curFrame, int flags); -	void placeMoveLevelItem(int itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight); -	bool addItemToInventory(int itemIndex); -	bool testUnkItemFlags(int itemIndex); -	void deleteItem(int itemIndex); +	Item makeItem(int itemType, int curFrame, int flags); +	void placeMoveLevelItem(Item itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight); +	bool addItemToInventory(Item itemIndex); +	bool testUnkItemFlags(Item itemIndex); +	void deleteItem(Item itemIndex);  	ItemInPlay *findObject(uint16 index); -	void runItemScript(int charNum, int item, int flags, int next, int reg4); +	void runItemScript(int charNum, Item item, int flags, int next, int reg4);  	void setHandItem(Item itemIndex);  	bool itemEquipped(int charNum, uint16 itemType); -	void setItemPosition(int item, uint16 x, uint16 y, int flyingHeight, int b); -	void removeLevelItem(int item, int block); -	bool launchObject(int objectType, int item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c); +	void setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b); +	void removeLevelItem(Item item, int block); +	bool launchObject(int objectType, Item item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c);  	void endObjectFlight(FlyingObject *t, int x, int y, int objectOnNextBlock);  	void processObjectFlight(FlyingObject *t, int x, int y);  	void updateObjectFlightPosition(FlyingObject *t); @@ -1231,9 +1231,9 @@ private:  	ItemInPlay *_itemsInPlay;  	ItemProperty *_itemProperties; -	int _itemInHand; -	uint16 _inventory[48]; -	int _inventoryCurItem; +	Item _itemInHand; +	Item _inventory[48]; +	Item _inventoryCurItem;  	int _currentControlMode;  	int _specialSceneFlag;  	int _lastCharInventory; @@ -1269,10 +1269,10 @@ private:  	int calcMonsterDirection(uint16 x1, uint16 y1, uint16 x2, uint16 y2);  	void setMonsterDirection(MonsterInPlay *monster, int dir);  	void monsterDropItems(MonsterInPlay *monster); -	void removeAssignedObjectFromBlock(LevelBlockProperty *l, int id); -	void removeDrawObjectFromBlock(LevelBlockProperty *l, int id); -	void assignMonsterToBlock(uint16 *assignedBlockObjects, int id); -	void giveItemToMonster(MonsterInPlay *monster, uint16 item); +	void removeAssignedObjectFromBlock(LevelBlockProperty *l, uint16 id); +	void removeDrawObjectFromBlock(LevelBlockProperty *l, uint16 id); +	void assignMonsterToBlock(uint16 *assignedBlockObjects, uint16 id); +	void giveItemToMonster(MonsterInPlay *monster, Item item);  	int checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 objectWidth, uint16 testFlag, uint16 wallFlag);  	int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag);  	int calcMonsterSkillLevel(int id, int a); diff --git a/engines/kyra/saveload_lol.cpp b/engines/kyra/saveload_lol.cpp index 480714e5c9..534e14fe26 100644 --- a/engines/kyra/saveload_lol.cpp +++ b/engines/kyra/saveload_lol.cpp @@ -117,7 +117,7 @@ Common::Error LoLEngine::loadGameState(int slot) {  	_selectedCharacter = in.readSByte();  	_currentLevel = in.readByte();  	for (int i = 0; i < 48; i++) -		_inventory[i] = in.readUint16BE(); +		_inventory[i] = in.readSint16BE();  	_inventoryCurItem = in.readSint16BE();  	_itemInHand = in.readSint16BE();  	_lastMouseRegion = in.readSint16BE(); @@ -243,7 +243,7 @@ Common::Error LoLEngine::loadGameState(int slot) {  			m->enable = in.readByte();  			m->objectType = in.readByte();  			m->attackerId = in.readUint16BE(); -			m->item = in.readUint16BE(); +			m->item = in.readSint16BE();  			m->x = in.readUint16BE();  			m->y = in.readUint16BE();  			m->flyingHeight = in.readByte(); @@ -340,7 +340,7 @@ Common::Error LoLEngine::saveGameState(int slot, const char *saveName, const Gra  	out->writeSByte(_selectedCharacter);  	out->writeByte(_currentLevel);  	for (int i = 0; i < 48; i++) -		out->writeUint16BE(_inventory[i]); +		out->writeSint16BE(_inventory[i]);  	out->writeSint16BE(_inventoryCurItem);  	out->writeSint16BE(_itemInHand);  	out->writeSint16BE(_lastMouseRegion); @@ -423,7 +423,7 @@ Common::Error LoLEngine::saveGameState(int slot, const char *saveName, const Gra  			out->writeByte(m->enable);  			out->writeByte(m->objectType);  			out->writeUint16BE(m->attackerId); -			out->writeUint16BE(m->item); +			out->writeSint16BE(m->item);  			out->writeUint16BE(m->x);  			out->writeUint16BE(m->y);  			out->writeByte(m->flyingHeight); diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 654b7da6b7..e35b9b37b2 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -423,6 +423,7 @@ public:  	virtual void setScreenDim(int dim) = 0;  	virtual const ScreenDim *getScreenDim(int dim) = 0; +	virtual int screenDimTableCount() const = 0;  	const ScreenDim *_curDim; diff --git a/engines/kyra/screen_hof.h b/engines/kyra/screen_hof.h index 1c17a424b3..5117716ac0 100644 --- a/engines/kyra/screen_hof.h +++ b/engines/kyra/screen_hof.h @@ -39,6 +39,7 @@ public:  	void setScreenDim(int dim);  	const ScreenDim *getScreenDim(int dim); +	int screenDimTableCount() const { return _screenDimTableCount; }  	// sequence player  	void generateGrayOverlay(const Palette &pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag); diff --git a/engines/kyra/screen_lok.h b/engines/kyra/screen_lok.h index 2a5ef7e12e..0d30c35bfd 100644 --- a/engines/kyra/screen_lok.h +++ b/engines/kyra/screen_lok.h @@ -43,6 +43,7 @@ public:  	void setScreenDim(int dim);  	const ScreenDim *getScreenDim(int dim); +	int screenDimTableCount() const { return _screenDimTableCount; }  	void setTextColorMap(const uint8 *cmap); diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h index 52e66df1ec..9f4d751d0c 100644 --- a/engines/kyra/screen_lol.h +++ b/engines/kyra/screen_lol.h @@ -43,8 +43,9 @@ public:  	void setScreenDim(int dim);  	const ScreenDim *getScreenDim(int dim); -	int curDimIndex() { return _curDimIndex; } +	int curDimIndex() const { return _curDimIndex; }  	void modifyScreenDim(int dim, int x, int y, int w, int h); +	int screenDimTableCount() const { return _screenDimTableCount; }  	void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) GCC_PRINTF(2, 8);  	void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) GCC_PRINTF(2, 9); diff --git a/engines/kyra/screen_mr.h b/engines/kyra/screen_mr.h index 4107003b12..c02fc4bfb2 100644 --- a/engines/kyra/screen_mr.h +++ b/engines/kyra/screen_mr.h @@ -39,6 +39,7 @@ public:  	void setScreenDim(int dim);  	const ScreenDim *getScreenDim(int dim); +	int screenDimTableCount() const { return _screenDimTableCount; }  	int getLayer(int x, int y); diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index 104a135ff6..864b6c39c7 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -700,7 +700,7 @@ int LoLEngine::olol_setGlobalVar(EMCState *script) {  		break;  	case 3: -		setHandItem((Item)b); +		setHandItem(b);  		break;  	case 4: @@ -1066,8 +1066,7 @@ int LoLEngine::olol_createHandItem(EMCState *script) {  	if (_itemInHand)  		return 0; -	uint16 itm = makeItem(stackPos(0), stackPos(1), stackPos(2)); -	setHandItem((Item)itm); +	setHandItem(makeItem(stackPos(0), stackPos(1), stackPos(2)));  	return 1;  } @@ -2087,7 +2086,7 @@ int LoLEngine::olol_placeInventoryItemInHand(EMCState *script) {  	_inventoryCurItem = i;  	int r = _itemInHand; -	setHandItem((Item)_inventory[i]); +	setHandItem(_inventory[i]);  	_inventory[i] = r;  	if (stackPos(1)) diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp index 3b63618d6d..d199276235 100644 --- a/engines/kyra/sprites_lol.cpp +++ b/engines/kyra/sprites_lol.cpp @@ -350,7 +350,7 @@ void LoLEngine::monsterDropItems(MonsterInPlay *monster) {  	}  } -void LoLEngine::removeAssignedObjectFromBlock(LevelBlockProperty *l, int id) { +void LoLEngine::removeAssignedObjectFromBlock(LevelBlockProperty *l, uint16 id) {  	uint16 *blockItemIndex = &l->assignedObjects;  	ItemInPlay *i = 0; @@ -367,7 +367,7 @@ void LoLEngine::removeAssignedObjectFromBlock(LevelBlockProperty *l, int id) {  	}  } -void LoLEngine::removeDrawObjectFromBlock(LevelBlockProperty *l, int id) { +void LoLEngine::removeDrawObjectFromBlock(LevelBlockProperty *l, uint16 id) {  	uint16 *blockItemIndex = &l->drawObjects;  	ItemInPlay *i = 0; @@ -384,7 +384,7 @@ void LoLEngine::removeDrawObjectFromBlock(LevelBlockProperty *l, int id) {  	}  } -void LoLEngine::assignMonsterToBlock(uint16 *assignedBlockObjects, int id) { +void LoLEngine::assignMonsterToBlock(uint16 *assignedBlockObjects, uint16 id) {  	ItemInPlay *t = findObject(id);  	t->nextAssignedObject = *assignedBlockObjects;  	*assignedBlockObjects = id; diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp index 7f9531507c..c5341cd8a6 100644 --- a/engines/kyra/text_lol.cpp +++ b/engines/kyra/text_lol.cpp @@ -46,7 +46,9 @@ TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *vm, Screen_LoL *screen) : _vm(vm  	_currentLine = new char[85];  	memset(_currentLine, 0, 85); -	for (int i = 0; i < 14; i++){ +	_textDimData = new TextDimData[_screen->screenDimTableCount()]; + +	for (int i = 0; i < _screen->screenDimTableCount(); i++){  		const ScreenDim *d = _screen->getScreenDim(i);  		_textDimData[i].color1 = d->unk8;  		_textDimData[i].color2 = d->unkA; @@ -59,6 +61,7 @@ TextDisplayer_LoL::~TextDisplayer_LoL() {  	delete[] _buffer;  	delete[] _dialogueBuffer;  	delete[] _currentLine; +	delete[] _textDimData;  }  void TextDisplayer_LoL::setupField(bool mode) { diff --git a/engines/kyra/text_lol.h b/engines/kyra/text_lol.h index 488be17cff..1e5bc8884e 100644 --- a/engines/kyra/text_lol.h +++ b/engines/kyra/text_lol.h @@ -90,7 +90,7 @@ private:  		uint8 line;  	}; -	TextDimData _textDimData[14]; +	TextDimData *_textDimData;  };  } // End of namespace Kyra  | 
