Ticket #8767: soundDataAssignment.patch

File soundDataAssignment.patch, 26.3 KB (added by athrxx, 16 years ago)

KYRA: audio data assignment patch

  • kyra.h

     
    5656        GI_KYRA3 = 2
    5757};
    5858
     59struct AudioDataStruct {
     60        const char * const *_fileList;
     61        const uint32 _fileListLen;     
     62        const void * const _cdaTracks;
     63        const uint32 _cdaNumTracks;
     64};
     65
    5966// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable
    6067// in the future we maybe merge some flags  and/or create new ones
    6168enum kDebugLevels {
  • kyra_v1.cpp

     
    180180
    181181        initStaticResource();
    182182       
    183         if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
    184                 _sound->setSoundFileList(_soundFilesTowns, _soundFilesTownsCount);
    185         else
    186                 _sound->setSoundFileList(_soundFiles, _soundFilesCount);
     183        const AudioDataStruct *const sndList = (_flags.platform == Common::kPlatformFMTowns ||
     184                _flags.platform == Common::kPlatformPC98) ? _soundData_TOWNS : _soundData_PC;
     185        _sound->setSoundList(sndList);
    187186
    188187        _trackMap = _dosTrackMap;
    189188        _trackMapSize = _dosTrackMapSize;
  • kyra_v1.h

     
    764764        const uint8 * const*_specialPalettes;
    765765
    766766        static const char *_soundFiles[];
    767         static const int _soundFilesCount;
    768767        static const char *_soundFilesTowns[];
    769         static const int _soundFilesTownsCount;
    770        
     768        static const int32 _cdaTrackTable[];
     769        static const AudioDataStruct _soundData_PC[];
     770        static const AudioDataStruct _soundData_TOWNS[];
     771               
    771772        static const int8 _charXPosTable[];
    772773        static const int8 _charYPosTable[];
    773774
  • kyra_v2.cpp

     
    139139                _sequenceStrings = (const char * const *) _sequenceStrings_TOWNS_EN;
    140140                _sequenceStringsSize = _sequenceStringsSize_TOWNS_EN;
    141141                _sequences = (const Sequence*) _sequences_TOWNS;
    142         } else {
     142                _soundData = (const AudioDataStruct *) _soundData_TOWNS;
     143        } else if (_flags.isTalkie) {
    143144                _sequenceSoundList = (const char * const *) _sequenceSoundList_PC;
    144145                _sequenceSoundListSize = _sequenceSoundListSize_PC;
    145146                _sequenceStrings = (const char * const *) _sequenceStrings_PC_EN;
    146147                _sequenceStringsSize = _sequenceStringsSize_PC_EN;
    147148                _sequences = (const Sequence*) _sequences_PC;
     149                _soundData = (const AudioDataStruct *) _soundData_PC;
     150        } else {
     151                _sequenceSoundList = (const char * const *) _sequenceSoundList_PCFLOPPY;
     152                _sequenceSoundListSize = _sequenceSoundListSize_PCFLOPPY;
     153                _sequenceStrings = (const char * const *) _sequenceStrings_PC_EN;
     154                _sequenceStringsSize = _sequenceStringsSize_PC_EN;
     155                _sequences = (const Sequence*) _sequences_PC;
     156                _soundData = (const AudioDataStruct *) _soundData_PC;
    148157        }
    149158
    150159        for (int i = 0; i < 33; i++)
     
    170179        if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
    171180                seq_showStarcraftLogo();
    172181
    173         seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
    174         //seq_playSequences(kSequenceFunters, kSequenceFrash);
     182        if (_flags.platform == Common::kPlatformPC && _flags.isDemo) {
     183                _res->loadPakFile("VOC.PAK");
     184                _menuChoice = 2;
     185        } else {
     186                seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
     187                //seq_playSequences(kSequenceFunters, kSequenceFrash);
    175188
    176         if (_menuChoice == 1) {
    177                 // load just the pak files needed for ingame
    178189                _res->unloadAllPakFiles();
    179                 if (_flags.platform == Common::kPlatformPC && (_flags.isTalkie || _flags.isDemo)) {
    180                         _res->loadFileList("FILEDATA.FDT");
    181                 } else if (_flags.platform == Common::kPlatformPC) {
    182                         //TODO:
    183                         //What files are needed for floppy version?
    184                 } else if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) {
    185                         char tmpfilename[13];
    186                         static const char * pakfiles [] = { "KYRA.DAT", "AUDIO.PAK", "CAULDRON.PAK",
    187                                 "MISC_CPS.PAK", "MISC_EMC.PAK", "OTHER.PAK", "VOC.PAK", "WSCORE.PAK" };
    188                         for (int i = 0; i < 8; i++)
    189                                 _res->loadPakFile(pakfiles[i]);
    190                         for (int i = 1; i < 10; i++) {
    191                                 sprintf(tmpfilename, "COST%d_SH.PAK", i);
    192                                 _res->loadPakFile(tmpfilename);
     190
     191                if (_menuChoice != 4) {
     192                        // load just the pak files needed for ingame
     193                        if (_flags.platform == Common::kPlatformPC && _flags.isTalkie) {
     194                                _res->loadFileList("FILEDATA.FDT");
     195                                _res->loadPakFile("KYRA.DAT");                 
     196                        } else if (_flags.platform == Common::kPlatformPC) {
     197                                // TODO
     198
     199                        } else if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) {
     200                                char tmpfilename[13];
     201                                static const char * pakfiles [] = { "KYRA.DAT", "AUDIO.PAK", "CAULDRON.PAK",
     202                                        "MISC_CPS.PAK", "MISC_EMC.PAK", "OTHER.PAK", "VOC.PAK", "WSCORE.PAK" };
     203                                for (int i = 0; i < 8; i++)
     204                                        _res->loadPakFile(pakfiles[i]);
     205                                for (int i = 1; i < 10; i++) {
     206                                        sprintf(tmpfilename, "COST%d_SH.PAK", i);
     207                                        _res->loadPakFile(tmpfilename);
     208                                }
     209                                for (int i = 1; i < 6; i++) {
     210                                        sprintf(tmpfilename, "HOFCH_%d.PAK", i);
     211                                        _res->loadPakFile(tmpfilename);
     212                                }
    193213                        }
    194                         for (int i = 1; i < 6; i++) {
    195                                 sprintf(tmpfilename, "HOFCH_%d.PAK", i);
    196                                 _res->loadPakFile(tmpfilename);
    197                         }
    198214                }
     215        }
    199216
     217        if (_menuChoice == 1) {
    200218                startup();
    201219                runLoop();
    202220                cleanup();
    203221        } else if (_menuChoice == 3) {
    204                 // Load Game
     222                // TODO:        Load Game
     223
     224        } else if (_menuChoice == 2) {
     225                // TODO:        Run Demo
     226
    205227        }
    206228
    207229        return 0;
    208230}
    209231
    210232void KyraEngine_v2::startup() {
    211         snd_assignMusicData(kMusicIngame);
     233        _sound->setSoundList(&_soundData[kMusicIngame]);
    212234        // The track map is exactly the same
    213235        // for FM-TOWNS and DOS
    214236        _trackMap = _dosTrackMap;
     
    15671589        _sound->loadSoundFile(file);
    15681590}
    15691591
    1570 void KyraEngine_v2::snd_assignMusicData(kMusicDataID id) {
    1571         if (_flags.platform == Common::kPlatformPC) {
    1572                 if (id == kMusicIntro)
    1573                         _sound->setSoundFileList(_dosSoundFileListIntro, 1);
    1574                 else if (id == kMusicFinale)
    1575                         _sound->setSoundFileList(_dosSoundFileListFinale, 1);
    1576                 else
    1577                         _sound->setSoundFileList(_dosSoundFileList, _dosSoundFileListSize);
    1578         } else {
    1579                 _sound->assignData(id);
    1580         }
    1581 }
    1582 
    15831592void KyraEngine_v2::playVoice(int high, int low) {
    15841593        int vocFile = high * 10000 + low * 10;
    15851594        snd_playVoiceFile(vocFile);
  • kyra_v2.h

     
    250250
    251251        static const char *_dosSoundFileListIntro[];
    252252        static const char *_dosSoundFileListFinale[];
    253         static const char *_dosSoundFileList[];
    254         static const int _dosSoundFileListSize;
     253        static const char *_dosSoundFileList[];
     254        static const char *_fmtSoundFileListIntro[];
     255        static const char *_fmtSoundFileListFinale[];
     256        static const char *_fmtSoundFileList[];
     257        static const uint8 _cdaTrackTableIntro[];
     258        static const uint8 _cdaTrackTableIngame[];
     259        static const uint8 _cdaTrackTableFinale[];
     260        static const AudioDataStruct _soundData_PC[];
     261        static const AudioDataStruct _soundData_TOWNS[];
    255262        static const int8 _dosTrackMap[];
    256263        static const int _dosTrackMapSize;
     264        const AudioDataStruct * _soundData;
    257265
    258266protected:
    259267        // game initialization
     
    630638
    631639        virtual void snd_playVoiceFile(int id);
    632640        void snd_loadSoundFile(int id);
    633         void snd_assignMusicData(kMusicDataID id);
    634641
    635642        void playVoice(int high, int low);
    636643
     
    843850
    844851        static const char *_sequenceSoundList_PC[];
    845852        static const int _sequenceSoundListSize_PC;
     853        static const char *_sequenceSoundList_PCFLOPPY[];
     854        static const int _sequenceSoundListSize_PCFLOPPY;
    846855        static const char *_sequenceSoundList_TOWNS[];
    847856        static const int _sequenceSoundListSize_TOWNS;
    848857        static const char *_sequenceStrings_TOWNS_EN[];
  • saveload_v1.cpp

     
    202202                // In the first version when this entry was introduced,
    203203                // it wasn't made sure that _curSfxFile was initialized
    204204                // so if it's out of bounds we just set it to 0.
    205                 if (_curSfxFile >= _soundFilesTownsCount || _curSfxFile < 0)
     205                if (_curSfxFile >= _soundData_TOWNS->_fileListLen || _curSfxFile < 0)
    206206                        _curSfxFile = 0;
    207207
    208208                if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
  • sequences_v2.cpp

     
    5151                        "K2_DEMO",
    5252                        "LOLSYSEX"
    5353                };
    54                 _sound->setSoundFileList(soundFileList, 2);
     54                //_sound->setSoundFileList(soundFileList, 2);
    5555        } else {
    56                 snd_assignMusicData((startSeq > kSequenceZanfaun) ?     kMusicFinale : kMusicIntro);
     56                _sound->setSoundList(&_soundData[(startSeq > kSequenceZanfaun) ?        kMusicFinale : kMusicIntro]);
    5757        }
    5858        _sound->loadSoundFile(0);
    5959
     
    15281528        _screen->loadBitmap("finale.cps", 3, 3, _screen->_currentPalette);
    15291529        _screen->setFont(Screen::FID_GOLDFONT_FNT);
    15301530
    1531         snd_assignMusicData(kMusicIngame);
     1531        _sound->setSoundList(&_soundData[kMusicIngame]);
    15321532        _sound->loadSoundFile(3);
    15331533        _sound->playTrack(3);
    15341534
     
    15371537
    15381538        //XXX
    15391539
    1540         snd_assignMusicData(kMusicFinale);
     1540        _sound->setSoundList(&_soundData[kMusicFinale]);
    15411541        _sound->loadSoundFile(0);
    15421542}
    15431543
  • sound.cpp

     
    4040
    4141Sound::Sound(KyraEngine *vm, Audio::Mixer *mixer)
    4242        : _vm(vm), _mixer(mixer), _currentVocFile(0), _vocHandle(), _compressHandle(),
    43         _musicEnabled(1), _sfxEnabled(true), _soundFileList(0), _soundFileListSize(0) {
     43        _musicEnabled(1), _sfxEnabled(true), _soundDataList(0) {
    4444}
    4545
    4646Sound::~Sound() {
     
    259259
    260260void SoundMidiPC::loadSoundFile(uint file) {
    261261        char filename[25];
    262         sprintf(filename, "%s.%s", soundFilename(file), _useC55 ? "C55" : "XMI");
     262        sprintf(filename, "%s.%s", fileListEntry(file), _useC55 ? "C55" : "XMI");
    263263
    264264        uint32 size;
    265265        uint8 *data = (_vm->resource())->fileData(filename, &size);
     
    296296
    297297void SoundMidiPC::loadSoundEffectFile(uint file) {
    298298        char filename[25];
    299         sprintf(filename, "%s.%s", soundFilename(file), _useC55 ? "C55" : "XMI");
     299        sprintf(filename, "%s.%s", fileListEntry(file), _useC55 ? "C55" : "XMI");
    300300
    301301        uint32 size;
    302302        uint8 *data = (_vm->resource())->fileData(filename, &size);
  • sound.h

     
    107107         * @param list  soundfile list
    108108         * @param s             number of soundfiles
    109109         */
    110         virtual void setSoundFileList(const char * const *list, uint s) { _soundFileList = list; _soundFileListSize = s; }
     110        virtual void setSoundList(const AudioDataStruct * const list) { _soundDataList = list; }
    111111
    112112        /**
    113          * Selects preset bundles of music files
    114          * and cd audio tracks the output device will use
    115          * when playing a track and/or sound effect.
    116          *
    117          * TODO: this is just needed for Kyrandia 2 FM-Towns version,
    118          * and is similar to what setSoundFileList is used for, so we
    119          * should think of a better solution than this.
    120          * @see setSoundFileList
    121          *
    122          * @param id    kMusicIntro, kMusicIngame or kMusicFinale
    123          */     
    124         virtual void assignData(kMusicDataID id) { _currentTheme = id; }
    125 
    126         /**
    127113         * Load a specifc sound file for use of
    128114         * playing music and sound effects.
    129115         */
     
    190176         */
    191177        void voiceStop();
    192178
    193 protected:
    194         const char *soundFilename(uint file) { return (file < _soundFileListSize) ? _soundFileList[file] : ""; }
     179protected:     
     180        const char * fileListEntry(uint file) const { return (file < _soundDataList->_fileListLen) ? _soundDataList->_fileList[file] : ""; }
     181        const void * cdaData() const { return _soundDataList->_cdaTracks; }
     182        const uint32 cdaTrackNum() const { return _soundDataList->_cdaNumTracks; }
     183
    195184        int _musicEnabled;
    196185        bool _sfxEnabled;
    197186
     
    201190        Audio::Mixer *_mixer;
    202191
    203192private:
    204         const char * const *_soundFileList;
    205         uint _soundFileListSize;
    206 
     193        const AudioDataStruct * _soundDataList;
    207194        Audio::AudioStream *_currentVocFile;
    208195        Audio::SoundHandle _vocHandle;
    209196        Common::File _compressHandle;
     
    444431
    445432        //SoundTowns_v2_TwnDriver * _driver;
    446433        uint8 * _twnTrackData;
    447 
    448         static const uint8 _cdaTrackTableK2Intro[];
    449         static const uint8 _cdaTrackTableK2Ingame[];
    450         static const uint8 _cdaTrackTableK2Finale[];
    451 
    452         static const struct Kyra2AudioThemes {
    453                 const uint8 * cdaTable;
    454                 const uint8 cdaTableSize;
    455                 const char * twnFilename;
    456         } _themes[];
    457434};
    458435
    459436class MixedSoundDriver : public Sound {
     
    461438        MixedSoundDriver(KyraEngine *vm, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(vm, mixer), _music(music), _sfx(sfx) {}
    462439        ~MixedSoundDriver() { delete _music; delete _sfx; }
    463440
    464         bool init() { return (_music->init() && _sfx->init()); }
     441        bool init() { return _music->init() | _sfx->init(); }
    465442        void process() { _music->process(); _sfx->process(); }
    466443
    467444        void setVolume(int volume) { _music->setVolume(volume); _sfx->setVolume(volume); }
    468445        int getVolume() { return _music->getVolume(); }
    469446
    470         void setSoundFileList(const char * const*list, uint s) { _music->setSoundFileList(list, s); _sfx->setSoundFileList(list, s); }
     447        void setSoundList(const AudioDataStruct * const list) { _music->setSoundList(list); _sfx->setSoundList(list); }
    471448        void loadSoundFile(uint file) { _music->loadSoundFile(file); _sfx->loadSoundFile(file); }
    472449
    473450        void playTrack(uint8 track) { _music->playTrack(track); }
  • sound_adlib.cpp

     
    22672267                // sync for each loop. To avoid that, we declare that all four
    22682268                // of the song channels have to jump "in sync".
    22692269
    2270                 if (track == 4 && scumm_stricmp(soundFilename(_soundFileLoaded), "KYRA1B") == 0)
     2270                if (track == 4 && scumm_stricmp(fileListEntry(_soundFileLoaded), "KYRA1B") == 0)
    22712271                        _driver->setSyncJumpMask(0x000F);
    22722272                else
    22732273                        _driver->setSyncJumpMask(0);
     
    23512351        uint8 *file_data = 0; uint32 file_size = 0;
    23522352
    23532353        char filename[25];
    2354         sprintf(filename, "%s.ADL", soundFilename(file));
     2354        sprintf(filename, "%s.ADL", fileListEntry(file));
    23552355
    23562356        file_data = _vm->resource()->fileData(filename, &file_size);
    23572357        if (!file_data) {
  • sound_towns.cpp

     
    10841084        _driver->send(0x79B0);
    10851085}
    10861086
    1087 SoundTowns::SoundTowns(KyraEngine *vm, Audio::Mixer *mixer)
    1088         : Sound(vm, mixer), _lastTrack(-1), _currentSFX(0), _sfxFileData(0),
    1089         _sfxFileIndex((uint)-1), _sfxWDTable(0), _parser(0) {
     1087SoundTowns::SoundTowns(KyraEngine *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _lastTrack(-1),
     1088         _currentSFX(0), _sfxFileData(0), _sfxFileIndex((uint)-1), _sfxWDTable(0), _parser(0) {
    10901089
    10911090        _driver = new SoundTowns_EuphonyDriver(_mixer);
    10921091        int ret = open();
     
    11181117        AudioCD.updateCD();
    11191118}
    11201119
    1121 namespace {
    1122 
    1123 struct CDTrackTable {
    1124         uint32 fileOffset;
    1125         bool loop;
    1126         int track;
    1127 };
    1128 
    1129 } // end of anonymous namespace
    1130 
    11311120void SoundTowns::playTrack(uint8 track) {
    11321121        if (track < 2)
    11331122                return;
    11341123        track -= 2;
    11351124
    1136         static const CDTrackTable tTable[] = {
    1137                 { 0x04000, 1,  0 },     { 0x05480, 1,  6 },     { 0x05E70, 0,  1 },
    1138                 { 0x06D90, 1,  3 },     { 0x072C0, 0, -1 },     { 0x075F0, 1, -1 },
    1139                 { 0x07880, 1, -1 },     { 0x089C0, 0, -1 },     { 0x09080, 0, -1 },
    1140                 { 0x091D0, 1,  4 },     { 0x0A880, 1,  5 },     { 0x0AF50, 0, -1 },
    1141                 { 0x0B1A0, 1, -1 },     { 0x0B870, 0, -1 },     { 0x0BCF0, 1, -1 },
    1142                 { 0x0C5D0, 1,  7 },     { 0x0D3E0, 1,  8 },     { 0x0e7b0, 1,  2 },
    1143                 { 0x0edc0, 0, -1 },     { 0x0eef0, 1,  9 },     { 0x10540, 1, 10 },
    1144                 { 0x10d80, 0, -1 },     { 0x10E30, 0, -1 },     { 0x10FC0, 0, -1 },
    1145                 { 0x11310, 1, -1 },     { 0x11A20, 1, -1 },     { 0x12380, 0, -1 },
    1146                 { 0x12540, 1, -1 },     { 0x12730, 1, -1 },     { 0x12A90, 1, 11 },
    1147                 { 0x134D0, 0, -1 },     { 0x00000, 0, -1 },     { 0x13770, 0, -1 },
    1148                 { 0x00000, 0, -1 },     { 0x00000, 0, -1 },     { 0x00000, 0, -1 },
    1149                 { 0x00000, 0, -1 },     { 0x14710, 1, 12 },     { 0x15DF0, 1, 13 },
    1150                 { 0x16030, 1, 14 },     { 0x17030, 0, -1 },     { 0x17650, 0, -1 },
    1151                 { 0x134D0, 0, -1 },     { 0x178E0, 1, -1 },     { 0x18200, 0, -1 },
    1152                 { 0x18320, 0, -1 },     { 0x184A0, 0, -1 },     { 0x18BB0, 0, -1 },
    1153                 { 0x19040, 0, 19 },     { 0x19B50, 0, 20 },     { 0x17650, 0, -1 },
    1154                 { 0x1A730, 1, 21 },     { 0x00000, 0, -1 },     { 0x12380, 0, -1 },
    1155                 { 0x1B810, 0, -1 },     { 0x1BA50, 0, 15 },     { 0x1C190, 0, 16 },
    1156                 { 0x1CA50, 0, 17 },     { 0x1D100, 0, 18 }
    1157         };
     1125        const int32 * const tTable = (const int32 * const) cdaData();
     1126        int tTableIndex = 3 * track;
    11581127
    1159         int trackNum = tTable[track].track;
    1160         bool loop = tTable[track].loop;
     1128        int trackNum = tTable[tTableIndex + 2];
     1129        int32 loop = tTable[tTableIndex + 1];
    11611130
    11621131        if (track == _lastTrack && _musicEnabled)
    11631132                return;
     
    11681137                AudioCD.play(trackNum+1, loop ? -1 : 1, 0, 0);
    11691138                AudioCD.updateCD();
    11701139        } else if (_musicEnabled) {
    1171                 playEuphonyTrack(tTable[track].fileOffset, loop);
     1140                playEuphonyTrack((uint32) tTable[tTableIndex], loop);
    11721141        }
    11731142
    11741143        _lastTrack = track;
     
    11951164                return;
    11961165        _sfxFileIndex = file;
    11971166        delete [] _sfxFileData;
    1198         _sfxFileData = _vm->resource()->fileData(soundFilename(file), 0);
     1167        _sfxFileData = _vm->resource()->fileData(fileListEntry(file), 0);
    11991168}
    12001169
    12011170void SoundTowns::playSoundEffect(uint8 track) {
     
    12301199        if (offset == -1)
    12311200                return;
    12321201
    1233         struct SfxHeader {
    1234                 uint32 id;
    1235                 uint32 inBufferSize;
    1236                 uint32 unused1;
    1237                 uint32 outBufferSize;
    1238                 uint32 unused2;
    1239                 uint32 unused3;
    1240                 uint32 rate;
    1241                 uint32 rootNoteOffs;
    1242         } *sfxHeader = (SfxHeader*)(fileBody + offset);
     1202        uint32 * sfxHeader = (uint32*)(fileBody + offset);
    12431203
    1244         uint32 sfxHeaderID = TO_LE_32(sfxHeader->id);
    1245         uint32 sfxHeaderInBufferSize = TO_LE_32(sfxHeader->inBufferSize);
    1246         uint32 sfxHeaderOutBufferSize = TO_LE_32(sfxHeader->outBufferSize);
    1247         uint32 sfxRootNoteOffs = TO_LE_32(sfxHeader->rootNoteOffs);
    1248         uint32 sfxRate = TO_LE_32(sfxHeader->rate);
     1204        uint32 sfxHeaderID = READ_LE_UINT32(sfxHeader);
     1205        uint32 sfxHeaderInBufferSize = READ_LE_UINT32(&sfxHeader[1]);
     1206        uint32 sfxHeaderOutBufferSize = READ_LE_UINT32(&sfxHeader[3]);
     1207        uint32 sfxRootNoteOffs = READ_LE_UINT32(&sfxHeader[7]);
     1208        uint32 sfxRate = READ_LE_UINT32(&sfxHeader[6]);
    12491209
    12501210        uint32 playbackBufferSize = (sfxHeaderID == 1) ? sfxHeaderInBufferSize : sfxHeaderOutBufferSize;
    12511211
     
    14151375
    14161376//      KYRA 2
    14171377
    1418 SoundTowns_v2::SoundTowns_v2(KyraEngine *vm, Audio::Mixer *mixer)
    1419         : Sound(vm, mixer), _lastTrack(-1), _currentSFX(0), /*_driver(0),*/
     1378SoundTowns_v2::SoundTowns_v2(KyraEngine *vm, Audio::Mixer *mixer) :
     1379        Sound(vm, mixer), _lastTrack(-1), _currentSFX(0), /*_driver(0),*/
    14201380         _twnTrackData(0) {
    14211381}
    14221382
     
    14521412        if (track == _lastTrack && _musicEnabled)
    14531413                return;
    14541414
     1415        const uint8 * const cdaTracks = (const uint8 * const) cdaData();
     1416
    14551417        int trackNum = -1;
    1456         for (int i = 0; i < _themes[_currentTheme].cdaTableSize; i++) {
    1457                 if (track == _themes[_currentTheme].cdaTable[i * 2]) {
    1458                         trackNum = _themes[_currentTheme].cdaTable[i * 2 + 1] - 1;
     1418        for (uint32 i = 0; i < cdaTrackNum(); i++) {
     1419                if (track == cdaTracks[i * 2]) {
     1420                        trackNum = cdaTracks[i * 2 + 1] - 1;
    14591421                        break;
    14601422                }
    14611423        }
     
    14701432                AudioCD.updateCD();
    14711433        } else if (_musicEnabled) {
    14721434                char musicfile[13];
    1473                 sprintf(musicfile, "%s%d.twn", _themes[_currentTheme].twnFilename, track);
     1435                sprintf(musicfile, "%s%d.twn", fileListEntry(0), track);
    14741436                if (_twnTrackData)
    14751437                        delete [] _twnTrackData;
    14761438                _twnTrackData = _vm->resource()->fileData(musicfile, 0);
     
    15471509        haltTrack();
    15481510}
    15491511
    1550 const uint8 SoundTowns_v2::_cdaTrackTableK2Intro[] =    {
    1551         0x03, 0x01, 0x04, 0x02, 0x05, 0x03, 0x06, 0x04, 0x07, 0x05, 0x08, 0x06
    1552 };
    1553 
    1554 const uint8 SoundTowns_v2::_cdaTrackTableK2Ingame[] =   {
    1555         0x02, 0x07, 0x03, 0x08, 0x04, 0x09, 0x07, 0x0A, 0x0C, 0x0B, 0x0D, 0x0C, 0x0E, 0x0D, 0x0F, 0x0E,
    1556         0x10, 0x0F, 0x12, 0x10, 0x13, 0x11, 0x15, 0x12, 0x17, 0x13, 0x18, 0x14, 0x19, 0x15, 0x1A, 0x16,
    1557         0x1B, 0x17, 0x1C, 0x18, 0x1D, 0x19, 0x1E, 0x1A, 0x1F, 0x1B, 0x21, 0x1C, 0x22, 0x1D, 0x23, 0x1E,
    1558         0x24, 0x1F, 0x25, 0x20, 0x26, 0x21, 0x27, 0x22, 0x28, 0x23, 0x29, 0x24, 0x2A, 0x25, 0x2B, 0x26,
    1559         0x2C, 0x27, 0x2D, 0x28, 0x2E, 0x29, 0x2F, 0x2A, 0x30, 0x2B, 0x31, 0x2C, 0x32, 0x2D, 0x33, 0x2E,
    1560         0x34, 0x2F, 0x35, 0x30, 0x36, 0x31, 0x37, 0x32, 0x38, 0x33, 0x39, 0x34, 0x3A, 0x35, 0x3B, 0x36,
    1561         0x3C, 0x37, 0x3D, 0x38, 0x3E, 0x39, 0x3F, 0x3A, 0x40, 0x3B, 0x41, 0x3C, 0x42, 0x3D, 0x43, 0x3E,
    1562         0x44, 0x3F, 0x45, 0x40, 0x46, 0x41, 0x47, 0x42, 0x48, 0x43, 0x49, 0x44, 0x4A, 0x45, 0x4B, 0x46,
    1563         0x4C, 0x47, 0x4D, 0x48, 0x4E, 0x49, 0x4F, 0x4A, 0x50, 0x4B, 0x51, 0x4C, 0x52, 0x4D, 0x53, 0x4E,
    1564         0x54, 0x4F, 0x55, 0x50, 0x56, 0x51, 0x57, 0x52
    1565 };
    1566 
    1567 const uint8 SoundTowns_v2::_cdaTrackTableK2Finale[] =   {
    1568         0x03, 0x53, 0x04, 0x54
    1569 };
    1570 
    1571 const SoundTowns_v2::Kyra2AudioThemes SoundTowns_v2::_themes[] = {
    1572         { _cdaTrackTableK2Intro,        ARRAYSIZE(_cdaTrackTableK2Intro) >> 1,  "intro"         },
    1573         { _cdaTrackTableK2Ingame,       ARRAYSIZE(_cdaTrackTableK2Ingame) >> 1, "k2"            },
    1574         { _cdaTrackTableK2Finale,       ARRAYSIZE(_cdaTrackTableK2Finale) >> 1, "finale"        }
    1575 };
    1576 
    15771512} // end of namespace Kyra
    15781513
    15791514#undef EUPHONY_FADEOUT_TICKS
  • staticres.cpp

     
    917917        "INTRO"
    918918};
    919919
    920 const int KyraEngine_v1::_soundFilesCount = ARRAYSIZE(KyraEngine_v1::_soundFiles);
    921 
    922920const char *KyraEngine_v1::_soundFilesTowns[] = {
    923921        "TW_INTRO.SFX",
    924922        "TW_SCEN1.SFX",
     
    928926        "TW_SCEN5.SFX"
    929927};
    930928
    931 const int KyraEngine_v1::_soundFilesTownsCount = ARRAYSIZE(KyraEngine_v1::_soundFilesTowns);
     929const int32 KyraEngine_v1::_cdaTrackTable[] = {
     930        0x04000, 1,  0, 0x05480, 1,  6, 0x05E70, 0,  1,
     931        0x06D90, 1,  3, 0x072C0, 0, -1, 0x075F0, 1, -1,
     932        0x07880, 1, -1, 0x089C0, 0, -1, 0x09080, 0, -1,
     933        0x091D0, 1,  4, 0x0A880, 1,  5, 0x0AF50, 0, -1,
     934        0x0B1A0, 1, -1, 0x0B870, 0, -1, 0x0BCF0, 1, -1,
     935        0x0C5D0, 1,  7, 0x0D3E0, 1,  8, 0x0e7b0, 1,  2,
     936        0x0edc0, 0, -1, 0x0eef0, 1,  9, 0x10540, 1, 10,
     937        0x10d80, 0, -1, 0x10E30, 0, -1, 0x10FC0, 0, -1,
     938        0x11310, 1, -1, 0x11A20, 1, -1, 0x12380, 0, -1,
     939        0x12540, 1, -1, 0x12730, 1, -1, 0x12A90, 1, 11,
     940        0x134D0, 0, -1, 0x00000, 0, -1, 0x13770, 0, -1,
     941        0x00000, 0, -1, 0x00000, 0, -1, 0x00000, 0, -1,
     942        0x00000, 0, -1, 0x14710, 1, 12, 0x15DF0, 1, 13,
     943        0x16030, 1, 14, 0x17030, 0, -1, 0x17650, 0, -1,
     944        0x134D0, 0, -1, 0x178E0, 1, -1, 0x18200, 0, -1,
     945        0x18320, 0, -1, 0x184A0, 0, -1, 0x18BB0, 0, -1,
     946        0x19040, 0, 19, 0x19B50, 0, 20, 0x17650, 0, -1,
     947        0x1A730, 1, 21, 0x00000, 0, -1, 0x12380, 0, -1,
     948        0x1B810, 0, -1, 0x1BA50, 0, 15, 0x1C190, 0, 16,
     949        0x1CA50, 0, 17, 0x1D100, 0, 18
     950};
    932951
     952const AudioDataStruct KyraEngine_v1::_soundData_PC[] = {
     953        { _soundFiles, ARRAYSIZE(_soundFiles), 0, 0 },
     954        { 0, 0, 0, 0}
     955};
     956
     957const AudioDataStruct KyraEngine_v1::_soundData_TOWNS[] = {
     958        { _soundFilesTowns, ARRAYSIZE(_soundFilesTowns), _cdaTrackTable, ARRAYSIZE(_cdaTrackTable) },
     959        { 0, 0, 0, 0}
     960};
    933961const int8 KyraEngine_v1::_charXPosTable[] = {
    934962         0,  4,  4,  4,  0, -4, -4, -4
    935963};
     
    14271455        "theend"
    14281456};
    14291457
     1458const char *KyraEngine_v2::_sequenceSoundList_PCFLOPPY[] = {
     1459        "intro1",
     1460        "intro2",
     1461        "intro3",
     1462        "intro4",
     1463        "intro5",
     1464        "intro6",
     1465        "intro7",
     1466        "intro8",
     1467        "intro9",
     1468        "intro10",
     1469        "intro11",
     1470        "intro12",
     1471        "glow",
     1472
     1473        "asong",
     1474        "crowcaw",
     1475        "eyerub2",
     1476        "pluck3",
     1477        "rodnreel",
     1478        "frog1",
     1479        "scavmov2",
     1480        "lambmom3",
     1481        "lambkid1",
     1482        "thunder2",
     1483        "thunder3",
     1484        "wind6",
     1485        "h2odrop2",
     1486        "gasleak",
     1487        "polgulp1",
     1488        "hndslap1",
     1489        "burp1",
     1490        "scream1",
     1491        "theend"
     1492};
     1493
    14301494const char *KyraEngine_v2::_sequenceSoundList_TOWNS[] = {
    14311495        "intro1.pcm",
    14321496        "intro2.pcm",
     
    14641528};
    14651529
    14661530const int KyraEngine_v2::_sequenceSoundListSize_PC = ARRAYSIZE(KyraEngine_v2::_sequenceSoundList_PC);
     1531const int KyraEngine_v2::_sequenceSoundListSize_PCFLOPPY = ARRAYSIZE(KyraEngine_v2::_sequenceSoundList_PCFLOPPY);
    14671532const int KyraEngine_v2::_sequenceSoundListSize_TOWNS = ARRAYSIZE(KyraEngine_v2::_sequenceSoundList_TOWNS);
    14681533
    14691534const uint8 KyraEngine_v2::_seqTextColorPresets[] = { 0x01, 0x01, 0x00, 0x3f, 0x3f, 0x3f };
     
    15421607        "K2TEST15"
    15431608};
    15441609
    1545 const int KyraEngine_v2::_dosSoundFileListSize = ARRAYSIZE(KyraEngine_v2::_dosSoundFileList);
     1610const char *KyraEngine_v2::_fmtSoundFileListIntro[] = { "intro" };
     1611const char *KyraEngine_v2::_fmtSoundFileListFinale[] = { "finale" };
     1612const char *KyraEngine_v2::_fmtSoundFileList[] = { "k2" };
    15461613
     1614const uint8 KyraEngine_v2::_cdaTrackTableIntro[] =      {
     1615        0x03, 0x01, 0x04, 0x02, 0x05, 0x03, 0x06, 0x04, 0x07, 0x05, 0x08, 0x06
     1616};
     1617
     1618const uint8 KyraEngine_v2::_cdaTrackTableIngame[] =     {
     1619        0x02, 0x07, 0x03, 0x08, 0x04, 0x09, 0x07, 0x0A, 0x0C, 0x0B, 0x0D, 0x0C, 0x0E, 0x0D, 0x0F, 0x0E,
     1620        0x10, 0x0F, 0x12, 0x10, 0x13, 0x11, 0x15, 0x12, 0x17, 0x13, 0x18, 0x14, 0x19, 0x15, 0x1A, 0x16,
     1621        0x1B, 0x17, 0x1C, 0x18, 0x1D, 0x19, 0x1E, 0x1A, 0x1F, 0x1B, 0x21, 0x1C, 0x22, 0x1D, 0x23, 0x1E,
     1622        0x24, 0x1F, 0x25, 0x20, 0x26, 0x21, 0x27, 0x22, 0x28, 0x23, 0x29, 0x24, 0x2A, 0x25, 0x2B, 0x26,
     1623        0x2C, 0x27, 0x2D, 0x28, 0x2E, 0x29, 0x2F, 0x2A, 0x30, 0x2B, 0x31, 0x2C, 0x32, 0x2D, 0x33, 0x2E,
     1624        0x34, 0x2F, 0x35, 0x30, 0x36, 0x31, 0x37, 0x32, 0x38, 0x33, 0x39, 0x34, 0x3A, 0x35, 0x3B, 0x36,
     1625        0x3C, 0x37, 0x3D, 0x38, 0x3E, 0x39, 0x3F, 0x3A, 0x40, 0x3B, 0x41, 0x3C, 0x42, 0x3D, 0x43, 0x3E,
     1626        0x44, 0x3F, 0x45, 0x40, 0x46, 0x41, 0x47, 0x42, 0x48, 0x43, 0x49, 0x44, 0x4A, 0x45, 0x4B, 0x46,
     1627        0x4C, 0x47, 0x4D, 0x48, 0x4E, 0x49, 0x4F, 0x4A, 0x50, 0x4B, 0x51, 0x4C, 0x52, 0x4D, 0x53, 0x4E,
     1628        0x54, 0x4F, 0x55, 0x50, 0x56, 0x51, 0x57, 0x52
     1629};
     1630
     1631const uint8 KyraEngine_v2::_cdaTrackTableFinale[] =     {
     1632        0x03, 0x53, 0x04, 0x54
     1633};
     1634
     1635const AudioDataStruct KyraEngine_v2::_soundData_PC[] = {
     1636        { _dosSoundFileListIntro, ARRAYSIZE(_dosSoundFileListIntro), 0, 0 },
     1637        { _dosSoundFileList, ARRAYSIZE(_dosSoundFileList), 0, 0},
     1638        { _dosSoundFileListFinale, ARRAYSIZE(_dosSoundFileListFinale), 0, 0 }
     1639};
     1640
     1641const AudioDataStruct KyraEngine_v2::_soundData_TOWNS[] = {
     1642        { _fmtSoundFileListIntro, ARRAYSIZE(_fmtSoundFileListIntro), _cdaTrackTableIntro, ARRAYSIZE(_cdaTrackTableIntro) >> 1 },
     1643        { _fmtSoundFileList, ARRAYSIZE(_fmtSoundFileList),_cdaTrackTableIngame, ARRAYSIZE(_cdaTrackTableIngame) >> 1 },
     1644        { _fmtSoundFileListFinale, ARRAYSIZE(_fmtSoundFileListFinale),_cdaTrackTableFinale, ARRAYSIZE(_cdaTrackTableFinale) >> 1 }
     1645};
     1646
    15471647const int KyraEngine_v2::_itemStringMapSize = ARRAYSIZE(KyraEngine_v2::_itemStringMap);
    15481648
    15491649const int8 KyraEngine_v2::_dosTrackMap[] = {