Skip to content

Commit

Permalink
SCUMM: Fix Tentacle issue, and possibly some other animation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
segrax authored and tobigun committed Feb 11, 2012
1 parent ddd65df commit 1e8d066
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 39 deletions.
52 changes: 28 additions & 24 deletions engines/scumm/actor.cpp
Expand Up @@ -396,9 +396,14 @@ void Actor::startWalkActor(int destX, int destY, int dir) {
}

if (_vm->_game.version <= 2) {

abr = adjustXYToBeInBox(abr.x, abr.y);
if (_pos.x == abr.x && _pos.y == abr.y && (dir == -1 || _facing == dir))
return;

if( _vm->_game.version == 0 )
((ActorC64*) this)->animateActor( newDirToOldDir( _facing ) );

} else {
if (_ignoreBoxes) {
abr.box = kInvalidBox;
Expand Down Expand Up @@ -554,17 +559,12 @@ void Actor_v2::walkActor() {

if (_facing != new_dir) {

if( _vm->_game.version != 0 )
setDirection(new_dir);
setDirection(new_dir);

} else {
_moving = 0;
}

if( _vm->_game.version == 0 )
if( _moving == 0 )
setDirection( new_dir );

return;
}

Expand Down Expand Up @@ -909,7 +909,7 @@ void ActorC64::setDirection(int direction) {

_animFrameRepeat = -1;
animateActor(res);
if(_moving)
if(_moving & MF_TURN)
animateCostume();
}

Expand All @@ -936,13 +936,12 @@ void Actor::turnToDirection(int newdir) {
} else {
_moving &= ~MF_TURN;
if (newdir != _facing) {

_moving |= MF_TURN;
_targetFacing = newdir;
}
}

if (_vm->_game.version == 0)
setDirection( newdir );
}


Expand Down Expand Up @@ -1004,8 +1003,10 @@ void Actor::putActor(int dstX, int dstY, int newRoom) {
showActor();
}

if( _vm->_game.version == 0 && _costume != 0x13 )
turnToDirection( oldDirToNewDir(2));
if( _vm->_game.version == 0 ) {
_moving = 0;
setDirection( oldDirToNewDir(2));
}
}

static bool inBoxQuickReject(const BoxCoords &box, int x, int y, int threshold) {
Expand Down Expand Up @@ -1874,7 +1875,7 @@ void ActorC64::startAnimActor(int f) {
if( f == _standFrame )
setDirection( _facing );
else
animateActor( newDirToOldDir(_facing) );
animateActor( newDirToOldDir(_targetFacing) );
}

void Actor::animateActor(int anim) {
Expand Down Expand Up @@ -1950,24 +1951,16 @@ void ActorC64::limbFrameCheck() {

_limbFrameRepeat[_limb_current] = _limbFrameRepeatNew[_limb_current];

_cost.active[_limb_current] = _cost.frame[_limb_current];
_vm->_costumeLoader->loadCostume(_costume);

// 0x25C3
_cost.active[_limb_current] = ((C64CostumeLoader*)_vm->_costumeLoader)->getFrame( this );
_cost.curpos[_limb_current] = 0;

_needRedraw = true;
}

void ActorC64::animateCostume() {

// Sound
if (_moving && _vm->_currentRoom != 1 && _vm->_currentRoom != 44) {
if (_cost.soundPos == 0)
_cost.soundCounter++;

// Is this the correct location?
// 0x073C
if (v0ActorTalkArray[_number] & 0x3F)
_cost.soundPos = (_cost.soundPos + 1) % 3;
}

speakCheck();

Expand Down Expand Up @@ -2780,6 +2773,17 @@ void ScummEngine_v71he::queueAuxEntry(int actorNum, int subIndex) {
void ActorC64::animateActor(int anim) {
int dir = -1;

// Sound
if (_moving && _vm->_currentRoom != 1 && _vm->_currentRoom != 44) {
if (_cost.soundPos == 0)
_cost.soundCounter++;

// Is this the correct location?
// 0x073C
if (v0ActorTalkArray[_number] & 0x3F)
_cost.soundPos = (_cost.soundPos + 1) % 3;
}

switch( anim ) {
case 0x00:
case 0x04:
Expand Down
29 changes: 15 additions & 14 deletions engines/scumm/costume.cpp
Expand Up @@ -1184,20 +1184,17 @@ byte C64CostumeRenderer::drawLimb(const Actor *a, int limb) {
if (limb >= 8)
return 0;

if (a->_cost.curpos[limb] == 0xFFFF || A->_cost.active[limb] == 0xFFFF )
return 0;

if (limb == 0) {
_draw_top = 200;
_draw_bottom = 0;
}

byte frameB = _loaded._frameOffsets[limb] + a->_cost.active[limb];
byte frameStart = _loaded._frameOffsets[ frameB ];
byte frame = _loaded._frameOffsets[frameStart + a->_cost.curpos[limb]];
if (frame == 0xFF)

if( a->_cost.curpos[limb] == 0xFFFF )
return 0;

_loaded.loadCostume( a->_costume );
byte frame = _loaded._frameOffsets[ a->_cost.curpos[limb] + a->_cost.active[limb] ];

byte ptrLow = _loaded._baseptr[frame];
byte ptrHigh = ptrLow + _loaded._dataOffsets[4];
int frameOffset = (_loaded._baseptr[ptrHigh] << 8) + _loaded._baseptr[ptrLow + 2]; // 0x23EF / 0x2400
Expand Down Expand Up @@ -1337,19 +1334,23 @@ void C64CostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) {
}
}

byte C64CostumeLoader::getFrame( ActorC64 *A ) {

loadCostume(A->_costume);

return _frameOffsets[ _frameOffsets[A->_limb_current] + A->_cost.start[ A->_limb_current ] ];
}

byte C64CostumeLoader::increaseAnims(Actor *a) {
ActorC64 *A = (ActorC64 *)a;

if( _frameOffsets == 0 || (a->_cost.active[A->_limb_current] == 0xFFFF) )
return 0;

uint16 limbPrevious = a->_cost.curpos[A->_limb_current]++;

loadCostume(a->_costume);

// increase each frame pos
// 0x2543
byte frameB = _frameOffsets[A->_limb_current] + a->_cost.active[A->_limb_current];
byte frameStart = _frameOffsets[ frameB ];
byte frame = _frameOffsets[frameStart + a->_cost.curpos[A->_limb_current]];
byte frame = _frameOffsets[ a->_cost.curpos[A->_limb_current] + a->_cost.active[A->_limb_current] ];

if ( frame == 0xFF ) {
// 0x2545
Expand Down
3 changes: 2 additions & 1 deletion engines/scumm/costume.h
Expand Up @@ -73,11 +73,12 @@ class C64CostumeLoader : public ClassicCostumeLoader {
void loadCostume(int id);
void costumeDecodeData(Actor *a, int frame, uint usemask);
byte increaseAnims(Actor *a);

byte getFrame( ActorC64 *A );

int _maxHeight;

protected:
int dirToDirStop(int oldDir);

};

Expand Down
1 change: 1 addition & 0 deletions engines/scumm/script_v0.cpp
Expand Up @@ -698,6 +698,7 @@ void ScummEngine_v0::o_animateActor() {
}

a->animateActor(anim);
a->animateCostume();
}

void ScummEngine_v0::o_getActorMoving() {
Expand Down

0 comments on commit 1e8d066

Please sign in to comment.