aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2011-02-19 21:42:34 +0100
committerJohannes Schickel2011-02-19 21:46:45 +0100
commite21d6e0d1120e917a4a019a4070ec4db5e988b9b (patch)
tree1142828b72ccf17d513c621e108d749f148fd32b /engines
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 'engines')
-rw-r--r--engines/agi/graphics.cpp23
-rw-r--r--engines/agi/graphics.h2
-rw-r--r--engines/agos/agos.h4
-rw-r--r--engines/agos/animation.cpp2
-rw-r--r--engines/agos/cursor.cpp6
-rw-r--r--engines/agos/debug.cpp22
-rw-r--r--engines/agos/draw.cpp12
-rw-r--r--engines/agos/gfx.cpp2
-rw-r--r--engines/agos/pn.cpp7
-rw-r--r--engines/agos/script_ff.cpp2
-rw-r--r--engines/agos/script_s1.cpp6
-rw-r--r--engines/agos/vga.cpp29
-rw-r--r--engines/agos/vga_e2.cpp7
-rw-r--r--engines/agos/vga_s1.cpp10
-rw-r--r--engines/agos/window.cpp12
-rw-r--r--engines/cine/pal.cpp8
-rw-r--r--engines/cruise/gfxModule.cpp11
-rw-r--r--engines/cruise/mouse.cpp4
-rw-r--r--engines/draci/screen.cpp20
-rw-r--r--engines/drascula/palette.cpp13
-rw-r--r--engines/gob/util.cpp4
-rw-r--r--engines/gob/video.cpp10
-rw-r--r--engines/gob/video.h1
-rw-r--r--engines/groovie/cursor.cpp9
-rw-r--r--engines/groovie/debug.cpp4
-rw-r--r--engines/groovie/graphics.cpp14
-rw-r--r--engines/groovie/graphics.h2
-rw-r--r--engines/groovie/roq.cpp27
-rw-r--r--engines/groovie/vdx.cpp9
-rw-r--r--engines/hugo/display.cpp24
-rw-r--r--engines/kyra/screen.cpp38
-rw-r--r--engines/kyra/screen_lok.cpp9
-rw-r--r--engines/kyra/screen_lol.cpp3
-rw-r--r--engines/lure/screen.cpp24
-rw-r--r--engines/lure/screen.h2
-rw-r--r--engines/made/screen.cpp11
-rw-r--r--engines/made/screen.h1
-rw-r--r--engines/mohawk/cursors.cpp62
-rw-r--r--engines/mohawk/graphics.cpp20
-rw-r--r--engines/mohawk/riven_cursors.h244
-rw-r--r--engines/mohawk/view.cpp10
-rw-r--r--engines/parallaction/graphics.cpp22
-rw-r--r--engines/parallaction/graphics.h2
-rw-r--r--engines/queen/display.cpp10
-rw-r--r--engines/saga/gfx.cpp48
-rw-r--r--engines/saga/gfx.h2
-rw-r--r--engines/sci/graphics/cursor.cpp2
-rw-r--r--engines/sci/graphics/palette.cpp22
-rw-r--r--engines/sci/graphics/transitions.cpp17
-rw-r--r--engines/scumm/cursor.cpp6
-rw-r--r--engines/scumm/he/cup_player_he.cpp4
-rw-r--r--engines/scumm/he/cup_player_he.h2
-rw-r--r--engines/scumm/he/palette_he.cpp15
-rw-r--r--engines/scumm/palette.cpp6
-rw-r--r--engines/scumm/smush/smush_player.cpp14
-rw-r--r--engines/sky/screen.cpp79
-rw-r--r--engines/sky/screen.h6
-rw-r--r--engines/sword1/animation.cpp2
-rw-r--r--engines/sword1/control.cpp20
-rw-r--r--engines/sword1/screen.cpp16
-rw-r--r--engines/sword1/screen.h4
-rw-r--r--engines/sword2/console.cpp2
-rw-r--r--engines/sword2/function.cpp12
-rw-r--r--engines/sword2/mouse.cpp4
-rw-r--r--engines/sword2/palette.cpp41
-rw-r--r--engines/sword2/protocol.cpp15
-rw-r--r--engines/sword2/render.cpp24
-rw-r--r--engines/sword2/screen.cpp29
-rw-r--r--engines/sword2/screen.h2
-rw-r--r--engines/sword2/sprite.cpp18
-rw-r--r--engines/sword2/sword2.h2
-rw-r--r--engines/teenagent/scene.cpp8
-rw-r--r--engines/teenagent/teenagent.cpp38
-rw-r--r--engines/testbed/graphics.cpp22
-rw-r--r--engines/testbed/graphics.h2
-rw-r--r--engines/tinsel/palette.cpp9
-rw-r--r--engines/toon/toon.cpp29
-rw-r--r--engines/touche/resource.cpp5
-rw-r--r--engines/touche/touche.cpp18
-rw-r--r--engines/touche/touche.h2
-rw-r--r--engines/tucker/locations.cpp8
-rw-r--r--engines/tucker/sequences.cpp33
-rw-r--r--engines/tucker/tucker.cpp14
-rw-r--r--engines/tucker/tucker.h2
84 files changed, 640 insertions, 728 deletions
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 7f8d99cc2f..b1198123ff 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -799,9 +799,8 @@ void GfxMgr::initPalette(const uint8 *p, uint colorCount, uint fromBits, uint to
const uint destMax = (1 << toBits) - 1;
for (uint col = 0; col < colorCount; col++) {
for (uint comp = 0; comp < 3; comp++) { // Convert RGB components
- _palette[col * 4 + comp] = (p[col * 3 + comp] * destMax) / srcMax;
+ _palette[col * 3 + comp] = (p[col * 3 + comp] * destMax) / srcMax;
}
- _palette[col * 4 + 3] = 0; // Set alpha to zero
}
}
@@ -931,8 +930,8 @@ static const byte appleIIgsMouseCursor[] = {
* RGBA-palette for the black and white SCI and Apple IIGS arrow cursors.
*/
static const byte sciMouseCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xFF, 0xFF, 0xFF, 0x00 // White
+ 0x00, 0x00, 0x00, // Black
+ 0xFF, 0xFF, 0xFF // White
};
/**
@@ -961,9 +960,9 @@ static const byte amigaMouseCursor[] = {
* and the Amiga-style busy cursor.
*/
static const byte amigaMouseCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xDE, 0x20, 0x21, 0x00, // Red
- 0xFF, 0xCF, 0xAD, 0x00 // Light red
+ 0x00, 0x00, 0x00, // Black
+ 0xDE, 0x20, 0x21, // Red
+ 0xFF, 0xCF, 0xAD // Light red
};
/**
@@ -994,17 +993,17 @@ static const byte busyAmigaMouseCursor[] = {
void GfxMgr::setCursor(bool amigaStyleCursor, bool busy) {
if (busy) {
- CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3);
CursorMan.replaceCursor(busyAmigaMouseCursor, 13, 16, 7, 8, 0);
return;
}
if (!amigaStyleCursor) {
- CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 3);
CursorMan.replaceCursor(sciMouseCursor, 11, 16, 1, 1, 0);
} else { // amigaStyleCursor
- CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3);
CursorMan.replaceCursor(amigaMouseCursor, 8, 11, 1, 1, 0);
}
}
@@ -1012,12 +1011,12 @@ void GfxMgr::setCursor(bool amigaStyleCursor, bool busy) {
void GfxMgr::setCursorPalette(bool amigaStyleCursor) {
if (!amigaStyleCursor) {
if (_currentCursorPalette != 1) {
- CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 3);
_currentCursorPalette = 1;
}
} else { // amigaStyleCursor
if (_currentCursorPalette != 2) {
- CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3);
_currentCursorPalette = 2;
}
}
diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h
index 18f323d596..60fbea2285 100644
--- a/engines/agi/graphics.h
+++ b/engines/agi/graphics.h
@@ -41,7 +41,7 @@ class GfxMgr {
private:
AgiBase *_vm;
- uint8 _palette[256 * 4];
+ uint8 _palette[256 * 3];
uint8 *_agiScreen;
unsigned char *_screen;
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index a2962cd827..7201dfd9d3 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -529,8 +529,8 @@ protected:
uint16 _PVCount1;
uint16 _GPVCount1;
- uint8 _currentPalette[1024];
- uint8 _displayPalette[1024];
+ uint8 _currentPalette[768];
+ uint8 _displayPalette[768];
byte *_planarBuf;
byte _videoBuf1[32000];
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index 4c01f6b826..d39ca377dc 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -87,7 +87,7 @@ void MoviePlayer::play() {
if (_vm->getBitFlag(41)) {
_vm->fillBackFromFront();
} else {
- uint8 palette[1024];
+ uint8 palette[768];
memset(palette, 0, sizeof(palette));
_vm->clearSurfaces();
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
diff --git a/engines/agos/cursor.cpp b/engines/agos/cursor.cpp
index 5ff2f014a6..cf42fe1f36 100644
--- a/engines/agos/cursor.cpp
+++ b/engines/agos/cursor.cpp
@@ -781,8 +781,8 @@ void AGOSEngine_Simon1::initMouse() {
}
static const byte mouseCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xFF, 0xFF, 0xFF, 0x00, // White
+ 0x00, 0x00, 0x00, // Black
+ 0xFF, 0xFF, 0xFF // White
};
void AGOSEngine::initMouse() {
@@ -792,7 +792,7 @@ void AGOSEngine::initMouse() {
memset(_mouseData, 0xFF, _maxCursorWidth * _maxCursorHeight);
- CursorMan.replaceCursorPalette(mouseCursorPalette, 0, ARRAYSIZE(mouseCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(mouseCursorPalette, 0, ARRAYSIZE(mouseCursorPalette) / 3);
}
void AGOSEngine::drawMousePointer() {
diff --git a/engines/agos/debug.cpp b/engines/agos/debug.cpp
index cb11d65218..d0dc8cc42e 100644
--- a/engines/agos/debug.cpp
+++ b/engines/agos/debug.cpp
@@ -436,7 +436,7 @@ static const byte bmp_hdr[] = {
0x00, 0x01, 0x00, 0x00,
};
-void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const uint32 *palette) {
+void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const byte *palette) {
Common::DumpFile out;
byte my_hdr[sizeof(bmp_hdr)];
int i;
@@ -454,11 +454,11 @@ void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const ui
out.write(my_hdr, sizeof(my_hdr));
- for (i = 0; i != 256; i++, palette++) {
+ for (i = 0; i != 256; i++, palette += 3) {
byte color[4];
- color[0] = (byte)(*palette >> 16);
- color[1] = (byte)(*palette >> 8);
- color[2] = (byte)(*palette);
+ color[0] = palette[2];
+ color[1] = palette[1];
+ color[2] = palette[0];
color[3] = 0;
out.write(color, 4);
}
@@ -565,7 +565,7 @@ void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, uint16 w, ui
}
}
- dumpBMP(filename, w, h, imageBuffer, (const uint32 *)palette);
+ dumpBMP(filename, w, h, imageBuffer, palette);
free(imageBuffer);
}
@@ -594,7 +594,7 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) {
}
if (getGameType() == GType_PN && (getFeatures() & GF_EGA)) {
- memcpy(palptr, _displayPalette, 64);
+ memcpy(palptr, _displayPalette, 3 * 16);
} else if (getGameType() == GType_PN || getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
src = vga1 + READ_BE_UINT16(vga1 + 6) + b * 32;
@@ -603,9 +603,8 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) {
palptr[0] = ((color & 0xf00) >> 8) * 32;
palptr[1] = ((color & 0x0f0) >> 4) * 32;
palptr[2] = ((color & 0x00f) >> 0) * 32;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
src += 2;
} while (--num);
} else {
@@ -615,9 +614,8 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) {
palptr[0] = src[0] << 2;
palptr[1] = src[1] << 2;
palptr[2] = src[2] << 2;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
src += 3;
} while (--num);
}
@@ -627,7 +625,7 @@ void AGOSEngine::dumpVgaBitmaps(uint16 zoneNum) {
uint16 width, height, flags;
uint32 offs, curOffs = 0;
const byte *p2;
- byte pal[1024];
+ byte pal[768];
uint16 zone = (getGameType() == GType_PN) ? 0 : zoneNum;
VgaPointersEntry *vpe = &_vgaBufferPointers[zone];
diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp
index 37abe9324c..317c68d31a 100644
--- a/engines/agos/draw.cpp
+++ b/engines/agos/draw.cpp
@@ -779,8 +779,8 @@ void AGOSEngine::setMoveRect(uint16 x, uint16 y, uint16 width, uint16 height) {
void AGOSEngine::displayScreen() {
if (_fastFadeInFlag == 0 && _paletteFlag == 1) {
_paletteFlag = 0;
- if (memcmp(_displayPalette, _currentPalette, 1024)) {
- memcpy(_currentPalette, _displayPalette, 1024);
+ if (memcmp(_displayPalette, _currentPalette, sizeof(_currentPalette))) {
+ memcpy(_currentPalette, _displayPalette, sizeof(_displayPalette));
_system->getPaletteManager()->setPalette(_displayPalette, 0, 256);
}
}
@@ -860,7 +860,7 @@ void AGOSEngine::fastFadeIn() {
slowFadeIn();
} else {
_paletteFlag = false;
- memcpy(_currentPalette, _displayPalette, 1024);
+ memcpy(_currentPalette, _displayPalette, sizeof(_displayPalette));
_system->getPaletteManager()->setPalette(_displayPalette, 0, _fastFadeInFlag);
_fastFadeInFlag = 0;
}
@@ -879,15 +879,15 @@ void AGOSEngine::slowFadeIn() {
src = _displayPalette;
dst = _currentPalette;
- for (p = _fastFadeInFlag; p !=0; p -= 3) {
+ for (p = _fastFadeInFlag; p != 0; p -= 3) {
if (src[0] >= c)
dst[0] += 4;
if (src[1] >= c)
dst[1] += 4;
if (src[2] >= c)
dst[2] += 4;
- src += 4;
- dst += 4;
+ src += 3;
+ dst += 3;
}
_system->getPaletteManager()->setPalette(_currentPalette, 0, _fastFadeCount);
delay(5);
diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp
index b784e4fcb3..710c9ddd7e 100644
--- a/engines/agos/gfx.cpp
+++ b/engines/agos/gfx.cpp
@@ -1041,7 +1041,7 @@ void AGOSEngine::paletteFadeOut(byte *palPtr, uint num, uint size) {
p[2] -= size;
else
p[2] = 0;
- p += 4;
+ p += 3;
} while (--num);
}
diff --git a/engines/agos/pn.cpp b/engines/agos/pn.cpp
index 7471b73d16..62d65de219 100644
--- a/engines/agos/pn.cpp
+++ b/engines/agos/pn.cpp
@@ -128,12 +128,7 @@ Common::Error AGOSEngine_PN::go() {
if (getFeatures() & GF_EGA) {
// Set EGA Palette
- for (int i = 0; i < 16; i++) {
- _displayPalette[i * 4 + 0] = egaPalette[i * 3 + 0];
- _displayPalette[i * 4 + 1] = egaPalette[i * 3 + 1];
- _displayPalette[i * 4 + 2] = egaPalette[i * 3 + 2];
- _displayPalette[i * 4 + 3] = 0;
- }
+ memcpy(_displayPalette, egaPalette, sizeof(egaPalette));
_paletteFlag = 1;
}
diff --git a/engines/agos/script_ff.cpp b/engines/agos/script_ff.cpp
index 5d640af6ad..3198b1b499 100644
--- a/engines/agos/script_ff.cpp
+++ b/engines/agos/script_ff.cpp
@@ -640,7 +640,7 @@ void AGOSEngine_Feeble::off_restartClock() {
void AGOSEngine_Feeble::off_setColor() {
// 195: set palette color
- uint16 c = getVarOrByte() * 4;
+ uint16 c = getVarOrByte() * 3;
uint8 r = getVarOrByte();
uint8 g = getVarOrByte();
uint8 b = getVarOrByte();
diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp
index 9dd1e3c5ab..05a725cb50 100644
--- a/engines/agos/script_s1.cpp
+++ b/engines/agos/script_s1.cpp
@@ -578,13 +578,13 @@ void AGOSEngine_Simon1::os1_specialFade() {
for (i = 32; i != 0; --i) {
paletteFadeOut(_currentPalette, 32, 8);
- paletteFadeOut(_currentPalette + 4 * 48, 144, 8);
- paletteFadeOut(_currentPalette + 4 * 208, 48, 8);
+ paletteFadeOut(_currentPalette + 3 * 48, 144, 8);
+ paletteFadeOut(_currentPalette + 3 * 208, 48, 8);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
delay(5);
}
- memcpy(_displayPalette, _currentPalette, 1024);
+ memcpy(_displayPalette, _currentPalette, sizeof(_currentPalette));
}
void AGOSEngine::scriptMouseOff() {
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index 8b8b16c9bb..83ee05036c 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -935,8 +935,8 @@ void AGOSEngine::vc22_setPalette() {
if (getGameType() == GType_PN) {
if (b > 128) {
- b-= 128;
- palptr = _displayPalette + 64;
+ b -= 128;
+ palptr = _displayPalette + 3 * 16;
}
} else if (getGameType() == GType_ELVIRA1) {
if (b >= 1000) {
@@ -956,24 +956,22 @@ void AGOSEngine::vc22_setPalette() {
num = 13;
for (int i = 0; i < 19; i++) {
- palptr[(13 + i) * 4 + 0] = extraColors[i * 3 + 0] * 4;
- palptr[(13 + i) * 4 + 1] = extraColors[i * 3 + 1] * 4;
- palptr[(13 + i) * 4 + 2] = extraColors[i * 3 + 2] * 4;
- palptr[(13 + i) * 4 + 3] = 0;
+ palptr[(13 + i) * 3 + 0] = extraColors[i * 3 + 0] * 4;
+ palptr[(13 + i) * 3 + 1] = extraColors[i * 3 + 1] * 4;
+ palptr[(13 + i) * 3 + 2] = extraColors[i * 3 + 2] * 4;
}
}
}
if (getGameType() == GType_ELVIRA2 && getPlatform() == Common::kPlatformAtariST) {
// Custom palette used for icon area
- palptr = &_displayPalette[13 * 64];
+ palptr = &_displayPalette[13 * 3 * 16];
for (uint8 c = 0; c < 16; c++) {
palptr[0] = iconPalette[c * 3 + 0] * 2;
palptr[1] = iconPalette[c * 3 + 1] * 2;
palptr[2] = iconPalette[c * 3 + 2] * 2;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
};
palptr = _displayPalette;
}
@@ -986,9 +984,8 @@ void AGOSEngine::vc22_setPalette() {
palptr[0] = ((color & 0xf00) >> 8) * 32;
palptr[1] = ((color & 0x0f0) >> 4) * 32;
palptr[2] = ((color & 0x00f) >> 0) * 32;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
src += 2;
} while (--num);
@@ -1212,10 +1209,9 @@ void AGOSEngine::vc33_setMouseOn() {
_mouseHideCount = 1;
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
// Set mouse palette
- _displayPalette[65 * 4 + 0] = 48 * 4;
- _displayPalette[65 * 4 + 1] = 48 * 4;
- _displayPalette[65 * 4 + 2] = 40 * 4;
- _displayPalette[65 * 4 + 3] = 0;
+ _displayPalette[65 * 3 + 0] = 48 * 4;
+ _displayPalette[65 * 3 + 1] = 48 * 4;
+ _displayPalette[65 * 3 + 2] = 40 * 4;
_paletteFlag = 1;
}
mouseOn();
@@ -1313,11 +1309,10 @@ void AGOSEngine::vc37_pokePalette() {
if (getGameType() == GType_PN && (getFeatures() & GF_EGA))
return;
- byte *palptr = _displayPalette + offs * 4;
+ byte *palptr = _displayPalette + offs * 3;
palptr[0] = ((color & 0xf00) >> 8) * 32;
palptr[1] = ((color & 0x0f0) >> 4) * 32;
palptr[2] = ((color & 0x00f) >> 0) * 32;
- palptr[3] = 0;
if (!(_videoLockOut & 0x20)) {
_paletteFlag = 1;
diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp
index a01e79ff99..b0431db801 100644
--- a/engines/agos/vga_e2.cpp
+++ b/engines/agos/vga_e2.cpp
@@ -115,7 +115,7 @@ void AGOSEngine::setPaletteSlot(uint16 srcOffs, uint8 dstOffs) {
byte *offs, *palptr, *src;
uint16 num;
- palptr = _displayPalette + dstOffs * 64;
+ palptr = _displayPalette + dstOffs * 3 * 16;
offs = _curVgaFile1 + READ_BE_UINT16(_curVgaFile1 + 6);
src = offs + srcOffs * 32;
num = 16;
@@ -125,9 +125,8 @@ void AGOSEngine::setPaletteSlot(uint16 srcOffs, uint8 dstOffs) {
palptr[0] = ((color & 0xf00) >> 8) * 32;
palptr[1] = ((color & 0x0f0) >> 4) * 32;
palptr[2] = ((color & 0x00f) >> 0) * 32;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
src += 2;
} while (--num);
@@ -371,7 +370,7 @@ void AGOSEngine::fullFade() {
if (dstPal[2] != b)
dstPal[2] += 4;
srcPal += 3;
- dstPal += 4;
+ dstPal += 3;
}
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
delay(5);
diff --git a/engines/agos/vga_s1.cpp b/engines/agos/vga_s1.cpp
index bb13d211fe..a2306d3cdb 100644
--- a/engines/agos/vga_s1.cpp
+++ b/engines/agos/vga_s1.cpp
@@ -112,7 +112,7 @@ void AGOSEngine_Simon1::vc22_setPalette() {
num = a == 0 ? 32 : 16;
palSize = 96;
- palptr = &_displayPalette[(a * 64)];
+ palptr = &_displayPalette[(a * 3 * 16)];
}
offs = _curVgaFile1 + 6;
@@ -122,22 +122,20 @@ void AGOSEngine_Simon1::vc22_setPalette() {
palptr[0] = src[0] * 4;
palptr[1] = src[1] * 4;
palptr[2] = src[2] * 4;
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
src += 3;
} while (--num);
if (getFeatures() & GF_32COLOR) {
// Custom palette used for verb area
- palptr = &_displayPalette[(13 * 64)];
+ palptr = &_displayPalette[(13 * 3 * 16)];
for (uint8 c = 0; c < 32; c++) {
palptr[0] = customPalette[c * 3 + 0];
palptr[1] = customPalette[c * 3 + 1];
palptr[2] = customPalette[c * 3 + 2];
- palptr[3] = 0;
- palptr += 4;
+ palptr += 3;
};
}
diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp
index 54e7928f38..a03c7e178a 100644
--- a/engines/agos/window.cpp
+++ b/engines/agos/window.cpp
@@ -151,13 +151,13 @@ void AGOSEngine::colorWindow(WindowBlock *window) {
if (getGameType() == GType_ELVIRA2 && window->y == 146) {
if (window->fillColor == 1) {
- _displayPalette[33 * 4 + 0] = 48 * 4;
- _displayPalette[33 * 4 + 1] = 40 * 4;
- _displayPalette[33 * 4 + 2] = 32 * 4;
+ _displayPalette[33 * 3 + 0] = 48 * 4;
+ _displayPalette[33 * 3 + 1] = 40 * 4;
+ _displayPalette[33 * 3 + 2] = 32 * 4;
} else {
- _displayPalette[33 * 4 + 0] = 56 * 4;
- _displayPalette[33 * 4 + 1] = 56 * 4;
- _displayPalette[33 * 4 + 2] = 40 * 4;
+ _displayPalette[33 * 3 + 0] = 56 * 4;
+ _displayPalette[33 * 3 + 1] = 56 * 4;
+ _displayPalette[33 * 3 + 2] = 40 * 4;
}
y--;
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index a074bd3f09..3c8ffc295b 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -185,16 +185,16 @@ const Graphics::PixelFormat &Palette::colorFormat() const {
}
void Palette::setGlobalOSystemPalette() const {
- byte buf[256 * 4]; // Allocate space for the largest possible palette
+ byte buf[256 * 3]; // Allocate space for the largest possible palette
// The color format used by OSystem's setPalette-function:
- save(buf, sizeof(buf), Graphics::PixelFormat(4, 8, 8, 8, 0, 0, 8, 16, 0), CINE_LITTLE_ENDIAN);
+ save(buf, sizeof(buf), Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), CINE_LITTLE_ENDIAN);
if (g_cine->getPlatform() == Common::kPlatformAmiga && colorCount() == 16) {
// The Amiga version of Future Wars does use the upper 16 colors for a darkened
// game palette to allow transparent dialog boxes. To support that in our code
// we do calculate that palette over here and append it to the screen palette.
- for (uint i = 0; i < 16 * 4; ++i)
- buf[16 * 4 + i] = buf[i] >> 1;
+ for (uint i = 0; i < 16 * 3; ++i)
+ buf[16 * 3 + i] = buf[i] >> 1;
g_system->getPaletteManager()->setPalette(buf, 0, colorCount() * 2);
} else {
diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp
index 00e44465f8..59561de8dc 100644
--- a/engines/cruise/gfxModule.cpp
+++ b/engines/cruise/gfxModule.cpp
@@ -273,16 +273,15 @@ static void mergeClipRects() {
}
void gfxModuleData_updatePalette() {
- byte paletteRGBA[256 * 4];
+ byte paletteRGBA[256 * 3];
if (palDirtyMax != -1) {
for (int i = palDirtyMin; i <= palDirtyMax; i++) {
- paletteRGBA[i * 4 + 0] = lpalette[i].R;
- paletteRGBA[i * 4 + 1] = lpalette[i].G;
- paletteRGBA[i * 4 + 2] = lpalette[i].B;
- paletteRGBA[i * 4 + 3] = 0xFF;
+ paletteRGBA[i * 3 + 0] = lpalette[i].R;
+ paletteRGBA[i * 3 + 1] = lpalette[i].G;
+ paletteRGBA[i * 3 + 2] = lpalette[i].B;
}
- g_system->getPaletteManager()->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1);
+ g_system->getPaletteManager()->setPalette(paletteRGBA + palDirtyMin*3, palDirtyMin, palDirtyMax - palDirtyMin + 1);
palDirtyMin = 256;
palDirtyMax = -1;
}
diff --git a/engines/cruise/mouse.cpp b/engines/cruise/mouse.cpp
index 521ba3a54e..24309030da 100644
--- a/engines/cruise/mouse.cpp
+++ b/engines/cruise/mouse.cpp
@@ -52,8 +52,8 @@ static const MouseCursor mouseCursors[] = {
CursorType currentCursor = CURSOR_NOMOUSE;
static const byte cursorPalette[] = {
- 0, 0, 0, 0xff,
- 0xff, 0xff, 0xff, 0xff
+ 0, 0, 0,
+ 0xff, 0xff, 0xff
};
void changeCursor(CursorType eType) {
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index bb7a093d8f..dbe3fd98b8 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -36,7 +36,7 @@ namespace Draci {
Screen::Screen(DraciEngine *vm) : _vm(vm) {
_surface = new Surface(kScreenWidth, kScreenHeight);
- _palette = new byte[4 * kNumColours];
+ _palette = new byte[3 * kNumColours];
_blackPalette = new byte[3 * kNumColours];
for (int i = 0; i < 3 * kNumColours; ++i) {
_blackPalette[i] = 0;
@@ -63,15 +63,14 @@ void Screen::setPalette(const byte *data, uint16 start, uint16 num) {
// Copy the palette
for (uint16 i = start; i < start + num; ++i) {
- _palette[i * 4] = pal.readByte();
- _palette[i * 4 + 1] = pal.readByte();
- _palette[i * 4 + 2] = pal.readByte();
- _palette[i * 4 + 3] = 0;
+ _palette[i * 3] = pal.readByte();
+ _palette[i * 3 + 1] = pal.readByte();
+ _palette[i * 3 + 2] = pal.readByte();
}
// Shift the palette two bits to the left to make it brighter. The
// original game only uses 6-bit colors 0..63.
- for (int i = start * 4; i < (start + num) * 4; ++i) {
+ for (int i = start * 3; i < (start + num) * 3; ++i) {
_palette[i] <<= 2;
}
@@ -86,14 +85,13 @@ void Screen::interpolatePalettes(const byte *first, const byte *second, uint16 s
// Interpolate the palettes
for (uint16 i = start; i < start + num; ++i) {
- _palette[i * 4] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
- _palette[i * 4 + 1] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
- _palette[i * 4 + 2] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
- _palette[i * 4 + 3] = 0;
+ _palette[i * 3] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
+ _palette[i * 3 + 1] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
+ _palette[i * 3 + 2] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number);
}
// Shift the palette two bits to the left to make it brighter
- for (int i = start * 4; i < (start + num) * 4; ++i) {
+ for (int i = start * 3; i < (start + num) * 3; ++i) {
_palette[i] <<= 2;
}
diff --git a/engines/drascula/palette.cpp b/engines/drascula/palette.cpp
index 67597efd0c..b521c0313b 100644
--- a/engines/drascula/palette.cpp
+++ b/engines/drascula/palette.cpp
@@ -65,15 +65,12 @@ void DrasculaEngine::black() {
}
void DrasculaEngine::setPalette(byte *PalBuf) {
- byte pal[256 * 4];
- int i;
-
- for (i = 0; i < 256; i++) {
- pal[i * 4 + 0] = PalBuf[i * 3 + 0] * 4;
- pal[i * 4 + 1] = PalBuf[i * 3 + 1] * 4;
- pal[i * 4 + 2] = PalBuf[i * 3 + 2] * 4;
- pal[i * 4 + 3] = 0;
+ byte pal[256 * 3];
+
+ for (int i = 0; i < 3 * 256; ++i) {
+ pal[i] = PalBuf[i] * 4;
}
+
_system->getPaletteManager()->setPalette(pal, 0, 256);
_system->updateScreen();
}
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index f0b475f65b..4d51b3d61f 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -318,13 +318,13 @@ void Util::forceMouseUp(bool onlyWhenSynced) {
void Util::clearPalette() {
int16 i;
- byte colors[1024];
+ byte colors[768];
_vm->validateVideoMode(_vm->_global->_videoMode);
if (_vm->_global->_setAllPalette) {
if (_vm->getPixelFormat().bytesPerPixel == 1) {
- memset(colors, 0, 1024);
+ memset(colors, 0, sizeof(colors));
g_system->getPaletteManager()->setPalette(colors, 0, 256);
}
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index 4a32489138..444ff8ed9e 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -345,7 +345,7 @@ void Video::drawPackedSprite(const char *path, Surface &dest, int width) {
void Video::setPalElem(int16 index, char red, char green, char blue,
int16 unused, int16 vidMode) {
- byte pal[4];
+ byte pal[3];
_vm->validateVideoMode(vidMode);
@@ -359,14 +359,14 @@ void Video::setPalElem(int16 index, char red, char green, char blue,
}
void Video::setPalette(PalDesc *palDesc) {
- byte pal[1024];
+ byte pal[768];
int16 numcolors;
_vm->validateVideoMode(_vm->_global->_videoMode);
numcolors = _vm->_global->_setAllPalette ? 256 : 16;
for (int i = 0; i < numcolors; i++)
- setPalColor(pal + i * 4, palDesc->vgaPal[i]);
+ setPalColor(pal + i * 3, palDesc->vgaPal[i]);
if (_vm->getPixelFormat().bytesPerPixel == 1)
g_system->getPaletteManager()->setPalette(pal, 0, numcolors);
@@ -374,14 +374,14 @@ void Video::setPalette(PalDesc *palDesc) {
void Video::setFullPalette(PalDesc *palDesc) {
if (_vm->_global->_setAllPalette) {
- byte pal[1024];
+ byte pal[768];
Color *colors = palDesc->vgaPal;
for (int i = 0; i < 256; i++) {
_vm->_global->_redPalette[i] = colors[i].red;
_vm->_global->_greenPalette[i] = colors[i].green;
_vm->_global->_bluePalette[i] = colors[i].blue;
- setPalColor(pal + i * 4, colors[i]);
+ setPalColor(pal + i * 3, colors[i]);
}
if (_vm->getPixelFormat().bytesPerPixel == 1)
diff --git a/engines/gob/video.h b/engines/gob/video.h
index 8828b666b3..69cdfe49ed 100644
--- a/engines/gob/video.h
+++ b/engines/gob/video.h
@@ -125,7 +125,6 @@ public:
pal[0] = red << 2;
pal[1] = green << 2;
pal[2] = blue << 2;
- pal[3] = 0;
}
void setPalColor(byte *pal, Color &color) {
setPalColor(pal, color.red, color.green, color.blue);
diff --git a/engines/groovie/cursor.cpp b/engines/groovie/cursor.cpp
index 2d0a2df245..6a87af8daf 100644
--- a/engines/groovie/cursor.cpp
+++ b/engines/groovie/cursor.cpp
@@ -226,13 +226,8 @@ byte *GrvCursorMan_t7g::loadImage(Common::SeekableReadStream &file) {
}
byte *GrvCursorMan_t7g::loadPalette(Common::SeekableReadStream &file) {
- byte *palette = new byte[4 * 32];
- for (uint8 colournum = 0; colournum < 32; colournum++) {
- palette[colournum * 4 + 0] = file.readByte();
- palette[colournum * 4 + 1] = file.readByte();
- palette[colournum * 4 + 2] = file.readByte();
- palette[colournum * 4 + 3] = 0;
- }
+ byte *palette = new byte[3 * 32];
+ file.read(palette, 3 * 32);
return palette;
}
diff --git a/engines/groovie/debug.cpp b/engines/groovie/debug.cpp
index 92afbb0115..bd4b671e11 100644
--- a/engines/groovie/debug.cpp
+++ b/engines/groovie/debug.cpp
@@ -137,11 +137,11 @@ bool Debugger::cmd_playref(int argc, const char **argv) {
bool Debugger::cmd_dumppal(int argc, const char **argv) {
uint16 i;
- byte palettedump[256 * 4];
+ byte palettedump[256 * 3];
_vm->_system->getPaletteManager()->grabPalette(palettedump, 0, 256);
for (i = 0; i < 256; i++) {
- DebugPrintf("%3d: %3d,%3d,%3d,%3d\n", i, palettedump[(i * 4)], palettedump[(i * 4) + 1], palettedump[(i * 4) + 2], palettedump[(i * 4) + 3]);
+ DebugPrintf("%3d: %3d,%3d,%3d\n", i, palettedump[(i * 3)], palettedump[(i * 3) + 1], palettedump[(i * 3) + 2]);
}
return true;
}
diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp
index 9d6da81fb6..3ceeeb6018 100644
--- a/engines/groovie/graphics.cpp
+++ b/engines/groovie/graphics.cpp
@@ -106,11 +106,7 @@ void GraphicsMan::fadeIn(byte *pal) {
_fadeStartTime = _vm->_system->getMillis();
// Copy the target palette
- for (int i = 0; i < 256; i++) {
- _paletteFull[(i * 4) + 0] = pal[(i * 3) + 0];
- _paletteFull[(i * 4) + 1] = pal[(i * 3) + 1];
- _paletteFull[(i * 4) + 2] = pal[(i * 3) + 2];
- }
+ memcpy(_paletteFull, pal, 3 * 256);
// Set the current fading
_fading = 1;
@@ -151,11 +147,11 @@ void GraphicsMan::applyFading(int step) {
}
// Calculate the new palette
- byte newpal[256 * 4];
+ byte newpal[256 * 3];
for (int i = 0; i < 256; i++) {
- newpal[(i * 4) + 0] = (_paletteFull[(i * 4) + 0] * factorR) / 256;
- newpal[(i * 4) + 1] = (_paletteFull[(i * 4) + 1] * factorG) / 256;
- newpal[(i * 4) + 2] = (_paletteFull[(i * 4) + 2] * factorB) / 256;
+ newpal[(i * 3) + 0] = (_paletteFull[(i * 3) + 0] * factorR) / 256;
+ newpal[(i * 3) + 1] = (_paletteFull[(i * 3) + 1] * factorG) / 256;
+ newpal[(i * 3) + 2] = (_paletteFull[(i * 3) + 2] * factorB) / 256;
}
// Set the screen palette
diff --git a/engines/groovie/graphics.h b/engines/groovie/graphics.h
index c9bade9538..a405822c9c 100644
--- a/engines/groovie/graphics.h
+++ b/engines/groovie/graphics.h
@@ -58,7 +58,7 @@ private:
// Palette fading
void applyFading(int step);
int _fading;
- byte _paletteFull[256 * 4];
+ byte _paletteFull[256 * 3];
uint32 _fadeStartTime;
};
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 540465050d..4d7157c797 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -53,46 +53,37 @@ ROQPlayer::ROQPlayer(GroovieEngine *vm) :
_prevBuf = new Graphics::Surface();
if (_vm->_mode8bit) {
- byte pal[256 * 4];
+ byte pal[256 * 3];
#ifdef DITHER
- byte pal3[256 * 3];
// Initialize to a black palette
- for (int i = 0; i < 256 * 3; i++) {
- pal3[i] = 0;
- }
+ memset(pal, 0, 256 * 3);
// Build a basic color palette
for (int r = 0; r < 4; r++) {
for (int g = 0; g < 4; g++) {
for (int b = 0; b < 4; b++) {
byte col = (r << 4) | (g << 2) | (b << 0);
- pal3[3 * col + 0] = r << 6;
- pal3[3 * col + 1] = g << 6;
- pal3[3 * col + 2] = b << 6;
+ pal[3 * col + 0] = r << 6;
+ pal[3 * col + 1] = g << 6;
+ pal[3 * col + 2] = b << 6;
}
}
}
// Initialize the dithering algorithm
_paletteLookup = new Graphics::PaletteLUT(8, Graphics::PaletteLUT::kPaletteYUV);
- _paletteLookup->setPalette(pal3, Graphics::PaletteLUT::kPaletteRGB, 8);
+ _paletteLookup->setPalette(pal, Graphics::PaletteLUT::kPaletteRGB, 8);
for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) {
debug("Groovie::ROQ: Building palette table: %02d/63", i);
_paletteLookup->buildNext();
}
- // Prepare the palette to show
- for (int i = 0; i < 256; i++) {
- pal[(i * 4) + 0] = pal3[(i * 3) + 0];
- pal[(i * 4) + 1] = pal3[(i * 3) + 1];
- pal[(i * 4) + 2] = pal3[(i * 3) + 2];
- }
#else // !DITHER
// Set a grayscale palette
for (int i = 0; i < 256; i++) {
- pal[(i * 4) + 0] = i;
- pal[(i * 4) + 1] = i;
- pal[(i * 4) + 2] = i;
+ pal[(i * 3) + 0] = i;
+ pal[(i * 3) + 1] = i;
+ pal[(i * 3) + 2] = i;
}
#endif // DITHER
diff --git a/engines/groovie/vdx.cpp b/engines/groovie/vdx.cpp
index 10177dad34..1b4a2b7800 100644
--- a/engines/groovie/vdx.cpp
+++ b/engines/groovie/vdx.cpp
@@ -555,15 +555,8 @@ void VDXPlayer::setPalette(uint8 *palette) {
if (_flagSkipPalette)
return;
- uint8 palBuf[4 * 256];
debugC(7, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Setting palette");
- for (int i = 0; i < 256; i++) {
- palBuf[(i * 4) + 0] = palette[(i * 3) + 0];
- palBuf[(i * 4) + 1] = palette[(i * 3) + 1];
- palBuf[(i * 4) + 2] = palette[(i * 3) + 2];
- palBuf[(i * 4) + 3] = 0;
- }
- _syst->getPaletteManager()->setPalette(palBuf, 0, 256);
+ _syst->getPaletteManager()->setPalette(palette, 0, 256);
}
} // End of Groovie namespace
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index f8fa90330d..a2962ff354 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -131,10 +131,24 @@ viewdib_t &Screen::getGUIBuffer() {
void Screen::createPal() {
debugC(1, kDebugDisplay, "createPal");
- g_system->getPaletteManager()->setPalette(_mainPalette, 0, _paletteSize / 4);
+ byte pal[3 * 256];
+ for (uint i = 0; i < _paletteSize; ++i) {
+ pal[3 * i + 0] = _mainPalette[4 * i + 0];
+ pal[3 * i + 1] = _mainPalette[4 * i + 1];
+ pal[3 * i + 2] = _mainPalette[4 * i + 2];
+ }
+
+ g_system->getPaletteManager()->setPalette(pal, 0, _paletteSize / 4);
}
void Screen::setCursorPal() {
+ byte pal[3 * 256];
+ for (uint i = 0; i < _paletteSize; ++i) {
+ pal[3 * i + 0] = _curPalette[4 * i + 0];
+ pal[3 * i + 1] = _curPalette[4 * i + 1];
+ pal[3 * i + 2] = _curPalette[4 * i + 2];
+ }
+
CursorMan.replaceCursorPalette(_curPalette, 0, _paletteSize / 4);
}
@@ -191,12 +205,12 @@ void Screen::displayRect(const int16 x, const int16 y, const int16 dx, const int
void Screen::remapPal(const uint16 oldIndex, const uint16 newIndex) {
debugC(1, kDebugDisplay, "Remap_pal(%d, %d)", oldIndex, newIndex);
- byte pal[4];
+ byte pal[3];
pal[0] = _curPalette[4 * oldIndex + 0] = _mainPalette[newIndex * 4 + 0];
pal[1] = _curPalette[4 * oldIndex + 1] = _mainPalette[newIndex * 4 + 1];
pal[2] = _curPalette[4 * oldIndex + 2] = _mainPalette[newIndex * 4 + 2];
- pal[3] = _curPalette[4 * oldIndex + 3] = _mainPalette[newIndex * 4 + 3];
+ //pal[3] = _curPalette[4 * oldIndex + 3] = _mainPalette[newIndex * 4 + 3];
g_system->getPaletteManager()->setPalette(pal, oldIndex, 1);
}
@@ -217,7 +231,7 @@ void Screen::savePal(Common::WriteStream *f) const {
void Screen::restorePal(Common::ReadStream *f) {
debugC(1, kDebugDisplay, "restorePal()");
- byte pal[4];
+ byte pal[3];
for (int i = 0; i < _paletteSize; i++)
_curPalette[i] = f->readByte();
@@ -226,7 +240,7 @@ void Screen::restorePal(Common::ReadStream *f) {
pal[0] = _curPalette[i * 4 + 0];
pal[1] = _curPalette[i * 4 + 1];
pal[2] = _curPalette[i * 4 + 2];
- pal[3] = _curPalette[i * 4 + 3];
+ //pal[3] = _curPalette[i * 4 + 3];
g_system->getPaletteManager()->setPalette(pal, i, 1);
}
}
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index b8eac058fd..3eea7aab14 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -137,16 +137,15 @@ bool Screen::init() {
// We setup the PC98 text mode palette at [16, 24], since that will be used
// for KANJI characters in Lands of Lore.
if (_use16ColorMode && _vm->gameFlags().platform == Common::kPlatformPC98) {
- uint8 palette[8 * 4];
+ uint8 palette[8 * 3];
for (int i = 0; i < 8; ++i) {
- palette[i * 4 + 0] = ((i >> 1) & 1) * 0xFF;
- palette[i * 4 + 1] = ((i >> 2) & 1) * 0xFF;
- palette[i * 4 + 2] = ((i >> 0) & 1) * 0xFF;
- palette[i * 4 + 3] = 0;
-
- _system->getPaletteManager()->setPalette(palette, 16, 8);
+ palette[i * 3 + 0] = ((i >> 1) & 1) * 0xFF;
+ palette[i * 3 + 1] = ((i >> 2) & 1) * 0xFF;
+ palette[i * 3 + 2] = ((i >> 0) & 1) * 0xFF;
}
+
+ _system->getPaletteManager()->setPalette(palette, 16, 8);
}
_curDim = 0;
@@ -180,7 +179,7 @@ bool Screen::enableScreenDebug(bool enable) {
}
void Screen::setResolution() {
- byte palette[4*256];
+ byte palette[3*256];
_system->getPaletteManager()->grabPalette(palette, 0, 256);
int width = 320, height = 200;
@@ -700,14 +699,13 @@ void Screen::getRealPalette(int num, uint8 *dst) {
}
void Screen::setScreenPalette(const Palette &pal) {
- uint8 screenPal[256 * 4];
+ uint8 screenPal[256 * 3];
_screenPalette->copy(pal);
for (int i = 0; i < pal.getNumColors(); ++i) {
- screenPal[4 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F;
- screenPal[4 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F;
- screenPal[4 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F;
- screenPal[4 * i + 3] = 0;
+ screenPal[3 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F;
+ screenPal[3 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F;
+ screenPal[3 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F;
}
_paletteChanged = true;
@@ -729,19 +727,19 @@ void Screen::setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b)
if (!_isAmiga)
return;
- uint8 screenPal[32 * 4];
+ uint8 screenPal[32 * 3];
assert(32 <= pal.getNumColors());
for (int i = 0; i < pal.getNumColors(); ++i) {
if (i != 0x10) {
- screenPal[4 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F;
- screenPal[4 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F;
- screenPal[4 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F;
+ screenPal[3 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F;
+ screenPal[3 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F;
+ screenPal[3 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F;
} else {
- screenPal[4 * i + 0] = (r * 0xFF) / 0x3F;
- screenPal[4 * i + 1] = (g * 0xFF) / 0x3F;
- screenPal[4 * i + 2] = (b * 0xFF) / 0x3F;
+ screenPal[3 * i + 0] = (r * 0xFF) / 0x3F;
+ screenPal[3 * i + 1] = (g * 0xFF) / 0x3F;
+ screenPal[3 * i + 2] = (b * 0xFF) / 0x3F;
}
screenPal[4 * i + 3] = 0;
}
diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp
index da96ea6821..227349754f 100644
--- a/engines/kyra/screen_lok.cpp
+++ b/engines/kyra/screen_lok.cpp
@@ -447,12 +447,11 @@ void Screen_LoK_16::mergeOverlay(int x, int y, int w, int h) {
}
void Screen_LoK_16::set16ColorPalette(const uint8 *pal) {
- uint8 palette[16 * 4];
+ uint8 palette[16 * 3];
for (int i = 0; i < 16; ++i) {
- palette[i * 4 + 0] = (pal[i * 3 + 0] * 0xFF) / 0x0F;
- palette[i * 4 + 1] = (pal[i * 3 + 1] * 0xFF) / 0x0F;
- palette[i * 4 + 2] = (pal[i * 3 + 2] * 0xFF) / 0x0F;
- palette[i * 4 + 3] = 0;
+ palette[i * 3 + 0] = (pal[i * 3 + 0] * 0xFF) / 0x0F;
+ palette[i * 3 + 1] = (pal[i * 3 + 1] * 0xFF) / 0x0F;
+ palette[i * 3 + 2] = (pal[i * 3 + 2] * 0xFF) / 0x0F;
}
_system->getPaletteManager()->setPalette(palette, 0, 16);
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index e85ea13371..ff35facbb5 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -795,11 +795,10 @@ void Screen_LoL::copyColor(int dstColorIndex, int srcColorIndex) {
uint8 *d = _screenPalette->getData() + dstColorIndex * 3;
memcpy(d, s, 3);
- uint8 ci[4];
+ uint8 ci[3];
ci[0] = (d[0] << 2) | (d[0] & 3);
ci[1] = (d[1] << 2) | (d[1] & 3);
ci[2] = (d[2] << 2) | (d[2] & 3);
- ci[3] = 0;
_system->getPaletteManager()->setPalette(ci, dstColorIndex, 1);
}
diff --git a/engines/lure/screen.cpp b/engines/lure/screen.cpp
index d00d969770..282e382bba 100644
--- a/engines/lure/screen.cpp
+++ b/engines/lure/screen.cpp
@@ -52,12 +52,26 @@ Screen::~Screen() {
delete _palette;
}
+void Screen::setSystemPalette(Palette *p, uint16 start, uint16 num) {
+ byte pal[3 * 256];
+ assert(start + num <= 256);
+
+ const byte *rawData = p->data();
+ for (uint i = 0; i < num; ++i) {
+ pal[i * 3 + 0] = rawData[(i + start) * 4 + 0];
+ pal[i * 3 + 1] = rawData[(i + start) * 4 + 1];
+ pal[i * 3 + 2] = rawData[(i + start) * 4 + 2];
+ }
+
+ _system.getPaletteManager()->setPalette(pal, start, num);
+}
+
// setPaletteEmpty
// Defaults the palette to an empty set
void Screen::setPaletteEmpty(int numEntries) {
Palette emptyPalette(numEntries, NULL, RGB64);
- _system.getPaletteManager()->setPalette(emptyPalette.data(), 0, numEntries);
+ setSystemPalette(&emptyPalette, 0, numEntries);
_palette->copyFrom(&emptyPalette);
/*
delete _palette;
@@ -73,7 +87,7 @@ void Screen::setPaletteEmpty(int numEntries) {
void Screen::setPalette(Palette *p) {
_palette->copyFrom(p);
- _system.getPaletteManager()->setPalette(_palette->data(), 0, GAME_COLOURS);
+ setSystemPalette(_palette, 0, GAME_COLOURS);
_system.updateScreen();
}
@@ -82,7 +96,7 @@ void Screen::setPalette(Palette *p) {
void Screen::setPalette(Palette *p, uint16 start, uint16 num) {
_palette->palette()->copyFrom(p->palette(), start * 4, start * 4, num * 4);
- _system.getPaletteManager()->setPalette(_palette->data(), start, num);
+ setSystemPalette(_palette, start, num);
_system.updateScreen();
}
@@ -114,7 +128,7 @@ void Screen::paletteFadeIn(Palette *p) {
}
if (changed) {
- _system.getPaletteManager()->setPalette(_palette->data(), 0, p->numEntries());
+ setSystemPalette(_palette, 0, p->numEntries());
_system.updateScreen();
_system.delayMillis(20);
while (events.pollEvent())
@@ -147,7 +161,7 @@ void Screen::paletteFadeOut(int numEntries) {
}
if (changed) {
- _system.getPaletteManager()->setPalette(_palette->data(), 0, numEntries);
+ setSystemPalette(_palette, 0, numEntries);
_system.updateScreen();
_system.delayMillis(20);
while (events.pollEvent())
diff --git a/engines/lure/screen.h b/engines/lure/screen.h
index 373683df2b..94bbab932e 100644
--- a/engines/lure/screen.h
+++ b/engines/lure/screen.h
@@ -42,6 +42,8 @@ private:
Disk &_disk;
Surface *_screen;
Palette *_palette;
+
+ void setSystemPalette(Palette *p, uint16 start, uint16 num);
public:
Screen(OSystem &system);
~Screen();
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index 7a4c12eefb..2649e2bd37 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -32,7 +32,6 @@ namespace Made {
Screen::Screen(MadeEngine *vm) : _vm(vm) {
- _screenPalette = new byte[256 * 4];
_palette = new byte[768];
_newPalette = new byte[768];
@@ -95,7 +94,6 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) {
Screen::~Screen() {
- delete[] _screenPalette;
delete[] _palette;
delete[] _newPalette;
@@ -220,14 +218,7 @@ void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 f
}
void Screen::setRGBPalette(byte *palRGB, int start, int count) {
- for (int i = 0; i < count; i++) {
- _screenPalette[i * 4 + 0] = palRGB[i * 3 + 0];
- _screenPalette[i * 4 + 1] = palRGB[i * 3 + 1];
- _screenPalette[i * 4 + 2] = palRGB[i * 3 + 2];
- _screenPalette[i * 4 + 3] = 0;
- }
-
- _vm->_system->getPaletteManager()->setPalette(_screenPalette, start, count);
+ _vm->_system->getPaletteManager()->setPalette(palRGB, start, count);
}
uint16 Screen::updateChannel(uint16 channelIndex) {
diff --git a/engines/made/screen.h b/engines/made/screen.h
index c91704ef79..e9292240a1 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -200,7 +200,6 @@ protected:
bool _screenLock;
bool _paletteLock;
- byte *_screenPalette;
byte *_palette, *_newPalette;
int _paletteColorCount, _oldPaletteColorCount;
bool _paletteInitialized, _needPalette;
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 45f3329f13..08f863544a 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -38,8 +38,8 @@
namespace Mohawk {
static const byte s_bwPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xFF, 0xFF, 0xFF, 0x00 // White
+ 0x00, 0x00, 0x00, // Black
+ 0xFF, 0xFF, 0xFF // White
};
void CursorManager::showCursor() {
@@ -153,7 +153,16 @@ void MystCursorManager::setCursor(uint16 id) {
// Myst ME stores some cursors as 24bpp images instead of 8bpp
if (surface->bytesPerPixel == 1) {
CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0);
- CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
+
+ const byte *srcPal = mhkSurface->getPalette();
+ byte pal[3*256];
+ for (uint i = 0; i < 256; ++i) {
+ pal[i * 3 + 0] = srcPal[i * 4 + 0];
+ pal[i * 3 + 1] = srcPal[i * 4 + 1];
+ pal[i * 3 + 2] = srcPal[i * 4 + 2];
+ }
+
+ CursorMan.replaceCursorPalette(pal, 0, 256);
} else {
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), 1, &pixelFormat);
@@ -174,92 +183,92 @@ void RivenCursorManager::setCursor(uint16 id) {
case 1002:
// Zip Mode
CursorMan.replaceCursor(s_zipModeCursor, 16, 16, 8, 8, 0);
- CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 3);
break;
case 2003:
// Hand Over Object
CursorMan.replaceCursor(s_objectHandCursor, 16, 16, 8, 8, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 2004:
// Grabbing/Using Object
CursorMan.replaceCursor(s_grabbingHandCursor, 13, 13, 6, 6, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3000:
// Standard Hand
CursorMan.replaceCursor(s_standardHandCursor, 15, 16, 6, 0, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3001:
// Pointing Left
CursorMan.replaceCursor(s_pointingLeftCursor, 15, 13, 0, 3, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3002:
// Pointing Right
CursorMan.replaceCursor(s_pointingRightCursor, 15, 13, 14, 3, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3003:
// Pointing Down (Palm Up)
CursorMan.replaceCursor(s_pointingDownCursorPalmUp, 13, 16, 3, 15, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3004:
// Pointing Up (Palm Up)
CursorMan.replaceCursor(s_pointingUpCursorPalmUp, 13, 16, 3, 0, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3005:
// Pointing Left (Curved)
CursorMan.replaceCursor(s_pointingLeftCursorBent, 15, 13, 0, 5, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3006:
// Pointing Right (Curved)
CursorMan.replaceCursor(s_pointingRightCursorBent, 15, 13, 14, 5, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 3007:
// Pointing Down (Palm Down)
CursorMan.replaceCursor(s_pointingDownCursorPalmDown, 15, 16, 7, 15, 0);
- CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3);
break;
case 4001:
// Red Marble
CursorMan.replaceCursor(s_redMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 3);
break;
case 4002:
// Orange Marble
CursorMan.replaceCursor(s_orangeMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 3);
break;
case 4003:
// Yellow Marble
CursorMan.replaceCursor(s_yellowMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 3);
break;
case 4004:
// Green Marble
CursorMan.replaceCursor(s_greenMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 3);
break;
case 4005:
// Blue Marble
CursorMan.replaceCursor(s_blueMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 3);
break;
case 4006:
// Violet Marble
CursorMan.replaceCursor(s_violetMarbleCursor, 12, 12, 5, 5, 0);
- CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 3);
break;
case 5000:
// Pellet
CursorMan.replaceCursor(s_pelletCursor, 8, 8, 4, 4, 0);
- CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 4);
+ CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 3);
break;
case 9000:
// Hide Cursor
@@ -302,7 +311,16 @@ void NECursorManager::setCursor(uint16 id) {
if (cursors[i].id == id) {
Common::NECursor *cursor = cursors[i].cursors[0];
CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), 0);
- CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
+
+ const byte *srcPal = cursor->getPalette();
+ byte pal[3 * 256];
+ for (uint j = 0; j < 256; ++j) {
+ pal[j * 3 + 0] = srcPal[j * 4 + 0];
+ pal[j * 3 + 1] = srcPal[j * 4 + 1];
+ pal[j * 3 + 2] = srcPal[j * 4 + 2];
+ }
+
+ CursorMan.replaceCursorPalette(pal, 0, 256);
return;
}
}
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index be2fe01c4d..78916be85c 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -136,13 +136,13 @@ void GraphicsManager::setPalette(uint16 id) {
uint16 colorStart = tpalStream->readUint16BE();
uint16 colorCount = tpalStream->readUint16BE();
- byte *palette = new byte[colorCount * 4];
+ byte *palette = new byte[colorCount * 3];
for (uint16 i = 0; i < colorCount; i++) {
- palette[i * 4] = tpalStream->readByte();
- palette[i * 4 + 1] = tpalStream->readByte();
- palette[i * 4 + 2] = tpalStream->readByte();
- palette[i * 4 + 3] = tpalStream->readByte();
+ palette[i * 3 + 0] = tpalStream->readByte();
+ palette[i * 3 + 1] = tpalStream->readByte();
+ palette[i * 3 + 2] = tpalStream->readByte();
+ tpalStream->readByte();
}
delete tpalStream;
@@ -1005,13 +1005,13 @@ void LBGraphics::setPalette(uint16 id) {
if (_vm->isPreMohawk()) {
Common::SeekableSubReadStreamEndian *ctblStream = _vm->wrapStreamEndian(ID_CTBL, id);
uint16 colorCount = ctblStream->readUint16();
- byte *palette = new byte[colorCount * 4];
+ byte *palette = new byte[colorCount * 3];
for (uint16 i = 0; i < colorCount; i++) {
- palette[i * 4] = ctblStream->readByte();
- palette[i * 4 + 1] = ctblStream->readByte();
- palette[i * 4 + 2] = ctblStream->readByte();
- palette[i * 4 + 3] = ctblStream->readByte();
+ palette[i * 3 + 0] = ctblStream->readByte();
+ palette[i * 3 + 1] = ctblStream->readByte();
+ palette[i * 3 + 2] = ctblStream->readByte();
+ ctblStream->readByte();
}
delete ctblStream;
diff --git a/engines/mohawk/riven_cursors.h b/engines/mohawk/riven_cursors.h
index 71cb8fd804..dadfdf0549 100644
--- a/engines/mohawk/riven_cursors.h
+++ b/engines/mohawk/riven_cursors.h
@@ -62,8 +62,8 @@ static const byte s_zipModeCursor[] = {
// Palette For The Zip Mode Cursor
////////////////////////////////////////
static const byte s_zipModeCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xDC, 0xFF, 0x00, 0x00, // Yellow
+ 0x00, 0x00, 0x00, // Black
+ 0xDC, 0xFF, 0x00 // Yellow
};
@@ -356,10 +356,10 @@ static const byte s_pointingDownCursorPalmDown[] = {
// Palette For All Hand Cursors
////////////////////////////////////////
static const byte s_handCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xED, 0xCD, 0x96, 0x00, // Light Peach
- 0x8A, 0x67, 0x2F, 0x00, // Brown
- 0xE8, 0x9A, 0x62, 0x00 // Dark Peach
+ 0x00, 0x00, 0x00, // Black
+ 0xED, 0xCD, 0x96, // Light Peach
+ 0x8A, 0x67, 0x2F, // Brown
+ 0xE8, 0x9A, 0x62 // Dark Peach
};
@@ -392,13 +392,13 @@ static const byte s_pelletCursor[] = {
// Palette For The Pellet Cursor
////////////////////////////////////////
static const byte s_pelletCursorPalette[] = {
- 0x5D, 0x67, 0x30, 0x00,
- 0x5E, 0x33, 0x33, 0x00,
- 0x55, 0x55, 0x55, 0x00,
- 0x44, 0x44, 0x44, 0x00,
- 0x33, 0x33, 0x33, 0x00,
- 0x2D, 0x33, 0x00, 0x00,
- 0x22, 0x22, 0x22, 0x00
+ 0x5D, 0x67, 0x30,
+ 0x5E, 0x33, 0x33,
+ 0x55, 0x55, 0x55,
+ 0x44, 0x44, 0x44,
+ 0x33, 0x33, 0x33,
+ 0x2D, 0x33, 0x00,
+ 0x22, 0x22, 0x22
};
////////////////////////////////////////
@@ -426,29 +426,29 @@ static const byte s_redMarbleCursor[] = {
// Palette For The Red Marble Cursor
////////////////////////////////////////
static const byte s_redMarbleCursorPalette[] = {
- 0xb8, 0x33, 0x32, 0x00,
- 0xe5, 0x33, 0x31, 0x00,
- 0x98, 0x06, 0x00, 0x00,
- 0xb8, 0x00, 0x34, 0x00,
- 0xe6, 0x00, 0x34, 0x00,
- 0x7a, 0x04, 0x00, 0x00,
- 0xe8, 0x9a, 0x62, 0x00,
- 0xea, 0x31, 0x67, 0x00,
- 0x6a, 0x03, 0x00, 0x00,
- 0x8c, 0x00, 0x35, 0x00,
- 0xb6, 0x36, 0x00, 0x00,
- 0xed, 0xcd, 0x96, 0x00,
- 0xe9, 0x66, 0x65, 0x00,
- 0x5b, 0x35, 0x00, 0x00,
- 0x5b, 0x02, 0x00, 0x00,
- 0x5f, 0x00, 0x35, 0x00,
- 0x4c, 0x01, 0x00, 0x00,
- 0x5e, 0x33, 0x33, 0x00,
- 0x89, 0x05, 0x00, 0x00,
- 0xb6, 0x08, 0x00, 0x00,
- 0xa7, 0x07, 0x00, 0x00,
- 0x88, 0x36, 0x00, 0x00,
- 0x8b, 0x33, 0x33, 0x00
+ 0xb8, 0x33, 0x32,
+ 0xe5, 0x33, 0x31,
+ 0x98, 0x06, 0x00,
+ 0xb8, 0x00, 0x34,
+ 0xe6, 0x00, 0x34,
+ 0x7a, 0x04, 0x00,
+ 0xe8, 0x9a, 0x62,
+ 0xea, 0x31, 0x67,
+ 0x6a, 0x03, 0x00,
+ 0x8c, 0x00, 0x35,
+ 0xb6, 0x36, 0x00,
+ 0xed, 0xcd, 0x96,
+ 0xe9, 0x66, 0x65,
+ 0x5b, 0x35, 0x00,
+ 0x5b, 0x02, 0x00,
+ 0x5f, 0x00, 0x35,
+ 0x4c, 0x01, 0x00,
+ 0x5e, 0x33, 0x33,
+ 0x89, 0x05, 0x00,
+ 0xb6, 0x08, 0x00,
+ 0xa7, 0x07, 0x00,
+ 0x88, 0x36, 0x00,
+ 0x8b, 0x33, 0x33
};
////////////////////////////////////////
@@ -475,26 +475,26 @@ static const byte s_orangeMarbleCursor[] = {
// Palette For The Orange Marble Cursor
////////////////////////////////////////
static const byte s_orangeMarbleCursorPalette[] = {
- 0xe1, 0x9e, 0x00, 0x00,
- 0xe3, 0x9b, 0x28, 0x00,
- 0xe2, 0xcf, 0x20, 0x00,
- 0xb5, 0x6a, 0x00, 0x00,
- 0xb6, 0x9b, 0x29, 0x00,
- 0x87, 0x69, 0x00, 0x00,
- 0xb7, 0x67, 0x2f, 0x00,
- 0xe9, 0xff, 0x93, 0x00,
- 0xe1, 0xff, 0x5a, 0x00,
- 0xe0, 0xd0, 0x00, 0x00,
- 0x5e, 0x33, 0x33, 0x00,
- 0x88, 0x36, 0x00, 0x00,
- 0xf3, 0xff, 0xc9, 0x00,
- 0x5b, 0x35, 0x00, 0x00,
- 0x8b, 0x33, 0x33, 0x00,
- 0xe6, 0xce, 0x5f, 0x00,
- 0x8a, 0x67, 0x2f, 0x00,
- 0x5d, 0x67, 0x30, 0x00,
- 0xe2, 0x6a, 0x00, 0x00,
- 0xb3, 0x9d, 0x00, 0x00
+ 0xe1, 0x9e, 0x00,
+ 0xe3, 0x9b, 0x28,
+ 0xe2, 0xcf, 0x20,
+ 0xb5, 0x6a, 0x00,
+ 0xb6, 0x9b, 0x29,
+ 0x87, 0x69, 0x00,
+ 0xb7, 0x67, 0x2f,
+ 0xe9, 0xff, 0x93,
+ 0xe1, 0xff, 0x5a,
+ 0xe0, 0xd0, 0x00,
+ 0x5e, 0x33, 0x33,
+ 0x88, 0x36, 0x00,
+ 0xf3, 0xff, 0xc9,
+ 0x5b, 0x35, 0x00,
+ 0x8b, 0x33, 0x33,
+ 0xe6, 0xce, 0x5f,
+ 0x8a, 0x67, 0x2f,
+ 0x5d, 0x67, 0x30,
+ 0xe2, 0x6a, 0x00,
+ 0xb3, 0x9d, 0x00
};
////////////////////////////////////////
@@ -521,20 +521,20 @@ static const byte s_yellowMarbleCursor[] = {
// Palette For The Yellow Marble Cursor
////////////////////////////////////////
static const byte s_yellowMarbleCursorPalette[] = {
- 0xb3, 0xd0, 0x00, 0x00,
- 0xb0, 0xff, 0x00, 0x00,
- 0x86, 0x9c, 0x00, 0x00,
- 0x87, 0xd0, 0x00, 0x00,
- 0xe0, 0xd0, 0x00, 0x00,
- 0xdc, 0xff, 0x00, 0x00,
- 0xb3, 0x9d, 0x00, 0x00,
- 0xdc, 0xff, 0x11, 0x00,
- 0x5a, 0x68, 0x00, 0x00,
- 0xe1, 0xff, 0x5a, 0x00,
- 0x5d, 0x67, 0x30, 0x00,
- 0x87, 0x69, 0x00, 0x00,
- 0x88, 0x9b, 0x2a, 0x00,
- 0x5a, 0x9c, 0x00, 0x00
+ 0xb3, 0xd0, 0x00,
+ 0xb0, 0xff, 0x00,
+ 0x86, 0x9c, 0x00,
+ 0x87, 0xd0, 0x00,
+ 0xe0, 0xd0, 0x00,
+ 0xdc, 0xff, 0x00,
+ 0xb3, 0x9d, 0x00,
+ 0xdc, 0xff, 0x11,
+ 0x5a, 0x68, 0x00,
+ 0xe1, 0xff, 0x5a,
+ 0x5d, 0x67, 0x30,
+ 0x87, 0x69, 0x00,
+ 0x88, 0x9b, 0x2a,
+ 0x5a, 0x9c, 0x00
};
////////////////////////////////////////
@@ -561,25 +561,25 @@ static const byte s_greenMarbleCursor[] = {
// Palette For The Green Marble Cursor
////////////////////////////////////////
static const byte s_greenMarbleCursorPalette[] = {
- 0x0e, 0xd0, 0x00, 0x00,
- 0x0f, 0xe1, 0x00, 0x00,
- 0x10, 0xf2, 0x00, 0x00,
- 0x0b, 0x9c, 0x00, 0x00,
- 0x0c, 0xad, 0x00, 0x00,
- 0x11, 0xff, 0x00, 0x00,
- 0x09, 0x8a, 0x00, 0x00,
- 0x0d, 0xbe, 0x00, 0x00,
- 0x30, 0xff, 0x5a, 0x00,
- 0x0d, 0x67, 0x30, 0x00,
- 0x6b, 0xff, 0x92, 0x00,
- 0x00, 0xff, 0x28, 0x00,
- 0x08, 0x79, 0x00, 0x00,
- 0x05, 0x57, 0x00, 0x00,
- 0x30, 0x67, 0x30, 0x00,
- 0x06, 0x68, 0x00, 0x00,
- 0x00, 0x9b, 0x2c, 0x00,
- 0x2e, 0x9c, 0x00, 0x00,
- 0x2e, 0x68, 0x00, 0x00
+ 0x0e, 0xd0, 0x00,
+ 0x0f, 0xe1, 0x00,
+ 0x10, 0xf2, 0x00,
+ 0x0b, 0x9c, 0x00,
+ 0x0c, 0xad, 0x00,
+ 0x11, 0xff, 0x00,
+ 0x09, 0x8a, 0x00,
+ 0x0d, 0xbe, 0x00,
+ 0x30, 0xff, 0x5a,
+ 0x0d, 0x67, 0x30,
+ 0x6b, 0xff, 0x92,
+ 0x00, 0xff, 0x28,
+ 0x08, 0x79, 0x00,
+ 0x05, 0x57, 0x00,
+ 0x30, 0x67, 0x30,
+ 0x06, 0x68, 0x00,
+ 0x00, 0x9b, 0x2c,
+ 0x2e, 0x9c, 0x00,
+ 0x2e, 0x68, 0x00
};
////////////////////////////////////////
@@ -606,28 +606,28 @@ static const byte s_blueMarbleCursor[] = {
// Palette For The Blue Marble Cursor
////////////////////////////////////////
static const byte s_blueMarbleCursorPalette[] = {
- 0x6b, 0x00, 0xd2, 0x00,
- 0x66, 0x00, 0xe3, 0x00,
- 0x72, 0x00, 0xff, 0x00,
- 0x53, 0x2d, 0x9d, 0x00,
- 0x4e, 0x00, 0xaf, 0x00,
- 0x6d, 0x00, 0xf5, 0x00,
- 0x7d, 0x00, 0xff, 0x00,
- 0x44, 0x00, 0x69, 0x00,
- 0x56, 0x00, 0x9d, 0x00,
- 0x56, 0x00, 0xc0, 0x00,
- 0x5e, 0x00, 0xd2, 0x00,
- 0x2b, 0x31, 0x68, 0x00,
- 0x3f, 0x00, 0x8c, 0x00,
- 0x91, 0x22, 0xff, 0x00,
- 0x41, 0x31, 0x68, 0x00,
- 0xd7, 0x95, 0xff, 0x00,
- 0x77, 0x22, 0xff, 0x00,
- 0x2f, 0x00, 0x69, 0x00,
- 0x37, 0x00, 0x7a, 0x00,
- 0x27, 0x00, 0x58, 0x00,
- 0x46, 0x00, 0x9d, 0x00,
- 0x33, 0x33, 0x33, 0x00
+ 0x6b, 0x00, 0xd2,
+ 0x66, 0x00, 0xe3,
+ 0x72, 0x00, 0xff,
+ 0x53, 0x2d, 0x9d,
+ 0x4e, 0x00, 0xaf,
+ 0x6d, 0x00, 0xf5,
+ 0x7d, 0x00, 0xff,
+ 0x44, 0x00, 0x69,
+ 0x56, 0x00, 0x9d,
+ 0x56, 0x00, 0xc0,
+ 0x5e, 0x00, 0xd2,
+ 0x2b, 0x31, 0x68,
+ 0x3f, 0x00, 0x8c,
+ 0x91, 0x22, 0xff,
+ 0x41, 0x31, 0x68,
+ 0xd7, 0x95, 0xff,
+ 0x77, 0x22, 0xff,
+ 0x2f, 0x00, 0x69,
+ 0x37, 0x00, 0x7a,
+ 0x27, 0x00, 0x58,
+ 0x46, 0x00, 0x9d,
+ 0x33, 0x33, 0x33
};
////////////////////////////////////////
@@ -654,17 +654,17 @@ static const byte s_violetMarbleCursor[] = {
// Palette For The Violet Marble Cursor
////////////////////////////////////////
static const byte s_violetMarbleCursorPalette[] = {
- 0xaa, 0x00, 0xd1, 0x00,
- 0xd8, 0x00, 0xff, 0x00,
- 0x76, 0x00, 0x9d, 0x00,
- 0xb5, 0x00, 0xff, 0x00,
- 0x87, 0x00, 0xd2, 0x00,
- 0xd7, 0x22, 0xff, 0x00,
- 0x68, 0x00, 0x69, 0x00,
- 0x44, 0x00, 0x69, 0x00,
- 0xd7, 0x5e, 0xff, 0x00,
- 0x9c, 0x00, 0x9d, 0x00,
- 0x56, 0x00, 0x9d, 0x00
+ 0xaa, 0x00, 0xd1,
+ 0xd8, 0x00, 0xff,
+ 0x76, 0x00, 0x9d,
+ 0xb5, 0x00, 0xff,
+ 0x87, 0x00, 0xd2,
+ 0xd7, 0x22, 0xff,
+ 0x68, 0x00, 0x69,
+ 0x44, 0x00, 0x69,
+ 0xd7, 0x5e, 0xff,
+ 0x9c, 0x00, 0x9d,
+ 0x56, 0x00, 0x9d
};
} // End of namespace Mohawk
diff --git a/engines/mohawk/view.cpp b/engines/mohawk/view.cpp
index 241b2c3663..837d386b58 100644
--- a/engines/mohawk/view.cpp
+++ b/engines/mohawk/view.cpp
@@ -421,13 +421,13 @@ void View::installBG(uint16 id) {
void View::setColors(Common::SeekableReadStream *tpalStream) {
uint16 colorStart = tpalStream->readUint16BE();
uint16 colorCount = tpalStream->readUint16BE();
- byte *palette = new byte[colorCount * 4];
+ byte *palette = new byte[colorCount * 3];
for (uint16 i = 0; i < colorCount; i++) {
- palette[i * 4] = tpalStream->readByte();
- palette[i * 4 + 1] = tpalStream->readByte();
- palette[i * 4 + 2] = tpalStream->readByte();
- palette[i * 4 + 3] = tpalStream->readByte();
+ palette[i * 3 + 0] = tpalStream->readByte();
+ palette[i * 3 + 1] = tpalStream->readByte();
+ palette[i * 3 + 2] = tpalStream->readByte();
+ tpalStream->readByte();
}
// TODO: copy into temporary buffer
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 79993a297a..35441d7e3e 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -160,26 +160,24 @@ void Palette::fadeTo(const Palette& target, uint step) {
return;
}
-uint Palette::fillRGBA(byte *rgba) {
+uint Palette::fillRGB(byte *rgb) {
byte r, g, b;
- byte *hbPal = rgba + _colors * 4;
+ byte *hbPal = rgb + _colors * 3;
for (uint32 i = 0; i < _colors; i++) {
r = (_data[i*3] << 2) | (_data[i*3] >> 4);
g = (_data[i*3+1] << 2) | (_data[i*3+1] >> 4);
b = (_data[i*3+2] << 2) | (_data[i*3+2] >> 4);
- rgba[i*4] = r;
- rgba[i*4+1] = g;
- rgba[i*4+2] = b;
- rgba[i*4+3] = 0;
+ rgb[i*3] = r;
+ rgb[i*3+1] = g;
+ rgb[i*3+2] = b;
if (_hb) {
- hbPal[i*4] = r >> 1;
- hbPal[i*4+1] = g >> 1;
- hbPal[i*4+2] = b >> 1;
- hbPal[i*4+3] = 0;
+ hbPal[i*3] = r >> 1;
+ hbPal[i*3+1] = g >> 1;
+ hbPal[i*3+2] = b >> 1;
}
}
@@ -222,9 +220,9 @@ void Palette::rotate(uint first, uint last, bool forward) {
void Gfx::setPalette(Palette pal) {
- byte sysPal[256*4];
+ byte sysPal[256*3];
- uint n = pal.fillRGBA(sysPal);
+ uint n = pal.fillRGB(sysPal);
_vm->_system->getPaletteManager()->setPalette(sysPal, 0, n);
}
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index afabcad21c..d6732e6fe4 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -250,7 +250,7 @@ public:
void setEntry(uint index, int red, int green, int blue);
void makeGrayscale();
void fadeTo(const Palette& target, uint step);
- uint fillRGBA(byte *rgba);
+ uint fillRGB(byte *rgb);
void rotate(uint first, uint last, bool forward);
};
diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp
index 4557588732..7b16df52bf 100644
--- a/engines/queen/display.cpp
+++ b/engines/queen/display.cpp
@@ -159,15 +159,7 @@ void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) {
debug(9, "Display::palSet(%d, %d)", start, end);
const int numColors = end - start + 1;
assert(numColors <= 256);
- uint8 tempPal[256 * 4];
- pal += start * 3;
- for (int i = 0; i < numColors; i++) {
- tempPal[4 * i + 0] = *pal++;
- tempPal[4 * i + 1] = *pal++;
- tempPal[4 * i + 2] = *pal++;
- tempPal[4 * i + 3] = 0;
- }
- _system->getPaletteManager()->setPalette(tempPal, start, numColors);
+ _system->getPaletteManager()->setPalette(pal + start * 3, start, numColors);
if (updateScreen) {
_vm->input()->delay(20);
}
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 771284f632..c46da4cd4e 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -201,20 +201,19 @@ void Gfx::setPalette(const PalEntry *pal, bool full) {
numcolors = 248;
}
- for (i = 0, ppal = &_currentPal[from * 4]; i < numcolors; i++, ppal += 4) {
+ for (i = 0, ppal = &_currentPal[from * 3]; i < numcolors; i++, ppal += 3) {
ppal[0] = _globalPalette[i].red = pal[i].red;
ppal[1] = _globalPalette[i].green = pal[i].green;
ppal[2] = _globalPalette[i].blue = pal[i].blue;
- ppal[3] = 0;
}
// Color 0 should always be black in IHNM
if (_vm->getGameId() == GID_IHNM)
- memset(&_currentPal[0 * 4], 0, 4);
+ memset(&_currentPal[0 * 3], 0, 3);
// Make 256th color black. See bug #1256368
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
- memset(&_currentPal[255 * 4], 0, 4);
+ memset(&_currentPal[255 * 3], 0, 3);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
@@ -225,20 +224,16 @@ void Gfx::setPaletteColor(int n, int r, int g, int b) {
// This function may get called a lot. To avoid forcing full-screen
// updates, only update the palette if the color actually changes.
- if (_currentPal[4 * n + 0] != r) {
- _currentPal[4 * n + 0] = _globalPalette[n].red = r;
+ if (_currentPal[3 * n + 0] != r) {
+ _currentPal[3 * n + 0] = _globalPalette[n].red = r;
update = true;
}
- if (_currentPal[4 * n + 1] != g) {
- _currentPal[4 * n + 1] = _globalPalette[n].green = g;
+ if (_currentPal[3 * n + 1] != g) {
+ _currentPal[3 * n + 1] = _globalPalette[n].green = g;
update = true;
}
- if (_currentPal[4 * n + 2] != b) {
- _currentPal[4 * n + 2] = _globalPalette[n].blue = b;
- update = true;
- }
- if (_currentPal[4 * n + 3] != 0) {
- _currentPal[4 * n + 3] = 0;
+ if (_currentPal[3 * n + 2] != b) {
+ _currentPal[3 * n + 2] = _globalPalette[n].blue = b;
update = true;
}
@@ -250,7 +245,7 @@ void Gfx::getCurrentPal(PalEntry *src_pal) {
int i;
byte *ppal;
- for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
+ for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) {
src_pal[i].red = ppal[0];
src_pal[i].green = ppal[1];
src_pal[i].blue = ppal[2];
@@ -285,7 +280,7 @@ void Gfx::palToBlack(PalEntry *srcPal, double percent) {
fpercent = 1.0 - fpercent;
// Use the correct percentage change per frame for each palette entry
- for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
+ for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) {
if (i < from || i >= from + numcolors)
palE = &_globalPalette[i];
else
@@ -314,16 +309,15 @@ void Gfx::palToBlack(PalEntry *srcPal, double percent) {
} else {
ppal[2] = (byte) new_entry;
}
- ppal[3] = 0;
}
// Color 0 should always be black in IHNM
if (_vm->getGameId() == GID_IHNM)
- memset(&_currentPal[0 * 4], 0, 4);
+ memset(&_currentPal[0 * 3], 0, 3);
// Make 256th color black. See bug #1256368
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
- memset(&_currentPal[255 * 4], 0, 4);
+ memset(&_currentPal[255 * 3], 0, 3);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
@@ -352,7 +346,7 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) {
fpercent = percent * percent;
// Use the correct percentage change per frame for each palette entry
- for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
+ for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) {
if (i < from || i >= from + numcolors)
palE = &_globalPalette[i];
else
@@ -381,16 +375,15 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) {
} else {
ppal[2] = (byte) new_entry;
}
- ppal[3] = 0;
}
// Color 0 should always be black in IHNM
if (_vm->getGameId() == GID_IHNM)
- memset(&_currentPal[0 * 4], 0, 4);
+ memset(&_currentPal[0 * 3], 0, 3);
// Make 256th color black. See bug #1256368
if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro())
- memset(&_currentPal[255 * 4], 0, 4);
+ memset(&_currentPal[255 * 3], 0, 3);
_system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES);
}
@@ -420,10 +413,10 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num
if (from > to)
percent = 1.0 - percent;
- byte fadePal[PAL_ENTRIES * 4];
+ byte fadePal[PAL_ENTRIES * 3];
// Use the correct percentage change per frame for each palette entry
- for (i = start, ppal = fadePal + start * 4; i < start + numColors; i++, ppal += 4) {
+ for (i = start, ppal = fadePal + start * 3; i < start + numColors; i++, ppal += 3) {
palE = &srcPal[i];
new_entry = (int)(palE->red * percent);
@@ -449,13 +442,12 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num
} else {
ppal[2] = (byte) new_entry;
}
- ppal[3] = 0;
}
// Color 0 should always be black in IHNM
- memset(&fadePal[0 * 4], 0, 4);
+ memset(&fadePal[0 * 3], 0, 3);
- _system->getPaletteManager()->setPalette(&fadePal[start * 4], start, numColors);
+ _system->getPaletteManager()->setPalette(&fadePal[start * 3], start, numColors);
}
#endif
diff --git a/engines/saga/gfx.h b/engines/saga/gfx.h
index 18d88503ce..33fac10c63 100644
--- a/engines/saga/gfx.h
+++ b/engines/saga/gfx.h
@@ -224,7 +224,7 @@ public:
private:
Surface _backBuffer;
- byte _currentPal[PAL_ENTRIES * 4];
+ byte _currentPal[PAL_ENTRIES * 3];
OSystem *_system;
SagaEngine *_vm;
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index e78d3e67cb..b085654d02 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -488,7 +488,7 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
uint16 hotspotX = READ_BE_UINT16(data);
uint16 hotspotY = READ_BE_UINT16(data + 2);
- static const byte cursorPalette[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00 };
+ static const byte cursorPalette[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0xff };
CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0);
CursorMan.replaceCursorPalette(cursorPalette, 1, 2);
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index b802f7294a..534890315c 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -431,7 +431,7 @@ static byte convertMacGammaToSCIGamma(int comp) {
void GfxPalette::copySysPaletteToScreen() {
// just copy palette to system
- byte bpal[4 * 256];
+ byte bpal[3 * 256];
// Get current palette, update it and put back
g_system->getPaletteManager()->grabPalette(bpal, 0, 256);
@@ -439,14 +439,14 @@ void GfxPalette::copySysPaletteToScreen() {
for (int16 i = 0; i < 256; i++) {
if (colorIsFromMacClut(i)) {
// If we've got a Mac CLUT, override the SCI palette with its non-black colors
- bpal[i * 4 ] = convertMacGammaToSCIGamma(_macClut[i * 3 ]);
- bpal[i * 4 + 1] = convertMacGammaToSCIGamma(_macClut[i * 3 + 1]);
- bpal[i * 4 + 2] = convertMacGammaToSCIGamma(_macClut[i * 3 + 2]);
+ bpal[i * 3 ] = convertMacGammaToSCIGamma(_macClut[i * 3 ]);
+ bpal[i * 3 + 1] = convertMacGammaToSCIGamma(_macClut[i * 3 + 1]);
+ bpal[i * 3 + 2] = convertMacGammaToSCIGamma(_macClut[i * 3 + 2]);
} else if (_sysPalette.colors[i].used != 0) {
// Otherwise, copy to the screen
- bpal[i * 4 ] = CLIP(_sysPalette.colors[i].r * _sysPalette.intensity[i] / 100, 0, 255);
- bpal[i * 4 + 1] = CLIP(_sysPalette.colors[i].g * _sysPalette.intensity[i] / 100, 0, 255);
- bpal[i * 4 + 2] = CLIP(_sysPalette.colors[i].b * _sysPalette.intensity[i] / 100, 0, 255);
+ bpal[i * 3 ] = CLIP(_sysPalette.colors[i].r * _sysPalette.intensity[i] / 100, 0, 255);
+ bpal[i * 3 + 1] = CLIP(_sysPalette.colors[i].g * _sysPalette.intensity[i] / 100, 0, 255);
+ bpal[i * 3 + 2] = CLIP(_sysPalette.colors[i].b * _sysPalette.intensity[i] / 100, 0, 255);
}
}
@@ -609,14 +609,14 @@ void GfxPalette::kernelAssertPalette(GuiResourceId resourceId) {
void GfxPalette::kernelSyncScreenPalette() {
// just copy palette to system
- byte bpal[4 * 256];
+ byte bpal[3 * 256];
// Get current palette, update it and put back
g_system->getPaletteManager()->grabPalette(bpal, 0, 256);
for (int16 i = 1; i < 255; i++) {
- _sysPalette.colors[i].r = bpal[i * 4];
- _sysPalette.colors[i].g = bpal[i * 4 + 1];
- _sysPalette.colors[i].b = bpal[i * 4 + 2];
+ _sysPalette.colors[i].r = bpal[i * 3];
+ _sysPalette.colors[i].g = bpal[i * 3 + 1];
+ _sysPalette.colors[i].b = bpal[i * 3 + 2];
}
}
diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp
index e741f66fde..e025a2f9ab 100644
--- a/engines/sci/graphics/transitions.cpp
+++ b/engines/sci/graphics/transitions.cpp
@@ -302,7 +302,7 @@ void GfxTransitions::copyRectToScreen(const Common::Rect rect, bool blackoutFlag
// Note: don't do too many steps in here, otherwise cpu will crap out because of
// the load
void GfxTransitions::fadeOut() {
- byte oldPalette[4 * 256], workPalette[4 * 256];
+ byte oldPalette[3 * 256], workPalette[3 * 256];
int16 stepNr, colorNr;
// Sierra did not fade in/out color 255 for sci1.1, but they used it in
// several pictures (e.g. qfg3 demo/intro), so the fading looked weird
@@ -313,17 +313,16 @@ void GfxTransitions::fadeOut() {
for (stepNr = 100; stepNr >= 0; stepNr -= 10) {
for (colorNr = 1; colorNr < tillColorNr; colorNr++) {
if (_palette->colorIsFromMacClut(colorNr)) {
- workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4];
- workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1];
- workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2];
+ workPalette[colorNr * 3 + 0] = oldPalette[colorNr * 3];
+ workPalette[colorNr * 3 + 1] = oldPalette[colorNr * 3 + 1];
+ workPalette[colorNr * 3 + 2] = oldPalette[colorNr * 3 + 2];
} else {
- workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100;
- workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100;
- workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100;
+ workPalette[colorNr * 3 + 0] = oldPalette[colorNr * 3] * stepNr / 100;
+ workPalette[colorNr * 3 + 1] = oldPalette[colorNr * 3 + 1] * stepNr / 100;
+ workPalette[colorNr * 3 + 2] = oldPalette[colorNr * 3 + 2] * stepNr / 100;
}
}
-
- g_system->getPaletteManager()->setPalette(workPalette + 4, 1, 254);
+ g_system->getPaletteManager()->setPalette(workPalette + 3, 1, 254);
g_sci->getEngineState()->wait(2);
}
}
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index 8e211a5041..f49635d10f 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -176,9 +176,9 @@ void ScummEngine_v70he::setCursorFromImg(uint img, uint room, uint imgindex) {
void ScummEngine_v70he::setDefaultCursor() {
const uint16 *src;
int i, j;
- static const byte palette[] = {0, 0, 0, 0,
- 0xff, 0xff, 0xff, 0,
- 0, 0, 0, 0};
+ static const byte palette[] = {0, 0, 0,
+ 0xff, 0xff, 0xff,
+ 0, 0, 0, };
if (_bytesPerPixel == 2) {
for (i = 0; i < 1024; i++)
diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp
index 516ff6b977..79bb47aafc 100644
--- a/engines/scumm/he/cup_player_he.cpp
+++ b/engines/scumm/he/cup_player_he.cpp
@@ -298,9 +298,7 @@ void CUP_Player::handleSFXB(Common::SeekableReadStream &dataStream, uint32 dataS
}
void CUP_Player::handleRGBS(Common::SeekableReadStream &dataStream, uint32 dataSize) {
- for (int i = 0; i < 256; i++) {
- dataStream.read(&_paletteData[i * 4], 3);
- }
+ dataStream.read(_paletteData, 256 * 3);
_paletteChanged = true;
}
diff --git a/engines/scumm/he/cup_player_he.h b/engines/scumm/he/cup_player_he.h
index 1b1c32d86f..93146fdf85 100644
--- a/engines/scumm/he/cup_player_he.h
+++ b/engines/scumm/he/cup_player_he.h
@@ -90,7 +90,7 @@ protected:
int _playbackRate;
int _width, _height;
- uint8 _paletteData[256 * 4];
+ uint8 _paletteData[256 * 3];
bool _paletteChanged;
uint8 *_offscreenBuffer;
diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp
index c7ed9e64a8..b42d6e97e2 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -380,21 +380,8 @@ void ScummEngine_v99he::updatePalette() {
return;
int num = _palDirtyMax - _palDirtyMin + 1;
- int i;
-
- byte palette_colors[1024];
- byte *p = palette_colors;
-
- for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
- byte *data = _hePalettes + 1024 + i * 3;
-
- *p++ = data[0];
- *p++ = data[1];
- *p++ = data[2];
- *p++ = 0;
- }
- _system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, num);
+ _system->getPaletteManager()->setPalette(_hePalettes + 1024 + _palDirtyMin * 3, _palDirtyMin, num);
_palDirtyMax = -1;
_palDirtyMin = 256;
diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp
index 52592cd90e..18784151b7 100644
--- a/engines/scumm/palette.cpp
+++ b/engines/scumm/palette.cpp
@@ -1081,7 +1081,7 @@ void ScummEngine::updatePalette() {
int num = _palDirtyMax - first + 1;
int i;
- byte palette_colors[1024];
+ byte palette_colors[3 * 256];
byte *p = palette_colors;
for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
@@ -1108,12 +1108,10 @@ void ScummEngine::updatePalette() {
*p++ = brightness;
*p++ = brightness;
*p++ = brightness;
- *p++ = 0;
} else {
*p++ = data[0];
*p++ = data[1];
*p++ = data[2];
- *p++ = 0;
}
}
@@ -1126,7 +1124,7 @@ void ScummEngine::updatePalette() {
p = palette_colors;
for (i = first; i < first + num; ++i) {
_16BitPalette[i] = get16BitColor(p[0], p[1], p[2]);
- p += 4;
+ p += 3;
}
return;
}
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index ad8a135a7c..fe2b9d99ff 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -1217,19 +1217,7 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
_vm->parseEvents();
_vm->processInput();
if (_palDirtyMax >= _palDirtyMin) {
- byte palette_colors[1024];
- byte *p = palette_colors;
-
- for (int i = _palDirtyMin; i <= _palDirtyMax; i++) {
- byte *data = _pal + i * 3;
-
- *p++ = data[0];
- *p++ = data[1];
- *p++ = data[2];
- *p++ = 0;
- }
-
- _vm->_system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1);
+ _vm->_system->getPaletteManager()->setPalette(_pal + _palDirtyMin * 3, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1);
_palDirtyMax = -1;
_palDirtyMin = 256;
diff --git a/engines/sky/screen.cpp b/engines/sky/screen.cpp
index dae158e41b..a77017de38 100644
--- a/engines/sky/screen.cpp
+++ b/engines/sky/screen.cpp
@@ -63,7 +63,7 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) {
_skyCompact = skyCompact;
int i;
- uint8 tmpPal[1024];
+ uint8 tmpPal[VGA_COLOURS * 3];
_gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2);
forceRefresh();
@@ -72,14 +72,13 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) {
_scrollScreen = NULL;
//blank the first 240 colors of the palette
- memset(tmpPal, 0, GAME_COLOURS * 4);
+ memset(tmpPal, 0, GAME_COLOURS * 3);
//set the remaining colors
for (i = 0; i < (VGA_COLOURS-GAME_COLOURS); i++) {
- tmpPal[4 * GAME_COLOURS + i * 4] = (_top16Colours[i * 3] << 2) + (_top16Colours[i * 3] >> 4);
- tmpPal[4 * GAME_COLOURS + i * 4 + 1] = (_top16Colours[i * 3 + 1] << 2) + (_top16Colours[i * 3 + 1] >> 4);
- tmpPal[4 * GAME_COLOURS + i * 4 + 2] = (_top16Colours[i * 3 + 2] << 2) + (_top16Colours[i * 3 + 2] >> 4);
- tmpPal[4 * GAME_COLOURS + i * 4 + 3] = 0x00;
+ tmpPal[3 * GAME_COLOURS + i * 3 + 0] = (_top16Colours[i * 3 + 0] << 2) + (_top16Colours[i * 3 + 0] >> 4);
+ tmpPal[3 * GAME_COLOURS + i * 3 + 1] = (_top16Colours[i * 3 + 1] << 2) + (_top16Colours[i * 3 + 1] >> 4);
+ tmpPal[3 * GAME_COLOURS + i * 3 + 2] = (_top16Colours[i * 3 + 2] << 2) + (_top16Colours[i * 3 + 2] >> 4);
}
//set the palette
@@ -116,8 +115,8 @@ void Screen::setPalette(uint8 *pal) {
void Screen::setPaletteEndian(uint8 *pal) {
#ifdef SCUMM_BIG_ENDIAN
- uint8 endPalette[256 * 3];
- for (uint16 cnt = 0; cnt < 256 * 3; cnt++)
+ uint8 endPalette[VGA_COLOURS * 3];
+ for (uint16 cnt = 0; cnt < VGA_COLOURS * 3; cnt++)
endPalette[cnt] = pal[cnt ^ 1];
convertPalette(endPalette, _palette);
#else
@@ -128,12 +127,12 @@ void Screen::setPaletteEndian(uint8 *pal) {
}
void Screen::halvePalette() {
- uint8 halfPalette[1024];
+ uint8 halfPalette[VGA_COLOURS * 3];
+
for (uint8 cnt = 0; cnt < GAME_COLOURS; cnt++) {
- halfPalette[(cnt << 2) | 0] = _palette[(cnt << 2) | 0] >> 1;
- halfPalette[(cnt << 2) | 1] = _palette[(cnt << 2) | 1] >> 1;
- halfPalette[(cnt << 2) | 2] = _palette[(cnt << 2) | 2] >> 1;
- halfPalette[(cnt << 2) | 3] = 0;
+ halfPalette[cnt * 3 + 0] = _palette[cnt * 3 + 0] >> 1;
+ halfPalette[cnt * 3 + 1] = _palette[cnt * 3 + 1] >> 1;
+ halfPalette[cnt * 3 + 2] = _palette[cnt * 3 + 2] >> 1;
}
_system->getPaletteManager()->setPalette(halfPalette, 0, GAME_COLOURS);
}
@@ -165,14 +164,14 @@ void Screen::showScreen(uint8 *pScreen) {
_system->updateScreen();
}
-void Screen::convertPalette(uint8 *inPal, uint8* outPal) { //convert 3 byte 0..63 rgb to 4byte 0..255 rgbx
+//convert 3 byte 0..63 rgb to 3 byte 0..255 rgb
+void Screen::convertPalette(uint8 *inPal, uint8* outPal) {
int i;
for (i = 0; i < VGA_COLOURS; i++) {
- outPal[4 * i] = (inPal[3 * i] << 2) + (inPal[3 * i] >> 4);
- outPal[4 * i + 1] = (inPal[3 * i + 1] << 2) + (inPal[3 * i + 1] >> 4);
- outPal[4 * i + 2] = (inPal[3 * i + 2] << 2) + (inPal[3 * i + 2] >> 4);
- outPal[4 * i + 3] = 0x00;
+ outPal[3 * i + 0] = (inPal[3 * i + 0] << 2) + (inPal[3 * i + 0] >> 4);
+ outPal[3 * i + 1] = (inPal[3 * i + 1] << 2) + (inPal[3 * i + 1] >> 4);
+ outPal[3 * i + 2] = (inPal[3 * i + 2] << 2) + (inPal[3 * i + 2] >> 4);
}
}
@@ -248,7 +247,7 @@ void Screen::fnFadeDown(uint32 scroll) {
uint32 delayTime = _system->getMillis();
for (uint8 cnt = 0; cnt < 32; cnt++) {
delayTime += 20;
- palette_fadedown_helper((uint32 *)_palette, GAME_COLOURS);
+ palette_fadedown_helper(_palette, GAME_COLOURS);
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
int32 waitTime = (int32)delayTime - _system->getMillis();
@@ -266,23 +265,24 @@ void Screen::fnFadeDown(uint32 scroll) {
}
}
-void Screen::palette_fadedown_helper(uint32 *pal, uint num) {
- byte *p = (byte *)pal;
-
+void Screen::palette_fadedown_helper(uint8 *pal, uint num) {
do {
- if (p[0] >= 8)
- p[0] -= 8;
+ if (pal[0] >= 8)
+ pal[0] -= 8;
else
- p[0] = 0;
- if (p[1] >= 8)
- p[1] -= 8;
+ pal[0] = 0;
+
+ if (pal[1] >= 8)
+ pal[1] -= 8;
else
- p[1] = 0;
- if (p[2] >= 8)
- p[2] -= 8;
+ pal[1] = 0;
+
+ if (pal[2] >= 8)
+ pal[2] -= 8;
else
- p[2] = 0;
- p += sizeof(uint32);
+ pal[2] = 0;
+
+ pal += 3;
} while (--num);
}
@@ -296,20 +296,23 @@ void Screen::paletteFadeUp(uint16 fileNr) {
}
void Screen::paletteFadeUp(uint8 *pal) {
- byte tmpPal[1024];
+ byte tmpPal[VGA_COLOURS * 3];
convertPalette(pal, tmpPal);
uint32 delayTime = _system->getMillis();
for (uint8 cnt = 1; cnt <= 32; cnt++) {
delayTime += 20;
+
for (uint8 colCnt = 0; colCnt < GAME_COLOURS; colCnt++) {
- _palette[(colCnt << 2) | 0] = (tmpPal[(colCnt << 2) | 0] * cnt) >> 5;
- _palette[(colCnt << 2) | 1] = (tmpPal[(colCnt << 2) | 1] * cnt) >> 5;
- _palette[(colCnt << 2) | 2] = (tmpPal[(colCnt << 2) | 2] * cnt) >> 5;
+ _palette[colCnt * 3 + 0] = (tmpPal[colCnt * 3 + 0] * cnt) >> 5;
+ _palette[colCnt * 3 + 1] = (tmpPal[colCnt * 3 + 1] * cnt) >> 5;
+ _palette[colCnt * 3 + 2] = (tmpPal[colCnt * 3 + 2] * cnt) >> 5;
}
+
_system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS);
_system->updateScreen();
+
int32 waitTime = (int32)delayTime - _system->getMillis();
if (waitTime < 0)
waitTime = 0;
@@ -328,8 +331,8 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) {
if (palette == NULL)
error("Screen::fnFadeUp: can't fetch compact %X", palNum);
#ifdef SCUMM_BIG_ENDIAN
- byte tmpPal[256 * 3];
- for (uint16 cnt = 0; cnt < 256*3; cnt++)
+ byte tmpPal[VGA_COLOURS * 3];
+ for (uint16 cnt = 0; cnt < VGA_COLOURS * 3; cnt++)
tmpPal[cnt] = palette[cnt ^ 1];
paletteFadeUp(tmpPal);
#else
diff --git a/engines/sky/screen.h b/engines/sky/screen.h
index 5310aebeee..69a9a2fc8f 100644
--- a/engines/sky/screen.h
+++ b/engines/sky/screen.h
@@ -100,8 +100,8 @@ private:
OSystem *_system;
Disk *_skyDisk;
SkyCompact *_skyCompact;
- static uint8 _top16Colours[16*3];
- uint8 _palette[1024];
+ static uint8 _top16Colours[16 * 3];
+ uint8 _palette[VGA_COLOURS * 3];
uint32 _currentPalette;
uint8 _seqGrid[20 * 12];
@@ -121,7 +121,7 @@ private:
//- more regular screen.asm + layer.asm routines
void convertPalette(uint8 *inPal, uint8* outPal);
- void palette_fadedown_helper(uint32 *pal, uint num);
+ void palette_fadedown_helper(uint8 *pal, uint num);
//- sprite.asm routines
// fixme: get rid of these globals
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index fa876b565f..60176be1a9 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -174,7 +174,7 @@ void MoviePlayer::play() {
// previous location would be momentarily drawn, before switching to
// the new one. Work around this by setting the palette to black.
- byte pal[4 * 256];
+ byte pal[3 * 256];
memset(pal, 0, sizeof(pal));
_system->getPaletteManager()->setPalette(pal, 0, 256);
}
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index c61d0b7c85..d4f6bfd1fe 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -248,13 +248,13 @@ void Control::askForCd() {
fontId = CZECH_SR_FONT;
_font = (uint8*)_resMan->openFetchRes(fontId);
uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE);
- uint8 *palOut = (uint8*)malloc(256 * 4);
+ uint8 *palOut = (uint8*)malloc(256 * 3);
for (uint16 cnt = 1; cnt < 256; cnt++) {
- palOut[cnt * 4 + 0] = pal[cnt * 3 + 0] << 2;
- palOut[cnt * 4 + 1] = pal[cnt * 3 + 1] << 2;
- palOut[cnt * 4 + 2] = pal[cnt * 3 + 2] << 2;
+ palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2;
+ palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2;
+ palOut[cnt * 3 + 2] = pal[cnt * 3 + 2] << 2;
}
- palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0;
+ palOut[0] = palOut[1] = palOut[2] = 0;
_resMan->resClose(SR_PALETTE);
_system->getPaletteManager()->setPalette(palOut, 0, 256);
free(palOut);
@@ -318,13 +318,13 @@ uint8 Control::runPanel() {
_redFont = (uint8*)_resMan->openFetchRes(redFontId);
uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE);
- uint8 *palOut = (uint8*)malloc(256 * 4);
+ uint8 *palOut = (uint8*)malloc(256 * 3);
for (uint16 cnt = 1; cnt < 256; cnt++) {
- palOut[cnt * 4 + 0] = pal[cnt * 3 + 0] << 2;
- palOut[cnt * 4 + 1] = pal[cnt * 3 + 1] << 2;
- palOut[cnt * 4 + 2] = pal[cnt * 3 + 2] << 2;
+ palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2;
+ palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2;
+ palOut[cnt * 3 + 2] = pal[cnt * 3 + 2] << 2;
}
- palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0;
+ palOut[0] = palOut[1] = palOut[2] = 0;
_resMan->resClose(SR_PALETTE);
_system->getPaletteManager()->setPalette(palOut, 0, 256);
free(palOut);
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index 031ab74d9a..24fd5b502f 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -144,19 +144,19 @@ void Screen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp) {
}
for (uint32 cnt = 0; cnt < length; cnt++) {
- _targetPalette[(start + cnt) * 4 + 0] = palData[cnt * 3 + 0] << 2;
- _targetPalette[(start + cnt) * 4 + 1] = palData[cnt * 3 + 1] << 2;
- _targetPalette[(start + cnt) * 4 + 2] = palData[cnt * 3 + 2] << 2;
+ _targetPalette[(start + cnt) * 3 + 0] = palData[cnt * 3 + 0] << 2;
+ _targetPalette[(start + cnt) * 3 + 1] = palData[cnt * 3 + 1] << 2;
+ _targetPalette[(start + cnt) * 3 + 2] = palData[cnt * 3 + 2] << 2;
}
_resMan->resClose(id);
_isBlack = false;
if (fadeUp) {
_fadingStep = 1;
_fadingDirection = FADE_UP;
- memset(_currentPalette, 0, 256 * 4);
+ memset(_currentPalette, 0, 256 * 3);
_system->getPaletteManager()->setPalette(_currentPalette, 0, 256);
} else
- _system->getPaletteManager()->setPalette(_targetPalette + 4 * start, start, length);
+ _system->getPaletteManager()->setPalette(_targetPalette + 3 * start, start, length);
}
void Screen::fullRefresh() {
@@ -1125,11 +1125,11 @@ void Screen::flushPsxCache() {
void Screen::fadePalette() {
if (_fadingStep == 16)
- memcpy(_currentPalette, _targetPalette, 256 * 4);
+ memcpy(_currentPalette, _targetPalette, 256 * 3);
else if ((_fadingStep == 1) && (_fadingDirection == FADE_DOWN)) {
- memset(_currentPalette, 0, 4 * 256);
+ memset(_currentPalette, 0, 3 * 256);
} else
- for (uint16 cnt = 0; cnt < 256 * 4; cnt++)
+ for (uint16 cnt = 0; cnt < 256 * 3; cnt++)
_currentPalette[cnt] = (_targetPalette[cnt] * _fadingStep) >> 4;
_fadingStep += _fadingDirection;
diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h
index fc998c6f28..88326a730e 100644
--- a/engines/sword1/screen.h
+++ b/engines/sword1/screen.h
@@ -161,8 +161,8 @@ private:
static RoomDef _roomDefTable[TOTAL_ROOMS]; // from ROOMS.C (not const, see fnSetParallax)
- uint8 _targetPalette[256 * 4];
- uint8 _currentPalette[256 * 4]; // for fading
+ uint8 _targetPalette[256 * 3];
+ uint8 _currentPalette[256 * 3]; // for fading
uint8 _fadingStep;
int8 _fadingDirection; // 1 for fade up, -1 for fade down
bool _isBlack; // if the logic already faded down the palette, this is set to show the
diff --git a/engines/sword2/console.cpp b/engines/sword2/console.cpp
index 6f4665a34c..bca3cd6184 100644
--- a/engines/sword2/console.cpp
+++ b/engines/sword2/console.cpp
@@ -319,7 +319,7 @@ bool Debugger::Cmd_Starts(int argc, const char **argv) {
}
bool Debugger::Cmd_Start(int argc, const char **argv) {
- uint8 pal[4] = { 255, 255, 255, 0 };
+ uint8 pal[3] = { 255, 255, 255 };
if (argc != 2) {
DebugPrintf("Usage: %s number\n", argv[0]);
diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp
index 5bc82b5f9e..5e570fbaad 100644
--- a/engines/sword2/function.cpp
+++ b/engines/sword2/function.cpp
@@ -1897,11 +1897,11 @@ int32 Logic::fnColour(int32 *params) {
#define GREEN 3
#define BLUE 4
-static const uint8 black[4] = { 0, 0, 0, 0 };
-static const uint8 white[4] = { 255, 255, 255, 0 };
-static const uint8 red[4] = { 255, 0, 0, 0 };
-static const uint8 green[4] = { 0, 255, 0, 0 };
-static const uint8 blue[4] = { 0, 0, 255, 0 };
+static const uint8 black[3] = { 0, 0, 0 };
+static const uint8 white[3] = { 255, 255, 255 };
+static const uint8 red[3] = { 255, 0, 0 };
+static const uint8 green[3] = { 0, 255, 0 };
+static const uint8 blue[3] = { 0, 0, 255 };
#endif
int32 Logic::fnFlash(int32 *params) {
@@ -2163,7 +2163,7 @@ int32 Logic::fnPlaySequence(int32 *params) {
// zero the entire palette in case we're about to fade up!
- byte pal[4 * 256];
+ byte pal[3 * 256];
memset(pal, 0, sizeof(pal));
_vm->_screen->setPalette(0, 256, pal, RDPAL_INSTANT);
diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp
index 7998079944..c8e9387cb7 100644
--- a/engines/sword2/mouse.cpp
+++ b/engines/sword2/mouse.cpp
@@ -1410,8 +1410,8 @@ void Mouse::addHuman() {
// info
if (_vm->_debugger->_testingSnR) {
- uint8 black[4] = { 0, 0, 0, 0 };
- uint8 white[4] = { 255, 255, 255, 0 };
+ uint8 black[3] = { 0, 0, 0 };
+ uint8 white[3] = { 255, 255, 255 };
// Testing logic scripts by simulating instant Save & Restore
diff --git a/engines/sword2/palette.cpp b/engines/sword2/palette.cpp
index 2b9b5b7f49..b348fd6bb5 100644
--- a/engines/sword2/palette.cpp
+++ b/engines/sword2/palette.cpp
@@ -53,7 +53,8 @@ void Screen::startNewPalette() {
if (!Sword2Engine::isPsx())
memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(screenFile), PALTABLESIZE);
- setPalette(0, 256, _vm->fetchPalette(screenFile), RDPAL_FADE);
+ _vm->fetchPalette(screenFile, _palette);
+ setPalette(0, 256, _palette, RDPAL_FADE);
// Indicating that it's a screen palette
_lastPaletteRes = 0;
@@ -110,12 +111,17 @@ void Screen::setFullPalette(int32 palRes) {
// palettes have a bright colour 0 although it should come out
// as black in the game!
- pal[0] = 0;
- pal[1] = 0;
- pal[2] = 0;
- pal[3] = 0;
+ _palette[0] = 0;
+ _palette[1] = 0;
+ _palette[2] = 0;
- setPalette(0, 256, pal, RDPAL_INSTANT);
+ for (uint i = 4, j = 3; i < 4 * 256; i += 4, j += 3) {
+ _palette[j + 0] = pal[i + 0];
+ _palette[j + 1] = pal[i + 1];
+ _palette[j + 2] = pal[i + 2];
+ }
+
+ setPalette(0, 256, _palette, RDPAL_INSTANT);
_vm->_resman->closeResource(palRes);
} else {
if (_thisScreen.background_layer_id) {
@@ -126,7 +132,8 @@ void Screen::setFullPalette(int32 palRes) {
if (!Sword2Engine::isPsx())
memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(data), PALTABLESIZE);
- setPalette(0, 256, _vm->fetchPalette(data), RDPAL_INSTANT);
+ _vm->fetchPalette(data, _palette);
+ setPalette(0, 256, _palette, RDPAL_INSTANT);
_vm->_resman->closeResource(_thisScreen.background_layer_id);
} else
error("setFullPalette(0) called, but no current screen available");
@@ -162,7 +169,7 @@ uint8 Screen::quickMatch(uint8 r, uint8 g, uint8 b) {
void Screen::setPalette(int16 startEntry, int16 noEntries, byte *colourTable, uint8 fadeNow) {
assert(noEntries > 0);
- memcpy(&_palette[4 * startEntry], colourTable, noEntries * 4);
+ memmove(&_palette[3 * startEntry], colourTable, noEntries * 3);
if (fadeNow == RDPAL_INSTANT) {
setSystemPalette(_palette, startEntry, noEntries);
@@ -232,7 +239,7 @@ void Screen::waitForFade() {
void Screen::fadeServer() {
static int32 previousTime = 0;
- byte fadePalette[256 * 4];
+ byte fadePalette[256 * 3];
byte *newPalette = fadePalette;
int32 currentTime;
int16 fadeMultiplier;
@@ -257,9 +264,9 @@ void Screen::fadeServer() {
} else {
fadeMultiplier = (int16)(((int32)(currentTime - _fadeStartTime) * 256) / _fadeTotalTime);
for (i = 0; i < 256; i++) {
- newPalette[i * 4 + 0] = (_palette[i * 4 + 0] * fadeMultiplier) >> 8;
- newPalette[i * 4 + 1] = (_palette[i * 4 + 1] * fadeMultiplier) >> 8;
- newPalette[i * 4 + 2] = (_palette[i * 4 + 2] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 0] = (_palette[i * 3 + 0] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 1] = (_palette[i * 3 + 1] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 2] = (_palette[i * 3 + 2] * fadeMultiplier) >> 8;
}
}
} else {
@@ -269,9 +276,9 @@ void Screen::fadeServer() {
} else {
fadeMultiplier = (int16)(((int32)(_fadeTotalTime - (currentTime - _fadeStartTime)) * 256) / _fadeTotalTime);
for (i = 0; i < 256; i++) {
- newPalette[i * 4 + 0] = (_palette[i * 4 + 0] * fadeMultiplier) >> 8;
- newPalette[i * 4 + 1] = (_palette[i * 4 + 1] * fadeMultiplier) >> 8;
- newPalette[i * 4 + 2] = (_palette[i * 4 + 2] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 0] = (_palette[i * 3 + 0] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 1] = (_palette[i * 3 + 1] * fadeMultiplier) >> 8;
+ newPalette[i * 3 + 2] = (_palette[i * 3 + 2] * fadeMultiplier) >> 8;
}
}
}
@@ -284,9 +291,9 @@ void Screen::setSystemPalette(const byte *colors, uint start, uint num) {
const byte *palette;
if (_dimPalette) {
- byte pal[256 * 4];
+ byte pal[256 * 3];
- for (uint i = start * 4; i < 4 * (start + num); i++)
+ for (uint i = start * 3; i < 3 * (start + num); i++)
pal[i] = colors[i] / 2;
palette = pal;
diff --git a/engines/sword2/protocol.cpp b/engines/sword2/protocol.cpp
index 6c47c07401..ef2c622287 100644
--- a/engines/sword2/protocol.cpp
+++ b/engines/sword2/protocol.cpp
@@ -40,7 +40,7 @@ namespace Sword2 {
* of the screen file.
*/
-byte *Sword2Engine::fetchPalette(byte *screenFile) {
+void Sword2Engine::fetchPalette(byte *screenFile, byte *palBuffer) {
byte *palette;
if (isPsx()) { // PSX version doesn't have a "MultiScreenHeader", instead there's a ScreenHeader and a tag
@@ -56,12 +56,15 @@ byte *Sword2Engine::fetchPalette(byte *screenFile) {
// palettes have a bright colour 0 it should come out as black in the
// game.
- palette[0] = 0;
- palette[1] = 0;
- palette[2] = 0;
- palette[3] = 0;
+ palBuffer[0] = 0;
+ palBuffer[1] = 0;
+ palBuffer[2] = 0;
- return palette;
+ for (uint i = 4, j = 3; i < 4 * 256; i += 4, j += 3) {
+ palBuffer[j + 0] = palette[i + 0];
+ palBuffer[j + 1] = palette[i + 1];
+ palBuffer[j + 2] = palette[i + 2];
+ }
}
/**
diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp
index 99295be571..a71d503d95 100644
--- a/engines/sword2/render.cpp
+++ b/engines/sword2/render.cpp
@@ -194,21 +194,21 @@ void Screen::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16
}
if (!transparent) {
- uint32 r1 = _palette[c1 * 4 + 0];
- uint32 g1 = _palette[c1 * 4 + 1];
- uint32 b1 = _palette[c1 * 4 + 2];
+ uint32 r1 = _palette[c1 * 3 + 0];
+ uint32 g1 = _palette[c1 * 3 + 1];
+ uint32 b1 = _palette[c1 * 3 + 2];
- uint32 r2 = _palette[c2 * 4 + 0];
- uint32 g2 = _palette[c2 * 4 + 1];
- uint32 b2 = _palette[c2 * 4 + 2];
+ uint32 r2 = _palette[c2 * 3 + 0];
+ uint32 g2 = _palette[c2 * 3 + 1];
+ uint32 b2 = _palette[c2 * 3 + 2];
- uint32 r3 = _palette[c3 * 4 + 0];
- uint32 g3 = _palette[c3 * 4 + 1];
- uint32 b3 = _palette[c3 * 4 + 2];
+ uint32 r3 = _palette[c3 * 3 + 0];
+ uint32 g3 = _palette[c3 * 3 + 1];
+ uint32 b3 = _palette[c3 * 3 + 2];
- uint32 r4 = _palette[c4 * 4 + 0];
- uint32 g4 = _palette[c4 * 4 + 1];
- uint32 b4 = _palette[c4 * 4 + 2];
+ uint32 r4 = _palette[c4 * 3 + 0];
+ uint32 g4 = _palette[c4 * 3 + 1];
+ uint32 b4 = _palette[c4 * 3 + 2];
uint32 r5 = (r1 * xFrac + r2 * (dstWidth - xFrac)) / dstWidth;
uint32 g5 = (g1 * xFrac + g2 * (dstWidth - xFrac)) / dstWidth;
diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp
index 1e45c0fc1f..8c2db79297 100644
--- a/engines/sword2/screen.cpp
+++ b/engines/sword2/screen.cpp
@@ -355,8 +355,8 @@ void Screen::buildDisplay() {
*/
void Screen::displayMsg(byte *text, int time) {
- byte pal[256 * 4];
- byte oldPal[256 * 4];
+ byte pal[256 * 3];
+ byte oldPal[256 * 3];
debug(2, "DisplayMsg: %s", text);
@@ -402,9 +402,9 @@ void Screen::displayMsg(byte *text, int time) {
memcpy(oldPal, _palette, sizeof(oldPal));
memset(pal, 0, sizeof(pal));
- pal[187 * 4 + 0] = 255;
- pal[187 * 4 + 1] = 255;
- pal[187 * 4 + 2] = 255;
+ pal[187 * 3 + 0] = 255;
+ pal[187 * 3 + 1] = 255;
+ pal[187 * 3 + 2] = 255;
setPalette(0, 256, pal, RDPAL_FADE);
fadeUp();
@@ -926,17 +926,16 @@ void Screen::rollCredits() {
uint16 logoWidth = 0;
uint16 logoHeight = 0;
byte *logoData = NULL;
- byte palette[256 * 4];
+ byte palette[256 * 3];
if (f.open("credits.bmp")) {
logoWidth = f.readUint16LE();
logoHeight = f.readUint16LE();
for (i = 0; i < 256; i++) {
- palette[i * 4 + 0] = f.readByte() << 2;
- palette[i * 4 + 1] = f.readByte() << 2;
- palette[i * 4 + 2] = f.readByte() << 2;
- palette[i * 4 + 3] = 0;
+ palette[i * 3 + 0] = f.readByte() << 2;
+ palette[i * 3 + 1] = f.readByte() << 2;
+ palette[i * 3 + 2] = f.readByte() << 2;
}
logoData = (byte *)malloc(logoWidth * logoHeight);
@@ -946,10 +945,9 @@ void Screen::rollCredits() {
} else {
warning("Can't find credits.bmp");
memset(palette, 0, sizeof(palette));
- palette[14 * 4 + 0] = 252;
- palette[14 * 4 + 1] = 252;
- palette[14 * 4 + 2] = 252;
- palette[14 * 4 + 3] = 0;
+ palette[14 * 3 + 0] = 252;
+ palette[14 * 3 + 1] = 252;
+ palette[14 * 3 + 2] = 252;
}
setPalette(0, 256, palette, RDPAL_INSTANT);
@@ -1235,7 +1233,8 @@ void Screen::splashScreen() {
initialiseBackgroundLayer(NULL);
initialiseBackgroundLayer(NULL);
- setPalette(0, 256, _vm->fetchPalette(bgfile), RDPAL_FADE);
+ _vm->fetchPalette(bgfile, _palette);
+ setPalette(0, 256, _palette, RDPAL_FADE);
renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);
closeBackgroundLayer();
diff --git a/engines/sword2/screen.h b/engines/sword2/screen.h
index 0abaebc5af..46eb53d0db 100644
--- a/engines/sword2/screen.h
+++ b/engines/sword2/screen.h
@@ -242,7 +242,7 @@ private:
uint16 _gridWide;
uint16 _gridDeep;
- byte _palette[256 * 4];
+ byte _palette[256 * 3];
byte _paletteMatch[PALTABLESIZE];
uint8 _fadeStatus;
diff --git a/engines/sword2/sprite.cpp b/engines/sword2/sprite.cpp
index 7d45f8df4e..255176292a 100644
--- a/engines/sword2/sprite.cpp
+++ b/engines/sword2/sprite.cpp
@@ -747,9 +747,9 @@ int32 Screen::drawSprite(SpriteInfo *s) {
for (i = 0; i < rs.height(); i++) {
for (j = 0; j < rs.width(); j++) {
if (src[j] && lightMap[j]) {
- uint8 r = ((32 - lightMap[j]) * _palette[src[j] * 4 + 0]) >> 5;
- uint8 g = ((32 - lightMap[j]) * _palette[src[j] * 4 + 1]) >> 5;
- uint8 b = ((32 - lightMap[j]) * _palette[src[j] * 4 + 2]) >> 5;
+ uint8 r = ((32 - lightMap[j]) * _palette[src[j] * 3 + 0]) >> 5;
+ uint8 g = ((32 - lightMap[j]) * _palette[src[j] * 3 + 1]) >> 5;
+ uint8 b = ((32 - lightMap[j]) * _palette[src[j] * 3 + 2]) >> 5;
src[j] = quickMatch(r, g, b);
}
}
@@ -787,12 +787,12 @@ int32 Screen::drawSprite(SpriteInfo *s) {
for (i = 0; i < rs.height(); i++) {
for (j = 0; j < rs.width(); j++) {
if (src[j]) {
- uint8 r1 = _palette[src[j] * 4 + 0];
- uint8 g1 = _palette[src[j] * 4 + 1];
- uint8 b1 = _palette[src[j] * 4 + 2];
- uint8 r2 = _palette[dst[j] * 4 + 0];
- uint8 g2 = _palette[dst[j] * 4 + 1];
- uint8 b2 = _palette[dst[j] * 4 + 2];
+ uint8 r1 = _palette[src[j] * 3 + 0];
+ uint8 g1 = _palette[src[j] * 3 + 1];
+ uint8 b1 = _palette[src[j] * 3 + 2];
+ uint8 r2 = _palette[dst[j] * 3 + 0];
+ uint8 g2 = _palette[dst[j] * 3 + 1];
+ uint8 b2 = _palette[dst[j] * 3 + 2];
uint8 r = (r1 * n + r2 * (8 - n)) >> 3;
uint8 g = (g1 * n + g2 * (8 - n)) >> 3;
diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h
index 302627b635..e741c51ce1 100644
--- a/engines/sword2/sword2.h
+++ b/engines/sword2/sword2.h
@@ -206,7 +206,7 @@ public:
bool heldIsInInventory();
#endif
- byte *fetchPalette(byte *screenFile);
+ void fetchPalette(byte *screenFile, byte *palBuffer);
byte *fetchScreenHeader(byte *screenFile);
byte *fetchLayerHeader(byte *screenFile, uint16 layerNo);
byte *fetchShadingMask(byte *screenFile);
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 4b37576846..f9756b5b91 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -1177,12 +1177,10 @@ bool Scene::processEventQueue() {
void Scene::setPalette(unsigned mul) {
//debug(0, "setPalette(%u)", mul);
- byte p[1024];
+ byte p[3*256];
- memset(p, 0, 1024);
- for (int i = 0; i < 256; ++i) {
- for (int c = 0; c < 3; ++c)
- p[i * 4 + c] = (unsigned)palette[i * 3 + c] * mul;
+ for (int i = 0; i < 3*256; ++i) {
+ p[i] = (unsigned)palette[i] * mul;
}
_system->getPaletteManager()->setPalette(p, 0, 256);
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index a492237adb..e66de70079 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -290,18 +290,12 @@ bool TeenAgentEngine::showCDLogo() {
return true;
byte bg[0xfa00];
- byte palette[0x400];
+ byte palette[3*256];
cdlogo.read(bg, sizeof(bg));
- memset(palette, 0, sizeof(palette));
-
- for(uint c = 0; c < 0x100; ++c) {
- uint idx = c * 4;
- cdlogo.read(palette + idx, 3);
- palette[idx] *= 4;
- palette[idx + 1] *= 4;
- palette[idx + 2] *= 4;
- }
+ cdlogo.read(palette, sizeof(palette));
+ for (uint c = 0; c < 3*256; ++c)
+ palette[c] *= 4;
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
_system->copyRectToScreen(bg, 320, 0, 0, 320, 200);
_system->updateScreen();
@@ -323,22 +317,16 @@ bool TeenAgentEngine::showLogo() {
return true;
byte bg[0xfa00];
- byte palette[0x400];
+ byte palette[3*256];
Common::ScopedPtr<Common::SeekableReadStream> frame(logo.getStream(1));
if (!frame)
return true;
frame->read(bg, sizeof(bg));
- memset(palette, 0, sizeof(palette));
-
- for(uint c = 0; c < 0x100; ++c) {
- uint idx = c * 4;
- frame->read(palette + idx, 3);
- palette[idx] *= 4;
- palette[idx + 1] *= 4;
- palette[idx + 2] *= 4;
- }
+ frame->read(palette, sizeof(palette));
+ for (uint c = 0; c < 3*256; ++c)
+ palette[c] *= 4;
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
uint n = logo.fileCount();
@@ -375,16 +363,12 @@ bool TeenAgentEngine::showMetropolis() {
FilePack varia;
varia.open("varia.res");
- byte palette[0x400];
- memset(palette, 0, sizeof(palette));
+ byte palette[3*256];
{
Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(5));
- for(uint c = 0; c < 0x400; c += 4) {
- s->read(palette + c, 3);
+ s->read(palette, sizeof(palette));
+ for (uint c = 0; c < 3*256; ++c)
palette[c] *= 4;
- palette[c + 1] *= 4;
- palette[c + 2] *= 4;
- }
}
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index ed51b33e94..a0e2754fe4 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -38,7 +38,7 @@
namespace Testbed {
-byte GFXTestSuite::_palette[256 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0};
+byte GFXTestSuite::_palette[256 * 3] = {0, 0, 0, 255, 255, 255, 255, 255, 255};
GFXTestSuite::GFXTestSuite() {
// Initialize color palettes
@@ -79,12 +79,12 @@ GFXTestSuite::GFXTestSuite() {
}
void GFXTestSuite::setCustomColor(uint r, uint g, uint b) {
- _palette[8] = r;
- _palette[9] = g;
- _palette[10] = b;
+ _palette[6] = r;
+ _palette[7] = g;
+ _palette[8] = b;
// Set colorNum kColorSpecial with a special color.
- int absIndx = kColorSpecial * 4;
+ int absIndx = kColorSpecial * 3;
_palette[absIndx + 1] = 173;
_palette[absIndx + 2] = 255;
_palette[absIndx + 3] = 47;
@@ -94,12 +94,12 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) {
// Helper functions used by GFX tests
void GFXtests::initMousePalette() {
- byte palette[3 * 4]; // Black, white and yellow
+ byte palette[3 * 3]; // Black, white and yellow
palette[0] = palette[1] = palette[2] = 0;
- palette[4] = palette[5] = palette[6] = 255;
- palette[8] = palette[9] = 255;
- palette[10] = 0;
+ palette[3] = palette[4] = palette[5] = 255;
+ palette[6] = palette[7] = 255;
+ palette[8] = 0;
CursorMan.replaceCursorPalette(palette, 0, 3);
}
@@ -968,14 +968,14 @@ TestExitStatus GFXtests::paletteRotation() {
Testsuite::clearEntireScreen();
// Use 256 colors
- byte palette[256 * 4] = {0};
+ byte palette[256 * 3] = {0};
int r, g, b;
int colIndx;
for (int i = 0; i < 256; i++) {
HSVtoRGB(r, g, b, i, 1, 1);
- colIndx = i * 4;
+ colIndx = i * 3;
palette[colIndx] = r;
palette[colIndx + 1] = g;
palette[colIndx + 2] = b;
diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h
index 4ab4ba65ab..01c76efea5 100644
--- a/engines/testbed/graphics.h
+++ b/engines/testbed/graphics.h
@@ -86,7 +86,7 @@ private:
* 2 (R:255, G:255, B:255) your customized color (by default white) (kColorCustom)
* The remaining values are zero
*/
- static byte _palette[256 * 4];
+ static byte _palette[256 * 3];
};
} // End of namespace Testbed
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index 7cc6564832..a0ceec54eb 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -133,6 +133,7 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {
void PalettesToVideoDAC() {
PALQ *pPalQ; // palette Q iterator
VIDEO_DAC_Q *pDACtail = vidDACdata; // set tail pointer
+ byte pal[768];
// while Q is not empty
while (pDAChead != pDACtail) {
@@ -164,8 +165,14 @@ void PalettesToVideoDAC() {
pColours = pDACtail->pal.pRGBarray;
}
+ for (int i = 0; i < pDACtail->numColours; ++i) {
+ pal[i * 3 + 0] = TINSEL_GetRValue(pColours[i]);
+ pal[i * 3 + 1] = TINSEL_GetGValue(pColours[i]);
+ pal[i * 3 + 2] = TINSEL_GetBValue(pColours[i]);
+ }
+
// update the system palette
- g_system->getPaletteManager()->setPalette((const byte *)pColours, pDACtail->destDACindex, pDACtail->numColours);
+ g_system->getPaletteManager()->setPalette(pal, pDACtail->destDACindex, pDACtail->numColours);
// update tail pointer
pDACtail++;
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index d2b98c2ed0..d65230df85 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -927,14 +927,7 @@ void ToonEngine::flushPalette(bool deferFlushToNextRender) {
return;
}
_needPaletteFlush = false;
- uint8 vmpalette[1024];
- for (int32 i = 0; i < 256; i++) {
- vmpalette[i*4+0] = _finalPalette[i*3+0];
- vmpalette[i*4+1] = _finalPalette[i*3+1];
- vmpalette[i*4+2] = _finalPalette[i*3+2];
- vmpalette[i*4+3] = 0;
- }
- _system->getPaletteManager()->setPalette(vmpalette, 0, 256);
+ _system->getPaletteManager()->setPalette(_finalPalette, 0, 256);
}
void ToonEngine::setPaletteEntries(uint8 *palette, int32 offset, int32 num) {
memcpy(_finalPalette + offset * 3, palette, num * 3);
@@ -1755,12 +1748,11 @@ void ToonEngine::flipScreens() {
void ToonEngine::fadeIn(int32 numFrames) {
for (int32 f = 0; f < numFrames; f++) {
- uint8 vmpalette[1024];
+ uint8 vmpalette[3 * 256];
for (int32 i = 0; i < 256; i++) {
- vmpalette[i*4+0] = f * _finalPalette[i*3+0] / (numFrames - 1);
- vmpalette[i*4+1] = f * _finalPalette[i*3+1] / (numFrames - 1);
- vmpalette[i*4+2] = f * _finalPalette[i*3+2] / (numFrames - 1);
- vmpalette[i*4+3] = 0;
+ vmpalette[i*3+0] = f * _finalPalette[i*3+0] / (numFrames - 1);
+ vmpalette[i*3+1] = f * _finalPalette[i*3+1] / (numFrames - 1);
+ vmpalette[i*3+2] = f * _finalPalette[i*3+2] / (numFrames - 1);
}
_system->getPaletteManager()->setPalette(vmpalette, 0, 256);
_system->updateScreen();
@@ -1770,16 +1762,15 @@ void ToonEngine::fadeIn(int32 numFrames) {
void ToonEngine::fadeOut(int32 numFrames) {
- uint8 oldpalette[1024];
+ uint8 oldpalette[3 * 256];
_system->getPaletteManager()->grabPalette(oldpalette, 0, 256);
for (int32 f = 0; f < numFrames; f++) {
- uint8 vmpalette[1024];
+ uint8 vmpalette[3 * 256];
for (int32 i = 0; i < 256; i++) {
- vmpalette[i*4+0] = (numFrames - f - 1) * oldpalette[i*4+0] / (numFrames - 1);
- vmpalette[i*4+1] = (numFrames - f - 1) * oldpalette[i*4+1] / (numFrames - 1);
- vmpalette[i*4+2] = (numFrames - f - 1) * oldpalette[i*4+2] / (numFrames - 1);
- vmpalette[i*4+3] = 255;
+ vmpalette[i*3+0] = (numFrames - f - 1) * oldpalette[i*3+0] / (numFrames - 1);
+ vmpalette[i*3+1] = (numFrames - f - 1) * oldpalette[i*3+1] / (numFrames - 1);
+ vmpalette[i*3+2] = (numFrames - f - 1) * oldpalette[i*3+2] / (numFrames - 1);
}
_system->getPaletteManager()->setPalette(vmpalette, 0, 256);
_system->updateScreen();
diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp
index df7992f26c..3c108e2931 100644
--- a/engines/touche/resource.cpp
+++ b/engines/touche/resource.cpp
@@ -423,10 +423,7 @@ void ToucheEngine::res_loadRoom(int num) {
_fData.skip(2);
const int roomImageNum = _fData.readUint16LE();
_fData.skip(2);
- for (int i = 0; i < 256; ++i) {
- _fData.read(&_paletteBuffer[i * 4], 3);
- _paletteBuffer[i * 4 + 3] = 0;
- }
+ _fData.read(_paletteBuffer, 3 * 256);
const uint32 offsImage = res_getDataOffset(kResourceTypeRoomImage, roomImageNum);
_fData.seek(offsImage);
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index ff8b0d944e..97d533f29f 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -3243,23 +3243,21 @@ void ToucheEngine::clearDirtyRects() {
}
void ToucheEngine::setPalette(int firstColor, int colorCount, int rScale, int gScale, int bScale) {
- uint8 pal[256 * 4];
+ uint8 pal[256 * 3];
for (int i = firstColor; i < firstColor + colorCount; ++i) {
- int r = _paletteBuffer[i * 4 + 0];
+ int r = _paletteBuffer[i * 3 + 0];
r = (r * rScale) >> 8;
- pal[i * 4 + 0] = (uint8)r;
+ pal[i * 3 + 0] = (uint8)r;
- int g = _paletteBuffer[i * 4 + 1];
+ int g = _paletteBuffer[i * 3 + 1];
g = (g * gScale) >> 8;
- pal[i * 4 + 1] = (uint8)g;
+ pal[i * 3 + 1] = (uint8)g;
- int b = _paletteBuffer[i * 4 + 2];
+ int b = _paletteBuffer[i * 3 + 2];
b = (b * bScale) >> 8;
- pal[i * 4 + 2] = (uint8)b;
-
- pal[i * 4 + 3] = 0;
+ pal[i * 3 + 2] = (uint8)b;
}
- _system->getPaletteManager()->setPalette(&pal[firstColor * 4], firstColor, colorCount);
+ _system->getPaletteManager()->setPalette(&pal[firstColor * 3], firstColor, colorCount);
}
void ToucheEngine::updateScreenArea(int x, int y, int w, int h) {
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 8b5f14d926..1580d072e6 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -781,7 +781,7 @@ protected:
int _fullRedrawCounter;
int _menuRedrawCounter;
uint8 *_offscreenBuffer;
- uint8 _paletteBuffer[256 * 4];
+ uint8 _paletteBuffer[256 * 3];
Common::Rect _dirtyRectsTable[NUM_DIRTY_RECTS];
int _dirtyRectsTableCount;
diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp
index cd99656695..108c6bcad5 100644
--- a/engines/tucker/locations.cpp
+++ b/engines/tucker/locations.cpp
@@ -1791,11 +1791,11 @@ void TuckerEngine::execData3PreUpdate_locationNum29() {
_updateLocationFadePaletteCounter = 0;
}
const int d = _updateLocationFadePaletteCounter / 2;
- uint8 scrollPal[5 * 4];
+ uint8 scrollPal[5 * 3];
for (int i = 0; i < 5; ++i) {
- scrollPal[i * 4] = r[i + d];
- scrollPal[i * 4 + 1] = g[i + d];
- scrollPal[i * 4 + 2] = b[i + d];
+ scrollPal[i * 3] = r[i + d];
+ scrollPal[i * 3 + 1] = g[i + d];
+ scrollPal[i * 3 + 2] = b[i + d];
}
_system->getPaletteManager()->setPalette(scrollPal, 118, 5);
if (_flagsTable[143] == 1) {
diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp
index 40706aee0f..5e99e3ccef 100644
--- a/engines/tucker/sequences.cpp
+++ b/engines/tucker/sequences.cpp
@@ -677,14 +677,14 @@ void AnimationSequencePlayer::updateSounds() {
}
void AnimationSequencePlayer::fadeInPalette() {
- uint8 paletteBuffer[256 * 4];
+ uint8 paletteBuffer[256 * 3];
memset(paletteBuffer, 0, sizeof(paletteBuffer));
bool fadeColors = true;
for (int step = 0; step < 64; ++step) {
if (fadeColors) {
fadeColors = false;
- for (int i = 0; i < 1024; ++i) {
- if ((i & 3) != 3 && paletteBuffer[i] < _animationPalette[i]) {
+ for (int i = 0; i < 3*256; ++i) {
+ if (paletteBuffer[i] < _animationPalette[i]) {
const int color = paletteBuffer[i] + 4;
paletteBuffer[i] = MIN<int>(color, _animationPalette[i]);
fadeColors = true;
@@ -698,14 +698,14 @@ void AnimationSequencePlayer::fadeInPalette() {
}
void AnimationSequencePlayer::fadeOutPalette() {
- uint8 paletteBuffer[256 * 4];
- memcpy(paletteBuffer, _animationPalette, 1024);
+ uint8 paletteBuffer[256 * 3];
+ memcpy(paletteBuffer, _animationPalette, 3*256);
bool fadeColors = true;
for (int step = 0; step < 64; ++step) {
if (fadeColors) {
fadeColors = false;
- for (int i = 0; i < 1024; ++i) {
- if ((i & 3) != 3 && paletteBuffer[i] > 0) {
+ for (int i = 0; i < 3*256; ++i) {
+ if (paletteBuffer[i] > 0) {
const int color = paletteBuffer[i] - 4;
paletteBuffer[i] = MAX<int>(0, color);
fadeColors = true;
@@ -741,13 +741,7 @@ uint8 *AnimationSequencePlayer::loadPicture(const char *fileName) {
}
void AnimationSequencePlayer::getRGBPalette(int index) {
- const byte *rgbPalette = _flicPlayer[index].getPalette();
- for (int i = 0; i < 256; i++) {
- _animationPalette[i * 4 + 0] = rgbPalette[i * 3 + 0];
- _animationPalette[i * 4 + 1] = rgbPalette[i * 3 + 1];
- _animationPalette[i * 4 + 2] = rgbPalette[i * 3 + 2];
- _animationPalette[i * 4 + 3] = 0;
- }
+ memcpy(_animationPalette, _flicPlayer[index].getPalette(), 3 * 256);
}
void AnimationSequencePlayer::openAnimation(int index, const char *fileName) {
@@ -827,9 +821,7 @@ void AnimationSequencePlayer::displayLoadingScreen() {
if (f.open("graphics/loading.pic")) {
fadeOutPalette();
f.seek(32);
- for (int i = 0; i < 1024; i += 4) {
- f.read(_animationPalette + i, 3);
- }
+ f.read(_animationPalette, 3 * 256);
f.read(_offscreenBuffer, 64000);
_system->copyRectToScreen(_offscreenBuffer, 320, 0, 0, kScreenWidth, kScreenHeight);
fadeInPalette();
@@ -846,12 +838,7 @@ void AnimationSequencePlayer::initPicPart4() {
void AnimationSequencePlayer::drawPicPart4() {
static const uint8 offsets[] = { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 };
if (_updateScreenIndex == -1) {
- for (int i = 0; i < 256; ++i) {
- if (memcmp(_animationPalette + i * 4, _picBufPtr + 32 + i * 3, 3) != 0) {
- memcpy(_animationPalette + i * 4, _picBufPtr + 32 + i * 3, 3);
- _animationPalette[i * 4 + 3] = 0;
- }
- }
+ memcpy(_animationPalette, _picBufPtr + 32, 3 * 256);
}
if (_updateScreenCounter == 0) {
static const uint8 counter[] = { 1, 2, 3, 4, 5, 35, 5, 4, 3, 2, 1 };
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp
index d4afdaba56..6e44eadc47 100644
--- a/engines/tucker/tucker.cpp
+++ b/engines/tucker/tucker.cpp
@@ -933,12 +933,12 @@ void TuckerEngine::updateFlagsForCharPosition() {
}
void TuckerEngine::fadeOutPalette(int colorsCount) {
- uint8 pal[256 * 4];
+ uint8 pal[256 * 3];
_system->getPaletteManager()->grabPalette(pal, 0, colorsCount);
for (int color = 0; color < colorsCount; ++color) {
for (int i = 0; i < 3; ++i) {
- const int c = int(pal[color * 4 + i]) + kFadePaletteStep * 4;
- pal[color * 4 + i] = MIN<int>(c, _currentPalette[color * 3 + i]);
+ const int c = int(pal[color * 3 + i]) + kFadePaletteStep * 3;
+ pal[color * 3 + i] = MIN<int>(c, _currentPalette[color * 3 + i]);
}
}
_system->getPaletteManager()->setPalette(pal, 0, colorsCount);
@@ -946,12 +946,12 @@ void TuckerEngine::fadeOutPalette(int colorsCount) {
}
void TuckerEngine::fadeInPalette(int colorsCount) {
- uint8 pal[256 * 4];
+ uint8 pal[256 * 3];
_system->getPaletteManager()->grabPalette(pal, 0, colorsCount);
for (int color = 0; color < colorsCount; ++color) {
for (int i = 0; i < 3; ++i) {
- const int c = int(pal[color * 4 + i]) - kFadePaletteStep * 4;
- pal[color * 4 + i] = MAX<int>(c, 0);
+ const int c = int(pal[color * 3 + i]) - kFadePaletteStep * 3;
+ pal[color * 3 + i] = MAX<int>(c, 0);
}
}
_system->getPaletteManager()->setPalette(pal, 0, colorsCount);
@@ -969,7 +969,7 @@ void TuckerEngine::fadePaletteColor(int color, int step) {
}
void TuckerEngine::setBlackPalette() {
- uint8 pal[256 * 4];
+ uint8 pal[256 * 3];
memset(pal, 0, sizeof(pal));
_system->getPaletteManager()->setPalette(pal, 0, 256);
}
diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h
index 6488bbc215..fd931998e4 100644
--- a/engines/tucker/tucker.h
+++ b/engines/tucker/tucker.h
@@ -975,7 +975,7 @@ private:
const SequenceUpdateFunc *_updateFunc;
int _updateFuncIndex;
Video::FlicDecoder _flicPlayer[2];
- uint8 _animationPalette[256 * 4];
+ uint8 _animationPalette[256 * 3];
int _soundSeqDataCount;
int _soundSeqDataIndex;
const SoundSequenceData *_soundSeqData;