diff options
author | Johannes Schickel | 2007-03-23 16:24:28 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-03-23 16:24:28 +0000 |
commit | 661944a0f9892d77c0638d44d877c785e828faa1 (patch) | |
tree | e54a1a7bf756fd30590041cce0ee3dd653484fe6 | |
parent | 32c7ee77488c8c6ff6dd2badb5af1eb321313e02 (diff) | |
download | scummvm-rg350-661944a0f9892d77c0638d44d877c785e828faa1.tar.gz scummvm-rg350-661944a0f9892d77c0638d44d877c785e828faa1.tar.bz2 scummvm-rg350-661944a0f9892d77c0638d44d877c785e828faa1.zip |
Implemented some palette code differences for Amiga version.
svn-id: r26281
-rw-r--r-- | engines/kyra/gui.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/scene.cpp | 68 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 45 | ||||
-rw-r--r-- | engines/kyra/screen.h | 2 | ||||
-rw-r--r-- | engines/kyra/script_v1.cpp | 59 | ||||
-rw-r--r-- | engines/kyra/sprites.cpp | 18 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 5 |
7 files changed, 142 insertions, 61 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 4da2998131..69d24c244c 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -1438,6 +1438,9 @@ void KyraEngine::gui_redrawHighlight(Menu menu) { } void KyraEngine::gui_fadePalette() { + if (_flags.platform == Common::kPlatformAmiga) + return; + static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1}; int index = 0; @@ -1456,6 +1459,9 @@ void KyraEngine::gui_fadePalette() { } void KyraEngine::gui_restorePalette() { + if (_flags.platform == Common::kPlatformAmiga) + return; + memcpy(_screen->_currentPalette, _screen->getPalette(2), 768); _screen->fadePalette(_screen->_currentPalette, 2); } diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp index bd728cfd52..e2f3293753 100644 --- a/engines/kyra/scene.cpp +++ b/engines/kyra/scene.cpp @@ -450,7 +450,7 @@ void KyraEngine::startSceneScript(int brandonAlive) { strcat(fileNameBuffer, ".CPS"); _screen->clearPage(3); // FIXME: check this hack for amiga version - _screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(1) : 0)); + _screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(0) : 0)); _sprites->loadSceneShapes(); _exitListPtr = 0; @@ -824,35 +824,55 @@ void KyraEngine::initSceneObjectList(int brandonAlive) { } void KyraEngine::initSceneScreen(int brandonAlive) { - if (_unkScreenVar1 && !queryGameFlag(0xA0)) { - for (int i = 0; i < 60; ++i) { - uint16 col = _screen->getPalette(0)[684+i]; - col += _screen->getPalette(1)[684+i] << 1; - col >>= 2; - _screen->getPalette(0)[684+i] = col; + if (_flags.platform == Common::kPlatformAmiga) { + if (_unkScreenVar1 && !queryGameFlag(0xF0)) { + memset(_screen->getPalette(2), 0, 32*3); + if (_currentCharacter->sceneId != 117 || !queryGameFlag(0xB3)) { + _screen->setScreenPalette(_screen->getPalette(2)); + } } - _screen->setScreenPalette(_screen->getPalette(0)); - } - if (_unkScreenVar2 == 1) { - _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); - } else { - _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); - } + if (_unkScreenVar2 == 1) + _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); + else + _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); + + if (_unkScreenVar1 && !queryGameFlag(0xA0)) { + if (_currentCharacter->sceneId == 45 && _paletteChanged) { + memcpy(_screen->getPalette(0) + 12*3, _screen->getPalette(4) + 12*3, 2); + } + + if (_currentCharacter->sceneId >= 229 && _currentCharacter->sceneId <= 245 && (_brandonStatusBit & 1)) { + memcpy(_screen->getPalette(0), _screen->getPalette(0) + 320*3, 64); + } - if (_unkScreenVar1 && _paletteChanged) { - if (!queryGameFlag(0xA0)) { - memcpy(_screen->getPalette(0) + 684, _screen->getPalette(1) + 684, 60); _screen->setScreenPalette(_screen->getPalette(0)); + } + } else { + if (_unkScreenVar1 && !queryGameFlag(0xA0)) { + for (int i = 0; i < 60; ++i) { + uint16 col = _screen->getPalette(0)[684+i]; + col += _screen->getPalette(1)[684+i] << 1; + col >>= 2; + _screen->getPalette(0)[684+i] = col; + } + _screen->setScreenPalette(_screen->getPalette(0)); + } + + if (_unkScreenVar2 == 1) { + _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); } else { - memset(_screen->getPalette(0), 0, 768); + _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); + } + + if (_unkScreenVar1 && _paletteChanged) { + if (!queryGameFlag(0xA0)) { + memcpy(_screen->getPalette(0) + 684, _screen->getPalette(1) + 684, 60); + _screen->setScreenPalette(_screen->getPalette(0)); + } else { + memset(_screen->getPalette(0), 0, 768); + } } - } - - // FIXME: hack to get the room palette working - if (_flags.platform == Common::kPlatformAmiga) { - memcpy(_screen->getPalette(0), _screen->getPalette(1), 32*3); - _screen->setScreenPalette(_screen->getPalette(0)); } // really call this here? diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index feded31d80..ef3e7badfa 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -54,9 +54,13 @@ Screen::~Screen() { delete [] _screenPalette; delete [] _decodeShapeBuffer; delete [] _animBlockPtr; - for (int i = 0; i < ARRAYSIZE(_palettes); ++i) { - delete [] _palettes[i]; + + if (_vm->gameFlags().platform != Common::kPlatformAmiga) { + for (int i = 0; i < ARRAYSIZE(_palettes); ++i) { + delete [] _palettes[i]; + } } + delete [] _bitBlitRects; for (int i = 0; i < ARRAYSIZE(_saveLoadPage); ++i) { delete [] _saveLoadPage[i]; @@ -120,17 +124,31 @@ bool Screen::init() { _pagePtrs[pageNum] = _pagePtrs[pageNum + 1] = pagePtr; } memset(_shapePages, 0, sizeof(_shapePages)); - _currentPalette = new uint8[768]; - assert(_currentPalette); - memset(_currentPalette, 0, 768); + + memset(_palettes, 0, sizeof(_palettes)); _screenPalette = new uint8[768]; assert(_screenPalette); memset(_screenPalette, 0, 768); - for (int i = 0; i < ARRAYSIZE(_palettes); ++i) { - _palettes[i] = new uint8[768]; - assert(_palettes[i]); - memset(_palettes[i], 0, 768); + + if (_vm->gameFlags().platform == Common::kPlatformAmiga) { + _currentPalette = new uint8[1248]; + assert(_currentPalette); + memset(_currentPalette, 0, 1248); + + for (int i = 0; i < 6; ++i) { + _palettes[i] = _currentPalette + (i+1)*96; + } + } else { + _currentPalette = new uint8[768]; + assert(_currentPalette); + memset(_currentPalette, 0, 768); + for (int i = 0; i < 3; ++i) { + _palettes[i] = new uint8[768]; + assert(_palettes[i]); + memset(_palettes[i], 0, 768); + } } + setScreenPalette(_currentPalette); _curDim = &_screenDimTable[0]; _charWidth = 0; @@ -416,18 +434,19 @@ void Screen::setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue) { void Screen::setScreenPalette(const uint8 *palData) { debugC(9, kDebugLevelScreen, "Screen::setScreenPalette(%p)", (const void *)palData); + int colors = (_vm->gameFlags().platform == Common::kPlatformAmiga ? 32 : 256); if (palData != _screenPalette) - memcpy(_screenPalette, palData, 768); + memcpy(_screenPalette, palData, colors*3); uint8 screenPal[256 * 4]; - for (int i = 0; i < 256; ++i) { + for (int i = 0; i < colors; ++i) { screenPal[4 * i + 0] = (palData[0] << 2) | (palData[0] & 3); screenPal[4 * i + 1] = (palData[1] << 2) | (palData[1] & 3); screenPal[4 * i + 2] = (palData[2] << 2) | (palData[2] & 3); screenPal[4 * i + 3] = 0; palData += 3; } - _system->setPalette(screenPal, 0, 256); + _system->setPalette(screenPal, 0, colors); } void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) { @@ -2304,7 +2323,7 @@ void Screen::copyScreenToRect(int x, int y, int w, int h, uint8 *ptr) { uint8 *Screen::getPalette(int num) { debugC(9, kDebugLevelScreen, "Screen::getPalette(%d)", num); - assert(num >= 0 && num < ARRAYSIZE(_palettes)+1); + assert(num >= 0 && num < (_vm->gameFlags().platform == Common::kPlatformAmiga ? 6 : 4)); if (num == 0) { return _currentPalette; } diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index b59c09d3d8..dab44f2b1a 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -288,7 +288,7 @@ private: uint8 *_saveLoadPage[8]; uint8 *_screenPalette; - uint8 *_palettes[3]; + uint8 *_palettes[6]; Font _fonts[FID_NUM]; uint8 _textColorsMap[16]; diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 9edca16747..d3ec7bd7eb 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -268,8 +268,20 @@ int KyraEngine::o1_runSceneAnimUntilDone(ScriptState *script) { } int KyraEngine::o1_fadeSpecialPalette(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_fadeSpecialPalette(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); - _screen->fadeSpecialPalette(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + if (_flags.platform == Common::kPlatformAmiga) { + debugC(3, kDebugLevelScriptFuncs, "o1_fadeSpecialPalette(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + if (_currentCharacter->sceneId != 45) { + if (stackPos(0) == 13) { + memcpy(_screen->getPalette(0), _screen->getPalette(0) + 384*3, 32*3); + _screen->setScreenPalette(_screen->getPalette(0)); + } + } else { + warning("o1_fadeSpecialPalette not implemented"); + } + } else { + debugC(3, kDebugLevelScriptFuncs, "o1_fadeSpecialPalette(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + _screen->fadeSpecialPalette(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + } return 0; } @@ -1549,21 +1561,36 @@ int KyraEngine::o1_fadeEntirePalette(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "o1_fadeEntirePalette(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); int cmd = stackPos(0); uint8 *fadePal = 0; - if (cmd == 0) { - fadePal = _screen->getPalette(2); - uint8 *screenPal = _screen->getPalette(0); - uint8 *backUpPal = _screen->getPalette(3); + + if (_flags.platform == Common::kPlatformAmiga) { + if (cmd == 0) { + fadePal = _screen->getPalette(2); + memset(fadePal, 0, 32*3); + memcpy(_screen->getPalette(4), _screen->getPalette(0), 32*3); + } else if (cmd == 1) { + fadePal = _screen->getPalette(0); + memcpy(_screen->getPalette(0), _screen->getPalette(4), 32*3); + } else if (cmd == 2) { + fadePal = _screen->getPalette(0); + memset(_screen->getPalette(2), 0, 32*3); + } + } else { + if (cmd == 0) { + fadePal = _screen->getPalette(2); + uint8 *screenPal = _screen->getPalette(0); + uint8 *backUpPal = _screen->getPalette(3); - memcpy(backUpPal, screenPal, sizeof(uint8)*768); - memset(fadePal, 0, sizeof(uint8)*768); - } else if (cmd == 1) { - //fadePal = _screen->getPalette(3); - warning("unimplemented o1_fadeEntirePalette function"); - return 0; - } else if (cmd == 2) { - memset(_screen->getPalette(2), 0, 768); - memcpy(_screen->getPalette(0), _screen->getPalette(1), 768); - fadePal = _screen->getPalette(0); + memcpy(backUpPal, screenPal, sizeof(uint8)*768); + memset(fadePal, 0, sizeof(uint8)*768); + } else if (cmd == 1) { + //fadePal = _screen->getPalette(3); + warning("unimplemented o1_fadeEntirePalette function"); + return 0; + } else if (cmd == 2) { + memset(_screen->getPalette(2), 0, 768); + memcpy(_screen->getPalette(0), _screen->getPalette(1), 768); + fadePal = _screen->getPalette(0); + } } _screen->fadePalette(fadePal, stackPos(1)); diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index a6a069cf98..d79004aa09 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -415,14 +415,20 @@ void Sprites::loadDat(const char *filename, SceneExits &exits) { if (_engine->_northExitHeight & 1) _engine->_northExitHeight += 1; - if (_engine->queryGameFlag(0xA0)) { - memcpy(_screen->getPalette(1), _screen->getPalette(3), 768); - } else { - memcpy(_screen->getPalette(1), _screen->getPalette(0), 768); - } // XXX _engine->_paletteChanged = 1; - if (_engine->gameFlags().platform != Common::kPlatformAmiga) { + + if (_engine->gameFlags().platform == Common::kPlatformAmiga) { + if (_engine->queryGameFlag(0xA0)) + memcpy(_screen->getPalette(3), _screen->getPalette(4), 32*3); + else + memcpy(_screen->getPalette(3), _screen->getPalette(0), 32*3); + } else { + if (_engine->queryGameFlag(0xA0)) + memcpy(_screen->getPalette(1), _screen->getPalette(3), 768); + else + memcpy(_screen->getPalette(1), _screen->getPalette(0), 768); + _screen->loadPalette(_dat + 0x17, _screen->getPalette(1) + 684, 60); } uint8 *data = _dat + 0x6B; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 9851761000..9013cd111f 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -843,7 +843,7 @@ void KyraEngine::loadMainScreen(int page) { _screen->clearPage(page); if (_flags.lang == Common::EN_ANY && !_flags.isTalkie && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) - _screen->loadBitmap("MAIN15.CPS", page, page, 0); + _screen->loadBitmap("MAIN15.CPS", page, page, _screen->getPalette(0)); else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN) _screen->loadBitmap("MAIN_ENG.CPS", page, page, 0); else if (_flags.lang == Common::FR_FRA) @@ -857,6 +857,9 @@ void KyraEngine::loadMainScreen(int page) { else warning("no main graphics file found"); + if (_flags.platform == Common::kPlatformAmiga) + memcpy(_screen->getPalette(1), _screen->getPalette(0), 32*3); + _screen->copyRegion(0, 0, 0, 0, 320, 200, page, 0); } |