diff options
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/assets.cpp | 11 | ||||
-rw-r--r-- | engines/mads/mads.cpp | 1 | ||||
-rw-r--r-- | engines/mads/palette.cpp | 64 | ||||
-rw-r--r-- | engines/mads/palette.h | 11 | ||||
-rw-r--r-- | engines/mads/scene_data.cpp | 3 |
5 files changed, 31 insertions, 59 deletions
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp index 1a2d542c95..1c958adfce 100644 --- a/engines/mads/assets.cpp +++ b/engines/mads/assets.cpp @@ -74,13 +74,8 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) { // Get the palette data spriteStream = sprite.getItemStream(2); - int numColors = 0; - byte *palData = _vm->_palette->decodePalette(spriteStream, &numColors); - Common::copy(palData, &palData[numColors], &_palette[0]); - if (numColors < 256) - Common::fill((byte *)&_palette[numColors], (byte *)&_palette[256], 0); - _colorCount = numColors; - delete[] palData; + _vm->_palette->decodePalette(spriteStream, flags); + delete spriteStream; spriteStream = sprite.getItemStream(1); @@ -133,7 +128,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) { fab.decompress(srcData, srcSize, destData, frameSizes[curFrame]); - // Load the frame + // Load the frames Common::MemoryReadStream *rs = new Common::MemoryReadStream(destData, frameSizes[curFrame]); _frames[curFrame]._frame = new MSprite(rs, Common::Point(_frames[curFrame]._bounds.left, _frames[curFrame]._bounds.top), diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index 0327a9fc67..6dfdf7b3b8 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -88,7 +88,6 @@ void MADSEngine::initialise() { _userInterface = UserInterface::init(this); _game = Game::init(this); - _events->loadCursors("*CURSOR.SS"); _screen.empty(); } diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index d9eb3ffa93..1525be982d 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -77,14 +77,13 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) { prioritizeFromList(lst); } -int PaletteUsage::process(Common::Array<RGB6> &palette, int v) { +int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) { byte *pal1 = nullptr, *pal2 = nullptr; int palLow; - int palHigh = (v & 0x800) ? 0x100 : 0xC; + int palHigh = (flags & 0x800) ? 0x100 : 0xFC; int palIdx; - assert(v >= 0); - if (v & 0x4000) { + if (flags & 0x4000) { palLow = 0; palIdx = palHigh; } else { @@ -98,7 +97,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) { int rgbIndex = _vm->_palette->_rgbList.scan(); uint32 rgbMask = 1 << rgbIndex; - int varA = v & 0x8000; + int varA = flags & 0x8000; bool hasUsage = !_vm->_palette->_paletteUsage.empty(); bool flag1 = false; @@ -127,14 +126,14 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) { if (!(palette[palIndex]._flags & 0x80)) { pal1[palIndex] = 0x40; } - if (!(palette[palIndex]._flags & 0x60)) { + if (palette[palIndex]._flags & 0x60) { pal1[palIndex] |= 0x20; } } _vm->_palette->processLists(palette.size(), pal1, pal2); - int var3A = (v & 0x4000) ? 0xffff : 0xfffe; + int var3A = (flags & 0x4000) ? 0xffff : 0xfffe; for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) { bool var48 = false; @@ -174,8 +173,8 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) { if (!var48 && !varA) { int var2 = !(palette[palIndex]._flags & 0x20) && ( - ((v & 0x2000) && !(palette[palIndex]._flags & 0x40)) || - ((v & 0x1000) && (palCount > 0)) + ((flags & 0x2000) && !(palette[palIndex]._flags & 0x40)) || + ((flags & 0x1000) && (palCount > 0)) ) ? 1 : 0x7fff; int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2; @@ -204,7 +203,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) { } } - if (!var48 && (!(v & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(v & 0x2000)))) { + if (!var48 && (!(flags & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(flags & 0x2000)))) { for (int idx = freeIndex; idx < palIdx && !var48; ++idx) { if (!_vm->_palette->_gamePalette[idx]) { --palCount; @@ -477,35 +476,18 @@ void Palette::processLists(int count, byte *pal1, byte *pal2) { } -byte *Palette::decodePalette(Common::SeekableReadStream *palStream, int *numColors) { - *numColors = palStream->readUint16LE(); - assert(*numColors <= 252); +void Palette::decodePalette(Common::SeekableReadStream *palStream, uint flags) { + int numColors = palStream->readUint16LE(); + assert(numColors <= 252); - byte *palData = new byte[*numColors * 3]; - Common::fill(&palData[0], &palData[*numColors * 3], 0); - - for (int i = 0; i < *numColors; ++i) { - byte r = palStream->readByte(); - byte g = palStream->readByte(); - byte b = palStream->readByte(); - palData[i * 3] = VGA_COLOR_TRANS(r); - palData[i * 3 + 1] = VGA_COLOR_TRANS(g); - palData[i * 3 + 2] = VGA_COLOR_TRANS(b); - - // The next 3 bytes are unused - palStream->skip(3); - } - - return palData; -} - -int Palette::loadPalette(Common::SeekableReadStream *palStream, int indexStart) { - int colorCount; - byte *palData = decodePalette(palStream, &colorCount); - _vm->_palette->setPalette(palData, indexStart, colorCount); - - delete palData; - return colorCount; + // Load in the palette + Common::Array<RGB6> palette; + palette.resize(numColors); + for (int i = 0; i < numColors; ++i) + palette[i].load(palStream); + + // Process the palette data + _paletteUsage.process(palette, flags); } void Palette::setSystemPalette() { @@ -524,9 +506,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) { // Init low range to common RGB values if (lowRange) { - _gamePalette[0] = 1; - - Common::fill(&_gamePalette[1], &_gamePalette[lowRange - 1], _gamePalette[0]); + Common::fill(&_gamePalette[0], &_gamePalette[lowRange], 1); } // Init high range to common RGB values @@ -537,6 +517,8 @@ void Palette::resetGamePalette(int lowRange, int highRange) { } _rgbList.clear(); + _rgbList[0] = _rgbList[1] = 0xffff; + _v1 = 0; _lowRange = lowRange; _highRange = highRange; diff --git a/engines/mads/palette.h b/engines/mads/palette.h index a7c3285aa3..ad9d1f3c4b 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -91,7 +91,7 @@ public: */ void prioritize(Common::Array<RGB6> &palette); - int process(Common::Array<RGB6> &palette, int v); + int process(Common::Array<RGB6> &palette, uint flags); void transform(Common::Array<RGB6> &palette); }; @@ -183,14 +183,9 @@ public: uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr); /** - * Decode a palette and return it, without affecting the Palette itself + * Decodes a palette and loads it into the main palette */ - byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors); - - /** - * Loads a palette from a stream - */ - int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0); + void decodePalette(Common::SeekableReadStream *palStream, uint flags); /** * Sets a small set of system/core colors needed by the game diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index eb4b221af9..d4fefff4f6 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -500,7 +500,8 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName, _vm->_palette->_paletteUsage.prioritize(artHeader._palette); } - _usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, 0xF800); + _usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, + (flags & 0xF800) | 0x8000); if (_usageIndex > 0) { _vm->_palette->_paletteUsage.transform(artHeader._palette); |