Skip to content

Commit

Permalink
ADL: Disable scanlines when saving thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
waltervn committed Mar 9, 2016
1 parent 912a31f commit b30fb41
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion engines/adl/adl.cpp
Expand Up @@ -552,7 +552,7 @@ Common::Error AdlEngine::saveGameState(int slot, const Common::String &desc) {
uint32 playTime = getTotalPlayTime();
outFile->writeUint32BE(playTime);

Graphics::saveThumbnail(*outFile);
_display->saveThumbnail(*outFile);

outFile->writeByte(_state.room);
outFile->writeByte(_state.moves);
Expand Down
51 changes: 40 additions & 11 deletions engines/adl/display.cpp
Expand Up @@ -33,6 +33,7 @@
#include "engines/engine.h"
#include "engines/util.h"
#include "graphics/palette.h"
#include "graphics/thumbnail.h"

namespace Adl {

Expand Down Expand Up @@ -81,7 +82,12 @@ Display::Display() :
_monochrome = !ConfMan.getBool("color");
_scanlines = ConfMan.getBool("scanlines");

setPalette(_scanlines, _monochrome);
if (_monochrome)
setMonoPalette();
else
setColorPalette();

enableScanlines(_scanlines);

_frameBuf = new byte[kFrameBufSize];
_frameBufSurface = new Graphics::Surface;
Expand All @@ -108,7 +114,34 @@ Display::~Display() {
delete _font;
}

void Display::setPalette(bool scanlines, bool monochrome) {
bool Display::saveThumbnail(Common::WriteStream &out) {
if (_scanlines) {
enableScanlines(false);
g_system->updateScreen();
}

bool retval = Graphics::saveThumbnail(out);

if (_scanlines) {
enableScanlines(true);
g_system->updateScreen();
}

return retval;
}

void Display::enableScanlines(bool enable) {
byte pal[6 * 3] = { };

if (enable)
g_system->getPaletteManager()->setPalette(pal, 6, 6);
else {
g_system->getPaletteManager()->grabPalette(pal, 0, 6);
g_system->getPaletteManager()->setPalette(pal, 6, 6);
}
}

void Display::setColorPalette() {
const byte colorPal[6 * 3] = {
0x00, 0x00, 0x00,
0xff, 0xff, 0xff,
Expand All @@ -118,20 +151,16 @@ void Display::setPalette(bool scanlines, bool monochrome) {
0xf2, 0x5e, 0x00
};

g_system->getPaletteManager()->setPalette(colorPal, 0, 6);
}

void Display::setMonoPalette() {
const byte monoPal[2 * 3] = {
0x00, 0x00, 0x00,
0x00, 0xc0, 0x01
};

if (monochrome) {
g_system->getPaletteManager()->setPalette(monoPal, 0, 2);
if (!scanlines)
g_system->getPaletteManager()->setPalette(monoPal, 6, 2);
} else {
g_system->getPaletteManager()->setPalette(colorPal, 0, 6);
if (!scanlines)
g_system->getPaletteManager()->setPalette(colorPal, 6, 6);
}
g_system->getPaletteManager()->setPalette(monoPal, 0, 2);
}

void Display::loadFrameBuffer(Common::ReadStream &stream) {
Expand Down
6 changes: 5 additions & 1 deletion engines/adl/display.h
Expand Up @@ -28,6 +28,7 @@

namespace Common {
class ReadStream;
class WriteStream;
class String;
class Point;
}
Expand All @@ -50,7 +51,9 @@ class Display {

Display();
~Display();
void setPalette(bool monochrome, bool scanlines);
void enableScanlines(bool enable);
void setMonoPalette();
void setColorPalette();
void loadFrameBuffer(Common::ReadStream &stream);
void decodeFrameBuffer();
void updateScreen();
Expand All @@ -69,6 +72,7 @@ class Display {
void setCharAtCursor(byte c);
void showCursor(bool enable);
void updateTextSurface();
bool saveThumbnail(Common::WriteStream &out);

private:
enum {
Expand Down

0 comments on commit b30fb41

Please sign in to comment.