diff options
author | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
commit | 75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch) | |
tree | f29541d55309487a94bd1d38e8b53bb3dde9aec6 /engines/kyra | |
parent | 48ee83b88957dab86bc763e9ef21a70179fa8679 (diff) | |
parent | e9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff) | |
download | scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2 scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip |
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend
changes into the branch. I suppose the gp2x backend and probably all new
backends, i.e. gph, dingux etc., might not compile anymore.
Since I have no way of testing those it would be nice if porters could look
into getting those up to speed in this branch.
svn-id: r53399
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/detection.cpp | 13 | ||||
-rw-r--r-- | engines/kyra/detection_tables.h | 16 | ||||
-rw-r--r-- | engines/kyra/gui.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 1 | ||||
-rw-r--r-- | engines/kyra/resource.cpp | 11 | ||||
-rw-r--r-- | engines/kyra/resource.h | 4 | ||||
-rw-r--r-- | engines/kyra/resource_intern.cpp | 259 | ||||
-rw-r--r-- | engines/kyra/resource_intern.h | 44 | ||||
-rw-r--r-- | engines/kyra/saveload.cpp | 7 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/screen_lol.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/screen_v2.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/script_tim.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sequences_lol.cpp | 19 | ||||
-rw-r--r-- | engines/kyra/sound_adlib.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sound_digital.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/sound_midi.cpp | 22 | ||||
-rw-r--r-- | engines/kyra/sound_towns.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sprites.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/text_hof.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/text_lol.cpp | 8 |
25 files changed, 299 insertions, 190 deletions
diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index 225b44b3f4..fc509700d7 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -76,7 +76,7 @@ bool Debugger::cmd_loadPalette(int argc, const char **argv) { return true; } - if (_vm->gameFlags().gameID != GI_KYRA1 && _vm->resource()->getFileSize(argv[1]) != 768) { + if (_vm->game() != GI_KYRA1 && _vm->resource()->getFileSize(argv[1]) != 768) { uint8 buffer[320*200]; _vm->screen()->copyRegionToBuffer(5, 0, 0, 320, 200, buffer); _vm->screen()->loadBitmap(argv[1], 5, 5, 0); diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 135a9ae7b2..875b49b62d 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -43,6 +43,13 @@ struct KYRAGameDescription { #include "kyra/detection_tables.h" +namespace { + +const char * const directoryGlobs[] = { + "malcolm", + 0 +}; + const ADParams detectionParams = { // Pointer to ADGameDescription or its superset structure (const byte *)adGameDescs, @@ -63,11 +70,13 @@ const ADParams detectionParams = { // Additional GUI options (for every game} Common::GUIO_NONE, // Maximum directory depth - 1, + 2, // List of directory globs - 0 + directoryGlobs }; +} // End of anonymous namespace + class KyraMetaEngine : public AdvancedMetaEngine { public: KyraMetaEngine() : AdvancedMetaEngine(detectionParams) {} diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h index 2e1d5afc17..84e0f343a7 100644 --- a/engines/kyra/detection_tables.h +++ b/engines/kyra/detection_tables.h @@ -1080,6 +1080,22 @@ const KYRAGameDescription adGameDescs[] = { "lol", 0, { + { "WESTWOOD.1", 0, "320b2828be595c491903f467094f05eb", -1 }, + { 0, 0, 0, 0 } + }, + Common::EN_ANY, + Common::kPlatformPC, + ADGF_NO_FLAGS, + Common::GUIO_NOSPEECH | Common::GUIO_MIDIADLIB | Common::GUIO_MIDIMT32 | Common::GUIO_MIDIGM | Common::GUIO_MIDIPCSPK + }, + LOL_FLOPPY_CMP_FLAGS + }, + + { + { + "lol", + 0, + { { "WESTWOOD.1", 0, "3c61cb7de5b2ec452f5851f5075207ee", -1 }, { 0, 0, 0, 0 } }, diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 9f5d29d7b9..f0eb25190b 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -92,7 +92,7 @@ void GUI::initMenu(Menu &menu) { textY = menu.y + menu.titleY; - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { printMenuText(getMenuTitle(menu), textX, textY, menu.textColor, 0, 9); } else { if (_vm->gameFlags().platform != Common::kPlatformAmiga) @@ -136,7 +136,7 @@ void GUI::initMenu(Menu &menu) { textX = getMenuCenterStringX(getMenuItemTitle(menu.item[i]), x1, x2); textY = y1 + 2; - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { textY++; if (i == menu.highlightedItem) printMenuText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].highlightColor, 0, 8); @@ -162,7 +162,7 @@ void GUI::initMenu(Menu &menu) { for (int i = 0; i < menu.numberOfItems; ++i) { if (getMenuItemLabel(menu.item[i])) { - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { menu.item[i].labelX = menu.item[i].x - 1; menu.item[i].labelY = menu.item[i].y + 3; printMenuText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, menu.item[i].textColor, 0, 10); @@ -206,7 +206,7 @@ void GUI::processHighlights(Menu &menu) { int mouseX = p.x; int mouseY = p.y; - if (_vm->_flags.gameID == GI_LOL && menu.highlightedItem != 255) { + if (_vm->game() == GI_LOL && menu.highlightedItem != 255) { // LoL doesnt't have default highlighted items. // We use a highlightedItem value of 255 for this. @@ -230,8 +230,8 @@ void GUI::processHighlights(Menu &menu) { if (mouseX > x1 && mouseX < x2 && mouseY > y1 && mouseY < y2) { - if (menu.highlightedItem != i || _vm->_flags.gameID == GI_LOL) { - if (_vm->_flags.gameID != GI_LOL) { + if (menu.highlightedItem != i || _vm->game() == GI_LOL) { + if (_vm->game() != GI_LOL) { if (menu.item[menu.highlightedItem].enabled) redrawText(menu); } @@ -260,7 +260,7 @@ void GUI::redrawText(const Menu &menu) { textX = getMenuCenterStringX(getMenuItemTitle(menu.item[i]), x1, x2); int textY = y1 + 2; - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { textY++; printMenuText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].textColor, 0, 8); } else { @@ -290,7 +290,7 @@ void GUI::redrawHighlight(const Menu &menu) { int textY = y1 + 2; - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { textY++; printMenuText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].highlightColor, 0, 8); } else { @@ -399,7 +399,7 @@ void GUI::updateSaveList(bool excludeQuickSaves) { int GUI::getNextSavegameSlot() { Common::InSaveFile *in; - int start = _vm->gameFlags().gameID == GI_LOL ? 0 : 1; + int start = _vm->game() == GI_LOL ? 0 : 1; for (int i = start; i < 990; i++) { if ((in = _vm->_saveFileMan->openForLoading(_vm->getSavegameFilename(i)))) diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 2169e5283f..c224a76385 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -654,8 +654,6 @@ void KyraEngine_MR::startup() { _invWsa->open("MOODOMTR.WSA", 1, 0); _invWsaFrame = 6; saveGameState(0, "New Game", 0); - _soundDigital->beginFadeOut(_musicSoundChannel, 60); - delayWithTicks(60); if (_gameToLoad == -1) enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); else diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 1c27716a67..4d0248b1e4 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -179,7 +179,7 @@ Common::Error KyraEngine_v1::init() { #ifdef ENABLE_LOL _flags.gameID = GI_LOL; #else - error("Lands of Lore demo is not supported in this build."); + error("Lands of Lore demo is not supported in this build"); #endif // !ENABLE_LOL } diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index f05e113456..d077d3a3b0 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -387,6 +387,7 @@ protected: bool canSaveGameStateCurrently() { return _isSaveAllowed; } const char *getSavegameFilename(int num); + Common::String _savegameFilename; static Common::String getSavegameFilename(const Common::String &target, int num); bool saveFileLoadable(int slot); diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index efc1b16c9b..63b8072654 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -38,6 +38,11 @@ namespace Kyra { Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm) { initializeLoaders(); + // Initialize directories for playing from CD or with original + // directory structure + if (_vm->game() == GI_KYRA3) + SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.get("path")), "malcolm"); + _files.add("global_search", &Common::SearchManager::instance(), 3, false); // compressed installer archives are added at level '2', // but that's done in Resource::reset not here @@ -70,7 +75,7 @@ bool Resource::reset() { // List of files in the talkie version, which can never be unload. static const char * const list[] = { "ADL.PAK", "CHAPTER1.VRM", "COL.PAK", "FINALE.PAK", "INTRO1.PAK", "INTRO2.PAK", - "INTRO3.PAK", "INTRO4.PAK", "MISC.PAK", "SND.PAK", "STARTUP.PAK", "XMI.PAK", + "INTRO3.PAK", "INTRO4.PAK", "MISC.PAK", "SND.PAK", "STARTUP.PAK", "XMI.PAK", "CAVE.APK", "DRAGON1.APK", "DRAGON2.APK", "LAGOON.APK", 0 }; @@ -148,7 +153,7 @@ bool Resource::loadPakFile(Common::String filename) { return loadPakFile(filename, file); } -bool Resource::loadPakFile(Common::String name, Common::SharedPtr<Common::ArchiveMember> file) { +bool Resource::loadPakFile(Common::String name, Common::ArchiveMemberPtr file) { name.toUppercase(); if (_archiveFiles.hasArchive(name) || _protectedFiles.hasArchive(name)) @@ -314,7 +319,7 @@ Common::SeekableReadStream *Resource::createReadStream(const Common::String &fil return _files.createReadStreamForMember(file); } -Common::Archive *Resource::loadArchive(const Common::String &name, Common::SharedPtr<Common::ArchiveMember> member) { +Common::Archive *Resource::loadArchive(const Common::String &name, Common::ArchiveMemberPtr member) { ArchiveMap::iterator cachedArchive = _archiveCache.find(name); if (cachedArchive != _archiveCache.end()) return cachedArchive->_value; diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index d572c1ac54..8372bf9ad1 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -55,7 +55,7 @@ public: bool reset(); bool loadPakFile(Common::String filename); - bool loadPakFile(Common::String name, Common::SharedPtr<Common::ArchiveMember> file); + bool loadPakFile(Common::String name, Common::ArchiveMemberPtr file); void unloadPakFile(Common::String filename, bool remFromCache = false); @@ -86,7 +86,7 @@ protected: Common::SearchSet _archiveFiles; Common::SearchSet _protectedFiles; - Common::Archive *loadArchive(const Common::String &name, Common::SharedPtr<Common::ArchiveMember> member); + Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member); Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset); bool loadProtectedFiles(const char * const * list); diff --git a/engines/kyra/resource_intern.cpp b/engines/kyra/resource_intern.cpp index 1021cface5..445ea579a0 100644 --- a/engines/kyra/resource_intern.cpp +++ b/engines/kyra/resource_intern.cpp @@ -35,16 +35,8 @@ namespace Kyra { // -> PlainArchive implementation -PlainArchive::PlainArchive(Common::SharedPtr<Common::ArchiveMember> file, const FileInputList &files) +PlainArchive::PlainArchive(Common::ArchiveMemberPtr file) : _file(file), _files() { - for (FileInputList::const_iterator i = files.begin(); i != files.end(); ++i) { - Entry entry; - - entry.offset = i->offset; - entry.size = i->size; - - _files[i->name] = entry; - } } bool PlainArchive::hasFile(const Common::String &name) { @@ -81,6 +73,99 @@ Common::SeekableReadStream *PlainArchive::createReadStreamForMember(const Common return new Common::SeekableSubReadStream(parent, fDesc->_value.offset, fDesc->_value.offset + fDesc->_value.size, DisposeAfterUse::YES); } +void PlainArchive::addFileEntry(const Common::String &name, const Entry entry) { + _files[name] = entry; +} + +PlainArchive::Entry PlainArchive::getFileEntry(const Common::String &name) const { + FileMap::const_iterator fDesc = _files.find(name); + if (fDesc == _files.end()) + return Entry(); + return fDesc->_value; +} + +// -> TlkArchive implementation + +TlkArchive::TlkArchive(Common::ArchiveMemberPtr file, uint16 entryCount, const uint32 *fileEntries) + : _file(file), _entryCount(entryCount), _fileEntries(fileEntries) { +} + +TlkArchive::~TlkArchive() { + delete[] _fileEntries; +} + +bool TlkArchive::hasFile(const Common::String &name) { + return (findFile(name) != 0); +} + +int TlkArchive::listMembers(Common::ArchiveMemberList &list) { + uint count = 0; + + for (; count < _entryCount; ++count) { + const Common::String name = Common::String::printf("%08u.AUD", _fileEntries[count * 2 + 0]); + list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(name, this))); + } + + return count; +} + +Common::ArchiveMemberPtr TlkArchive::getMember(const Common::String &name) { + if (!hasFile(name)) + return Common::ArchiveMemberPtr(); + + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + +Common::SeekableReadStream *TlkArchive::createReadStreamForMember(const Common::String &name) const { + const uint32 *fileDesc = findFile(name); + if (!fileDesc) + return 0; + + Common::SeekableReadStream *parent = _file->createReadStream(); + if (!parent) + return 0; + + parent->seek(fileDesc[1], SEEK_SET); + const uint32 size = parent->readUint32LE(); + const uint32 fileStart = fileDesc[1] + 4; + + return new Common::SeekableSubReadStream(parent, fileStart, fileStart + size, DisposeAfterUse::YES); +} + +const uint32 *TlkArchive::findFile(const Common::String &name) const { + Common::String uppercaseName = name; + uppercaseName.toUppercase(); + + if (!uppercaseName.hasSuffix(".AUD")) + return 0; + + uint32 id; + if (sscanf(uppercaseName.c_str(), "%08u.AUD", &id) != 1) + return 0; + + // Binary search for the file entry + int leftIndex = 0; + int rightIndex = _entryCount - 1; + + while (leftIndex <= rightIndex) { + int mid = (leftIndex + rightIndex) / 2; + + const uint32 key = _fileEntries[mid * 2]; + if (key == id) { + // Found + return &_fileEntries[mid * 2]; + } else if (key > id) { + // Take the left sub-tree + rightIndex = mid - 1; + } else { + // Take the right sub-tree + leftIndex = mid + 1; + } + } + + return 0; +} + // -> CachedArchive implementation CachedArchive::CachedArchive(const FileInputList &files) @@ -142,6 +227,20 @@ bool ResLoaderPak::checkFilename(Common::String filename) const { return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".CMP") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename())); } +namespace { + +Common::String readString(Common::SeekableReadStream &stream) { + Common::String result; + char c = 0; + + while ((c = stream.readByte()) != 0) + result += c; + + return result; +} + +} // end of anonymous namespace + bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const { int32 filesize = stream.size(); if (filesize < 0) @@ -163,12 +262,7 @@ bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableRe if (offset < stream.pos() || offset > filesize || offset < 0) return false; - byte c = 0; - - file.clear(); - - while (!stream.eos() && (c = stream.readByte()) != 0) - file += c; + file = readString(stream); if (stream.eos()) return false; @@ -191,34 +285,15 @@ bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableRe return true; } -namespace { - -Common::String readString(Common::SeekableReadStream &stream) { - Common::String result; - char c = 0; - - while ((c = stream.readByte()) != 0) - result += c; - - return result; -} - -struct PlainArchiveListSearch { - PlainArchiveListSearch(const Common::String &search) : _search(search) {} - - bool operator()(const PlainArchive::InputEntry &entry) { - return _search.equalsIgnoreCase(entry.name); - } - Common::String _search; -}; - -} // end of anonymous namespace - -Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> memberFile, Common::SeekableReadStream &stream) const { +Common::Archive *ResLoaderPak::load(Common::ArchiveMemberPtr memberFile, Common::SeekableReadStream &stream) const { int32 filesize = stream.size(); if (filesize < 0) return 0; + Common::ScopedPtr<PlainArchive> result(new PlainArchive(memberFile)); + if (!result) + return 0; + int32 startoffset = 0, endoffset = 0; bool switchEndian = false; bool firstFile = true; @@ -229,8 +304,6 @@ Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> mem startoffset = SWAP_BYTES_32(startoffset); } - PlainArchive::FileInputList files; - Common::String file; while (!stream.eos()) { // The start offset of a file should never be in the filelist @@ -239,11 +312,7 @@ Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> mem return 0; } - file.clear(); - byte c = 0; - - while (!stream.eos() && (c = stream.readByte()) != 0) - file += c; + file = readString(stream); if (stream.eos()) { warning("PAK file '%s' is corrupted", memberFile->getDisplayName().c_str()); @@ -271,14 +340,8 @@ Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> mem if (!endoffset) endoffset = filesize; - if (startoffset != endoffset) { - PlainArchive::InputEntry entry; - entry.size = endoffset - startoffset; - entry.offset = startoffset; - entry.name = file; - - files.push_back(entry); - } + if (startoffset != endoffset) + result->addFileEntry(file, PlainArchive::Entry(startoffset, endoffset - startoffset)); if (endoffset == filesize) break; @@ -286,38 +349,32 @@ Common::Archive *ResLoaderPak::load(Common::SharedPtr<Common::ArchiveMember> mem startoffset = endoffset; } - PlainArchive::FileInputList::const_iterator iter = Common::find_if(files.begin(), files.end(), PlainArchiveListSearch("LINKLIST")); - if (iter != files.end()) { - stream.seek(iter->offset, SEEK_SET); + PlainArchive::Entry linklistFile = result->getFileEntry("LINKLIST"); + if (linklistFile.size != 0) { + stream.seek(linklistFile.offset, SEEK_SET); - uint32 magic = stream.readUint32BE(); + const uint32 magic = stream.readUint32BE(); if (magic != MKID_BE('SCVM')) error("LINKLIST file does not contain 'SCVM' header"); - uint32 links = stream.readUint32BE(); - for (uint i = 0; i < links; ++i) { - Common::String linksTo = readString(stream); - uint32 sources = stream.readUint32BE(); + const uint32 links = stream.readUint32BE(); + for (uint32 i = 0; i < links; ++i) { + const Common::String linksTo = readString(stream); + const uint32 sources = stream.readUint32BE(); - iter = Common::find_if(files.begin(), files.end(), PlainArchiveListSearch(linksTo)); - if (iter == files.end()) + PlainArchive::Entry destination = result->getFileEntry(linksTo); + if (destination.size == 0) error("PAK file link destination '%s' not found", linksTo.c_str()); - for (uint j = 0; j < sources; ++j) { - Common::String dest = readString(stream); - - PlainArchive::InputEntry link = *iter; - link.name = dest; - files.push_back(link); - - // Better safe than sorry, we update the 'iter' value, in case push_back invalidated it - iter = Common::find_if(files.begin(), files.end(), PlainArchiveListSearch(linksTo)); + for (uint32 j = 0; j < sources; ++j) { + const Common::String dest = readString(stream); + result->addFileEntry(dest, destination); } } } - return new PlainArchive(memberFile, files); + return result.release(); } // -> ResLoaderInsMalcolm implementation @@ -343,9 +400,11 @@ bool ResLoaderInsMalcolm::isLoadable(const Common::String &filename, Common::See return (buffer[0] == 0x0D && buffer[1] == 0x0A); } -Common::Archive *ResLoaderInsMalcolm::load(Common::SharedPtr<Common::ArchiveMember> memberFile, Common::SeekableReadStream &stream) const { +Common::Archive *ResLoaderInsMalcolm::load(Common::ArchiveMemberPtr memberFile, Common::SeekableReadStream &stream) const { Common::List<Common::String> filenames; - PlainArchive::FileInputList files; + Common::ScopedPtr<PlainArchive> result(new PlainArchive(memberFile)); + if (!result) + return 0; // thanks to eriktorbjorn for this code (a bit modified though) stream.seek(3, SEEK_SET); @@ -374,17 +433,14 @@ Common::Archive *ResLoaderInsMalcolm::load(Common::SharedPtr<Common::ArchiveMemb stream.seek(3, SEEK_SET); for (Common::List<Common::String>::iterator file = filenames.begin(); file != filenames.end(); ++file) { - PlainArchive::InputEntry entry; - entry.size = stream.readUint32LE(); - entry.offset = stream.pos(); - entry.name = *file; - entry.name.toLowercase(); - stream.seek(entry.size, SEEK_CUR); - - files.push_back(entry); + const uint32 fileSize = stream.readUint32LE(); + const uint32 fileOffset = stream.pos(); + + result->addFileEntry(*file, PlainArchive::Entry(fileOffset, fileSize)); + stream.seek(fileSize, SEEK_CUR); } - return new PlainArchive(memberFile, files); + return result.release(); } bool ResLoaderTlk::checkFilename(Common::String filename) const { @@ -412,31 +468,20 @@ bool ResLoaderTlk::isLoadable(const Common::String &filename, Common::SeekableRe return true; } -Common::Archive *ResLoaderTlk::load(Common::SharedPtr<Common::ArchiveMember> file, Common::SeekableReadStream &stream) const { - uint16 entries = stream.readUint16LE(); - PlainArchive::FileInputList files; - - for (uint i = 0; i < entries; ++i) { - PlainArchive::InputEntry entry; - - uint32 resFilename = stream.readUint32LE(); - uint32 resOffset = stream.readUint32LE(); +Common::Archive *ResLoaderTlk::load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const { + const uint16 entryCount = stream.readUint16LE(); - entry.offset = resOffset+4; + uint32 *fileEntries = new uint32[entryCount * 2]; + assert(fileEntries); + stream.read(fileEntries, sizeof(uint32) * entryCount * 2); - char realFilename[20]; - snprintf(realFilename, 20, "%.08u.AUD", resFilename); - entry.name = realFilename; - - uint32 curOffset = stream.pos(); - stream.seek(resOffset, SEEK_SET); - entry.size = stream.readUint32LE(); - stream.seek(curOffset, SEEK_SET); - - files.push_back(entry); + for (uint i = 0; i < entryCount; ++i) { + fileEntries[i * 2 + 0] = READ_LE_UINT32(&fileEntries[i * 2 + 0]); + fileEntries[i * 2 + 1] = READ_LE_UINT32(&fileEntries[i * 2 + 1]); } - return new PlainArchive(file, files); + + return new TlkArchive(file, entryCount, fileEntries); } // InstallerLoader implementation @@ -469,7 +514,7 @@ void FileExpanderSource::advSrcBitsBy1() { _key >>= 1; if (!--_bitsLeft) { if (_dataPtr < _endofBuffer) - _key = ((*_dataPtr++) << 8 ) | (_key & 0xff); + _key = ((*_dataPtr++) << 8) | (_key & 0xff); _bitsLeft = 8; } } diff --git a/engines/kyra/resource_intern.h b/engines/kyra/resource_intern.h index bceccc34b7..16f3a1fe91 100644 --- a/engines/kyra/resource_intern.h +++ b/engines/kyra/resource_intern.h @@ -38,33 +38,49 @@ class Resource; class PlainArchive : public Common::Archive { public: - struct InputEntry { - Common::String name; + struct Entry { + Entry() : offset(0), size(0) {} + Entry(uint32 o, uint32 s) : offset(o), size(s) {} uint32 offset; uint32 size; }; - typedef Common::List<InputEntry> FileInputList; + PlainArchive(Common::ArchiveMemberPtr file); - PlainArchive(Common::SharedPtr<Common::ArchiveMember> file, const FileInputList &files); + void addFileEntry(const Common::String &name, const Entry entry); + Entry getFileEntry(const Common::String &name) const; + // Common::Archive API implementation bool hasFile(const Common::String &name); int listMembers(Common::ArchiveMemberList &list); Common::ArchiveMemberPtr getMember(const Common::String &name); Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: - struct Entry { - uint32 offset; - uint32 size; - }; - typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap; - Common::SharedPtr<Common::ArchiveMember> _file; + Common::ArchiveMemberPtr _file; FileMap _files; }; +class TlkArchive : public Common::Archive { +public: + TlkArchive(Common::ArchiveMemberPtr file, uint16 entryCount, const uint32 *fileEntries); + ~TlkArchive(); + + bool hasFile(const Common::String &name); + int listMembers(Common::ArchiveMemberList &list); + Common::ArchiveMemberPtr getMember(const Common::String &name); + Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; +private: + Common::ArchiveMemberPtr _file; + + const uint32 *findFile(const Common::String &name) const; + + const uint16 _entryCount; + const uint32 * const _fileEntries; +}; + class CachedArchive : public Common::Archive { public: struct InputEntry { @@ -99,28 +115,28 @@ public: virtual ~ResArchiveLoader() {} virtual bool checkFilename(Common::String filename) const = 0; virtual bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const = 0; - virtual Common::Archive *load(Common::SharedPtr<Common::ArchiveMember> file, Common::SeekableReadStream &stream) const = 0; + virtual Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const = 0; }; class ResLoaderPak : public ResArchiveLoader { public: bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; - Common::Archive *load(Common::SharedPtr<Common::ArchiveMember> file, Common::SeekableReadStream &stream) const; + Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const; }; class ResLoaderInsMalcolm : public ResArchiveLoader { public: bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; - Common::Archive *load(Common::SharedPtr<Common::ArchiveMember> file, Common::SeekableReadStream &stream) const; + Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const; }; class ResLoaderTlk : public ResArchiveLoader { public: bool checkFilename(Common::String filename) const; bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const; - Common::Archive *load(Common::SharedPtr<Common::ArchiveMember> file, Common::SeekableReadStream &stream) const; + Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const; }; class InstallerLoader { diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index 56e1c73d0a..3ad7093046 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -137,7 +137,7 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena kReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, false, header); if (errorCode != kRSHENoError) { if (errorCode == kRSHEInvalidType) - warning("No ScummVM Kyra engine savefile header."); + warning("No ScummVM Kyra engine savefile header"); else if (errorCode == kRSHEInvalidVersion) warning("Savegame is not the right version (%u, '%s')", header.version, header.oldHeader ? "true" : "false"); else if (errorCode == kRSHEIoError) @@ -224,9 +224,8 @@ Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, con } const char *KyraEngine_v1::getSavegameFilename(int num) { - static Common::String filename; - filename = getSavegameFilename(_targetName, num); - return filename.c_str(); + _savegameFilename = getSavegameFilename(_targetName, num); + return _savegameFilename.c_str(); } Common::String KyraEngine_v1::getSavegameFilename(const Common::String &target, int num) { diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index ade9886c2e..b7e01f31aa 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -40,7 +40,7 @@ namespace Kyra { Screen::Screen(KyraEngine_v1 *vm, OSystem *system) : _system(system), _vm(vm), _sjisInvisibleColor(0), - _cursorColorKey((vm->gameFlags().gameID == GI_KYRA1) ? 0xFF : 0x00) { + _cursorColorKey((vm->game() == GI_KYRA1) ? 0xFF : 0x00) { _debugEnabled = false; _maskMinY = _maskMaxY = -1; @@ -86,7 +86,7 @@ bool Screen::init() { if (_vm->gameFlags().useHiResOverlay) { _useOverlays = true; _useSJIS = (_vm->gameFlags().lang == Common::JA_JPN); - _sjisInvisibleColor = (_vm->gameFlags().gameID == GI_KYRA1) ? 0x80 : 0xF6; + _sjisInvisibleColor = (_vm->game() == GI_KYRA1) ? 0x80 : 0xF6; for (int i = 0; i < SCREEN_OVLS_NUM; ++i) { if (!_sjisOverlayPtrs[i]) { @@ -787,7 +787,7 @@ void Screen::copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPag } if (y2 < 0) { - if (y2 <= -h ) + if (y2 <= -h) return; h += y2; y1 -= y2; @@ -1084,7 +1084,7 @@ void Screen::setTextColor(const uint8 *cmap, int a, int b) { bool Screen::loadFont(FontId fontId, const char *filename) { if (fontId == FID_SJIS_FNT) { - warning("Trying to replace system SJIS font."); + warning("Trying to replace system SJIS font"); return true; } @@ -1300,7 +1300,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int _dsScaleH = 0x100; } - if ((flags & 0x2000) && _vm->gameFlags().gameID != GI_KYRA1) + if ((flags & 0x2000) && _vm->game() != GI_KYRA1) _dsTable5 = va_arg(args, uint8 *); static const DsMarginSkipFunc dsMarginFunc[] = { @@ -1436,7 +1436,7 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int uint16 frameSize = READ_LE_UINT16(src); src += 2; - int colorTableColors = ((_vm->gameFlags().gameID != GI_KYRA1) && (shapeFlags & 4)) ? *src++ : 16; + int colorTableColors = ((_vm->game() != GI_KYRA1) && (shapeFlags & 4)) ? *src++ : 16; if (!(flags & 0x8000) && (shapeFlags & 1)) _dsTable2 = src; @@ -3016,10 +3016,10 @@ byte *Screen::getOverlayPtr(int page) { else if (page == 2 || page == 3) return _sjisOverlayPtrs[2]; - if (_vm->gameFlags().gameID == GI_KYRA2) { + if (_vm->game() == GI_KYRA2) { if (page == 12 || page == 13) return _sjisOverlayPtrs[3]; - } else if (_vm->gameFlags().gameID == GI_LOL) { + } else if (_vm->game() == GI_LOL) { if (page == 4 || page == 5) return _sjisOverlayPtrs[3]; if (page == 6 || page == 7) diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp index be3dbe5b21..e8ec7bc180 100644 --- a/engines/kyra/screen_lol.cpp +++ b/engines/kyra/screen_lol.cpp @@ -637,7 +637,7 @@ void Screen_LoL::copyRegionSpecial(int page1, int w1, int h1, int x1, int y1, in d++; } - for (int ii = (i & 1) ^ 1; ii < ibw_2; ii += 2 ) { + for (int ii = (i & 1) ^ 1; ii < ibw_2; ii += 2) { *d = *s; d += 2; s += 2; diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 3907f844cb..4d90bf2bab 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -53,7 +53,7 @@ uint8 *Screen_v2::generateOverlay(const Palette &pal, uint8 *buffer, int opColor int maxIndex = maxColor; if (maxIndex == -1) { - if (_vm->gameFlags().gameID == GI_LOL) { + if (_vm->game() == GI_LOL) { if (_use16ColorMode) maxIndex = 255; else @@ -64,9 +64,9 @@ uint8 *Screen_v2::generateOverlay(const Palette &pal, uint8 *buffer, int opColor } for (int i = 1; i != 256; ++i) { - const byte curR = pal[i * 3 + 0] - ((((pal[i * 3 + 0] - opR) * weight) >> 7) & 0x7F); - const byte curG = pal[i * 3 + 1] - ((((pal[i * 3 + 1] - opG) * weight) >> 7) & 0x7F); - const byte curB = pal[i * 3 + 2] - ((((pal[i * 3 + 2] - opB) * weight) >> 7) & 0x7F); + const byte curR = pal[i * 3 + 0] - (((pal[i * 3 + 0] - opR) * weight) >> 7); + const byte curG = pal[i * 3 + 1] - (((pal[i * 3 + 1] - opG) * weight) >> 7); + const byte curB = pal[i * 3 + 2] - (((pal[i * 3 + 2] - opB) * weight) >> 7); uint16 idxSum = _use16ColorMode ? 0xFFFF : 0x7FFF; byte index = opColor; diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index 20bc8abec5..61916b92c0 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -95,7 +95,7 @@ TIMInterpreter::TIMInterpreter(KyraEngine_v1 *engine, Screen_v2 *screen_v2, OSys _textDisplayed = false; _textAreaBuffer = new uint8[320*40]; assert(_textAreaBuffer); - if ((_vm->gameFlags().platform == Common::kPlatformPC98 || _vm->gameFlags().isDemo) && _vm->gameFlags().gameID == GI_LOL) + if ((_vm->gameFlags().platform == Common::kPlatformPC98 || _vm->gameFlags().isDemo) && _vm->game() == GI_LOL) _drawPage2 = 0; else _drawPage2 = 8; @@ -176,7 +176,7 @@ TIM *TIMInterpreter::load(const char *filename, const Common::Array<const TIMOpc Common::strlcpy(_tim->filename, filename, 13); - _tim->isLoLOutro = (_vm->gameFlags().gameID == GI_LOL) && !scumm_stricmp(filename, "LOLFINAL.TIM"); + _tim->isLoLOutro = (_vm->game() == GI_LOL) && !scumm_stricmp(filename, "LOLFINAL.TIM"); _tim->lolCharacter = 0; TIM *r = _tim; @@ -259,7 +259,7 @@ int TIMInterpreter::exec(TIM *tim, bool loop) { if (cur.ip) { cur.ip += cur.ip[0]; cur.lastTime = cur.nextTime; - cur.nextTime += (cur.ip[1] ) * _vm->tickLength(); + cur.nextTime += cur.ip[1] * _vm->tickLength(); } } } @@ -467,7 +467,7 @@ void TIMInterpreter::setupTextPalette(uint index, int fadePalette) { int TIMInterpreter::initAnimStruct(int index, const char *filename, int x, int y, int, int offscreenBuffer, uint16 wsaFlags) { Movie *wsa = 0; - const bool isLoLDemo = _vm->gameFlags().isDemo && _vm->gameFlags().gameID == GI_LOL; + const bool isLoLDemo = _vm->gameFlags().isDemo && _vm->game() == GI_LOL; if (isLoLDemo || _vm->gameFlags().platform == Common::kPlatformPC98 || _currentTim->isLoLOutro) _drawPage2 = 0; @@ -755,7 +755,7 @@ int TIMInterpreter::cmd_loadSoundFile(const uint16 *param) { const char *file = (const char *)(_currentTim->text + READ_LE_UINT16(_currentTim->text + (param[0]<<1))); _vm->sound()->loadSoundFile(file); - if (_vm->gameFlags().gameID == GI_LOL) + if (_vm->game() == GI_LOL) _vm->sound()->loadSfxFile(file); return 1; diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp index dc1a0f4d15..ac9148e607 100644 --- a/engines/kyra/sequences_lol.cpp +++ b/engines/kyra/sequences_lol.cpp @@ -81,6 +81,13 @@ int LoLEngine::processPrologue() { } switch (selection) { + case -1: + // This is sent on RTL for example, if we would not have any + // special case for this the default path would call quitGame + // and thus make the next game launched from the launcher + // quit instantly. + break; + case 0: // New game processSelection = 0; break; @@ -397,7 +404,8 @@ void LoLEngine::kingSelectionIntro() { _screen->fprintStringIntro("%s", 8, y + i * 10, 0x32, 0x00, 0x9C, 0x20, _tim->getCTableEntry(57 + i)); } - _sound->voicePlay("KING01", &_speechHandle); + if (_flags.isTalkie) + _sound->voicePlay("KING01", &_speechHandle); int index = 4; while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && !skipFlag()) { @@ -441,7 +449,8 @@ void LoLEngine::kingSelectionReminder() { _screen->fprintStringIntro("%s", 8, y + 10, 0x32, 0x00, 0x9C, 0x20, _tim->getCTableEntry(63)); } - _sound->voicePlay("KING02", &_speechHandle); + if (_flags.isTalkie) + _sound->voicePlay("KING02", &_speechHandle); int index = 0; while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && index < 15) { @@ -468,7 +477,8 @@ void LoLEngine::kingSelectionReminder() { } void LoLEngine::kingSelectionOutro() { - _sound->voicePlay("KING03", &_speechHandle); + if (_flags.isTalkie) + _sound->voicePlay("KING03", &_speechHandle); int index = 0; while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && !shouldQuit() && !skipFlag()) { @@ -627,7 +637,8 @@ void LoLEngine::selectionCharInfoIntro(char *file) { if (speechEnabled() && !_sound->isVoicePresent(file)) break; - _sound->voicePlay(file, &_speechHandle); + if (_flags.isTalkie) + _sound->voicePlay(file, &_speechHandle); int i = 0; while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelectionInfoResult == -1 && !shouldQuit()) { diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 9ab4aa0053..8458d751de 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -2241,7 +2241,7 @@ const int SoundAdLibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdLibPC::_kyra1S SoundAdLibPC::SoundAdLibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) { memset(_trackEntries, 0, sizeof(_trackEntries)); - _v2 = (_vm->gameFlags().gameID == GI_KYRA2) || (_vm->gameFlags().gameID == GI_LOL && !_vm->gameFlags().isDemo); + _v2 = (_vm->game() == GI_KYRA2) || (_vm->game() == GI_LOL && !_vm->gameFlags().isDemo); _driver = new AdLibDriver(mixer, _v2); assert(_driver); diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index 5b5a548f4a..150bafbef3 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -158,7 +158,6 @@ AUDStream::AUDStream(Common::SeekableReadStream *stream) : _stream(stream), _end _outBufferOffset(0), _outBufferSize(0), _inBuffer(0), _inBufferSize(0) { _rate = _stream->readUint16LE(); - _length = Audio::Timestamp(0, _rate); _totalSize = _stream->readUint32LE(); // TODO?: add checks @@ -167,6 +166,9 @@ AUDStream::AUDStream(Common::SeekableReadStream *stream) : _stream(stream), _end _streamStart = stream->pos(); + debugC(5, kDebugLevelSound, "AUD Info: rate: %d, totalSize: %d, flags: %d, type: %d, streamStart: %d", _rate, _totalSize, flags, type, _streamStart); + + _length = Audio::Timestamp(0, _rate); for (uint32 i = 0; i < _totalSize;) { uint16 size = _stream->readUint16LE(); uint16 outSize = _stream->readUint16LE(); @@ -460,6 +462,7 @@ int SoundDigital::playSound(const char *filename, uint8 priority, Audio::Mixer:: Common::strlcpy(use->filename, filename, sizeof(use->filename)); use->priority = priority; + debugC(5, kDebugLevelSound, "playSound: \"%s\"", use->filename); Audio::SeekableAudioStream *audioStream = _supportedCodecs[usedCodec].streamFunc(stream, DisposeAfterUse::YES); if (!audioStream) { warning("Couldn't create audio stream for file '%s'", filename); diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp index 026c72de26..c24ce5a95b 100644 --- a/engines/kyra/sound_midi.cpp +++ b/engines/kyra/sound_midi.cpp @@ -134,10 +134,14 @@ MidiOutput::MidiOutput(OSystem *system, MidiDriver *output, bool isMT32, bool de static const byte sysEx2[] = { 3, 4, 3, 4, 3, 4, 3, 4, 4 }; static const byte sysEx3[] = { 0, 3, 2 }; - sendSysEx(0x7F, 0x00, 0x00, sysEx1, 1); - sendSysEx(0x10, 0x00, 0x0D, sysEx1, 9); - sendSysEx(0x10, 0x00, 0x04, sysEx2, 9); - sendSysEx(0x10, 0x00, 0x01, sysEx3, 3); + if (_isMT32) { + sendSysEx(0x7F, 0x00, 0x00, sysEx1, 1); + sendSysEx(0x10, 0x00, 0x0D, sysEx1, 9); + sendSysEx(0x10, 0x00, 0x04, sysEx2, 9); + sendSysEx(0x10, 0x00, 0x01, sysEx3, 3); + } else { + _output->sendGMReset(); + } memset(_channels, 0, sizeof(_channels)); for (int i = 0; i < 16; ++i) { @@ -519,12 +523,12 @@ bool SoundMidiPC::init() { if (_nativeMT32 && _type == kMidiMT32) { const char *midiFile = 0; const char *pakFile = 0; - if (_vm->gameFlags().gameID == GI_KYRA1) { + if (_vm->game() == GI_KYRA1) { midiFile = "INTRO"; - } else if (_vm->gameFlags().gameID == GI_KYRA2) { + } else if (_vm->game() == GI_KYRA2) { midiFile = "HOF_SYX"; pakFile = "AUDIO.PAK"; - } else if (_vm->gameFlags().gameID == GI_LOL) { + } else if (_vm->game() == GI_LOL) { midiFile = "LOREINTR"; if (_vm->gameFlags().isDemo) { @@ -618,7 +622,7 @@ void SoundMidiPC::loadSoundFile(Common::String file) { // Since KYRA1 uses the same file for SFX and Music // we setup sfx to play from music file as well - if (_vm->gameFlags().gameID == GI_KYRA1) { + if (_vm->game() == GI_KYRA1) { for (int i = 0; i < 3; ++i) { _output->setSoundSource(i+1); _sfx[i]->loadMusic(_musicFile, fileSize); @@ -631,7 +635,7 @@ void SoundMidiPC::loadSfxFile(Common::String file) { Common::StackLock lock(_mutex); // Kyrandia 1 doesn't use a special sfx file - if (_vm->gameFlags().gameID == GI_KYRA1) + if (_vm->game() == GI_KYRA1) return; file = getFileName(file); diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp index d27b075906..86a1eb228e 100644 --- a/engines/kyra/sound_towns.cpp +++ b/engines/kyra/sound_towns.cpp @@ -47,6 +47,7 @@ SoundTowns::SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer) SoundTowns::~SoundTowns() { g_system->getAudioCDManager()->stop(); haltTrack(); + delete _driver; delete[] _musicTrackData; delete[] _sfxFileData; } @@ -585,13 +586,13 @@ void SoundTownsPC98_v2::beginFadeOut() { } int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle, uint8, bool) { - //static const uint16 rates[] = { 0x10E1, 0x0CA9, 0x0870, 0x0654, 0x0438, 0x032A, 0x021C, 0x0194 }; + static const uint16 rates[] = { 0x10E1, 0x0CA9, 0x0870, 0x0654, 0x0438, 0x032A, 0x021C, 0x0194 }; static const char patternHOF[] = "%s.PCM"; static const char patternLOL[] = "%s.VOC"; int h = 0; if (_currentSFX) { - while (_mixer->isSoundHandleActive(_soundChannels[h]) && h < kNumChannelHandles) + while (h < kNumChannelHandles && _mixer->isSoundHandleActive(_soundChannels[h])) h++; if (h >= kNumChannelHandles) return 0; @@ -606,7 +607,7 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle, if (!src) return 0; - //uint16 sfxRate = rates[READ_LE_UINT16(src)]; + uint16 sfxRate = rates[READ_LE_UINT16(src)]; src += 2; bool compressed = (READ_LE_UINT16(src) & 1) ? true : false; src += 2; @@ -646,8 +647,7 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle, sfx[i] = cmd; } - _currentSFX = Audio::makeRawStream(sfx, outsize, 11025, - Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN); + _currentSFX = Audio::makeRawStream(sfx, outsize, sfxRate * 10, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN); _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundChannels[h], _currentSFX); if (handle) *handle = _soundChannels[h]; diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index 4fa12fd687..52689869c6 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -71,7 +71,7 @@ void Sprites::setupSceneAnims() { if (_anims[i].script != 0) { data = _anims[i].script; - assert( READ_LE_UINT16(data) == 0xFF86 ); + assert(READ_LE_UINT16(data) == 0xFF86); data += 4; _anims[i].disable = READ_LE_UINT16(data) != 0; @@ -509,7 +509,7 @@ void Sprites::loadDat(const char *filename, SceneExits &exits) { } void Sprites::freeSceneShapes() { - for (int i = 0; i < ARRAYSIZE(_sceneShapes); i++ ) { + for (int i = 0; i < ARRAYSIZE(_sceneShapes); i++) { delete[] _sceneShapes[i]; _sceneShapes[i] = 0; } diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 4b71b1d69d..a06b488c86 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -878,7 +878,7 @@ void KyraEngine_LoK::loadItems() { _shapes[323] = 0; - for (shape = 1; shape < 6; shape++ ) + for (shape = 1; shape < 6; shape++) _shapes[323 + shape] = _screen->encodeShape((shape - 1) * 32, 0, 32, 17, 0); for (shape = 330; shape <= 334; shape++) diff --git a/engines/kyra/text_hof.cpp b/engines/kyra/text_hof.cpp index 9d20cdd51a..4c292b70db 100644 --- a/engines/kyra/text_hof.cpp +++ b/engines/kyra/text_hof.cpp @@ -544,7 +544,7 @@ void KyraEngine_HoF::processDialogue(int dlgOffset, int vocH, int csEntry) { } objectChat((const char *)_unkBuf500Bytes, 0, vocHi, vocLo); } else { - if (activeTimSequence != nextTimSequence ) { + if (activeTimSequence != nextTimSequence) { if (activeTimSequence > -1) { deinitTalkObject(activeTimSequence); activeTimSequence = -1; diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp index d5264be483..7f9531507c 100644 --- a/engines/kyra/text_lol.cpp +++ b/engines/kyra/text_lol.cpp @@ -204,10 +204,12 @@ void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, } void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) { - static uint8 textColors256[] = { 0xfe, 0xa2, 0x84, 0x97, 0x9F }; - static uint8 textColors16[] = { 0x33, 0xaa, 0x88, 0x55, 0x99 }; - static uint8 soundEffect[] = { 0x0B, 0x00, 0x2B, 0x1B, 0x00 }; + static const uint8 textColors256[] = { 0xfe, 0xa2, 0x84, 0x97, 0x9F }; + static const uint8 textColors16[] = { 0x33, 0xaa, 0x88, 0x55, 0x99 }; + static const uint8 soundEffect[] = { 0x0B, 0x00, 0x2B, 0x1B, 0x00 }; + const uint8 *textColors = _vm->gameFlags().use16ColorMode ? textColors16 : textColors256; + if (type & 4) type ^= 4; else |