[Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.90,1.91 actor.h,1.10,1.11 costume.cpp,1.36,1.37 object.cpp,1.76,1.77 scumm.h,1.182,1.183

Max Horn fingolfin at users.sourceforge.net
Mon Jul 15 15:57:03 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv11966

Modified Files:
	actor.cpp actor.h costume.cpp object.cpp scumm.h 
Log Message:
added Actor::isInClass convenience method; fixed typo in object.cpp; moved some functions from class Scumm to LoadedCostume

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- actor.cpp	15 Jul 2002 21:50:51 -0000	1.90
+++ actor.cpp	15 Jul 2002 22:56:24 -0000	1.91
@@ -197,12 +197,12 @@
 		flipY = (walkdata.YXFactor > 0);
 
 		// Check for X-Flip
-		if ((flags & 0x08) || _vm->getClass(number, 0x1E)) {
+		if ((flags & 0x08) || isInClass(0x1E)) {	// 0x1E = 30
 			dir = 360 - dir;
 			flipX = !flipX;
 		}
 		// Check for Y-Flip
-		if ((flags & 0x10) || _vm->getClass(number, 0x1D)) {
+		if ((flags & 0x10) || isInClass(0x1D)) {	// 0x1E = 29
 			dir = 180 - dir;
 			flipY = !flipY;
 		}
@@ -340,7 +340,7 @@
 
 	// FIXME: Special 'no scaling' class for MI1 VGA Floppy
 	//        Not totally sure if this is correct.
-	if (_vm->_gameId == GID_MONKEY_VGA && _vm->getClass(number, 0x96))
+	if (_vm->_gameId == GID_MONKEY_VGA && isInClass(0x96))
 		return;
 
 	if (_vm->_features & GF_NO_SCALLING) {
@@ -577,7 +577,7 @@
 	abr.y = dstY;
 	abr.dist = 0;
 
-	if ((_vm->_features & GF_SMALL_HEADER) && _vm->getClass(number, 22))
+	if ((_vm->_features & GF_SMALL_HEADER) && isInClass(22))
 		return abr;
 
 	if (ignoreBoxes == 0) {
@@ -598,7 +598,7 @@
 					|| !(_vm->_features & GF_SMALL_HEADER))
 				for (j = box; j >= firstValidBox; j--) {
 					flags = _vm->getBoxFlags(j);
-					if (flags & 0x80 && (!(flags & 0x20) || _vm->getClass(number, 0x1F)))
+					if (flags & 0x80 && (!(flags & 0x20) || isInClass(0x1F)))
 						continue;
 
 					if (pathfrom >= firstValidBox && (_vm->getPathToDestBox(pathfrom, j) == -1))
@@ -835,27 +835,24 @@
 
 void Actor::drawActorCostume()
 {
-	if (!(_vm->_features & GF_AFTER_V7)) {
-		CostumeRenderer cr;
-
-		if (!needRedraw)
-			return;
+	if (!needRedraw)
+		return;
 
-		if (_vm->getClass(number, 20))
-			mask = 0;
-		else if (_vm->getClass(number, 21))
-			forceClip = 1;
+	// FIXME: ugly fix for samnmax inventory
+	if (_vm->_gameId == GID_SAMNMAX && _vm->getState(995))
+		return;
 
-		// FIXME: ugly fix for samnmax inventory
-		if (_vm->_gameId == GID_SAMNMAX && _vm->getState(995))
-			return;
+	needRedraw = false;
 
-		needRedraw = false;
+	setupActorScale();
 
-		setupActorScale();
+	if (!(_vm->_features & GF_AFTER_V7)) {
+		CostumeRenderer cr(_vm);
 
-		/* First, zero initialize all fields */
-		memset(&cr, 0, sizeof(cr));
+		if (isInClass(20))
+			mask = 0;
+		else if (isInClass(21))
+			forceClip = 1;
 
 		cr._actorX = x - _vm->virtscr->xstart;
 		cr._actorY = y - elevation;
@@ -863,7 +860,6 @@
 		cr._scaleY = scaley;
 
 		cr._outheight = _vm->virtscr->height;
-		cr._vm = _vm;
 
 		cr._zbuf = mask;
 		if (cr._zbuf > _vm->gdi._numZBuffer)
@@ -889,13 +885,6 @@
 	} else {
 		AkosRenderer ar(_vm);
 
-		if (!needRedraw)
-			return;
-
-		needRedraw = false;
-
-		setupActorScale();
-
 		ar.x = x - _vm->virtscr->xstart;
 		ar.y = y - elevation;
 		ar.scale_x = scalex;
@@ -948,9 +937,9 @@
 				needBgReset = true;
 			}
 		} else {
-			LoadedCostume lc;
-			_vm->loadCostume(&lc, costume);
-			if (_vm->cost_increaseAnims(&lc, this)) {
+			LoadedCostume lc(_vm);
+			lc.loadCostume(costume);
+			if (lc.increaseAnims(this)) {
 				needRedraw = true;
 				needBgReset = true;
 			}
@@ -1389,4 +1378,9 @@
 	for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
 		a->needBgReset = false;
 	}
+}
+
+bool Actor::isInClass(int cls)
+{
+	return _vm->getClass(number, cls);
 }

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- actor.h	15 Jul 2002 01:38:52 -0000	1.10
+++ actor.h	15 Jul 2002 22:56:24 -0000	1.11
@@ -161,6 +161,8 @@
 		animVariable[var] = value;
 	}
 
+protected:
+	bool isInClass(int cls);
 };
 
 #endif

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/costume.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- costume.cpp	7 Jul 2002 20:25:23 -0000	1.36
+++ costume.cpp	15 Jul 2002 22:56:24 -0000	1.37
@@ -790,8 +790,7 @@
 
 }
 
-#if 0
-void CostumeRenderer::loadCostume(int id)
+void LoadedCostume::loadCostume(int id)
 {
 	_ptr = _vm->getResourceAddress(rtCostume, id);
 
@@ -820,7 +819,6 @@
 
 	_dataptr = _ptr + READ_LE_UINT16(_ptr + _numColors + 8);
 }
-#endif
 
 byte CostumeRenderer::drawOneSlot(Actor *a, int slot)
 {
@@ -867,36 +865,6 @@
 	return newDirToOldDir(a->facing) + frame * 4;
 }
 
-void Scumm::loadCostume(LoadedCostume *lc, int costume)
-{
-	lc->_ptr = getResourceAddress(rtCostume, costume);
-
-	if (_features & GF_AFTER_V6) {
-		lc->_ptr += 8;
-	} else if (!(_features & GF_SMALL_HEADER)) {
-		lc->_ptr += 2;
-	}
-
-	switch (lc->_ptr[7] & 0x7F) {
-	case 0x58:
-		lc->_numColors = 16;
-		break;
-	case 0x59:
-		lc->_numColors = 32;
-		break;
-	case 0x60:										/* New since version 6 */
-		lc->_numColors = 16;
-		break;
-	case 0x61:										/* New since version 6 */
-		lc->_numColors = 32;
-		break;
-	default:
-		error("Costume %d is invalid", costume);
-	}
-
-	lc->_dataptr = lc->_ptr + READ_LE_UINT16(lc->_ptr + lc->_numColors + 8);
-}
-
 void Scumm::cost_decodeData(Actor *a, int frame, uint usemask)
 {
 	byte *p, *r;
@@ -905,9 +873,9 @@
 	byte extra, cmd;
 	byte *dataptr;
 	int anim;
-	LoadedCostume lc;
+	LoadedCostume lc(this);
 
-	loadCostume(&lc, a->costume);
+	lc.loadCostume(a->costume);
 
 	anim = cost_frameToAnim(a, frame);
 
@@ -992,22 +960,22 @@
 
 void CostumeRenderer::setCostume(int costume)
 {
-	_vm->loadCostume(&_loaded, costume);
+	_loaded.loadCostume(costume);
 }
 
-byte Scumm::cost_increaseAnims(LoadedCostume *lc, Actor *a)
+byte LoadedCostume::increaseAnims(Actor *a)
 {
 	int i;
 	byte r = 0;
 
 	for (i = 0; i != 16; i++) {
 		if (a->cost.curpos[i] != 0xFFFF)
-			r += cost_increaseAnim(lc, a, i);
+			r += increaseAnim(a, i);
 	}
 	return r;
 }
 
-byte Scumm::cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot)
+byte LoadedCostume::increaseAnim(Actor *a, int slot)
 {
 	int highflag;
 	int i, end;
@@ -1019,7 +987,7 @@
 	highflag = a->cost.curpos[slot] & 0x8000;
 	i = a->cost.curpos[slot] & 0x7FFF;
 	end = a->cost.end[slot];
-	code = lc->_dataptr[i] & 0x7F;
+	code = _dataptr[i] & 0x7F;
 
 	do {
 		if (!highflag) {
@@ -1029,16 +997,16 @@
 			if (i != end)
 				i++;
 		}
-		nc = lc->_dataptr[i];
+		nc = _dataptr[i];
 
 		if (nc == 0x7C) {
 			a->cost.animCounter1++;
 			if (a->cost.start[slot] != end)
 				continue;
 		} else {
-			if (_features & GF_AFTER_V6) {
+			if (_vm->_features & GF_AFTER_V6) {
 				if (nc >= 0x71 && nc <= 0x78) {
-					addSoundToQueue2(a->sound[nc - 0x71]);
+					_vm->addSoundToQueue2(a->sound[nc - 0x71]);
 					if (a->cost.start[slot] != end)
 						continue;
 				}
@@ -1052,7 +1020,7 @@
 		}
 
 		a->cost.curpos[slot] = i | highflag;
-		return (lc->_dataptr[i] & 0x7F) != code;
+		return (_dataptr[i] & 0x7F) != code;
 	} while (1);
 }
 

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/object.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- object.cpp	7 Jul 2002 20:21:42 -0000	1.76
+++ object.cpp	15 Jul 2002 22:56:24 -0000	1.77
@@ -44,7 +44,7 @@
 {
 	checkRange(_numGlobalObjects - 1, 0, obj, "Object %d out of range in putClass");
 	cls &= 0x7F;
-	checkRange(32, 1, cls, "Class %d out of range in getClass");
+	checkRange(32, 1, cls, "Class %d out of range in putClass");
 
 
 	if (_features & GF_SMALL_HEADER) {

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- scumm.h	15 Jul 2002 21:50:51 -0000	1.182
+++ scumm.h	15 Jul 2002 22:56:24 -0000	1.183
@@ -351,18 +351,31 @@
 	void addLinebreaks(int a, byte *str, int pos, int maxwidth);
 };
 
-struct LoadedCostume {
+class LoadedCostume {
+protected:
+	Scumm *_vm;
+
+public:
 	byte *_ptr;
 	byte *_dataptr;
 	byte _numColors;
-	
+
+	LoadedCostume(Scumm *vm) : _vm(vm), _ptr(0), _dataptr(0), _numColors(0) {}
+
+	void loadCostume(int id);
+	byte increaseAnims(Actor *a);
+
+protected:
+	byte increaseAnim(Actor *a, int slot);
 };
 
-struct CostumeRenderer {
+class CostumeRenderer {
+protected:
 	Scumm *_vm;
 	
 	LoadedCostume _loaded;
-		
+	
+public:
 	byte *_shadow_table;
 
 	byte *_frameptr;
@@ -414,6 +427,9 @@
 	void setPalette(byte *palette);
 	void setFacing(uint16 facing);
 	void setCostume(int costume);
+
+public:
+	CostumeRenderer(Scumm *vm) : _vm(vm), _loaded(vm) {}
 };
 
 #define ARRAY_HDR_SIZE 6
@@ -873,9 +889,6 @@
 	int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f);
 
 	/* Should be in Costume class */
-	void loadCostume(LoadedCostume *lc, int costume);
-	byte cost_increaseAnims(LoadedCostume *lc, Actor *a);
-	byte cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot);
 	void cost_decodeData(Actor *a, int frame, uint usemask);
 	int cost_frameToAnim(Actor *a, int frame);
 





More information about the Scummvm-git-logs mailing list