aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agos/agos.h4
-rw-r--r--engines/agos/animation.cpp2
-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/made/screen.cpp2
-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--video/video_decoder.cpp13
28 files changed, 152 insertions, 169 deletions
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/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/made/screen.cpp b/engines/made/screen.cpp
index b76ff15851..2649e2bd37 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -218,7 +218,7 @@ void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 f
}
void Screen::setRGBPalette(byte *palRGB, int start, int count) {
- _vm->_system->getPaletteManager()->setPalette(palRGB + start * 3, start, count);
+ _vm->_system->getPaletteManager()->setPalette(palRGB, start, count);
}
uint16 Screen::updateChannel(uint16 channelIndex) {
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/video/video_decoder.cpp b/video/video_decoder.cpp
index 3f23d83761..a6317bac8f 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -50,18 +50,7 @@ uint32 VideoDecoder::getElapsedTime() const {
}
void VideoDecoder::setSystemPalette() {
- const byte *vidPalette = getPalette();
- byte *sysPalette = new byte[256 * 4];
-
- for (uint16 i = 0; i < 256; i++) {
- sysPalette[i * 4] = vidPalette[i * 3];
- sysPalette[i * 4 + 1] = vidPalette[i * 3 + 1];
- sysPalette[i * 4 + 2] = vidPalette[i * 3 + 2];
- sysPalette[i * 4 + 3] = 0;
- }
-
- g_system->getPaletteManager()->setPalette(sysPalette, 0, 256);
- delete[] sysPalette;
+ g_system->getPaletteManager()->setPalette(getPalette(), 0, 256);
}
bool VideoDecoder::needsUpdate() const {