aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-26 20:35:18 -0400
committerPaul Gilbert2014-03-26 20:35:18 -0400
commit253023b9bb35547c1afe9678f051fb83329d3245 (patch)
treea19262bf4bbe9798e2c9531cba24ed7f8871cc29 /engines/mads
parent2eaafe1579abf6ab895c903bbe802451cd36f98d (diff)
downloadscummvm-rg350-253023b9bb35547c1afe9678f051fb83329d3245.tar.gz
scummvm-rg350-253023b9bb35547c1afe9678f051fb83329d3245.tar.bz2
scummvm-rg350-253023b9bb35547c1afe9678f051fb83329d3245.zip
MADS: Add missing case for sprite assets palette loading
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/assets.cpp32
-rw-r--r--engines/mads/user_interface.cpp2
2 files changed, 32 insertions, 2 deletions
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 02b91aac2f..ec5d54251f 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -88,7 +88,37 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
// Process the palette data
if (flags & 9) {
- warning("TODO: Unknown palette processing");
+ _usageIndex = 0;
+
+ if (flags & 8) {
+ int newPalCtr = 0;
+
+ for (uint i = 0; i < palette.size(); ++i) {
+ RGB6 &rgb = palette[i];
+
+ // Scan for existing rgb at beginning of the main palette
+ bool found = false;
+ for (int pIndex = 0; pIndex < 4 && !found; ++pIndex) {
+ byte *palP = &_vm->_palette->_mainPalette[pIndex * 3];
+ if (palP[0] == rgb.r && palP[1] == rgb.g && palP[2] == rgb.b) {
+ rgb._palIndex = pIndex;
+ found = true;
+ }
+ }
+
+ if (!found) {
+ // Existing palette entry not found, so need to add it in
+ int palIndex = (0xF7F607 >> (8 * newPalCtr)) & 0xff;
+ byte *palP = &_vm->_palette->_mainPalette[palIndex * 3];
+ palP[0] = rgb.r;
+ palP[1] = rgb.g;
+ palP[2] = rgb.b;
+ rgb._palIndex = palIndex;
+
+ newPalCtr = MIN(newPalCtr + 1, 2);
+ }
+ }
+ }
} else {
_usageIndex = _vm->_palette->_paletteUsage.process(palette, flags);
assert(_usageIndex >= 0);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 05e9b70432..67e6718c5d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -196,7 +196,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
_inventoryTopIndex = 0;
_objectY = 0;
_selectedInvIndex = -1;
- _selectedActionIndex = -1;
+ _selectedActionIndex = 0;
_selectedItemVocabIdx = -1;
_scrollerY = 0;
_highlightedActionIndex = -1;