aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2008-04-21 20:20:34 +0000
committerFilippos Karapetis2008-04-21 20:20:34 +0000
commit54485c24c530288280174f6d286c8c0b367a8206 (patch)
tree3f2a547f0b380f6db26480e222ab5dc1cda75cc3 /engines
parent169bf5ddba25a7ab63b405a48bccc449550a693e (diff)
downloadscummvm-rg350-54485c24c530288280174f6d286c8c0b367a8206.tar.gz
scummvm-rg350-54485c24c530288280174f6d286c8c0b367a8206.tar.bz2
scummvm-rg350-54485c24c530288280174f6d286c8c0b367a8206.zip
Some palette related fixes
svn-id: r31650
Diffstat (limited to 'engines')
-rw-r--r--engines/made/pmvplayer.cpp8
-rw-r--r--engines/made/pmvplayer.h2
-rw-r--r--engines/made/resource.cpp21
-rw-r--r--engines/made/resource.h6
-rw-r--r--engines/made/screen.cpp28
-rw-r--r--engines/made/screen.h3
-rw-r--r--engines/made/scriptfuncs.cpp4
7 files changed, 44 insertions, 28 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index 69c3c80318..6faa7f6291 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -68,8 +68,8 @@ void PmvPlayer::play(const char *filename) {
_mixer->stopAll();
// Read palette
- _fd->read(_palette, 768);
- _vm->_screen->setRGBPalette(_palette);
+ _fd->read(_paletteRGB, 768);
+ _vm->_screen->setRGBPalette(_paletteRGB);
uint32 frameCount = 0;
uint16 chunkCount = 0;
@@ -116,7 +116,7 @@ void PmvPlayer::play(const char *filename) {
if (palChunkOfs) {
palData = frameData + palChunkOfs - 8;
palSize = READ_LE_UINT32(palData + 4);
- decompressPalette(palData + 8, _palette, palSize);
+ decompressPalette(palData + 8, _paletteRGB, palSize);
}
// Handle video
@@ -145,7 +145,7 @@ void PmvPlayer::play(const char *filename) {
firstTime = false;
}
- _vm->_screen->setRGBPalette(_palette);
+ _vm->_screen->setRGBPalette(_paletteRGB);
handleEvents();
updateScreen();
diff --git a/engines/made/pmvplayer.h b/engines/made/pmvplayer.h
index 0e63d73f7f..35712f1932 100644
--- a/engines/made/pmvplayer.h
+++ b/engines/made/pmvplayer.h
@@ -51,7 +51,7 @@ protected:
Common::File *_fd;
Audio::AppendableAudioStream *_audioStream;
Audio::SoundHandle _audioStreamHandle;
- byte _palette[768];
+ byte _paletteRGB[768];
Graphics::Surface *_surface;
bool _abort;
void readChunk(uint32 &chunkType, uint32 &chunkSize);
diff --git a/engines/made/resource.cpp b/engines/made/resource.cpp
index b7c185280c..cf49e0201b 100644
--- a/engines/made/resource.cpp
+++ b/engines/made/resource.cpp
@@ -38,21 +38,26 @@ Resource::~Resource() {
/* PictureResource */
-PictureResource::PictureResource() : _picture(NULL), _palette(NULL) {
+PictureResource::PictureResource() : _picture(NULL), _picturePalette(NULL) {
+ _hasPalette = false;
}
PictureResource::~PictureResource() {
- if (_picture)
+ if (_picture) {
delete _picture;
- if (_palette)
- delete[] _palette;
+ _picture = 0;
+ }
+ if (_picturePalette) {
+ delete[] _picturePalette;
+ _picturePalette = 0;
+ }
}
void PictureResource::load(byte *source, int size) {
Common::MemoryReadStream *sourceS = new Common::MemoryReadStream(source, size);
- bool hasPalette = sourceS->readByte() == 1;
+ _hasPalette = (sourceS->readByte() != 0);
sourceS->readByte();
sourceS->readByte();
sourceS->readByte();
@@ -66,9 +71,9 @@ void PictureResource::load(byte *source, int size) {
debug(2, "width = %d; height = %d\n", width, height);
- if (hasPalette) {
- _palette = new byte[768];
- sourceS->read(_palette, 768);
+ if (_hasPalette) {
+ _picturePalette = new byte[768];
+ sourceS->read(_picturePalette, 768);
}
_picture = new Graphics::Surface();
diff --git a/engines/made/resource.h b/engines/made/resource.h
index 619bf80b0c..bba940de69 100644
--- a/engines/made/resource.h
+++ b/engines/made/resource.h
@@ -62,10 +62,12 @@ public:
~PictureResource();
void load(byte *source, int size);
Graphics::Surface *getPicture() const { return _picture; }
- byte *getPalette() const { return _palette; }
+ byte *getPalette() const { return _picturePalette; }
+ bool hasPalette() const { return _hasPalette; }
protected:
Graphics::Surface *_picture;
- byte *_palette;
+ byte *_picturePalette;
+ bool _hasPalette;
};
class AnimationResource : public Resource {
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index 6c50069bc0..f189331dd4 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -73,14 +73,18 @@ void Screen::drawSurface(Graphics::Surface *source, int x, int y) {
}
-void Screen::setRGBPalette(byte *palRGB, int start, int count) {
+void Screen::loadRGBPalette(byte *palRGB, int count) {
for (int i = 0; i < count; i++) {
- _palette[i * 4 + 0] = palRGB[i * 3 + 0];
- _palette[i * 4 + 1] = palRGB[i * 3 + 1];
- _palette[i * 4 + 2] = palRGB[i * 3 + 2];
- _palette[i * 4 + 3] = 0;
+ _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->setPalette(_palette, start, count);
+}
+
+void Screen::setRGBPalette(byte *palRGB, int start, int count) {
+ loadRGBPalette(palRGB, count);
+ _vm->_system->setPalette(_screenPalette, start, count);
}
uint16 Screen::updateChannel(uint16 channelIndex) {
@@ -226,6 +230,8 @@ uint16 Screen::drawFlex(uint16 flexIndex, int16 x, int16 y, uint16 flag1, uint16
if (flexIndex == 0)
return 0;
+ if (flexIndex == 1279) return 0; // HACK: fixes the first screen
+
PictureResource *flex = _vm->_res->getPicture(flexIndex);
Graphics::Surface *sourceSurface = flex->getPicture();
byte *source = (byte*)sourceSurface->getBasePtr(0, 0);
@@ -248,10 +254,12 @@ uint16 Screen::drawFlex(uint16 flexIndex, int16 x, int16 y, uint16 flag1, uint16
dest += clipInfo.destSurface->pitch;
}
- // TODO: Palette stuff; palette should be set in showPage
- byte *pal = flex->getPalette();
- if (pal) {
- setRGBPalette(pal);
+ // Palette is set in showPage
+ if (flex->hasPalette()) {
+ byte *pal = flex->getPalette();
+ if (pal != 0) {
+ loadRGBPalette(pal);
+ }
}
_vm->_res->freeResource(flex);
diff --git a/engines/made/screen.h b/engines/made/screen.h
index 545cce2bfd..d6040e7dcc 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -61,6 +61,7 @@ public:
void clearScreen();
void drawSurface(Graphics::Surface *source, int x, int y);
+ void loadRGBPalette(byte *palRGB, int count = 256);
void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
uint16 updateChannel(uint16 channelIndex);
@@ -99,7 +100,7 @@ public:
void setExclude(uint16 exclude);
void setGround(uint16 ground);
- byte _palette[256 * 4];
+ byte _screenPalette[256 * 4];
protected:
MadeEngine *_vm;
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 03ea762d78..5aa4b41eaa 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -185,12 +185,12 @@ int16 ScriptFunctionsRtz::o1_DRAWPIC(int16 argc, int16 *argv) {
}
int16 ScriptFunctionsRtz::o1_CLS(int16 argc, int16 *argv) {
- //_vm->_screen->clearScreen();
+ _vm->_screen->clearScreen();
return 0;
}
int16 ScriptFunctionsRtz::o1_SHOWPAGE(int16 argc, int16 *argv) {
- //_vm->_system->setPalette(_vm->_screen->_palette, 0, 256);
+ _vm->_system->setPalette(_vm->_screen->_screenPalette, 0, 256);
_vm->_screen->show();
return 0;
}