[Scummvm-cvs-logs] SF.net SVN: scummvm:[42145] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Jul 5 21:56:55 CEST 2009


Revision: 42145
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42145&view=rev
Author:   drmccoy
Date:     2009-07-05 19:56:54 +0000 (Sun, 05 Jul 2009)

Log Message:
-----------
Split off Hotspots::evaluateNew()

Modified Paths:
--------------
    scummvm/trunk/engines/gob/hotspots.cpp
    scummvm/trunk/engines/gob/hotspots.h

Modified: scummvm/trunk/engines/gob/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 19:56:40 UTC (rev 42144)
+++ scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 19:56:54 UTC (rev 42145)
@@ -924,7 +924,7 @@
 }
 
 uint16 Hotspots::handleInput(int16 time, uint16 maxPos, uint16 &curPos,
-		InputDesc *inpDesc, uint16 &id, uint16 &index) {
+		InputDesc *inputs, uint16 &id, uint16 &index) {
 
 	uint16 descInd = 0;
 	uint16 key     = 0;
@@ -955,11 +955,11 @@
 
 		_vm->_draw->_destSurface = 21;
 
-		_vm->_draw->_backColor    = inpDesc[descInd].backColor;
-		_vm->_draw->_frontColor   = inpDesc[descInd].frontColor;
+		_vm->_draw->_backColor    = inputs[descInd].backColor;
+		_vm->_draw->_frontColor   = inputs[descInd].frontColor;
 		_vm->_draw->_textToPrint  = tempStr;
 		_vm->_draw->_transparency = 1;
-		_vm->_draw->_fontIndex    = inpDesc[descInd].fontIndex;
+		_vm->_draw->_fontIndex    = inputs[descInd].fontIndex;
 
 		_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10);
 
@@ -1006,8 +1006,8 @@
 		key = readString(inputSpot.left, inputSpot.top,
 		    inputSpot.right - inputSpot.left + 1,
 		    inputSpot.bottom - inputSpot.top + 1,
-		    inpDesc[curPos].backColor, inpDesc[curPos].frontColor,
-		    GET_VARO_STR(inputSpot.key), inpDesc[curPos].fontIndex,
+		    inputs[curPos].backColor, inputs[curPos].frontColor,
+		    GET_VARO_STR(inputSpot.key), inputs[curPos].fontIndex,
 				inputSpot.getType(), time, id, index);
 
 		if (_vm->_inter->_terminate)
@@ -1112,251 +1112,238 @@
 	}
 }
 
-void Hotspots::evaluate() {
-	InputDesc descArray[20];
-	int16 array[300];
-	char *str;
-	int16 counter;
-	int16 var_24;
-	int16 var_26;
-	int16 collStackPos;
+void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
+		uint16 &validId, bool &hasInput, uint16 &inputIndex) {
 
-	push(0);
+	ids[i] = 0;
 
-	uint16 endIndex = 0;
-	while (!_hotspots[endIndex].isEnd())
-		endIndex++;
+	// Type and window
+	byte type = _vm->_game->_script->readByte();
+	byte window = 0;
 
-	_shouldPush = false;
+	if ((type & 0x40) != 0) {
+		type  -= 0x40;
+		window = _vm->_game->_script->readByte();
+	}
 
-	_vm->_game->_script->skip(1);
+	// Coordinates
+	uint16 left, top, width, height, right, bottom;
+	uint32 funcPos = 0;
+	if ((type & 0x80) != 0) {
+		funcPos = _vm->_game->_script->pos();
+		left    = _vm->_game->_script->readValExpr();
+		top     = _vm->_game->_script->readValExpr();
+		width   = _vm->_game->_script->readValExpr();
+		height  = _vm->_game->_script->readValExpr();
+	} else {
+		funcPos = 0;
+		left    = _vm->_game->_script->readUint16();
+		top     = _vm->_game->_script->readUint16();
+		width   = _vm->_game->_script->readUint16();
+		height  = _vm->_game->_script->readUint16();
+	}
+	type &= 0x7F;
 
-	byte count = _vm->_game->_script->readByte();
-
-	_vm->_game->_handleMouse           = _vm->_game->_script->peekByte(0);
-	int16 duration         = _vm->_game->_script->peekByte(1);
-	byte stackPos2         = _vm->_game->_script->peekByte(3);
-	byte descIndex         = _vm->_game->_script->peekByte(4);
-	bool needRecalculation = _vm->_game->_script->peekByte(5) != 0;
-
-	duration *= 1000;
-	if ((stackPos2 != 0) || (descIndex != 0)) {
-		duration /= 100;
-		if (_vm->_game->_script->peekByte(1) == 100)
-			duration = 2;
+	// Apply global drawing offset
+	if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
+		left += _vm->_draw->_backDeltaX;
+		top  += _vm->_draw->_backDeltaY;
 	}
 
-	int16 timeVal = duration;
+	right  = left + width  - 1;
+	bottom = top  + height - 1;
 
-	_vm->_game->_script->skip(6);
+	// Removing 0x4 from the state
+	if ((type == 11) || (type == 12)) {
+		uint8 wantedState = (type == 11) ? 0xE : 0xD;
 
-	WRITE_VAR(16, 0);
+		_vm->_game->_script->skip(6);
 
-	byte var_41 = 0;
-	int16 var_46 = 0;
+		for (int j = 0; j < kHotspotCount; j++) {
+			Hotspot &spot = _hotspots[j];
 
-	uint16 id      = 0;
-	uint16 validId = 0xFFFF;
-	uint16 index   = 0;
+			if (spot.getState() == wantedState) {
+				spot.id       &= 0xBFFF;
+				spot.funcEnter = _vm->_game->_script->pos();
+				spot.funcLeave = _vm->_game->_script->pos();
+			}
+		}
 
-	bool   hasInput   = false;
-	uint16 inputIndex = 0;
+		_vm->_game->_script->skipBlock();
 
-	for (uint16 i = 0; i < count; i++) {
-		array[i] = 0;
+		return;
+	}
 
-		byte type = _vm->_game->_script->readByte();
-		byte window = 0;
+	int16 key   = 0;
+	int16 flags = 0;
+	Video::FontDesc *font = 0;
+	uint32 funcEnter = 0, funcLeave = 0;
 
-		if ((type & 0x40) != 0) {
-			type  -= 0x40;
-			window = _vm->_game->_script->readByte();
-		}
+	// Evaluate parameters for the new hotspot
+	switch (type) {
+	case kTypeNone:
+		_vm->_game->_script->skip(6);
 
-		uint16 left, top, width, height, right, bottom;
-		uint32 funcEnter = 0, funcLeave = 0, funcPos = 0;
-		if ((type & 0x80) != 0) {
-			funcPos = _vm->_game->_script->pos();
-			left    = _vm->_game->_script->readValExpr();
-			top     = _vm->_game->_script->readValExpr();
-			width   = _vm->_game->_script->readValExpr();
-			height  = _vm->_game->_script->readValExpr();
-		} else {
-			funcPos = 0;
-			left    = _vm->_game->_script->readUint16();
-			top     = _vm->_game->_script->readUint16();
-			width   = _vm->_game->_script->readUint16();
-			height  = _vm->_game->_script->readUint16();
-		}
+		funcEnter = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-		if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
-			left += _vm->_draw->_backDeltaX;
-			top  += _vm->_draw->_backDeltaY;
-		}
+		funcLeave = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-		right  = left + width  - 1;
-		bottom = top  + height - 1;
+		key   = i + 0xA000;
+		flags = type + (window << 8);
+		break;
 
-		int16 key   = 0;
-		int16 flags = 0;
-		Video::FontDesc *font = 0;
+	case kTypeMove:
+		key    = _vm->_game->_script->readInt16();
+		ids[i] = _vm->_game->_script->readInt16();
+		flags  = _vm->_game->_script->readInt16();
 
-		type &= 0x7F;
-		switch (type) {
-		case kTypeNone:
-			_vm->_game->_script->skip(6);
+		funcEnter = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-			funcEnter = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+		funcLeave = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-			funcLeave = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+		if (key == 0)
+			key = i + 0xA000;
 
-			key   = i + 0xA000;
-			flags = type + (window << 8);
+		flags = type + (window << 8) + (flags << 4);
+		break;
 
-			add(i + 0x8000, left, top, right, bottom,
-					flags, key, funcEnter, funcLeave, funcPos);
-			break;
+	case kTypeInput1NoLeave:
+	case kTypeInput1Leave:
+	case kTypeInput2NoLeave:
+	case kTypeInput2Leave:
+	case kTypeInput3NoLeave:
+	case kTypeInput3Leave:
+	case kTypeInputFloatNoLeave:
+	case kTypeInputFloatLeave:
+		hasInput = true;
 
-		case kTypeMove:
-			key      = _vm->_game->_script->readInt16();
-			array[i] = _vm->_game->_script->readInt16();
-			flags    = _vm->_game->_script->readInt16();
+		_vm->_util->clearKeyBuf();
 
-			funcEnter = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+		// Input text parameters
+		key                           = _vm->_game->_script->readVarIndex();
+		inputs[inputIndex].fontIndex  = _vm->_game->_script->readInt16();
+		inputs[inputIndex].backColor  = _vm->_game->_script->readByte();
+		inputs[inputIndex].frontColor = _vm->_game->_script->readByte();
+		inputs[inputIndex].str        = 0;
 
-			funcLeave = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+		if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) {
+			inputs[inputIndex].str =
+				(const char *) (_vm->_game->_script->getData() + _vm->_game->_script->pos() + 2);
+			_vm->_game->_script->skip(_vm->_game->_script->peekUint16() + 2);
+		}
 
-			if (key == 0)
-				key = i + 0xA000;
-			flags = type + (window << 8) + (flags << 4);
-
-			add(i + 0x8000, left, top, right, bottom,
-					flags, key, funcEnter, funcLeave, funcPos);
+		if (left == 0xFFFF) {
+			if ((type & 1) == 0)
+				_vm->_game->_script->skipBlock();
 			break;
+		}
 
-		case kTypeInput1NoLeave:
-		case kTypeInput1Leave:
-		case kTypeInput2NoLeave:
-		case kTypeInput2Leave:
-		case kTypeInput3NoLeave:
-		case kTypeInput3Leave:
-		case kTypeInputFloatNoLeave:
-		case kTypeInputFloatLeave:
-			hasInput = true;
+		font = _vm->_draw->_fonts[inputs[inputIndex].fontIndex];
+		if (!font->extraData)
+			right = left + width * font->itemWidth - 1;
 
-			_vm->_util->clearKeyBuf();
+		funcEnter = 0;
+		funcPos   = 0;
+		funcLeave = 0;
+		if (!(type & 1)) {
+			funcLeave = _vm->_game->_script->pos();
+			_vm->_game->_script->skipBlock();
+		}
 
-			key                              = _vm->_game->_script->readVarIndex();
-			descArray[inputIndex].fontIndex  = _vm->_game->_script->readInt16();
-			descArray[inputIndex].backColor  = _vm->_game->_script->readByte();
-			descArray[inputIndex].frontColor = _vm->_game->_script->readByte();
-			descArray[inputIndex].ptr        = 0;
+		flags = type;
 
-			if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) {
-				descArray[inputIndex].ptr = _vm->_game->_script->getData() + _vm->_game->_script->pos() + 2;
-				_vm->_game->_script->skip(_vm->_game->_script->peekUint16() + 2);
-			}
+		inputIndex++;
+		break;
 
-			if (left == 0xFFFF) {
-				if ((type & 1) == 0)
-					_vm->_game->_script->skipBlock();
-				break;
-			}
+	case 20:
+		validId = i;
+		// Fall through to case 2
+	case kTypeClick:
+		key    = _vm->_game->_script->readInt16();
+		ids[i] = _vm->_game->_script->readInt16();
+		flags  = _vm->_game->_script->readInt16();
 
-			font = _vm->_draw->_fonts[descArray[inputIndex].fontIndex];
-			if (!font->extraData)
-				right = left + width * font->itemWidth - 1;
+		funcEnter = 0;
 
-			funcEnter = 0;
-			funcPos   = 0;
-			funcLeave = 0;
-			if (!(type & 1)) {
-				funcLeave = _vm->_game->_script->pos();
-				_vm->_game->_script->skipBlock();
-			}
+		funcLeave = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-			flags = type;
+		flags = 2 + (window << 8) + (flags << 4);
+		break;
 
-			inputIndex++;
+	case 21:
+		key    = _vm->_game->_script->readInt16();
+		ids[i] = _vm->_game->_script->readInt16();
+		flags  = _vm->_game->_script->readInt16() & 3;
 
-			add(i + 0x8000, left, top, right, bottom,
-					flags, key, funcEnter, funcLeave, funcPos);
+		funcEnter = _vm->_game->_script->pos();
+		_vm->_game->_script->skipBlock();
 
-			break;
+		funcLeave = 0;
 
-		case 11:
-			_vm->_game->_script->skip(6);
+		flags = 2 + (window << 8) + (flags << 4);
+		break;
+	}
 
-			for (int j = 0; j < kHotspotCount; j++) {
-				Hotspot &spot = _hotspots[j];
+	add(i + 0x8000, left, top, right, bottom,
+			flags, key, funcEnter, funcLeave, funcPos);
+}
 
-				if (spot.getState() == 0xE) {
-					spot.id       &= 0xBFFF;
-					spot.funcEnter = _vm->_game->_script->pos();
-					spot.funcLeave = _vm->_game->_script->pos();
-				}
-			}
+void Hotspots::evaluate() {
+	InputDesc inputs[20];
+	uint16 ids[kHotspotCount];
+	int16 counter;
+	int16 var_24;
+	int16 var_26;
+	int16 collStackPos;
 
-			_vm->_game->_script->skipBlock();
-			break;
+	push(0);
 
-		case 12:
-			_vm->_game->_script->skip(6);
+	uint16 endIndex = 0;
+	while (!_hotspots[endIndex].isEnd())
+		endIndex++;
 
-			for (int j = 0; j < kHotspotCount; j++) {
-				Hotspot &spot = _hotspots[j];
+	_shouldPush = false;
 
-				if (spot.getState() == 0xD) {
-					spot.id       &= 0xBFFF;
-					spot.funcEnter = _vm->_game->_script->pos();
-					spot.funcLeave = _vm->_game->_script->pos();
-				}
-			}
+	_vm->_game->_script->skip(1);
 
-			_vm->_game->_script->skipBlock();
-			break;
+	byte count = _vm->_game->_script->readByte();
 
-		case 20:
-			validId = i;
-			// Fall through to case 2
-		case kTypeClick:
-			key      = _vm->_game->_script->readInt16();
-			array[i] = _vm->_game->_script->readInt16();
-			flags    = _vm->_game->_script->readInt16();
+	_vm->_game->_handleMouse           = _vm->_game->_script->peekByte(0);
+	int16 duration         = _vm->_game->_script->peekByte(1);
+	byte stackPos2         = _vm->_game->_script->peekByte(3);
+	byte descIndex         = _vm->_game->_script->peekByte(4);
+	bool needRecalculation = _vm->_game->_script->peekByte(5) != 0;
 
-			funcEnter = 0;
+	duration *= 1000;
+	if ((stackPos2 != 0) || (descIndex != 0)) {
+		duration /= 100;
+		if (_vm->_game->_script->peekByte(1) == 100)
+			duration = 2;
+	}
 
-			funcLeave = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+	int16 timeVal = duration;
 
-			flags = 2 + (window << 8) + (flags << 4);
+	_vm->_game->_script->skip(6);
 
-			add(i + 0x8000, left, top, right, bottom,
-					flags, key, funcEnter, funcLeave, funcPos);
-			break;
+	WRITE_VAR(16, 0);
 
-		case 21:
-			key      = _vm->_game->_script->readInt16();
-			array[i] = _vm->_game->_script->readInt16();
-			flags    = _vm->_game->_script->readInt16() & 3;
+	byte var_41 = 0;
+	int16 var_46 = 0;
 
-			funcEnter = _vm->_game->_script->pos();
-			_vm->_game->_script->skipBlock();
+	uint16 id      = 0;
+	uint16 validId = 0xFFFF;
+	uint16 index   = 0;
 
-			funcLeave = 0;
+	bool   hasInput   = false;
+	uint16 inputIndex = 0;
+	for (uint16 i = 0; i < count; i++)
+		evaluateNew(i, ids, inputs, validId, hasInput, inputIndex);
 
-			flags = 2 + (window << 8) + (flags << 4);
-
-			add(i + 0x8000, left, top, right, bottom,
-					flags, key, funcEnter, funcLeave, funcPos);
-			break;
-		}
-	}
-
 	if (needRecalculation)
 		recalculate(true);
 
@@ -1368,7 +1355,7 @@
 		if (hasInput) {
 			uint16 curEditIndex = 0;
 
-			key = handleInput(duration, inputIndex, curEditIndex, descArray, id, index);
+			key = handleInput(duration, inputIndex, curEditIndex, inputs, id, index);
 
 			WRITE_VAR(55, curEditIndex);
 			if (key == kKeyReturn) {
@@ -1454,7 +1441,7 @@
 							break;
 
 						if (Hotspot::getState(id) == 0x8)
-							WRITE_VAR(16, array[id & 0xFFF]);
+							WRITE_VAR(16, ids[id & 0xFFF]);
 						else
 							WRITE_VAR(16, id & 0xFFF);
 
@@ -1537,7 +1524,7 @@
 		_vm->_inter->storeMouse();
 
 		if (Hotspot::getState(id) == 0x8)
-			WRITE_VAR(16, array[id & 0xFFF]);
+			WRITE_VAR(16, ids[id & 0xFFF]);
 		else
 			WRITE_VAR(16, id & 0xFFF);
 
@@ -1581,7 +1568,7 @@
 			}
 
 			if ((spot.getType() >= kTypeInput2NoLeave) && (spot.getType() <= kTypeInput3Leave)) {
-				str = (char *) descArray[var_24].ptr;
+				const char *str = inputs[var_24].str;
 
 				strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
 
@@ -1605,7 +1592,7 @@
 						WRITE_VAR(17 + var_26, 1);
 						break;
 					}
-				} while (READ_LE_UINT16(descArray[var_24].ptr - 2) > pos);
+				} while (READ_LE_UINT16(inputs[var_24].str - 2) > pos);
 				collStackPos++;
 			} else {
 				WRITE_VAR(17 + var_26, 2);
@@ -1629,7 +1616,7 @@
 		_vm->_inter->storeMouse();
 		if (VAR(16) == 0) {
 			if (Hotspot::getState(id) == 0x8)
-				WRITE_VAR(16, array[id & 0xFFF]);
+				WRITE_VAR(16, ids[id & 0xFFF]);
 			else
 				WRITE_VAR(16, id & 0xFFF);
 		}

Modified: scummvm/trunk/engines/gob/hotspots.h
===================================================================
--- scummvm/trunk/engines/gob/hotspots.h	2009-07-05 19:56:40 UTC (rev 42144)
+++ scummvm/trunk/engines/gob/hotspots.h	2009-07-05 19:56:54 UTC (rev 42145)
@@ -133,7 +133,7 @@
 		uint16 fontIndex;
 		uint16 backColor;
 		uint16 frontColor;
-		byte *ptr;
+		const char *str;
 	};
 
 	GobEngine *_vm;
@@ -175,7 +175,10 @@
 			Type type, int16 &duration, uint16 &id, uint16 index);
 
 	uint16 handleInput(int16 time, uint16 hotspotIndex, uint16 &curPos,
-			InputDesc *inpDesc, uint16 &id, uint16 &index);
+			InputDesc *inputs, uint16 &id, uint16 &index);
+
+	void evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
+			uint16 &validId, bool &hasInput, uint16 &inputIndex);
 };
 
 } // End of namespace Gob


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