[Scummvm-cvs-logs] CVS: scummvm/scumm costume.cpp,1.159,1.160 gfx.cpp,2.400,2.401

kirben kirben at users.sourceforge.net
Mon Mar 14 20:07:00 CET 2005


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

Modified Files:
	costume.cpp gfx.cpp 
Log Message:

Patch from Quietust:
Animated costumes for NES maniac.


Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- costume.cpp	15 Mar 2005 02:47:36 -0000	1.159
+++ costume.cpp	15 Mar 2005 04:05:14 -0000	1.160
@@ -593,7 +593,7 @@
 	frameset = 0;
 	framenum = 0;
 
-	src = _baseptr + 4;
+	src = _dataOffsets;
 	// Cost(a)
 	offset = src[(frameset * 4 + framenum) * 2];
 
@@ -673,7 +673,7 @@
 
 void CostumeRenderer::drawNESCostume(const Actor *a, int limb) {
 	const byte *src;
-	int offset, numSprites, spritesOffset, numAnims;
+	int offset, numSprites;
 	byte *table, *ptr, *spritesDefs, *spritesOffsetTab, *numSpritesTab, *spritesPal;
 	const CostumeData &cost = a->_cost;
 	int anim = cost.frame[limb];
@@ -682,33 +682,27 @@
 	src = _loaded._dataOffsets;
 
 	// Cost(a)
-	offset = src[anim * 2];
-	numAnims = src[anim * 2 + 1];
+	int frame = src[src[8*anim + 2 * newDirToOldDir(a->getFacing())] + frameNum];
+	bool flipped = (newDirToOldDir(a->getFacing()) == 1);
 
 	// Lookup & desc
-	table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][0]);
-	offset = READ_LE_UINT16(table + v1MMNESLookup[_loaded._id] * 2 + 2);
+	table = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][0]) + 2;
+	offset = READ_LE_UINT16(table + v1MMNESLookup[_loaded._id] * 2);
 
 	// lens
-	numSpritesTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][1]);
-
+	numSpritesTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][1]) + 2 + offset;
 	// offs
-	spritesOffsetTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][2]);
-
+	spritesOffsetTab = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][2]) + 2 + offset*2;
 	// data
-	spritesDefs = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][3]);
-
+	spritesDefs = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][3]) + 2;
 	// data
 	spritesPal = _vm->getResourceAddress(rtCostume, v1MMNEScostTables[_vm->_v1MMNESCostumeSet][5]) + 2;
 
-	offset = READ_LE_UINT16(table + v1MMNESLookup[_loaded._id] * 2 + 2) + frameNum;
-	numSprites = numSpritesTab[offset + 2] + 1;
-	spritesOffset = READ_LE_UINT16(spritesOffsetTab + offset * 2 + 2);
-
-	ptr = spritesDefs + spritesOffset + 2;
+	ptr = spritesDefs + READ_LE_UINT16(spritesOffsetTab + frame*2);
+	numSprites = numSpritesTab[frame] + 1;
 
 	int left = 239, right = 0, top = 239, bottom = 0;
-  
+
 	for (int spr = 0; spr < numSprites; spr++) {
 		byte mask = (ptr[0] & 0x80) ? 0x01 : 0x80;
 		int8 y = ptr[0] << 1;	y >>= 1;
@@ -716,6 +710,11 @@
 		byte palette = (ptr[2] & 0x03) << 2;
 		int8 x = ptr[2];	x >>= 2;
 		ptr += 3;
+		if (flipped)
+		{
+			mask = (mask == 0x80) ? 0x01 : 0x80;
+			x = -x;
+		}
 
 		for (int ty = 0; ty < 8; ty++) {
 			byte c1 = _vm->_v1MMNESCostumeGfx[_vm->_v1MMNESCostumeSet][tile * 16 + ty];
@@ -743,7 +742,7 @@
 		if (bottom < _actorY + y + 8)
 			bottom = _actorY + y + 8;
 	}
-	_vm->markRectAsDirty(kMainVirtScreen, left, right, top, bottom);
+	_vm->markRectAsDirty(kMainVirtScreen,left,right,top,bottom);
 }
 
 byte CostumeRenderer::drawLimb(const Actor *a, int limb) {
@@ -805,30 +804,16 @@
 
 }
 
+extern void DecodeNESTileData(const byte *src, byte *dest);
+
 void ScummEngine::cost_decodeNESCostumeGfx() {
 	for (int n = 0; n < 2; n++) {
 		byte *patTable = getResourceAddress(rtCostume, v1MMNEScostTables[n][4]);
-		int j = 0;
-		int i = 3;
 		int maxSprites = patTable[2];
-		int len = READ_LE_UINT16(patTable);
-
 		if (maxSprites == 0)
-			maxSprites = 257;
-
+			maxSprites = 256;
 		_v1MMNESCostumeGfx[n] = (byte *)calloc(maxSprites * 16, 1);
-
-		while (i < len) {
-			if (patTable[i] & 0x80) {
-				for (int cnt = (patTable[i++] & 0x7F); cnt > 0; cnt--)
-					_v1MMNESCostumeGfx[n][j++] = patTable[i++];
-			} else {
-				for (int cnt = patTable[i++]; cnt > 0; cnt--)
-					_v1MMNESCostumeGfx[n][j++] = patTable[i];
-				i++;
-			}
-		}
-
+		DecodeNESTileData(patTable,_v1MMNESCostumeGfx[n]);
 		// We will not need it anymore
 		nukeResource(rtCostume, v1MMNEScostTables[n][4]);
 	}
@@ -857,6 +842,7 @@
 	if (_features & GF_NES) {
 		a->_cost.curpos[0] = 0;
 		a->_cost.start[0] = 0;
+		a->_cost.end[0] = getResourceAddress(rtCostume,a->_costume)[2+0*2+1];
 		a->_cost.frame[0] = frame;
 		return;
 	}
@@ -973,7 +959,7 @@
 
 	if (_vm->_features & GF_NES) {
 		a->_cost.curpos[slot]++;
-		if (a->_cost.curpos[slot] == _numAnim)
+		if (a->_cost.curpos[slot] >= a->_cost.end[slot])
 			a->_cost.curpos[slot] = a->_cost.start[slot];
 		return 0;
 	}

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.400
retrieving revision 2.401
diff -u -d -r2.400 -r2.401
--- gfx.cpp	14 Mar 2005 11:46:10 -0000	2.400
+++ gfx.cpp	15 Mar 2005 04:05:15 -0000	2.401
@@ -1875,13 +1875,18 @@
 
 void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int height) {
 //	printf("drawStripNES, pitch=%i, strip=%i, height=%i\n",dstPitch,stripnr,height);
-	if (height != 128)
-	{
-//		debug(0,"NES room data %i (not 128) pixels high!\n",height);
-		height = 128;
-	}
 	height /= 8;
 	int x = stripnr + 2;	// NES version has a 2 tile gap on each edge
+
+	if (height > 16) {
+//		debug(0,"NES room data %i (not 128) pixels high!\n",height);
+		height = 16;
+	}
+	if (x > 63)
+	{
+		debug(0,"NES tried to render invalid strip %i",stripnr);
+		return;
+	}
 	for (int y = 0; y < height; y++) {
 		int palette = (_NESAttributes[((y << 2) & 0x30) | ((x >> 2) & 0xF)] >> (((y & 2) << 1) | (x & 2))) & 0x3;
 		int tile = _NESNametable[y][x];





More information about the Scummvm-git-logs mailing list