1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Object animation definitions
22  */
23 
24 #ifndef TINSEL_ANIM_H     // prevent multiple includes
25 #define TINSEL_ANIM_H
26 
27 #include "tinsel/dw.h"	// for SCNHANDLE
28 
29 namespace Tinsel {
30 
31 struct OBJECT;
32 
33 /** animation structure */
34 struct ANIM {
35 	int aniRate;		///< animation speed
36 	int aniDelta;		///< animation speed delta counter
37 	OBJECT *pObject;	///< object to animate (assumed to be multi-part)
38 	uint32 hScript;		///< animation script handle
39 	int scriptIndex;	///< current position in animation script
40 };
41 typedef ANIM *PANIM;
42 
43 typedef void (*PANI_ADDR)(struct ANIM *);
44 
45 /** Animation script commands */
46 enum {
47 	ANI_END			= 0,	///< end of animation script
48 	ANI_JUMP		= 1,	///< animation script jump
49 	ANI_HFLIP		= 2,	///< flip animated object horizontally
50 	ANI_VFLIP		= 3,	///< flip animated object vertically
51 	ANI_HVFLIP		= 4,	///< flip animated object in both directions
52 	ANI_ADJUSTX		= 5,	///< adjust animated object x animation point
53 	ANI_ADJUSTY		= 6,	///< adjust animated object y animation point
54 	ANI_ADJUSTXY	= 7,	///< adjust animated object x & y animation points
55 	ANI_NOSLEEP		= 8,	///< do not sleep for this frame
56 	ANI_CALL		= 9,	///< call routine
57 	ANI_HIDE		= 10,	///< hide animated object
58 	ANI_STOP		= 11	///< stop sound
59 };
60 
61 /** animation script command possibilities */
62 union ANI_SCRIPT {
63 	int32 op;			///< treat as an opcode or operand
64 	uint32 hFrame;		///< treat as a animation frame handle
65 //	PANI_ADDR pFunc;	///< treat as a animation function call
66 };
67 
68 
69 /*----------------------------------------------------------------------*\
70 |*			Anim Function Prototypes			*|
71 \*----------------------------------------------------------------------*/
72 
73 /** states for DoNextFrame */
74 enum SCRIPTSTATE {ScriptFinished, ScriptNoSleep, ScriptSleep};
75 
76 SCRIPTSTATE DoNextFrame(	// Execute the next animation frame of a animation script
77 	ANIM *pAnim);		// animation data structure
78 
79 void InitStepAnimScript(	// Init a ANIM struct for single stepping through a animation script
80 	ANIM *pAnim,		// animation data structure
81 	OBJECT *pAniObj,	// object to animate
82 	SCNHANDLE hNewScript,	// handle to script of multipart frames
83 	int aniSpeed);		// sets speed of animation in frames
84 
85 SCRIPTSTATE StepAnimScript(	// Execute the next command in a animation script
86 	ANIM *pAnim);		// animation data structure
87 
88 void SkipFrames(		// Skip the specified number of frames
89 	ANIM *pAnim,		// animation data structure
90 	int numFrames);		// number of frames to skip
91 
92 bool AboutToJumpOrEnd(PANIM pAnim);
93 
94 } // End of namespace Tinsel
95 
96 #endif		// TINSEL_ANIM_H
97