diff options
| author | Strangerke | 2013-10-15 01:07:26 +0200 | 
|---|---|---|
| committer | Strangerke | 2013-10-15 01:07:26 +0200 | 
| commit | 6437179de324d60343e7a4db8696dfdc513a4956 (patch) | |
| tree | 6e27c524e01c3c4dced2af2280d5080d526b8f08 | |
| parent | 597690ae9d401844a6e842654e368710d60b2fc8 (diff) | |
| download | scummvm-rg350-6437179de324d60343e7a4db8696dfdc513a4956.tar.gz scummvm-rg350-6437179de324d60343e7a4db8696dfdc513a4956.tar.bz2 scummvm-rg350-6437179de324d60343e7a4db8696dfdc513a4956.zip  | |
AVALANCHE: Get rid of SpriteInfo
| -rw-r--r-- | engines/avalanche/animation.cpp | 58 | ||||
| -rw-r--r-- | engines/avalanche/animation.h | 7 | ||||
| -rw-r--r-- | engines/avalanche/avalot.cpp | 4 | ||||
| -rw-r--r-- | engines/avalanche/graphics.cpp | 14 | ||||
| -rw-r--r-- | engines/avalanche/graphics.h | 12 | 
5 files changed, 46 insertions, 49 deletions
diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp index a785c9c08f..71070b2af7 100644 --- a/engines/avalanche/animation.cpp +++ b/engines/avalanche/animation.cpp @@ -88,24 +88,24 @@ void AnimationType::init(byte spritenum, bool doCheck) {  	inf.skip(16 - commentSize);  	_frameNum = inf.readByte(); -	_info._xLength = inf.readByte(); -	_info._yLength = inf.readByte(); +	_xLength = inf.readByte(); +	_yLength = inf.readByte();  	_seq = inf.readByte(); -	_info._size = inf.readUint16LE(); +	_size = inf.readUint16LE();  	_fgBubbleCol = (Color)inf.readByte();  	_bgBubbleCol = (Color)inf.readByte();  	_acciNum = inf.readByte();  	_animCount = 0; // = 1; -	_info._xWidth = _info._xLength / 8; -	if ((_info._xLength % 8) > 0) -		_info._xWidth++; +	_xWidth = _xLength / 8; +	if ((_xLength % 8) > 0) +		_xWidth++;  	for (int i = 0; i < _frameNum; i++) { -		_info._sil[_animCount] = new SilType[11 * (_info._yLength + 1)]; -		_info._mani[_animCount] = new ManiType[_info._size - 6]; -		for (int j = 0; j <= _info._yLength; j++) -			inf.read((*_info._sil[_animCount])[j], _info._xWidth); -		inf.read(*_info._mani[_animCount], _info._size - 6); +		_sil[_animCount] = new SilType[11 * (_yLength + 1)]; +		_mani[_animCount] = new ManiType[_size - 6]; +		for (int j = 0; j <= _yLength; j++) +			inf.read((*_sil[_animCount])[j], _xWidth); +		inf.read(*_mani[_animCount], _size - 6);  		_animCount++;  	} @@ -149,7 +149,7 @@ void AnimationType::draw() {  	byte picnum = _facingDir * _seq + _stepNum; -	_anim->_vm->_graphics->drawSprite(_info, picnum, _x, _y); +	_anim->_vm->_graphics->drawSprite(this, picnum, _x, _y);  }  /** @@ -183,7 +183,7 @@ void AnimationType::appear(int16 wx, int16 wy, Direction wf) {  bool AnimationType::checkCollision() {  	for (int i = 0; i < _anim->kSpriteNumbMax; i++) {  		AnimationType *spr = _anim->_sprites[i]; -		if (spr->_quick && (spr->_id != _id) && (_x + _info._xLength > spr->_x) && (_x < spr->_x + spr->_info._xLength) && (spr->_y == _y)) +		if (spr->_quick && (spr->_id != _id) && (_x + _xLength > spr->_x) && (_x < spr->_x + spr->_xLength) && (spr->_y == _y))  			return true;  	} @@ -209,7 +209,7 @@ void AnimationType::walk() {  			return;  		} -		byte magicColor = _anim->checkFeet(_x, _x + _info._xLength, _oldY[_anim->_vm->_cp], _y, _info._yLength) - 1; +		byte magicColor = _anim->checkFeet(_x, _x + _xLength, _oldY[_anim->_vm->_cp], _y, _yLength) - 1;  		// -1  is because the modified array indexes of magics[] compared to Pascal .  		if ((magicColor != 255) & !_anim->_vm->_doingSpriteRun) { @@ -283,8 +283,8 @@ void AnimationType::walkTo(byte pedNum) {  	PedType *curPed = &_anim->_vm->_peds[pedNum];  	setSpeed(getSign(curPed->_x - _x) * 4, getSign(curPed->_y - _y)); -	_homingX = curPed->_x - _info._xLength / 2; -	_homingY = curPed->_y - _info._yLength; +	_homingX = curPed->_x - _xLength / 2; +	_homingY = curPed->_y - _yLength;  	_homing = true;  } @@ -360,21 +360,21 @@ void AnimationType::stopWalk() {   * Sets up talk vars.   */  void AnimationType::chatter() { -	_anim->_vm->_talkX = _x + _info._xLength / 2; +	_anim->_vm->_talkX = _x + _xLength / 2;  	_anim->_vm->_talkY = _y;  	_anim->_vm->_graphics->setDialogColor(_bgBubbleCol, _fgBubbleCol);  }  void AnimationType::remove() {  	_animCount--; -	_info._xWidth = _info._xLength / 8; -	if ((_info._xLength % 8) > 0) -		_info._xWidth++; +	_xWidth = _xLength / 8; +	if ((_xLength % 8) > 0) +		_xWidth++;  	for (int i = 0; i < _frameNum; i++) {  		assert(_animCount > 0);  		_animCount--; -		delete[] _info._mani[_animCount]; -		delete[] _info._sil[_animCount]; +		delete[] _mani[_animCount]; +		delete[] _sil[_animCount];  	}  	_quick = false; @@ -961,7 +961,7 @@ void Animation::setMoveSpeed(byte t, Direction dir) {  void Animation::appearPed(byte sprNum, byte pedNum) {  	AnimationType *curSpr = _sprites[sprNum];  	PedType *curPed = &_vm->_peds[pedNum]; -	curSpr->appear(curPed->_x - curSpr->_info._xLength / 2, curPed->_y - curSpr->_info._yLength, curPed->_direction); +	curSpr->appear(curPed->_x - curSpr->_xLength / 2, curPed->_y - curSpr->_yLength, curPed->_direction);  	setMoveSpeed(sprNum, curPed->_direction);  } @@ -1026,9 +1026,9 @@ void Animation::arrowProcs(byte tripnum) {  		// This is so if: a) the bottom of the arrow is below Avvy's head,  		// b) the left of the arrow is left of the right of Avvy's head, and  		// c) the right of the arrow is right of the left of Avvy's head. -		if ((tripSpr->_y + tripSpr->_info._yLength >= avvy->_y) // A -			&& (tripSpr->_x <= avvy->_x + avvy->_info._xLength) // B -			&& (tripSpr->_x + tripSpr->_info._xLength >= avvy->_x)) { // C +		if ((tripSpr->_y + tripSpr->_yLength >= avvy->_y) // A +			&& (tripSpr->_x <= avvy->_x + avvy->_xLength) // B +			&& (tripSpr->_x + tripSpr->_xLength >= avvy->_x)) { // C  			// OK, it's hit him... what now?  			_sprites[1]->_callEachStepFl = false; // prevent recursion. @@ -1275,7 +1275,7 @@ bool Animation::inField(byte which) {  	AnimationType *avvy = _sprites[0];  	FieldType *curField = &_vm->_fields[which]; -	int16 yy = avvy->_y + avvy->_info._yLength; +	int16 yy = avvy->_y + avvy->_yLength;  	return (avvy->_x >= curField->_x1) && (avvy->_x <= curField->_x2) && (yy >= curField->_y1) && (yy <= curField->_y2);  } @@ -1291,7 +1291,7 @@ bool Animation::nearDoor() {  	AnimationType *avvy = _sprites[0];  	int16 ux = avvy->_x; -	int16 uy = avvy->_y + avvy->_info._yLength; +	int16 uy = avvy->_y + avvy->_yLength;  	for (int i = 8; i < _vm->_fieldNum; i++) {  		FieldType *curField = &_vm->_fields[i]; @@ -1439,7 +1439,7 @@ void Animation::synchronize(Common::Serializer &sz) {  		sz.syncAsByte(spr->_visible);  		sz.syncAsByte(spr->_homing);  		sz.syncAsByte(spr->_count); -		sz.syncAsByte(spr->_info._xWidth); +		sz.syncAsByte(spr->_xWidth);  		sz.syncAsByte(spr->_speedX);  		sz.syncAsByte(spr->_speedY);  		sz.syncAsByte(spr->_animCount); diff --git a/engines/avalanche/animation.h b/engines/avalanche/animation.h index 297f9110a8..5dbaa5afd7 100644 --- a/engines/avalanche/animation.h +++ b/engines/avalanche/animation.h @@ -42,7 +42,12 @@ enum Direction {  class AnimationType {  public: -	SpriteInfo _info; +	// Former SpriteInfo structure +	byte _xWidth; +	byte _xLength, _yLength; +	ManiType *_mani[24]; +	SilType *_sil[24]; +	uint16 _size; // The size of one picture.  	// Former Stat structure  	Common::String _name; // Name of character. diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index b1c6f96f8b..352ac6a852 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -1140,14 +1140,14 @@ void AvalancheEngine::guideAvvy(Common::Point cursorPos) {  	AnimationType *avvy = _animation->_sprites[0];  	if (cursorPos.x < avvy->_x)  		what = 1; -	else if (cursorPos.x > (avvy->_x + avvy->_info._xLength)) +	else if (cursorPos.x > (avvy->_x + avvy->_xLength))  		what = 2;  	else  		what = 0; // On top  	if (cursorPos.y < avvy->_y)  		what += 3; -	else if (cursorPos.y > (avvy->_y + avvy->_info._yLength)) +	else if (cursorPos.y > (avvy->_y + avvy->_yLength))  		what += 6;  	switch (what) { diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 151879d6c7..0b16590785 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -536,11 +536,11 @@ byte GraphicManager::getScreenColor(Common::Point pos) {  	return *(byte *)_surface.getBasePtr(pos.x, pos.y / 2);  } -void GraphicManager::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y) { +void GraphicManager::drawSprite(AnimationType *sprite, byte picnum, int16 x, int16 y) {  	// First we make the pixels of the sprite blank. -	for (int j = 0; j < sprite._yLength; j++) { -		for (int i = 0; i < sprite._xLength; i++) { -			if (((*sprite._sil[picnum])[j][i / 8] >> ((7 - i % 8)) & 1) == 0) +	for (int j = 0; j < sprite->_yLength; j++) { +		for (int i = 0; i < sprite->_xLength; i++) { +			if (((*sprite->_sil[picnum])[j][i / 8] >> ((7 - i % 8)) & 1) == 0)  				*(byte *)_surface.getBasePtr(x + i, y + j) = 0;  		}  	} @@ -548,10 +548,10 @@ void GraphicManager::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x,  	// Then we draw the picture to the blank places.  	uint16 maniPos = 0; // Because the original manitype starts at 5!!! See Graphics.h for definition. -	for (int j = 0; j < sprite._yLength; j++) { +	for (int j = 0; j < sprite->_yLength; j++) {  		for (int8 plane = 3; plane >= 0; plane--) { // The planes are in the opposite way. -			for (uint16 i = 0; i  < sprite._xLength; i += 8) { -				byte pixel = (*sprite._mani[picnum])[maniPos++]; +			for (uint16 i = 0; i < sprite->_xLength; i += 8) { +				byte pixel = (*sprite->_mani[picnum])[maniPos++];  				for (int bit = 0; bit < 8; bit++) {  					byte pixelBit = (pixel >> bit) & 1;  					*(byte *)_surface.getBasePtr(x + i + 7 - bit, y + j) += (pixelBit << plane); diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index b45d37e186..4af6d4e8db 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -36,21 +36,13 @@  namespace Avalanche {  class AvalancheEngine; +class AnimationType;  struct SpriteType;  typedef byte FontType[256][16];  typedef byte ManiType[2049];  typedef byte SilType[51][11]; // 35, 4 -class SpriteInfo { -public: -	byte _xWidth; -	byte _xLength, _yLength; -	ManiType *_mani[24]; -	SilType *_sil[24]; -	uint16 _size; // The size of one picture. -}; -  struct MouseHotspotType {  	int16 _horizontal, _vertical;  }; @@ -95,7 +87,7 @@ public:  	// Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data  	Graphics::Surface loadPictureRaw(Common::File &file, uint16 width, uint16 height); -	void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y); +	void drawSprite(AnimationType *sprite, byte picnum, int16 x, int16 y);  	void drawPicture(Graphics::Surface &target, const Graphics::Surface picture, uint16 destX, uint16 destY);  	void drawThinkPic(Common::String filename, int id);  	void drawToolbar();  | 
