diff options
| author | Max Horn | 2003-12-17 17:12:09 +0000 | 
|---|---|---|
| committer | Max Horn | 2003-12-17 17:12:09 +0000 | 
| commit | 3364949c82cec9330d95d6e5399ed46f370681e8 (patch) | |
| tree | bdd5e7faf34fb20bdd4a3ed974295a5947394f7c | |
| parent | 3661c7f06cb4ba4af8b9dc5f44267a48ddb0ad83 (diff) | |
| download | scummvm-rg350-3364949c82cec9330d95d6e5399ed46f370681e8.tar.gz scummvm-rg350-3364949c82cec9330d95d6e5399ed46f370681e8.tar.bz2 scummvm-rg350-3364949c82cec9330d95d6e5399ed46f370681e8.zip | |
Patch #861716: palManipulateInit for V6 games (I modified the patch a bit)
svn-id: r11718
| -rw-r--r-- | scumm/gfx.cpp | 69 | ||||
| -rw-r--r-- | scumm/intern.h | 2 | ||||
| -rw-r--r-- | scumm/script_v5.cpp | 2 | ||||
| -rw-r--r-- | scumm/scumm.h | 4 | 
4 files changed, 59 insertions, 18 deletions
| diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 4bf3af464b..7b9c3a2a83 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -25,6 +25,7 @@  #include "scumm/actor.h"  #include "scumm/bomp.h"  #include "scumm/charset.h" +#include "scumm/intern.h"  #include "scumm/resource.h"  #include "scumm/usage_bits.h" @@ -2870,23 +2871,23 @@ void ScummEngine::moveMemInPalRes(int start, int end, byte direction) {  	doCyclePalette(_palManipIntermediatePal, start, end, 6, !direction);  } -void ScummEngine::palManipulateInit(int start, int end, int string_id, int time) { +void ScummEngine::palManipulateInit(int resID, int start, int end, int time) {  	byte *pal, *target, *between;  	byte *string1, *string2, *string3;  	int i; -	string1 = getStringAddress(string_id); -	string2 = getStringAddress(string_id + 1); -	string3 = getStringAddress(string_id + 2); +	string1 = getStringAddress(resID); +	string2 = getStringAddress(resID + 1); +	string3 = getStringAddress(resID + 2);  	if (!string1 || !string2 || !string3) {  		warning("palManipulateInit(%d,%d,%d,%d): Cannot obtain string resources %d, %d and %d", -				start, end, string_id, time, string_id, string_id + 1, string_id + 2); +				resID, start, end, time, resID, resID + 1, resID + 2);  		return;  	} -	string1+=start; -	string2+=start; -	string3+=start; +	string1 += start; +	string2 += start; +	string3 += start;  	_palManipStart = start;  	_palManipEnd = end; @@ -2916,6 +2917,44 @@ void ScummEngine::palManipulateInit(int start, int end, int string_id, int time)  	_palManipCounter = time;  } +void ScummEngine_v6::palManipulateInit(int resID, int start, int end, int time) { +	byte *pal, *target, *between; +	const byte *new_pal; +	int i; + +	new_pal = getPalettePtr(resID); + +	new_pal += start*3; + +	_palManipStart = start; +	_palManipEnd = end; +	_palManipCounter = 0; + +	if (!_palManipPalette) +		_palManipPalette = (byte *)calloc(0x300, 1); +	if (!_palManipIntermediatePal) +		_palManipIntermediatePal = (byte *)calloc(0x600, 1); + +	pal = _currentPalette + start * 3; +	target = _palManipPalette + start * 3; +	between = _palManipIntermediatePal + start * 6; + +	for (i = start; i < end; ++i) { +		*target++ = *new_pal++; +		*target++ = *new_pal++; +		*target++ = *new_pal++; +		*(uint16 *)between = ((uint16) *pal++) << 8; +		between += 2; +		*(uint16 *)between = ((uint16) *pal++) << 8; +		between += 2; +		*(uint16 *)between = ((uint16) *pal++) << 8; +		between += 2; +	} + +	_palManipCounter = time; +} + +  void ScummEngine::palManipulate() {  	byte *target, *pal, *between;  	int i, j; @@ -2969,7 +3008,7 @@ void ScummEngine::setupShadowPalette(int slot, int redScale, int greenScale, int  }  void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) { -	const byte *basepal = getPalettePtr(); +	const byte *basepal = getPalettePtr(_curPalIndex);  	const byte *pal = basepal;  	const byte *compareptr;  	byte *table = _shadowPalette; @@ -3054,7 +3093,7 @@ void ScummEngine::createSpecialPalette(int16 from, int16 to, int16 redScale, int  	int i, j; -	palPtr = getPalettePtr(); +	palPtr = getPalettePtr(_curPalIndex);  	for (i = 0; i < 256; i++)  		_proc_special_palette[i] = i; @@ -3103,7 +3142,7 @@ void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int  		int j;  		int color; -		cptr = getPalettePtr() + startColor * 3; +		cptr = getPalettePtr(_curPalIndex) + startColor * 3;  		cur = _currentPalette + startColor * 3;  		for (j = startColor; j <= endColor; j++) { @@ -3163,7 +3202,7 @@ void ScummEngine::desaturatePalette(int hueScale, int satScale, int lightScale,  		byte *cur;  		int j; -		cptr = getPalettePtr() + startColor * 3; +		cptr = getPalettePtr(_curPalIndex) + startColor * 3;  		cur = _currentPalette + startColor * 3;  		for (j = startColor; j <= endColor; j++) { @@ -3330,7 +3369,7 @@ void ScummEngine::setPalette(int palindex) {  	const byte *pals;  	_curPalIndex = palindex; -	pals = getPalettePtr(); +	pals = getPalettePtr(_curPalIndex);  	setPaletteFromPtr(pals);  } @@ -3354,7 +3393,7 @@ const byte *ScummEngine::findPalInPals(const byte *pal, int idx) {  	return offs + READ_LE_UINT32(offs + idx * sizeof(uint32));  } -const byte *ScummEngine::getPalettePtr() { +const byte *ScummEngine::getPalettePtr(int palindex) {  	const byte *cptr;  	cptr = getResourceAddress(rtRoom, _roomResource); @@ -3362,7 +3401,7 @@ const byte *ScummEngine::getPalettePtr() {  	if (_CLUT_offs) {  		cptr += _CLUT_offs;  	} else { -		cptr = findPalInPals(cptr + _PALS_offs, _curPalIndex); +		cptr = findPalInPals(cptr + _PALS_offs, palindex);  	}  	assert(cptr);  	return cptr; diff --git a/scumm/intern.h b/scumm/intern.h index 770a396cb4..3a6ea3b846 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -343,6 +343,8 @@ protected:  	virtual void setupScummVars(); +	virtual void palManipulateInit(int resID, int start, int end, int time); +  	virtual void decodeParseString(int a, int b);  	int getStackList(int *args, uint maxnum); diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 01269d2604..81e0b00b77 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -1986,7 +1986,7 @@ void ScummEngine_v5::o5_roomOps() {  		c = getVarOrDirectByte(PARAM_2);  		_opcode = fetchScriptByte();  		d = getVarOrDirectByte(PARAM_1); -		palManipulateInit(b, c, a, d); +		palManipulateInit(a, b, c, d);  		break;  	case 16:	// SO_CYCLE_SPEED diff --git a/scumm/scumm.h b/scumm/scumm.h index 7677019072..ca6f3f8ae8 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -827,7 +827,7 @@ protected:  	void clampCameraPos(Common::Point *pt);  	void actorFollowCamera(int act); -	const byte *getPalettePtr(); +	const byte *getPalettePtr(int palindex);  	void setupAmigaPalette();  	void setupEGAPalette();  	void setupV1ManiacPalette(); @@ -842,7 +842,7 @@ protected:  	void copyPalColor(int dst, int src);  	void cyclePalette();  	void stopCycle(int i); -	void palManipulateInit(int start, int end, int string_id, int time); +	virtual void palManipulateInit(int resID, int start, int end, int time);  	void palManipulate();  public:  	int remapPaletteColor(int r, int g, int b, uint threshold);		// Used by Actor::remapActorPalette | 
