Skip to content

Commit

Permalink
M4: Updated for OSystem Palette RGBA->RGB Change.
Browse files Browse the repository at this point in the history
  • Loading branch information
digitall committed Feb 20, 2011
1 parent 292f197 commit 10e2cec
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions engines/m4/dialogs.cpp
Expand Up @@ -43,8 +43,8 @@ static void strToLower(char *s) {
}

const RGB8 DIALOG_PALETTE[8] = {
{0x80, 0x80, 0x80, 0xff}, {0x90, 0x90, 0x90, 0xff}, {0x70, 0x70, 0x70, 0xff}, {0x9c, 0x9c, 0x9c, 0xff},
{0x80, 0x80, 0x80, 0xff}, {0x90, 0x90, 0x90, 0xff}, {0xDC, 0xDC, 0xDC, 0xff}, {0x00, 0x00, 0x00, 0xff}
{0x80, 0x80, 0x80}, {0x90, 0x90, 0x90}, {0x70, 0x70, 0x70}, {0x9c, 0x9c, 0x9c},
{0x80, 0x80, 0x80}, {0x90, 0x90, 0x90}, {0xDC, 0xDC, 0xDC}, {0x00, 0x00, 0x00}
};

#define ROR16(v,amt) (((uint16)(v) >> amt) | ((uint16)(v) << (16 - amt)))
Expand Down
7 changes: 5 additions & 2 deletions engines/m4/graphics.cpp
Expand Up @@ -795,7 +795,11 @@ void M4Surface::m4LoadBackground(Common::SeekableReadStream *source) {
palette[i].b = source->readByte() << 2;
palette[i].g = source->readByte() << 2;
palette[i].r = source->readByte() << 2;
palette[i].u = source->readByte() << 2;
// FIXME - Removed u field from RGB8 as the OSystem palette is now RGB.
// If this is needed, then the system setPalette() call will need changing to skip this.
uint8 u = source->readByte() << 2;
if (u != 0)
debugC(1, kDebugGraphics, "Unused u field in Palette data non-zero: %d", u);

if ((blackIndex == 0) && !palette[i].r && !palette[i].g && !palette[i].b)
blackIndex = i;
Expand Down Expand Up @@ -1049,7 +1053,6 @@ void Palette::setEntry(uint index, uint8 r, uint8 g, uint8 b) {
c.r = r;
c.g = g;
c.b = b;
c.u = 255;
g_system->getPaletteManager()->setPalette((const byte *)&c, index, 1);
}

Expand Down
6 changes: 3 additions & 3 deletions engines/m4/graphics.h
Expand Up @@ -47,7 +47,7 @@ struct BGR8 {
};

struct RGB8 {
uint8 r, g, b, u;
uint8 r, g, b;
};

//later use ScummVM's Rect?
Expand Down Expand Up @@ -214,8 +214,8 @@ class Palette {
MadsM4Engine *_vm;
bool _colorsChanged;
bool _fading_in_progress;
byte _originalPalette[256 * 4];
byte _fadedPalette[256 * 4];
byte _originalPalette[256 * 3];
byte _fadedPalette[256 * 3];
int _usageCount[256];

void reset();
Expand Down
4 changes: 2 additions & 2 deletions engines/m4/mads_scene.cpp
Expand Up @@ -111,8 +111,8 @@ void MadsScene::loadSceneTemporary() {
/* Existing code that eventually needs to be replaced with the proper MADS code */
// Set system palette entries
_vm->_palette->blockRange(0, 18);
RGB8 sysColors[3] = { {0x1f<<2, 0x2d<<2, 0x31<<2, 0}, {0x24<<2, 0x37<<2, 0x3a<<2, 0},
{0x00<<2, 0x10<<2, 0x16<<2, 0}};
RGB8 sysColors[3] = { {0x1f<<2, 0x2d<<2, 0x31<<2}, {0x24<<2, 0x37<<2, 0x3a<<2},
{0x00<<2, 0x10<<2, 0x16<<2}};
_vm->_palette->setPalette(&sysColors[0], 4, 3);

_interfaceSurface->initialise();
Expand Down
8 changes: 4 additions & 4 deletions engines/m4/scene.cpp
Expand Up @@ -149,11 +149,11 @@ void Scene::showCodes() {
for (int i = 0; i < _walkSurface->width() * _walkSurface->height(); i++)
destP[i] = (srcP[i] & 0x10) ? 0xFF : 0;

byte colors[256 * 4];
byte colors[256 * 3];
memset(colors, 0, sizeof(colors));
colors[255 * 4 + 0] = 255;
colors[255 * 4 + 1] = 255;
colors[255 * 4 + 2] = 255;
colors[255 * 3 + 0] = 255;
colors[255 * 3 + 1] = 255;
colors[255 * 3 + 2] = 255;
_vm->_palette->setPalette(colors, 0, 256);
} else {
// MADS handling
Expand Down
8 changes: 4 additions & 4 deletions engines/m4/woodscript.cpp
Expand Up @@ -321,12 +321,12 @@ void WoodScript::update() {

{
// FIXME: This should be done when a new palette is set
byte palette[1024];
byte palette[768];
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
for (int i = 0; i < 256; i++) {
_mainPalette[i].r = palette[i * 4 + 0];
_mainPalette[i].g = palette[i * 4 + 1];
_mainPalette[i].b = palette[i * 4 + 2];
_mainPalette[i].r = palette[i * 3 + 0];
_mainPalette[i].g = palette[i * 3 + 1];
_mainPalette[i].b = palette[i * 3 + 2];
}
}

Expand Down

0 comments on commit 10e2cec

Please sign in to comment.