diff options
author | Johannes Schickel | 2011-02-19 21:42:34 +0100 |
---|---|---|
committer | Johannes Schickel | 2011-02-19 21:46:45 +0100 |
commit | e21d6e0d1120e917a4a019a4070ec4db5e988b9b (patch) | |
tree | 1142828b72ccf17d513c621e108d749f148fd32b /backends | |
parent | 32d0e4c15fb33f80db194087850466664a43516a (diff) | |
parent | b26f30b98793c522265a3eeb48fb3b41034663c6 (diff) | |
download | scummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.tar.gz scummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.tar.bz2 scummvm-rg350-e21d6e0d1120e917a4a019a4070ec4db5e988b9b.zip |
Merge branch 'osystem-palette' of https://github.com/lordhoto/scummvm into master
Conflicts:
backends/platform/android/android.cpp
engines/sci/graphics/screen.cpp
engines/sci/graphics/transitions.cpp
Diffstat (limited to 'backends')
-rw-r--r-- | backends/graphics/default-palette.h | 6 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 28 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 13 | ||||
-rw-r--r-- | backends/platform/android/android.cpp | 26 | ||||
-rw-r--r-- | backends/platform/dc/display.cpp | 7 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 5 | ||||
-rw-r--r-- | backends/platform/iphone/osys_video.cpp | 5 | ||||
-rw-r--r-- | backends/platform/n64/osys_n64.h | 2 | ||||
-rw-r--r-- | backends/platform/n64/osys_n64_base.cpp | 18 | ||||
-rw-r--r-- | backends/platform/ps2/Gs2dScreen.cpp | 16 | ||||
-rw-r--r-- | backends/platform/ps2/Gs2dScreen.h | 4 | ||||
-rw-r--r-- | backends/platform/ps2/systemps2.cpp | 4 | ||||
-rw-r--r-- | backends/platform/psp/display_client.cpp | 6 | ||||
-rw-r--r-- | backends/platform/wii/osystem_gfx.cpp | 15 |
14 files changed, 64 insertions, 91 deletions
diff --git a/backends/graphics/default-palette.h b/backends/graphics/default-palette.h index 6e3a75350e..12436aae51 100644 --- a/backends/graphics/default-palette.h +++ b/backends/graphics/default-palette.h @@ -38,7 +38,7 @@ */ class DefaultPaletteManager : public PaletteManager { protected: - byte _palette[4 * 256]; + byte _palette[3 * 256]; /** * Subclasses should only implement this method and none of the others. @@ -51,12 +51,12 @@ protected: public: void setPalette(const byte *colors, uint start, uint num) { assert(start + num <= 256); - memcpy(_palette + 4 * start, colors, 4 * num); + memcpy(_palette + 3 * start, colors, 3 * num); setPaletteIntern(colors, start, num); } void grabPalette(byte *colors, uint start, uint num) { assert(start + num <= 256); - memcpy(colors, _palette + 4 * start, 4 * num); + memcpy(colors, _palette + 3 * start, 3 * num); } }; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index a1b2e00f51..beac2f6d3e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -62,8 +62,8 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() _videoMode.fullscreen = ConfMan.getBool("fullscreen"); _videoMode.antialiasing = false; - _gamePalette = (byte *)calloc(sizeof(byte) * 4, 256); - _cursorPalette = (byte *)calloc(sizeof(byte) * 4, 256); + _gamePalette = (byte *)calloc(sizeof(byte) * 3, 256); + _cursorPalette = (byte *)calloc(sizeof(byte) * 3, 256); } OpenGLGraphicsManager::~OpenGLGraphicsManager() { @@ -314,7 +314,7 @@ void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) #endif // Save the screen palette - memcpy(_gamePalette + start * 4, colors, num * 4); + memcpy(_gamePalette + start * 3, colors, num * 3); _screenNeedsRedraw = true; @@ -330,7 +330,7 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) { #endif // Copies current palette to buffer - memcpy(colors, _gamePalette + start * 4, num * 4); + memcpy(colors, _gamePalette + start * 3, num * 3); } void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -580,7 +580,7 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin assert(colors); // Save the cursor palette - memcpy(_cursorPalette + start * 4, colors, num * 4); + memcpy(_cursorPalette + start * 3, colors, num * 3); _cursorPaletteDisabled = false; _cursorNeedsRedraw = true; @@ -686,9 +686,9 @@ void OpenGLGraphicsManager::refreshGameScreen() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -728,9 +728,9 @@ void OpenGLGraphicsManager::refreshOverlay() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -772,9 +772,9 @@ void OpenGLGraphicsManager::refreshCursor() { for (int i = 0; i < _cursorState.w * _cursorState.h; i++) { // Check for keycolor if (src[i] != _cursorKeyColor) { - dst[0] = palette[src[i] * 4]; - dst[1] = palette[src[i] * 4 + 1]; - dst[2] = palette[src[i] * 4 + 2]; + dst[0] = palette[src[i] * 3]; + dst[1] = palette[src[i] * 3 + 1]; + dst[2] = palette[src[i] * 3 + 2]; dst[3] = 255; } dst += 4; diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 480cf2e795..15d896c57a 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -1337,11 +1337,10 @@ void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; SDL_Color *base = _currentPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } if (start < _paletteDirtyStart) @@ -1365,10 +1364,9 @@ void SdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { const SDL_Color *base = _currentPalette + start; for (uint i = 0; i < num; ++i) { - colors[i * 4] = base[i].r; - colors[i * 4 + 1] = base[i].g; - colors[i * 4 + 2] = base[i].b; - colors[i * 4 + 3] = 0xFF; + colors[i * 3] = base[i].r; + colors[i * 3 + 1] = base[i].g; + colors[i * 3 + 2] = base[i].b; } } @@ -1377,11 +1375,10 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n const byte *b = colors; uint i; SDL_Color *base = _cursorPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } _cursorPaletteDisabled = false; diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 0424983824..38bc94eb7f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -749,32 +749,12 @@ void OSystem_Android::setPalette(const byte *colors, uint start, uint num) { if (!_use_mouse_palette) _setCursorPalette(colors, start, num); - byte *palette = _game_texture->palette() + start * 3; - - do { - for (int i = 0; i < 3; ++i) - palette[i] = colors[i]; - - palette += 3; - colors += 4; - } while (--num); + memcpy(_game_texture->palette() + start * 3, colors, num * 3); } void OSystem_Android::grabPalette(byte *colors, uint start, uint num) { ENTER("%p, %u, %u", colors, start, num); - - const byte *palette = _game_texture->palette_const() + start * 3; - - do { - for (int i = 0; i < 3; ++i) - colors[i] = palette[i]; - - // alpha - colors[3] = 0xff; - - palette += 3; - colors += 4; - } while (--num); + memcpy(colors, _game_texture->palette_const() + start * 3, num * 3); } void OSystem_Android::copyRectToScreen(const byte *buf, int pitch, @@ -1051,7 +1031,7 @@ void OSystem_Android::_setCursorPalette(const byte *colors, // Leave alpha untouched to preserve keycolor palette += 4; - colors += 4; + colors += 3; } while (--num); } diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 53dbff333d..b297022775 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -156,7 +156,7 @@ void OSystem_Dreamcast::setPalette(const byte *colors, uint start, uint num) *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 4; + colors += 3; } _screen_dirty = true; } @@ -169,7 +169,7 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 4; + colors += 3; } _enable_cursor_palette = true; } @@ -188,8 +188,7 @@ void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) colors[0] = ((p&0x7c00)>>7)|((p&0x7000)>>12); colors[1] = ((p&0x03e0)>>2)|((p&0x0380)>>7); colors[2] = ((p&0x001f)<<3)|((p&0x001c)>>2); - colors[3] = 0xff; - colors += 4; + colors += 3; } } diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 55e3be6cca..3ad92b4355 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -204,7 +204,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) { } // if (num == 255) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue); - colors += 4; + colors += 3; } } @@ -235,7 +235,7 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) { u16 paletteValue = red | (green << 5) | (blue << 10); _cursorPalette[r] = paletteValue; - colors += 4; + colors += 3; } _disableCursorPalette = false; @@ -266,7 +266,6 @@ void OSystem_DS::grabPalette(unsigned char *colours, uint start, uint num) { *colours++ = (BG_PALETTE[r] & 0x001F) << 3; *colours++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3; *colours++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3; - colours++; } } diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index ee27e4d87c..d67d38932a 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -102,7 +102,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { for (uint i = start; i < start + num; ++i) { _palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); - b += 4; + b += 3; } dirtyFullScreen(); @@ -114,8 +114,7 @@ void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { for (uint i = start; i < start + num; ++i) { Graphics::colorToRGB<Graphics::ColorMasks<565> >(_palette[i], b[0], b[1], b[2]); - b[3] = 0xFF; - b += 4; + b += 3; } } diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index e5ffc7f3bc..2daa41a9f6 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -93,7 +93,7 @@ protected: uint16 *_screenPalette; // Array for palette entries (256 colors max) #ifndef N64_EXTREME_MEMORY_SAVING - uint32 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss + uint8 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss #endif uint16 _cursorPalette[256]; // Palette entries for the cursor diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 1b9c704225..54eab0fd52 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -113,8 +113,8 @@ OSystem_N64::OSystem_N64() { // Clear palette array _screenPalette = (uint16*)memalign(8, 256 * sizeof(uint16)); #ifndef N64_EXTREME_MEMORY_SAVING - _screenExactPalette = (uint32*)memalign(8, 256 * sizeof(uint32)); - memset(_screenExactPalette, 0, 256 * sizeof(uint32)); + _screenExactPalette = (uint8*)memalign(8, 256 * 3); + memset(_screenExactPalette, 0, 256 * 3); #endif memset(_screenPalette, 0, 256 * sizeof(uint16)); memset(_cursorPalette, 0, 256 * sizeof(uint16)); @@ -350,12 +350,13 @@ int16 OSystem_N64::getWidth() { } void OSystem_N64::setPalette(const byte *colors, uint start, uint num) { - for (uint i = 0; i < num; ++i) { - _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); #ifndef N64_EXTREME_MEMORY_SAVING - _screenExactPalette[start + i] = *((uint32*)(colors)); + memcpy(_screenExactPalette + start * 3, colors, num * 3); #endif - colors += 4; + + for (uint i = 0; i < num; ++i) { + _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); + colors += 3; } // If cursor uses the game palette, we need to rebuild the hicolor buffer @@ -413,10 +414,9 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) { *colors++ = ((color & 0x1F) << 3); *colors++ = (((color >> 5) & 0x1F) << 3); *colors++ = (((color >> 10) & 0x1F) << 3); - *colors++ = 0; } #else - memcpy(colors, (uint8*)(_screenExactPalette + start), num * 4); + memcpy(colors, _screenExactPalette + start * 3, num * 3); #endif return; @@ -425,7 +425,7 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) { void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { for (uint i = 0; i < num; ++i) { _cursorPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); - colors += 4; + colors += 3; } _cursorPaletteDisabled = false; diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index c6318e73d0..f869779573 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -408,25 +408,33 @@ void Gs2dScreen::unlockScreen() { SignalSema(g_DmacSema); } -void Gs2dScreen::setPalette(const uint32 *pal, uint8 start, uint16 num) { +void Gs2dScreen::setPalette(const uint8 *pal, uint8 start, uint16 num) { assert(start + num <= 256); WaitSema(g_DmacSema); for (uint16 cnt = 0; cnt < num; cnt++) { uint16 dest = start + cnt; dest = (dest & 0xE7) | ((dest & 0x8) << 1) | ((dest & 0x10) >> 1); // rearrange like the GS expects it - _clut[dest] = pal[cnt] & 0xFFFFFF; + + uint32 color = pal[0] | (pal[1] << 8) | (pal[2] << 16); + _clut[dest] = color; + pal += 3; } _clutChanged = true; SignalSema(g_DmacSema); } -void Gs2dScreen::grabPalette(uint32 *pal, uint8 start, uint16 num) { +void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) { assert(start + num <= 256); for (uint16 cnt = 0; cnt < num; cnt++) { uint16 src = start + cnt; src = (src & 0xE7) | ((src & 0x8) << 1) | ((src & 0x10) >> 1); - pal[cnt] = _clut[src]; + + uint32 color = _clut[src]; + pal[0] = (color >> 0) & 0xFF; + pal[1] = (color >> 8) & 0xFF; + pal[2] = (color >> 16) & 0xFF; + pal += 3; } } diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index 81f47d5f4a..358e717cbe 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -65,9 +65,9 @@ public: void unlockScreen(); void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h); - void setPalette(const uint32 *pal, uint8 start, uint16 num); + void setPalette(const uint8 *pal, uint8 start, uint16 num); void updateScreen(void); - void grabPalette(uint32 *pal, uint8 start, uint16 num); + void grabPalette(uint8 *pal, uint8 start, uint16 num); void grabScreen(Graphics::Surface *surf); //- overlay routines void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index ab7839e18f..77de74eb5b 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -544,11 +544,11 @@ void OSystem_PS2::initSize(uint width, uint height, const Graphics::PixelFormat } void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) { - _screen->setPalette((const uint32*)colors, (uint8)start, (uint16)num); + _screen->setPalette(colors, (uint8)start, (uint16)num); } void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) { - _screen->grabPalette((uint32*)colors, (uint8)start, (uint16)num); + _screen->grabPalette(colors, (uint8)start, (uint16)num); } void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp index 82e2d17d10..76b4a28e4a 100644 --- a/backends/platform/psp/display_client.cpp +++ b/backends/platform/psp/display_client.cpp @@ -110,7 +110,7 @@ void Palette::setPartial(const byte *colors, uint32 start, uint32 num, bool supp for (uint32 i = 0; i < num; ++i) { byte alphaVal = supportsAlpha ? src[3] : 0xFF; *palette = (uint16)_pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal); - src += 4; + src += 3; palette++; } } else if (_pixelFormat.bitsPerPixel == 32) { @@ -120,7 +120,7 @@ void Palette::setPartial(const byte *colors, uint32 start, uint32 num, bool supp for (uint32 i = 0; i < num; ++i) { byte alphaVal = supportsAlpha ? src[3] : 0xFF; *palette = _pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal); - src += 4; + src += 3; palette++; } } @@ -214,7 +214,6 @@ void Palette::getPartial(byte *colors, uint start, uint num) { *colors++ = (byte)r; *colors++ = (byte)g; *colors++ = (byte)b; - *colors++ = (byte)a; palette++; } } else if (_pixelFormat.bitsPerPixel == 32) { @@ -227,7 +226,6 @@ void Palette::getPartial(byte *colors, uint start, uint num) { *colors++ = (byte)r; *colors++ = (byte)g; *colors++ = (byte)b; - *colors++ = (byte)a; palette++; } } diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 4a925a60c9..cb9a8c72e9 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -326,19 +326,16 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texGame.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s +=3) d[start + i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(s[0], s[1], s[2]); - s += 4; - } gfx_tex_flush_palette(&_texGame); s = colors; d = _cursorPalette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) { d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; } if (_cursorPaletteDisabled) { @@ -360,13 +357,11 @@ void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { byte *d = colors; u8 r, g, b; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, d += 3) { Graphics::colorToRGB<Graphics::ColorMasks<565> >(s[start + i], r, g, b); d[0] = r; d[1] = g; d[2] = b; - d[3] = 0xff; - d += 4; } } @@ -391,10 +386,8 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texMouse.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; - } _cursorPaletteDirty = true; } |