ILLUSIONS: Move palette code from Screen to new ScreenPalette class

This commit is contained in:
johndoe123 2016-03-26 21:36:27 +01:00 committed by Eugene Sandulenko
parent 9447d42fd7
commit 2bd1386528
10 changed files with 255 additions and 223 deletions

View file

@ -152,6 +152,7 @@ Common::Error IllusionsEngine_BBDOU::run() {
_resSys->addResourceLoader(0x00170000, new SpecialCodeLoader(this));
_screen = new Screen(this, 640, 480, 16);
_screenPalette = new NullScreenPalette();
_screenText = new ScreenText(this);
_input = new Input();
_actorInstances = new ActorInstanceList(this);

View file

@ -104,6 +104,7 @@ Common::Error IllusionsEngine_Duckman::run() {
_resSys->addResourceLoader(0x00190000, new GenericResourceLoader(this));
_screen = new Screen(this, 320, 200, 8);
_screenPalette = new ScreenPalette(this);
_screenText = new ScreenText(this);
_input = new Input();
_actorInstances = new ActorInstanceList(this);
@ -221,6 +222,7 @@ Common::Error IllusionsEngine_Duckman::run() {
delete _actorInstances;
delete _input;
delete _screenText;
delete _screenPalette;
delete _screen;
delete _resSys;
delete _resReader;
@ -283,7 +285,7 @@ void IllusionsEngine_Duckman::initUpdateFunctions() {
int IllusionsEngine_Duckman::updateScript(uint flags) {
// TODO Some more stuff
if (_screen->isDisplayOn() && !_screen->isFaderActive() && _pauseCtr == 0) {
if (_screen->isDisplayOn() && !_screenPalette->isFaderActive() && _pauseCtr == 0) {
if (_input->pollEvent(kEventAbort)) {
startScriptThread(0x00020342, 0);
} else if (_input->pollEvent(kEventF1)) {
@ -362,6 +364,39 @@ void IllusionsEngine_Duckman::startFader(int duration, int minValue, int maxValu
_fader->_notifyThreadId = threadId;
}
void IllusionsEngine_Duckman::updateFader() {
if (_fader && !_fader->_paused && _fader->_active) {
int32 currTime = getCurrentTime();
int32 currDuration = currTime - _fader->_startTime;
if (currDuration) {
int newValue;
if (currDuration >= _fader->_duration) {
newValue = _fader->_maxValue;
} else {
newValue = (currDuration * (_fader->_maxValue - _fader->_minValue) / _fader->_duration) + _fader->_minValue;
}
if (_fader->_currValue != newValue) {
_fader->_currValue = newValue;
_screenPalette->setFader(newValue, _fader->_firstIndex, _fader->_lastIndex);
}
if (_fader->_currValue == _fader->_maxValue) {
_fader->_active = false;
notifyThreadId(_fader->_notifyThreadId);
}
}
}
}
void IllusionsEngine_Duckman::pauseFader() {
_fader->_paused = true;
_fader->_startTime = getCurrentTime() - _fader->_startTime;
}
void IllusionsEngine_Duckman::unpauseFader() {
_fader->_startTime = getCurrentTime() - _fader->_startTime;
_fader->_paused = false;
}
void IllusionsEngine_Duckman::setDefaultTextCoords() {
WidthHeight dimensions;
dimensions._width = 300;
@ -1145,7 +1180,7 @@ bool IllusionsEngine_Duckman::loadSavegameFromScript(int16 slotNum, uint32 calli
bool IllusionsEngine_Duckman::saveSavegameFromScript(int16 slotNum, uint32 callingThreadId) {
// TODO
const char *fileName = getSavegameFilename(slotNum);
// const char *fileName = getSavegameFilename(slotNum);
bool success = false;//savegame(fileName, _savegameDescription.c_str());
return success;
}

View file

@ -81,7 +81,7 @@ public:
protected:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
public:
// TODO ActiveScenes _activeScenes;
uint32 _prevSceneId;
@ -112,6 +112,9 @@ public:
int updateScreenShaker(uint flags);
void startFader(int duration, int minValue, int maxValue, int firstIndex, int lastIndex, uint32 threadId);
void updateFader();
void pauseFader();
void unpauseFader();
void setDefaultTextCoords();

View file

@ -206,14 +206,14 @@ int IllusionsEngine::updateGraphics(uint flags) {
return kUFNext;
}
int IllusionsEngine::updateSprites(uint flags) {
_screen->updateSprites();
_screen->updatePalette();
int IllusionsEngine::updateSoundMan(uint flags) {
_soundMan->update();
return kUFNext;
}
int IllusionsEngine::updateSoundMan(uint flags) {
_soundMan->update();
int IllusionsEngine::updateSprites(uint flags) {
_screen->updateSprites();
_screenPalette->updatePalette();
return kUFNext;
}
@ -267,39 +267,6 @@ bool IllusionsEngine::isSoundActive() {
return true;
}
void IllusionsEngine::updateFader() {
if (_fader && !_fader->_paused && _fader->_active) {
int32 currTime = getCurrentTime();
int32 currDuration = currTime - _fader->_startTime;
if (currDuration) {
int newValue;
if (currDuration >= _fader->_duration) {
newValue = _fader->_maxValue;
} else {
newValue = (currDuration * (_fader->_maxValue - _fader->_minValue) / _fader->_duration) + _fader->_minValue;
}
if (_fader->_currValue != newValue) {
_fader->_currValue = newValue;
_screen->setFader(newValue, _fader->_firstIndex, _fader->_lastIndex);
}
if (_fader->_currValue == _fader->_maxValue) {
_fader->_active = false;
notifyThreadId(_fader->_notifyThreadId);
}
}
}
}
void IllusionsEngine::pauseFader() {
_fader->_paused = true;
_fader->_startTime = getCurrentTime() - _fader->_startTime;
}
void IllusionsEngine::unpauseFader() {
_fader->_startTime = getCurrentTime() - _fader->_startTime;
_fader->_paused = false;
}
void IllusionsEngine::setCurrFontId(uint32 fontId) {
_fontId = fontId;
}

View file

@ -77,6 +77,7 @@ class TalkInstanceList;
class ThreadList;
class UpdateFunctions;
class GameState;
class ScreenPaletteBase;
enum {
kGameIdBBDOU = 1,
@ -108,6 +109,7 @@ public:
void updateEvents();
Screen *_screen;
ScreenPaletteBase *_screenPalette;
ScreenText *_screenText;
Input *_input;
ActorInstanceList *_actorInstances;
@ -157,8 +159,8 @@ public:
int updateActors(uint flags);
int updateSequences(uint flags);
int updateGraphics(uint flags);
int updateSprites(uint flags);
int updateSoundMan(uint flags);
int updateSprites(uint flags);
uint32 getElapsedUpdateTime();
Common::Point *getObjectActorPositionPtr(uint32 objectId);
@ -168,9 +170,9 @@ public:
void playVideo(uint32 videoId, uint32 objectId, uint32 value, uint32 threadId);
bool isSoundActive();
void updateFader();
void pauseFader();
void unpauseFader();
virtual void updateFader() {};
virtual void pauseFader() {};
virtual void unpauseFader() {};
void setCurrFontId(uint32 fontId);
bool checkActiveTalkThreads();

View file

@ -404,7 +404,7 @@ void BackgroundInstance::load(Resource *resource) {
if (_bgRes->_palettesCount > 0) {
Palette *palette = _bgRes->getPalette(_bgRes->_paletteIndex - 1);
_vm->_screen->setPalette(palette->_palette, 1, palette->_count);
_vm->_screenPalette->setPalette(palette->_palette, 1, palette->_count);
}
}
@ -425,7 +425,7 @@ void BackgroundInstance::pause() {
_vm->setDefaultTextCoords();
_vm->_camera->getActiveState(_savedCameraState);
_savedPalette = new byte[1024];
_vm->_screen->getPalette(_savedPalette);
_vm->_screenPalette->getPalette(_savedPalette);
freeSurface();
}
}
@ -435,7 +435,7 @@ void BackgroundInstance::unpause() {
if (_pauseCtr <= 0) {
registerResources();
initSurface();
_vm->_screen->setPalette(_savedPalette, 1, 256);
_vm->_screenPalette->setPalette(_savedPalette, 1, 256);
delete[] _savedPalette;
_savedPalette = 0;
// TODO _vm->_screen->_fadeClear();

View file

@ -214,6 +214,155 @@ bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcR
return true;
}
// Palette
ScreenPalette::ScreenPalette(IllusionsEngine *vm)
: _vm(vm), _needRefreshPalette(false), _isFaderActive(false) {
memset(_mainPalette, 0, sizeof(_mainPalette));
}
void ScreenPalette::setPalette(byte *colors, uint start, uint count) {
byte *dstPal = &_mainPalette[3 * (start - 1)];
for (uint i = 0; i < count; ++i) {
*dstPal++ = *colors++;
*dstPal++ = *colors++;
*dstPal++ = *colors++;
++colors;
}
buildColorTransTbl();
_needRefreshPalette = true;
}
void ScreenPalette::setPaletteEntry(int16 index, byte r, byte g, byte b) {
byte colors[4];
colors[0] = r;
colors[1] = g;
colors[2] = b;
setPalette(colors, index, 1);
}
void ScreenPalette::getPalette(byte *colors) {
byte *srcPal = _mainPalette;
for (uint i = 0; i < 256; ++i) {
*colors++ = *srcPal++;
*colors++ = *srcPal++;
*colors++ = *srcPal++;
++colors;
}
}
void ScreenPalette::shiftPalette(int16 fromIndex, int16 toIndex) {
byte r, g, b;
if (toIndex > fromIndex) {
r = _mainPalette[3 * toIndex + 0];
g = _mainPalette[3 * toIndex + 1];
b = _mainPalette[3 * toIndex + 2];
for (int16 i = toIndex; i > fromIndex; --i) {
byte *dst = &_mainPalette[3 * i];
byte *src = &_mainPalette[3 * (i - 1)];
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
}
_mainPalette[3 * fromIndex + 0] = r;
_mainPalette[3 * fromIndex + 1] = g;
_mainPalette[3 * fromIndex + 2] = b;
} else {
r = _mainPalette[3 * toIndex + 0];
g = _mainPalette[3 * toIndex + 1];
b = _mainPalette[3 * toIndex + 2];
for (int16 i = toIndex + 1; i < fromIndex; +i) {
byte *dst = &_mainPalette[3 * i];
byte *src = &_mainPalette[3 * (i + 1)];
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
}
_mainPalette[3 * fromIndex + 0] = r;
_mainPalette[3 * fromIndex + 1] = g;
_mainPalette[3 * fromIndex + 2] = b;
}
// TODO Refresh colorTransTbl
_needRefreshPalette = true;
}
void ScreenPalette::updatePalette() {
if (_needRefreshPalette) {
if (_isFaderActive) {
updateFaderPalette();
setSystemPalette(_faderPalette);
} else {
setSystemPalette(_mainPalette);
}
_needRefreshPalette = false;
}
}
void ScreenPalette::updateFaderPalette() {
if (_newFaderValue >= 255) {
_newFaderValue -= 256;
for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) {
byte r = _mainPalette[i * 3 + 0];
byte g = _mainPalette[i * 3 + 1];
byte b = _mainPalette[i * 3 + 2];
_faderPalette[i * 3 + 0] = r - (((_newFaderValue * (255 - r)) >> 8) & 0xFF);
_faderPalette[i * 3 + 1] = g - (((_newFaderValue * (255 - g)) >> 8) & 0xFF);
_faderPalette[i * 3 + 2] = b - (((_newFaderValue * (255 - b)) >> 8) & 0xFF);
}
} else {
for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) {
byte r = _mainPalette[i * 3 + 0];
byte g = _mainPalette[i * 3 + 1];
byte b = _mainPalette[i * 3 + 2];
_faderPalette[i * 3 + 0] = _newFaderValue * r / 255;
_faderPalette[i * 3 + 1] = _newFaderValue * g / 255;
_faderPalette[i * 3 + 2] = _newFaderValue * b / 255;
}
}
}
void ScreenPalette::setFader(int newValue, int firstIndex, int lastIndex) {
if (newValue == 255) {
_isFaderActive = false;
_needRefreshPalette = true;
} else {
_isFaderActive = true;
_needRefreshPalette = true;
_newFaderValue = newValue;
_firstFaderIndex = firstIndex - 1;
_lastFaderIndex = lastIndex;
}
}
void ScreenPalette::setSystemPalette(byte *palette) {
g_system->getPaletteManager()->setPalette(palette, 0, 256);
}
void ScreenPalette::buildColorTransTbl() {
const int cr = _mainPalette[3 * 1 + 0];
const int cg = _mainPalette[3 * 1 + 1];
const int cb = _mainPalette[3 * 1 + 2];
for (int index1 = 0; index1 < 256; ++index1) {
const int dr = (cr + _mainPalette[3 * index1 + 0]) / 2;
const int dg = (cg + _mainPalette[3 * index1 + 1]) / 2;
const int db = (cb + _mainPalette[3 * index1 + 2]) / 2;
int minDistance = 766;
int minIndex2 = 2;
for (int index2 = 2; index2 < 256; ++index2) {
int distance =
ABS(dr - _mainPalette[3 * index2 + 0]) +
ABS(dg - _mainPalette[3 * index2 + 1]) +
ABS(db - _mainPalette[3 * index2 + 2]);
if (distance < minDistance) {
minDistance = distance;
minIndex2 = index2;
}
}
_colorTransTbl[index1] = minIndex2;
}
}
// Screen
Screen::Screen(IllusionsEngine *vm, int16 width, int16 height, int bpp)
@ -230,10 +379,6 @@ Screen::Screen(IllusionsEngine *vm, int16 width, int16 height, int bpp)
_backSurface = allocSurface(width, height);
_needRefreshPalette = false;
memset(_mainPalette, 0, sizeof(_mainPalette));
_isFaderActive = false;
_isScreenOffsetActive = false;
}
@ -330,145 +475,6 @@ void Screen::drawSurface(Common::Rect &dstRect, Graphics::Surface *surface, Comm
}
}
void Screen::setPalette(byte *colors, uint start, uint count) {
if (_backSurface->format.bytesPerPixel == 1) {
byte *dstPal = &_mainPalette[3 * (start - 1)];
for (uint i = 0; i < count; ++i) {
*dstPal++ = *colors++;
*dstPal++ = *colors++;
*dstPal++ = *colors++;
++colors;
}
buildColorTransTbl();
_needRefreshPalette = true;
}
}
void Screen::setPaletteEntry(int16 index, byte r, byte g, byte b) {
byte colors[4];
colors[0] = r;
colors[1] = g;
colors[2] = b;
setPalette(colors, index, 1);
}
void Screen::getPalette(byte *colors) {
byte *srcPal = _mainPalette;
for (uint i = 0; i < 256; ++i) {
*colors++ = *srcPal++;
*colors++ = *srcPal++;
*colors++ = *srcPal++;
++colors;
}
}
void Screen::shiftPalette(int16 fromIndex, int16 toIndex) {
byte r, g, b;
if (toIndex > fromIndex) {
r = _mainPalette[3 * toIndex + 0];
g = _mainPalette[3 * toIndex + 1];
b = _mainPalette[3 * toIndex + 2];
for (int16 i = toIndex; i > fromIndex; --i) {
byte *dst = &_mainPalette[3 * i];
byte *src = &_mainPalette[3 * (i - 1)];
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
}
_mainPalette[3 * fromIndex + 0] = r;
_mainPalette[3 * fromIndex + 1] = g;
_mainPalette[3 * fromIndex + 2] = b;
} else {
r = _mainPalette[3 * toIndex + 0];
g = _mainPalette[3 * toIndex + 1];
b = _mainPalette[3 * toIndex + 2];
for (int16 i = toIndex + 1; i < fromIndex; +i) {
byte *dst = &_mainPalette[3 * i];
byte *src = &_mainPalette[3 * (i + 1)];
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
}
_mainPalette[3 * fromIndex + 0] = r;
_mainPalette[3 * fromIndex + 1] = g;
_mainPalette[3 * fromIndex + 2] = b;
}
// TODO Refresh colorTransTbl
_needRefreshPalette = true;
}
void Screen::updatePalette() {
if (_needRefreshPalette) {
if (_isFaderActive) {
updateFaderPalette();
setSystemPalette(_faderPalette);
} else {
setSystemPalette(_mainPalette);
}
_needRefreshPalette = false;
}
}
void Screen::updateFaderPalette() {
if (_newFaderValue >= 255) {
_newFaderValue -= 256;
for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) {
byte r = _mainPalette[i * 3 + 0];
byte g = _mainPalette[i * 3 + 1];
byte b = _mainPalette[i * 3 + 2];
_faderPalette[i * 3 + 0] = r - (((_newFaderValue * (255 - r)) >> 8) & 0xFF);
_faderPalette[i * 3 + 1] = g - (((_newFaderValue * (255 - g)) >> 8) & 0xFF);
_faderPalette[i * 3 + 2] = b - (((_newFaderValue * (255 - b)) >> 8) & 0xFF);
}
} else {
for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) {
byte r = _mainPalette[i * 3 + 0];
byte g = _mainPalette[i * 3 + 1];
byte b = _mainPalette[i * 3 + 2];
_faderPalette[i * 3 + 0] = _newFaderValue * r / 255;
_faderPalette[i * 3 + 1] = _newFaderValue * g / 255;
_faderPalette[i * 3 + 2] = _newFaderValue * b / 255;
}
}
}
void Screen::setFader(int newValue, int firstIndex, int lastIndex) {
if (newValue == 255) {
_isFaderActive = false;
_needRefreshPalette = true;
} else {
_isFaderActive = true;
_needRefreshPalette = true;
_newFaderValue = newValue;
_firstFaderIndex = firstIndex - 1;
_lastFaderIndex = lastIndex;
}
}
void Screen::buildColorTransTbl() {
const int cr = _mainPalette[3 * 1 + 0];
const int cg = _mainPalette[3 * 1 + 1];
const int cb = _mainPalette[3 * 1 + 2];
for (int index1 = 0; index1 < 256; ++index1) {
const int dr = (cr + _mainPalette[3 * index1 + 0]) / 2;
const int dg = (cg + _mainPalette[3 * index1 + 1]) / 2;
const int db = (cb + _mainPalette[3 * index1 + 2]) / 2;
int minDistance = 766;
int minIndex2 = 2;
for (int index2 = 2; index2 < 256; ++index2) {
int distance =
ABS(dr - _mainPalette[3 * index2 + 0]) +
ABS(dg - _mainPalette[3 * index2 + 1]) +
ABS(db - _mainPalette[3 * index2 + 2]);
if (distance < minDistance) {
minDistance = distance;
minIndex2 = index2;
}
}
_colorTransTbl[index1] = minIndex2;
}
}
void Screen::drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count) {
switch (_backSurface->format.bytesPerPixel) {
case 1:
@ -547,10 +553,6 @@ int16 Screen::drawChar16(FontResource *font, Graphics::Surface *surface, int16 x
return charWidth;
}
void Screen::setSystemPalette(byte *palette) {
g_system->getPaletteManager()->setPalette(palette, 0, 256);
}
void Screen::decompressSprite8(SpriteDecompressQueueItem *item) {
byte *src = item->_compressedPixels;
Graphics::Surface *dstSurface = item->_surface;
@ -637,6 +639,7 @@ void Screen::drawSurface81(int16 destX, int16 destY, Graphics::Surface *surface,
// Unscaled
const int16 w = srcRect.width();
const int16 h = srcRect.height();
const byte* colorTransTbl = _vm->_screenPalette->getColorTransTbl();
for (int16 yc = 0; yc < h; ++yc) {
byte *src = (byte*)surface->getBasePtr(srcRect.left, srcRect.top + yc);
byte *dst = (byte*)_backSurface->getBasePtr(destX, destY + yc);
@ -644,7 +647,7 @@ void Screen::drawSurface81(int16 destX, int16 destY, Graphics::Surface *surface,
const byte pixel = *src++;
if (pixel != 0) {
if (pixel == 1)
*dst = _colorTransTbl[*dst];
*dst = colorTransTbl[*dst];
else
*dst = pixel;
}
@ -659,10 +662,9 @@ void Screen::drawSurface82(Common::Rect &dstRect, Graphics::Surface *surface, Co
const int srcWidth = srcRect.width(), srcHeight = srcRect.height();
const int errYStart = srcHeight / dstHeight;
const int errYIncr = srcHeight % dstHeight;
// const int midY = dstHeight / 2;
const int errXStart = srcWidth / dstWidth;
const int errXIncr = srcWidth % dstWidth;
// const int midX = dstWidth / 2;
const byte* colorTransTbl = _vm->_screenPalette->getColorTransTbl();
int h = dstHeight, errY = 0, skipY, srcY = srcRect.top;
byte *dst = (byte*)_backSurface->getBasePtr(dstRect.left, dstRect.top);
skipY = (dstHeight < srcHeight) ? 0 : dstHeight / (2*srcHeight) + 1;
@ -677,7 +679,7 @@ void Screen::drawSurface82(Common::Rect &dstRect, Graphics::Surface *surface, Co
const byte pixel = *src;
if (pixel != 0) {
if (pixel == 1)
*dstRow = _colorTransTbl[*dstRow];
*dstRow = colorTransTbl[*dstRow];
else
*dstRow = pixel;
}
@ -693,7 +695,7 @@ void Screen::drawSurface82(Common::Rect &dstRect, Graphics::Surface *surface, Co
const byte pixel = *src;
if (pixel != 0) {
if (pixel == 1)
*dstRow = _colorTransTbl[*dstRow];
*dstRow = colorTransTbl[*dstRow];
else
*dstRow = pixel;
}

View file

@ -111,6 +111,47 @@ struct Fader {
Fader() : _active(false), _paused(false) {}
};
class ScreenPaletteBase {
public:
virtual ~ScreenPaletteBase() {};
virtual void setPalette(byte *colors, uint start, uint count) {};
virtual void setPaletteEntry(int16 index, byte r, byte g, byte b) {};
virtual void getPalette(byte *colors) {};
virtual void shiftPalette(int16 fromIndex, int16 toIndex) {};
virtual void updatePalette() {};
virtual void updateFaderPalette() {};
virtual void setFader(int newValue, int firstIndex, int lastIndex) {};
virtual bool isFaderActive() const { return false; }
virtual const byte* getColorTransTbl() const { return 0; }
};
class ScreenPalette : public ScreenPaletteBase {
public:
ScreenPalette(IllusionsEngine *vm);
void setPalette(byte *colors, uint start, uint count);
void setPaletteEntry(int16 index, byte r, byte g, byte b);
void getPalette(byte *colors);
void shiftPalette(int16 fromIndex, int16 toIndex);
void updatePalette();
void updateFaderPalette();
void setFader(int newValue, int firstIndex, int lastIndex);
bool isFaderActive() const { return _isFaderActive; }
const byte* getColorTransTbl() const { return _colorTransTbl; }
protected:
IllusionsEngine *_vm;
bool _needRefreshPalette;
byte _mainPalette[768];
byte _colorTransTbl[256];
bool _isFaderActive;
byte _faderPalette[768];
int _newFaderValue, _firstFaderIndex, _lastFaderIndex;
void setSystemPalette(byte *palette);
void buildColorTransTbl();
};
class NullScreenPalette : public ScreenPaletteBase {
};
// TODO Split into two classes (8bit and 16bit)?
class Screen {
@ -126,13 +167,6 @@ public:
void clearScreenOffsetAreas();
void decompressSprite(SpriteDecompressQueueItem *item);
void drawSurface(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, int16 scale, uint32 flags);
void setPalette(byte *colors, uint start, uint count);
void setPaletteEntry(int16 index, byte r, byte g, byte b);
void getPalette(byte *colors);
void shiftPalette(int16 fromIndex, int16 toIndex);
void updatePalette();
void updateFaderPalette();
void setFader(int newValue, int firstIndex, int lastIndex);
void drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
void fillSurface(Graphics::Surface *surface, byte color);
uint16 convertColor(byte color);
@ -141,7 +175,6 @@ public:
uint16 getColorKey2() const { return _colorKey2; }
int16 getScreenWidth() const { return _backSurface->w; }
int16 getScreenHeight() const { return _backSurface->h; }
bool isFaderActive() const { return _isFaderActive; }
public:
IllusionsEngine *_vm;
bool _displayOn;
@ -151,20 +184,9 @@ public:
SpriteDrawQueue *_drawQueue;
Graphics::Surface *_backSurface;
bool _needRefreshPalette;
byte _mainPalette[768];
byte _colorTransTbl[256];
bool _isFaderActive;
byte _faderPalette[768];
int _newFaderValue, _firstFaderIndex, _lastFaderIndex;
bool _isScreenOffsetActive;
Common::Point _screenOffsetPt;
void setSystemPalette(byte *palette);
void buildColorTransTbl();
void drawText8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
int16 drawChar8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c);

View file

@ -128,7 +128,7 @@ bool ScreenText::insertText(uint16 *text, uint32 fontId, WidthHeight dimensions,
bool done = refreshScreenText(font, screenText->_info._dimensions, screenText->_info._offsPt,
text, screenText->_info._flags, screenText->_info._color2, screenText->_info._color1,
outTextPtr);
_vm->_screen->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
_vm->_screenPalette->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
uint16 *textPart = screenText->_text;
while (text != outTextPtr)
@ -157,7 +157,7 @@ void ScreenText::removeText() {
refreshScreenText(font, screenText->_info._dimensions, screenText->_info._offsPt,
screenText->_text, screenText->_info._flags, screenText->_info._color2, screenText->_info._color1,
outTextPtr);
_vm->_screen->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
_vm->_screenPalette->setPaletteEntry(font->getColorIndex(), screenText->_info._colorR, screenText->_info._colorG, screenText->_info._colorB);
setTextInfoPosition(screenText->_info._position);
}
}

View file

@ -361,13 +361,13 @@ void SequenceOpcodes::opSetPalette(Control *control, OpCall &opCall) {
ARG_BYTE(fromIndex);
BackgroundResource *bgRes = _vm->_backgroundInstances->getActiveBgResource();
Palette *palette = bgRes->getPalette(paletteIndex - 1);
_vm->_screen->setPalette(palette->_palette, fromIndex, palette->_count);
_vm->_screenPalette->setPalette(palette->_palette, fromIndex, palette->_count);
}
void SequenceOpcodes::opShiftPalette(Control *control, OpCall &opCall) {
ARG_INT16(fromIndex);
ARG_INT16(toIndex);
_vm->_screen->shiftPalette(fromIndex, toIndex);
_vm->_screenPalette->shiftPalette(fromIndex, toIndex);
}
void SequenceOpcodes::opPlaySound(Control *control, OpCall &opCall) {