diff options
-rw-r--r-- | engines/sword1/animation.cpp | 17 | ||||
-rw-r--r-- | engines/sword1/animation.h | 4 | ||||
-rw-r--r-- | engines/sword2/animation.cpp | 27 | ||||
-rw-r--r-- | engines/sword2/animation.h | 4 | ||||
-rw-r--r-- | graphics/animation.cpp | 55 | ||||
-rw-r--r-- | graphics/animation.h | 5 |
6 files changed, 57 insertions, 55 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 9d0fbb7788..1697590e17 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -58,19 +58,6 @@ void AnimationState::drawYUV(int width, int height, byte *const *dat) { #endif } -void AnimationState::updateScreen(void) { -#ifndef BACKEND_8BIT - int width = _movieScale * _frameWidth; - int height = _movieScale * _frameHeight; - int pitch = _movieScale * _movieWidth; - int x = _movieScale * ((_movieWidth - _frameWidth) / 2); - int y = _movieScale * ((_movieHeight - _frameHeight) / 2); - - _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y + _movieScale * 40, width, height); -#endif - _sys->updateScreen(); -} - OverlayColor *AnimationState::giveRgbBuffer(void) { #ifdef BACKEND_8BIT return NULL; @@ -153,11 +140,9 @@ void MoviePlayer::play(uint32 id) { OSystem::Event event; while (_sys->pollEvent(event)) { switch (event.type) { -#ifndef BACKEND_8BIT case OSystem::EVENT_SCREEN_CHANGED: - anim->buildLookup(); + anim->screenChanged(); break; -#endif case OSystem::EVENT_KEYDOWN: if (event.kbd.keycode == 27) { delete anim; diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h index 6e1fa11c3d..f49245153b 100644 --- a/engines/sword1/animation.h +++ b/engines/sword1/animation.h @@ -61,13 +61,9 @@ class AnimationState : public Graphics::BaseAnimationState { private: Screen *_scr; - int _frameWidth; - int _frameHeight; - public: AnimationState(Screen *scr, Audio::Mixer *snd, OSystem *sys); ~AnimationState(); - void updateScreen(); OverlayColor *giveRgbBuffer(void); bool soundFinished(); diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index e8d17e88b0..b1ad009a86 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -114,29 +114,6 @@ void AnimationState::clearScreen() { #endif } -void AnimationState::updateScreen() { - int x, y; - - x = (_movieWidth - _frameWidth) / 2; - y = (_movieHeight - _frameHeight) / 2; - -#ifdef BACKEND_8BIT - byte *buf = _vm->_screen->getScreen() + y * RENDERWIDE + x; - - _vm->_system->copyRectToScreen(buf, _movieWidth, (640 - _movieWidth) / 2, (480 - _movieHeight) / 2, _movieWidth, _movieHeight); -#else - int width = _movieScale * _frameWidth; - int height = _movieScale * _frameHeight; - int pitch = _movieScale * _movieWidth; - - x *= _movieScale; - y *= _movieScale; - - _sys->copyRectToOverlay(_overlay + y * pitch + x, pitch, x, y, width, height); -#endif - _vm->_system->updateScreen(); -} - void AnimationState::drawYUV(int width, int height, byte *const *dat) { _frameWidth = width; _frameHeight = height; @@ -350,11 +327,9 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte * OSystem::Event event; while (_sys->pollEvent(event)) { switch (event.type) { -#ifndef BACKEND_8BIT case OSystem::EVENT_SCREEN_CHANGED: - anim->buildLookup(); + anim->screenChanged(); break; -#endif case OSystem::EVENT_KEYDOWN: if (event.kbd.keycode == 27) skipCutscene = true; diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h index 960721b8a1..32598c013d 100644 --- a/engines/sword2/animation.h +++ b/engines/sword2/animation.h @@ -45,9 +45,6 @@ class AnimationState : public ::Graphics::BaseAnimationState { private: Sword2Engine *_vm; - int _frameWidth; - int _frameHeight; - public: AnimationState(Sword2Engine *vm); ~AnimationState(); @@ -57,7 +54,6 @@ public: #endif void clearScreen(); - void updateScreen(); private: void drawYUV(int width, int height, byte *const *dat); diff --git a/graphics/animation.cpp b/graphics/animation.cpp index 731fe595e7..dcf39609f4 100644 --- a/graphics/animation.cpp +++ b/graphics/animation.cpp @@ -39,7 +39,7 @@ BaseAnimationState::BaseAnimationState(Audio::Mixer *snd, OSystem *sys, int widt _movieScale = MIN(screenW / _movieWidth, screenH / _movieHeight); - assert (_movieScale >= 1); + assert(_movieScale >= 1); if (_movieScale > 3) _movieScale = 3; @@ -125,7 +125,7 @@ bool BaseAnimationState::init(const char *name, void *audioArg) { _lutCalcNum = (BITDEPTH + _palettes[_palNum].end + 2) / (_palettes[_palNum].end + 2); #else buildLookup(); - _overlay = (OverlayColor*)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor)); + _overlay = (OverlayColor *)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor)); _sys->showOverlay(); #endif @@ -255,6 +255,34 @@ bool BaseAnimationState::checkPaletteSwitch() { return false; } +void BaseAnimationState::screenChanged() { +#ifndef BACKEND_8BIT + const int screenW = _sys->getOverlayWidth(); + const int screenH = _sys->getOverlayHeight(); + + int newScale = MIN(screenW / _movieWidth, screenH / _movieHeight); + + assert(newScale >= 1); + if (newScale > 3) + newScale = 3; + + if (newScale != _movieScale) { + // HACK: Since frames generally do not cover the entire screen, + // We need to undraw the old frame. This is a very hacky + // way of doing that. + OverlayColor *buf = (OverlayColor *)calloc(screenW * screenH, sizeof(OverlayColor)); + _sys->copyRectToOverlay(buf, screenW, 0, 0, screenW, screenH); + free(buf); + + free(_overlay); + _movieScale = newScale; + _overlay = (OverlayColor *)calloc(_movieScale * _movieWidth * _movieScale * _movieHeight, sizeof(OverlayColor)); + } + + buildLookup(); +#endif +} + #ifdef BACKEND_8BIT /** @@ -445,7 +473,7 @@ void BaseAnimationState::plotYUV(int width, int height, byte *const *dat) { } void BaseAnimationState::plotYUV1x(int width, int height, byte *const *dat) { - OverlayColor *ptr = _overlay + _movieWidth * (_movieHeight - height) / 2 + (_movieWidth - width) / 2; + OverlayColor *ptr = _overlay; byte *lum = dat[0]; byte *cr = dat[2]; @@ -498,7 +526,7 @@ void BaseAnimationState::plotYUV1x(int width, int height, byte *const *dat) { } void BaseAnimationState::plotYUV2x(int width, int height, byte *const *dat) { - OverlayColor *ptr = _overlay + 2 * _movieWidth * (_movieHeight - height) + _movieWidth - width; + OverlayColor *ptr = _overlay; byte *lum = dat[0]; byte *cr = dat[2]; @@ -563,7 +591,7 @@ void BaseAnimationState::plotYUV2x(int width, int height, byte *const *dat) { } void BaseAnimationState::plotYUV3x(int width, int height, byte *const *dat) { - OverlayColor *ptr = _overlay + (3 * (_movieHeight - height) / 2) * 3 * _movieWidth + 3 * (_movieWidth - width ) / 2; + OverlayColor *ptr = _overlay; byte *lum = dat[0]; byte *cr = dat[2]; @@ -633,6 +661,23 @@ void BaseAnimationState::plotYUV3x(int width, int height, byte *const *dat) { } } +void BaseAnimationState::updateScreen() { +#ifndef BACKEND_8BIT + int width = _movieScale * _frameWidth; + int height = _movieScale * _frameHeight; + int pitch = _movieScale * _movieWidth; + + const int screenW = _sys->getOverlayWidth(); + const int screenH = _sys->getOverlayHeight(); + + int x = (screenW - _movieScale * _frameWidth) / 2; + int y = (screenH - _movieScale * _frameHeight) / 2; + + _sys->copyRectToOverlay(_overlay, pitch, x, y, width, height); +#endif + _sys->updateScreen(); +} + #endif } // End of namespace Graphics diff --git a/graphics/animation.h b/graphics/animation.h index 42c1c899f3..aa36369974 100644 --- a/graphics/animation.h +++ b/graphics/animation.h @@ -78,6 +78,9 @@ protected: const int _movieWidth; const int _movieHeight; + int _frameWidth; + int _frameHeight; + #ifndef BACKEND_8BIT int _movieScale; #endif @@ -130,6 +133,8 @@ public: bool init(const char *name, void *audioArg = NULL); bool decodeFrame(); + void screenChanged(); + void updateScreen(); #ifndef BACKEND_8BIT void buildLookup(); |