SCI: Turn kernel_sleep() into SciEvent::sleep()

svn-id: r48119
This commit is contained in:
Max Horn 2010-02-23 22:47:53 +00:00
parent 02201e937a
commit 2e68de1e5a
6 changed files with 28 additions and 27 deletions

View file

@ -721,26 +721,6 @@ bool kernel_matches_signature(SegManager *segMan, const char *sig, int argc, con
return false;
}
void kernel_sleep(SciEvent *event, uint32 msecs) {
uint32 time;
const uint32 wakeup_time = g_system->getMillis() + msecs;
while (true) {
// let backend process events and update the screen
event->get(SCI_EVENT_PEEK);
// TODO: we need to call Cursor::refreshPosition() before each screen update to limit the mouse cursor position
time = g_system->getMillis();
if (time + 10 < wakeup_time) {
g_system->delayMillis(10);
} else {
if (time < wakeup_time)
g_system->delayMillis(wakeup_time - time);
break;
}
}
}
void Kernel::setDefaultKernelNames(Common::String gameId) {
_kernelNames = Common::StringList(sci_default_knames, SCI_KNAMES_DEFAULT_ENTRIES_NR);

View file

@ -77,7 +77,7 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
uint32 neededSleep = 30;
if (duration < neededSleep) {
kernel_sleep(s->_event, neededSleep - duration);
s->_event->sleep(neededSleep - duration);
s->_throttleLastTime = g_system->getMillis();
} else {
s->_throttleLastTime = curTime;

View file

@ -27,7 +27,7 @@
#include "sci/sci.h" // for INCLUDE_OLDGFX
#include "sci/debug.h" // for g_debug_sleeptime_factor
#include "sci/event.h" // for kernel_sleep
#include "sci/event.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
@ -93,7 +93,7 @@ void EngineState::wait(int16 ticks) {
last_wait_time = time;
ticks *= g_debug_sleeptime_factor;
kernel_sleep(_event, ticks * 1000 / 60);
_event->sleep(ticks * 1000 / 60);
}
uint16 EngineState::currentRoomNumber() const {

View file

@ -351,4 +351,25 @@ sciEvent SciEvent::get(unsigned int mask) {
return event;
}
void SciEvent::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);
// TODO: we need to call Cursor::refreshPosition() before each screen update to limit the mouse cursor position
time = g_system->getMillis();
if (time + 10 < wakeup_time) {
g_system->delayMillis(10);
} else {
if (time < wakeup_time)
g_system->delayMillis(wakeup_time - time);
break;
}
}
}
} // End of namespace Sci

View file

@ -118,6 +118,8 @@ public:
sciEvent get(unsigned int mask);
void sleep(uint32 msecs);
private:
int altify (int ch);
int shiftify (int c);
@ -127,8 +129,6 @@ private:
Common::List<sciEvent> _events;
};
void kernel_sleep(SciEvent *event, uint32 msecs); // is in kernel.cpp
} // End of namespace Sci
#endif

View file

@ -760,7 +760,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
}
break;
case SCI_EVENT_NONE:
kernel_sleep(_event, 2500 / 1000);
_event->sleep(2500 / 1000);
break;
}
}
@ -799,7 +799,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
return curItemEntry;
case SCI_EVENT_NONE:
kernel_sleep(_event, 2500 / 1000);
_event->sleep(2500 / 1000);
break;
}