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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Jun 19 00:07:32 CEST 2010


Revision: 50033
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50033&view=rev
Author:   fingolfin
Date:     2010-06-18 22:07:32 +0000 (Fri, 18 Jun 2010)

Log Message:
-----------
AGI: Change some #defines to enums

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agi/agi.h
    scummvm/trunk/engines/agi/cycle.cpp
    scummvm/trunk/engines/agi/op_cmd.cpp
    scummvm/trunk/engines/agi/op_test.cpp
    scummvm/trunk/engines/agi/saveload.cpp

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/agi.cpp	2010-06-18 22:07:32 UTC (rev 50033)
@@ -556,7 +556,7 @@
 
 	_restartGame = false;
 
-	_oldMode = -1;
+	_oldMode = INPUT_NONE;
 
 	_predictiveDialogRunning = false;
 	_predictiveDictText = NULL;

Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/agi.h	2010-06-18 22:07:32 UTC (rev 50033)
@@ -502,21 +502,40 @@
 	int curIP;
 };
 
-#define EGO_VIEW_TABLE	0
-#define	HORIZON		36
-#define _WIDTH		160
-#define _HEIGHT		168
+enum {
+	EGO_VIEW_TABLE	= 0,
+	HORIZON			= 36,
+	_WIDTH			= 160,
+	_HEIGHT			= 168
+};
 
+enum InputMode {
+	INPUT_NORMAL	= 0x01,
+	INPUT_GETSTRING	= 0x02,
+	INPUT_MENU		= 0x03,
+	INPUT_NONE		= 0x04
+};
+
+enum State {
+	STATE_INIT		= 0x00,
+	STATE_LOADED	= 0x01,
+	STATE_RUNNING	= 0x02
+};
+
+enum {
+	SBUF16_OFFSET = 0,
+	SBUF256_OFFSET = ((_WIDTH) * (_HEIGHT)),
+	FROM_SBUF16_TO_SBUF256_OFFSET = ((SBUF256_OFFSET) - (SBUF16_OFFSET)),
+	FROM_SBUF256_TO_SBUF16_OFFSET = ((SBUF16_OFFSET) - (SBUF256_OFFSET))
+};
+
 /**
  * AGI game structure.
  * This structure contains all global data of an AGI game executed
  * by the interpreter.
  */
 struct AgiGame {
-#define STATE_INIT	0x00
-#define STATE_LOADED	0x01
-#define STATE_RUNNING	0x02
-	int state;		/**< state of the interpreter */
+	State state;		/**< state of the interpreter */
 
 	// TODO: Check whether adjMouseX and adjMouseY must be saved and loaded when using savegames.
 	//       If they must be then loading and saving is partially broken at the moment.
@@ -540,12 +559,9 @@
 	uint8 inputBuffer[40]; /**< buffer for user input */
 	uint8 echoBuffer[40];	/**< buffer for echo.line */
 	int keypress;
-#define INPUT_NORMAL	0x01
-#define INPUT_GETSTRING	0x02
-#define INPUT_MENU	0x03
-#define INPUT_NONE	0x04
-	int inputMode;			/**< keyboard input mode */
-	int inputEnabled;		/**< keyboard input enabled */
+
+	InputMode inputMode;			/**< keyboard input mode */
+	bool inputEnabled;		/**< keyboard input enabled */
 	int lognum;				/**< current logic number */
 	Common::Array<ScriptPos> execStack;
 
@@ -573,10 +589,7 @@
 	char cursorChar;
 	unsigned int colorFg;
 	unsigned int colorBg;
-#define SBUF16_OFFSET 0
-#define SBUF256_OFFSET ((_WIDTH) * (_HEIGHT))
-#define FROM_SBUF16_TO_SBUF256_OFFSET ((SBUF256_OFFSET) - (SBUF16_OFFSET))
-#define FROM_SBUF256_TO_SBUF16_OFFSET ((SBUF16_OFFSET) - (SBUF256_OFFSET))
+
 	uint8 *sbufOrig;		/**< Pointer to the 160x336 AGI screen buffer that contains vertically two 160x168 screens (16 color and 256 color). */
 	uint8 *sbuf16c;			/**< 160x168 16 color (+control line & priority information) AGI screen buffer. Points at sbufOrig + SBUF16_OFFSET. */
 	uint8 *sbuf256c;		/**< 160x168 256 color AGI screen buffer (For AGI256 and AGI256-2 support). Points at sbufOrig + SBUF256_OFFSET. */
@@ -834,7 +847,7 @@
 	int loadGameSimple();
 
 	uint8 *_intobj;
-	int _oldMode;
+	InputMode _oldMode;
 	bool _restartGame;
 
 	Menu* _menu;
@@ -876,7 +889,7 @@
 	static void agiTimerFunctionLow(void *refCon);
 	void initPriTable();
 
-	void newInputMode(int);
+	void newInputMode(InputMode mode);
 	void oldInputMode();
 
 	int getvar(int);

Modified: scummvm/trunk/engines/agi/cycle.cpp
===================================================================
--- scummvm/trunk/engines/agi/cycle.cpp	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/cycle.cpp	2010-06-18 22:07:32 UTC (rev 50033)
@@ -177,9 +177,9 @@
 	setvar(vDays, getvar(vDays) + 1);
 }
 
-void AgiEngine::newInputMode(int i) {
+void AgiEngine::newInputMode(InputMode mode) {
 	_oldMode = _game.inputMode;
-	_game.inputMode = i;
+	_game.inputMode = mode;
 }
 
 void AgiEngine::oldInputMode() {
@@ -436,7 +436,7 @@
 		setvar(vFreePages, 180); // Set amount of free memory to realistic value
 		setvar(vMaxInputChars, 38);
 		_game.inputMode = INPUT_NONE;
-		_game.inputEnabled = 0;
+		_game.inputEnabled = false;
 		_game.hasPrompt = 0;
 
 		_game.state = STATE_RUNNING;

Modified: scummvm/trunk/engines/agi/op_cmd.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_cmd.cpp	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/op_cmd.cpp	2010-06-18 22:07:32 UTC (rev 50033)
@@ -1563,8 +1563,8 @@
 
 	// Disables input while shaking to prevent bug
 	// #1678230: AGI: Entering text while screen is shaking
-	int originalValue = game.inputEnabled;
-	game.inputEnabled = 0;
+	bool originalValue = game.inputEnabled;
+	game.inputEnabled = false;
 
 	g_gfx->shakeStart();
 

Modified: scummvm/trunk/engines/agi/op_test.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_test.cpp	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/op_test.cpp	2010-06-18 22:07:32 UTC (rev 50033)
@@ -111,7 +111,7 @@
 
 	game.keypress = 0;
 	if (!x) {
-		int mode = game.inputMode;
+		InputMode mode = game.inputMode;
 
 		game.inputMode = INPUT_NONE;
 		g_agi->mainCycle();

Modified: scummvm/trunk/engines/agi/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agi/saveload.cpp	2010-06-18 22:06:56 UTC (rev 50032)
+++ scummvm/trunk/engines/agi/saveload.cpp	2010-06-18 22:07:32 UTC (rev 50033)
@@ -132,7 +132,7 @@
 	out->writeSint16BE((int16)_game.hasPrompt);
 	out->writeSint16BE((int16)_game.gameFlags);
 
-	out->writeSint16BE((int16)_game.inputEnabled);
+	out->writeSint16BE(_game.inputEnabled);
 
 	for (i = 0; i < _HEIGHT; i++)
 		out->writeByte(_game.priTable[i]);
@@ -302,7 +302,7 @@
 		// TODO: played time
 	}
 
-	_game.state = in->readByte();
+	_game.state = (State)in->readByte();
 
 	in->read(loadId, 8);
 	if (strcmp(loadId, _game.id) && checkId) {
@@ -361,7 +361,7 @@
 	_game.echoBuffer[0] = 0;
 	_game.keypress = 0;
 
-	_game.inputMode = in->readSint16BE();
+	_game.inputMode = (InputMode)in->readSint16BE();
 	_game.lognum = in->readSint16BE();
 
 	_game.playerControl = in->readSint16BE();


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