diff options
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 10 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 7 | ||||
-rw-r--r-- | scumm/scumm.cpp | 45 | ||||
-rw-r--r-- | scumm/scumm.h | 3 | ||||
-rw-r--r-- | scumm/sound.cpp | 19 |
5 files changed, 77 insertions, 7 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 6e231f251e..97ebd26cb4 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -123,6 +123,16 @@ void ScummEngine::openRoom(int room) { encByte = (_features & GF_USE_KEY) ? 0xFF : 0; } + // If we have substitute + if (_heMacFileNameIndex > 0) { + char tmpBuf[128]; + + generateMacFileName(buf, tmpBuf, 128, 0, _heMacFileNameIndex); + strcpy(buf, tmpBuf); + generateMacFileName(buf2, tmpBuf, 128, 0, _heMacFileNameIndex); + strcpy(buf2, tmpBuf); + } + result = openResourceFile(buf, encByte); if ((result == false) && (buf2[0])) { result = openResourceFile(buf2, encByte); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index dc9abc00d6..44686e5bdd 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -1547,6 +1547,13 @@ void ScummEngine_v72he::o72_openFile() { sprintf((char *)filename, "%s.he9", _gameName.c_str()); } + if (_heMacFileNameIndex > 0) { + char buf1[128]; + + generateMacFileName((char *)filename, buf1, 128, 0, _heMacFileNameIndex); + strcpy((char *)filename, buf1); + } + for (r = strlen((char*)filename); r != 0; r--) { if (filename[r - 1] == '\\') break; diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 3f326fb18f..bca0bda002 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -69,7 +69,7 @@ extern bool isSmartphone(void); #endif -static int generateMacFileName(const char *filename, char *buf, int bufsize, int cont = 0); +static int generateMacFileName_(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0); namespace Scumm { @@ -678,6 +678,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _expire_counter = 0; _lastLoadedRoom = 0; _roomResource = 0; + _heMacFileNameIndex = 0; OF_OWNER_ROOM = 0; _verbMouseOver = 0; _inventoryOffset = 0; @@ -2597,6 +2598,11 @@ void ScummEngine::errorString(const char *buf1, char *buf2) { } } +int ScummEngine::generateMacFileName(const char *filename, char *buf, int bufsize, int cont, int index) { + return generateMacFileName_(filename, buf, bufsize, cont, index); +} + + } // End of namespace Scumm using namespace Scumm; @@ -2674,7 +2680,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) { } if (g->features & GF_HUMONGOUS) { - if ((heLastName = generateMacFileName(tempName, detectName, 128, + if ((heLastName = generateMacFileName_(tempName, detectName, 128, heLastName)) == -1) heOver = true; } else { @@ -2736,7 +2742,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) { return detectedGames; } -static int generateMacFileName(const char *filename, char *buf, int bufsize, int cont) { +static int generateMacFileName_(const char *filename, char *buf, int bufsize, int cont, int index) { if (cont == -1) return -1; @@ -2744,9 +2750,17 @@ static int generateMacFileName(const char *filename, char *buf, int bufsize, int cont++; char num = filename[strlen(filename) - 1]; + + // In some cases we have .(a) and .(b) extensions + if (num == ')') + num = filename[strlen(filename) - 2]; + char *n = strrchr(filename, '.'); int len = n - filename; + if (index > 0) + cont = index; + for (int i = cont; i < ARRAYSIZE(heMacFileNameTable); i++) { if (!scumm_strnicmp(filename, heMacFileNameTable[i].winName, len)) { if (heMacFileNameTable[i].hasParens) @@ -2777,8 +2791,9 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { // Calculate MD5 of the games detection file, for savegames etc. const char *name = g->name; - char detectName[256], gameMD5[32+1]; + char detectName[256], tempName[256], gameMD5[32+1]; uint8 md5sum[16]; + int heLastName = 0; if (g->detectFilename) { strcpy(detectName, game.detectFilename); @@ -2792,6 +2807,24 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { } else if (g->features & GF_HUMONGOUS) { strcpy(detectName, name); strcat(detectName, ".he0"); + strcpy(tempName, name); + strcat(tempName, ".he0"); + + bool heOver = false; + File f; + + while (!heOver) { + if (f.exists(detectName, ConfMan.get("path").c_str())) + break; + + if ((heLastName = generateMacFileName_(tempName, detectName, 256, + heLastName)) == -1) + heOver = true; + } + + // Force game to have Mac platform + if (heLastName > 0) + game.features |= GF_MACINTOSH; } else { strcpy(detectName, name); strcat(detectName, ".000"); @@ -2922,6 +2955,10 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { error("Engine_SCUMM_create(): Unknown version of game engine"); } + // FIXME: dirty HACK. Should we introduce another parameter to constructor + // instead? + ((ScummEngine *)engine)->_heMacFileNameIndex = heLastName; + return engine; } diff --git a/scumm/scumm.h b/scumm/scumm.h index c66031300f..99678243a2 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -489,6 +489,9 @@ public: int _roomResource; // FIXME - should be protected but Sound::pauseSounds uses it bool _egoPositioned; // Used by Actor::putActor, hence public + int generateMacFileName(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0); + int _heMacFileNameIndex; + protected: int _keyPressed; uint16 _lastKeyHit; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index de2a9a5080..4f76c0e451 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -171,10 +171,15 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { int music_offs, total_size; uint tracks, skip = 0; - char buf[32]; + char buf[32], buf1[128]; File musicFile; sprintf(buf, "%s.he4", _vm->getGameName()); + + if (_vm->_heMacFileNameIndex > 0) { + _vm->generateMacFileName(buf, buf1, 128, 0, _vm->_heMacFileNameIndex); + strcpy(buf, buf1); + } if (musicFile.open(buf) == false) { warning("playSound: Music file is not open"); return; @@ -1072,10 +1077,18 @@ ScummFile *Sound::openSfxFile() { } if (!file->isOpen()) { - if (_vm->_heversion >= 70) + if (_vm->_heversion >= 70) { sprintf(buf, "%s.he2", _vm->getGameName()); - else + + if (_vm->_heMacFileNameIndex > 0) { + char buf1[128]; + + _vm->generateMacFileName(buf, buf1, 128, 0, _vm->_heMacFileNameIndex); + strcpy(buf, buf1); + } + } else { sprintf(buf, "%s.tlk", _vm->getGameName()); + } if (file->open(buf) && _vm->_heversion <= 72) file->setEnc(0x69); _soundMode = kVOCMode; |