From 425132faf9ca3eec69a087a65321bae5c8c7a1ab Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 9 Aug 2014 21:44:38 +0200 Subject: PRINCE: showPalette(), showLogo() - update --- engines/prince/prince.cpp | 56 ++++++++++++++++++++++------------------------- engines/prince/prince.h | 2 +- engines/prince/script.cpp | 2 +- 3 files changed, 28 insertions(+), 32 deletions(-) (limited to 'engines/prince') diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 7ecdae5fa6..2894831386 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -358,11 +358,10 @@ void PrinceEngine::showLogo() { if (Resource::loadResource(&logo, "logo.raw", true)) { loadSample(0, "LOGO.WAV"); playSample(0, 0); - _graph->setPalette(logo.getPalette()); - //TODO - setPalette(); _graph->draw(_graph->_frontScreen, logo.getSurface()); - _graph->update(_graph->_frontScreen); _graph->change(); + _graph->update(_graph->_frontScreen); + setPalette(logo.getPalette()); _system->delayMillis(1000 / kFPS * 70); } } @@ -1833,35 +1832,32 @@ void PrinceEngine::blackPalette() { free(blackPalette); } -void PrinceEngine::setPalette() { - byte *paletteBackup = nullptr; - 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(); - Common::Event event; - Common::EventManager *eventMan = _system->getEventManager(); - eventMan->pollEvent(event); - if (shouldQuit()) { - _graph->setPalette(paletteBackup); - free(blackPalette); - return; +void PrinceEngine::setPalette(const byte *palette) { + if (palette != nullptr) { + byte *blackPalette = (byte *)malloc(256 * 3); + int fadeStep = 0; + for (int i = 0; i <= kFadeStep; i++) { + for (int j = 0; j < 256; j++) { + blackPalette[3 * j] = palette[3 * j] * fadeStep / 4; + blackPalette[3 * j + 1] = palette[3 * j + 1] * fadeStep / 4; + blackPalette[3 * j + 2] = palette[3 * j + 2] * fadeStep / 4; + } + fadeStep++; + _graph->setPalette(blackPalette); + _system->updateScreen(); + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + eventMan->pollEvent(event); + if (shouldQuit()) { + _graph->setPalette(palette); + free(blackPalette); + return; + } + pause(); } - pause(); - } - if (paletteBackup != nullptr) { - _graph->setPalette(paletteBackup); + _graph->setPalette(palette); + free(blackPalette); } - free(blackPalette); } void PrinceEngine::pause() { diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 2a9fe8666b..a1e59cc9ae 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -484,7 +484,7 @@ public: static const uint8 kFadeStep = 4; void blackPalette(); - void setPalette(); + void setPalette(const byte *palette); int getMob(Common::Array &mobList, bool usePriorityList, int posX, int posY); diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 8fa24a4afc..872da2e82d 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -559,7 +559,7 @@ void Interpreter::O_BLACKPALETTE() { } void Interpreter::O_SETUPPALETTE() { - _vm->setPalette(); + _vm->setPalette(_vm->_roomBmp->getPalette()); debugInterpreter("O_SETUPPALETTE"); } -- cgit v1.2.3