Ticket #8935: bs1-subtitles.diff
File bs1-subtitles.diff, 3.7 KB (added by , 15 years ago) |
---|
-
engines/sword1/animation.h
92 92 Audio::Mixer *_snd; 93 93 OSystem *_system; 94 94 Common::Array<MovieText *> _movieTexts; 95 byte *_textSpriteBuf;96 95 int _textX, _textY, _textWidth, _textHeight; 97 96 byte _black, _white; 98 97 -
engines/sword1/animation.cpp
36 36 #include "common/str.h" 37 37 #include "common/events.h" 38 38 #include "common/system.h" 39 #include "graphics/surface.h" 39 40 40 41 namespace Sword1 { 41 42 … … 70 71 : _vm(vm), _screen(screen), _textMan(textMan), _snd(snd), _system(system) { 71 72 _bgSoundStream = NULL; 72 73 _ticks = 0; 73 _textSpriteBuf = NULL;74 74 _black = 1; 75 75 _white = 255; 76 76 _currentFrame = 0; … … 275 275 _textHeight = frame->height; 276 276 _textX = 320 - _textWidth / 2; 277 277 _textY = 420 - _textHeight; 278 _textSpriteBuf = (byte *)calloc(_textHeight, _textWidth);279 278 } 280 279 if (_currentFrame == _movieTexts[0]->_endFrame) { 281 280 _textMan->releaseText(2, false); 282 free(_textSpriteBuf);283 _textSpriteBuf = NULL;284 281 delete _movieTexts.remove_at(0); 285 282 } 286 283 } … … 309 306 if (terminated) 310 307 _snd->stopHandle(_bgSoundHandle); 311 308 312 if (_textSpriteBuf) { 313 _textMan->releaseText(2, false); 314 free(_textSpriteBuf); 315 _textSpriteBuf = NULL; 316 } 309 _textMan->releaseText(2, false); 317 310 318 311 while (!_movieTexts.empty()) 319 312 delete _movieTexts.remove_at(_movieTexts.size() - 1); … … 444 437 } 445 438 446 439 void MoviePlayerDXA::processFrame(void) { 440 } 441 442 void MoviePlayerDXA::updateScreen(void) { 443 _system->copyRectToScreen(_drawBuffer, _frameWidth, _frameX, _frameY, _frameWidth, _frameHeight); 444 447 445 // TODO: Handle the advanced cutscene packs. Do they really exist? 448 446 449 447 // We cannot draw the text to _drawBuffer, since that's one of the 450 // decoder's internal buffers. Instead, we copy part of _drawBuffer 451 // to the text sprite. 448 // decoder's internal buffers, and besides it may be much smaller than 449 // the screen, so it's possible that the subtitles don't fit on it. 450 // Instead, we get the frame buffer from the backend, after copying the 451 // frame to it, and draw on that. 452 452 453 if (_textSpriteBuf) { 454 memset(_textSpriteBuf, 0, _textWidth * _textHeight); 455 456 // FIXME: This is inefficient 457 int x, y; 458 459 for (y = _textY; y < _textY + _textHeight; y++) { 460 for (x = _textX; x < _textX + _textWidth; x++) { 461 if (x >= _frameX && x <= _frameX + _frameWidth && y >= _frameY && y <= _frameY + _frameHeight) { 462 _textSpriteBuf[(y - _textY) * _textWidth + x - _textX] = _drawBuffer[(y - _frameY) * _frameWidth + x - _frameX]; 463 } 464 } 465 } 466 453 if (_textMan->giveSpriteData(2)) { 454 Graphics::Surface *frameBuffer = _system->lockScreen(); 467 455 byte *src = (byte *)_textMan->giveSpriteData(2) + sizeof(FrameHeader); 468 byte *dst = _textSpriteBuf;456 byte *dst = (byte *)frameBuffer->getBasePtr(_textX, _textY); 469 457 470 for ( y = 0; y < _textHeight; y++) {471 for ( x = 0; x < _textWidth; x++) {458 for (int y = 0; y < _textHeight; y++) { 459 for (int x = 0; x < _textWidth; x++) { 472 460 switch (src[x]) { 473 461 case BORDER_COL: 474 462 dst[x] = _black; … … 479 467 } 480 468 } 481 469 src += _textWidth; 482 dst += _textWidth;470 dst += frameBuffer->pitch; 483 471 } 484 }485 }486 472 487 void MoviePlayerDXA::updateScreen(void) { 488 _system->copyRectToScreen(_drawBuffer, _frameWidth, _frameX, _frameY, _frameWidth, _frameHeight); 489 if (_textSpriteBuf) { 490 _system->copyRectToScreen(_textSpriteBuf, _textWidth, _textX, _textY, _textWidth, _textHeight); 473 _system->unlockScreen(); 491 474 } 475 492 476 _system->updateScreen(); 493 477 } 494 478