[Scummvm-cvs-logs] SF.net SVN: scummvm: [26855] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Wed May 16 21:23:15 CEST 2007


Revision: 26855
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26855&view=rev
Author:   peres001
Date:     2007-05-16 12:23:14 -0700 (Wed, 16 May 2007)

Log Message:
-----------
Replaced explicit bitmasks with function calls.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/callables.cpp
    scummvm/trunk/engines/parallaction/commands.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/zone.cpp
    scummvm/trunk/engines/parallaction/zone.h

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-05-16 19:23:14 UTC (rev 26855)
@@ -93,7 +93,7 @@
 			int16 _si = _zoneTypeNames->lookup(_tokens[1]);
 			if (_si != -1) {
 				vD0->_type |= 1 << (_si-1);
-				if (((vD0->_type & 0xFFFF) != kZoneNone) && ((vD0->_type & 0xFFFF) != kZoneCommand)) {
+				if ((vD0->type() != kZoneNone) && (vD0->type() != kZoneCommand)) {
 					parseZoneTypeBlock(script, vD0);
 				}
 			}

Modified: scummvm/trunk/engines/parallaction/callables.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables.cpp	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/callables.cpp	2007-05-16 19:23:14 UTC (rev 26855)
@@ -301,15 +301,15 @@
 		pal0[(i+FIRST_BASE_COLOR)] = _vm->_gfx->_palette[i];
 		pal0[(i+FIRST_BASE_COLOR)*3+1] = 0;
 		pal0[(i+FIRST_BASE_COLOR)*3+2] = 0;
-		pal0[(i+FIRST_EHB_COLOR)*3+1] = 0;
-		pal0[(i+FIRST_EHB_COLOR)*3+2] = 0;
+//		pal0[(i+FIRST_EHB_COLOR)*3+1] = 0;
+//		pal0[(i+FIRST_EHB_COLOR)*3+2] = 0;
 	}
 
 	for (uint16 _di = 0; _di < 30; _di++) {
 		g_system->delayMillis(20);
 		_vm->_gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS);
-		g_system->delayMillis(20);
-		_vm->_gfx->setPalette(pal0, FIRST_EHB_COLOR, EHB_PALETTE_COLORS);
+//		g_system->delayMillis(20);
+//		_vm->_gfx->setPalette(pal0, FIRST_EHB_COLOR, EHB_PALETTE_COLORS);
 	}
 
 	_vm->_gfx->setPalette(_vm->_gfx->_palette);
@@ -369,8 +369,7 @@
 		_vm->_gfx->displayCenteredString(130, v2C[_language]);
 		_vm->_gfx->displayCenteredString(160, v1C[_language]);
 
-		_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
-		_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2);
+		_vm->_gfx->updateScreen();
 		waitUntilLeftClick();
 
 		strcpy(_vm->_location._name, "estgrotta.drki");
@@ -383,8 +382,7 @@
 		_vm->_gfx->displayCenteredString(130, v6C[_language]);
 		_vm->_gfx->displayCenteredString(160, v5C[_language]);
 
-		_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
-		_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2);
+		_vm->_gfx->updateScreen();
 		waitUntilLeftClick();
 
 		_vm->_menu->selectCharacter();

Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/commands.cpp	2007-05-16 19:23:14 UTC (rev 26855)
@@ -283,7 +283,7 @@
 			if (u->_zone != NULL) {
 				u->_zone->_flags &= ~kFlagsRemove;
 				u->_zone->_flags |= kFlagsActive;
-				if ((u->_zone->_type & 0xFFFF) == kZoneGet) {
+				if (u->_zone->type() == kZoneGet) {
 					addJob(&jobDisplayDroppedItem, u->_zone, kPriority17 );
 				}
 			}

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-16 19:23:14 UTC (rev 26855)
@@ -561,7 +561,7 @@
 			return &_input;
 		}
 
-		if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) {
+		if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || (z->type() != kZoneCommand))) {
 			_input._event = kEvWalk;
 			return &_input;
 		}
@@ -584,7 +584,7 @@
 			return &_input;
 		}
 
-		if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
+		if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || (z->type() == kZoneCommand))) {
 
 			_input._zone = z;
 			if (z->_flags & kFlagsNoWalk) {

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-05-16 19:23:14 UTC (rev 26855)
@@ -121,8 +121,8 @@
 		// but we need to check it separately here. The same workaround is applied in hitZone.
 		if (((z->_top == -1) ||
 			((z->_left == -2) && (
-				(((z->_type & 0xFFFF) == kZoneMerge) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj1)) != 0) || (isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj2)) != 0))) ||
-				(((z->_type & 0xFFFF) == kZoneGet) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.get->_icon)) != 0)))
+				((z->type() == kZoneMerge) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj1)) != 0) || (isItemInInventory(MAKE_INVENTORY_ID(z->u.merge->_obj2)) != 0))) ||
+				((z->type() == kZoneGet) && ((isItemInInventory(MAKE_INVENTORY_ID(z->u.get->_icon)) != 0)))
 			))) &&
 			((_engineFlags & kEngineQuit) == 0)) {
 
@@ -152,7 +152,7 @@
 
 	TypeData *u = &z->u;
 
-	switch (z->_type & 0xFFFF) {
+	switch (z->type()) {
 	case kZoneExamine:	// examine Zone alloc
 		u->examine = new ExamineData;
 		break;
@@ -185,7 +185,7 @@
 
 	do {
 
-		switch (z->_type & 0xFFFF) {
+		switch (z->type()) {
 		case kZoneExamine: // examine Zone init
 			if (!scumm_stricmp(_tokens[0], "file")) {
 				u->examine->_filename = (char*)malloc(strlen(_tokens[1])+1);
@@ -374,11 +374,9 @@
 uint16 Parallaction::runZone(Zone *z) {
 	debugC(3, kDebugLocation, "runZone (%s)", z->_label._text);
 
-	uint16 subtype = z->_type & 0xFFFF;
+	debugC(3, kDebugLocation, "type = %x, id = %x",z->type(), z->boundId() >> 16);
+	switch(z->type()) {
 
-	debugC(3, kDebugLocation, "type = %x, object = %x", subtype, (z->_type & 0xFFFF0000) >> 16);
-	switch(subtype) {
-
 	case kZoneExamine:
 		if (z->u.examine->_filename) {
 			displayItemComment(z->u.examine);
@@ -544,15 +542,15 @@
 				// WORKAROUND: this huge condition is needed because we made TypeData a collection of structs
 				// instead of an union. So, merge->_obj1 and get->_icon were just aliases in the original engine,
 				// but we need to check it separately here. The same workaround is applied in freeZones.
-				if ((((z->_type & 0xFFFF) == kZoneMerge) && (((_si == z->u.merge->_obj1) && (_di == z->u.merge->_obj2)) || ((_si == z->u.merge->_obj2) && (_di == z->u.merge->_obj1)))) ||
-					(((z->_type & 0xFFFF) == kZoneGet) && ((_si == z->u.get->_icon) || (_di == z->u.get->_icon)))) {
+				if (((z->type() == kZoneMerge) && (((_si == z->u.merge->_obj1) && (_di == z->u.merge->_obj2)) || ((_si == z->u.merge->_obj2) && (_di == z->u.merge->_obj1)))) ||
+					((z->type() == kZoneGet) && ((_si == z->u.get->_icon) || (_di == z->u.get->_icon)))) {
 
 					// special Zone
-					if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
+					if ((type == 0) && (z->boundId() == 0 == 0))
 						return z;
 					if (z->_type == type)
 						return z;
-					if ((z->_type & 0xFFFF0000) == type)
+					if (z->boundId() == type)
 						return z;
 
 				}
@@ -572,11 +570,11 @@
 		}
 
 		// normal Zone
-		if ((type == 0) && ((z->_type & 0xFFFF0000) == 0))
+		if ((type == 0) && (z->boundId() == 0))
 			return z;
 		if (z->_type == type)
 			return z;
-		if ((z->_type & 0xFFFF0000) == type)
+		if (z->boundId() == type)
 			return z;
 
 	}
@@ -592,8 +590,8 @@
 		_f = ((_di >= a->_top + a->height()) || (_di <= a->_top)) ? 0 : 1;		// _f: vertical range
 
 		_b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; 										 // _b: (no type specified) AND (Animation is not the character)
-		_c = (a->_type & 0xFFFF0000) ? 0 : 1; 															// _c: Animation is not an object
-		_d = ((a->_type & 0xFFFF0000) != type) ? 0 : 1;													// _d: Animation is an object of the same type
+		_c = (a->boundId()) ? 0 : 1; 															// _c: Animation is not an object
+		_d = (a->boundId() != type) ? 0 : 1;													// _d: Animation is an object of the same type
 
 		if ((_a != 0 && _e != 0 && _f != 0) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) {
 
@@ -617,7 +615,7 @@
 Zone::~Zone() {
 //	printf("~Zone(%s)\n", _label._text);
 
-	switch (_type & 0xFFFF) {
+	switch (type()) {
 	case kZoneExamine:
 		free(u.examine->_filename);
 		free(u.examine->_description);

Modified: scummvm/trunk/engines/parallaction/zone.h
===================================================================
--- scummvm/trunk/engines/parallaction/zone.h	2007-05-16 13:00:38 UTC (rev 26854)
+++ scummvm/trunk/engines/parallaction/zone.h	2007-05-16 19:23:14 UTC (rev 26855)
@@ -48,7 +48,6 @@
 	kZoneCommand	   = 0x800
 };
 
-
 enum ZoneFlags {
 	kFlagsClosed		= 1,				// Zone: door is closed / switch is off
 	kFlagsActive		= 2,				// Zone/Animation: object is visible
@@ -64,7 +63,6 @@
 	kFlagsNoWalk		= 0x800 			// Zone: character doesn't need to walk towards object to interact
 };
 
-
 #define NUM_ANSWERS		 5
 
 struct Command;
@@ -214,6 +212,13 @@
 	void translate(int16 x, int16 y);
 	virtual uint16 width() const;
 	virtual uint16 height() const;
+
+	uint32 type() {
+		return _type & 0xFFFF;
+	}
+	uint32 boundId() {
+		return (_type & 0xFFFF0000);
+	}
 };
 
 typedef Zone* ZonePointer;


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