Ticket #8782: hofStartupFix_V2 plus ingame sfx.patch

File hofStartupFix_V2 plus ingame sfx.patch, 7.6 KB (added by athrxx, 16 years ago)
  • kyra.cpp

     
    162162                        _lang = 2;
    163163                        break;
    164164
     165                case Common::JA_JPN:
     166                        _lang = 3;
     167                        break;
     168
    165169                default:
    166170                        warning("unsupported language, switching back to English");
    167171                        _lang = 0;
  • kyra_v2.cpp

     
    6767        _newChapterFile = 1;
    6868        _oldTalkFile = -1;
    6969        _currentTalkFile = 0;
     70        _lastSfxTrack = -1;
    7071        _handItemSet = -1;
    7172        _lastProcessedSceneScript = 0;
    7273        _specialSceneScriptRunFlag = false;
     
    212213        _screen->setMouseCursor(0, 0, getShapePtr(0));
    213214
    214215        _screenBuffer = new uint8[64000];
     216        _unkBuf200kByte = new uint8[200000];
    215217
     218        loadChapterBuffer(_newChapterFile);     
     219
    216220        loadCCodeBuffer("C_CODE.XXX");
    217         loadOptionsBuffer("OPTIONS.XXX");
    218         loadChapterBuffer(_newChapterFile);
     221       
     222        if (_flags.isTalkie) {
     223                loadOptionsBuffer("OPTIONS.XXX");
    219224
    220         _unkBuf200kByte = new uint8[200000];
     225                showMessageFromCCode(265, 150, 0);
     226                openTalkFile(0);
     227                _currentTalkFile = 1;
     228                openTalkFile(1);
     229        }
    221230
    222         showMessageFromCCode(265, 150, 0);
    223 
    224         openTalkFile(0);
    225         _currentTalkFile = 1;
    226         openTalkFile(1);
    227 
    228231        showMessage(0, 207);
    229232
    230233        _screen->setShapePages(5, 3);
     
    806809const char *KyraEngine_v2::getTableString(int id, const uint8 *buffer, int decode) {
    807810        const char *string = (const char*)getTableEntry(buffer, id);
    808811
    809         if (decode) {
     812        if (decode && _flags.lang != Common::JA_JPN) {
    810813                decodeString1(string, _internStringBuf);
    811814                decodeString2(_internStringBuf, _internStringBuf);
    812815                string = _internStringBuf;
     
    920923
    921924        strcpy(src, getTableString(str1, _cCodeBuffer, 1));
    922925
    923         while (*src != 0x20)
     926        if (_flags.lang != Common::JA_JPN) {
     927                while (*src != 0x20)
     928                        ++src;
    924929                ++src;
    925         ++src;
    926 
    927         *src = toupper(*src);
     930                *src = toupper(*src);
     931        }
     932       
    928933        strcpy((char*)_unkBuf500Bytes, src);
    929934
    930935        if (str2 > 0) {
    931                 strcat((char*)_unkBuf500Bytes, " ");
     936                if (_flags.lang != Common::JA_JPN)
     937                        strcat((char*)_unkBuf500Bytes, " ");
    932938                strcat((char*)_unkBuf500Bytes, getTableString(str2, _cCodeBuffer, 1));
    933939        }
    934940
     
    10131019        char filename[12];
    10141020        strcpy(filename, "_NPC.EMC");
    10151021
    1016         switch (_lang) {
    1017         case 0:
    1018                 filename[5] = 'E';
    1019                 break;
     1022        if (_flags.platform != Common::kPlatformPC || _flags.isTalkie) {
     1023                switch (_lang) {
     1024                case 0:
     1025                        filename[5] = 'E';
     1026                        break;
    10201027
    1021         case 1:
    1022                 filename[5] = 'F';
    1023                 break;
     1028                case 1:
     1029                        filename[5] = 'F';
     1030                        break;
    10241031
    1025         case 2:
    1026                 filename[5] = 'G';
    1027                 break;
     1032                case 2:
     1033                        filename[5] = 'G';
     1034                        break;
    10281035
    1029         default:
    1030                 break;
    1031         };
     1036                case 3:
     1037                        filename[5] = 'J';
     1038                        break;
    10321039
     1040                default:
     1041                        break;
     1042                };
     1043        }
     1044
    10331045        _scriptInterpreter->loadScript(filename, &_npcScriptData, &_opcodes);
    10341046}
    10351047
     
    15521564}
    15531565
    15541566void KyraEngine_v2::playVoice(int high, int low) {
     1567        if (!_flags.isTalkie)
     1568                return;
    15551569        int vocFile = high * 10000 + low * 10;
    15561570        snd_playVoiceFile(vocFile);
    15571571}
    15581572
     1573void KyraEngine_v2::snd_playSoundEffect(int track) {
     1574        debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v2::snd_playSoundEffect(%d)", track);
     1575       
     1576        if (track == 10)
     1577                track = _lastSfxTrack;
     1578
     1579        if (track == 10 || track == -1)
     1580                return;
     1581
     1582        _lastSfxTrack = track;
     1583
     1584        int16 vocIndex = (int16) READ_LE_UINT16(&_ingameSoundIndex[track * 2]);
     1585        if (vocIndex != -1)
     1586                _sound->voicePlay(_ingameSoundList[vocIndex]);
     1587        else if (_flags.platform == Common::kPlatformPC)
     1588                // TODO ?? Maybe there is a way to let users select whether they want
     1589                // voc, midi or adl sfx (even though it makes no sense to choose anything but voc).
     1590                // For now this is used as a fallback only (if no voc file exists).
     1591                KyraEngine::snd_playSoundEffect(track);
     1592}
     1593
    15591594#pragma mark -
    15601595
    15611596void KyraEngine_v2::loadInvWsa(const char *filename, int run, int delayTime, int page, int sfx, int sFrame, int flags) {
  • kyra_v2.h

     
    642642        int _oldTalkFile;
    643643        int _currentTalkFile;
    644644        void openTalkFile(int newFile);
     645        int _lastSfxTrack;
    645646
    646647        virtual void snd_playVoiceFile(int id);
    647648        void snd_loadSoundFile(int id);
    648649
    649650        void playVoice(int high, int low);
     651        void snd_playSoundEffect(int track);
    650652
    651653        // timer
    652654        void timerFunc2(int);
     
    869871        int _cdaTrackTableFinaleSize;
    870872        const char *const *_sequenceSoundList;
    871873        int _sequenceSoundListSize;
     874        const char *const *_ingameSoundList;
     875        int _ingameSoundListSize;
     876        const uint16 *_ingameSoundIndex;
     877        int _ingameSoundIndexSize;
    872878        const char *const *_sequenceStrings;
    873879        int _sequenceStringsSize;
    874880        int _sequenceStringsDuration[33];
  • resource.h

     
    236236        k2SeqplayFinaleCDA,
    237237
    238238        k2IngamePakFiles,
     239        k2IngameSfxFiles,
     240        k2IngameSfxIndex,
    239241        k2IngameTracks,
    240242        k2IngameCDA,
    241243
  • scene_v2.cpp

     
    3535void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk2, int unk3) {
    3636        if (_newChapterFile != _currentTalkFile) {
    3737                _currentTalkFile = _newChapterFile;
    38                 showMessageFromCCode(265, 150, 0);
    39                 _screen->updateScreen();
    40                 openTalkFile(_currentTalkFile);
     38                if (_flags.isTalkie) {
     39                        showMessageFromCCode(265, 150, 0);
     40                        _screen->updateScreen();
     41                        openTalkFile(_currentTalkFile);
     42                }
    4143                showMessage(0, 207);
    4244                _screen->updateScreen();
    4345        }
     
    425427       
    426428        strcpy(filename, _sceneList[sceneId].filename);
    427429        strcat(filename, ".");
    428         strcat(filename, _scriptLangExt[_lang]);
     430        strcat(filename, _scriptLangExt[(_flags.platform == Common::kPlatformPC && !_flags.isTalkie) ? 0 : _lang]);
    429431       
    430432        assert(_res->getFileSize(filename));
    431433        _scriptInterpreter->loadScript(filename, &_sceneScriptData, &_opcodes);
  • staticres.cpp

     
    239239
    240240                // Ingame
    241241                { k2IngamePakFiles, kStringList, "I_PAKFILES.TXT" },
     242                { k2IngameSfxFiles, kStringList, "I_SFXFILES.TXT" },
     243                { k2IngameSfxIndex, kRawData, "I_SFXINDEX.TRA" },               
    242244                { k2IngameTracks, kStringList, "I_TRACKS.TRA" },
    243245                { k2IngameCDA, kRawData, "I_TRACKS.CDA" },
    244246
     
    914916        _ingamePakList = _staticres->loadStrings(k2IngamePakFiles, _ingamePakListSize);
    915917        _sequenceStrings = _staticres->loadStrings(k2SeqplayStrings, _sequenceStringsSize);
    916918        _sequenceSoundList = _staticres->loadStrings(k2SeqplaySfxFiles, _sequenceSoundListSize);
     919        _ingameSoundList = _staticres->loadStrings(k2IngameSfxFiles, _ingameSoundListSize);
     920        _ingameSoundIndex = (const uint16*) _staticres->loadRawData(k2IngameSfxIndex, _ingameSoundIndexSize);
    917921        _musicFileListIntro = _staticres->loadStrings(k2SeqplayIntroTracks, _musicFileListIntroSize);
    918922        _musicFileListIngame = _staticres->loadStrings(k2IngameTracks, _musicFileListIngameSize);
    919923        _musicFileListFinale = _staticres->loadStrings(k2SeqplayFinaleTracks, _musicFileListFinaleSize);
     
    13401344const char *KyraEngine_v2::_languageExtension[] = {
    13411345        "ENG",
    13421346        "FRE",
    1343         "GER"/*,
     1347        "GER",/*,
    13441348        "ITA",          Italian and Spanish was never included
    13451349        "SPA"*/
     1350        "JPN"
    13461351};
    13471352
    13481353const char *KyraEngine_v2::_scriptLangExt[] = {
    13491354        "EMC",
    13501355        "FMC",
    1351         "GMC"/*,
     1356        "GMC",/*,
    13521357        "IMC",          Italian and Spanish was never included
    13531358        "SMC"*/
     1359        "JMC"
    13541360};
    13551361
    13561362const int KyraEngine_v2::_characterFrameTable[] = {