diff options
Diffstat (limited to 'engines/scumm/scumm.cpp')
-rw-r--r-- | engines/scumm/scumm.cpp | 92 |
1 files changed, 61 insertions, 31 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 36caff452d..7b136dc36d 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -114,17 +114,18 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _rnd("scumm") { - if (_game.heversion > 0) { - _gdi = new GdiHE(this); - } else if (_game.platform == Common::kPlatformNES) { - _gdi = new GdiNES(this); #ifdef USE_RGB_COLOR - } else if (_game.features & GF_16BIT_COLOR) { + if (_game.features & GF_16BIT_COLOR) { if (_game.platform == Common::kPlatformPCEngine) _gdi = new GdiPCEngine(this); - else - _gdi = new Gdi16Bit(this); + else if (_game.heversion > 0) + _gdi = new GdiHE16bit(this); + } else #endif + if (_game.heversion > 0) { + _gdi = new GdiHE(this); + } else if (_game.platform == Common::kPlatformNES) { + _gdi = new GdiNES(this); } else if (_game.version <= 1) { _gdi = new GdiV1(this); } else if (_game.version == 2) { @@ -162,7 +163,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _pauseDialog = NULL; _versionDialog = NULL; _fastMode = 0; - _actors = NULL; + _actors = _sortedActors = NULL; _arraySlot = NULL; _inventory = NULL; _newNames = NULL; @@ -260,7 +261,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _switchRoomEffect2 = 0; _switchRoomEffect = 0; - _bytesPerPixelOutput = _bytesPerPixel = 1; + _bytesPerPixel = 1; _doEffect = false; _snapScroll = false; _currentLights = 0; @@ -328,7 +329,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) memset(&_cyclRects, 0, 16 * sizeof(Common::Rect)); _numCyclRects = 0; #endif - + // // Init all VARS to 0xFF // @@ -545,24 +546,25 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _screenHeight = 200; } - _bytesPerPixelOutput = _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + uint8 sizeMult = _bytesPerPixel; #ifdef USE_RGB_COLOR #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) - _bytesPerPixelOutput = 2; + sizeMult = 2; #endif #endif // Allocate gfx compositing buffer (not needed for V7/V8 games). if (_game.version < 7) - _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * _bytesPerPixelOutput); + _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * sizeMult); else _compositeBuf = 0; _herculesBuf = 0; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - _herculesBuf = (byte *)malloc(Common::kHercW * Common::kHercH); + _herculesBuf = (byte *)malloc(kHercWidth * kHercHeight); } // Add debug levels @@ -584,9 +586,12 @@ ScummEngine::~ScummEngine() { _mixer->stopAll(); - for (int i = 0; i < _numActors; ++i) - delete _actors[i]; - delete[] _actors; + if (_actors) { + for (int i = 0; i < _numActors; ++i) + delete _actors[i]; + delete[] _actors; + } + delete[] _sortedActors; delete[] _2byteFontPtr; @@ -1135,7 +1140,7 @@ Common::Error ScummEngine::init() { // Initialize backend if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - initGraphics(Common::kHercW, Common::kHercH, true); + initGraphics(kHercWidth, kHercHeight, true); } else { int screenWidth = _screenWidth; int screenHeight = _screenHeight; @@ -1145,16 +1150,37 @@ Common::Error ScummEngine::init() { screenWidth *= _textSurfaceMultiplier; screenHeight *= _textSurfaceMultiplier; } - if (_game.features & GF_16BIT_COLOR + if (_game.features & GF_16BIT_COLOR #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE || _game.platform == Common::kPlatformFMTowns #endif ) { #ifdef USE_RGB_COLOR - Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - initGraphics(screenWidth, screenHeight, screenWidth > 320, &format); - if (format != _system->getScreenFormat()) - return Common::kUnsupportedColorMode; + _outputPixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + + if (_game.platform != Common::kPlatformFMTowns && _game.platform != Common::kPlatformPCEngine) { + initGraphics(screenWidth, screenHeight, screenWidth > 320, &_outputPixelFormat); + if (_outputPixelFormat != _system->getScreenFormat()) + return Common::kUnsupportedColorMode; + } else { + Common::List<Graphics::PixelFormat> tryModes = _system->getSupportedFormats(); + for (Common::List<Graphics::PixelFormat>::iterator g = tryModes.begin(); g != tryModes.end(); ++g) { + if (g->bytesPerPixel != 2 || g->aBits()) { + g = tryModes.erase(g); + g--; + } + + if (*g == _outputPixelFormat) { + tryModes.clear(); + tryModes.push_back(_outputPixelFormat); + break; + } + } + + initGraphics(screenWidth, screenHeight, screenWidth > 320, tryModes); + if (_system->getScreenFormat().bytesPerPixel != 2) + return Common::kUnsupportedColorMode; + } #else if (_game.platform == Common::kPlatformFMTowns && _game.version == 3) { warning("Starting game without the required 16bit color support.\nYou may experience color glitches"); @@ -1166,12 +1192,14 @@ Common::Error ScummEngine::init() { } else { #ifdef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns && _game.version == 5) - error("This game requires dual graphics layer support which is disabled in this build"); + return Common::Error(Common::kUnsupportedColorMode, "This game requires dual graphics layer support which is disabled in this build"); #endif initGraphics(screenWidth, screenHeight, (screenWidth > 320)); } } + _outputPixelFormat = _system->getScreenFormat(); + setupScumm(); readIndexFile(); @@ -1280,7 +1308,7 @@ void ScummEngine::setupScumm() { _res->setHeapThreshold(400000, maxHeapThreshold); free(_compositeBuf); - _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _bytesPerPixelOutput); + _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _outputPixelFormat.bytesPerPixel); } #ifdef ENABLE_SCUMM_7_8 @@ -1361,7 +1389,7 @@ void ScummEngine::resetScumm() { #ifdef USE_RGB_COLOR if (_game.features & GF_16BIT_COLOR #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE - || _game.platform == Common::kPlatformFMTowns + || (_game.platform == Common::kPlatformFMTowns) #endif ) _16BitPalette = (uint16 *)calloc(512, sizeof(uint16)); @@ -1370,8 +1398,8 @@ void ScummEngine::resetScumm() { #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) { delete _townsScreen; - _townsScreen = new TownsScreen(_system, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, _bytesPerPixelOutput); - _townsScreen->setupLayer(0, _screenWidth, _screenHeight, (_bytesPerPixelOutput == 2) ? 32767 : 256); + _townsScreen = new TownsScreen(_system, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, _outputPixelFormat); + _townsScreen->setupLayer(0, _screenWidth, _screenHeight, (_outputPixelFormat.bytesPerPixel == 2) ? 32767 : 256); _townsScreen->setupLayer(1, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 16, _textPalette); } #endif @@ -1762,8 +1790,10 @@ void ScummEngine::setupMusic(int midi) { if (missingFile) { GUI::MessageDialog dialog( - "Native MIDI support requires the Roland Upgrade from LucasArts,\n" - "but " + fileName + " is missing. Using AdLib instead.", "Ok"); + Common::String::format( + _("Native MIDI support requires the Roland Upgrade from LucasArts,\n" + "but %s is missing. Using AdLib instead."), fileName.c_str()), + _("OK")); dialog.runModal(); _musicType = MDT_ADLIB; } @@ -1838,7 +1868,7 @@ void ScummEngine::setupMusic(int midi) { } _imuse = IMuse::create(_system, nativeMidiDriver, adlibMidiDriver); - + if (_game.platform == Common::kPlatformFMTowns) { _musicEngine = _townsPlayer = new Player_Towns_v2(this, _mixer, _imuse, true); if (!_townsPlayer->init()) |