KINGDOM: Support partial palette update in MVE decoder

This commit is contained in:
Thomas Fach-Pedersen 2020-05-31 11:09:48 +02:00 committed by Eugene Sandulenko
parent c24d35d387
commit 5ed3222fce
3 changed files with 16 additions and 4 deletions

View File

@ -527,7 +527,8 @@ void KingdomGame::playMovie(int movieNum) {
g_system->unlockScreen();
if (decoder->hasDirtyPalette()) {
g_system->getPaletteManager()->setPalette(decoder->getPalette(), 0, 256);
PaletteManager *paletteManager = g_system->getPaletteManager();
decoder->applyPalette(paletteManager);
}
g_system->updateScreen();

View File

@ -97,6 +97,10 @@ void MveDecoder::setAudioTrack(int track) {
_audioTrack= track;
}
void MveDecoder::applyPalette(PaletteManager *paletteManager) {
paletteManager->setPalette(_palette + 3 * _palStart, _palStart, _palCount);
}
void MveDecoder::copyBlock(Graphics::Surface &dst, Common::MemoryReadStream &s, int block) {
int x = (block % _widthInBlocks) * 8;
int y = (block / _widthInBlocks) * 8;
@ -404,15 +408,17 @@ void MveDecoder::readNextPacket() {
byte g = _s->readByte();
byte b = _s->readByte();
_palette[3*i+0] = (r << 2) | r;
_palette[3*i+1] = (g << 2) | g;
_palette[3*i+2] = (b << 2) | b;
_palette[3*i+0] = (r << 2) | (r >> 4);
_palette[3*i+1] = (g << 2) | (g >> 4);
_palette[3*i+2] = (b << 2) | (b >> 4);
}
if (palCount & 1) {
_s->skip(1);
}
_dirtyPalette = true;
_palStart = palStart;
_palCount = palCount;
break;
}

View File

@ -38,6 +38,8 @@ namespace Graphics {
struct PixelFormat;
}
class PaletteManager;
namespace Video {
/**
@ -66,6 +68,8 @@ class MveDecoder : public VideoDecoder {
Common::Rational _frameRate;
bool _dirtyPalette;
uint16 _palStart;
uint16 _palCount;
byte _palette[0x300];
uint16 _skipMapSize;
@ -150,6 +154,7 @@ public:
bool loadStream(Common::SeekableReadStream *stream);
void setAudioTrack(int track);
void applyPalette(PaletteManager *paletteManager);
// const Common::List<Common::Rect> *getDirtyRects() const;
// void clearDirtyRects();