Ticket #8851: bs1-mac-en-v2.patch

File bs1-mac-en-v2.patch, 3.4 KB (added by sev-, 15 years ago)

Updated patch for r38961

  • engines/sword1/sword1.cpp

     
    139139
    140140        _systemVars.playSpeech = 1;
    141141        _mouseState = 0;
     142       
     143        // Some Mac versions use big endian for the speech files but not all of them.
     144        // The speech files have always the clu extension (and not the clm for big endian)
     145        // and the only way I have found to try to guess if we should use big endian is by
     146        // testing the language.
     147        // Mac BS1 english full version: big endian.
     148        // PC BS1 (all language) & Mac BS1 french : little endian.
     149        // Mac BS1 all other language: not known. Currently set on little endian.
     150        // Mac BS1 demo: not known, set to the same than the full version (i.e. english uses big endian).
     151        if (SwordEngine::isMac() && _systemVars.language == BS1_ENGLISH)
     152                _sound->setIsBigEndianSpeech(true);
    142153
    143154        _logic->initialize();
    144155        _objectMan->initialize();
  • engines/sword1/sound.h

     
    9494        int addToQueue(int32 fxNo);
    9595
    9696        void engine(void);
     97       
     98        void setIsBigEndianSpeech(bool);
    9799
    98100private:
    99101        uint8 _sfxVolL, _sfxVolR, _speechVolL, _speechVolR;
     
    116118        uint8            _endOfQueue;
    117119        Audio::Mixer *_mixer;
    118120        ResMan *_resMan;
     121        bool _bigEndianSpeech;
    119122        char _filePath[100];
    120123        static const char _musicList[270];
    121124        static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
  • engines/sword1/sound.cpp

     
    5151        strcpy(_filePath, searchPath);
    5252        _mixer = mixer;
    5353        _resMan = pResMan;
     54        _bigEndianSpeech = false;
    5455        _cowHeader = NULL;
    5556        _endOfQueue = 0;
    5657        _currentCowFile = 0;
     
    6768        closeCowSystem();
    6869}
    6970
     71void Sound::setIsBigEndianSpeech(bool isBE) {
     72        _bigEndianSpeech = isBE;
     73}
     74
    7075int Sound::addToQueue(int32 fxNo) {
    7176        bool alreadyInQueue = false;
    7277        for (uint8 cnt = 0; (cnt < _endOfQueue) && (!alreadyInQueue); cnt++)
     
    384389                int16 *dstData = (int16*)malloc(resSize * 2);
    385390                int32 samplesLeft = resSize;
    386391                while (srcPos < cSize && samplesLeft > 0) {
    387                         length = (int16)READ_LE_UINT16(srcData + srcPos);
     392                        length = (int16)(_bigEndianSpeech ? READ_BE_UINT16(srcData + srcPos) : READ_LE_UINT16(srcData + srcPos));
    388393                        srcPos++;
    389394                        if (length < 0) {
    390395                                length = -length;
    391396                                if (length > samplesLeft)
    392397                                        length = samplesLeft;
     398
     399                                int16 value;
     400                                if (_bigEndianSpeech) {
     401                                        value = (int16)SWAP_BYTES_16(*((uint16*)(srcData + srcPos)));
     402                                } else {
     403                                        value = srcData[srcPos];
     404                                }
     405
    393406                                for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
    394                                         dstData[dstPos++] = srcData[srcPos];
     407                                        dstData[dstPos++] = value;
     408
    395409                                srcPos++;
    396410                        } else {
    397411                                if (length > samplesLeft)
    398412                                        length = samplesLeft;
    399                                 memcpy(dstData + dstPos, srcData + srcPos, length * 2);
    400                                 dstPos += length;
    401                                 srcPos += length;
     413
     414                                if (_bigEndianSpeech) {
     415                                        for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
     416                                                dstData[dstPos++] = (int16)SWAP_BYTES_16(*((uint16*)(srcData + (srcPos++))));
     417                                } else {
     418                                        memcpy(dstData + dstPos, srcData + srcPos, length * 2);
     419                                        dstPos += length;
     420                                        srcPos += length;
     421                                }
    402422                        }
    403423                        samplesLeft -= length;
    404424                }