2004-01-13 01:26:18 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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-01-12 11:11:19 +00:00
|
|
|
#ifndef ANIMATION_H
|
|
|
|
#define ANIMATION_H
|
|
|
|
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
2004-01-14 08:14:25 +00:00
|
|
|
// Uncomment this if you are using libmpeg2 0.3.1.
|
|
|
|
// #define USE_MPEG2_0_3_1
|
|
|
|
|
2004-01-17 09:15:42 +00:00
|
|
|
#ifdef _MSC_VER
|
2004-01-30 20:47:21 +00:00
|
|
|
typedef int8 int8_t;
|
2004-01-17 09:15:42 +00:00
|
|
|
typedef signed short int16_t;
|
2004-01-30 20:47:21 +00:00
|
|
|
typedef int32 int32_t;
|
2004-01-17 09:15:42 +00:00
|
|
|
|
2004-01-30 20:47:21 +00:00
|
|
|
typedef uint8 uint8_t;
|
|
|
|
typedef uint16 uint16_t;
|
|
|
|
typedef uint32 uint32_t;
|
2004-01-17 09:15:42 +00:00
|
|
|
#else
|
2004-01-12 23:41:05 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
2004-01-14 08:14:25 +00:00
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
#ifdef USE_MPEG2
|
|
|
|
extern "C" {
|
|
|
|
#include <mpeg2dec/mpeg2.h>
|
|
|
|
}
|
2004-01-14 08:14:25 +00:00
|
|
|
|
|
|
|
#ifdef USE_MPEG2_0_3_1
|
|
|
|
typedef int mpeg2_state_t;
|
|
|
|
typedef sequence_t mpeg2_sequence_t;
|
|
|
|
#define STATE_BUFFER -1
|
|
|
|
#endif
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Sword2 {
|
|
|
|
|
|
|
|
|
2004-01-17 14:20:32 +00:00
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
#define SQR(x) ((x) * (x))
|
2004-01-12 11:11:19 +00:00
|
|
|
#define SHIFT 3
|
2004-01-17 14:20:32 +00:00
|
|
|
#else
|
|
|
|
#define SHIFT 1
|
|
|
|
#endif
|
|
|
|
|
2004-01-12 19:08:04 +00:00
|
|
|
#define BITDEPTH (1 << (8 - SHIFT))
|
|
|
|
#define ROUNDADD (1 << (SHIFT - 1))
|
2004-01-12 11:11:19 +00:00
|
|
|
|
|
|
|
#define BUFFER_SIZE 4096
|
|
|
|
|
2004-01-13 01:26:18 +00:00
|
|
|
class AnimationState {
|
2004-01-13 14:16:40 +00:00
|
|
|
private:
|
|
|
|
Sword2Engine *_vm;
|
|
|
|
|
2004-02-12 16:55:18 +00:00
|
|
|
uint framenum;
|
2004-01-18 05:52:04 +00:00
|
|
|
int ticks;
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
#ifdef USE_MPEG2
|
|
|
|
mpeg2dec_t *decoder;
|
|
|
|
const mpeg2_info_t *info;
|
|
|
|
#endif
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
File *mpgfile;
|
2004-01-13 13:12:40 +00:00
|
|
|
File *sndfile;
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2004-01-17 14:20:32 +00:00
|
|
|
byte buffer[BUFFER_SIZE];
|
|
|
|
|
|
|
|
PlayingSoundHandle bgSound;
|
|
|
|
AudioStream *bgSoundStream;
|
|
|
|
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
int palnum;
|
|
|
|
int maxPalnum;
|
|
|
|
|
|
|
|
byte lookup[2][BITDEPTH * BITDEPTH * BITDEPTH];
|
|
|
|
byte *lut;
|
|
|
|
byte *lut2;
|
|
|
|
int lutcalcnum;
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
int curpal;
|
|
|
|
int cr;
|
|
|
|
int pos;
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
struct {
|
2004-02-12 16:55:18 +00:00
|
|
|
uint cnt;
|
|
|
|
uint end;
|
2004-01-13 10:09:53 +00:00
|
|
|
byte pal[4 * 256];
|
|
|
|
} palettes[50];
|
2004-01-17 14:20:32 +00:00
|
|
|
#else
|
2004-01-30 20:57:23 +00:00
|
|
|
static NewGuiColor *lookup;
|
2004-01-30 20:47:21 +00:00
|
|
|
NewGuiColor *overlay;
|
2004-01-17 14:20:32 +00:00
|
|
|
#endif
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2004-01-13 01:26:18 +00:00
|
|
|
public:
|
2004-01-17 14:20:32 +00:00
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
AnimationState(Sword2Engine *vm);
|
|
|
|
~AnimationState();
|
|
|
|
|
|
|
|
bool init(const char *name);
|
|
|
|
bool decodeFrame();
|
|
|
|
|
2004-01-18 21:09:57 +00:00
|
|
|
#ifndef BACKEND_8BIT
|
|
|
|
void drawTextObject(SpriteInfo *s, uint8 *src);
|
2004-02-14 10:37:21 +00:00
|
|
|
void clearDisplay();
|
2004-01-18 21:09:57 +00:00
|
|
|
void updateDisplay(void);
|
|
|
|
#endif
|
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
private:
|
2004-01-17 14:20:32 +00:00
|
|
|
|
|
|
|
#ifdef BACKEND_8BIT
|
2004-01-13 01:26:18 +00:00
|
|
|
void buildLookup(int p, int lines);
|
2004-01-17 14:20:32 +00:00
|
|
|
bool checkPaletteSwitch();
|
|
|
|
#else
|
2004-01-30 20:57:23 +00:00
|
|
|
void buildLookup(void);
|
2004-01-17 14:20:32 +00:00
|
|
|
void plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat);
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
};
|
2004-01-13 01:26:18 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
class MoviePlayer {
|
|
|
|
private:
|
|
|
|
Sword2Engine *_vm;
|
|
|
|
uint8 *_textSurface;
|
|
|
|
|
|
|
|
void openTextObject(MovieTextObject *obj);
|
|
|
|
void closeTextObject(MovieTextObject *obj);
|
2004-01-18 21:09:57 +00:00
|
|
|
void drawTextObject(AnimationState *anim, MovieTextObject *obj);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-01-13 14:22:29 +00:00
|
|
|
int32 playDummy(const char *filename, MovieTextObject *text[], uint8 *musicOut);
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
public:
|
|
|
|
MoviePlayer(Sword2Engine *vm) : _vm(vm), _textSurface(NULL) {}
|
|
|
|
int32 play(const char *filename, MovieTextObject *text[], uint8 *musicOut);
|
2004-01-13 01:26:18 +00:00
|
|
|
};
|
2004-01-12 11:11:19 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword2
|
|
|
|
|
|
|
|
#endif
|