diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/prince.cpp | 46 | ||||
-rw-r--r-- | engines/prince/prince.h | 4 | ||||
-rw-r--r-- | engines/prince/script.cpp | 2 |
3 files changed, 51 insertions, 1 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index b48ba76308..d6981ee90d 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -372,6 +372,9 @@ bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) { } bool PrinceEngine::loadLocation(uint16 locationNr) { + + blackPalette(); + _flicPlayer.close(); memset(_textSlots, 0, sizeof(_textSlots)); @@ -407,7 +410,6 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { Resource::loadResource(_roomBmp, "room", true); if (_roomBmp->getSurface()) { _sceneWidth = _roomBmp->getSurface()->w; - _graph->setPalette(_roomBmp->getPalette()); } loadZoom(_mainHero->_zoomBitmap, _mainHero->kZoomBitmapLen, "zoom"); // TODO - second hero @@ -1760,6 +1762,48 @@ void PrinceEngine::drawScreen() { } } +void PrinceEngine::blackPalette() { + byte *paletteBackup = (byte *)malloc(256 * 3); + byte *blackPalette = (byte *)malloc(256 * 3); + + int fadeStep = kFadeStep - 1; + for (int i = 0; i < kFadeStep; i++) { + _system->getPaletteManager()->grabPalette(paletteBackup, 0, 256); + for (int j = 0; j < 256; j++) { + blackPalette[3 * j] = paletteBackup[3 * j] * fadeStep / 4; + blackPalette[3 * j + 1] = paletteBackup[3 * j + 1] * fadeStep / 4; + blackPalette[3 * j + 2] = paletteBackup[3 * j + 2] * fadeStep / 4; + } + fadeStep--; + _graph->setPalette(blackPalette); + _system->updateScreen(); + pause(); + } + free(paletteBackup); + free(blackPalette); +} + +void PrinceEngine::setPalette() { + byte *paletteBackup; + byte *blackPalette = (byte *)malloc(256 * 3); + + int fadeStep = 0; + for (int i = 0; i <= kFadeStep; i++) { + paletteBackup = (byte *)_roomBmp->getPalette(); + for (int j = 0; j < 256; j++) { + blackPalette[3 * j] = paletteBackup[3 * j] * fadeStep / 4; + blackPalette[3 * j + 1] = paletteBackup[3 * j + 1] * fadeStep / 4; + blackPalette[3 * j + 2] = paletteBackup[3 * j + 2] * fadeStep / 4; + } + fadeStep++; + _graph->setPalette(blackPalette); + _system->updateScreen(); + pause(); + } + _graph->setPalette(paletteBackup); + free(blackPalette); +} + void PrinceEngine::pause() { uint32 currentTime = _system->getMillis(); int delay = 1000/15 - int32(_system->getMillis() - currentTime); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 239a3b2311..311935ffed 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -439,6 +439,10 @@ public: void doZoomOut(int slot); void freeZoomObject(int slot); + static const uint8 kFadeStep = 4; + void blackPalette(); + void setPalette(); + // Pathfinding static const int16 kPathGridStep = 2; static const int32 kPathBitmapLen = (kMaxPicHeight / kPathGridStep * kMaxPicWidth / kPathGridStep) / 8; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index a2f22427a7..9e380a27e8 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -520,10 +520,12 @@ void Interpreter::O_WAITFOREVER() { } void Interpreter::O_BLACKPALETTE() { + _vm->blackPalette(); debugInterpreter("O_BLACKPALETTE"); } void Interpreter::O_SETUPPALETTE() { + _vm->setPalette(); debugInterpreter("O_SETUPPALETTE"); } |