Ticket #8650: diff

File diff, 4.6 KB (added by SF/robinwatts, 18 years ago)

Patch to allow DXA to double if required

  • engines/sword1/animation.cpp

     
    405405
    406406        char filename[20];
    407407        snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]);
    408         if (loadFile(filename)) {
     408        if (loadFile(filename, 640, 480)) {
    409409                // The Broken Sword games always use external audio tracks.
    410410                if (_fd.readUint32BE() != MKID_BE('NULL'))
    411411                        return false;
  • engines/sword2/animation.cpp

     
    510510
    511511        snprintf(filename, sizeof(filename), "%s.dxa", _name);
    512512
    513         if (loadFile(filename)) {
     513        if (loadFile(filename,
     514                        _vm->_screen->getScreenWide(),
     515                        _vm->_screen->getScreenDeep())) {
    514516                // The Broken Sword games always use external audio tracks.
    515517                if (_fd.readUint32BE() != MKID_BE('NULL'))
    516518                        return false;
  • engines/agos/animation.cpp

     
    6262        // Change file extension to dxa
    6363        sprintf(videoName, "%s.dxa", baseName);
    6464
    65         if (!loadFile(videoName)) {
     65        if (!loadFile(videoName,
     66                        _vm->_screen->getScreenWide(),
     67                        _vm->_screen->getScreenDeep())) {
    6668                // Check short filename to work around
    6769                // bug in a German Windows 2CD version.
    6870                if (baseLen >= 8) {
  • graphics/dxa_player.cpp

     
    2929#include <zlib.h>
    3030#endif
    3131
     32static void scaleUpBy2(byte *dst, byte *src, uint16 width, uint16 h) {
     33  uint16 x;
     34
     35  while (h > 0)
     36  {
     37    for (x=width; x>0; x--)
     38    {
     39      register byte v;
     40      v = *src++;
     41      *dst++ = v;
     42      *dst++ = v;
     43    }
     44    memcpy(dst, dst-width*2, width*2);
     45    dst += width*2;
     46    h--;
     47  }
     48}
     49
    3250namespace Graphics {
    3351
    3452DXAPlayer::DXAPlayer() {
     
    3654        _frameBuffer2 = 0;
    3755        _scaledBuffer = 0;
    3856        _drawBuffer = 0;
     57        _scaledBuffer2 = 0;
    3958
    4059        _width = 0;
    4160        _height = 0;
     
    4867        _frameTicks = 0;
    4968
    5069        _scaleMode = S_NONE;
     70
     71        _scaling = 1;
    5172}
    5273
    5374DXAPlayer::~DXAPlayer() {
     
    5677int DXAPlayer::getWidth() {
    5778        if (!_fd.isOpen())
    5879                return 0;
    59         return _width;
     80        return _width*_scaling;
    6081}
    6182
    6283int DXAPlayer::getHeight() {
    6384        if (!_fd.isOpen())
    6485                return 0;
    65         return _height;
     86        return _height*_scaling;
    6687}
    6788
    6889int DXAPlayer::getCurFrame() {
     
    7798        return _framesCount;
    7899}
    79100
     101bool DXAPlayer::loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight) {
     102        bool result = loadFile(filename);
     103
     104        if (result)
     105        {
     106                _scaling = MIN(maxWidth/_width, maxHeight/_height);
     107                if (_scaling < 1)
     108                        _scaling = 1;
     109                if (_scaling > 2)
     110                        _scaling = 2;
     111                if (_scaling >= 2)
     112                {
     113                        _scaledBuffer2 = (uint8 *)malloc(_width*_height*_scaling*_scaling);
     114                        if (!_scaledBuffer2) {
     115                                _scaling = 1;
     116                        }
     117                }
     118        }
     119        return result;
     120}
    80121bool DXAPlayer::loadFile(const char *filename) {
    81122        uint32 tag;
    82123        int32 frameRate;
     
    147188        free(_frameBuffer1);
    148189        free(_frameBuffer2);
    149190        free(_scaledBuffer);
     191        free(_scaledBuffer2);
    150192}
    151193
    152194void DXAPlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
     
    535577                _drawBuffer = _frameBuffer1;
    536578                break;
    537579        }
     580
     581        if (_scaling == 2) {
     582                /* Scale up here */
     583                scaleUpBy2(_scaledBuffer2, _drawBuffer, _width, _height);
     584                _drawBuffer = _scaledBuffer2;
     585        }
    538586}
    539587
    540588} // End of namespace Graphics
  • graphics/dxa_player.h

     
    4646        byte *_frameBuffer2;
    4747        byte *_scaledBuffer;
    4848        byte *_drawBuffer;
     49        byte *_scaledBuffer2;
    4950        uint16 _width;
    5051        uint16 _height, _curHeight;
    5152        uint16 _framesCount;
     
    5556        uint16 _frameSkipped;
    5657        uint32 _frameTicks;
    5758        ScaleMode _scaleMode;
     59        uint32 _scaling;
    5860
    5961public:
    6062        DXAPlayer();
     
    9193        bool loadFile(const char *filename);
    9294
    9395        /**
     96         * Load a DXA encoded video file and setup scaling if required
     97         * @param filename      the filename to load
     98         * @param maxWidth      the maximum width  available to the film
     99         * @param maxHeight     the maximum height available to the film
     100         */
     101        bool loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight);
     102
     103        /**
    94104         * Close a DXA encoded video file
    95105         */
    96106        void closeFile();