aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorJohannes Schickel2011-02-19 21:42:34 +0100
committerJohannes Schickel2011-02-19 21:46:45 +0100
commite21d6e0d1120e917a4a019a4070ec4db5e988b9b (patch)
tree1142828b72ccf17d513c621e108d749f148fd32b /backends/platform
parent32d0e4c15fb33f80db194087850466664a43516a (diff)
parentb26f30b98793c522265a3eeb48fb3b41034663c6 (diff)
downloadscummvm-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/platform')
-rw-r--r--backends/platform/android/android.cpp26
-rw-r--r--backends/platform/dc/display.cpp7
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp5
-rw-r--r--backends/platform/iphone/osys_video.cpp5
-rw-r--r--backends/platform/n64/osys_n64.h2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp18
-rw-r--r--backends/platform/ps2/Gs2dScreen.cpp16
-rw-r--r--backends/platform/ps2/Gs2dScreen.h4
-rw-r--r--backends/platform/ps2/systemps2.cpp4
-rw-r--r--backends/platform/psp/display_client.cpp6
-rw-r--r--backends/platform/wii/osystem_gfx.cpp15
11 files changed, 42 insertions, 66 deletions
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;
}