[Scummvm-cvs-logs] SF.net SVN: scummvm:[54846] scummvm/trunk/engines/mohawk
fuzzie at users.sourceforge.net
fuzzie at users.sourceforge.net
Thu Dec 9 22:25:22 CET 2010
Revision: 54846
http://scummvm.svn.sourceforge.net/scummvm/?rev=54846&view=rev
Author: fuzzie
Date: 2010-12-09 21:25:21 +0000 (Thu, 09 Dec 2010)
Log Message:
-----------
MOHAWK: Fix LBPaletteItem to handle variable-size palettes
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-09 21:25:05 UTC (rev 54845)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-12-09 21:25:21 UTC (rev 54846)
@@ -2692,19 +2692,29 @@
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 @@
void LBPaletteItem::update() {
if (_fadeInStart) {
+ if (!_palette)
+ error("LBPaletteItem had no palette on startup");
+
uint32 elapsedTime = _vm->_system->getMillis() - _fadeInStart;
uint32 divTime = elapsedTime / _fadeInStep;
Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-09 21:25:05 UTC (rev 54845)
+++ scummvm/trunk/engines/mohawk/livingbooks.h 2010-12-09 21:25:21 UTC (rev 54846)
@@ -419,6 +419,7 @@
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 @@
protected:
uint16 _fadeInPeriod, _fadeInStep, _drawStart, _drawCount;
uint32 _fadeInStart, _fadeInCurrent;
- byte _palette[255 * 4];
+ byte *_palette;
};
struct LiveTextWord {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list