From 6ee82a20276d213a06d43ff731d197f5a92a09d7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 25 Jun 2010 16:16:29 +0000 Subject: SCI: Introduce SciGameId enum svn-id: r50273 --- engines/sci/console.cpp | 2 +- engines/sci/detection.cpp | 92 ++++++++++++++++++++++++++++++--- engines/sci/engine/kernel.cpp | 4 +- engines/sci/engine/kgraphics.cpp | 2 +- engines/sci/engine/kmisc.cpp | 4 +- engines/sci/engine/kpathing.cpp | 4 +- engines/sci/engine/segment.cpp | 4 +- engines/sci/engine/static_selectors.cpp | 2 +- engines/sci/engine/vm.cpp | 28 +++++----- engines/sci/graphics/paint16.cpp | 2 +- engines/sci/graphics/picture.cpp | 4 +- engines/sci/graphics/ports.cpp | 32 +++++++++--- engines/sci/graphics/screen.cpp | 4 +- engines/sci/resource.h | 2 +- engines/sci/resource_audio.cpp | 32 ++++++++---- engines/sci/sci.cpp | 18 ++++--- engines/sci/sci.h | 76 +++++++++++++++++++++++++-- 17 files changed, 247 insertions(+), 65 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index b987450d3a..e8cbb6cf0e 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -425,7 +425,7 @@ bool Console::cmdGetVersion(int argc, const char **argv) { bool hasVocab997 = g_sci->getResMan()->testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS)) ? true : false; - DebugPrintf("Game ID: %s\n", _engine->getGameId().c_str()); + DebugPrintf("Game ID: %s\n", _engine->getGameIdStr()); DebugPrintf("Emulated interpreter version: %s\n", getSciVersionDesc(getSciVersion())); DebugPrintf("\n"); DebugPrintf("Detected features:\n"); diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 3b153d3dd1..0932cb3fdc 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -40,7 +40,7 @@ namespace Sci { // Titles of the games -static const PlainGameDescriptor SciGameTitles[] = { +static const PlainGameDescriptor s_sciGameTitles[] = { {"sci", "Sierra SCI Game"}, {"sci-fanmade", "Fanmade SCI Game"}, // === SCI0 games ========================================================= @@ -119,6 +119,80 @@ static const PlainGameDescriptor SciGameTitles[] = { {0, 0} }; +struct GameIdStrToEnum { + const char *gameidStr; + SciGameId gameidEnum; +}; + +static const GameIdStrToEnum s_gameIdStrToEnum[] = { + { "astrochicken", GID_ASTROCHICKEN }, + { "camelot", GID_CAMELOT }, + { "castlebrain", GID_CASTLEBRAIN }, + { "christmas1988", GID_CHRISTMAS1988 }, + { "christmas1990", GID_CHRISTMAS1990 }, + { "christmas1992", GID_CHRISTMAS1992 }, + { "cnick-kq", GID_CNICK_KQ }, + { "cnick-laurabow", GID_CNICK_LAURABOW }, + { "cnick-longbow", GID_CNICK_LONGBOW }, + { "cnick-lsl", GID_CNICK_LSL }, + { "cnick-sq", GID_CNICK_SQ }, + { "ecoquest", GID_ECOQUEST }, + { "ecoquest2", GID_ECOQUEST2 }, + { "fairytales", GID_FAIRYTALES }, + { "freddypharkas", GID_FREDDYPHARKAS }, + { "funseeker", GID_FUNSEEKER }, + { "gk1", GID_GK1 }, + { "gk2", GID_GK2 }, + { "hoyle1", GID_HOYLE1 }, + { "hoyle2", GID_HOYLE2 }, + { "hoyle3", GID_HOYLE3 }, + { "hoyle4", GID_HOYLE4 }, + { "iceman", GID_ICEMAN }, + { "islandbrain", GID_ISLANDBRAIN }, + { "jones", GID_JONES }, + { "kq1sci", GID_KQ1 }, + { "kq4sci", GID_KQ4 }, + { "kq5", GID_KQ5 }, + { "kq6", GID_KQ6 }, + { "kq7", GID_KQ7 }, + { "laurabow", GID_LAURABOW }, + { "laurabow2", GID_LAURABOW2 }, + { "lighthouse", GID_LIGHTHOUSE }, + { "longbow", GID_LONGBOW }, + { "lsl1sci", GID_LSL1 }, + { "lsl2", GID_LSL2 }, + { "lsl3", GID_LSL3 }, + { "lsl5", GID_LSL5 }, + { "lsl6", GID_LSL6 }, + { "lsl7", GID_LSL7 }, + { "mothergoose", GID_MOTHERGOOSE }, + { "msastrochicken", GID_MSASTROCHICKEN }, + { "pepper", GID_PEPPER }, + { "phantasmagoria", GID_PHANTASMAGORIA }, + { "phantasmagoria2", GID_PHANTASMAGORIA2 }, + { "pq1sci", GID_PQ1 }, + { "pq2", GID_PQ2 }, + { "pq3", GID_PQ3 }, + { "pq4", GID_PQ4 }, + { "pqswat", GID_PQSWAT }, + { "qfg1", GID_QFG1 }, + { "qfg2", GID_QFG2 }, + { "qfg3", GID_QFG3 }, + { "qfg4", GID_QFG4 }, + { "rama", GID_RAMA }, + { "sci-fanmade", GID_FANMADE }, // FIXME: Do we really need/want this? + { "shivers", GID_SHIVERS }, + { "shivers2", GID_SHIVERS2 }, + { "slater", GID_SLATER }, + { "sq1sci", GID_SQ1 }, + { "sq3", GID_SQ3 }, + { "sq4", GID_SQ4 }, + { "sq5", GID_SQ5 }, + { "sq6", GID_SQ6 }, + { "torin", GID_TORIN }, + { NULL, (SciGameId)-1 } +}; + struct OldNewIdTableEntry { const char *oldId; const char *newId; @@ -300,7 +374,7 @@ static const ADParams detectionParams = { // Number of bytes to compute MD5 sum for 5000, // List of all engine targets - SciGameTitles, + s_sciGameTitles, // Structure for autoupgrading obsolete targets 0, // Name of single gameid (optional) @@ -523,12 +597,16 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl return (const ADGameDescription *)&s_fallbackDesc; } -bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { - const ADGameDescription *desc = (const ADGameDescription *)gd; - - *engine = new SciEngine(syst, desc); +bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + const GameIdStrToEnum *g = s_gameIdStrToEnum; + for (; g->gameidStr; ++g) { + if (0 == strcmp(desc->gameid, g->gameidStr)) { + *engine = new SciEngine(syst, desc, g->gameidEnum); + return true; + } + } - return true; + return false; } bool SciMetaEngine::hasFeature(MetaEngineFeature f) const { diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 41a2d2dd2b..d6dcf650bc 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -745,7 +745,7 @@ void Kernel::setDefaultKernelNames() { // In SCI1.1, kSetSynonyms is an empty function _kernelNames[0x26] = "Empty"; - if (g_sci->getGameId() == "kq6") { + if (g_sci->getGameId() == GID_KQ6) { // In the Windows version of KQ6 CD, the empty kSetSynonyms // function has been replaced with kPortrait. In KQ6 Mac, // kPlayBack has been replaced by kShowMovie. @@ -753,7 +753,7 @@ void Kernel::setDefaultKernelNames() { _kernelNames[0x26] = "Portrait"; else if (g_sci->getPlatform() == Common::kPlatformMacintosh) _kernelNames[0x84] = "ShowMovie"; - } else if (g_sci->getGameId() == "qfg4" && g_sci->isDemo()) { + } else if (g_sci->getGameId() == GID_QFG4 && g_sci->isDemo()) { _kernelNames[0x7b] = "RemapColors"; // QFG4 Demo has this SCI2 function instead of StrSplit } diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 756ac6ffcb..b1cd1451d1 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -541,7 +541,7 @@ reg_t kBaseSetter(EngineState *s, int argc, reg_t *argv) { // WORKAROUND for a problem in LSL1VGA. This allows the casino door to be opened, // till the actual problem is found - if (s->currentRoomNumber() == 300 && g_sci->getGameId() == "lsl1sci") { + if (s->currentRoomNumber() == 300 && g_sci->getGameId() == GID_LSL1) { int top = readSelectorValue(s->_segMan, object, SELECTOR(brTop)); writeSelectorValue(s->_segMan, object, SELECTOR(brTop), top + 2); } diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 4dd7df1b52..f742734ad7 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -60,9 +60,9 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) { // throttling resulting in having to do 1000 pushups or something. Another // way of handling this would be delaying incrementing of "machineSpeed" // selector. - if (g_sci->getGameId() == "lsl3" && s->currentRoomNumber() == 290) + if (g_sci->getGameId() == GID_LSL3 && s->currentRoomNumber() == 290) s->_throttleTrigger = true; - else if (g_sci->getGameId() == "iceman" && s->currentRoomNumber() == 27) { + else if (g_sci->getGameId() == GID_ICEMAN && s->currentRoomNumber() == 27) { s->_throttleTrigger = true; neededSleep = 60; } diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index ba6fb9bb6e..fdaae3e121 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1090,7 +1090,7 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) { // WORKAROUND: broken polygon in lsl1sci, room 350, after opening elevator // Polygon has 17 points but size is set to 19 - if ((size == 19) && g_sci->getGameId() == "lsl1sci") { + if ((size == 19) && g_sci->getGameId() == GID_LSL1) { if ((s->currentRoomNumber() == 350) && (read_point(segMan, points, 18) == Common::Point(108, 137))) { debug(1, "Applying fix for broken polygon in lsl1sci, room 350"); @@ -1212,7 +1212,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co // WORKAROUND LSL5 room 660. Priority glitch due to us choosing a different path // than SSCI. Happens when Patti walks to the control room. - if (g_sci->getGameId() == "lsl5" && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) { + if (g_sci->getGameId() == GID_LSL5 && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) { debug(1, "[avoidpath] Applying fix for priority problem in LSL5, room 660"); pf_s->_prependPoint = new_start; new_start = new Common::Point(77, 107); diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 6a564fcc57..0a39d950b0 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -465,7 +465,7 @@ SegmentRef LocalVariables::dereference(reg_t pointer) { ret.reg = &_locals[pointer.offset / 2]; } else { if ((g_sci->getEngineState()->currentRoomNumber() == 660 || g_sci->getEngineState()->currentRoomNumber() == 660) - && g_sci->getGameId() == "laurabow2") { + && g_sci->getGameId() == GID_LAURABOW2) { // Happens in two places during the intro of LB2CD, both from kMemory(peek): // - room 160: Heap 160 has 83 local variables (0-82), and the game // asks for variables at indices 83 - 90 too. @@ -520,7 +520,7 @@ SegmentRef SystemStrings::dereference(reg_t pointer) { if (isValidOffset(pointer.offset)) ret.raw = (byte *)(_strings[pointer.offset]._value); else { - if (g_sci->getGameId() == "kq5") { + if (g_sci->getGameId() == GID_KQ5) { // This occurs in KQ5CD when interacting with certain objects } else { error("SystemStrings::dereference(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp index 12d61ed24a..85089e74c8 100644 --- a/engines/sci/engine/static_selectors.cpp +++ b/engines/sci/engine/static_selectors.cpp @@ -158,7 +158,7 @@ Common::StringArray Kernel::checkStaticSelectorNames() { } } - if (g_sci->getGameId() == "hoyle4") { + if (g_sci->getGameId() == GID_HOYLE4) { // The demo of Hoyle 4 is one of the few demos with lip syncing and no selector vocabulary. // This needs two selectors, "syncTime" and "syncCue", which keep changing positions in each // game. Usually, games with speech and lip sync have a selector vocabulary, so we don't need diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 3295406745..3dad005bb2 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -169,7 +169,7 @@ static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, in } else { // WORKAROUND: Mixed-Up Mother Goose tries to use an invalid parameter in Event::new(). // Just skip around it here so we don't error out in validate_arithmetic. - if (g_sci->getGameId() == "mothergoose" && getSciVersion() <= SCI_VERSION_1_1 && type == VAR_PARAM && index == 1) + if (g_sci->getGameId() == GID_MOTHERGOOSE && getSciVersion() <= SCI_VERSION_1_1 && type == VAR_PARAM && index == 1) return false; debugC(2, kDebugLevelVM, "%s", txt.c_str()); @@ -184,20 +184,22 @@ static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, in } struct UninitializedReadWorkaround { - const char *gameId; + SciGameId gameId; int scriptNr; const char *objectName; const char *methodName; int index; uint16 newValue; -} static const uninitializedReadWorkarounds[] = { - { "laurabow2", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu - { "freddypharkas", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu - { "freddypharkas", 31, "quitWin", "open", 5, 0xf }, // is used as priority for game menu - { "lsl1sci", 720, "rm720", "init", 0, 0 }, // age check room - { "islandbrain", 140, "piece", "init", 3, 1 }, // some initialization variable. bnt is done on it, and it should be non-0 - { "sq4", 928, "Narrator", "startText", 1000, 1 }, // sq4cd: method returns this to the caller - { NULL, -1, NULL, NULL, 0, 0 } +}; + +static const UninitializedReadWorkaround uninitializedReadWorkarounds[] = { + { GID_LAURABOW2, 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu + { GID_FREDDYPHARKAS, 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu + { GID_FREDDYPHARKAS, 31, "quitWin", "open", 5, 0xf }, // is used as priority for game menu + { GID_LSL1, 720, "rm720", "init", 0, 0 }, // age check room + { GID_ISLANDBRAIN, 140, "piece", "init", 3, 1 }, // some initialization variable. bnt is done on it, and it should be non-0 + { GID_SQ4, 928, "Narrator", "startText", 1000, 1 }, // sq4cd: method returns this to the caller + { (SciGameId)0, -1, NULL, NULL, 0, 0 } }; static reg_t validate_read_var(reg_t *r, reg_t *stack_base, int type, int max, int index, int line, reg_t default_value) { @@ -218,14 +220,14 @@ static reg_t validate_read_var(reg_t *r, reg_t *stack_base, int type, int max, i Common::String curObjectName = state->_segMan->getObjectName(call.sendp); Common::String curMethodName; - Common::String gameId = g_sci->getGameId(); + const SciGameId gameId = g_sci->getGameId(); if (call.type == EXEC_STACK_TYPE_CALL) curMethodName = g_sci->getKernel()->getSelectorName(call.selector); // Search if this is a known uninitialized read const UninitializedReadWorkaround *workaround = uninitializedReadWorkarounds; - while (workaround->gameId) { + while (workaround->objectName) { if (workaround->gameId == gameId && workaround->scriptNr == curScriptNr && workaround->objectName == curObjectName && workaround->methodName == curMethodName && workaround->index == index) { // Workaround found @@ -481,7 +483,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt if (!strcmp(objectName, "Sq4GlobalNarrator") && selector == 606) { // SQ4 has a script bug in the Sq4GlobalNarrator object when invoking the // returnVal selector, which doesn't affect gameplay, thus don't diplay it - } else if (!strcmp(objectName, "longSong") && selector == 3 && g_sci->getGameId() == "qfg1") { + } else if (!strcmp(objectName, "longSong") && selector == 3 && g_sci->getGameId() == GID_QFG1) { // QFG1VGA has a script bug in the longSong object when invoking the // loop selector, which doesn't affect gameplay, thus don't diplay it } else { diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp index 4cf3cc16e5..c5b97ad216 100644 --- a/engines/sci/graphics/paint16.cpp +++ b/engines/sci/graphics/paint16.cpp @@ -524,7 +524,7 @@ reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) { // 2 Dummy functions, longbow-demo is using those several times but sierra sci doesn't support them at all case SCI_DISPLAY_DUMMY1: case SCI_DISPLAY_DUMMY2: - if (!((g_sci->getGameId() == "longbow") && (g_sci->isDemo()))) + if (!((g_sci->getGameId() == GID_LONGBOW) && (g_sci->isDemo()))) error("Unknown kDisplay argument %X", displayArg); if (displayArg == SCI_DISPLAY_DUMMY2) { if (argc) { diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index b410fc47f1..7cd37b6f46 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -437,7 +437,7 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { memcpy(&EGApalettes[i], &vector_defaultEGApalette, sizeof(vector_defaultEGApalette)); memcpy(&EGApriority, &vector_defaultEGApriority, sizeof(vector_defaultEGApriority)); - if (g_sci->getGameId() == "iceman") { + if (g_sci->getGameId() == GID_ICEMAN) { // WORKAROUND: we remove certain visual&priority lines in underwater rooms of iceman, when not dithering the // picture. Normally those lines aren't shown, because they share the same color as the dithered // fill color combination. When not dithering, those lines would appear and get distracting. @@ -532,7 +532,7 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { // inside picture data for such games case PIC_OP_SET_PATTERN: if (_resourceType >= SCI_PICTURE_TYPE_SCI11) { - if (g_sci->getGameId() == "sq4") { + if (g_sci->getGameId() == GID_SQ4) { // WORKAROUND: For SQ4 / for some pictures handle this like a terminator // This picture includes garbage data, first a set pattern w/o parameter and then short pattern // I guess that garbage is a left over from the sq4-floppy (sci1) to sq4-cd (sci1.1) conversion diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index a9bf81f013..6e53ef44c4 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -55,7 +55,7 @@ GfxPorts::~GfxPorts() { } void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *text16) { - int16 offTop = 10; + int16 offTop; _usesOldGfxFunctions = usesOldGfxFunctions; _paint16 = paint16; @@ -84,15 +84,33 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te else _styleUser = SCI_WINDOWMGR_STYLE_USER | SCI_WINDOWMGR_STYLE_TRANSPARENT; - // Jones, Slater, Hoyle 3&4 and Crazy Nicks Laura Bow/Kings Quest were called with parameter -Nw 0 0 200 320. - // Mother Goose (SCI1) uses -Nw 0 0 159 262. The game will later use SetPort so we don't need to set the other fields. + // Jones, Slater, Hoyle 3&4 and Crazy Nicks Laura Bow/Kings Quest were + // called with parameter -Nw 0 0 200 320. + // Mother Goose (SCI1) uses -Nw 0 0 159 262. The game will later use + // SetPort so we don't need to set the other fields. // This actually meant not skipping the first 10 pixellines in windowMgrPort - Common::String gameId = g_sci->getGameId(); - if (gameId == "jones" || gameId == "slater" || gameId == "hoyle3" || gameId == "hoyle4" || gameId == "cnick-laurabow" || gameId == "cnick-kq" || (gameId == "mothergoose" && getSciVersion() == SCI_VERSION_1_EARLY)) + switch (g_sci->getGameId()) { + case GID_JONES: + case GID_SLATER: + case GID_HOYLE3: + case GID_HOYLE4: + case GID_CNICK_LAURABOW: + case GID_CNICK_KQ: offTop = 0; - // Mixed-Up Fairy Tales (& its demo) uses -w 26 0 200 320. If we don't also do this we will get not-fully-removed windows everywhere - if (gameId == "fairytales") + break; + case GID_MOTHERGOOSE: + if (getSciVersion() == SCI_VERSION_1_EARLY) + offTop = 0; + break; + case GID_FAIRYTALES: + // Mixed-Up Fairy Tales (& its demo) uses -w 26 0 200 320. If we don't + // also do this we will get not-fully-removed windows everywhere. offTop = 26; + break; + default: + offTop = 10; + break; + } openPort(_wmgrPort); setPort(_wmgrPort); diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 82ff478da2..bcb86e2d6f 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -97,9 +97,9 @@ GfxScreen::GfxScreen(ResourceManager *resMan, int16 width, int16 height, int ups if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1) { // For SCI1.1 Mac, we need to expand the screen to accommodate for // the icon bar. Of course, both KQ6 and QFG1 VGA differ in size. - if (g_sci->getGameId() == "kq6") + if (g_sci->getGameId() == GID_KQ6) initGraphics(_displayWidth, _displayHeight + 26, _displayWidth > 320); - else if (g_sci->getGameId() == "qfg1") + else if (g_sci->getGameId() == GID_QFG1) initGraphics(_displayWidth, _displayHeight + 20, _displayWidth > 320); else error("Unknown SCI1.1 Mac game"); diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 00197876d8..584c61dbd6 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -323,7 +323,7 @@ public: * archive can be extracted in the extras directory, and the GM patches can be * applied per game, if applicable. */ - void addNewGMPatch(const Common::String &gameId); + void addNewGMPatch(SciGameId gameId); bool detectHires(); // Detects, if standard font of current game includes extended characters (>0x80) diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index 909f1d6480..8629fecfa7 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -143,27 +143,37 @@ bool Resource::loadFromAudioVolumeSCI1(Common::SeekableReadStream *file) { return true; } -void ResourceManager::addNewGMPatch(const Common::String &gameId) { +void ResourceManager::addNewGMPatch(SciGameId gameId) { Common::String gmPatchFile; - if (gameId == "ecoquest") + switch (gameId) { + case GID_ECOQUEST: gmPatchFile = "ECO1GM.PAT"; - else if (gameId == "hoyle3") - gmPatchFile = "HOY3GM.PAT"; - else if (gameId == "hoyle3") + break; + case GID_HOYLE3: gmPatchFile = "HOY3GM.PAT"; - else if (gameId == "lsl1sci") + break; + case GID_LSL1: gmPatchFile = "LL1_GM.PAT"; - else if (gameId == "lsl5") + break; + case GID_LSL5: gmPatchFile = "LL5_GM.PAT"; - else if (gameId == "longbow") + break; + case GID_LONGBOW: gmPatchFile = "ROBNGM.PAT"; - else if (gameId == "sq1sci") + break; + case GID_SQ1: gmPatchFile = "SQ1_GM.PAT"; - else if (gameId == "sq4") + break; + case GID_SQ4: gmPatchFile = "SQ4_GM.PAT"; - else if (gameId == "fairytales") + break; + case GID_FAIRYTALES: gmPatchFile = "TALEGM.PAT"; + break; + default: + break; + } if (!gmPatchFile.empty() && Common::File::exists(gmPatchFile)) { ResourceSource *psrcPatch = new PatchResourceSource(gmPatchFile); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 527c2d24ba..6decfc7c27 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -71,8 +71,8 @@ SciEngine *g_sci = 0; class GfxDriver; -SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) - : Engine(syst), _gameDescription(desc), _gameId(_gameDescription->gameid) { +SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId) + : Engine(syst), _gameDescription(desc), _gameId(gameId) { assert(g_sci == 0); g_sci = this; @@ -128,7 +128,7 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) // Add the patches directory, except for KQ6CD; The patches folder in some versions of KQ6CD // is for the demo of Phantasmagoria, included in the disk - if (_gameId != "kq6") + if (_gameId != GID_KQ6) SearchMan.addSubDirectoryMatching(gameDataDir, "patches"); // resource patches } @@ -179,10 +179,10 @@ Common::Error SciEngine::run() { // gk1/floppy does support upscaled hires scriptswise, but doesn't actually have the hires content we need to limit // it to platform windows. if (getPlatform() == Common::kPlatformWindows) { - if (_gameId == "kq6") + if (_gameId == GID_KQ6) upscaledHires = GFX_SCREEN_UPSCALED_640x440; #ifdef ENABLE_SCI32 - if (_gameId == "gk1") + if (_gameId == GID_GK1) upscaledHires = GFX_SCREEN_UPSCALED_640x480; #endif } @@ -503,6 +503,10 @@ Console *SciEngine::getSciDebugger() { return _console; } +const char *SciEngine::getGameIdStr() const { + return _gameDescription->gameid; +} + Common::Language SciEngine::getLanguage() const { return _gameDescription->language; } @@ -524,12 +528,12 @@ Common::String SciEngine::getSavegamePattern() const { } Common::String SciEngine::getFilePrefix() const { - if (_gameId == "qfg2") { + if (_gameId == GID_QFG2) { // Quest for Glory 2 wants to read files from Quest for Glory 1 (EGA/VGA) to import character data if (_gamestate->currentRoomNumber() == 805) return "qfg1"; // TODO: Include import-room for qfg1vga - } else if (_gameId == "qfg3") { + } else if (_gameId == GID_QFG3) { // Quest for Glory 3 wants to read files from Quest for Glory 2 to import character data if (_gamestate->currentRoomNumber() == 54) return "qfg2"; diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 68a62c5fcc..f60aad67a7 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -104,6 +104,75 @@ enum kDebugLevels { kDebugLevelOnStartup = 1 << 23 }; +enum SciGameId { + GID_ASTROCHICKEN, + GID_CAMELOT, + GID_CASTLEBRAIN, + GID_CHRISTMAS1988, + GID_CHRISTMAS1990, + GID_CHRISTMAS1992, + GID_CNICK_KQ, + GID_CNICK_LAURABOW, + GID_CNICK_LONGBOW, + GID_CNICK_LSL, + GID_CNICK_SQ, + GID_ECOQUEST, + GID_ECOQUEST2, + GID_FAIRYTALES, + GID_FREDDYPHARKAS, + GID_FUNSEEKER, + GID_GK1, + GID_GK2, + GID_HOYLE1, + GID_HOYLE2, + GID_HOYLE3, + GID_HOYLE4, + GID_ICEMAN, + GID_ISLANDBRAIN, + GID_JONES, + GID_KQ1, + GID_KQ4, + GID_KQ5, + GID_KQ6, + GID_KQ7, + GID_LAURABOW, + GID_LAURABOW2, + GID_LIGHTHOUSE, + GID_LONGBOW, + GID_LSL1, + GID_LSL2, + GID_LSL3, + GID_LSL5, + GID_LSL6, + GID_LSL7, + GID_MOTHERGOOSE, + GID_MSASTROCHICKEN, + GID_PEPPER, + GID_PHANTASMAGORIA, + GID_PHANTASMAGORIA2, + GID_PQ1, + GID_PQ2, + GID_PQ3, + GID_PQ4, + GID_PQSWAT, + GID_QFG1, + GID_QFG2, + GID_QFG3, + GID_QFG4, + GID_RAMA, + GID_SHIVERS, + GID_SHIVERS2, + GID_SLATER, + GID_SQ1, + GID_SQ3, + GID_SQ4, + GID_SQ5, + GID_SQ6, + GID_TORIN, + + GID_FANMADE // FIXME: Do we really need/want this? +}; + /** SCI versions */ enum SciVersion { SCI_VERSION_NONE, @@ -136,7 +205,7 @@ enum kLanguage { class SciEngine : public Engine { friend class Console; public: - SciEngine(OSystem *syst, const ADGameDescription *desc); + SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId); ~SciEngine(); // Engine APIs @@ -151,7 +220,8 @@ public: bool canSaveGameStateCurrently(); void syncSoundSettings(); - const Common::String &getGameId() const { return _gameId; } + const SciGameId &getGameId() const { return _gameId; } + const char *getGameIdStr() const; int getResourceVersion() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; @@ -264,7 +334,7 @@ private: void initStackBaseWithSelector(Selector selector); const ADGameDescription *_gameDescription; - const Common::String _gameId; + const SciGameId _gameId; ResourceManager *_resMan; /**< The resource manager */ EngineState *_gamestate; Kernel *_kernel; -- cgit v1.2.3