aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-12 16:14:57 -0400
committerPaul Gilbert2014-04-12 16:14:57 -0400
commit9b0f0b6efec3da058157beb25bab7083328df1da (patch)
tree7689d6956a5ca60bf19e149ce9b75cedb3d31b69 /engines/mads
parent8b2a7525cc6af408f05e2bac9b1b16ed0b36dcda (diff)
downloadscummvm-rg350-9b0f0b6efec3da058157beb25bab7083328df1da.tar.gz
scummvm-rg350-9b0f0b6efec3da058157beb25bab7083328df1da.tar.bz2
scummvm-rg350-9b0f0b6efec3da058157beb25bab7083328df1da.zip
MADS: Add missing handling code for palette _rgbList
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/animation.cpp7
-rw-r--r--engines/mads/assets.cpp5
-rw-r--r--engines/mads/assets.h5
-rw-r--r--engines/mads/palette.cpp18
-rw-r--r--engines/mads/palette.h2
5 files changed, 35 insertions, 2 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index ddad63ca2f..b79a753c28 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -322,7 +322,12 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
_spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites);
}
- // TODO: List var_420/var_422 population that seems to overwrite other structures?
+ Common::Array<int> usageList;
+ for (int idx = 0; idx < _header._spriteSetsCount; ++idx)
+ usageList.push_back(_spriteSets[idx]->_usageIndex);
+
+ if (usageList.size() > 0 > 0)
+ _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount);
if (_header._animMode == 4) {
// Remaps the sprite list indexes for frames to the loaded sprite list indexes
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 582b80dd8a..3e18a6711e 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -46,6 +46,11 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int
load(stream, flags);
}
+SpriteAsset::~SpriteAsset() {
+ if (_usageIndex)
+ _vm->_palette->_paletteUsage.resetPalFlags(_usageIndex);
+}
+
void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
int curFrame = 0;
uint32 frameOffset = 0;
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 54417f84ff..a5d3b3ecef 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -89,6 +89,11 @@ public:
*/
SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int flags);
+ /**
+ * Destructor
+ */
+ ~SpriteAsset();
+
int getCount() { return _frameCount; }
int getFrameRate() const { return _frameRate; }
int getPixelSpeed() const { return _pixelSpeed; }
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 8dfd8f6525..0c1819c809 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -276,6 +276,21 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde
_vm->_palette->_rgbList[sceneUsageIndex] = true;
}
+void PaletteUsage::resetPalFlags(int idx) {
+ if (idx >= 0 && idx < 32) {
+ uint32 rgbMask = ~(1 << idx);
+
+ uint32 *flagP = _vm->_palette->_palFlags;
+ for (int i = 0; i < 256; ++i, ++flagP) {
+ *flagP &= rgbMask;
+ if (*flagP == 2)
+ *flagP = 0;
+ }
+
+ _vm->_palette->_rgbList[idx] = 0;
+ }
+}
+
int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
*palIndex = -1;
int count = 0;
@@ -330,6 +345,7 @@ Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
_lowRange = 0;
_highRange = 0;
Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0);
+ Common::fill(&_palFlags[0], &_palFlags[PALETTE_COUNT], 0);
}
void Palette::setPalette(const byte *colors, uint start, uint num) {
@@ -423,7 +439,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
// Init low range to common RGB values
if (lowRange) {
- Common::fill(&_palFlags[0], &_palFlags[lowRange], 1);
+ Common::fill(&_palFlags[0], &_palFlags[lowRange - 1], 1);
}
// Init high range to common RGB values
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 5ad7e23d2b..9751351a95 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -127,6 +127,8 @@ public:
void transform(Common::Array<RGB6> &palette);
void updateUsage(Common::Array<int> &usageList, int sceneUsageIndex);
+
+ void resetPalFlags(int idx);
};
class RGBList {