Ticket #7492: bs1-dxa.diff
File bs1-dxa.diff, 20.6 KB (added by , 18 years ago) |
---|
-
engines/sword1/animation.h
24 24 #define ANIMATION_H 25 25 26 26 #include "graphics/animation.h" 27 #include "graphics/dxa_player.h" 27 28 28 29 #include "sword1/screen.h" 29 30 #include "sword1/sound.h" … … 57 58 #define INTRO_LOGO_OVLS 12 58 59 #define INTRO_TEXT_OVLS 8 59 60 61 class MoviePlayer { 62 public: 63 MoviePlayer(Screen *scr, Audio::Mixer *snd, OSystem *sys); 64 virtual ~MoviePlayer(void); 65 virtual bool load(uint32 id); 66 void play(void); 67 void updatePalette(byte *pal, bool packed = true); 68 private: 69 bool checkSkipFrame(void); 70 protected: 71 Screen *_scr; 72 Audio::Mixer *_snd; 73 OSystem *_sys; 74 75 uint32 _id; 76 77 byte *_frameBuffer; 78 uint _currentFrame; 79 int _framesSkipped; 80 bool _forceFrame; 81 82 int _frameWidth, _frameHeight; 83 int _frameX, _frameY; 84 85 Audio::SoundHandle _bgSoundHandle; 86 Audio::AudioStream *_bgSoundStream; 87 uint32 _ticks; 88 89 virtual void handleScreenChanged(void); 90 virtual bool initOverlays(uint32 id); 91 virtual bool decodeFrame(void) = 0; 92 virtual void processFrame(void) = 0; 93 virtual void syncFrame(void); 94 virtual void updateScreen(void) = 0; 95 }; 96 97 #ifdef USE_ZLIB 98 99 class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer { 100 protected: 101 virtual void setPalette(byte *pal); 102 public: 103 MoviePlayerDXA(Screen *scr, Audio::Mixer *snd, OSystem *sys); 104 virtual ~MoviePlayerDXA(void); 105 bool load(uint32 id); 106 protected: 107 bool initOverlays(uint32 id); 108 bool decodeFrame(void); 109 void processFrame(void); 110 void updateScreen(void); 111 }; 112 113 #endif 114 115 #ifdef USE_MPEG2 116 60 117 class AnimationState : public Graphics::BaseAnimationState { 61 118 private: 119 MoviePlayer *_player; 62 120 Screen *_scr; 63 121 64 122 public: 65 AnimationState( Screen *scr, Audio::Mixer *snd, OSystem *sys);66 ~AnimationState( );123 AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys); 124 ~AnimationState(void); 67 125 OverlayColor *giveRgbBuffer(void); 68 bool soundFinished();69 126 70 127 private: 71 128 void drawYUV(int width, int height, byte *const *dat); … … 78 135 virtual Audio::AudioStream *createAudioStream(const char *name, void *arg); 79 136 }; 80 137 81 class MoviePlayer {138 class MoviePlayerMPEG : public MoviePlayer { 82 139 public: 83 MoviePlayer (Screen *scr, Audio::Mixer *snd, OSystem *sys);84 ~MoviePlayer(void);85 void play(uint32 id);86 pr ivate:140 MoviePlayerMPEG(Screen *scr, Audio::Mixer *snd, OSystem *sys); 141 virtual ~MoviePlayerMPEG(void); 142 bool load(uint32 id); 143 protected: 87 144 void insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor *pal); 88 void processFrame(uint32 animId, AnimationState *anim, uint32 frameNo); 145 AnimationState *_anim; 146 OverlayColor *_introPal; 147 uint8 *_logoOvls[INTRO_LOGO_OVLS]; 148 89 149 bool initOverlays(uint32 id); 90 Screen *_scr; 91 Audio::Mixer *_snd; 92 OSystem *_sys; 93 94 static const char *_sequenceList[20]; 95 uint8 *_logoOvls[INTRO_LOGO_OVLS]; 96 OverlayColor *_introPal; 150 bool decodeFrame(void); 151 void processFrame(void); 152 void syncFrame(void); 153 void updateScreen(void); 154 void handleScreenChanged(void); 97 155 }; 98 156 157 #endif 158 99 159 struct FileQueue { 100 160 Audio::AudioStream *stream; 101 161 FileQueue *next; … … 114 174 FileQueue *_queue; 115 175 }; 116 176 177 MoviePlayer *makeMoviePlayer(uint32 id, Screen *scr, Audio::Mixer *snd, OSystem *sys); 178 117 179 } // End of namespace Sword1 118 180 119 181 #endif -
engines/sword1/animation.cpp
28 28 #include "sound/vorbis.h" 29 29 30 30 #include "common/config-manager.h" 31 #include "common/endian.h" 31 32 #include "common/str.h" 32 33 #include "common/system.h" 33 34 34 35 namespace Sword1 { 35 36 36 AnimationState::AnimationState(Screen *scr, Audio::Mixer *snd, OSystem *sys) 37 : BaseAnimationState(snd, sys, 640, 400), _scr(scr) { 38 } 37 static const char *sequenceList[20] = { 38 "ferrari", // 0 CD2 ferrari running down fitz in sc19 39 "ladder", // 1 CD2 george walking down ladder to dig sc24->sc$ 40 "steps", // 2 CD2 george walking down steps sc23->sc24 41 "sewer", // 3 CD1 george entering sewer sc2->sc6 42 "intro", // 4 CD1 intro sequence ->sc1 43 "river", // 5 CD1 george being thrown into river by flap & g$ 44 "truck", // 6 CD2 truck arriving at bull's head sc45->sc53/4 45 "grave", // 7 BOTH george's grave in scotland, from sc73 + from sc38 $ 46 "montfcon", // 8 CD2 monfaucon clue in ireland dig, sc25 47 "tapestry", // 9 CD2 tapestry room beyond spain well, sc61 48 "ireland", // 10 CD2 ireland establishing shot europe_map->sc19 49 "finale", // 11 CD2 grand finale at very end, from sc73 50 "history", // 12 CD1 George's history lesson from Nico, in sc10 51 "spanish", // 13 CD2 establishing shot for 1st visit to Spain, europe_m$ 52 "well", // 14 CD2 first time being lowered down well in Spai$ 53 "candle", // 15 CD2 Candle burning down in Spain mausoleum sc59 54 "geodrop", // 16 CD2 from sc54, George jumping down onto truck 55 "vulture", // 17 CD2 from sc54, vultures circling George's dead body 56 "enddemo", // 18 --- for end of single CD demo 57 "credits", // 19 CD2 credits, to follow "finale" sequence 58 }; 39 59 40 AnimationState::~AnimationState() { 41 } 60 /////////////////////////////////////////////////////////////////////////////// 61 // Basic movie player 62 /////////////////////////////////////////////////////////////////////////////// 42 63 43 44 #ifdef BACKEND_8BIT 45 void AnimationState::setPalette(byte *pal) { 46 _sys->setPalette(pal, 0, 256); 64 MoviePlayer::MoviePlayer(Screen *scr, Audio::Mixer *snd, OSystem *sys) 65 : _scr(scr), _snd(snd), _sys(sys) { 66 _bgSoundStream = NULL; 67 _ticks = 0; 68 _frameBuffer = NULL; 69 _currentFrame = 0; 70 _forceFrame = false; 71 _framesSkipped = 0; 47 72 } 48 #endif49 73 50 void AnimationState::drawYUV(int width, int height, byte *const *dat) { 51 _frameWidth = width; 52 _frameHeight = height; 53 54 #ifdef BACKEND_8BIT 55 _scr->plotYUV(_lut, width, height, dat); 56 #else 57 plotYUV(width, height, dat); 58 #endif 74 MoviePlayer::~MoviePlayer(void) { 59 75 } 60 76 61 OverlayColor *AnimationState::giveRgbBuffer(void) { 62 #ifdef BACKEND_8BIT 63 return NULL; 64 #else 65 return _overlay; 66 #endif 77 void MoviePlayer::updatePalette(byte *pal, bool packed) { 78 byte palette[4 * 256]; 79 byte *p = palette; 80 for (int i = 0; i < 256; i++) { 81 *p++ = *pal++; 82 *p++ = *pal++; 83 *p++ = *pal++; 84 if (!packed) 85 *p++ = *pal++; 86 else 87 *p++ = 0; 88 } 89 _sys->setPalette(palette, 0, 256); 90 _forceFrame = true; 67 91 } 68 92 69 bool AnimationState::soundFinished(void) { 70 return !_snd->isSoundHandleActive(_bgSound); 93 void MoviePlayer::handleScreenChanged(void) { 71 94 } 72 95 73 Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *arg) { 74 if (arg) 75 return (Audio::AudioStream*)arg; 76 else 77 return Audio::AudioStream::openStreamFile(name); 96 bool MoviePlayer::initOverlays(uint32 id) { 97 return true; 78 98 } 79 99 80 MoviePlayer::MoviePlayer(Screen *scr, Audio::Mixer *snd, OSystem *sys) 81 : _scr(scr), _snd(snd), _sys(sys) { 82 for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++) 83 _logoOvls[cnt] = NULL; 84 _introPal = NULL; 100 bool MoviePlayer::checkSkipFrame(void) { 101 if (_forceFrame) { 102 _forceFrame = false; 103 return false; 104 } 105 if (_framesSkipped > 10) { 106 warning("Forced frame %d to be displayed", _currentFrame); 107 _framesSkipped = 0; 108 return false; 109 } 110 if (_bgSoundStream) { 111 if ((_snd->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame + 1) 112 return false; 113 } else { 114 if (_sys->getMillis() <= _ticks) 115 return false; 116 } 117 _framesSkipped++; 118 return true; 85 119 } 86 120 87 MoviePlayer::~MoviePlayer(void) { 88 if (_introPal) 89 free(_introPal); 90 for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++) 91 if (_logoOvls[cnt]) 92 free(_logoOvls[cnt]); 121 void MoviePlayer::syncFrame(void) { 122 _ticks += 83; 123 if (checkSkipFrame()) { 124 warning("Skipped frame %d", _currentFrame); 125 return; 126 } 127 if (_bgSoundStream) { 128 while (_snd->isSoundHandleActive(_bgSoundHandle) && (_snd->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame) { 129 _sys->delayMillis(10); 130 } 131 132 // In case the background sound ends prematurely, update _ticks 133 // so that we can still fall back on the no-sound sync case for 134 // the subsequent frames. 135 136 _ticks = _sys->getMillis(); 137 } else { 138 while (_sys->getMillis() < _ticks) { 139 _sys->delayMillis(10); 140 } 141 } 93 142 } 94 143 95 144 /** 96 145 * Plays an animated cutscene. 97 146 * @param id the id of the file 98 147 */ 99 void MoviePlayer::play(uint32 id) { 100 #if defined(USE_MPEG2) && defined(USE_VORBIS) 101 AnimationState *anim = new AnimationState(_scr, _snd, _sys); 102 Audio::AudioStream *stream = NULL; 148 bool MoviePlayer::load(uint32 id) { 149 _id = id; 150 _bgSoundStream = NULL; 103 151 if (SwordEngine::_systemVars.cutscenePackVersion == 1) { 104 152 if ((id == SEQ_INTRO) || (id == SEQ_FINALE) || (id == SEQ_HISTORY) || (id == SEQ_FERRARI)) { 105 153 // these sequences are language specific 106 154 char sndName[20]; 107 sprintf(sndName, "%s.snd", _sequenceList[id]);155 sprintf(sndName, "%s.snd", sequenceList[id]); 108 156 Common::File *oggSource = new Common::File(); 109 157 if (oggSource->open(sndName)) { 110 158 SplittedAudioStream *sStream = new SplittedAudioStream(); … … 122 170 sStream->appendStream(apStream); 123 171 } 124 172 free(header); 125 stream = sStream;173 _bgSoundStream = sStream; 126 174 } else 127 175 warning("Sound file \"%s\" not found", sndName); 128 176 initOverlays(id); 129 177 oggSource->decRef(); 130 178 } 131 179 } 132 bool initOK = anim->init(_sequenceList[id], stream); 180 return true; 181 } 133 182 134 uint32 frameCount = 0; 135 if (initOK) { 136 while (anim->decodeFrame()) { 137 processFrame(id, anim, frameCount); 138 anim->updateScreen(); 139 frameCount++; 140 OSystem::Event event; 141 while (_sys->pollEvent(event)) { 142 switch (event.type) { 143 case OSystem::EVENT_SCREEN_CHANGED: 144 anim->handleScreenChanged(); 145 break; 146 case OSystem::EVENT_KEYDOWN: 147 if (event.kbd.keycode == 27) { 148 delete anim; 149 return; 150 } 151 break; 152 case OSystem::EVENT_QUIT: 153 _sys->quit(); 154 break; 155 default: 156 break; 183 void MoviePlayer::play(void) { 184 _framesSkipped = 0; 185 _ticks = _sys->getMillis(); 186 if (_bgSoundStream) { 187 _snd->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream); 188 } 189 _currentFrame = 0; 190 while (decodeFrame()) { 191 processFrame(); 192 syncFrame(); 193 updateScreen(); 194 _currentFrame++; 195 OSystem::Event event; 196 while (_sys->pollEvent(event)) { 197 switch (event.type) { 198 case OSystem::EVENT_SCREEN_CHANGED: 199 handleScreenChanged(); 200 break; 201 case OSystem::EVENT_KEYDOWN: 202 if (event.kbd.keycode == 27) { 203 _snd->stopHandle(_bgSoundHandle); 204 return; 157 205 } 206 break; 207 case OSystem::EVENT_QUIT: 208 _sys->quit(); 209 break; 210 default: 211 break; 158 212 } 159 213 } 160 214 } 161 while ( !anim->soundFinished())215 while (_snd->isSoundHandleActive(_bgSoundHandle)) 162 216 _sys->delayMillis(100); 163 delete anim;164 #endif // USE_MPEG2 && USE_VORBIS165 217 } 166 218 167 void MoviePlayer::insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor *pal) {168 if (ovl != NULL)169 for (uint32 cnt = 0; cnt < 640 * 400; cnt++)170 if (ovl[cnt])171 buf[cnt] = pal[ovl[cnt]];172 }173 174 void MoviePlayer::processFrame(uint32 animId, AnimationState *anim, uint32 frameNo) {175 #if defined(USE_MPEG2) && !defined(BACKEND_8BIT)176 if ((animId != 4) || (SwordEngine::_systemVars.cutscenePackVersion == 0))177 return;178 OverlayColor *buf = anim->giveRgbBuffer();179 if ((frameNo > 397) && (frameNo < 444)) { // Broken Sword Logo180 if (frameNo <= 403)181 insertOverlay(buf, _logoOvls[frameNo - 398], _introPal); // fade up182 else if (frameNo <= 437)183 insertOverlay(buf, _logoOvls[(frameNo - 404) % 6 + 6], _introPal); // animation184 else {185 insertOverlay(buf, _logoOvls[5 - (frameNo - 438)], _introPal); // fade down186 }187 }188 #endif189 }190 191 bool MoviePlayer::initOverlays(uint32 id) {192 #if defined(USE_MPEG2) && !defined(BACKEND_8BIT)193 if (id == SEQ_INTRO) {194 ArcFile ovlFile;195 if (!ovlFile.open("intro.dat")) {196 warning("\"intro.dat\" not found");197 return false;198 }199 ovlFile.enterPath(SwordEngine::_systemVars.language);200 for (uint8 fcnt = 0; fcnt < 12; fcnt++) {201 _logoOvls[fcnt] = ovlFile.decompressFile(fcnt);202 if (fcnt > 0)203 for (uint32 cnt = 0; cnt < 640 * 400; cnt++)204 if (_logoOvls[fcnt - 1][cnt] && !_logoOvls[fcnt][cnt])205 _logoOvls[fcnt][cnt] = _logoOvls[fcnt - 1][cnt];206 }207 uint8 *pal = ovlFile.fetchFile(12);208 _introPal = (OverlayColor*)malloc(256 * sizeof(OverlayColor));209 for (uint16 cnt = 0; cnt < 256; cnt++)210 _introPal[cnt] = _sys->RGBToColor(pal[cnt * 3 + 0], pal[cnt * 3 + 1], pal[cnt * 3 + 2]);211 }212 #endif213 214 return true;215 }216 217 219 SplittedAudioStream::SplittedAudioStream(void) { 218 220 _queue = NULL; 219 221 } … … 275 277 return retVal; 276 278 } 277 279 278 const char * MoviePlayer::_sequenceList[20] = { 279 "ferrari", // 0 CD2 ferrari running down fitz in sc19 280 "ladder", // 1 CD2 george walking down ladder to dig sc24->sc$ 281 "steps", // 2 CD2 george walking down steps sc23->sc24 282 "sewer", // 3 CD1 george entering sewer sc2->sc6 283 "intro", // 4 CD1 intro sequence ->sc1 284 "river", // 5 CD1 george being thrown into river by flap & g$ 285 "truck", // 6 CD2 truck arriving at bull's head sc45->sc53/4 286 "grave", // 7 BOTH george's grave in scotland, from sc73 + from sc38 $ 287 "montfcon", // 8 CD2 monfaucon clue in ireland dig, sc25 288 "tapestry", // 9 CD2 tapestry room beyond spain well, sc61 289 "ireland", // 10 CD2 ireland establishing shot europe_map->sc19 290 "finale", // 11 CD2 grand finale at very end, from sc73 291 "history", // 12 CD1 George's history lesson from Nico, in sc10 292 "spanish", // 13 CD2 establishing shot for 1st visit to Spain, europe_m$ 293 "well", // 14 CD2 first time being lowered down well in Spai$ 294 "candle", // 15 CD2 Candle burning down in Spain mausoleum sc59 295 "geodrop", // 16 CD2 from sc54, George jumping down onto truck 296 "vulture", // 17 CD2 from sc54, vultures circling George's dead body 297 "enddemo", // 18 --- for end of single CD demo 298 "credits", // 19 CD2 credits, to follow "finale" sequence 299 }; 280 #ifdef USE_ZLIB 300 281 282 /////////////////////////////////////////////////////////////////////////////// 283 // Movie player for the new DXA movies 284 /////////////////////////////////////////////////////////////////////////////// 285 286 MoviePlayerDXA::MoviePlayerDXA(Screen *src, Audio::Mixer *snd, OSystem *sys) 287 : MoviePlayer(src, snd, sys) { 288 } 289 290 MoviePlayerDXA::~MoviePlayerDXA(void) { 291 // free(_frameBuffer); 292 } 293 294 bool MoviePlayerDXA::load(uint32 id) { 295 if (!MoviePlayer::load(id)) 296 return false; 297 298 char filename[20]; 299 snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); 300 if (loadFile(filename)) { 301 // The Broken Sword games always use external audio tracks. 302 if (_fd.readUint32BE() != MKID_BE('NULL')) 303 return false; 304 _frameWidth = getWidth(); 305 _frameHeight = getHeight(); 306 _frameX = (640 - _frameWidth) / 2; 307 _frameY = (480 - _frameHeight) / 2; 308 if (!_bgSoundStream) { 309 _bgSoundStream = Audio::AudioStream::openStreamFile(sequenceList[id]); 310 } 311 return true; 312 } 313 return false; 314 } 315 316 bool MoviePlayerDXA::initOverlays(uint32 id) { 317 // TODO 318 return true; 319 } 320 321 void MoviePlayerDXA::setPalette(byte *pal) { 322 updatePalette(pal, true); 323 } 324 325 bool MoviePlayerDXA::decodeFrame(void) { 326 if (_currentFrame < _framesCount) { 327 decodeNextFrame(); 328 return true; 329 } 330 return false; 331 } 332 333 void MoviePlayerDXA::processFrame(void) { 334 // TODO 335 } 336 337 void MoviePlayerDXA::updateScreen(void) { 338 // Using _frameBuffer1 directly should work, as long as we don't do any 339 // post-processing of the frame. 340 _sys->copyRectToScreen(_frameBuffer1, _frameWidth, _frameX, _frameY, _frameWidth, _frameHeight); 341 _sys->updateScreen(); 342 } 343 344 #endif 345 346 #ifdef USE_MPEG2 347 348 /////////////////////////////////////////////////////////////////////////////// 349 // Movie player for the old MPEG movies 350 /////////////////////////////////////////////////////////////////////////////// 351 352 MoviePlayerMPEG::MoviePlayerMPEG(Screen *src, Audio::Mixer *snd, OSystem *sys) 353 : MoviePlayer(src, snd, sys) { 354 for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++) 355 _logoOvls[cnt] = NULL; 356 _introPal = NULL; 357 } 358 359 MoviePlayerMPEG::~MoviePlayerMPEG(void) { 360 free(_introPal); 361 for (uint8 cnt = 0; cnt < INTRO_LOGO_OVLS; cnt++) 362 free(_logoOvls[cnt]); 363 } 364 365 void MoviePlayerMPEG::handleScreenChanged(void) { 366 _anim->handleScreenChanged(); 367 } 368 369 void MoviePlayerMPEG::insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor *pal) { 370 if (ovl != NULL) 371 for (uint32 cnt = 0; cnt < 640 * 400; cnt++) 372 if (ovl[cnt]) 373 buf[cnt] = pal[ovl[cnt]]; 374 } 375 376 bool MoviePlayerMPEG::load(uint32 id) { 377 if (MoviePlayer::load(id)) { 378 _anim = new AnimationState(this, _scr, _snd, _sys); 379 return _anim->init(sequenceList[id], _bgSoundStream); 380 } 381 return false; 382 } 383 384 bool MoviePlayerMPEG::initOverlays(uint32 id) { 385 if (id == SEQ_INTRO) { 386 ArcFile ovlFile; 387 if (!ovlFile.open("intro.dat")) { 388 warning("\"intro.dat\" not found"); 389 return false; 390 } 391 ovlFile.enterPath(SwordEngine::_systemVars.language); 392 for (uint8 fcnt = 0; fcnt < 12; fcnt++) { 393 _logoOvls[fcnt] = ovlFile.decompressFile(fcnt); 394 if (fcnt > 0) 395 for (uint32 cnt = 0; cnt < 640 * 400; cnt++) 396 if (_logoOvls[fcnt - 1][cnt] && !_logoOvls[fcnt][cnt]) 397 _logoOvls[fcnt][cnt] = _logoOvls[fcnt - 1][cnt]; 398 } 399 uint8 *pal = ovlFile.fetchFile(12); 400 _introPal = (OverlayColor*)malloc(256 * sizeof(OverlayColor)); 401 for (uint16 cnt = 0; cnt < 256; cnt++) 402 _introPal[cnt] = _sys->RGBToColor(pal[cnt * 3 + 0], pal[cnt * 3 + 1], pal[cnt * 3 + 2]); 403 } 404 405 return true; 406 } 407 408 bool MoviePlayerMPEG::decodeFrame(void) { 409 return _anim->decodeFrame(); 410 } 411 412 void MoviePlayerMPEG::updateScreen(void) { 413 _anim->updateScreen(); 414 } 415 416 void MoviePlayerMPEG::processFrame(void) { 417 #ifndef BACKEND_8BIT 418 if ((_id != 4) || (SwordEngine::_systemVars.cutscenePackVersion == 0)) 419 return; 420 OverlayColor *buf = _anim->giveRgbBuffer(); 421 if ((_currentFrame > 397) && (_currentFrame < 444)) { // Broken Sword Logo 422 if (_currentFrame <= 403) 423 insertOverlay(buf, _logoOvls[_currentFrame - 398], _introPal); // fade up 424 else if (_currentFrame <= 437) 425 insertOverlay(buf, _logoOvls[(_currentFrame - 404) % 6 + 6], _introPal); // animation 426 else { 427 insertOverlay(buf, _logoOvls[5 - (_currentFrame - 438)], _introPal); // fade down 428 } 429 } 430 #endif 431 } 432 433 void MoviePlayerMPEG::syncFrame(void) { 434 } 435 436 AnimationState::AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys) 437 : BaseAnimationState(snd, sys, 640, 400), _player(player), _scr(scr) { 438 } 439 440 AnimationState::~AnimationState(void) { 441 } 442 443 #ifdef BACKEND_8BIT 444 void AnimationState::setPalette(byte *pal) { 445 _player->updatePalette(pal, false); 446 } 447 #endif 448 449 void AnimationState::drawYUV(int width, int height, byte *const *dat) { 450 _frameWidth = width; 451 _frameHeight = height; 452 453 #ifdef BACKEND_8BIT 454 _scr->plotYUV(_lut, width, height, dat); 455 #else 456 plotYUV(width, height, dat); 457 #endif 458 } 459 460 OverlayColor *AnimationState::giveRgbBuffer(void) { 461 #ifdef BACKEND_8BIT 462 return NULL; 463 #else 464 return _overlay; 465 #endif 466 } 467 468 Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *arg) { 469 if (arg) 470 return (Audio::AudioStream*)arg; 471 else 472 return Audio::AudioStream::openStreamFile(name); 473 } 474 475 #endif 476 477 /////////////////////////////////////////////////////////////////////////////// 478 // Factory function for creating the appropriate cutscene player 479 /////////////////////////////////////////////////////////////////////////////// 480 481 MoviePlayer *makeMoviePlayer(uint32 id, Screen *scr, Audio::Mixer *snd, OSystem *sys) { 482 #if defined(USE_ZLIB) || defined(USE_MPEG2) 483 char filename[20]; 484 #endif 485 486 #ifdef USE_ZLIB 487 snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); 488 489 if (Common::File::exists(filename)) { 490 return new MoviePlayerDXA(scr, snd, sys); 491 } 492 #endif 493 494 #ifdef USE_MPEG2 495 snprintf(filename, sizeof(filename), "%s.mp2", sequenceList[id]); 496 497 if (Common::File::exists(filename)) { 498 return new MoviePlayerMPEG(scr, snd, sys); 499 } 500 #endif 501 502 return NULL; 503 } 504 301 505 } // End of namespace Sword1 -
engines/sword1/logic.cpp
951 951 CreditsPlayer player(_system, _mixer); 952 952 player.play(); 953 953 } else { 954 MoviePlayer player(_screen, _mixer, _system); 955 player.play(sequenceId); 954 MoviePlayer *player = makeMoviePlayer(sequenceId, _screen, _mixer, _system); 955 if (player) { 956 if (player->load(sequenceId)) 957 player->play(); 958 delete player; 959 } 956 960 } 957 961 return SCRIPT_CONT; 958 962 }