[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.216,1.217 intern.h,2.422,2.423 module.mk,1.47,1.48 script_v90he.cpp,2.214,2.215 scumm.cpp,1.406,1.407 scumm.h,1.565,1.566 wiz_he.cpp,2.40,2.41 wiz_he.h,2.15,2.16

kirben kirben at users.sourceforge.net
Thu Apr 7 03:51:11 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26934/scumm

Modified Files:
	akos.cpp intern.h module.mk script_v90he.cpp scumm.cpp scumm.h 
	wiz_he.cpp wiz_he.h 
Log Message:

Add WIP on hePalette.


Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -d -r1.216 -r1.217
--- akos.cpp	4 Apr 2005 11:41:13 -0000	1.216
+++ akos.cpp	7 Apr 2005 10:43:43 -0000	1.217
@@ -289,23 +289,26 @@
 	uint size, i;
 
 	size = _vm->getResourceDataSize(akpl);
+	if (size == 0)
+		return;
 
 	if (size > 256)
 		error("akos_setPalette: %d is too many colors", size);
 
-	for (i = 0; i < size; i++) {
-		palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i];
+	if (_vm->_heversion >= 99 && _paletteNum) {
+		for (i = 0; i < size; i++)
+			palette[i] = (byte)_vm->_hePalettes[_paletteNum * 1024 + 768 + akpl[i]];
+	} else {
+		for (i = 0; i < size; i++) {
+			palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i];
+		}
 	}
 
-	if (_paletteNum) {
-		// TODO
-		// Sets palette number to use for actor palette
-	}
 
-	if (_vm->_heversion == 70 && size) {
+	if (_vm->_heversion == 70) {
 		for (i = 0; i < size; i++)
 			palette[i] = _vm->_HEV7ActorPalette[palette[i]];
-	}
+	} 
 
 	if (size == 256) {
 		byte color = new_palette[0];
@@ -1256,8 +1259,13 @@
 	if (_draw_bottom < dst.bottom)
 		_draw_bottom = dst.bottom;
 
+	const uint8 *palPtr = NULL;
+	if (_vm->_heversion >= 99) {
+		palPtr = _vm->_hePalettes + 1792;
+	}
+
 	byte *dstPtr = (byte *)_out.pixels + dst.left + dst.top * _out.pitch;
-	Wiz::decompressWizImage(dstPtr, _out.pitch, dst, _srcptr, src);
+	Wiz::decompressWizImage(dstPtr, _out.pitch, dst, _srcptr, src, palPtr);
 	return 0;
 }
 

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.422
retrieving revision 2.423
diff -u -d -r2.422 -r2.423
--- intern.h	6 Apr 2005 23:56:50 -0000	2.422
+++ intern.h	7 Apr 2005 10:43:50 -0000	2.423
@@ -901,7 +901,6 @@
 
 	int _heObject, _heObjectNum;
 	int _hePaletteNum;
-	uint8 *_hePalettes;
 	
 	const OpcodeEntryV90he *_opcodesV90he;
 	FloodStateParameters _floodStateParams;
@@ -940,6 +939,7 @@
 	void sortArray(int array, int dim2start, int dim2end, int dim1start, int dim1end, int sortOrder);
 	
 	uint8 *getHEPalette(int palSlot);
+	uint8 *getHEPaletteIndex(int palSlot);
 	int getHEPaletteColor(int palSlot, int color);
 	void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b);
 	void setHEPaletteFromPtr(int palSlot, const uint8 *palData);
@@ -1089,7 +1089,19 @@
 	void o90_kernelSetFunctions();
 };
 
-class ScummEngine_v100he : public ScummEngine_v90he {
+class ScummEngine_v99he : public ScummEngine_v90he {
+public:
+	ScummEngine_v99he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v90he(detector, syst, gs, md5sum) {}
+
+protected:
+	virtual void copyPalColor(int dst, int src);
+	virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
+	virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
+	virtual void setPalColor(int index, int r, int g, int b);
+	virtual void updatePalette();
+};
+
+class ScummEngine_v100he : public ScummEngine_v99he {
 protected:
 	typedef void (ScummEngine_v100he::*OpcodeProcV100he)();
 	struct OpcodeEntryV100he {
@@ -1102,7 +1114,7 @@
 	const OpcodeEntryV100he *_opcodesV100he;
 
 public:
-	ScummEngine_v100he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v90he(detector, syst, gs, md5sum) {}
+	ScummEngine_v100he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v99he(detector, syst, gs, md5sum) {}
 
 protected:
 	virtual void setupOpcodes();

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- module.mk	7 Apr 2005 07:29:19 -0000	1.47
+++ module.mk	7 Apr 2005 10:43:51 -0000	1.48
@@ -23,6 +23,7 @@
 	scumm/nut_renderer.o \
 	scumm/object.o \
 	scumm/palette.o \
+	scumm/palette_he.o \
 	scumm/player_mod.o \
 	scumm/player_v1.o \
 	scumm/player_nes.o \

Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.214
retrieving revision 2.215
diff -u -d -r2.214 -r2.215
--- script_v90he.cpp	6 Apr 2005 23:56:50 -0000	2.214
+++ script_v90he.cpp	7 Apr 2005 10:43:51 -0000	2.215
@@ -2131,11 +2131,20 @@
 }
 
 uint8 *ScummEngine_v90he::getHEPalette(int palSlot) {
-	assert(palSlot >= 1 && palSlot <= _numPalettes);
-	if (palSlot == 1) {
-		return _currentPalette; // XXX won't work, as size == 768
+	if (palSlot) {
+		assert(palSlot >= 1 && palSlot <= _numPalettes);
+		return _hePalettes + palSlot * 1024 + 768;
 	} else {
-		return _hePalettes + (palSlot - 2) * 1024;
+		return _hePalettes + 1768;
+	}
+}
+
+uint8 *ScummEngine_v90he::getHEPaletteIndex(int palSlot) {
+	if (palSlot) {
+		assert(palSlot >= 1 && palSlot <= _numPalettes);
+		return _hePalettes + palSlot * 1024;
+	} else {
+		return _hePalettes + 1024;
 	}
 }
 
@@ -2165,6 +2174,11 @@
 		*pc++ = *palData++;
 		*pi++ = i;
 	}
+	for (int i = 0; i < 10; ++i)
+		_hePalettes[palSlot * 1024 + 768 + i] = 1;
+	for (int i = 246; i < 256; ++i)
+		_hePalettes[palSlot * 1024 + 768 + i] = 1;
+	
 }
 
 void ScummEngine_v90he::setHEPaletteFromCostume(int palSlot, int resId) {
@@ -2205,7 +2219,7 @@
 	assert(dstPalSlot >= 1 && dstPalSlot <= _numPalettes);
 	assert(srcPalSlot >= 1 && srcPalSlot <= _numPalettes);
 	if (dstPalSlot != srcPalSlot) {
-		memcpy(_hePalettes + srcPalSlot * 1024, _hePalettes + dstPalSlot * 1024, 1024);
+		memcpy(_hePalettes + dstPalSlot * 1024, _hePalettes + srcPalSlot * 1024, 1024);
 	}
 }
 
@@ -2214,7 +2228,7 @@
 	uint8 *dstPal = _hePalettes + palSlot * 1024 + dstColor * 3;
 	uint8 *srcPal = _hePalettes + (palSlot + 1) * 1024 + srcColor * 3;
 	memcpy(dstPal, srcPal, 3);
-	*(_hePalettes + palSlot * 1024 + 768 + dstColor) = srcColor;
+	_hePalettes[palSlot * 1024 + 768] = srcColor;
 }
 
 void ScummEngine_v90he::o90_getPaletteData() {
@@ -2225,6 +2239,13 @@
 
 	switch (subOp) {
 	case 0:
+		pop();
+		pop();
+		pop();
+		pop();
+		pop();
+		pop();
+		push(0);
 		break;
 	case 7:
 		pop();
@@ -2251,7 +2272,7 @@
 	default:
 		error("o90_getPaletteData: Unknown case %d", subOp);
 	}
-	debug(1,"o90_getPaletteData stub (%d)", subOp);
+	debug(0,"o90_getPaletteData stub (%d)", subOp);
 }
 
 void ScummEngine_v90he::o90_paletteOps() {
@@ -2323,7 +2344,7 @@
 	default:
 		error("o90_paletteOps: Unknown case %d", subOp);
 	}
-	debug(1,"o90_paletteOps stub (%d)", subOp);
+	debug(0,"o90_paletteOps stub (%d)", subOp);
 }
 
 

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.406
retrieving revision 1.407
diff -u -d -r1.406 -r1.407
--- scumm.cpp	7 Apr 2005 07:29:19 -0000	1.406
+++ scumm.cpp	7 Apr 2005 10:43:51 -0000	1.407
@@ -3295,9 +3295,10 @@
 		case 100:
 			engine = new ScummEngine_v100he(detector, syst, game, md5sum);
 			break;
+		case 99:
+			engine = new ScummEngine_v99he(detector, syst, game, md5sum);
 		case 90:
 		case 98:
-		case 99:
 			engine = new ScummEngine_v90he(detector, syst, game, md5sum);
 			break;
 		case 80:

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.565
retrieving revision 1.566
diff -u -d -r1.565 -r1.566
--- scumm.h	6 Apr 2005 17:31:13 -0000	1.565
+++ scumm.h	7 Apr 2005 10:43:51 -0000	1.566
@@ -439,7 +439,7 @@
 	// Cursor/palette
 	void updateCursor();
 	virtual void animateCursor() {}
-	void updatePalette();
+	virtual void updatePalette();
 	virtual void saveOrLoadCursorImages(Serializer *s) {}
 
 	/**
@@ -983,12 +983,12 @@
 	void setupV1ManiacPalette();
 	void setupV1ZakPalette();
 	void setPalette(int pal, int room);
-	void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
-	void setPalColor(int index, int r, int g, int b);
+	virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
+	virtual void setPalColor(int index, int r, int g, int b);
 	void setDirtyColors(int min, int max);
 	const byte *findPalInPals(const byte *pal, int index);
 	void swapPalColors(int a, int b);
-	void copyPalColor(int dst, int src);
+	virtual void copyPalColor(int dst, int src);
 	void cyclePalette();
 	void stopCycle(int i);
 	virtual void palManipulateInit(int resID, int start, int end, int time);
@@ -999,7 +999,7 @@
 	void moveMemInPalRes(int start, int end, byte direction);
 	void setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
 	void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
-	void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
+	virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
 	void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor);
 
 	void setupCursor();
@@ -1089,6 +1089,7 @@
 	bool testGfxOtherUsageBits(int strip, int bit);
 
 public:
+	uint8 *_hePalettes;
 	byte _HEV7ActorPalette[256];
 	byte _roomPalette[256];
 	byte *_shadowPalette;

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.40
retrieving revision 2.41
diff -u -d -r2.40 -r2.41
--- wiz_he.cpp	6 Apr 2005 17:31:35 -0000	2.40
+++ wiz_he.cpp	7 Apr 2005 10:43:51 -0000	2.41
@@ -271,11 +271,11 @@
 	return srcRect.isValidRect() && dstRect.isValidRect();
 }
 
-void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) {
+void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr) {
 	Common::Rect r1, r2;
 	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
 		dst += r2.left + r2.top * dstw;
-		decompressWizImage(dst, dstw, r2, src, r1);
+		decompressWizImage(dst, dstw, r2, src, r1, palPtr);
 	}
 }
 
@@ -324,7 +324,7 @@
 	}
 }
 
-void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *imagePal) {
+void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dstPtr, *dstPtrNext;
 	uint32 code;
@@ -332,6 +332,14 @@
 	int h, w, xoff;
 	uint16 off;
 	
+	byte imagePal[256];
+	if (!palPtr) {
+		for (int i = 0; i < 256; i++) {
+			imagePal[i] = i;
+		}
+		palPtr = imagePal;
+	}
+
 	dstPtr = dst;
 	dataPtr = src;
 	
@@ -406,10 +414,7 @@
 					if (w < 0) {
 						code += w;
 					}
-					uint8 color = *dataPtr++;
-					if (imagePal) {
-						color = imagePal[color];
-					}
+					uint8 color = imagePal[*dataPtr++];
 					memset(dstPtr, color, code);
 					dstPtr += code;
 				} else {
@@ -417,14 +422,8 @@
 					if (w < 0) {
 						code += w;
 					}
-					if (imagePal) {
-						while (code--) {
-							*dstPtr++ = imagePal[*dataPtr++];
-						}
-					} else {
-						memcpy(dstPtr, dataPtr, code);
-						dstPtr += code;
-						dataPtr += code;
+					while (code--) {
+						*dstPtr++ = imagePal[*dataPtr++];
 					}
 				}
 			}
@@ -785,7 +784,12 @@
 	Common::Rect rCapt(pvs->w, pvs->h);
 	if (rCapt.intersects(r)) {
 		rCapt.clip(r);
-		const uint8 *palPtr = _currentPalette;
+		const uint8 *palPtr;
+		if (_heversion >= 99) {
+			palPtr = _hePalettes + 1024;
+		} else {
+			palPtr = _currentPalette;
+		}
 
 		int w = rCapt.width();
 		int h = rCapt.height();
@@ -873,12 +877,20 @@
 }
 
 uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, int xmapNum, const Common::Rect *clipBox, int flags, int dstResNum, int paletteNum) {
-	debug(1, "drawWizImage(%d, %d, %d, 0x%X)", resNum, x1, y1, flags);
+	debug(1, "drawWizImage(resNum %d, x1 %d, y1 %d, flags 0x%X, xmapNum %d paletteNum %d)", resNum, x1, y1, flags, xmapNum, paletteNum);
 	uint8 *dst = NULL;
+	const uint8 *palPtr = NULL;
+	if (_heversion >= 99) {
+		if (paletteNum) {
+			palPtr = _hePalettes + paletteNum * 1024 + 768;
+		} else {
+			palPtr = _hePalettes + 1792;
+		}
+	}
 	uint8 *dataPtr = getResourceAddress(rtImage, resNum);
 	if (dataPtr) {
 		uint8 *rmap = NULL;
-		uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, state, 0);
+		//uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, state, 0);
 		
 		uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
 		assert(wizh);
@@ -959,16 +971,15 @@
 			} else if (flags & 0x100) {
 				warning("drawWizImage() unhandled flag 0x100");
 			} else {
-				_wiz.copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen);
+				_wiz.copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
 			}
 		} else if (comp == 0 || comp == 2 || comp == 3) {
 			uint8 *trns = findWrappedBlock(MKID('TRNS'), dataPtr, state, 0);
 			int color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1;
-			const uint8 *pal = xmap;
 			if (flags & kWIFRemapPalette) {
-				pal = rmap + 4;
+				palPtr = rmap + 4;
 			}
-			_wiz.copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, pal, color);
+			_wiz.copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
 		} else {
 			warning("unhandled wiz compression type %d", comp);
 		}
@@ -1114,6 +1125,7 @@
 }
 
 void ScummEngine_v72he::drawWizPolygon(int resNum, int state, int id, int flags, int xmapNum, int dstResNum, int paletteNum) {
+	debug(1, "drawWizPolygon(resNum %d, id %d, flags 0x%X, xmapNum %d paletteNum %d)", resNum, id, flags, xmapNum, paletteNum);
 	int i;
 	WizPolygon *wp = NULL;
 	for (i = 0; i < ARRAYSIZE(_wiz._polygons); ++i) {
@@ -1374,6 +1386,12 @@
 	}
 	res_size += 8 + img_w * img_h;
 	
+	const uint8 *palPtr;
+	if (_heversion >= 99) {
+		palPtr = _hePalettes + 1024;
+	} else {
+		palPtr = _currentPalette;
+	}
 	uint8 *res_data = res.createResource(rtImage, params->img.resNum, res_size);
 	if (!res_data) {
 		VAR(119) = -1;
@@ -1389,7 +1407,7 @@
 		if (flags & 1) {
 			WRITE_BE_UINT32(res_data, 'RGBS'); res_data += 4;
 			WRITE_BE_UINT32(res_data, 0x308); res_data += 4;
-			memcpy(res_data, _currentPalette, 0x300); res_data += 0x300;			
+			memcpy(res_data, palPtr, 0x300); res_data += 0x300;			
 		}
 		if (flags & 2) {
 			WRITE_BE_UINT32(res_data, 'SPOT'); res_data += 4;

Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -d -r2.15 -r2.16
--- wiz_he.h	1 Apr 2005 12:43:13 -0000	2.15
+++ wiz_he.h	7 Apr 2005 10:43:51 -0000	2.16
@@ -132,9 +132,9 @@
 	void polygonRotatePoints(Common::Point *pts, int num, int alpha);
 
 	static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);	
-	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect);
+	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr = NULL);
 	static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
-	static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *imagePal = NULL);
+	static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr = NULL);
 	int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h);
 	uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
 	uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);





More information about the Scummvm-git-logs mailing list