diff options
-rw-r--r-- | engines/lure/screen.cpp | 24 | ||||
-rw-r--r-- | engines/lure/screen.h | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/engines/lure/screen.cpp b/engines/lure/screen.cpp index d00d969770..282e382bba 100644 --- a/engines/lure/screen.cpp +++ b/engines/lure/screen.cpp @@ -52,12 +52,26 @@ Screen::~Screen() { delete _palette; } +void Screen::setSystemPalette(Palette *p, uint16 start, uint16 num) { + byte pal[3 * 256]; + assert(start + num <= 256); + + const byte *rawData = p->data(); + for (uint i = 0; i < num; ++i) { + pal[i * 3 + 0] = rawData[(i + start) * 4 + 0]; + pal[i * 3 + 1] = rawData[(i + start) * 4 + 1]; + pal[i * 3 + 2] = rawData[(i + start) * 4 + 2]; + } + + _system.getPaletteManager()->setPalette(pal, start, num); +} + // setPaletteEmpty // Defaults the palette to an empty set void Screen::setPaletteEmpty(int numEntries) { Palette emptyPalette(numEntries, NULL, RGB64); - _system.getPaletteManager()->setPalette(emptyPalette.data(), 0, numEntries); + setSystemPalette(&emptyPalette, 0, numEntries); _palette->copyFrom(&emptyPalette); /* delete _palette; @@ -73,7 +87,7 @@ void Screen::setPaletteEmpty(int numEntries) { void Screen::setPalette(Palette *p) { _palette->copyFrom(p); - _system.getPaletteManager()->setPalette(_palette->data(), 0, GAME_COLOURS); + setSystemPalette(_palette, 0, GAME_COLOURS); _system.updateScreen(); } @@ -82,7 +96,7 @@ void Screen::setPalette(Palette *p) { void Screen::setPalette(Palette *p, uint16 start, uint16 num) { _palette->palette()->copyFrom(p->palette(), start * 4, start * 4, num * 4); - _system.getPaletteManager()->setPalette(_palette->data(), start, num); + setSystemPalette(_palette, start, num); _system.updateScreen(); } @@ -114,7 +128,7 @@ void Screen::paletteFadeIn(Palette *p) { } if (changed) { - _system.getPaletteManager()->setPalette(_palette->data(), 0, p->numEntries()); + setSystemPalette(_palette, 0, p->numEntries()); _system.updateScreen(); _system.delayMillis(20); while (events.pollEvent()) @@ -147,7 +161,7 @@ void Screen::paletteFadeOut(int numEntries) { } if (changed) { - _system.getPaletteManager()->setPalette(_palette->data(), 0, numEntries); + setSystemPalette(_palette, 0, numEntries); _system.updateScreen(); _system.delayMillis(20); while (events.pollEvent()) diff --git a/engines/lure/screen.h b/engines/lure/screen.h index 373683df2b..94bbab932e 100644 --- a/engines/lure/screen.h +++ b/engines/lure/screen.h @@ -42,6 +42,8 @@ private: Disk &_disk; Surface *_screen; Palette *_palette; + + void setSystemPalette(Palette *p, uint16 start, uint16 num); public: Screen(OSystem &system); ~Screen(); |