Fixed crash in SCI2.1 games

svn-id: r49546
This commit is contained in:
Filippos Karapetis 2010-06-09 18:42:21 +00:00
parent d191c9d0f9
commit c486b77bb7
4 changed files with 15 additions and 14 deletions

View file

@ -394,7 +394,6 @@ SciKernelFunction kfunct_mappers[] = {
Kernel::Kernel(ResourceManager *resMan, SegManager *segMan) : _resMan(resMan), _segMan(segMan) { Kernel::Kernel(ResourceManager *resMan, SegManager *segMan) : _resMan(resMan), _segMan(segMan) {
loadSelectorNames(); loadSelectorNames();
mapSelectors(); // Map a few special selectors for later use mapSelectors(); // Map a few special selectors for later use
loadKernelNames(); // must be called after the selectors are set
} }
Kernel::~Kernel() { Kernel::~Kernel() {
@ -748,12 +747,12 @@ void Kernel::setDefaultKernelNames() {
} }
} }
void Kernel::loadKernelNames() { void Kernel::loadKernelNames(GameFeatures *features) {
_kernelNames.clear(); _kernelNames.clear();
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
if (getSciVersion() >= SCI_VERSION_2_1) if (getSciVersion() >= SCI_VERSION_2_1)
setKernelNamesSci21(); setKernelNamesSci21(features);
else if (getSciVersion() == SCI_VERSION_2) else if (getSciVersion() == SCI_VERSION_2)
setKernelNamesSci2(); setKernelNamesSci2();
else else

View file

@ -207,7 +207,6 @@ public:
*/ */
Common::String lookupText(reg_t address, int index); Common::String lookupText(reg_t address, int index);
private:
/** /**
* Loads the kernel function names. * Loads the kernel function names.
* *
@ -216,8 +215,9 @@ private:
* The resulting list has the same format regardless of the format of the * The resulting list has the same format regardless of the format of the
* name table of the resource (the format changed between version 0 and 1). * name table of the resource (the format changed between version 0 and 1).
*/ */
void loadKernelNames(); void loadKernelNames(GameFeatures *features);
private:
/** /**
* Sets the default kernel function names, based on the SCI version used * Sets the default kernel function names, based on the SCI version used
*/ */
@ -232,7 +232,7 @@ private:
/** /**
* Sets the default kernel function names to the SCI2.1 kernel functions * Sets the default kernel function names to the SCI2.1 kernel functions
*/ */
void setKernelNamesSci21(); void setKernelNamesSci21(GameFeatures *features);
#endif #endif
/** /**

View file

@ -378,7 +378,7 @@ void Kernel::setKernelNamesSci2() {
_kernelNames = Common::StringArray(sci2_default_knames, kKernelEntriesSci2); _kernelNames = Common::StringArray(sci2_default_knames, kKernelEntriesSci2);
} }
void Kernel::setKernelNamesSci21() { void Kernel::setKernelNamesSci21(GameFeatures *features) {
// Some SCI games use a modified SCI2 kernel table instead of the SCI2.1/SCI3 kernel table. // Some SCI games use a modified SCI2 kernel table instead of the SCI2.1/SCI3 kernel table.
// The GK2 demo does this as well as at least one version of KQ7. We detect which version // The GK2 demo does this as well as at least one version of KQ7. We detect which version
// to use based on where kDoSound is called from Sound::play(). // to use based on where kDoSound is called from Sound::play().
@ -386,7 +386,7 @@ void Kernel::setKernelNamesSci21() {
// This is interesting because they all have the same interpreter version (2.100.002), yet // This is interesting because they all have the same interpreter version (2.100.002), yet
// they would not be compatible with other games of the same interpreter. // they would not be compatible with other games of the same interpreter.
if (g_sci->_features->detectSci21KernelType() == SCI_VERSION_2) { if (features->detectSci21KernelType() == SCI_VERSION_2) {
_kernelNames = Common::StringArray(sci2_default_knames, kKernelEntriesGk2Demo); _kernelNames = Common::StringArray(sci2_default_knames, kKernelEntriesGk2Demo);
// OnMe is IsOnMe here, but they should be compatible // OnMe is IsOnMe here, but they should be compatible
_kernelNames[0x23] = "Robot"; // Graph in SCI2 _kernelNames[0x23] = "Robot"; // Graph in SCI2

View file

@ -141,6 +141,9 @@ Common::Error SciEngine::run() {
return Common::kNoGameDataFoundError; return Common::kNoGameDataFoundError;
} }
// Add the after market GM patches for the specified game, if they exist
_resMan->addNewGMPatch(getGameID());
SegManager *segMan = new SegManager(_resMan); SegManager *segMan = new SegManager(_resMan);
// Scale the screen, if needed // Scale the screen, if needed
@ -170,6 +173,8 @@ Common::Error SciEngine::run() {
else else
_gfxScreen = new GfxScreen(_resMan, 320, 200, upscaledHires); _gfxScreen = new GfxScreen(_resMan, 320, 200, upscaledHires);
_gfxScreen->debugUnditherSetState(ConfMan.getBool("undither"));
if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1) if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1)
_gfxMacIconBar = new GfxMacIconBar(); _gfxMacIconBar = new GfxMacIconBar();
@ -181,10 +186,10 @@ Common::Error SciEngine::run() {
_console = new Console(this); _console = new Console(this);
_kernel = new Kernel(_resMan, segMan); _kernel = new Kernel(_resMan, segMan);
_features = new GameFeatures(segMan, _kernel);
// Only SCI0 and SCI01 games used a parser // Only SCI0 and SCI01 games used a parser
_vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA) ? new Vocabulary(_resMan) : NULL; _vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA) ? new Vocabulary(_resMan) : NULL;
_audio = new AudioPlayer(_resMan); _audio = new AudioPlayer(_resMan);
_features = new GameFeatures(segMan, _kernel);
_gamestate = new EngineState(segMan); _gamestate = new EngineState(segMan);
_eventMan = new EventManager(_resMan); _eventMan = new EventManager(_resMan);
@ -207,23 +212,20 @@ Common::Error SciEngine::run() {
} }
#endif #endif
// Add the after market GM patches for the specified game, if they exist
_resMan->addNewGMPatch(getGameID());
if (game_init(_gamestate)) { /* Initialize */ if (game_init(_gamestate)) { /* Initialize */
warning("Game initialization failed: Aborting..."); warning("Game initialization failed: Aborting...");
// TODO: Add an "init failed" error? // TODO: Add an "init failed" error?
return Common::kUnknownError; return Common::kUnknownError;
} }
_kernel->loadKernelNames(_features); // Must be called after game_init()
script_adjust_opcode_formats(_gamestate); script_adjust_opcode_formats(_gamestate);
SciVersion soundVersion = _features->detectDoSoundType(); SciVersion soundVersion = _features->detectDoSoundType();
_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, soundVersion); _gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, soundVersion);
_gfxScreen->debugUnditherSetState(ConfMan.getBool("undither"));
#ifdef USE_OLD_MUSIC_FUNCTIONS #ifdef USE_OLD_MUSIC_FUNCTIONS
if (game_init_sound(_gamestate, 0, soundVersion)) { if (game_init_sound(_gamestate, 0, soundVersion)) {
warning("Game initialization failed: Error in sound subsystem. Aborting..."); warning("Game initialization failed: Error in sound subsystem. Aborting...");