Ticket #1746: bs1_demo.diff

File bs1_demo.diff, 5.3 KB (added by eriktorbjorn, 20 years ago)

Patch against an August 30 CVS snapshot

  • sword1/sound.cpp

    diff -ur --exclude=CVS ScummVM/sword1/sound.cpp ScummVM+hack/sword1/sound.cpp
    old new  
    3131#define SOUND_SPEECH_ID 1
    3232#define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
    3333
    34 Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan) {
     34Sound::Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo) {
    3535        strcpy(_filePath, searchPath);
    3636        _mixer = mixer;
    3737        _resMan = pResMan;
     
    3939        _endOfQueue = 0;
    4040        _currentCowFile = 0;
    4141        _speechVolL = _speechVolR = _sfxVolL = _sfxVolR = 192;
     42        _isDemo = isDemo;
    4243}
    4344
    4445int Sound::addToQueue(int32 fxNo) {
     
    185186        while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
    186187                headerPos++;
    187188        if (headerPos < 100) {
    188                 uint32 resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
     189                int32 resSize;
    189190                // Demo uses slightly different headers
    190                 if (resSize > cSize) {
     191                if (_isDemo) {
    191192                        resSize = READ_LE_UINT32(fBuf + headerPos + 6) >> 1;
    192193                        headerPos += 2;
    193                 }
    194 
     194                } else
     195                        resSize = READ_LE_UINT32(fBuf + headerPos + 4) >> 1;
    195196                int16 *srcData = (int16*)(fBuf + headerPos + 8);
    196197                int16 *dstData = (int16*)malloc(resSize * 2);
    197198                uint32 srcPos = 0;
  • sword1/sound.h

    diff -ur --exclude=CVS ScummVM/sword1/sound.h ScummVM+hack/sword1/sound.h
    old new  
    6060
    6161class Sound {
    6262public:
    63         Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
     63        Sound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan, bool isDemo);
    6464        ~Sound(void);
    6565        void setSpeechVol(uint8 volL, uint8 volR) { _speechVolL = volL; _speechVolR = volR; };
    6666        void setSfxVol(uint8 volL, uint8 volR) { _sfxVolL = volL; _sfxVolR = volR; };
     
    100100        uint8            _endOfQueue;
    101101        SoundMixer *_mixer;
    102102        ResMan *_resMan;
     103        bool _isDemo;
    103104        char _filePath[100];
    104105        static const char _musicList[270];
    105106        static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
  • sword1/sword1.cpp

    diff -ur --exclude=CVS ScummVM/sword1/sword1.cpp ScummVM+hack/sword1/sword1.cpp
    old new  
    4747using namespace Sword1;
    4848
    4949/* Broken Sword 1 */
    50 static const GameSettings sword1_setting =
    51         {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER};
     50static const GameSettings sword1_settings[] = {
     51        {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER},
     52        {"sword1demo", "Broken Sword I (Demo)", GF_DEFAULT_TO_1X_SCALER | Sword1::GF_DEMO },
     53        { NULL, NULL, 0 }
     54};
    5255
    5356GameList Engine_SWORD1_gameList() {
     57        const GameSettings *g = sword1_settings;
    5458        GameList games;
    55         games.push_back(sword1_setting);
     59        while (g->name) {       
     60                games.push_back(*g);
     61                g++;
     62        }
    5663        return games;
    5764}
    5865
    5966DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
    6067        DetectedGameList detectedGames;
     68        const GameSettings *g = sword1_settings;
    6169
    62         // Iterate over all files in the given directory
    63         for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
    64                 const char *gameName = file->displayName().c_str();
    65 
    66                 if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
    67                         (0 == scumm_stricmp("cd1.id", gameName)) ||
    68                         (0 == scumm_stricmp("cd2.id", gameName))) {
    69                         // Match found, add to list of candidates, then abort inner loop.
    70                         detectedGames.push_back(sword1_setting);
    71                         break;
     70        // TODO: It would be nice if we had code here which distinguishes
     71        // between the 'sword1' and 'sword1demo' targets.
     72
     73        while (g->name) {
     74                // Iterate over all files in the given directory
     75                for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
     76                        const char *gameName = file->displayName().c_str();
     77
     78                        if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
     79                                (0 == scumm_stricmp("cd1.id", gameName)) ||
     80                                (0 == scumm_stricmp("cd2.id", gameName))) {
     81                                // Match found, add to list of candidates, then abort inner loop.
     82                                detectedGames.push_back(*g);
     83                                break;
     84                        }
    7285                }
     86                g++;
    7387        }
    7488
    7589        return detectedGames;
     
    92106SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst)
    93107        : Engine(syst) {
    94108
     109        _features = detector->_game.features;
     110
    95111        if (!_mixer->isReady())
    96112                warning("Sound initialization failed");
    97113}
     
    122138        _mouse = new Mouse(_system, _resMan, _objectMan);
    123139        _screen = new Screen(_system, _resMan, _objectMan);
    124140        _music = new Music(_system, _mixer);
    125         _sound = new Sound("", _mixer, _resMan);
     141        _sound = new Sound("", _mixer, _resMan, (_features & GF_DEMO) != 0);
    126142        _menu = new Menu(_screen, _mouse);
    127143        _logic = new Logic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer);
    128144        _mouse->useLogicAndMenu(_logic, _menu);
  • sword1/sword1.h

    diff -ur --exclude=CVS ScummVM/sword1/sword1.h ScummVM+hack/sword1/sword1.h
    old new  
    2929
    3030namespace Sword1 {
    3131
     32enum {
     33        GF_DEMO = 1 << 0
     34};
     35
    3236class Screen;
    3337class Sound;
    3438class Logic;
     
    6165        virtual ~SwordEngine();
    6266        static SystemVars _systemVars;
    6367        void reinitialize(void);
     68
     69        uint32 _features;
    6470protected:
    6571        void go();
    6672private: