diff options
author | Joseph-Eugene Winzer | 2017-06-10 00:17:19 +0200 |
---|---|---|
committer | Thierry Crozat | 2018-01-22 21:16:27 +0000 |
commit | 0c72f52ad880279037004e78f36c302d5422b53f (patch) | |
tree | b77880e011e9fa3290c2449ff3f6f80afde26a64 /engines/supernova/supernova.cpp | |
parent | ca8c87ff2eb895d8b5a4538245e79b5240eb436d (diff) | |
download | scummvm-rg350-0c72f52ad880279037004e78f36c302d5422b53f.tar.gz scummvm-rg350-0c72f52ad880279037004e78f36c302d5422b53f.tar.bz2 scummvm-rg350-0c72f52ad880279037004e78f36c302d5422b53f.zip |
SUPERNOVA: Add palette fade in/out
Diffstat (limited to 'engines/supernova/supernova.cpp')
-rw-r--r-- | engines/supernova/supernova.cpp | 133 |
1 files changed, 71 insertions, 62 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 84b8550dc8..69fcea588c 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -46,7 +46,9 @@ namespace Supernova { SupernovaEngine::SupernovaEngine(OSystem *syst) : Engine(syst) , _console(NULL) - , _colorIndex(0) + , _brightness(255) + , _menuBrightness(255) + , _incIndex(10) { // const Common::FSNode gameDataDir(ConfMan.get("path")); // SearchMan.addSubDirectoryMatching(gameDataDir, "sound"); @@ -69,14 +71,13 @@ Common::Error SupernovaEngine::run() { debug(_system->getScreenFormat().toString().c_str()); _console = new Console(this); - initPalette(); initData(); + initPalette(); + paletteFadeIn(); _gameRunning = true; while (_gameRunning) { updateEvents(); - renderImage(31, 0); - renderText("Das Schicksal", 44, 132, 4); _system->updateScreen(); _system->delayMillis(10); @@ -100,13 +101,22 @@ void SupernovaEngine::updateEvents() { case Common::EVENT_KEYDOWN: if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) { - _console->attach(); + paletteFadeOut(); + } + if (event.kbd.keycode == Common::KEYCODE_d && !event.kbd.hasFlags(Common::KBD_CTRL)) { + paletteFadeIn(); } if (event.kbd.keycode == Common::KEYCODE_q) { playSound(48, 13530); } if (event.kbd.keycode == Common::KEYCODE_w) { - ++_colorIndex; + renderImage(_incIndex, 0); + if (_incIndex == 31) { + renderText("Das Schicksal", 44, 132, 4); + renderText("des Horst Hummel", 35, 142, 4); + renderText("Teil 1:", 64, 120, 12); + } + ++_incIndex; } break; default: @@ -119,62 +129,7 @@ void SupernovaEngine::initData() { } void SupernovaEngine::initPalette() { - // Default VGA palette - byte pal[768] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0xa8, 0x00, 0x00, 0xa8, 0xa8, 0xa8, 0x00, 0x00, 0xa8, 0x00, 0xa8, - 0xa8, 0x54, 0x00, 0xa8, 0xa8, 0xa8, 0x54, 0x54, 0x54, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0x54, 0x54, 0xfc, 0xfc, - 0xfc, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x14, 0x14, 0x14, - 0x20, 0x20, 0x20, 0x2c, 0x2c, 0x2c, 0x38, 0x38, 0x38, 0x44, 0x44, 0x44, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, - 0x70, 0x70, 0x70, 0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb4, 0xb4, 0xb4, 0xc8, 0xc8, 0xc8, - 0xe0, 0xe0, 0xe0, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0xfc, 0x40, 0x00, 0xfc, 0x7c, 0x00, 0xfc, 0xbc, 0x00, 0xfc, - 0xfc, 0x00, 0xfc, 0xfc, 0x00, 0xbc, 0xfc, 0x00, 0x7c, 0xfc, 0x00, 0x40, 0xfc, 0x00, 0x00, 0xfc, 0x40, 0x00, - 0xfc, 0x7c, 0x00, 0xfc, 0xbc, 0x00, 0xfc, 0xfc, 0x00, 0xbc, 0xfc, 0x00, 0x7c, 0x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, 0xfc, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x70, 0x38, 0x00, 0x70, 0x54, 0x00, 0x70, - 0x70, 0x00, 0x70, 0x70, 0x00, 0x54, 0x70, 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x00, 0x00, 0x70, 0x1c, 0x00, - 0x70, 0x38, 0x00, 0x70, 0x54, 0x00, 0x70, 0x70, 0x00, 0x54, 0x70, 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x00, - 0x00, 0x70, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x70, 0x38, 0x00, 0x70, 0x54, 0x00, 0x70, 0x70, 0x00, 0x54, 0x70, - 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, - 0x70, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, - 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38, - 0x38, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, - 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, - 0x70, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, - 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50, - 0x50, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, - 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00, - 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00, - 0x00, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, - 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, - 0x40, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, - 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20, - 0x20, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, - 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, - 0x40, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, - 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c, - 0x2c, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, - 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - byte init_pal[] = { - 0, 0, 0, 16,16,16, 22,22,22, 28,28,28, - 63,63,63, 0,52, 0, 0,63, 0, 54, 0, 0, - 63, 0, 0, 0, 0,30, 0, 0,45, 40,40,40, - 20,50,63, 10,63,10, 60,60, 0, 63,10,10 - }; - - _system->getPaletteManager()->setPalette(pal, 0, 256); - _system->getPaletteManager()->setPalette(init_pal, 0, 16); + _system->getPaletteManager()->setPalette(initVGAPalette, 0, 256); } void SupernovaEngine::playSound(int filenumber, int offset) { @@ -216,6 +171,8 @@ void SupernovaEngine::renderImage(int filenumber, int section) { _image.loadStream(file); _image.loadSection(section); + _system->getPaletteManager()->setPalette(_image.getPalette(), 16, 240); + paletteBrightness(); _system->copyRectToScreen(_image.getSurface()->getPixels(), 320, 0, 0, 320, 200); } @@ -346,5 +303,57 @@ void SupernovaEngine::renderBox(int x, int y, int width, int height, byte color) _system->unlockScreen(); } +void SupernovaEngine::paletteBrightness() { + byte palette[768]; + + _system->getPaletteManager()->grabPalette(palette, 0, 256); + for (size_t i = 0; i < 48; ++i) { + palette[i] = (initVGAPalette[i] * _menuBrightness) >> 8; + } + for (size_t i = 48; i < 768; ++i) { + const byte *imagePalette; + if (_image.getPalette()) { + imagePalette = _image.getPalette(); + } else { + imagePalette = palette; + } + palette[i] = (imagePalette[i - 48] * _brightness) >> 8; + } + _system->getPaletteManager()->setPalette(palette, 0, 256); } +void SupernovaEngine::paletteFadeOut() { + // TODO: scene 0 (newspaper article in intro, mode 0x11) + // needs to be handled differently + + while (_brightness > 20) { + _menuBrightness = _brightness; + paletteBrightness(); + _brightness -= 20; + _system->updateScreen(); + _system->delayMillis(10); + } + _menuBrightness = 0; + _brightness = 0; + paletteBrightness(); + _system->updateScreen(); +} + +void SupernovaEngine::paletteFadeIn() { + // TODO: scene 0 (newspaper article in intro, mode 0x11) + // needs to be handled differently + + while (_brightness < 235) { + _menuBrightness = _brightness; + paletteBrightness(); + _brightness += 20; + _system->updateScreen(); + _system->delayMillis(10); + } + _menuBrightness = 255; + _brightness = 255; + paletteBrightness(); + _system->updateScreen(); +} + +} |