diff options
| -rw-r--r-- | engines/xeen/interface.cpp | 6 | ||||
| -rw-r--r-- | engines/xeen/interface.h | 2 | ||||
| -rw-r--r-- | engines/xeen/map.cpp | 130 | ||||
| -rw-r--r-- | engines/xeen/map.h | 4 | ||||
| -rw-r--r-- | engines/xeen/resources.cpp | 40 | ||||
| -rw-r--r-- | engines/xeen/resources.h | 2 | 
6 files changed, 177 insertions, 7 deletions
| diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 0ae64ca9c0..4fb943fde5 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -885,7 +885,7 @@ void Interface::draw3d(bool flag) {  			mazeObject._frame = animEntry._frame1._frames[directionIndex];  		} else {  			++mazeObject._frame; -			if (i == objNum && _animCounter > 0 && ( +			if ((int)i == objNum && _animCounter > 0 && (  					objObject._spriteId == (_vm->_files->_isDarkCc ? 15 : 16) ||  					objObject._spriteId == 58 || objObject._spriteId == 73)) {  				if (mazeObject._frame > 4 || mazeObject._spriteId == 58) @@ -1199,8 +1199,4 @@ void Interface::setMazeBits() {  } -void Interface::getCell() { -} - -  } // End of namespace Xeen diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 1c110352bb..d50cdd029b 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -145,8 +145,6 @@ private:  	void setMainButtons();  	void setMazeBits(); - -	void getCell();  public:  	Interface(XeenEngine *vm); diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index b8ea36b698..b6bf91db57 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -854,6 +854,8 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) {  	_mazeDataIndex = 0;  	_currentSteppedOn = false;  	_currentSurfaceId = 0; +	_currentWall = 0; +	_currentTile = 0;  	_currentIsGrate = false;  	_currentCantRest = false;  	_currentIsDrain = false; @@ -1217,4 +1219,132 @@ void Map::setCellSurfaceFlags(const Common::Point &pt, int bits) {  	_mazeData[0]._cells[pt.y][pt.x]._surfaceId |= bits;  } + +int Map::getCell(int idx) { +	int mapId = _vm->_party._mazeId; +	Direction dir = _vm->_party._mazeDirection; +	Common::Point pt( +		_vm->_party._mazePosition.x + SCREEN_POSITIONING_X[_vm->_party._mazeDirection][idx], +		_vm->_party._mazePosition.y + SCREEN_POSITIONING_Y[_vm->_party._mazeDirection][idx] +	); + +	if (pt.x > 31 || pt.y > 31) { +		if (_vm->_files->_isDarkCc) { +			if ((mapId >= 53 && mapId <= 88 && mapId != 73) || (mapId >= 74 && mapId <= 120) || +					mapId == 125 || mapId == 126 || mapId == 128 || mapId == 129) { +				_currentSurfaceId = SURFTYPE_DESERT; +			} else { +				_currentSurfaceId = 0; +			} +		} else { +			_currentSurfaceId = (mapId >= 25 && mapId <= 27) ? 7 : 0; +		} +		_currentWall = 0x8888; +		return _currentWall; +	}  + +	_mazeDataIndex = 0; +	while (_mazeData[_mazeDataIndex]._mazeId != mapId) +		++_mazeDataIndex; + +	if (pt.y & 16) { +		if (pt.y >= 0) { +			pt.y -= 16; +			mapId = _mazeData[_mazeDataIndex]._surroundingMazes._north; +		} else { +			pt.y += 16; +			mapId = _mazeData[_mazeDataIndex]._surroundingMazes._south; +		} + +		if (!mapId) { +			if (_isOutdoors) { +				_currentSurfaceId = SURFTYPE_SPACE; +				_currentWall = 0; +				return 0; +			} else { +				if (_vm->_files->_isDarkCc) { +					if ((mapId >= 53 && mapId <= 88 && mapId != 73) || (mapId >= 74 && mapId <= 120) || +						mapId == 125 || mapId == 126 || mapId == 128 || mapId == 129) { +						_currentSurfaceId = SURFTYPE_DESERT; +					} else { +						_currentSurfaceId = 0; +					} +				} else { +					_currentSurfaceId = (mapId >= 25 && mapId <= 27) ? SURFTYPE_ROAD : SURFTYPE_DEFAULT; +				} + +				_currentWall = 0x8888; +				return _currentWall; +			} +		 +			_mazeDataIndex = 0; +			while (_mazeData[_mazeDataIndex]._mazeId != mapId) +				++_mazeDataIndex; +		} +	} + +	if (pt.x & 16) { +		if (pt.x >= 0) { +			pt.x -= 16; +			mapId = _mazeData[_mazeDataIndex]._surroundingMazes._east; +		} else { +			pt.x += 16; +			mapId = _mazeData[_mazeDataIndex]._surroundingMazes._east; +		} + +		if (!mapId) { +			if (_isOutdoors) { +				_currentSurfaceId = SURFTYPE_SPACE; +				_currentWall = 0; +				return _currentWall; +			} else { +				if (_vm->_files->_isDarkCc) { +					if ((mapId >= 53 && mapId <= 88 && mapId != 73) || (mapId >= 74 && mapId <= 120) || +						mapId == 125 || mapId == 126 || mapId == 128 || mapId == 129) { +						_currentSurfaceId = SURFTYPE_DESERT; +					} else { +						_currentSurfaceId = 0; +					} +				} else { +					_currentSurfaceId = (mapId >= 25 && mapId <= 27) ? SURFTYPE_ROAD : SURFTYPE_DEFAULT; +				} + +				_currentWall = 0x8888; +				return _currentWall; +			} + +			_mazeDataIndex = 0; +			while (_mazeData[_mazeDataIndex]._mazeId != mapId) +				++_mazeDataIndex; +		} +	} + +	MazeWallLayers &wallLayers = _mazeData[_mazeDataIndex]._wallData[pt.y][pt.x]; +	if (_isOutdoors) { +		if (mapId) { +			// TODO: tile is set to word of (wallLayers >> 8) && 0xff? Makes no sense +			_currentTile = wallLayers._outdoors._surfaceId; +			_currentWall = wallLayers._outdoors._iMiddle; +			_currentSurfaceId = wallLayers._outdoors._surfaceId; +		} else { +			_currentSurfaceId = SURFTYPE_DEFAULT; +			_currentWall = 0; +			_currentTile = 0; +		} +	} else { +		if (!mapId) +			return 0; + +		if (pt.x > 31 || pt.y > 31) +			_currentSurfaceId = SURFTYPE_ROAD; +		else +			_currentSurfaceId = _mazeData[_mazeDataIndex]._cells[pt.y][pt.x]._surfaceId; + +		_currentWall = wallLayers._data; +		return (_currentWall >> (WALL_NUMBERS[dir][idx * 2] * 4)) & 0xF; +	} + +	return _currentWall; +} +  } // End of namespace Xeen diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 7255552d5d..17c3fc684f 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -351,6 +351,8 @@ private:  	int _mazeDataIndex;  	bool _currentSteppedOn;  	int _currentSurfaceId; +	int _currentWall; +	int _currentTile;  	void loadEvents(int mapId); @@ -377,6 +379,8 @@ public:  	void setCellSurfaceFlags(const Common::Point &pt, int bits);  	void saveMaze(); + +	int getCell(int idx);  };  } // End of namespace Xeen diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 0737e1462d..352e59620c 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -375,4 +375,44 @@ 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][96] = { +	{ +	3, 0, 0, 0, 3, 0, 2, 0, 3, 0, 3, 0, +	0, 0, 3, 0, 2, 0, 3, 0, 3, 0, 0, 0, +	3, 0, 0, 0, 3, 0, 2, 0, 3, 0, 2, 0, +	3, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, +	0, 0, 3, 0, 0, 0, 3, 0, 2, 0, 3, 0, +	2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, +	0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, +	2, 0, 2, 0, 0, 0, 0, 0, 1, 0, 1, 0 +	}, { +	2, 0, 3, 0, 2, 0, 1, 0, 2, 0, 2, 0, +	3, 0, 2, 0, 1, 0, 2, 0, 2, 0, 3, 0, +	2, 0, 3, 0, 2, 0, 1, 0, 2, 0, 1, 0, +	2, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, +	3, 0, 2, 0, 3, 0, 2, 0, 1, 0, 2, 0, +	1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, +	3, 0, 3, 0, 3, 0, 3, 0, 1, 0, 1, 0, +	1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 +	}, { +	1, 0, 2, 0, 1, 0, 0, 0, 1, 0, 1, 0, +	2, 0, 1, 0, 0, 0, 1, 0, 1, 0, 2, 0, +	1, 0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, +	1, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, +	2, 0, 1, 0, 2, 0, 1, 0, 0, 0, 1, 0, +	0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, +	2, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0, 0, +	0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0 +	}, { +	0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, +	1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 0, +	0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 3, 0, +	0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, +	1, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, +	3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, +	1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 3, 0, +	3, 0, 3, 0, 0, 0, 0, 0, 2, 0, 2, 0 +	} +}; +  } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 36c2cb0e12..2c537fd890 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -82,6 +82,8 @@ extern const int OUTDOOR_OBJECT_Y[2][12];  extern const int DIRECTION_ANIM_POSITIONS[4][4]; +extern const byte WALL_NUMBERS[4][96]; +  } // End of namespace Xeen  #endif	/* XEEN_RESOURCES_H */ | 
