mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 07:53:12 +00:00
Added support for DXA cutscenes, while still retaining support for the old MPEG
cutscenes and the "dummy" (subtitles and voice-over) mode. Several tweaks and cleanups were made in this process, and there may very well be regressions, but it should be stable enough to commit. svn-id: r23420
This commit is contained in:
parent
6ed462e06f
commit
5658e71f4d
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@
|
||||
#define SWORD2_ANIMATION_H
|
||||
|
||||
#include "graphics/animation.h"
|
||||
#include "graphics/dxa_player.h"
|
||||
#include "sound/mixer.h"
|
||||
|
||||
namespace Sword2 {
|
||||
@ -41,12 +42,97 @@ struct MovieTextObject {
|
||||
uint16 *speech;
|
||||
};
|
||||
|
||||
struct MovieInfo {
|
||||
const char *name;
|
||||
const uint frames;
|
||||
const bool seamless;
|
||||
};
|
||||
|
||||
class MoviePlayer {
|
||||
protected:
|
||||
Sword2Engine *_vm;
|
||||
Audio::Mixer *_mixer;
|
||||
OSystem *_system;
|
||||
|
||||
byte _originalPalette[4 * 256];
|
||||
|
||||
byte *_textSurface;
|
||||
|
||||
Audio::SoundHandle _speechHandle;
|
||||
Audio::SoundHandle _bgSoundHandle;
|
||||
Audio::AudioStream *_bgSoundStream;
|
||||
|
||||
uint32 _ticks;
|
||||
|
||||
uint _currentFrame;
|
||||
byte *_frameBuffer;
|
||||
int _frameWidth, _frameHeight;
|
||||
int _frameX, _frameY;
|
||||
|
||||
byte _black, _white;
|
||||
|
||||
uint _numFrames;
|
||||
uint _leadOutFrame;
|
||||
bool _seamless;
|
||||
|
||||
int _framesSkipped;
|
||||
bool _forceFrame;
|
||||
|
||||
static struct MovieInfo _movies[];
|
||||
|
||||
MovieTextObject **_textList;
|
||||
int _currentText;
|
||||
|
||||
void savePalette();
|
||||
void restorePalette();
|
||||
|
||||
void openTextObject(MovieTextObject *t);
|
||||
void closeTextObject(MovieTextObject *t);
|
||||
|
||||
virtual void handleScreenChanged() {}
|
||||
|
||||
virtual void clearScreen();
|
||||
virtual void updateScreen();
|
||||
virtual bool decodeFrame() = 0;
|
||||
virtual bool checkSkipFrame();
|
||||
virtual void waitForFrame();
|
||||
virtual void drawFrame();
|
||||
virtual void drawTextObject(MovieTextObject *t);
|
||||
virtual void undrawTextObject(MovieTextObject *t);
|
||||
|
||||
public:
|
||||
MoviePlayer(Sword2Engine *vm);
|
||||
virtual ~MoviePlayer();
|
||||
|
||||
void updatePalette(byte *pal, bool packed = true);
|
||||
virtual bool load(const char *name, MovieTextObject *text[]);
|
||||
void play(int32 leadIn, int32 leadOut);
|
||||
};
|
||||
|
||||
class MoviePlayerDummy : public MoviePlayer {
|
||||
protected:
|
||||
virtual bool decodeFrame();
|
||||
virtual bool checkSkipFrame();
|
||||
virtual void waitForFrame();
|
||||
virtual void drawFrame();
|
||||
virtual void drawTextObject(MovieTextObject *t);
|
||||
virtual void undrawTextObject(MovieTextObject *t);
|
||||
|
||||
public:
|
||||
MoviePlayerDummy(Sword2Engine *vm);
|
||||
virtual ~MoviePlayerDummy();
|
||||
|
||||
virtual bool load(const char *name, MovieTextObject *text[]);
|
||||
};
|
||||
|
||||
#ifdef USE_MPEG2
|
||||
class AnimationState : public ::Graphics::BaseAnimationState {
|
||||
private:
|
||||
Sword2Engine *_vm;
|
||||
MoviePlayer *_player;
|
||||
|
||||
public:
|
||||
AnimationState(Sword2Engine *vm);
|
||||
AnimationState(Sword2Engine *vm, MoviePlayer *player);
|
||||
~AnimationState();
|
||||
|
||||
#ifndef BACKEND_8BIT
|
||||
@ -63,38 +149,45 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
struct MovieInfo {
|
||||
char name[9];
|
||||
uint frames;
|
||||
bool seamless;
|
||||
};
|
||||
class MoviePlayerMPEG : public MoviePlayer {
|
||||
protected:
|
||||
AnimationState *_anim;
|
||||
|
||||
class MoviePlayer {
|
||||
private:
|
||||
Sword2Engine *_vm;
|
||||
Audio::Mixer *_snd;
|
||||
OSystem *_sys;
|
||||
virtual bool checkSkipFrame();
|
||||
virtual void waitForFrame();
|
||||
virtual bool decodeFrame();
|
||||
|
||||
byte *_textSurface;
|
||||
|
||||
Audio::SoundHandle _leadOutHandle;
|
||||
|
||||
uint _leadOutFrame;
|
||||
bool _seamless;
|
||||
|
||||
static struct MovieInfo _movies[];
|
||||
|
||||
void openTextObject(MovieTextObject *obj);
|
||||
void closeTextObject(MovieTextObject *obj);
|
||||
void drawTextObject(AnimationState *anim, MovieTextObject *obj);
|
||||
|
||||
void playMPEG(const char *filename, MovieTextObject *text[], byte *leadOut, uint32 leadOutLen);
|
||||
void playDummy(const char *filename, MovieTextObject *text[], byte *leadOut, uint32 leadOutLen);
|
||||
#ifndef BACKEND_8BIT
|
||||
virtual void handleScreenChanged();
|
||||
virtual void clearScreen();
|
||||
virtual void drawFrame();
|
||||
virtual void updateScreen();
|
||||
virtual void drawTextObject(MovieTextObject *t);
|
||||
#endif
|
||||
|
||||
public:
|
||||
MoviePlayer(Sword2Engine *vm);
|
||||
int32 play(const char *filename, MovieTextObject *text[], int32 leadInRes, int32 leadOutRes);
|
||||
MoviePlayerMPEG(Sword2Engine *vm);
|
||||
virtual ~MoviePlayerMPEG();
|
||||
|
||||
virtual bool load(const char *name, MovieTextObject *text[]);
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef USE_ZLIB
|
||||
class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer {
|
||||
protected:
|
||||
virtual void setPalette(byte *pal);
|
||||
virtual bool decodeFrame();
|
||||
|
||||
public:
|
||||
MoviePlayerDXA(Sword2Engine *vm);
|
||||
virtual ~MoviePlayerDXA();
|
||||
|
||||
virtual bool load(const char *name, MovieTextObject *text[]);
|
||||
};
|
||||
#endif
|
||||
|
||||
MoviePlayer *makeMoviePlayer(Sword2Engine *vm, const char *name);
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
||||
|
@ -2131,17 +2131,13 @@ int32 Logic::fnPlaySequence(int32 *params) {
|
||||
// pause sfx during sequence
|
||||
_vm->_sound->pauseFx();
|
||||
|
||||
MoviePlayer player(_vm);
|
||||
uint32 rv;
|
||||
MoviePlayer *player = makeMoviePlayer(_vm, filename);
|
||||
|
||||
if (_sequenceTextLines && !readVar(DEMO))
|
||||
rv = player.play(filename, sequenceSpeechArray, _smackerLeadIn, _smackerLeadOut);
|
||||
else
|
||||
rv = player.play(filename, NULL, _smackerLeadIn, _smackerLeadOut);
|
||||
if (player->load(filename, (_sequenceTextLines && !readVar(DEMO)) ? sequenceSpeechArray : NULL)) {
|
||||
player->play(_smackerLeadIn, _smackerLeadOut);
|
||||
}
|
||||
|
||||
// check the error return-value
|
||||
if (rv)
|
||||
debug(5, "MoviePlayer.play(\"%s\") returned 0x%.8x", filename, rv);
|
||||
delete player;
|
||||
|
||||
// unpause sound fx again, in case we're staying in same location
|
||||
_vm->_sound->unpauseFx();
|
||||
|
@ -29,10 +29,6 @@
|
||||
#include "sword2/defs.h"
|
||||
#include "sword2/screen.h"
|
||||
|
||||
#ifdef BACKEND_8BIT
|
||||
#include "sword2/animation.h"
|
||||
#endif
|
||||
|
||||
namespace Sword2 {
|
||||
|
||||
#define MILLISECSPERCYCLE 83
|
||||
@ -555,31 +551,4 @@ void Screen::closeBackgroundLayer() {
|
||||
_layer = 0;
|
||||
}
|
||||
|
||||
#ifdef BACKEND_8BIT
|
||||
void Screen::plotYUV(byte *lut, int width, int height, byte *const *dat) {
|
||||
byte *buf = _buffer + ((480 - height) / 2) * RENDERWIDE + (640 - width) / 2;
|
||||
|
||||
int x, y;
|
||||
|
||||
int ypos = 0;
|
||||
int cpos = 0;
|
||||
int linepos = 0;
|
||||
|
||||
for (y = 0; y < height; y += 2) {
|
||||
for (x = 0; x < width; x += 2) {
|
||||
int i = ((((dat[2][cpos] + ROUNDADD) >> SHIFT) * (BITDEPTH + 1)) + ((dat[1][cpos] + ROUNDADD) >> SHIFT)) * (BITDEPTH + 1);
|
||||
cpos++;
|
||||
|
||||
buf[linepos ] = lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
|
||||
buf[RENDERWIDE + linepos++] = lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
|
||||
buf[linepos ] = lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
|
||||
buf[RENDERWIDE + linepos++] = lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
|
||||
}
|
||||
linepos += (2 * RENDERWIDE - width);
|
||||
ypos += width;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} // End of namespace Sword2
|
||||
|
@ -428,10 +428,6 @@ public:
|
||||
void plotPoint(int x, int y, uint8 colour);
|
||||
void drawLine(int x0, int y0, int x1, int y1, uint8 colour);
|
||||
|
||||
#ifdef BACKEND_8BIT
|
||||
void plotYUV(byte *lut, int width, int height, byte *const *dat);
|
||||
#endif
|
||||
|
||||
void rollCredits();
|
||||
void splashScreen();
|
||||
};
|
||||
|
@ -141,6 +141,9 @@ public:
|
||||
void buildLookup();
|
||||
#endif
|
||||
|
||||
int getFrameWidth() { return _frameWidth; }
|
||||
int getFrameHeight() { return _frameHeight; }
|
||||
|
||||
protected:
|
||||
bool checkPaletteSwitch();
|
||||
virtual void drawYUV(int width, int height, byte *const *dat) = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user