[Scummvm-cvs-logs] SF.net SVN: scummvm:[45259] scummvm/trunk/engines/agi

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Oct 20 13:13:01 CEST 2009


Revision: 45259
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45259&view=rev
Author:   fingolfin
Date:     2009-10-20 11:13:00 +0000 (Tue, 20 Oct 2009)

Log Message:
-----------
AGI: Turn g_tickTimer & g_mouse into members of class AgiEngine resp. AgiBase

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agi/agi.h
    scummvm/trunk/engines/agi/cycle.cpp
    scummvm/trunk/engines/agi/graphics.cpp
    scummvm/trunk/engines/agi/inv.cpp
    scummvm/trunk/engines/agi/keyboard.cpp
    scummvm/trunk/engines/agi/menu.cpp
    scummvm/trunk/engines/agi/op_cmd.cpp
    scummvm/trunk/engines/agi/preagi.cpp
    scummvm/trunk/engines/agi/saveload.cpp
    scummvm/trunk/engines/agi/text.cpp

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/agi.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -48,9 +48,6 @@
 
 namespace Agi {
 
-static uint32 g_tickTimer;
-struct Mouse g_mouse;
-
 void AgiEngine::allowSynthetic(bool allow) {
 	_allowSynthetic = allow;
 }
@@ -81,17 +78,17 @@
 			break;
 		case Common::EVENT_LBUTTONDOWN:
 			key = BUTTON_LEFT;
-			g_mouse.button = kAgiMouseButtonLeft;
+			_mouse.button = kAgiMouseButtonLeft;
 			keyEnqueue(key);
-			g_mouse.x = event.mouse.x;
-			g_mouse.y = event.mouse.y;
+			_mouse.x = event.mouse.x;
+			_mouse.y = event.mouse.y;
 			break;
 		case Common::EVENT_RBUTTONDOWN:
 			key = BUTTON_RIGHT;
-			g_mouse.button = kAgiMouseButtonRight;
+			_mouse.button = kAgiMouseButtonRight;
 			keyEnqueue(key);
-			g_mouse.x = event.mouse.x;
-			g_mouse.y = event.mouse.y;
+			_mouse.x = event.mouse.x;
+			_mouse.y = event.mouse.y;
 			break;
 		case Common::EVENT_WHEELUP:
 			key = WHEEL_UP;
@@ -102,28 +99,28 @@
 			keyEnqueue(key);
 			break;
 		case Common::EVENT_MOUSEMOVE:
-			g_mouse.x = event.mouse.x;
-			g_mouse.y = event.mouse.y;
+			_mouse.x = event.mouse.x;
+			_mouse.y = event.mouse.y;
 
 			if (!_game.mouseFence.isEmpty()) {
-				if (g_mouse.x < _game.mouseFence.left)
-					g_mouse.x = _game.mouseFence.left;
-				if (g_mouse.x > _game.mouseFence.right)
-					g_mouse.x = _game.mouseFence.right;
-				if (g_mouse.y < _game.mouseFence.top)
-					g_mouse.y = _game.mouseFence.top;
-				if (g_mouse.y > _game.mouseFence.bottom)
-					g_mouse.y = _game.mouseFence.bottom;
+				if (_mouse.x < _game.mouseFence.left)
+					_mouse.x = _game.mouseFence.left;
+				if (_mouse.x > _game.mouseFence.right)
+					_mouse.x = _game.mouseFence.right;
+				if (_mouse.y < _game.mouseFence.top)
+					_mouse.y = _game.mouseFence.top;
+				if (_mouse.y > _game.mouseFence.bottom)
+					_mouse.y = _game.mouseFence.bottom;
 
-				g_system->warpMouse(g_mouse.x, g_mouse.y);
+				g_system->warpMouse(_mouse.x, _mouse.y);
 			}
 
 			break;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
-			g_mouse.button = kAgiMouseButtonUp;
-			g_mouse.x = event.mouse.x;
-			g_mouse.y = event.mouse.y;
+			_mouse.button = kAgiMouseButtonUp;
+			_mouse.x = event.mouse.x;
+			_mouse.y = event.mouse.y;
 			break;
 		case Common::EVENT_KEYDOWN:
 			if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == Common::KEYCODE_d) {
@@ -276,21 +273,22 @@
 	static uint32 m = 0;
 	uint32 dm;
 
-	if (g_tickTimer < m)
+	if (_tickTimer < m)
 		m = 0;
 
-	while ((dm = g_tickTimer - m) < 5) {
+	while ((dm = _tickTimer - m) < 5) {
 		processEvents();
 		if (_console->isAttached())
 			_console->onFrame();
 		_system->delayMillis(10);
 		_system->updateScreen();
 	}
-	m = g_tickTimer;
+	m = _tickTimer;
 }
 
 void AgiEngine::agiTimerFunctionLow(void *refCon) {
-	g_tickTimer++;
+	AgiEngine *self = (AgiEngine *)refCon;
+	self->_tickTimer++;
 }
 
 void AgiEngine::pause(uint32 msec) {
@@ -532,7 +530,7 @@
 
 	memset(&_game, 0, sizeof(struct AgiGame));
 	memset(&_debug, 0, sizeof(struct AgiDebug));
-	memset(&g_mouse, 0, sizeof(struct Mouse));
+	memset(&_mouse, 0, sizeof(struct Mouse));
 
 	_game.clockEnabled = false;
 	_game.state = STATE_INIT;
@@ -542,7 +540,7 @@
 
 	_allowSynthetic = false;
 
-	g_tickTimer = 0;
+	_tickTimer = 0;
 
 	_intobj = NULL;
 
@@ -636,7 +634,7 @@
 
 	_lastSaveTime = 0;
 
-	_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
+	_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, this);
 
 	debugC(2, kDebugLevelMain, "Detect game");
 

Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/agi.h	2009-10-20 11:13:00 UTC (rev 45259)
@@ -666,8 +666,6 @@
 class Menu;
 class SearchTree;
 
-extern struct Mouse g_mouse;
-
 // Image stack support
 struct ImageStackElement {
 	uint8 type;
@@ -719,6 +717,8 @@
 	AgiGame _game;
 	Common::RandomSource *_rnd;
 
+	Mouse _mouse;
+
 	bool _noSaveLoadAllowed;
 
 	virtual void pollTimer(void) = 0;
@@ -788,6 +788,8 @@
 
 private:
 
+	uint32 _tickTimer;
+
 	int _keyQueue[KEY_QUEUE_SIZE];
 	int _keyQueueStart;
 	int _keyQueueEnd;

Modified: scummvm/trunk/engines/agi/cycle.cpp
===================================================================
--- scummvm/trunk/engines/agi/cycle.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/cycle.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -201,8 +201,8 @@
 	//
 	// We run AGIMOUSE always as a side effect
 	if (getFeatures() & GF_AGIMOUSE || 1) {
-		_game.vars[28] = g_mouse.x / 2;
-		_game.vars[29] = g_mouse.y;
+		_game.vars[28] = _mouse.x / 2;
+		_game.vars[29] = _mouse.y;
 	}
 	if (key == KEY_PRIORITY) {
 		_sprites->eraseBoth();

Modified: scummvm/trunk/engines/agi/graphics.cpp
===================================================================
--- scummvm/trunk/engines/agi/graphics.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/graphics.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -776,7 +776,7 @@
 	x2 = x + CHAR_COLS * len + 2;
 	y2 = y + CHAR_LINES + 2;
 
-	if ((int)g_mouse.x >= x1 && (int)g_mouse.y >= y1 && (int)g_mouse.x <= x2 && (int)g_mouse.y <= y2)
+	if ((int)_vm->_mouse.x >= x1 && (int)_vm->_mouse.y >= y1 && (int)_vm->_mouse.x < x2 && (int)_vm->_mouse.y <= y2)
 		return true;
 
 	return false;

Modified: scummvm/trunk/engines/agi/inv.cpp
===================================================================
--- scummvm/trunk/engines/agi/inv.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/inv.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -74,8 +74,8 @@
 int AgiEngine::findItem() {
 	int r, c;
 
-	r = g_mouse.y / CHAR_LINES;
-	c = g_mouse.x / CHAR_COLS;
+	r = _mouse.y / CHAR_LINES;
+	c = _mouse.x / CHAR_COLS;
 
 	debugC(6, kDebugLevelInventory, "r = %d, c = %d", r, c);
 

Modified: scummvm/trunk/engines/agi/keyboard.cpp
===================================================================
--- scummvm/trunk/engines/agi/keyboard.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/keyboard.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -130,7 +130,7 @@
 	}
 
 	if (key == BUTTON_LEFT) {
-		if ((getflag(fMenusWork) || (getFeatures() & GF_MENUS)) && g_mouse.y <= CHAR_LINES) {
+		if ((getflag(fMenusWork) || (getFeatures() & GF_MENUS)) && _mouse.y <= CHAR_LINES) {
 			newInputMode(INPUT_MENU);
 			return true;
 		}
@@ -138,8 +138,8 @@
 
 	// Show predictive dialog if the user clicks on input area
 	if (key == BUTTON_LEFT &&
-			(int)g_mouse.y >= _game.lineUserInput * CHAR_LINES &&
-			(int)g_mouse.y <= (_game.lineUserInput + 1) * CHAR_LINES) {
+			(int)_mouse.y >= _game.lineUserInput * CHAR_LINES &&
+			(int)_mouse.y <= (_game.lineUserInput + 1) * CHAR_LINES) {
 		if (predictiveDialog()) {
 			if (_game.inputMode == INPUT_NONE) {
 				for (int n = 0; _predictiveResult[n]; n++)
@@ -188,8 +188,8 @@
 			// Handle mouse button events
 			if (key == BUTTON_LEFT) {
 				v->flags |= ADJ_EGO_XY;
-				v->parm1 = WIN_TO_PIC_X(g_mouse.x);
-				v->parm2 = WIN_TO_PIC_Y(g_mouse.y);
+				v->parm1 = WIN_TO_PIC_X(_mouse.x);
+				v->parm2 = WIN_TO_PIC_Y(_mouse.y);
 				return true;
 			}
 		}
@@ -216,8 +216,8 @@
 
 	switch (key) {
 	case BUTTON_LEFT:
-		if ((int)g_mouse.y >= _stringdata.y * CHAR_LINES &&
-				(int)g_mouse.y <= (_stringdata.y + 1) * CHAR_LINES) {
+		if ((int)_mouse.y >= _stringdata.y * CHAR_LINES &&
+				(int)_mouse.y <= (_stringdata.y + 1) * CHAR_LINES) {
 			if (predictiveDialog()) {
 				strcpy(_game.strings[_stringdata.str], _predictiveResult);
 				newInputMode(INPUT_NORMAL);

Modified: scummvm/trunk/engines/agi/menu.cpp
===================================================================
--- scummvm/trunk/engines/agi/menu.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/menu.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -132,16 +132,16 @@
 }
 
 bool Menu::mouseOverText(int line, int col, char *s) {
-	if (g_mouse.x < col * CHAR_COLS)
+	if (_vm->_mouse.x < col * CHAR_COLS)
 		return false;
 
-	if (g_mouse.x > (int)(col + strlen(s)) * CHAR_COLS)
+	if (_vm->_mouse.x > (int)(col + strlen(s)) * CHAR_COLS)
 		return false;
 
-	if (g_mouse.y < line * CHAR_LINES)
+	if (_vm->_mouse.y < line * CHAR_LINES)
 		return false;
 
-	if (g_mouse.y >= (line + 1) * CHAR_LINES)
+	if (_vm->_mouse.y >= (line + 1) * CHAR_LINES)
 		return false;
 
 	return true;
@@ -296,12 +296,12 @@
 	//
 	// Mouse handling
 	//
-	if (g_mouse.button) {
+	if (_vm->_mouse.button) {
 		int hmenu, vmenu;
 
 		buttonUsed = 1;	// Button has been used at least once
 
-		if (g_mouse.y <= CHAR_LINES) {
+		if (_vm->_mouse.y <= CHAR_LINES) {
 			// on the menubar
 			hmenu = 0;
 
@@ -361,7 +361,7 @@
 
 		drawMenuOptionHilite(_hCurMenu, _vCurMenu);
 
-		if (g_mouse.y <= CHAR_LINES) {
+		if (_vm->_mouse.y <= CHAR_LINES) {
 			// on the menubar
 		} else {
 			// see which option we selected

Modified: scummvm/trunk/engines/agi/op_cmd.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_cmd.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/op_cmd.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -1519,9 +1519,9 @@
 cmd(push_script) {
 	// We run AGIMOUSE always as a side effect
 	if (g_agi->getFeatures() & GF_AGIMOUSE || 1) {
-		game.vars[27] = g_mouse.button;
-		game.vars[28] = g_mouse.x / 2;
-		game.vars[29] = g_mouse.y;
+		game.vars[27] = g_agi->_mouse.button;
+		game.vars[28] = g_agi->_mouse.x / 2;
+		game.vars[29] = g_agi->_mouse.y;
 	} else {
 		if (g_agi->getVersion() >= 0x2915) {
 			report("push.script\n");
@@ -1546,8 +1546,8 @@
 }
 
 cmd(mouse_posn) {
-	_v[p0] = WIN_TO_PIC_X(g_mouse.x);
-	_v[p1] = WIN_TO_PIC_Y(g_mouse.y);
+	_v[p0] = WIN_TO_PIC_X(g_agi->_mouse.x);
+	_v[p1] = WIN_TO_PIC_Y(g_agi->_mouse.y);
 }
 
 cmd(shake_screen) {

Modified: scummvm/trunk/engines/agi/preagi.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/preagi.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -69,7 +69,7 @@
 
 	memset(&_game, 0, sizeof(struct AgiGame));
 	memset(&_debug, 0, sizeof(struct AgiDebug));
-	memset(&g_mouse, 0, sizeof(struct Mouse));
+	memset(&_mouse, 0, sizeof(struct Mouse));
 }
 
 void PreAgiEngine::initialize() {

Modified: scummvm/trunk/engines/agi/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agi/saveload.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/saveload.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -689,16 +689,16 @@
 				rc = -1;
 				goto getout;
 			}
-			slotClicked = ((int)g_mouse.y - 1) / CHAR_COLS - (vm + 4);
+			slotClicked = ((int)_mouse.y - 1) / CHAR_COLS - (vm + 4);
 			xmin = (hm + 1) * CHAR_COLS;
 			xmax = xmin + CHAR_COLS * 34;
-			if ((int)g_mouse.x >= xmin && (int)g_mouse.x <= xmax) {
+			if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
 				if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS)
 					active = slotClicked;
 			}
 			xmin = (hm + 36) * CHAR_COLS;
 			xmax = xmin + CHAR_COLS;
-			if ((int)g_mouse.x >= xmin && (int)g_mouse.x <= xmax) {
+			if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
 				if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS) {
 					if (slotClicked == 0)
 						keyEnqueue(KEY_UP);

Modified: scummvm/trunk/engines/agi/text.cpp
===================================================================
--- scummvm/trunk/engines/agi/text.cpp	2009-10-20 10:35:49 UTC (rev 45258)
+++ scummvm/trunk/engines/agi/text.cpp	2009-10-20 11:13:00 UTC (rev 45259)
@@ -623,8 +623,8 @@
 	if (_debug.statusline) {
 		printStatus("%3d(%03d) %3d,%3d(%3d,%3d)               ",
 				getvar(0), getvar(1), _game.viewTable[0].xPos,
-				_game.viewTable[0].yPos, WIN_TO_PIC_X(g_mouse.x),
-				WIN_TO_PIC_Y(g_mouse.y));
+				_game.viewTable[0].yPos, WIN_TO_PIC_X(_mouse.x),
+				WIN_TO_PIC_Y(_mouse.y));
 		return;
 	}
 


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