diff options
author | Filippos Karapetis | 2009-10-06 14:37:25 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-06 14:37:25 +0000 |
commit | 5d382150dfcef7ad596f5c164d9313c8469ddf62 (patch) | |
tree | dcb3ed7fff6b8b8b00240d4bb3842d7b63c740aa /engines/sci/gui | |
parent | 3eb350ff1f93a2390faf1fdf36314c2c4f8c9857 (diff) | |
download | scummvm-rg350-5d382150dfcef7ad596f5c164d9313c8469ddf62.tar.gz scummvm-rg350-5d382150dfcef7ad596f5c164d9313c8469ddf62.tar.bz2 scummvm-rg350-5d382150dfcef7ad596f5c164d9313c8469ddf62.zip |
- Removed the SciGuiGfx parameter from SciGuiView
- Moved _sysPalette inside SciGuiScreen
- Made CreatePaletteFromData() a static helper function
svn-id: r44696
Diffstat (limited to 'engines/sci/gui')
-rw-r--r-- | engines/sci/gui/gui.cpp | 8 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.cpp | 162 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.h | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_helpers.h | 48 | ||||
-rw-r--r-- | engines/sci/gui/gui_picture.cpp | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_screen.h | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_view.cpp | 23 | ||||
-rw-r--r-- | engines/sci/gui/gui_view.h | 9 |
8 files changed, 132 insertions, 124 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 4bbeb14bf6..2022c9c06c 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -261,7 +261,7 @@ void SciGui::drawPicture(GuiResourceId pictureId, uint16 style, uint16 flags, in void SciGui::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo) { _gfx->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, paletteNo); - _gfx->setScreenPalette(&_gfx->_sysPalette); + _gfx->setScreenPalette(&_screen->_sysPalette); _screen->copyToScreen(); } @@ -333,13 +333,13 @@ void SciGui::paletteSet(int resourceNo, int flags) { } int16 SciGui::paletteFind(int r, int g, int b) { - return _gfx->MatchColor(&_gfx->_sysPalette, r, g, b) & 0xFF; + return _gfx->MatchColor(&_screen->_sysPalette, r, g, b) & 0xFF; } void SciGui::paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette) { - _gfx->PaletteSetIntensity(fromColor, toColor, intensity, &_gfx->_sysPalette); + _gfx->PaletteSetIntensity(fromColor, toColor, intensity, &_screen->_sysPalette); if (setPalette) { - _gfx->setScreenPalette(&_gfx->_sysPalette); + _gfx->setScreenPalette(&_screen->_sysPalette); } } diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index 26062666b2..b3ed3d0358 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -76,18 +76,18 @@ void SciGuiGfx::init() { void SciGuiGfx::initPalette() { int16 i; for (i = 0; i < 256; i++) { - _sysPalette.colors[i].used = 0; - _sysPalette.colors[i].r = 0; - _sysPalette.colors[i].g = 0; - _sysPalette.colors[i].b = 0; - _sysPalette.intensity[i] = 100; - _sysPalette.mapping[i] = i; + _screen->_sysPalette.colors[i].used = 0; + _screen->_sysPalette.colors[i].r = 0; + _screen->_sysPalette.colors[i].g = 0; + _screen->_sysPalette.colors[i].b = 0; + _screen->_sysPalette.intensity[i] = 100; + _screen->_sysPalette.mapping[i] = i; } - _sysPalette.colors[0].used = 1; - _sysPalette.colors[255].used = 1; - _sysPalette.colors[255].r = 255; - _sysPalette.colors[255].g = 255; - _sysPalette.colors[255].b = 255; + _screen->_sysPalette.colors[0].used = 1; + _screen->_sysPalette.colors[255].used = 1; + _screen->_sysPalette.colors[255].r = 255; + _screen->_sysPalette.colors[255].g = 255; + _screen->_sysPalette.colors[255].b = 255; // Load default palette from resource 999 if (!SetResPalette(999, 2)) { @@ -132,10 +132,10 @@ bool SciGuiGfx::SetAmigaPalette() { byte2 = file.readByte(); if ((byte1 == EOF) || (byte2 == EOF)) error("Amiga palette file ends prematurely"); - _sysPalette.colors[curColor].used = 1; - _sysPalette.colors[curColor].r = (byte1 & 0x0F) * 0x11; - _sysPalette.colors[curColor].g = ((byte2 & 0xF0) >> 4) * 0x11; - _sysPalette.colors[curColor].b = (byte2 & 0x0F) * 0x11; + _screen->_sysPalette.colors[curColor].used = 1; + _screen->_sysPalette.colors[curColor].r = (byte1 & 0x0F) * 0x11; + _screen->_sysPalette.colors[curColor].g = ((byte2 & 0xF0) >> 4) * 0x11; + _screen->_sysPalette.colors[curColor].b = (byte2 & 0x0F) * 0x11; } file.close(); return true; @@ -145,76 +145,29 @@ bool SciGuiGfx::SetAmigaPalette() { void SciGuiGfx::SetEGApalette() { int i; - _sysPalette.colors[1].r = 0x000; _sysPalette.colors[1].g = 0x000; _sysPalette.colors[1].b = 0x0AA; - _sysPalette.colors[2].r = 0x000; _sysPalette.colors[2].g = 0x0AA; _sysPalette.colors[2].b = 0x000; - _sysPalette.colors[3].r = 0x000; _sysPalette.colors[3].g = 0x0AA; _sysPalette.colors[3].b = 0x0AA; - _sysPalette.colors[4].r = 0x0AA; _sysPalette.colors[4].g = 0x000; _sysPalette.colors[4].b = 0x000; - _sysPalette.colors[5].r = 0x0AA; _sysPalette.colors[5].g = 0x000; _sysPalette.colors[5].b = 0x0AA; - _sysPalette.colors[6].r = 0x0AA; _sysPalette.colors[6].g = 0x055; _sysPalette.colors[6].b = 0x000; - _sysPalette.colors[7].r = 0x0AA; _sysPalette.colors[7].g = 0x0AA; _sysPalette.colors[7].b = 0x0AA; - _sysPalette.colors[8].r = 0x055; _sysPalette.colors[8].g = 0x055; _sysPalette.colors[8].b = 0x055; - _sysPalette.colors[9].r = 0x055; _sysPalette.colors[9].g = 0x055; _sysPalette.colors[9].b = 0x0FF; - _sysPalette.colors[10].r = 0x055; _sysPalette.colors[10].g = 0x0FF; _sysPalette.colors[10].b = 0x055; - _sysPalette.colors[11].r = 0x055; _sysPalette.colors[11].g = 0x0FF; _sysPalette.colors[11].b = 0x0FF; - _sysPalette.colors[12].r = 0x0FF; _sysPalette.colors[12].g = 0x055; _sysPalette.colors[12].b = 0x055; - _sysPalette.colors[13].r = 0x0FF; _sysPalette.colors[13].g = 0x055; _sysPalette.colors[13].b = 0x0FF; - _sysPalette.colors[14].r = 0x0FF; _sysPalette.colors[14].g = 0x0FF; _sysPalette.colors[14].b = 0x055; - _sysPalette.colors[15].r = 0x0FF; _sysPalette.colors[15].g = 0x0FF; _sysPalette.colors[15].b = 0x0FF; + _screen->_sysPalette.colors[1].r = 0x000; _screen->_sysPalette.colors[1].g = 0x000; _screen->_sysPalette.colors[1].b = 0x0AA; + _screen->_sysPalette.colors[2].r = 0x000; _screen->_sysPalette.colors[2].g = 0x0AA; _screen->_sysPalette.colors[2].b = 0x000; + _screen->_sysPalette.colors[3].r = 0x000; _screen->_sysPalette.colors[3].g = 0x0AA; _screen->_sysPalette.colors[3].b = 0x0AA; + _screen->_sysPalette.colors[4].r = 0x0AA; _screen->_sysPalette.colors[4].g = 0x000; _screen->_sysPalette.colors[4].b = 0x000; + _screen->_sysPalette.colors[5].r = 0x0AA; _screen->_sysPalette.colors[5].g = 0x000; _screen->_sysPalette.colors[5].b = 0x0AA; + _screen->_sysPalette.colors[6].r = 0x0AA; _screen->_sysPalette.colors[6].g = 0x055; _screen->_sysPalette.colors[6].b = 0x000; + _screen->_sysPalette.colors[7].r = 0x0AA; _screen->_sysPalette.colors[7].g = 0x0AA; _screen->_sysPalette.colors[7].b = 0x0AA; + _screen->_sysPalette.colors[8].r = 0x055; _screen->_sysPalette.colors[8].g = 0x055; _screen->_sysPalette.colors[8].b = 0x055; + _screen->_sysPalette.colors[9].r = 0x055; _screen->_sysPalette.colors[9].g = 0x055; _screen->_sysPalette.colors[9].b = 0x0FF; + _screen->_sysPalette.colors[10].r = 0x055; _screen->_sysPalette.colors[10].g = 0x0FF; _screen->_sysPalette.colors[10].b = 0x055; + _screen->_sysPalette.colors[11].r = 0x055; _screen->_sysPalette.colors[11].g = 0x0FF; _screen->_sysPalette.colors[11].b = 0x0FF; + _screen->_sysPalette.colors[12].r = 0x0FF; _screen->_sysPalette.colors[12].g = 0x055; _screen->_sysPalette.colors[12].b = 0x055; + _screen->_sysPalette.colors[13].r = 0x0FF; _screen->_sysPalette.colors[13].g = 0x055; _screen->_sysPalette.colors[13].b = 0x0FF; + _screen->_sysPalette.colors[14].r = 0x0FF; _screen->_sysPalette.colors[14].g = 0x0FF; _screen->_sysPalette.colors[14].b = 0x055; + _screen->_sysPalette.colors[15].r = 0x0FF; _screen->_sysPalette.colors[15].g = 0x0FF; _screen->_sysPalette.colors[15].b = 0x0FF; for (i = 0; i <= 15; i++) { - _sysPalette.colors[i].used = 1; + _screen->_sysPalette.colors[i].used = 1; } for (i = 16; i <= 254; i++) { - _sysPalette.colors[i].r = 200; - _sysPalette.colors[i].used = 1; - } - setScreenPalette(&_sysPalette); -} - -#define SCI_PAL_FORMAT_CONSTANT 1 -#define SCI_PAL_FORMAT_VARIABLE 0 - -void SciGuiGfx::CreatePaletteFromData(byte *data, GuiPalette *paletteOut) { - int palFormat = 0; - int palOffset = 0; - int palColorStart = 0; - int palColorCount = 0; - int colorNo = 0; - - memset(paletteOut, 0, sizeof(GuiPalette)); - // Setup default mapping - for (colorNo = 0; colorNo < 256; colorNo++) { - paletteOut->mapping[colorNo] = colorNo; - } - if (data[0] == 0 && data[1] == 1) { - // SCI0/SCI1 palette - palFormat = SCI_PAL_FORMAT_VARIABLE; // CONSTANT; - palOffset = 260; - palColorStart = 0; palColorCount = 256; - //memcpy(&paletteOut->mapping, data, 256); - } else { - // SCI1.1 palette - palFormat = data[32]; - palOffset = 37; - palColorStart = READ_LE_UINT16(data + 25); palColorCount = READ_LE_UINT16(data + 29); - } - switch (palFormat) { - case SCI_PAL_FORMAT_CONSTANT: - for (colorNo = palColorStart; colorNo < palColorStart + palColorCount; colorNo++) { - paletteOut->colors[colorNo].used = 1; - paletteOut->colors[colorNo].r = data[palOffset++]; - paletteOut->colors[colorNo].g = data[palOffset++]; - paletteOut->colors[colorNo].b = data[palOffset++]; - } - break; - case SCI_PAL_FORMAT_VARIABLE: - for (colorNo = palColorStart; colorNo < palColorStart + palColorCount; colorNo++) { - paletteOut->colors[colorNo].used = data[palOffset++]; - paletteOut->colors[colorNo].r = data[palOffset++]; - paletteOut->colors[colorNo].g = data[palOffset++]; - paletteOut->colors[colorNo].b = data[palOffset++]; - } - break; + _screen->_sysPalette.colors[i].r = 200; + _screen->_sysPalette.colors[i].used = 1; } + setScreenPalette(&_screen->_sysPalette); } bool SciGuiGfx::SetResPalette(int16 resourceNo, int16 flag) { @@ -230,12 +183,12 @@ bool SciGuiGfx::SetResPalette(int16 resourceNo, int16 flag) { } void SciGuiGfx::SetPalette(GuiPalette *sciPal, int16 flag) { - uint32 systime = _sysPalette.timestamp; + uint32 systime = _screen->_sysPalette.timestamp; if (flag == 2 || sciPal->timestamp != systime) { - MergePalettes(sciPal, &_sysPalette, flag); - sciPal->timestamp = _sysPalette.timestamp; - if (_picNotValid == 0 && systime != _sysPalette.timestamp) - setScreenPalette(&_sysPalette); + MergePalettes(sciPal, &_screen->_sysPalette, flag); + sciPal->timestamp = _screen->_sysPalette.timestamp; + if (_picNotValid == 0 && systime != _screen->_sysPalette.timestamp) + setScreenPalette(&_screen->_sysPalette); } } @@ -306,8 +259,8 @@ uint16 SciGuiGfx::MatchColor(GuiPalette*pPal, byte r, byte g, byte b) { } void SciGuiGfx::setScreenPalette(GuiPalette*pal) { - if (pal != &_sysPalette) - memcpy(&_sysPalette,pal,sizeof(GuiPalette)); + if (pal != &_screen->_sysPalette) + memcpy(&_screen->_sysPalette,pal,sizeof(GuiPalette)); // just copy palette to system byte bpal[4 * 256]; // Get current palette, update it and put back @@ -324,8 +277,8 @@ void SciGuiGfx::setScreenPalette(GuiPalette*pal) { } void SciGuiGfx::getSysPalette(GuiPalette*pal) { - if (pal != &_sysPalette) - memcpy(pal, &_sysPalette,sizeof(GuiPalette)); + if (pal != &_screen->_sysPalette) + memcpy(pal, &_screen->_sysPalette,sizeof(GuiPalette)); } GuiPort *SciGuiGfx::SetPort(GuiPort *newPort) { @@ -1267,7 +1220,7 @@ void SciGuiGfx::drawPicture(GuiResourceId pictureId, uint16 style, bool addToFla } void SciGuiGfx::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo) { - SciGuiView *view = new SciGuiView(_s->resMan, this, _screen, viewId); + SciGuiView *view = new SciGuiView(_s->resMan, _screen, viewId); Common::Rect rect(0, 0); Common::Rect clipRect(0, 0); if (view) { @@ -1279,7 +1232,16 @@ void SciGuiGfx::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo clipRect.clip(_curPort->rect); if (clipRect.isEmpty()) // nothing to draw return; - view->draw(rect, clipRect, loopNo, celNo, priority, paletteNo); + + if (view->hasEmbeddedPal()) { + // Merge view palette in... + SetPalette(view->getPalette(), 1); + } + + Common::Rect clipRectTranslated = clipRect; + OffsetRect(clipRectTranslated); + view->draw(rect, clipRect, clipRectTranslated, loopNo, celNo, priority, paletteNo); + //if (_picNotValid == 0) // _gfx->ShowBits(rect, 1); } @@ -1299,18 +1261,18 @@ void SciGuiGfx::PaletteAnimate(byte fromColor, byte toColor, int speed) { if (_palSchedules[i].from == fromColor) { if (_palSchedules[i].schedule < now) { if (speed > 0) { - col = _sysPalette.colors[fromColor]; - memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], len * sizeof(GuiColor)); - _sysPalette.colors[toColor - 1] = col; + col = _screen->_sysPalette.colors[fromColor]; + memmove(&_screen->_sysPalette.colors[fromColor], &_screen->_sysPalette.colors[fromColor + 1], len * sizeof(GuiColor)); + _screen->_sysPalette.colors[toColor - 1] = col; } else { - col = _sysPalette.colors[toColor - 1]; - memmove(&_sysPalette.colors[fromColor+1], &_sysPalette.colors[fromColor], len * sizeof(GuiColor)); - _sysPalette.colors[fromColor] = col; + col = _screen->_sysPalette.colors[toColor - 1]; + memmove(&_screen->_sysPalette.colors[fromColor + 1], &_screen->_sysPalette.colors[fromColor], len * sizeof(GuiColor)); + _screen->_sysPalette.colors[fromColor] = col; } // removing schedule _palSchedules.remove_at(i); } - setScreenPalette(&_sysPalette); + setScreenPalette(&_screen->_sysPalette); return; } } @@ -1410,7 +1372,7 @@ void SciGuiGfx::SetNowSeen(reg_t objectReference) { } // now get cel rectangle - view = new SciGuiView(_s->resMan, this, _screen, viewId); + view = new SciGuiView(_s->resMan, _screen, viewId); view->getCelRect(loopNo, celNo, x, y, z, &celRect); // TODO: sometimes loop is negative. Check what it means diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index 5555786ec4..92cea7ae9d 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -53,7 +53,6 @@ public: void ResetScreen(); bool SetAmigaPalette(); void SetEGApalette(); - void CreatePaletteFromData(byte *paletteData, GuiPalette *paletteOut); bool SetResPalette(int16 resourceNo, int16 flag); void SetPalette(GuiPalette *sciPal, int16 flag); void MergePalettes(GuiPalette *pFrom, GuiPalette *pTo, uint16 flag); @@ -134,7 +133,6 @@ public: Common::Rect _menuRect; uint32 _sysTicks; int32 _sysSpeed; // ticker timer in ms - GuiPalette _sysPalette; bool _picNotValid; diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h index bf83a6dac8..ed66705976 100644 --- a/engines/sci/gui/gui_helpers.h +++ b/engines/sci/gui/gui_helpers.h @@ -26,6 +26,7 @@ #ifndef SCI_GUI_HELPERS_H #define SCI_GUI_HELPERS_H +#include "common/endian.h" // for READ_LE_UINT16 #include "common/rect.h" #include "sci/engine/vm_types.h" @@ -107,6 +108,53 @@ enum { GFX_REMOVEVIEW = 0x80 }; +#define SCI_PAL_FORMAT_CONSTANT 1 +#define SCI_PAL_FORMAT_VARIABLE 0 + +static inline void CreatePaletteFromData(byte *data, GuiPalette *paletteOut) { + int palFormat = 0; + int palOffset = 0; + int palColorStart = 0; + int palColorCount = 0; + int colorNo = 0; + + memset(paletteOut, 0, sizeof(GuiPalette)); + // Setup default mapping + for (colorNo = 0; colorNo < 256; colorNo++) { + paletteOut->mapping[colorNo] = colorNo; + } + if (data[0] == 0 && data[1] == 1) { + // SCI0/SCI1 palette + palFormat = SCI_PAL_FORMAT_VARIABLE; // CONSTANT; + palOffset = 260; + palColorStart = 0; palColorCount = 256; + //memcpy(&paletteOut->mapping, data, 256); + } else { + // SCI1.1 palette + palFormat = data[32]; + palOffset = 37; + palColorStart = READ_LE_UINT16(data + 25); palColorCount = READ_LE_UINT16(data + 29); + } + switch (palFormat) { + case SCI_PAL_FORMAT_CONSTANT: + for (colorNo = palColorStart; colorNo < palColorStart + palColorCount; colorNo++) { + paletteOut->colors[colorNo].used = 1; + paletteOut->colors[colorNo].r = data[palOffset++]; + paletteOut->colors[colorNo].g = data[palOffset++]; + paletteOut->colors[colorNo].b = data[palOffset++]; + } + break; + case SCI_PAL_FORMAT_VARIABLE: + for (colorNo = palColorStart; colorNo < palColorStart + palColorCount; colorNo++) { + paletteOut->colors[colorNo].used = data[palOffset++]; + paletteOut->colors[colorNo].r = data[palOffset++]; + paletteOut->colors[colorNo].g = data[palOffset++]; + paletteOut->colors[colorNo].b = data[palOffset++]; + } + break; + } +} + } // End of namespace Sci #endif diff --git a/engines/sci/gui/gui_picture.cpp b/engines/sci/gui/gui_picture.cpp index d58fd678aa..aa54333688 100644 --- a/engines/sci/gui/gui_picture.cpp +++ b/engines/sci/gui/gui_picture.cpp @@ -91,7 +91,7 @@ void SciGuiPicture::drawSci11Vga() { GuiPalette palette; // Create palette and set it - _gfx->CreatePaletteFromData(inbuffer + palette_data_ptr, &palette); + CreatePaletteFromData(inbuffer + palette_data_ptr, &palette); _gfx->SetPalette(&palette, 2); // display Cel-data diff --git a/engines/sci/gui/gui_screen.h b/engines/sci/gui/gui_screen.h index 45f4d99685..1b3688e5a4 100644 --- a/engines/sci/gui/gui_screen.h +++ b/engines/sci/gui/gui_screen.h @@ -68,6 +68,8 @@ public: uint16 _displayHeight; uint _displayPixels; + GuiPalette _sysPalette; + private: void restoreBitsScreen(Common::Rect rect, byte *&memoryPtr, byte *screen); void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr); diff --git a/engines/sci/gui/gui_view.cpp b/engines/sci/gui/gui_view.cpp index b5bd5f5380..c5bcd6cc9e 100644 --- a/engines/sci/gui/gui_view.cpp +++ b/engines/sci/gui/gui_view.cpp @@ -32,8 +32,8 @@ namespace Sci { -SciGuiView::SciGuiView(ResourceManager *resMan, SciGuiGfx *gfx, SciGuiScreen *screen, GuiResourceId resourceId) - : _resMan(resMan), _gfx(gfx), _screen(screen), _resourceId(resourceId) { +SciGuiView::SciGuiView(ResourceManager *resMan, SciGuiScreen *screen, GuiResourceId resourceId) + : _resMan(resMan), _screen(screen), _resourceId(resourceId) { assert(resourceId != -1); initData(resourceId); } @@ -82,7 +82,7 @@ void SciGuiView::initData(GuiResourceId resourceId) { if (IsEGA) { // simple mapping for 16 colors _EGAMapping = _resourceData + palOffset; } else { - _gfx->CreatePaletteFromData(&_resourceData[palOffset], &_palette); + CreatePaletteFromData(&_resourceData[palOffset], &_palette); _embeddedPal = true; } } @@ -141,7 +141,7 @@ void SciGuiView::initData(GuiResourceId resourceId) { celSize = _resourceData[13]; if (palOffset) { - _gfx->CreatePaletteFromData(&_resourceData[palOffset], &_palette); + CreatePaletteFromData(&_resourceData[palOffset], &_palette); _embeddedPal = true; } @@ -343,8 +343,8 @@ byte *SciGuiView::getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo) { return _loop[loopNo].cel[celNo].rawBitmap; } -void SciGuiView::draw(Common::Rect rect, Common::Rect clipRect, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo) { - GuiPalette *palette = _embeddedPal ? &_palette : &_gfx->_sysPalette; +void SciGuiView::draw(Common::Rect rect, Common::Rect clipRect, Common::Rect clipRectTranslated, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo) { + GuiPalette *palette = _embeddedPal ? &_palette : &_screen->_sysPalette; sciViewCelInfo *celInfo = getCelInfo(loopNo, celNo); byte *bitmap = getBitmap(loopNo, celNo); int16 celHeight = celInfo->height, celWidth = celInfo->width; @@ -354,21 +354,16 @@ void SciGuiView::draw(Common::Rect rect, Common::Rect clipRect, GuiViewLoopNo lo byte drawMask = priority == 255 ? SCI_SCREEN_MASK_VISUAL : SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY; int x, y; - // Merge view palette in... - if (_embeddedPal) - _gfx->SetPalette(&_palette, 1); - width = MIN(clipRect.width(), celWidth); height = MIN(clipRect.height(), celHeight); bitmap += (clipRect.top - rect.top) * celWidth + (clipRect.left - rect.left); - _gfx->OffsetRect(clipRect); - for (y = clipRect.top; y < clipRect.top + height; y++, bitmap += celWidth) { + for (y = clipRectTranslated.top; y < clipRectTranslated.top + height; y++, bitmap += celWidth) { for (x = 0; x < width; x++) { color = bitmap[x]; - if (color != clearKey && priority >= _screen->getPriority(clipRect.left + x, y)) - _screen->putPixel(clipRect.left + x, y, drawMask, palette->mapping[color], priority, 0); + if (color != clearKey && priority >= _screen->getPriority(clipRectTranslated.left + x, y)) + _screen->putPixel(clipRectTranslated.left + x, y, drawMask, palette->mapping[color], priority, 0); } } } diff --git a/engines/sci/gui/gui_view.h b/engines/sci/gui/gui_view.h index 0fd2ab244f..b2bf9d7d35 100644 --- a/engines/sci/gui/gui_view.h +++ b/engines/sci/gui/gui_view.h @@ -47,7 +47,7 @@ struct sciViewLoopInfo { class SciGuiView { public: - SciGuiView(ResourceManager *resMan, SciGuiGfx *gfx, SciGuiScreen *screen, GuiResourceId resourceId); + SciGuiView(ResourceManager *resMan, SciGuiScreen *screen, GuiResourceId resourceId); ~SciGuiView(); // TODO: Remove gfx reference after putting palette things into SciGuiScreen @@ -59,14 +59,17 @@ public: sciViewLoopInfo *getLoopInfo(GuiViewLoopNo loopNo); void getCelRect(GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 x, int16 y, int16 z, Common::Rect *outRect); byte *getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo); - void draw(Common::Rect rect, Common::Rect clipRect, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo); + void draw(Common::Rect rect, Common::Rect clipRect, Common::Rect clipRectTranslated, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo); + + bool hasEmbeddedPal() const { return _embeddedPal; } + + GuiPalette *getPalette() { return &_palette; } private: void initData(GuiResourceId resourceId); void unpackCel(GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte *outPtr, uint16 pixelCount); ResourceManager *_resMan; - SciGuiGfx *_gfx; SciGuiScreen *_screen; GuiResourceId _resourceId; |