aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorMax Horn2009-10-20 11:13:00 +0000
committerMax Horn2009-10-20 11:13:00 +0000
commit50435d6bae2a89180676dbdbc83986d952ffb717 (patch)
treee9efbe501a07e9cca801556fd1bf622544172f3c /engines/agi
parenta41292a92fae04863070e84744bc2620235b7887 (diff)
downloadscummvm-rg350-50435d6bae2a89180676dbdbc83986d952ffb717.tar.gz
scummvm-rg350-50435d6bae2a89180676dbdbc83986d952ffb717.tar.bz2
scummvm-rg350-50435d6bae2a89180676dbdbc83986d952ffb717.zip
AGI: Turn g_tickTimer & g_mouse into members of class AgiEngine resp. AgiBase
svn-id: r45259
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.cpp60
-rw-r--r--engines/agi/agi.h6
-rw-r--r--engines/agi/cycle.cpp4
-rw-r--r--engines/agi/graphics.cpp2
-rw-r--r--engines/agi/inv.cpp4
-rw-r--r--engines/agi/keyboard.cpp14
-rw-r--r--engines/agi/menu.cpp14
-rw-r--r--engines/agi/op_cmd.cpp10
-rw-r--r--engines/agi/preagi.cpp2
-rw-r--r--engines/agi/saveload.cpp6
-rw-r--r--engines/agi/text.cpp4
11 files changed, 63 insertions, 63 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 746636d031..95939684de 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -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 @@ void AgiEngine::processEvents() {
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 @@ void AgiEngine::processEvents() {
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;
-
- g_system->warpMouse(g_mouse.x, g_mouse.y);
+ 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(_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 @@ void AgiEngine::pollTimer(void) {
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 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
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 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
_allowSynthetic = false;
- g_tickTimer = 0;
+ _tickTimer = 0;
_intobj = NULL;
@@ -636,7 +634,7 @@ void AgiEngine::initialize() {
_lastSaveTime = 0;
- _timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
+ _timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, this);
debugC(2, kDebugLevelMain, "Detect game");
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 78bb8bd264..71789a6322 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -666,8 +666,6 @@ class SpritesMgr;
class Menu;
class SearchTree;
-extern struct Mouse g_mouse;
-
// Image stack support
struct ImageStackElement {
uint8 type;
@@ -719,6 +717,8 @@ public:
AgiGame _game;
Common::RandomSource *_rnd;
+ Mouse _mouse;
+
bool _noSaveLoadAllowed;
virtual void pollTimer(void) = 0;
@@ -788,6 +788,8 @@ public:
private:
+ uint32 _tickTimer;
+
int _keyQueue[KEY_QUEUE_SIZE];
int _keyQueueStart;
int _keyQueueEnd;
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 2b4ef7f60a..10df40556f 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -201,8 +201,8 @@ int AgiEngine::mainCycle() {
//
// 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();
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 3461bb473e..020d228d82 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -776,7 +776,7 @@ int GfxMgr::testButton(int x, int y, const char *s) {
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;
diff --git a/engines/agi/inv.cpp b/engines/agi/inv.cpp
index dad1548cd9..ffb41bd266 100644
--- a/engines/agi/inv.cpp
+++ b/engines/agi/inv.cpp
@@ -74,8 +74,8 @@ void AgiEngine::printItem(int n, int fg, int bg) {
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);
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index b47a39e592..6f73062816 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -130,7 +130,7 @@ int AgiEngine::handleController(int key) {
}
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 @@ int AgiEngine::handleController(int key) {
// 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 @@ int AgiEngine::handleController(int key) {
// 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 @@ void AgiEngine::handleGetstring(int key) {
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);
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index e1db04ff49..6d23ebc14c 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -132,16 +132,16 @@ void Menu::newMenuSelected(int i) {
}
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 @@ bool Menu::keyhandler(int key) {
//
// 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 @@ bool Menu::keyhandler(int key) {
drawMenuOptionHilite(_hCurMenu, _vCurMenu);
- if (g_mouse.y <= CHAR_LINES) {
+ if (_vm->_mouse.y <= CHAR_LINES) {
// on the menubar
} else {
// see which option we selected
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index d6c8f14400..1baf40fe98 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1519,9 +1519,9 @@ cmd(print_at_v) {
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(set_pri_base) {
}
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) {
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index f012426727..a5c4d35259 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -69,7 +69,7 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) :
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() {
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 070f530e69..df3667d312 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -689,16 +689,16 @@ int AgiEngine::selectSlot() {
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);
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 04af531809..6b1466642b 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -623,8 +623,8 @@ void AgiEngine::writeStatus() {
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;
}