aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Haisch2008-04-21 11:05:44 +0000
committerBenjamin Haisch2008-04-21 11:05:44 +0000
commit7531e54006f67398213f827d821be77e3bdb2070 (patch)
tree4f10e5d2170e84baaa52f56be0798866edd43f1b
parentd003b7e6a8ab861b207c322122e7abb5a5d0be83 (diff)
downloadscummvm-rg350-7531e54006f67398213f827d821be77e3bdb2070.tar.gz
scummvm-rg350-7531e54006f67398213f827d821be77e3bdb2070.tar.bz2
scummvm-rg350-7531e54006f67398213f827d821be77e3bdb2070.zip
Fixed palette handling in PMV videos.
svn-id: r31641
-rw-r--r--engines/made/pmvplayer.cpp37
-rw-r--r--engines/made/pmvplayer.h1
2 files changed, 29 insertions, 9 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index dbb8d02a48..b2467ffd20 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -48,8 +48,6 @@ void PmvPlayer::play(const char *filename) {
_fd->read(_palette, 768);
updatePalette();
- //FILE *raw = fopen("track.raw", "wb");
-
uint32 frameCount = 0;
// TODO: Sound can still be a little choppy. A bug in the decoder or -
@@ -66,6 +64,7 @@ void PmvPlayer::play(const char *filename) {
byte *frameData = new byte[chunkSize];
_fd->read(frameData, chunkSize);
+ // Handle audio
byte *audioData = frameData + READ_LE_UINT32(frameData + 8) - 8;
chunkSize = READ_LE_UINT16(audioData + 4);
uint16 chunkCount = READ_LE_UINT16(audioData + 6);
@@ -78,9 +77,17 @@ void PmvPlayer::play(const char *filename) {
byte *soundData = new byte[soundSize];
decompressSound(audioData + 8, soundData, chunkSize, chunkCount);
_audioStream->queueBuffer(soundData, soundSize);
-
- //fwrite(soundData, soundSize, 1, raw);
+ // Handle palette
+ uint32 palChunkOfs = READ_LE_UINT32(frameData + 16);
+ if (palChunkOfs) {
+ byte *palData = frameData + palChunkOfs - 8;
+ uint32 palSize = READ_LE_UINT32(palData + 4);
+ decompressPalette(palData + 8, _palette, palSize);
+ updatePalette();
+ }
+
+ // Handle video
byte *imageData = frameData + READ_LE_UINT32(frameData + 12) - 8;
uint32 frameNum = READ_LE_UINT32(frameData);
@@ -101,16 +108,17 @@ void PmvPlayer::play(const char *filename) {
decompressImage(imageData, *_surface, cmdOffs, pixelOffs, maskOffs, lineSize, frameNum > 0);
+ delete[] frameData;
+
handleEvents();
updateScreen();
- delete[] frameData;
-
frameCount++;
while (_mixer->getSoundElapsedTime(_audioStreamHandle) < frameCount * frameDelay) {
_system->delayMillis(10);
}
+
}
_audioStream->finish();
@@ -120,15 +128,14 @@ void PmvPlayer::play(const char *filename) {
delete _fd;
delete _surface;
- //fclose(raw);
-
}
void PmvPlayer::readChunk(uint32 &chunkType, uint32 &chunkSize) {
chunkType = _fd->readUint32BE();
chunkSize = _fd->readUint32LE();
- debug(2, "chunkType = %c%c%c%c; chunkSize = %d\n",
+ debug(2, "ofs = %08X; chunkType = %c%c%c%c; chunkSize = %d\n",
+ _fd->pos(),
(chunkType >> 24) & 0xFF, (chunkType >> 16) & 0xFF, (chunkType >> 8) & 0xFF, chunkType & 0xFF,
chunkSize);
@@ -168,4 +175,16 @@ void PmvPlayer::updateScreen() {
_system->updateScreen();
}
+void PmvPlayer::decompressPalette(byte *palData, byte *outPal, uint32 palDataSize) {
+ byte *palDataEnd = palData + palDataSize;
+ while (palData < palDataEnd) {
+ byte count = *palData++;
+ byte entry = *palData++;
+ if (count == 255 && entry == 255)
+ break;
+ memcpy(&outPal[entry * 3], palData, (count + 1) * 3);
+ palData += (count + 1) * 3;
+ }
+}
+
}
diff --git a/engines/made/pmvplayer.h b/engines/made/pmvplayer.h
index 11204df3a7..09f7be0fe9 100644
--- a/engines/made/pmvplayer.h
+++ b/engines/made/pmvplayer.h
@@ -32,6 +32,7 @@ protected:
void handleEvents();
void updatePalette();
void updateScreen();
+ void decompressPalette(byte *palData, byte *outPal, uint32 palDataSize);
};
}