2013-06-27 12:13:00 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
/*
* This code is based on the original source code of Lord Avalot d ' Argent version 1.3 .
* Copyright ( c ) 1994 - 1995 Mike , Mark and Thomas Thurman .
*/
2013-09-08 11:30:23 +02:00
/* Original name: TRIP5 / Trippancy V - the sprite animation subsystem */
2013-06-27 12:13:00 +02:00
2013-09-07 19:09:06 +02:00
# ifndef AVALANCHE_ANIMATION_H
# define AVALANCHE_ANIMATION_H
2013-06-27 12:13:00 +02:00
2013-07-24 17:02:08 +02:00
# include "avalanche/graphics.h"
2013-07-18 15:13:23 +02:00
2013-06-27 12:13:00 +02:00
# include "common/scummsys.h"
# include "common/str.h"
namespace Avalanche {
2013-06-29 10:13:02 +02:00
class AvalancheEngine ;
2013-09-08 11:40:35 +02:00
class Animation ;
2013-06-29 10:13:02 +02:00
2013-09-08 11:40:35 +02:00
struct StatType {
Common : : String _name ; // Name of character.
Common : : String _comment ; // Comment.
byte _frameNum ; // Number of pictures.
byte _seq ; // How many in one stride.
byte _fgBubbleCol , _bgBubbleCol ; // Foreground & background bubble colors.
byte _acciNum ; // The number according to Acci. (1=Avvy, etc.)
2013-06-29 10:13:02 +02:00
} ;
2013-09-07 19:09:06 +02:00
class AnimationType {
2013-06-29 10:13:02 +02:00
public :
2013-07-18 15:13:23 +02:00
SpriteInfo _info ;
2013-09-08 11:40:35 +02:00
StatType _stat ; // Vital statistics.
2013-09-07 23:42:34 +02:00
byte _facingDir , _stepNum ;
2013-09-08 11:34:21 +02:00
int16 _x , _y ; // Current xy coords.
int16 _oldX [ 2 ] , _oldY [ 2 ] ; // Last xy coords.
int8 _moveX , _moveY ; // Amount to move sprite by, each step.
2013-09-07 23:03:27 +02:00
byte _id ;
2013-09-07 23:42:34 +02:00
bool _quick , _visible , _homing , _doCheck ;
2013-09-08 11:34:21 +02:00
int16 _homingX , _homingY ; // Homing x & y coords.
byte _count ; // Counts before changing step.
byte _speedX , _speedY ; // x & y speed.
byte _animCount ; // Total number of sprites.
2013-09-07 23:42:34 +02:00
bool _vanishIfStill ; // Do we show this sprite if it's still?
bool _callEachStepFl ; // Do we call the eachstep procedure?
byte _eachStepProc ;
2013-06-29 10:13:02 +02:00
2013-09-08 12:53:19 +02:00
void init ( byte spritenum , bool doCheck , Animation * anim ) ; // Loads & sets up the sprite.
2013-09-08 11:34:21 +02:00
void original ( ) ; // Just sets 'quick' to false.
2013-09-08 12:21:02 +02:00
void draw ( ) ; // Drops sprite onto screen. Original: andexor().
2013-09-08 11:34:21 +02:00
void turn ( byte whichway ) ; // Turns character round.
void appear ( int16 wx , int16 wy , byte wf ) ; // Switches it on.
void bounce ( ) ; // Bounces off walls.
void walk ( ) ; // Prepares for andexor, etc.
void walkTo ( byte pednum ) ; // Home in on a point.
2013-09-08 12:39:33 +02:00
void stopHoming ( ) ; // Self-explanatory.
2013-09-08 11:34:21 +02:00
void homeStep ( ) ; // Calculates ix & iy for one homing step.
2013-09-08 12:39:33 +02:00
void setSpeed ( int8 xx , int8 yy ) ; // Sets ix & iy, non-homing, etc.
2013-09-08 11:34:21 +02:00
void stopWalk ( ) ; // Stops the sprite from moving.
void chatter ( ) ; // Sets up talk vars.
2013-09-08 12:39:33 +02:00
void remove ( ) ;
2013-06-29 10:13:02 +02:00
private :
2013-09-08 12:53:19 +02:00
Animation * _anim ;
2013-06-29 10:13:02 +02:00
2013-09-07 20:02:14 +02:00
bool checkCollision ( ) ;
2013-09-08 12:23:48 +02:00
int8 getSign ( int16 val ) ;
2013-06-29 10:13:02 +02:00
} ;
2013-09-07 19:09:06 +02:00
class Animation {
2013-06-29 10:13:02 +02:00
public :
2013-09-07 19:09:06 +02:00
friend class AnimationType ;
2013-06-27 12:13:00 +02:00
2013-09-08 12:21:02 +02:00
enum Direction {
kDirUp , kDirRight , kDirDown , kDirLeft ,
kDirUpRight , kDirDownRight , kDirDownLeft , kDirUpLeft ,
kDirStopped
} ;
2013-09-07 09:14:14 +02:00
2013-09-08 12:46:16 +02:00
static const byte kSpriteNumbMax = 5 ; // current max no. of sprites
2013-06-27 12:13:00 +02:00
2013-09-08 12:21:02 +02:00
enum Proc {
kProcFollowAvvyY = 1 ,
kProcBackAndForth ,
kProcFaceAvvy ,
kProcArrow ,
kProcSpludwick , // Unused
kProcGrabAvvy ,
kProcGeida // Spludwick uses it as well for homing! TODO: Unify it with kProcSpludwick.
} ;
AnimationType _sprites [ kSpriteNumbMax ] ;
bool _mustExclaim ;
uint16 _sayWhat ;
2013-09-13 22:58:24 +02:00
byte _direction ; // The direction Avvy is currently facing.
byte _oldDirection ;
2013-06-27 12:13:00 +02:00
2013-09-07 19:09:06 +02:00
Animation ( AvalancheEngine * vm ) ;
~ Animation ( ) ;
2013-09-05 15:48:30 +02:00
2013-09-07 20:02:14 +02:00
void animLink ( ) ;
2013-09-08 12:06:08 +02:00
void loadAnims ( ) ; // Original: loadtrip().
void callSpecial ( uint16 which ) ;
2013-09-07 23:42:34 +02:00
void openDoor ( byte whither , byte ped , byte magicnum ) ; // Handles slidey-open doors.
2013-09-08 12:06:08 +02:00
void catacombMove ( byte ped ) ; // When you enter a new position in the catacombs, this procedure should be called. It changes the 'also' codes so that they may match the picture on the screen.
2013-09-07 23:03:27 +02:00
void stopWalking ( ) ;
2013-09-08 12:06:08 +02:00
void changeDirection ( byte t , byte dir ) ;
void appearPed ( byte trn , byte np ) ;
void flipRoom ( byte room , byte ped ) ;
bool inField ( byte which ) ; // Returns true if you're within field "which".
bool nearDoor ( ) ; // Returns True if you're near a door.
void updateSpeed ( ) ;
2013-07-24 13:11:24 +02:00
void handleMoveKey ( const Common : : Event & event ) ; // To replace tripkey().
2013-06-29 10:13:02 +02:00
private :
AvalancheEngine * _vm ;
2013-09-08 12:06:08 +02:00
byte checkFeet ( int16 x1 , int16 x2 , int16 oy , int16 y , byte yl ) ;
2013-09-08 12:21:02 +02:00
byte geidaPed ( byte which ) ;
void dawnDelay ( ) ;
void grabAvvy ( byte tripnum ) ;
void arrowProcs ( byte tripnum ) ;
2013-09-07 23:03:27 +02:00
void hideInCupboard ( ) ;
2013-09-08 12:06:08 +02:00
2013-09-08 12:21:02 +02:00
// Different movements for NPCs:
void followAvalotY ( byte tripnum ) ; // Original: follow_avvy_y().
void backAndForth ( byte tripnum ) ;
void faceAvvy ( byte tripnum ) ;
// Movements for Homing NPCs: Spludwick and Geida.
void spin ( byte whichway , byte & tripnum ) ;
2013-09-08 12:06:08 +02:00
void takeAStep ( byte & tripnum ) ;
2013-09-08 12:21:02 +02:00
void geidaProcs ( byte tripnum ) ;
2013-09-08 12:06:08 +02:00
2013-09-08 12:21:02 +02:00
void drawSprites ( ) ; // Original: call_andexors().
2013-06-29 10:13:02 +02:00
} ;
2013-06-27 12:13:00 +02:00
} // End of namespace Avalanche.
2013-09-07 19:09:06 +02:00
# endif // AVALANCHE_ANIMATION_H