SCI: Turn kernel_sleep() into SciEvent::sleep()
svn-id: r48119
This commit is contained in:
parent
02201e937a
commit
2e68de1e5a
6 changed files with 28 additions and 27 deletions
|
@ -721,26 +721,6 @@ bool kernel_matches_signature(SegManager *segMan, const char *sig, int argc, con
|
||||||
return false;
|
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) {
|
void Kernel::setDefaultKernelNames(Common::String gameId) {
|
||||||
_kernelNames = Common::StringList(sci_default_knames, SCI_KNAMES_DEFAULT_ENTRIES_NR);
|
_kernelNames = Common::StringList(sci_default_knames, SCI_KNAMES_DEFAULT_ENTRIES_NR);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) {
|
||||||
uint32 neededSleep = 30;
|
uint32 neededSleep = 30;
|
||||||
|
|
||||||
if (duration < neededSleep) {
|
if (duration < neededSleep) {
|
||||||
kernel_sleep(s->_event, neededSleep - duration);
|
s->_event->sleep(neededSleep - duration);
|
||||||
s->_throttleLastTime = g_system->getMillis();
|
s->_throttleLastTime = g_system->getMillis();
|
||||||
} else {
|
} else {
|
||||||
s->_throttleLastTime = curTime;
|
s->_throttleLastTime = curTime;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "sci/sci.h" // for INCLUDE_OLDGFX
|
#include "sci/sci.h" // for INCLUDE_OLDGFX
|
||||||
#include "sci/debug.h" // for g_debug_sleeptime_factor
|
#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/state.h"
|
||||||
#include "sci/engine/selector.h"
|
#include "sci/engine/selector.h"
|
||||||
|
@ -93,7 +93,7 @@ void EngineState::wait(int16 ticks) {
|
||||||
last_wait_time = time;
|
last_wait_time = time;
|
||||||
|
|
||||||
ticks *= g_debug_sleeptime_factor;
|
ticks *= g_debug_sleeptime_factor;
|
||||||
kernel_sleep(_event, ticks * 1000 / 60);
|
_event->sleep(ticks * 1000 / 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 EngineState::currentRoomNumber() const {
|
uint16 EngineState::currentRoomNumber() const {
|
||||||
|
|
|
@ -351,4 +351,25 @@ sciEvent SciEvent::get(unsigned int mask) {
|
||||||
return event;
|
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
|
} // End of namespace Sci
|
||||||
|
|
|
@ -118,6 +118,8 @@ public:
|
||||||
|
|
||||||
sciEvent get(unsigned int mask);
|
sciEvent get(unsigned int mask);
|
||||||
|
|
||||||
|
void sleep(uint32 msecs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int altify (int ch);
|
int altify (int ch);
|
||||||
int shiftify (int c);
|
int shiftify (int c);
|
||||||
|
@ -127,8 +129,6 @@ private:
|
||||||
Common::List<sciEvent> _events;
|
Common::List<sciEvent> _events;
|
||||||
};
|
};
|
||||||
|
|
||||||
void kernel_sleep(SciEvent *event, uint32 msecs); // is in kernel.cpp
|
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -760,7 +760,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCI_EVENT_NONE:
|
case SCI_EVENT_NONE:
|
||||||
kernel_sleep(_event, 2500 / 1000);
|
_event->sleep(2500 / 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,7 +799,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
|
||||||
return curItemEntry;
|
return curItemEntry;
|
||||||
|
|
||||||
case SCI_EVENT_NONE:
|
case SCI_EVENT_NONE:
|
||||||
kernel_sleep(_event, 2500 / 1000);
|
_event->sleep(2500 / 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue