diff options
| -rw-r--r-- | engines/mads/font.cpp | 3 | ||||
| -rw-r--r-- | engines/mads/msurface.cpp | 2 | ||||
| -rw-r--r-- | engines/mads/palette.cpp | 116 | ||||
| -rw-r--r-- | engines/mads/palette.h | 81 | 
4 files changed, 3 insertions, 199 deletions
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp index 0ff01905ce..b8f8187fc7 100644 --- a/engines/mads/font.cpp +++ b/engines/mads/font.cpp @@ -30,11 +30,12 @@ namespace MADS {  Font::Font(MADSEngine *vm) : _vm(vm) {  	_sysFont = true; -	 +	/*  	_fontColors[0] = _vm->_palette->BLACK;  	_fontColors[1] = _vm->_palette->WHITE;  	_fontColors[2] = _vm->_palette->BLACK;  	_fontColors[3] = _vm->_palette->DARK_GRAY; +	*/  }  Font::~Font() { diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index 74043bf91f..3a38360bfe 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -196,7 +196,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo  }  void MSurface::empty() { -	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK); +	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), 0);  }  void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,  diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 4568f7d39a..a0e58ca54b 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -37,28 +37,6 @@ void RGB6::load(Common::SeekableReadStream *f) {  	flags = f->readByte();  } -RGBList::RGBList(int numEntries, byte *srcData, bool freeData) { -	_size = numEntries; -	assert(numEntries <= PALETTE_COUNT); - -	if (srcData == NULL) { -		_data = new byte[numEntries * 3]; -		_freeData = true; -	} else { -		_data = srcData; -		_freeData = freeData; -	} - -	_palIndexes = new byte[numEntries]; -	Common::fill(&_palIndexes[0], &_palIndexes[numEntries], 0); -} - -RGBList::~RGBList() { -	if (_freeData) -		delete[] _data; -	delete[] _palIndexes; -} -  /*------------------------------------------------------------------------*/  PaletteUsage::PaletteUsage() { @@ -220,97 +198,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {  }  void Palette::reset() { -	byte palData[PALETTE_SIZE]; -	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT); - -	BLACK = palIndexFromRgb(0, 0, 0, palData); -	BLUE = palIndexFromRgb(0, 0, 255, palData); -	GREEN = palIndexFromRgb(0, 255, 0, palData); -	CYAN = palIndexFromRgb(0, 255, 255, palData); -	RED = palIndexFromRgb(255, 0, 0, palData); -	VIOLET = palIndexFromRgb(255, 0, 255, palData); -	BROWN = palIndexFromRgb(168, 84, 84, palData); -	LIGHT_GRAY = palIndexFromRgb(168, 168, 168, palData); -	DARK_GRAY = palIndexFromRgb(84, 84, 84, palData); -	LIGHT_BLUE = palIndexFromRgb(0, 0, 127, palData); -	LIGHT_GREEN = palIndexFromRgb(0, 127, 0, palData); -	LIGHT_CYAN = palIndexFromRgb(0, 127, 127, palData); -	LIGHT_RED = palIndexFromRgb(84, 0, 0, palData); -	PINK = palIndexFromRgb(84, 0, 0, palData); -	YELLOW = palIndexFromRgb(0, 84, 84, palData); -	WHITE = palIndexFromRgb(255, 255, 255, palData); -} - -void Palette::resetColorCounts() { -	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0); -} - -void Palette::blockRange(int startIndex, int size) { -	// Use a reference count of -1 to signal a palette index shouldn't be used -	Common::fill(&_usageCount[startIndex], &_usageCount[startIndex + size], -1); -} - -void Palette::addRange(RGBList *list) { -	byte *data = list->data(); -	byte *palIndexes = list->palIndexes(); -	byte palData[PALETTE_COUNT]; -	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT); -	bool paletteChanged = false; -	 -	for (int colIndex = 0; colIndex < list->size(); ++colIndex) { -		// Scan through for an existing copy of the RGB value -		int palIndex = -1;  -		while (++palIndex < PALETTE_COUNT) { -			if (_usageCount[palIndex] <= 0) -				// Palette index is to be skipped -				continue; - -			if ((palData[palIndex * 3] == data[colIndex * 3]) &&  -				(palData[palIndex * 3 + 1] == data[colIndex * 3 + 1]) && -				(palData[palIndex * 3 + 2] == data[colIndex * 3 + 2]))  -				// Match found -				break; -		} - -		if (palIndex == PALETTE_COUNT) { -			// No match found, so find a free slot to use -			palIndex = -1; -			while (++palIndex < PALETTE_COUNT) { -				if (_usageCount[palIndex] == 0) -					break; -			} - -			if (palIndex == PALETTE_COUNT)  -				error("addRange - Ran out of palette space to allocate"); - -			palData[palIndex * 3] = data[colIndex * 3]; -			palData[palIndex * 3 + 1] = data[colIndex * 3 + 1]; -			palData[palIndex * 3 + 2] = data[colIndex * 3 + 2]; -			paletteChanged = true; -		} - -		palIndexes[colIndex] = palIndex; -		++_usageCount[palIndex]; -	} - -	if (paletteChanged) { -		g_system->getPaletteManager()->setPalette(&palData[0], 0, 256); -		reset(); -	} -} - -void Palette::deleteRange(RGBList *list) { -	// Release the reference count on each of the palette entries -	for (int colIndex = 0; colIndex < list->size(); ++colIndex) { -		int palIndex = list->palIndexes()[colIndex]; -		assert(_usageCount[palIndex] > 0); -		--_usageCount[palIndex]; -	} -} - -void Palette::deleteAllRanges() { -	for (int colIndex = 0; colIndex < 255; ++colIndex) -		_usageCount[colIndex] = 0;  }  void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) { @@ -373,8 +260,6 @@ int Palette::loadPalette(Common::SeekableReadStream *palStream, int indexStart)  }  void Palette::setSystemPalette() { -	resetColorCounts(); -  	byte palData[4 * 3];  	palData[0 * 3] = palData[0 * 3 + 1] = palData[0 * 3 + 2] = 0;  	palData[1 * 3] = palData[1 * 3 + 1] = palData[1 * 3 + 2] = 0x54; @@ -382,7 +267,6 @@ void Palette::setSystemPalette() {  	palData[3 * 3] = palData[3 * 3 + 1] = palData[3 * 3 + 2] = 0xff;  	setPalette(palData, 0, 4); -	blockRange(0, 4);  }  void Palette::resetGamePalette(int lowRange, int highRange) { diff --git a/engines/mads/palette.h b/engines/mads/palette.h index a00e1789f4..d85e25b8b6 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -50,42 +50,6 @@ struct RGB6 {  	void load(Common::SeekableReadStream *f);  }; -/** - * Used to store a list of RGB values - */ -class RGBList { -private: -	int _size; -	byte *_data; -	byte *_palIndexes; -	bool _freeData; -public: -	/**  -	 * Constructor -	 */ -	RGBList(int numEntries = 256, byte *srcData = NULL, bool freeData = true); - -	/** -	 * Destructor -	 */ -	~RGBList(); - -	/** -	 * Returns the raw data containing the RGB values as 3 bytes per entry -	 */ -	byte *data() { return _data; } - -	/** -	 * Returns the list of palette indexes each RGB tuple maps to in the current palette -	 */ -	byte *palIndexes() { return _palIndexes; } - -	/** -	 * Returns the size of the palette -	 */ -	int size() const { return _size; } -}; -  class PaletteUsage {  private:  	Common::Array<int> _data; @@ -180,33 +144,6 @@ public:  	 */  	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr); -	// Methods used for reference counting color usage -	/** -	 * Resets the usage counts for the palette -	 */ -	void resetColorCounts(); - -	/** -	 * Blocks out a range of the palette from being used -	 */ -	void blockRange(int startIndex, int size); - -	/** -	 * Adds the data of an RGBList into the current palette and increment usage counts. -	 */ -	void addRange(RGBList *list); - -	/** -	 * Delets a range from the current palette, dercementing the accompanying usage counts. -	 */ -	void deleteRange(RGBList *list); - -	/** -	 * Deletes all loaded RGB lists are their usage references. -	 */ -	void deleteAllRanges(); - -	// Virtual method table  	/**  	 * Decode a palette and return it, without affecting the Palette itself  	 */ @@ -248,24 +185,6 @@ public:  	void close() {  		warning("TODO: Palette::close");  	} - -	// Color indexes -	uint8 BLACK; -	uint8 BLUE; -	uint8 GREEN; -	uint8 CYAN; -	uint8 RED; -	uint8 VIOLET; -	uint8 BROWN; -	uint8 LIGHT_GRAY; -	uint8 DARK_GRAY; -	uint8 LIGHT_BLUE; -	uint8 LIGHT_GREEN; -	uint8 LIGHT_CYAN; -	uint8 LIGHT_RED; -	uint8 PINK; -	uint8 YELLOW; -	uint8 WHITE;  };  } // End of namespace MADS  | 
