2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Background animation management module private header
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-02-19 17:30:43 +00:00
|
|
|
#ifndef SAGA_ANIMATION_H
|
|
|
|
#define SAGA_ANIMATION_H
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
#include "saga/stream.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2005-07-25 02:38:43 +00:00
|
|
|
#define MAX_ANIMATIONS 10
|
2004-10-27 21:32:28 +00:00
|
|
|
#define DEFAULT_FRAME_TIME 140
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
#define SAGA_FRAME_START 0xF
|
|
|
|
#define SAGA_FRAME_END 0x3F
|
2005-07-25 02:38:43 +00:00
|
|
|
#define SAGA_FRAME_NOOP 0x1F
|
2004-12-15 00:24:12 +00:00
|
|
|
#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
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
enum AnimationState {
|
|
|
|
ANIM_PLAYING = 0x01,
|
|
|
|
ANIM_PAUSE = 0x02,
|
2005-10-01 11:39:08 +00:00
|
|
|
ANIM_STOPPING = 0x03
|
2005-10-01 11:09:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum AnimationFlags {
|
|
|
|
ANIM_FLAG_NONE = 0x00,
|
|
|
|
ANIM_FLAG_ENDSCENE = 0x01 // When animation ends, dispatch scene end event
|
2005-06-11 17:24:06 +00:00
|
|
|
};
|
|
|
|
|
2005-09-23 14:29:26 +00:00
|
|
|
// Cutaway info array member. Cutaways are basically animations with a really
|
|
|
|
// bad attitude.
|
|
|
|
struct Cutaway {
|
2005-09-24 10:13:17 +00:00
|
|
|
uint16 backgroundResourceId;
|
|
|
|
uint16 animResourceId;
|
2005-09-24 19:29:55 +00:00
|
|
|
int16 cycles;
|
2005-09-23 14:29:26 +00:00
|
|
|
int16 frameRate;
|
|
|
|
};
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Animation info array member
|
2005-06-11 17:24:06 +00:00
|
|
|
struct AnimationData {
|
|
|
|
byte *resourceData;
|
|
|
|
size_t resourceLength;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
uint16 magic;
|
|
|
|
|
|
|
|
uint16 screenWidth;
|
|
|
|
uint16 screenHeight;
|
|
|
|
|
|
|
|
byte unknown06;
|
|
|
|
byte unknown07;
|
|
|
|
|
2005-06-25 15:55:43 +00:00
|
|
|
int16 maxFrame;
|
|
|
|
int16 loopFrame;
|
2005-06-11 17:24:06 +00:00
|
|
|
|
2005-06-25 15:55:43 +00:00
|
|
|
int16 start;
|
2005-06-11 17:24:06 +00:00
|
|
|
|
2005-06-25 15:55:43 +00:00
|
|
|
int16 currentFrame;
|
2005-06-11 17:24:06 +00:00
|
|
|
size_t *frameOffsets;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-28 03:44:07 +00:00
|
|
|
uint16 completed;
|
|
|
|
uint16 cycles;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
int frameTime;
|
|
|
|
|
|
|
|
AnimationState state;
|
|
|
|
int16 linkId;
|
2004-04-30 23:02:23 +00:00
|
|
|
uint16 flags;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
AnimationData(const byte *animResourceData, size_t animResourceLength) {
|
2005-07-30 21:11:48 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2005-06-11 17:24:06 +00:00
|
|
|
resourceLength = animResourceLength;
|
|
|
|
resourceData = (byte*)malloc(animResourceLength);
|
|
|
|
memcpy(resourceData, animResourceData, animResourceLength);
|
|
|
|
}
|
|
|
|
~AnimationData() {
|
|
|
|
free(frameOffsets);
|
|
|
|
free(resourceData);
|
|
|
|
}
|
2004-07-31 13:34:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
2005-09-23 14:29:26 +00:00
|
|
|
void loadCutawayList(const byte *resourcePointer, size_t resourceLength);
|
|
|
|
void freeCutawayList(void);
|
2007-08-30 17:55:19 +00:00
|
|
|
int playCutaway(int cut, bool fade);
|
2005-09-24 19:29:55 +00:00
|
|
|
void endCutaway(void);
|
|
|
|
void returnFromCutaway(void);
|
2005-10-03 10:01:09 +00:00
|
|
|
void clearCutaway(void);
|
2005-09-23 14:29:26 +00:00
|
|
|
|
2007-06-06 19:46:10 +00:00
|
|
|
void startVideo(int vid, bool fade);
|
|
|
|
void endVideo(void);
|
|
|
|
void returnFromVideo(void);
|
|
|
|
|
2005-06-20 11:46:34 +00:00
|
|
|
void load(uint16 animId, const byte *animResourceData, size_t animResourceLength);
|
2005-06-08 19:01:19 +00:00
|
|
|
void freeId(uint16 animId);
|
2005-06-11 17:24:06 +00:00
|
|
|
void play(uint16 animId, int vectorTime, bool playing = true);
|
|
|
|
void link(int16 animId1, int16 animId2);
|
|
|
|
void setFlag(uint16 animId, uint16 flag);
|
|
|
|
void clearFlag(uint16 animId, uint16 flag);
|
|
|
|
void setFrameTime(uint16 animId, int time);
|
|
|
|
void reset(void);
|
2004-12-03 19:15:44 +00:00
|
|
|
void animInfo(void);
|
2007-06-14 23:28:30 +00:00
|
|
|
void cutawayInfo(void);
|
2005-06-11 17:24:06 +00:00
|
|
|
void setCycles(uint16 animId, int cycles);
|
2004-12-28 03:44:07 +00:00
|
|
|
void stop(uint16 animId);
|
2004-12-28 04:09:10 +00:00
|
|
|
void finish(uint16 animId);
|
|
|
|
void resume(uint16 animId, int cycles);
|
2007-06-16 14:06:17 +00:00
|
|
|
void resumeAll();
|
2005-06-11 17:24:06 +00:00
|
|
|
int16 getCurrentFrame(uint16 animId);
|
2007-08-30 17:55:19 +00:00
|
|
|
int getFrameTime(uint16 animId);
|
|
|
|
int getCycles(uint16 animId);
|
2007-08-27 10:03:23 +00:00
|
|
|
|
2005-08-04 14:49:04 +00:00
|
|
|
bool hasAnimation(uint16 animId) {
|
|
|
|
if (animId >= MAX_ANIMATIONS) {
|
2005-09-27 06:16:16 +00:00
|
|
|
if (animId < MAX_ANIMATIONS + ARRAYSIZE(_cutawayAnimations))
|
|
|
|
return (_cutawayAnimations[animId - MAX_ANIMATIONS] != NULL);
|
2005-08-04 14:49:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (_animations[animId] != NULL);
|
|
|
|
}
|
2007-08-27 10:03:23 +00:00
|
|
|
|
|
|
|
bool hasCutaway(void) { return _cutawayActive; }
|
|
|
|
void setCutAwayMode(int mode) { _cutAwayMode = mode; }
|
|
|
|
int cutawayListLength() { return _cutawayListLength; }
|
|
|
|
int cutawayBgResourceID(int cutaway) { return _cutawayList[cutaway].backgroundResourceId; }
|
|
|
|
int cutawayAnimResourceID(int cutaway) { return _cutawayList[cutaway].animResourceId; }
|
|
|
|
|
2004-07-31 13:34:43 +00:00
|
|
|
private:
|
2005-07-25 16:22:32 +00:00
|
|
|
void decodeFrame(AnimationData *anim, size_t frameOffset, byte *buf, size_t bufLength);
|
2007-08-31 10:59:33 +00:00
|
|
|
int fillFrameOffsets(AnimationData *anim, bool reallyFill = true);
|
2005-06-11 17:24:06 +00:00
|
|
|
|
|
|
|
void validateAnimationId(uint16 animId) {
|
|
|
|
if (animId >= MAX_ANIMATIONS) {
|
2005-09-27 06:16:16 +00:00
|
|
|
if (animId >= MAX_ANIMATIONS + ARRAYSIZE(_cutawayAnimations))
|
|
|
|
error("validateAnimationId: animId out of range");
|
|
|
|
if (_cutawayAnimations[animId - MAX_ANIMATIONS] == NULL) {
|
|
|
|
error("validateAnimationId: animId=%i unassigned", animId);
|
|
|
|
}
|
2005-06-11 17:24:06 +00:00
|
|
|
}
|
|
|
|
if (_animations[animId] == NULL) {
|
2007-08-30 17:55:19 +00:00
|
|
|
error("validateAnimationId: animId=%i unassigned.", animId);
|
2005-06-11 17:24:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-25 16:22:32 +00:00
|
|
|
bool isLongData() const {
|
2005-10-14 00:56:52 +00:00
|
|
|
if ((_vm->getGameType() == GType_ITE) && (_vm->getPlatform() != Common::kPlatformMacintosh)) {
|
2005-07-25 16:22:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2005-07-19 19:05:52 +00:00
|
|
|
}
|
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
AnimationData* getAnimation(uint16 animId) {
|
|
|
|
validateAnimationId(animId);
|
2005-09-27 06:16:16 +00:00
|
|
|
if (animId > MAX_ANIMATIONS)
|
|
|
|
return _cutawayAnimations[animId - MAX_ANIMATIONS];
|
2005-06-11 17:24:06 +00:00
|
|
|
return _animations[animId];
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 getAnimationCount() const {
|
|
|
|
uint16 i = 0;
|
|
|
|
for (; i < MAX_ANIMATIONS; i++) {
|
|
|
|
if (_animations[i] == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2004-07-31 23:33:14 +00:00
|
|
|
|
2004-08-01 13:34:20 +00:00
|
|
|
SagaEngine *_vm;
|
2005-06-11 17:24:06 +00:00
|
|
|
AnimationData *_animations[MAX_ANIMATIONS];
|
2005-09-27 06:16:16 +00:00
|
|
|
AnimationData *_cutawayAnimations[2];
|
2005-09-23 14:29:26 +00:00
|
|
|
Cutaway *_cutawayList;
|
2007-06-07 12:11:33 +00:00
|
|
|
PalEntry saved_pal[PAL_ENTRIES];
|
2005-09-23 14:29:26 +00:00
|
|
|
int _cutawayListLength;
|
2005-09-24 19:29:55 +00:00
|
|
|
bool _cutawayActive;
|
2007-06-07 12:11:33 +00:00
|
|
|
int _cutAwayMode;
|
|
|
|
bool _cutAwayFade;
|
2004-07-31 13:34:43 +00:00
|
|
|
};
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|
|
|
|
|
2007-07-31 18:08:40 +00:00
|
|
|
#endif // ANIMATION_H_
|