diff options
author | Florian Kagerer | 2010-10-01 19:24:52 +0000 |
---|---|---|
committer | Florian Kagerer | 2010-10-01 19:24:52 +0000 |
commit | 0d8f4a22ae51d5943014a4c5f3ba610686039a24 (patch) | |
tree | 4f2ba902f2681c10f1f9949efc9424bcc93e14c1 /engines/scumm/scumm.cpp | |
parent | be1d196da5dbbabaef0bfa835b51e9c82c407645 (diff) | |
download | scummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.tar.gz scummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.tar.bz2 scummvm-rg350-0d8f4a22ae51d5943014a4c5f3ba610686039a24.zip |
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
Diffstat (limited to 'engines/scumm/scumm.cpp')
-rw-r--r-- | engines/scumm/scumm.cpp | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 0f1b43cedb..4cb4b282e8 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -258,7 +258,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _switchRoomEffect2 = 0; _switchRoomEffect = 0; - _bytesPerPixel = 1; + _bytesPerPixelOutput = _bytesPerPixel = 1; _doEffect = false; _snapScroll = false; _currentLights = 0; @@ -278,6 +278,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _hePalettes = NULL; _hePaletteSlot = 0; _16BitPalette = NULL; + _townsScreen = 0; _shadowPalette = NULL; _shadowPaletteSize = 0; memset(_currentPalette, 0, sizeof(_currentPalette)); @@ -318,6 +319,13 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _skipDrawObject = 0; + _townsPaletteFlags = 0; + _townsClearLayerFlag = 1; + _townsActiveLayerFlags = 3; + memset(&_curStringRect, -1, sizeof(Common::Rect)); + memset(&_cyclRects, 0, 16 * sizeof(Common::Rect)); + _numCyclRects = 0; + // // Init all VARS to 0xFF // @@ -533,16 +541,19 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _screenHeight = 200; } - _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + _bytesPerPixelOutput = _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + +#ifdef USE_RGB_COLOR + if (_game.platform == Common::kPlatformFMTowns) + _bytesPerPixelOutput = 2; +#endif // Allocate gfx compositing buffer (not needed for V7/V8 games). if (_game.version < 7) - _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * _bytesPerPixel); + _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * _bytesPerPixelOutput); else _compositeBuf = 0; - _fmtownsBuf = 0; - _herculesBuf = 0; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { _herculesBuf = (byte *)malloc(Common::kHercW * Common::kHercH); @@ -608,7 +619,10 @@ ScummEngine::~ScummEngine() { free(_compositeBuf); free(_herculesBuf); - free(_fmtownsBuf); + + free(_16BitPalette); + + delete _townsScreen; delete _debugger; @@ -1116,14 +1130,19 @@ Common::Error ScummEngine::init() { screenWidth *= _textSurfaceMultiplier; screenHeight *= _textSurfaceMultiplier; } - if (_game.features & GF_16BIT_COLOR) { + if (_game.features & GF_16BIT_COLOR || _game.platform == Common::kPlatformFMTowns) { #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; #else - error("16bit color support is required for this game"); + if (_game.platform == Common::kPlatformFMTowns) { + warning("Starting game without the required 16bit color support.\nYou will experience severe color glitches"); + initGraphics(screenWidth, screenHeight, (screenWidth > 320)); + } else { + error("16bit color support is required for this game"); + } #endif } else { initGraphics(screenWidth, screenHeight, (screenWidth > 320)); @@ -1241,13 +1260,8 @@ void ScummEngine::setupScumm() { _res->setHeapThreshold(400000, maxHeapThreshold); - if (_game.platform == Common::kPlatformFMTowns && _language == Common::JA_JPN) { - free(_fmtownsBuf); - _fmtownsBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier); - } - free(_compositeBuf); - _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _bytesPerPixel); + _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _bytesPerPixelOutput); } #ifdef ENABLE_SCUMM_7_8 @@ -1325,6 +1339,18 @@ void ScummEngine::resetScumm() { debug(9, "resetScumm"); +#ifdef USE_RGB_COLOR + if (_game.features & GF_16BIT_COLOR || _game.platform == Common::kPlatformFMTowns) + _16BitPalette = (uint16 *)calloc(512, sizeof(uint16)); +#endif + + 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->setupLayer(1, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 16, _textPalette); + } + if (_game.version == 0) { initScreens(8, 144); } else if ((_game.id == GID_MANIAC) && (_game.version <= 1) && !(_game.platform == Common::kPlatformNES)) { @@ -1517,8 +1543,6 @@ void ScummEngine_v3::resetScumm() { if (_game.id == GID_LOOM && _game.platform == Common::kPlatformPCEngine) { - _16BitPalette = (uint16 *)calloc(512, sizeof(uint16)); - // Load tile set and palette for the distaff byte *roomptr = getResourceAddress(rtRoom, 90); assert(roomptr); @@ -1928,6 +1952,10 @@ void ScummEngine::waitForTimer(int msec_delay) { while (!shouldQuit()) { _sound->updateCD(); // Loop CD Audio if needed parseEvents(); + + if (_townsScreen) + _townsScreen->update(); + _system->updateScreen(); if (_system->getMillis() >= start_time + msec_delay) break; @@ -2055,6 +2083,8 @@ load_game: goto load_game; } + towns_processPalCycleField(); + if (_currentRoom == 0) { if (_game.version > 3) CHARSET_1(); @@ -2442,6 +2472,10 @@ void ScummEngine::pauseEngineIntern(bool pause) { } else { // Update the screen to make it less likely that the player will see a // brief cursor palette glitch when the GUI is disabled. + + if (_townsScreen) + _townsScreen->update(); + _system->updateScreen(); // Resume sound & video |