From 4f9576e033afe20b8de37cff761dd9b08286e63e Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 23 Aug 2006 21:13:11 +0000 Subject: The DXA player now bases subtitle position on screen size, rather than frame size. This should help people who want to use the smaller, low-quality cutscenes instead of the high-quality ones. The MPEG player probably doesn't know this trick. Maybe later. svn-id: r23742 --- engines/sword2/animation.cpp | 49 ++++++++++++++++++++++++++++++++++++++------ engines/sword2/animation.h | 36 +++++++++++++++++--------------- 2 files changed, 62 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index aac61bacfb..9f134621ec 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -219,11 +219,20 @@ void MoviePlayer::closeTextObject(MovieTextObject *t) { } } +void MoviePlayer::calcTextPosition(MovieTextObject *t, int &xPos, int &yPos) { + xPos = 320 - t->textSprite->w / 2; + yPos = 420 - t->textSprite->h; +} + void MoviePlayer::drawTextObject(MovieTextObject *t) { if (t->textSprite && _textSurface) { int screenWidth = _vm->_screen->getScreenWide(); byte *src = t->textSprite->data; - byte *dst = _frameBuffer + (_frameY + _frameHeight - t->textSprite->h - 20) * screenWidth + _frameX + (_frameWidth - t->textSprite->w) / 2; + int xPos, yPos; + + calcTextPosition(t, xPos, yPos); + + byte *dst = _frameBuffer + yPos * screenWidth + xPos; for (int y = 0; y < t->textSprite->h; y++) { for (int x = 0; x < t->textSprite->w; x++) { @@ -235,10 +244,32 @@ void MoviePlayer::drawTextObject(MovieTextObject *t) { src += t->textSprite->w; dst += screenWidth; } + + if (yPos + t->textSprite->h > _frameY + _frameHeight || t->textSprite->w > _frameWidth) { + _system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, t->textSprite->w, t->textSprite->h); + } } } void MoviePlayer::undrawTextObject(MovieTextObject *t) { + int xPos, yPos; + + calcTextPosition(t, xPos, yPos); + + // We only need to undraw the text if it's outside the frame. Otherwise + // the next frame will cover the old text anyway. + + if (yPos + t->textSprite->h > _frameY + _frameHeight || t->textSprite->w > _frameWidth) { + int screenWidth = _vm->_screen->getScreenWide(); + byte *dst = _frameBuffer + yPos * screenWidth + xPos; + + for (int y = 0; y < t->textSprite->h; y++) { + memset(dst, 0, t->textSprite->w); + dst += screenWidth; + } + + _system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, t->textSprite->w, t->textSprite->h); + } } bool MoviePlayer::load(const char *name, MovieTextObject *text[]) { @@ -398,11 +429,6 @@ void MoviePlayer::play(int32 leadIn, int32 leadOut) { updateScreen(); } - // The current text object may still be open - if (_textList && _textList[_currentText]) { - closeTextObject(_textList[_currentText]); - } - if (!terminate) { // Wait for the voice and sound track to stop playing. This is // to make sure that we don't cut off the speech in @@ -417,6 +443,12 @@ void MoviePlayer::play(int32 leadIn, int32 leadOut) { _mixer->stopHandle(_bgSoundHandle); } + // The current text object may still be open + if (_textList && _textList[_currentText]) { + undrawTextObject(_textList[_currentText]); + closeTextObject(_textList[_currentText]); + } + if (!_seamless) { clearFrame(); drawFrame(); @@ -575,6 +607,11 @@ void MoviePlayerMPEG::drawTextObject(MovieTextObject *t) { } } +void MoviePlayerMPEG::undrawTextObject(MovieTextObject *t) { + // As long as we only have subtitles for full-sized cutscenes, we don't + // really need to implement this function. +} + void AnimationState::drawTextObject(SpriteInfo *s, byte *src) { int moviePitch = _movieScale * _movieWidth; int textX = _movieScale * s->x; diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h index 57393c6521..337ee2b630 100644 --- a/engines/sword2/animation.h +++ b/engines/sword2/animation.h @@ -91,6 +91,7 @@ protected: void openTextObject(MovieTextObject *t); void closeTextObject(MovieTextObject *t); + void calcTextPosition(MovieTextObject *t, int &xPos, int &yPos); virtual void handleScreenChanged() {} @@ -113,17 +114,17 @@ public: class MoviePlayerDummy : public MoviePlayer { protected: - virtual bool decodeFrame(); - virtual void syncFrame(); - virtual void drawFrame(); - virtual void drawTextObject(MovieTextObject *t); - virtual void undrawTextObject(MovieTextObject *t); + bool decodeFrame(); + void syncFrame(); + void drawFrame(); + void drawTextObject(MovieTextObject *t); + void undrawTextObject(MovieTextObject *t); public: MoviePlayerDummy(Sword2Engine *vm); virtual ~MoviePlayerDummy(); - virtual bool load(const char *name, MovieTextObject *text[]); + bool load(const char *name, MovieTextObject *text[]); }; #ifdef USE_MPEG2 @@ -158,32 +159,33 @@ protected: virtual void syncFrame(); #ifndef BACKEND_8BIT - virtual void handleScreenChanged(); - virtual void clearFrame(); - virtual void drawFrame(); - virtual void updateScreen(); - virtual void drawTextObject(MovieTextObject *t); + void handleScreenChanged(); + void clearFrame(); + void drawFrame(); + void updateScreen(); + void drawTextObject(MovieTextObject *t); + void undrawTextObject(MovieTextObject *t); #endif public: MoviePlayerMPEG(Sword2Engine *vm); - virtual ~MoviePlayerMPEG(); + ~MoviePlayerMPEG(); - virtual bool load(const char *name, MovieTextObject *text[]); + 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(); + void setPalette(byte *pal); + bool decodeFrame(); public: MoviePlayerDXA(Sword2Engine *vm); - virtual ~MoviePlayerDXA(); + ~MoviePlayerDXA(); - virtual bool load(const char *name, MovieTextObject *text[]); + bool load(const char *name, MovieTextObject *text[]); }; #endif -- cgit v1.2.3