2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Background animation management module private header
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
#ifndef SAGA_ANIMATION_H_
|
|
|
|
#define SAGA_ANIMATION_H_
|
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
#include "saga/stream.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define MAX_ANIMATIONS 7
|
|
|
|
#define DEFAULT_FRAME_TIME 140
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-11 21:10:36 +00:00
|
|
|
#define SAGA_FRAME_HEADER_LEN (_vm->getFeatures() & GF_MAC_RESOURCES ? 13 : 12)
|
2004-12-15 00:24:12 +00:00
|
|
|
|
|
|
|
#define SAGA_FRAME_START 0xF
|
|
|
|
#define SAGA_FRAME_END 0x3F
|
|
|
|
#define SAGA_FRAME_REPOSITION 0x30
|
|
|
|
#define SAGA_FRAME_ROW_END 0x2F
|
|
|
|
#define SAGA_FRAME_LONG_COMPRESSED_RUN 0x20
|
|
|
|
#define SAGA_FRAME_LONG_UNCOMPRESSED_RUN 0x10
|
|
|
|
#define SAGA_FRAME_COMPRESSED_RUN 0x80
|
|
|
|
#define SAGA_FRAME_UNCOMPRESSED_RUN 0x40
|
|
|
|
#define SAGA_FRAME_EMPTY_RUN 0xC0
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// All animation resources begin with an ANIMATION_HEADER
|
|
|
|
// at 0x00, followed by a RLE code stream
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
struct ANIMATION_HEADER {
|
2004-04-30 23:02:23 +00:00
|
|
|
uint16 magic;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-04-30 23:02:23 +00:00
|
|
|
uint16 screen_w;
|
|
|
|
uint16 screen_h;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
byte unknown06;
|
|
|
|
byte unknown07;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-03 17:39:20 +00:00
|
|
|
byte maxframe;
|
2004-12-28 03:44:07 +00:00
|
|
|
byte loopframe;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
uint16 start;
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
struct FRAME_HEADER {
|
2004-04-12 21:40:49 +00:00
|
|
|
int x_start;
|
|
|
|
int y_start;
|
|
|
|
|
|
|
|
int x_pos;
|
|
|
|
int y_pos;
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Animation info array member
|
2004-10-27 21:32:28 +00:00
|
|
|
struct ANIMATION {
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-04-30 23:02:23 +00:00
|
|
|
const byte *resdata;
|
2004-04-12 21:40:49 +00:00
|
|
|
size_t resdata_len;
|
|
|
|
|
2005-01-03 17:39:20 +00:00
|
|
|
uint16 maxframe;
|
2004-04-12 21:40:49 +00:00
|
|
|
size_t *frame_offsets;
|
2004-12-28 03:44:07 +00:00
|
|
|
int16 current_frame;
|
|
|
|
uint16 completed;
|
|
|
|
uint16 cycles;
|
|
|
|
int16 loopframe;
|
2004-04-30 23:02:23 +00:00
|
|
|
const byte *cur_frame_p;
|
2004-04-12 21:40:49 +00:00
|
|
|
size_t cur_frame_len;
|
|
|
|
int frame_time;
|
|
|
|
|
2004-12-28 04:09:10 +00:00
|
|
|
int state;
|
2004-12-28 03:44:07 +00:00
|
|
|
int16 link_id;
|
2004-04-30 23:02:23 +00:00
|
|
|
uint16 flags;
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-07-31 13:34:43 +00:00
|
|
|
enum ANIM_FLAGS {
|
2004-12-28 04:09:10 +00:00
|
|
|
ANIM_PLAYING = 0x01,
|
2004-08-10 23:04:52 +00:00
|
|
|
ANIM_PAUSE = 0x02,
|
2004-12-28 04:09:10 +00:00
|
|
|
ANIM_STOPPING = 0x04,
|
2004-07-31 13:34:43 +00:00
|
|
|
ANIM_ENDSCENE = 0x80 // When animation ends, dispatch scene end event
|
|
|
|
};
|
|
|
|
|
|
|
|
class Anim {
|
|
|
|
public:
|
2004-08-01 13:34:20 +00:00
|
|
|
Anim(SagaEngine *vm);
|
2004-07-31 13:34:43 +00:00
|
|
|
~Anim(void);
|
2004-12-03 19:15:44 +00:00
|
|
|
|
2004-07-31 13:34:43 +00:00
|
|
|
int load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p);
|
|
|
|
int freeId(uint16 anim_id);
|
2004-12-28 03:44:07 +00:00
|
|
|
int play(uint16 anim_id, int vector_time, bool playing = true);
|
|
|
|
int link(int16 anim_id1, int16 anim_id2);
|
2004-07-31 13:34:43 +00:00
|
|
|
int setFlag(uint16 anim_id, uint16 flag);
|
2004-08-10 23:04:52 +00:00
|
|
|
int clearFlag(uint16 anim_id, uint16 flag);
|
2004-07-31 13:34:43 +00:00
|
|
|
int setFrameTime(uint16 anim_id, int time);
|
|
|
|
int reset(void);
|
2004-12-03 19:15:44 +00:00
|
|
|
void animInfo(void);
|
2004-12-28 03:44:07 +00:00
|
|
|
void setCycles(uint animId, int cycles);
|
|
|
|
void stop(uint16 animId);
|
2004-12-28 04:09:10 +00:00
|
|
|
void finish(uint16 animId);
|
|
|
|
void resume(uint16 animId, int cycles);
|
2005-04-16 20:59:24 +00:00
|
|
|
int16 getCurrentFrame(uint16 anim_id);
|
2004-07-31 23:33:14 +00:00
|
|
|
|
2004-07-31 13:34:43 +00:00
|
|
|
private:
|
|
|
|
int ITE_DecodeFrame(const byte *anim_resource, size_t anim_resource_len, size_t frame_offset, byte *buf, size_t buf_len);
|
|
|
|
int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_p,
|
2004-05-04 03:33:03 +00:00
|
|
|
size_t thisf_len, const byte **nextf_p, size_t *nextf_len);
|
2004-07-31 13:34:43 +00:00
|
|
|
int getFrameOffset(const byte *anim_resource, size_t anim_resource_len, uint16 find_frame, size_t *frame_offset);
|
2004-12-28 03:44:07 +00:00
|
|
|
void readAnimHeader(MemoryReadStreamEndian &readS, ANIMATION_HEADER &ah);
|
2004-07-31 23:33:14 +00:00
|
|
|
|
2004-08-01 13:34:20 +00:00
|
|
|
SagaEngine *_vm;
|
2004-07-31 23:33:14 +00:00
|
|
|
bool _initialized;
|
|
|
|
|
|
|
|
uint16 _anim_count;
|
|
|
|
uint16 _anim_limit;
|
2004-10-27 21:32:28 +00:00
|
|
|
ANIMATION *_anim_tbl[MAX_ANIMATIONS];
|
2004-07-31 23:33:14 +00:00
|
|
|
|
2004-07-31 13:34:43 +00:00
|
|
|
};
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#endif /* ANIMATION_H_ */
|
2004-04-12 21:40:49 +00:00
|
|
|
/* end "r_animation.h" */
|