[Scummvm-cvs-logs] SF.net SVN: scummvm: [21622] scummvm/trunk/engines/simon

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Tue Apr 4 17:38:04 CEST 2006


Revision: 21622
Author:   eriktorbjorn
Date:     2006-04-04 17:37:42 -0700 (Tue, 04 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21622&view=rev

Log Message:
-----------
Use the setBitFlag() and getBitFlag() functions, instead of manipulating
_bitArray[] directly. This kind of change is, of course, rather error-prone. I
hope I haven't introduced any regressions.

Modified Paths:
--------------
    scummvm/trunk/engines/simon/items.cpp
    scummvm/trunk/engines/simon/oracle.cpp
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/verb.cpp
    scummvm/trunk/engines/simon/vga.cpp
Modified: scummvm/trunk/engines/simon/items.cpp
===================================================================
--- scummvm/trunk/engines/simon/items.cpp	2006-04-05 00:24:53 UTC (rev 21621)
+++ scummvm/trunk/engines/simon/items.cpp	2006-04-05 00:37:42 UTC (rev 21622)
@@ -890,20 +890,17 @@
 			break;
 
 		case 153:{									/* set bit */
-				uint bit = getVarOrByte();
-				_bitArray[bit / 16] |= 1 << (bit & 15);
+				setBitFlag(getVarOrByte(), true);
 				break;
 			}
 
 		case 154:{									/* clear bit */
-				uint bit = getVarOrByte();
-				_bitArray[bit / 16] &= ~(1 << (bit & 15));
+				setBitFlag(getVarOrByte(), false);
 				break;
 			}
 
 		case 155:{									/* is bit clear */
-				uint bit = getVarOrByte();
-				condition = (_bitArray[bit / 16] & (1 << (bit & 15))) == 0;
+				condition = !getBitFlag(getVarOrByte());
 			}
 			break;
 
@@ -912,7 +909,7 @@
 				if (getGameType() == GType_SIMON1 && _subroutine == 2962 && bit == 63) {
 					bit = 50;
 				}
-				condition = (_bitArray[bit / 16] & (1 << (bit & 15))) != 0;
+				condition = getBitFlag(bit);
 			}
 			break;
 
@@ -984,26 +981,22 @@
 			} break;
 
 		case 166:{									/* set bit2 */
-				uint bit = getVarOrByte();
-				_bitArray[(bit / 16) + 16] |= 1 << (bit & 15);
+				setBitFlag(256 + getVarOrByte(), true);
 			}
 			break;
 
 		case 167:{									/* clear bit2 */
-				uint bit = getVarOrByte();
-				_bitArray[(bit / 16) + 16] &= ~(1 << (bit & 15));
+				setBitFlag(256 + getVarOrByte(), false);
 			}
 			break;
 
 		case 168:{									/* is bit2 clear */
-				uint bit = getVarOrByte();
-				condition = (_bitArray[(bit / 16) + 16] & (1 << (bit & 15))) == 0;
+				condition = !getBitFlag(256 + getVarOrByte());
 			}
 			break;
 
 		case 169:{									/* is bit2 set */
-				uint bit = getVarOrByte();
-				condition = (_bitArray[(bit / 16) + 16] & (1 << (bit & 15))) != 0;
+				condition = getBitFlag(256 + getVarOrByte());
 			}
 			break;
 
@@ -1174,7 +1167,7 @@
 
 		// Feeble opcodes
 		case 191:
-			if (_bitArray[5] & 0x0008) {
+			if (getBitFlag(83)) {
 				_PVCount1 = 0;
 				_GPVCount1 = 0;
 			} else {
@@ -1188,7 +1181,7 @@
 				uint8 b = getVarOrByte();
 				uint8 c = getVarOrByte();
 				uint8 d = getVarOrByte();
-				if (_bitArray[5] & 0x0008) {
+				if (getBitFlag(83)) {
 					_pathValues1[_PVCount1++] = a;
 					_pathValues1[_PVCount1++] = b;
 					_pathValues1[_PVCount1++] = c;
@@ -1223,26 +1216,22 @@
 			break;
 
 		case 196:{									/* set bit3 */
-				uint bit = getVarOrByte();
-				_bitArray[(bit / 16) + 32] |= 1 << (bit & 15);
+				setBitFlag(512 + getVarOrByte(), true);
 			}
 			break;
 
 		case 197:{									/* clear bit3 */
-				uint bit = getVarOrByte();
-				_bitArray[(bit / 16) + 32] &= ~(1 << (bit & 15));
+				setBitFlag(512 + getVarOrByte(), false);
 			}
 			break;
 
 		case 198:{									/* is bit3 clear */
-				uint bit = getVarOrByte();
-				condition = (_bitArray[(bit / 16) + 32] & (1 << (bit & 15))) == 0;
+				condition = !getBitFlag(512 + getVarOrByte());
 			}
 			break;
 
 		case 199:{									/* is bit3 set */
-				uint bit = getVarOrByte();
-				condition = (_bitArray[(bit / 16) + 32] & (1 << (bit & 15))) != 0;
+				condition = getBitFlag(512 + getVarOrByte());
 			}
 			break;
 

Modified: scummvm/trunk/engines/simon/oracle.cpp
===================================================================
--- scummvm/trunk/engines/simon/oracle.cpp	2006-04-05 00:24:53 UTC (rev 21621)
+++ scummvm/trunk/engines/simon/oracle.cpp	2006-04-05 00:37:42 UTC (rev 21622)
@@ -45,7 +45,7 @@
 }
 
 void SimonEngine::hyperLinkOn(uint16 x) {
-	if ((_bitArray[3] & (1 << 3)) == 0)
+	if (!getBitFlag(51))
 		return;
 
 	_hyperLink = x;
@@ -55,7 +55,7 @@
 
 
 void SimonEngine::hyperLinkOff() {
-	if ((_bitArray[3] & (1 << 3)) == 0)
+	if (!getBitFlag(51))
 		return;
 
 	_variableArray[52] = _textWindow->x + _textWindow->textColumn - _variableArray[50];
@@ -110,11 +110,11 @@
 				linksUp();
 			}
 			scrollOracleUp();
-			_bitArray[5] |= (1 << 14);
+			setBitFlag(94, true);
 			sub = getSubroutineByID(_variableArray[104]);
 			if(sub)
 				startSubroutineEx(sub);
-			_bitArray[5] &= ~(1 << 14);
+			setBitFlag(94, false);
 			bltOracleText();
 		}
 		if (_currentBoxNumber != 600 || _leftButtonDown)
@@ -144,11 +144,11 @@
 				linksDown();
 			}
 			scrollOracleDown();
-			_bitArray[5] |= (1 << 13);
+			setBitFlag(93, true);
 			sub = getSubroutineByID(_variableArray[104]);
 			if (sub)
 				startSubroutineEx(sub);
-			_bitArray[5] &= ~(1 << 13);
+			setBitFlag(93, false);
 			bltOracleText();
 		}
 		if (_currentBoxNumber != 600 || _leftButtonDown)

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-04-05 00:24:53 UTC (rev 21621)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-04-05 00:37:42 UTC (rev 21622)
@@ -1708,19 +1708,19 @@
 	}
 
 	if (getGameType() == GType_FF) {
-		if (_bitArray[6] & 0x8) { // Oracle
+		if (getBitFlag(99)) { // Oracle
 			if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
-				_bitArray[6] |= 0x4;
+				setBitFlag(98, true);
 			} else {
-				if (_bitArray[6] & 0x4) {
+				if (getBitFlag(98)) {
 					_variableArray[254] = 63;
 				}
 			}
-		} else if (_bitArray[5] & 0x0100) { // Close Up
+		} else if (getBitFlag(88)) { // Close Up
 			if (_mouseX >= 10 && _mouseX <= 635 && _mouseY >= 5 && _mouseY <= 475) {
-				_bitArray[5] |= 0x80;
+				setBitFlag(87, true);
 			} else {
-				if (_bitArray[5] & 0x80) {
+				if (getBitFlag(87)) {
 					_variableArray[254] = 75;
 				}
 			}
@@ -1733,7 +1733,7 @@
 	}
 
 	if (getGameType() == GType_SIMON2) {
-		if (_bitArray[4] & 0x8000) {
+		if (getBitFlag(79)) {
 			if (!_vgaVar9) {
 				if (_mouseX >= 630 / 2 || _mouseX < 9)
 					goto get_out2;
@@ -2702,7 +2702,7 @@
 }
 
 void SimonEngine::o_mouseOn() {
-	if (getGameType() == GType_SIMON2 && _bitArray[4] & 0x8000)
+	if (getGameType() == GType_SIMON2 && getBitFlag(79))
 		_mouseCursor = 0;
 	_mouseHideCount = 0;
 }
@@ -3482,8 +3482,8 @@
 		if (speech_id == 9999) {
 			if (_subtitles)
 				return;
-			if (!(_bitArray[0] & 0x4000) && !(_bitArray[1] & 0x1000)) {
-				_bitArray[0] |= 0x4000;
+			if (!getBitFlag(14) && !getBitFlag(28)) {
+				setBitFlag(14, true);
 				_variableArray[100] = 15;
 				loadSprite(4, 1, 130, 0, 0, 0);
 				o_waitForSync(130);
@@ -3503,8 +3503,8 @@
 		if (speech_id == 0xFFFF) {
 			if (_subtitles)
 				return;
-			if (!(_bitArray[0] & 0x4000) && !(_bitArray[1] & 0x1000)) {
-				_bitArray[0] |= 0x4000;
+			if (!getBitFlag(14) && !getBitFlag(28)) {
+				setBitFlag(14, true);
 				_variableArray[100] = 5;
 				loadSprite(4, 1, 30, 0, 0, 0);
 				o_waitForSync(130);
@@ -3602,7 +3602,7 @@
 		render_string(vgaSpriteId, color, width, height, convertedString);
 
 	int b = 4;
-	if (!(_bitArray[8] & 0x20))
+	if (!getBitFlag(133))
 		b = 3;
 
 	x /= 8;
@@ -4212,7 +4212,7 @@
 				break;
 			case OSystem::EVENT_LBUTTONDOWN:
 				if (getGameType() == GType_FF)
-					_bitArray[5] |= 0x0200;
+					setBitFlag(89, true);
 				_leftButtonDown++;
 #if defined (_WIN32_WCE) || defined(PALMOS_MODE)
 				_sdlMouseX = event.mouse.x;
@@ -4221,11 +4221,11 @@
 				break;
 			case OSystem::EVENT_LBUTTONUP:
 				if (getGameType() == GType_FF)
-					_bitArray[5] &= ~0x0200;
+					setBitFlag(89, false);
 				break;
 			case OSystem::EVENT_RBUTTONDOWN:
 				if (getGameType() == GType_FF)
-					_bitArray[5] &= ~0x1000;
+					setBitFlag(92, false);
 				if (getGameType() == GType_SIMON2 || getGameType() == GType_FF)
 					_rightButtonDown++;
 				else

Modified: scummvm/trunk/engines/simon/verb.cpp
===================================================================
--- scummvm/trunk/engines/simon/verb.cpp	2006-04-05 00:24:53 UTC (rev 21621)
+++ scummvm/trunk/engines/simon/verb.cpp	2006-04-05 00:37:42 UTC (rev 21622)
@@ -193,7 +193,7 @@
 	HitArea *ha;
 
 	if (getGameType() == GType_SIMON2) {
-		if (_bitArray[4] & 0x8000) {
+		if (getBitFlag(79)) {
 			o_sync(202);
 			_lastHitArea2Ptr = NULL;
 			return;
@@ -295,7 +295,7 @@
 	FillOrCopyStruct *fcs;
 
 	if (getGameType() == GType_SIMON2) {
-		if (_bitArray[4] & 0x8000)
+		if (getBitFlag(79))
 			return;
 	}
 
@@ -418,7 +418,7 @@
 
 		if (getGameType() == GType_SIMON2) {
 			id = 2;
-			if (!(_bitArray[4] & 0x8000))
+			if (!getBitFlag(79))
 				id = (_mouseY >= 136) ? 102 : 101;
 		} else {
 			id = (_mouseY >= 136) ? 102 : 101;
@@ -620,7 +620,7 @@
 	const uint16 y_ = y;
 
 	if (getGameType() == GType_SIMON2) {
-		if (_bitArray[4] & 0x8000 || y < 134) {
+		if (getBitFlag(79) || y < 134) {
 			x_ += _scrollX * 8;
 		}
 	}
@@ -692,7 +692,7 @@
 	const byte *string_ptr;
 
 	if (getGameType() == GType_SIMON2) {
-		if (_bitArray[4] & 0x8000) {
+		if (getBitFlag(79)) {
 			Subroutine *sub;
 			_variableArray[84] = a;
 			sub = getSubroutineByID(5003);

Modified: scummvm/trunk/engines/simon/vga.cpp
===================================================================
--- scummvm/trunk/engines/simon/vga.cpp	2006-04-05 00:24:53 UTC (rev 21621)
+++ scummvm/trunk/engines/simon/vga.cpp	2006-04-05 00:37:42 UTC (rev 21622)
@@ -1251,7 +1251,7 @@
 		}
 		/* vc10_helper_4 */
 	} else {
-		if (getGameType() == GType_SIMON2 && state->flags & kDFUseFrontBuf && _bitArray[10] & 0x800) {
+		if (getGameType() == GType_SIMON2 && state->flags & kDFUseFrontBuf && getBitFlag(171)) {
 			state->surf_addr = state->surf2_addr;
 			state->surf_pitch = state->surf2_pitch;
 		}
@@ -1704,7 +1704,7 @@
 	uint var = vcReadNextWord();
 	int16 value = vcReadVar(var) + vcReadNextWord();
 
-	if ((getGameType() == GType_SIMON2) && var == 15 && !(_bitArray[5] & 1)) {
+	if ((getGameType() == GType_SIMON2) && var == 15 && !getBitFlag(80)) {
 		int16 tmp;
 
 		if (_scrollCount != 0) {
@@ -1733,7 +1733,7 @@
 	uint var = vcReadNextWord();
 	int16 value = vcReadVar(var) - vcReadNextWord();
 
-	if ((getGameType() == GType_SIMON2) && var == 15 && !(_bitArray[5] & 1)) {
+	if ((getGameType() == GType_SIMON2) && var == 15 && !getBitFlag(80)) {
 		int16 tmp;
 
 		if (_scrollCount != 0) {


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