diff options
author | Johannes Schickel | 2011-02-15 22:52:15 +0100 |
---|---|---|
committer | Johannes Schickel | 2011-02-15 22:52:15 +0100 |
commit | 74e4b5a6cdada50fcf5ab32f73da16c356a1d16a (patch) | |
tree | 3ec22145ddbf2b56d22079fbd011c33d96840079 /engines | |
parent | 3b9da7f03b52c57c66ba79cc28d60ffdda5ec970 (diff) | |
download | scummvm-rg350-74e4b5a6cdada50fcf5ab32f73da16c356a1d16a.tar.gz scummvm-rg350-74e4b5a6cdada50fcf5ab32f73da16c356a1d16a.tar.bz2 scummvm-rg350-74e4b5a6cdada50fcf5ab32f73da16c356a1d16a.zip |
SWORD2: Adapt to setPalette/grabPalette RGBA->RGB change.
Thanks to eriktorbjorn for helping me with this.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sword2/console.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/function.cpp | 12 | ||||
-rw-r--r-- | engines/sword2/mouse.cpp | 4 | ||||
-rw-r--r-- | engines/sword2/palette.cpp | 41 | ||||
-rw-r--r-- | engines/sword2/protocol.cpp | 15 | ||||
-rw-r--r-- | engines/sword2/render.cpp | 24 | ||||
-rw-r--r-- | engines/sword2/screen.cpp | 29 | ||||
-rw-r--r-- | engines/sword2/screen.h | 2 | ||||
-rw-r--r-- | engines/sword2/sprite.cpp | 18 | ||||
-rw-r--r-- | engines/sword2/sword2.h | 2 |
10 files changed, 79 insertions, 70 deletions
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); |