mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 08:25:35 +00:00
SWORD2: Adapt to setPalette/grabPalette RGBA->RGB change.
Thanks to eriktorbjorn for helping me with this.
This commit is contained in:
parent
3b9da7f03b
commit
74e4b5a6cd
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -242,7 +242,7 @@ private:
|
||||
uint16 _gridWide;
|
||||
uint16 _gridDeep;
|
||||
|
||||
byte _palette[256 * 4];
|
||||
byte _palette[256 * 3];
|
||||
byte _paletteMatch[PALTABLESIZE];
|
||||
|
||||
uint8 _fadeStatus;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user