aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlyssa Milburn2010-12-09 21:25:21 +0000
committerAlyssa Milburn2010-12-09 21:25:21 +0000
commit4393ef1bd5c607df678d78b56dd9c1e515dae84f (patch)
treea4debd3b20197a0f25b259f08f368b6bcc35f094 /engines
parent0257f2a2171349446e820e7b21334b6d71016b3c (diff)
downloadscummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.tar.gz
scummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.tar.bz2
scummvm-rg350-4393ef1bd5c607df678d78b56dd9c1e515dae84f.zip
MOHAWK: Fix LBPaletteItem to handle variable-size palettes
svn-id: r54846
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/livingbooks.cpp17
-rw-r--r--engines/mohawk/livingbooks.h3
2 files changed, 17 insertions, 3 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index e750e2c2f2..6d93ec4151 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -2692,19 +2692,29 @@ void LBGroupItem::stop() {
LBPaletteItem::LBPaletteItem(MohawkEngine_LivingBooks *vm, Common::Rect rect) : LBItem(vm, rect) {
debug(3, "new LBPaletteItem");
+
_fadeInStart = 0;
+ _palette = NULL;
+}
+
+LBPaletteItem::~LBPaletteItem() {
+ delete[] _palette;
}
void LBPaletteItem::readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream) {
switch (type) {
case kLBPaletteXData:
{
- assert(size == 8 + 255 * 4);
+ assert(size >= 8);
_fadeInPeriod = stream->readUint16();
_fadeInStep = stream->readUint16();
_drawStart = stream->readUint16();
_drawCount = stream->readUint16();
- stream->read(_palette, 255 * 4);
+ if (_drawStart + _drawCount > 256)
+ error("encountered palette trying to set more than 256 colours");
+ assert(size == 8 + _drawCount * 4);
+ _palette = new byte[_drawCount * 4];
+ stream->read(_palette, _drawCount * 4);
}
break;
@@ -2728,6 +2738,9 @@ bool LBPaletteItem::togglePlaying(bool playing, bool restart) {
void LBPaletteItem::update() {
if (_fadeInStart) {
+ if (!_palette)
+ error("LBPaletteItem had no palette on startup");
+
uint32 elapsedTime = _vm->_system->getMillis() - _fadeInStart;
uint32 divTime = elapsedTime / _fadeInStep;
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index fe4c47dc48..b1879824ad 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -419,6 +419,7 @@ protected:
class LBPaletteItem : public LBItem {
public:
LBPaletteItem(MohawkEngine_LivingBooks *_vm, Common::Rect rect);
+ ~LBPaletteItem();
void readData(uint16 type, uint16 size, Common::SeekableSubReadStreamEndian *stream);
@@ -428,7 +429,7 @@ public:
protected:
uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
uint32 _fadeInStart, _fadeInCurrent;
- byte _palette[255 * 4];
+ byte *_palette;
};
struct LiveTextWord {