diff options
-rw-r--r-- | sword1/animation.cpp | 34 | ||||
-rw-r--r-- | sword2/driver/animation.cpp | 23 |
2 files changed, 30 insertions, 27 deletions
diff --git a/sword1/animation.cpp b/sword1/animation.cpp index 73b88221a7..00e5658dc2 100644 --- a/sword1/animation.cpp +++ b/sword1/animation.cpp @@ -26,6 +26,9 @@ #include "sword1/animation.h" +#define MOVIE_WIDTH 640 +#define MOVIE_HEIGHT 400 + namespace Sword1 { AnimationState::AnimationState(Screen *scr, SoundMixer *snd, OSystem *sys) @@ -48,9 +51,8 @@ AnimationState::~AnimationState() { #endif } -bool AnimationState::init(const char *basename) { +bool AnimationState::init(const char *name) { #ifdef USE_MPEG2 - char tempFile[512]; decoder = NULL; @@ -64,11 +66,11 @@ bool AnimationState::init(const char *basename) { // Load lookup palettes // TODO: Binary format so we can use File class - sprintf(tempFile, "%s.pal", basename); + sprintf(tempFile, "%s.pal", name); FILE *f = fopen(tempFile, "r"); if (!f) { - warning("Cutscene: %s.pal palette missing", basename); + warning("Cutscene: %s.pal palette missing", name); return false; } @@ -113,13 +115,13 @@ bool AnimationState::init(const char *basename) { lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2); #else buildLookup(); - overlay = (NewGuiColor*)calloc(640 * 400, sizeof(NewGuiColor)); + overlay = (NewGuiColor*)calloc(MOVIE_WIDTH * MOVIE_HEIGHT, sizeof(NewGuiColor)); _sys->show_overlay(); #endif // Open MPEG2 stream mpgfile = new File(); - sprintf(tempFile, "%s.mp2", basename); + sprintf(tempFile, "%s.mp2", name); if (!mpgfile->open(tempFile)) { warning("Cutscene: Could not open %s", tempFile); return false; @@ -140,14 +142,14 @@ bool AnimationState::init(const char *basename) { sndfile = new File; #ifdef USE_VORBIS - sprintf(tempFile, "%s.ogg", basename); + sprintf(tempFile, "%s.ogg", name); if (sndfile->open(tempFile)) bgSoundStream = makeVorbisStream(sndfile, sndfile->size()); #endif #ifdef USE_MAD if (!sndfile->isOpen()) { - sprintf(tempFile, "%s.mp3", basename); + sprintf(tempFile, "%s.mp3", name); if (sndfile->open(tempFile)) bgSoundStream = makeMP3Stream(sndfile, sndfile->size()); } @@ -246,9 +248,9 @@ void AnimationState::buildLookup() { for (cr = 0; cr < BITDEPTH; cr++) { for (cb = 0; cb < BITDEPTH; cb++) { for (y = 0; y < 256; y++) { - r = ((y-16) * 256 + (int) (256 * 1.596) * ((cr << SHIFT) - 128)) / 256; - g = ((y-16) * 256 - (int) (0.813 * 256) * ((cr << SHIFT) - 128) - (int) (0.391 * 256) * ((cb << SHIFT) - 128)) / 256; - b = ((y-16) * 256 + (int) (2.018 * 256) * ((cb << SHIFT) - 128)) / 256; + r = ((y - 16) * 256 + (int) (256 * 1.596) * ((cr << SHIFT) - 128)) / 256; + g = ((y - 16) * 256 - (int) (0.813 * 256) * ((cr << SHIFT) - 128) - (int) (0.391 * 256) * ((cb << SHIFT) - 128)) / 256; + b = ((y - 16) * 256 + (int) (2.018 * 256) * ((cb << SHIFT) - 128)) / 256; if (r < 0) r = 0; else if (r > 255) r = 255; @@ -265,7 +267,7 @@ void AnimationState::buildLookup() { void AnimationState::plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat) { - NewGuiColor *ptr = overlay + (400-height)/2 * 640 + (640-width)/2; + NewGuiColor *ptr = overlay + (MOVIE_HEIGHT - height) / 2 * MOVIE_WIDTH + (MOVIE_WIDTH - width) / 2; int x, y; @@ -279,16 +281,16 @@ void AnimationState::plotYUV(NewGuiColor *lut, int width, int height, byte *cons cpos++; ptr[linepos ] = lut[i + dat[0][ ypos ]]; - ptr[640 + linepos++] = lut[i + dat[0][width + ypos++]]; + ptr[MOVIE_WIDTH + linepos++] = lut[i + dat[0][width + ypos++]]; ptr[linepos ] = lut[i + dat[0][ ypos ]]; - ptr[640 + linepos++] = lut[i + dat[0][width + ypos++]]; + ptr[MOVIE_WIDTH + linepos++] = lut[i + dat[0][width + ypos++]]; } - linepos += (2 * 640 - width); + linepos += (2 * MOVIE_WIDTH - width); ypos += width; } - _sys->copy_rect_overlay(overlay, 640, 0, 40, 640, 400); + _sys->copy_rect_overlay(overlay, MOVIE_WIDTH, 0, 40, MOVIE_WIDTH, MOVIE_HEIGHT); } #endif diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp index e54b76f0de..1cd2def9f5 100644 --- a/sword2/driver/animation.cpp +++ b/sword2/driver/animation.cpp @@ -20,6 +20,10 @@ */ #include "common/stdafx.h" +#include "common/file.h" +#include "sound/vorbis.h" +#include "sound/mp3.h" + #include "sword2/sword2.h" #include "sword2/maketext.h" #include "sword2/driver/animation.h" @@ -28,10 +32,8 @@ #include "sword2/driver/menu.h" #include "sword2/driver/render.h" -#include "common/file.h" - -#include "sound/vorbis.h" -#include "sound/mp3.h" +#define MOVIE_WIDTH 640 +#define MOVIE_HEIGHT 480 namespace Sword2 { @@ -119,7 +121,7 @@ bool AnimationState::init(const char *name) { lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2); #else buildLookup(); - overlay = (NewGuiColor*)calloc(640 * 480, sizeof(NewGuiColor)); + overlay = (NewGuiColor*)calloc(MOVIE_WIDTH * MOVIE_HEIGHT, sizeof(NewGuiColor)); _vm->_system->show_overlay(); #endif @@ -235,7 +237,6 @@ bool AnimationState::checkPaletteSwitch() { return false; } - #else NewGuiColor *AnimationState::lookup = 0; @@ -273,7 +274,7 @@ void AnimationState::buildLookup() { void AnimationState::plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat) { - NewGuiColor *ptr = overlay + (480 - height) / 2 * 640 + (640 - width) / 2; + NewGuiColor *ptr = overlay + (MOVIE_HEIGHT - height) / 2 * MOVIE_WIDTH + (MOVIE_WIDTH - width) / 2; int x, y; @@ -292,7 +293,7 @@ void AnimationState::plotYUV(NewGuiColor *lut, int width, int height, byte *cons ptr[RENDERWIDE + linepos++] = lut[i + dat[0][width + ypos++]]; } - linepos += (2 * 640 - width); + linepos += (2 * MOVIE_WIDTH - width); ypos += width; } } @@ -326,12 +327,12 @@ void AnimationState::drawTextObject(SpriteInfo *s, uint8 *src) { void AnimationState::clearDisplay(void) { NewGuiColor black = _vm->_system->RGBToColor(0, 0, 0); - for (int i = 0; i < 640 * 480; i++) + for (int i = 0; i < MOVIE_WIDTH * MOVIE_HEIGHT; i++) overlay[i] = black; } void AnimationState::updateDisplay(void) { - _vm->_system->copy_rect_overlay(overlay, 640, 0, 0, 640, 480); + _vm->_system->copy_rect_overlay(overlay, MOVIE_WIDTH, 0, 0, MOVIE_WIDTH, MOVIE_HEIGHT); } #endif @@ -651,7 +652,7 @@ int32 MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], uint memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP); uint8 msg[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos"; - Memory *data = _vm->_fontRenderer->makeTextSprite(msg, 640, 255, _vm->_speechFontId); + Memory *data = _vm->_fontRenderer->makeTextSprite(msg, MOVIE_WIDTH, 255, _vm->_speechFontId); FrameHeader *frame = (FrameHeader *) data->ad; SpriteInfo msgSprite; uint8 *msgSurface; |