diff options
| -rw-r--r-- | scumm/actor.cpp | 28 | ||||
| -rw-r--r-- | scumm/actor.h | 19 | ||||
| -rw-r--r-- | scumm/akos.cpp | 6 | ||||
| -rw-r--r-- | scumm/costume.cpp | 4 | ||||
| -rw-r--r-- | scumm/debugger.cpp | 12 | ||||
| -rw-r--r-- | scumm/object.cpp | 2 | ||||
| -rw-r--r-- | scumm/resource.cpp | 1 | ||||
| -rw-r--r-- | scumm/script_v2.cpp | 6 | ||||
| -rw-r--r-- | scumm/script_v5.cpp | 5 | ||||
| -rw-r--r-- | scumm/script_v6.cpp | 3 | ||||
| -rw-r--r-- | scumm/script_v8.cpp | 3 | 
11 files changed, 45 insertions, 44 deletions
| diff --git a/scumm/actor.cpp b/scumm/actor.cpp index f63668d2ca..9de27a2f27 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -51,11 +51,7 @@ void Actor::initActor(int mode) {  		x = 0;  		y = 0;  		facing = 180; -		newDirection = 180; -		talkFrequency = 256;  	} else if (mode == 2) { -		facing = 180; -		newDirection = 180;  	}  	elevation = 0; @@ -66,7 +62,7 @@ void Actor::initActor(int mode) {  	scaley = scalex = 0xFF;  	charset = 0;  	memset(sound, 0, sizeof(sound)); -	newDirection = 0; +	targetFacing = facing;  	stopActorMoving(); @@ -181,7 +177,7 @@ int Actor::calcMovementFactor(int newX, int newY) {  	walkdata.xfrac = 0;  	walkdata.yfrac = 0; -	newDirection = _vm->getAngleFromPos(deltaXFactor, deltaYFactor); +	targetFacing = _vm->getAngleFromPos(deltaXFactor, deltaYFactor);  	return actorWalkStep();  } @@ -284,7 +280,7 @@ int Actor::updateActorDirection(bool is_walking) {  	dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(this) : false;  	from = toSimpleDir(dirType, facing); -	dir = remapDirection(newDirection, is_walking); +	dir = remapDirection(targetFacing, is_walking);  	if (_vm->_features & GF_NEW_COSTUMES)  		// Direction interpolation interfers with walk scripts in Dig; they perform @@ -324,14 +320,14 @@ int Actor::actorWalkStep() {  	int tmpX, tmpY;  	int actorX, actorY;  	int distX, distY; -	int direction; +	int nextFacing;  	needRedraw = true; -	direction = updateActorDirection(true); -	if (!(moving & MF_IN_LEG) || facing != direction) { -		if (walkFrame != frame || facing != direction) { -			startWalkAnim(1, direction); +	nextFacing = updateActorDirection(true); +	if (!(moving & MF_IN_LEG) || facing != nextFacing) { +		if (walkFrame != frame || facing != nextFacing) { +			startWalkAnim(1, nextFacing);  		}  		moving |= MF_IN_LEG;  	} @@ -536,14 +532,18 @@ void Actor::setDirection(int direction) {  	int i;  	uint16 vald; +	// Do nothing if actor is already facing in the given direction  	if (facing == direction)  		return; +	// Normalize the angle  	facing = normalizeAngle(direction); +	// If there is no costume set for this actor, we are finished  	if (costume == 0)  		return; +	// Update the costume for the new direction (and mark the actor for redraw)  	aMask = 0x8000;  	for (i = 0; i < 16; i++, aMask >>= 1) {  		vald = cost.frame[i]; @@ -736,7 +736,7 @@ void Actor::turnToDirection(int newdir) {  			moving = MF_TURN;  		else  			moving |= MF_TURN; -		newDirection = newdir; +		targetFacing = newdir;  	}  } @@ -1575,7 +1575,7 @@ const SaveLoadEntry *Actor::getSaveLoadEntries() {  		MKLINE(Actor, charset, sleByte, VER_V8),  		MKARRAY(Actor, sound[0], sleByte, 8, VER_V8),  		MKARRAY(Actor, animVariable[0], sleUint16, 8, VER_V8), -		MKLINE(Actor, newDirection, sleUint16, VER_V8), +		MKLINE(Actor, targetFacing, sleUint16, VER_V8),  		MKLINE(Actor, moving, sleByte, VER_V8),  		MKLINE(Actor, ignoreBoxes, sleByte, VER_V8),  		MKLINE(Actor, forceClip, sleByte, VER_V8), diff --git a/scumm/actor.h b/scumm/actor.h index 6071d301e0..5748f557ee 100644 --- a/scumm/actor.h +++ b/scumm/actor.h @@ -86,14 +86,12 @@ public:  	int elevation;  	uint width;  	byte number; -	uint16 facing;  	uint16 costume;  	byte room;  	byte talkColor;  	int talkFrequency;  	byte scalex, scaley;  	byte charset; -	int16 newDirection;  	byte moving;  	bool ignoreBoxes;  	byte forceClip; @@ -101,10 +99,8 @@ public:  	bool needRedraw, needBgReset, visible;  	byte shadow_mode;  	bool flip; -	uint speedx, speedy;  	byte frame;  	byte walkbox; -	byte animProgress, animSpeed;  	int16 talkPosX, talkPosY;  	uint16 talkScript, walkScript;  	bool ignoreTurns;	// TODO - we do not honor this flag at all currently! @@ -113,6 +109,10 @@ public:  	CostumeData cost;  	byte palette[256];  protected: +	uint16 facing; +	uint16 targetFacing; +	uint speedx, speedy; +	byte animProgress, animSpeed;  	bool costumeNeedsInit;  	ActorWalkData walkdata;  	int16 animVariable[16]; @@ -188,11 +188,15 @@ public:  		return room == _vm->_currentRoom;  	} -	int getActorXYPos(int &x, int &y) const ; +	int getActorXYPos(int &x, int &y) const;  	int getRoom() const {  		return room;  	} +	 +	int getFacing() const { +		return facing; +	}  	int getAnimVar(byte var) const {  		return animVariable[var]; @@ -201,6 +205,11 @@ public:  		animVariable[var] = value;  	} +	void setAnimSpeed(byte newAnimSpeed) { +		animSpeed = newAnimSpeed; +		animProgress = 0; +	} +	  	void classChanged(int cls, bool value);  	// Used by the save/load syste: diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 19eaa64653..c9f1ed2078 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -125,9 +125,9 @@ bool Scumm::akos_hasManyDirections(Actor *a) {  int Scumm::akos_frameToAnim(Actor *a, int frame) {  	if (akos_hasManyDirections(a)) -		return toSimpleDir(1, a->facing) + frame * 8; +		return toSimpleDir(1, a->getFacing()) + frame * 8;  	else -		return newDirToOldDir(a->facing) + frame * 4; +		return newDirToOldDir(a->getFacing()) + frame * 4;  }  void Scumm::akos_decodeData(Actor *a, int frame, uint usemask) { @@ -243,7 +243,7 @@ void AkosRenderer::setCostume(int costume) {  }  void AkosRenderer::setFacing(Actor *a) { -	_mirror = (newDirToOldDir(a->facing) != 0 || akhd->flags & 1); +	_mirror = (newDirToOldDir(a->getFacing()) != 0 || akhd->flags & 1);  	if (a->flip)  		_mirror = !_mirror;  } diff --git a/scumm/costume.cpp b/scumm/costume.cpp index 4df47a0e98..fbe2b05e70 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -641,7 +641,7 @@ byte CostumeRenderer::drawLimb(const CostumeData &cost, int limb) {  }  int Scumm::cost_frameToAnim(Actor *a, int frame) { -	return newDirToOldDir(a->facing) + frame * 4; +	return newDirToOldDir(a->getFacing()) + frame * 4;  }  void Scumm::cost_decodeData(Actor *a, int frame, uint usemask) { @@ -746,7 +746,7 @@ void CostumeRenderer::setPalette(byte *palette) {  }  void CostumeRenderer::setFacing(Actor *a) { -	_mirror = newDirToOldDir(a->facing) != 0 || _loaded._mirror; +	_mirror = newDirToOldDir(a->getFacing()) != 0 || _loaded._mirror;  }  void CostumeRenderer::setCostume(int costume) { diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index e4796d67bf..7a860960ac 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -596,18 +596,18 @@ bool ScummDebugger::Cmd_PrintActor(int argc, const char **argv) {  	int i;  	Actor *a; -	Debug_Printf("+--------------------------------------------------------------------+\n"); -	Debug_Printf("|# |room|  x |  y |elev|cos|width|box|mov| zp|frame|scale|spd|dir|cls|\n"); -	Debug_Printf("+--+----+----+----+----+---+-----+---+---+---+-----+-----+---+---+---+\n"); +	Debug_Printf("+----------------------------------------------------------------+\n"); +	Debug_Printf("|# |room|  x |  y |elev|cos|width|box|mov| zp|frame|scale|dir|cls|\n"); +	Debug_Printf("+--+----+----+----+----+---+-----+---+---+---+-----+-----+---+---+\n");  	for (i = 1; i < _s->_numActors; i++) {  		a = &_s->_actors[i];  		if (a->visible) -			Debug_Printf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|%3d|$%02x|\n", +			Debug_Printf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|$%02x|\n",  						 a->number, a->room, a->x, a->y, a->elevation, a->costume,  						 a->width, a->walkbox, a->moving, a->forceClip, a->frame, -						 a->scalex, a->speedx, a->facing, int(_s->_classData[a->number]&0xFF)); +						 a->scalex, a->getFacing(), int(_s->_classData[a->number]&0xFF));  	} -	Debug_Printf("+--------------------------------------------------------------------+\n"); +	Debug_Printf("+----------------------------------------------------------------+\n");  	return true;  } diff --git a/scumm/object.cpp b/scumm/object.cpp index c3f613c5a5..21044fdbe4 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -1241,7 +1241,7 @@ int Scumm::getObjOldDir(int obj) {  int Scumm::getObjNewDir(int obj) {  	int dir;  	if (obj < _numActors) { -		dir = derefActor(obj, "getObjNewDir")->facing; +		dir = derefActor(obj, "getObjNewDir")->getFacing();  	} else {  		int x, y;  		getObjectXYPos(obj, x, y, dir); diff --git a/scumm/resource.cpp b/scumm/resource.cpp index bd2f12f35c..3201df4dd3 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -705,7 +705,6 @@ int Scumm::readSoundResource(int type, int idx) {  				(char)((basetag >> 16) & 0xff),  				(char)((basetag >> 8) & 0xff), (char)(basetag & 0xff), total_size); -	//if (_gameId == GID_SAMNMAX || _features & GF_AFTER_V7) {  	if (basetag == MKID('MIDI') || basetag == MKID('iMUS')) {  		_fileHandle.seek(-8, SEEK_CUR);  		_fileHandle.read(createResource(type, idx, total_size + 8), total_size + 8); diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index a46f8e7cfa..0d75988578 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -1340,12 +1340,8 @@ void Scumm_v2::o2_beginOverride() {  void Scumm_v2::o2_chainScript() {  	int data = getVarOrDirectByte(0x80); -	int cur = _currentScript; - -	vm.slot[cur].number = 0; -	vm.slot[cur].status = 0; +	stopScript(vm.slot[_currentScript].number);  	_currentScript = 0xFF; -  	runScript(data, 0, 0, 0);  } diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 2e6777609c..4c5c602194 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -524,8 +524,7 @@ void Scumm_v5::o5_actorSet() {  			break;  		case 22:										/* animspeed */ -			a->animSpeed = getVarOrDirectByte(0x80); -			a->animProgress = 0; +			a->setAnimSpeed(getVarOrDirectByte(0x80));  			break;  		case 23:										/* shadow mode */  			a->shadow_mode = getVarOrDirectByte(0x80); @@ -942,7 +941,7 @@ void Scumm_v5::o5_getActorFacing() {  	getResultPos();  	int act = getVarOrDirectByte(0x80);  	Actor *a = derefActor(act, "o5_getActorFacing"); -	setResult(newDirToOldDir(a->facing)); +	setResult(newDirToOldDir(a->getFacing()));  }  void Scumm_v5::o5_getActorMoving() { diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 8f4d5ee34c..b87ca12aa0 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -1717,8 +1717,7 @@ void Scumm_v6::o6_actorOps() {  			a->putActor(a->x, a->y, a->room);  		break;  	case 97: -		a->animSpeed = pop(); -		a->animProgress = 0; +		a->setAnimSpeed(pop());  		break;  	case 98:  		a->shadow_mode = pop(); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index f7db60fcd3..72a3e3a4f1 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -959,8 +959,7 @@ void Scumm_v8::o8_actorOps() {  		a->standFrame = pop();  		break;  	case 0x6C:		// SO_ACTOR_ANIMATION_SPEED Set speed of animation -		a->animSpeed = pop(); -		a->animProgress = 0; +		a->setAnimSpeed(pop());  		break;  	case 0x6D:		// SO_ACTOR_DEFAULT  		// FIXME - is this right? Or maybe a->initActor(2) ? | 
