aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-14 14:58:19 +0000
committerFilippos Karapetis2009-03-14 14:58:19 +0000
commit498a355a74822974733ade011875e3446f655e96 (patch)
tree560d5049e688aab9709c6d80dc8d76220f92ef17
parent092f2a37e3e8ef1283ee04281727ed113061ff27 (diff)
downloadscummvm-rg350-498a355a74822974733ade011875e3446f655e96.tar.gz
scummvm-rg350-498a355a74822974733ade011875e3446f655e96.tar.bz2
scummvm-rg350-498a355a74822974733ade011875e3446f655e96.zip
Reduced CPU usage of the MADE engine by about 10% (by profiling the code)
- Added delays in places where the screen gets updated - Moved event polling inside sfPollEvent() (cause that's where events are polled), instead of after each opcode svn-id: r39392
-rw-r--r--engines/made/screen.cpp7
-rw-r--r--engines/made/script.cpp9
-rw-r--r--engines/made/scriptfuncs.cpp5
3 files changed, 6 insertions, 15 deletions
diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp
index 79d43dad61..6fb7804753 100644
--- a/engines/made/screen.cpp
+++ b/engines/made/screen.cpp
@@ -358,9 +358,7 @@ void Screen::updateSprites() {
drawSpriteChannels(_workScreenDrawCtx, 1, 2);
_vm->_system->copyRectToScreen((const byte*)_workScreen->pixels, _workScreen->pitch, 0, 0, _workScreen->w, _workScreen->h);
-
- _vm->_system->updateScreen();
-
+ _vm->_screen->updateScreenAndWait(10);
}
void Screen::clearChannels() {
@@ -626,14 +624,13 @@ void Screen::show() {
_fx->run(_visualEffectNum, _workScreen, _palette, _newPalette, _paletteColorCount);
_visualEffectNum = 0;
- _vm->_system->updateScreen();
-
if (!_paletteInitialized) {
memcpy(_newPalette, _palette, _paletteColorCount * 3);
_oldPaletteColorCount = _paletteColorCount;
_paletteInitialized = true;
}
+ updateScreenAndWait(10);
}
void Screen::flash(int flashCount) {
diff --git a/engines/made/script.cpp b/engines/made/script.cpp
index 79f93f3b23..4c3bff77c3 100644
--- a/engines/made/script.cpp
+++ b/engines/made/script.cpp
@@ -144,9 +144,6 @@ void ScriptInterpreter::runScript(int16 scriptObjectIndex) {
_codeIp = _codeBase;
while (!_vm->shouldQuit()) {
-
- _vm->handleEvents();
-
byte opcode = readByte();
if (opcode >= 1 && opcode <= _commandsMax) {
@@ -159,11 +156,7 @@ void ScriptInterpreter::runScript(int16 scriptObjectIndex) {
/* We sleep a little after 500 opcodes to reduce the CPU load.
*/
if (++opcodeSleepCounter > 500) {
- uint32 startTime = _vm->_system->getMillis();
- while (_vm->_system->getMillis() < startTime + 5) {
- _vm->handleEvents();
- _vm->_system->delayMillis(5);
- }
+ _vm->_screen->updateScreenAndWait(5);
opcodeSleepCounter = 0;
}
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 77e180628f..5b6ff37905 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -203,11 +203,12 @@ int16 ScriptFunctions::sfShowPage(int16 argc, int16 *argv) {
}
int16 ScriptFunctions::sfPollEvent(int16 argc, int16 *argv) {
-
- _vm->_system->updateScreen();
+ _vm->handleEvents();
+ _vm->_screen->updateScreenAndWait(10);
int16 eventNum = _vm->_eventNum;
_vm->_eventNum = 0;
+
return eventNum;
}