aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-06-17 23:10:37 +0000
committerMax Horn2010-06-17 23:10:37 +0000
commit8e07a1e16768548112a290d04348e26173e8afa0 (patch)
tree02e9b309a40e6e9865facfe10bd1e8d5267cb112
parent37434d86ae8f4e7ca3e7f0258c78ad9441f99e31 (diff)
downloadscummvm-rg350-8e07a1e16768548112a290d04348e26173e8afa0.tar.gz
scummvm-rg350-8e07a1e16768548112a290d04348e26173e8afa0.tar.bz2
scummvm-rg350-8e07a1e16768548112a290d04348e26173e8afa0.zip
SCI: Moved the event code a little bit around.
* Move sleep() from EventManager to SciEngine * Rename EventManager methods: get -> getSciEvent, and getFromScummVM -> getScummVMEvent * Make scancode_rows static const * Turn altify & numlockify from EventManager methods into static functions (and comment out the currently unused numlockify) svn-id: r49959
-rw-r--r--engines/sci/engine/kevent.cpp2
-rw-r--r--engines/sci/engine/kmisc.cpp2
-rw-r--r--engines/sci/engine/state.cpp2
-rw-r--r--engines/sci/event.cpp18
-rw-r--r--engines/sci/event.h9
-rw-r--r--engines/sci/graphics/cursor.cpp2
-rw-r--r--engines/sci/graphics/menu.cpp8
-rw-r--r--engines/sci/graphics/portrait.cpp2
-rw-r--r--engines/sci/sci.h2
9 files changed, 23 insertions, 24 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index c5a37dde94..718da6c3d3 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -65,7 +65,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
oldx = mousePos.x;
oldy = mousePos.y;
- curEvent = g_sci->getEventManager()->get(mask);
+ curEvent = g_sci->getEventManager()->getSciEvent(mask);
if (g_sci->getVocabulary())
g_sci->getVocabulary()->parser_event = NULL_REG; // Invalidate parser event
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index ef6088b6d5..99b268f774 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -79,7 +79,7 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
uint32 duration = curTime - s->_throttleLastTime;
if (duration < neededSleep) {
- g_sci->getEventManager()->sleep(neededSleep - duration);
+ g_sci->sleep(neededSleep - duration);
s->_throttleLastTime = g_system->getMillis();
} else {
s->_throttleLastTime = curTime;
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 1c8113e5e4..80b9ba3bcb 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -121,7 +121,7 @@ void EngineState::wait(int16 ticks) {
lastWaitTime = time;
ticks *= g_debug_sleeptime_factor;
- g_sci->getEventManager()->sleep(ticks * 1000 / 60);
+ g_sci->sleep(ticks * 1000 / 60);
}
void EngineState::initGlobals() {
diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp
index 7a55555a70..6681e12008 100644
--- a/engines/sci/event.cpp
+++ b/engines/sci/event.cpp
@@ -44,7 +44,7 @@ EventManager::EventManager(ResourceManager *resMan) {
EventManager::~EventManager() {
}
-struct scancode_row {
+static const struct scancode_row {
int offset;
const char *keys;
} scancode_rows[SCANCODE_ROWS_NR] = {
@@ -53,7 +53,7 @@ struct scancode_row {
{0x2c, "ZXCVBNM,./"}
};
-int EventManager::altify (int ch) {
+static int altify(int ch) {
// Calculates a PC keyboard scancode from a character */
int row;
int c = toupper((char)ch);
@@ -74,7 +74,8 @@ int EventManager::altify (int ch) {
return ch;
}
-int EventManager::numlockify (int c) {
+/*
+static int numlockify(int c) {
switch (c) {
case SCI_KEY_DELETE:
return '.';
@@ -102,6 +103,7 @@ int EventManager::numlockify (int c) {
return c; // Unchanged
}
}
+*/
static const byte codepagemap_88591toDOS[0x80] = {
'?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', // 0x8x
@@ -114,7 +116,7 @@ static const byte codepagemap_88591toDOS[0x80] = {
'?', 0xa4, 0x95, 0xa2, 0x93, '?', 0x94, '?', '?', 0x97, 0xa3, 0x96, 0x81, '?', '?', 0x98 // 0xFx
};
-sciEvent EventManager::getFromScummVM() {
+sciEvent EventManager::getScummVMEvent() {
static int _modifierStates = 0; // FIXME: Avoid non-const global vars
sciEvent input = { SCI_EVENT_NONE, 0, 0, 0 };
@@ -315,7 +317,7 @@ sciEvent EventManager::getFromScummVM() {
return input;
}
-sciEvent EventManager::get(unsigned int mask) {
+sciEvent EventManager::getSciEvent(unsigned int mask) {
//sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
sciEvent event = { 0, 0, 0, 0 };
@@ -328,7 +330,7 @@ sciEvent EventManager::get(unsigned int mask) {
// Get all queued events from graphics driver
do {
- event = getFromScummVM();
+ event = getScummVMEvent();
if (event.type != SCI_EVENT_NONE)
_events.push_back(event);
} while (event.type != SCI_EVENT_NONE);
@@ -384,13 +386,13 @@ sciEvent EventManager::get(unsigned int mask) {
return event;
}
-void EventManager::sleep(uint32 msecs) {
+void SciEngine::sleep(uint32 msecs) {
uint32 time;
const uint32 wakeup_time = g_system->getMillis() + msecs;
while (true) {
// let backend process events and update the screen
- get(SCI_EVENT_PEEK);
+ _eventMan->getSciEvent(SCI_EVENT_PEEK);
time = g_system->getMillis();
if (time + 10 < wakeup_time) {
g_system->delayMillis(10);
diff --git a/engines/sci/event.h b/engines/sci/event.h
index 7882e56c02..b973733f48 100644
--- a/engines/sci/event.h
+++ b/engines/sci/event.h
@@ -116,15 +116,10 @@ public:
EventManager(ResourceManager *resMgr);
~EventManager();
- sciEvent get(unsigned int mask);
-
- void sleep(uint32 msecs);
+ sciEvent getSciEvent(unsigned int mask);
private:
- int altify (int ch);
- int shiftify (int c);
- int numlockify (int c);
- sciEvent getFromScummVM();
+ sciEvent getScummVMEvent();
ResourceManager *_resMan;
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 2930bb8a46..369549cf7b 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -341,7 +341,7 @@ void GfxCursor::kernelMoveCursor(Common::Point pos) {
// Trigger event reading to make sure the mouse coordinates will
// actually have changed the next time we read them.
- _event->get(SCI_EVENT_PEEK);
+ _event->getSciEvent(SCI_EVENT_PEEK);
}
} // End of namespace Sci
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index 5ca4d8176b..f5eac70ccd 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -705,7 +705,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
_paint16->bitsShow(_menuRect);
while (true) {
- curEvent = _event->get(SCI_EVENT_ANY);
+ curEvent = _event->getSciEvent(SCI_EVENT_ANY);
switch (curEvent.type) {
case SCI_EVENT_KEYBOARD:
@@ -795,7 +795,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
}
break;
case SCI_EVENT_NONE:
- _event->sleep(2500 / 1000);
+ g_sci->sleep(2500 / 1000);
break;
}
}
@@ -823,7 +823,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
_paint16->bitsShow(_ports->_menuRect);
while (true) {
- curEvent = _event->get(SCI_EVENT_ANY);
+ curEvent = _event->getSciEvent(SCI_EVENT_ANY);
switch (curEvent.type) {
case SCI_EVENT_MOUSE_RELEASE:
@@ -834,7 +834,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
return curItemEntry;
case SCI_EVENT_NONE:
- _event->sleep(2500 / 1000);
+ g_sci->sleep(2500 / 1000);
break;
}
diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp
index f7d6f4de0a..9c113cf5f4 100644
--- a/engines/sci/graphics/portrait.cpp
+++ b/engines/sci/graphics/portrait.cpp
@@ -182,7 +182,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
// Wait till syncTime passed, then show specific animation bitmap
do {
g_sci->getEngineState()->wait(1);
- curEvent = _event->get(SCI_EVENT_ANY);
+ curEvent = _event->getSciEvent(SCI_EVENT_ANY);
if (curEvent.type == SCI_EVENT_MOUSE_PRESS ||
(curEvent.type == SCI_EVENT_KEYBOARD && curEvent.data == SCI_KEY_ESC) ||
g_engine->shouldQuit())
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 7d04840759..6a069fecda 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -176,6 +176,8 @@ public:
/** Remove the 'TARGET-' prefix of the given filename, if present. */
Common::String unwrapFilename(const Common::String &name) const;
+ void sleep(uint32 msecs);
+
public:
/**