[Scummvm-cvs-logs] SF.net SVN: scummvm:[35714] scummvm/trunk/engines/scumm
Kirben at users.sourceforge.net
Kirben at users.sourceforge.net
Sun Jan 4 04:49:23 CET 2009
Revision: 35714
http://scummvm.svn.sourceforge.net/scummvm/?rev=35714&view=rev
Author: Kirben
Date: 2009-01-04 03:49:23 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
Use cache when converting 16bit colors, for faster conversions.
Modified Paths:
--------------
scummvm/trunk/engines/scumm/he/wiz_he.cpp
scummvm/trunk/engines/scumm/palette.cpp
scummvm/trunk/engines/scumm/scumm.cpp
scummvm/trunk/engines/scumm/scumm.h
Modified: scummvm/trunk/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.cpp 2009-01-04 00:58:45 UTC (rev 35713)
+++ scummvm/trunk/engines/scumm/he/wiz_he.cpp 2009-01-04 03:49:23 UTC (rev 35714)
@@ -574,10 +574,10 @@
uint8 r = ((col >> 10) & 0x1F) << 3;
uint8 g = ((col >> 5) & 0x1F) << 3;
uint8 b = ((col >> 0) & 0x1F) << 3;
- col = _vm->remapPaletteColor(r, g, b, -1);
+ uint8 color = _vm->convert16BitColor(col, r, g, b);
if (transColor == -1 || transColor != col) {
- dst[i] = palPtr[col];
+ dst[i] = palPtr[color];
}
}
src += srcw * 2;
@@ -662,7 +662,7 @@
uint8 r = ((col >> 10) & 0x1F) << 3;
uint8 g = ((col >> 5) & 0x1F) << 3;
uint8 b = ((col >> 0) & 0x1F) << 3;
- col = _vm->remapPaletteColor(r, g, b, -1);
+ col = _vm->convert16BitColor(col, r, g, b);
if (type == kWizXMap) {
*dstPtr = xmapPtr[col * 256 + *dstPtr];
@@ -696,7 +696,7 @@
uint8 r = ((col >> 10) & 0x1F) << 3;
uint8 g = ((col >> 5) & 0x1F) << 3;
uint8 b = ((col >> 0) & 0x1F) << 3;
- col = _vm->remapPaletteColor(r, g, b, -1);
+ col = _vm->convert16BitColor(col, r, g, b);
if (type == kWizXMap) {
*dstPtr = xmapPtr[col * 256 + *dstPtr];
Modified: scummvm/trunk/engines/scumm/palette.cpp
===================================================================
--- scummvm/trunk/engines/scumm/palette.cpp 2009-01-04 00:58:45 UTC (rev 35713)
+++ scummvm/trunk/engines/scumm/palette.cpp 2009-01-04 03:49:23 UTC (rev 35714)
@@ -310,6 +310,9 @@
_palDirtyMin = min;
if (_palDirtyMax < max)
_palDirtyMax = max;
+
+ if (_hePaletteCache)
+ memset(_hePaletteCache, -1, 65536);
}
void ScummEngine::initCycl(const byte *ptr) {
@@ -810,6 +813,16 @@
#endif
+int ScummEngine::convert16BitColor(uint16 color, uint8 r, uint8 g, uint8 b) {
+ // HACK: Find the closest matching color, and store in
+ // cache for faster access.
+ if (_hePaletteCache[color] == -1) {
+ _hePaletteCache[color] = remapPaletteColor(r, g, b, -1);
+ }
+
+ return _hePaletteCache[color];
+}
+
int ScummEngine::remapPaletteColor(int r, int g, int b, int threshold) {
byte *pal;
int ar, ag, ab, i;
Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp 2009-01-04 00:58:45 UTC (rev 35713)
+++ scummvm/trunk/engines/scumm/scumm.cpp 2009-01-04 03:49:23 UTC (rev 35714)
@@ -264,6 +264,7 @@
_palManipPalette = NULL;
_palManipIntermediatePal = NULL;
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
+ _hePaletteCache = NULL;
_hePalettes = NULL;
_shadowPalette = NULL;
_shadowPaletteSize = 0;
@@ -805,6 +806,7 @@
delete _logicHE;
}
if (_game.heversion >= 99) {
+ free(_hePaletteCache);
free(_hePalettes);
}
}
@@ -1521,6 +1523,9 @@
ScummEngine_v90he::resetScumm();
+ _hePaletteCache = (int16 *)malloc(65536);
+ memset(_hePaletteCache, -1, 65536);
+
_hePalettes = (uint8 *)malloc((_numPalettes + 1) * 1024);
memset(_hePalettes, 0, (_numPalettes + 1) * 1024);
Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h 2009-01-04 00:58:45 UTC (rev 35713)
+++ scummvm/trunk/engines/scumm/scumm.h 2009-01-04 03:49:23 UTC (rev 35714)
@@ -1027,6 +1027,7 @@
virtual void palManipulateInit(int resID, int start, int end, int time);
void palManipulate();
public:
+ int convert16BitColor(uint16 color, uint8 r, uint8 g, uint8 b);
int remapPaletteColor(int r, int g, int b, int threshold); // Used by Actor::remapActorPalette
protected:
void moveMemInPalRes(int start, int end, byte direction);
@@ -1102,6 +1103,7 @@
// HE specific
byte _HEV7ActorPalette[256];
uint8 *_hePalettes;
+ int16 *_hePaletteCache;
protected:
int _shadowPaletteSize;
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