aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-08-10 15:48:50 +0000
committerTorbjörn Andersson2005-08-10 15:48:50 +0000
commitc3f3d9f3f2b3e1ddf9804276cf57a9e009011c02 (patch)
tree2d8f1ed4962a84c85990dd2a2146c9e7ca18b9f2
parent5f1da785363c2cd313907e4abeed642c6dce4eaf (diff)
downloadscummvm-rg350-c3f3d9f3f2b3e1ddf9804276cf57a9e009011c02.tar.gz
scummvm-rg350-c3f3d9f3f2b3e1ddf9804276cf57a9e009011c02.tar.bz2
scummvm-rg350-c3f3d9f3f2b3e1ddf9804276cf57a9e009011c02.zip
Made Gobliiins less of a CPU hog by adding some strategic delays and
turning on the screen auto-dirtying - some as Simon uses. It's not perfect by any means, but it may be good enough for 0.8.0 at least. svn-id: r18649
-rw-r--r--gob/draw.cpp2
-rw-r--r--gob/game.cpp3
-rw-r--r--gob/global.cpp1
-rw-r--r--gob/global.h1
-rw-r--r--gob/gob.cpp6
-rw-r--r--gob/inter.cpp7
-rw-r--r--gob/palanim.cpp2
-rw-r--r--gob/scenery.cpp3
-rw-r--r--gob/util.cpp15
-rw-r--r--gob/video.cpp2
10 files changed, 23 insertions, 19 deletions
diff --git a/gob/draw.cpp b/gob/draw.cpp
index 4585f23905..6e93380e84 100644
--- a/gob/draw.cpp
+++ b/gob/draw.cpp
@@ -653,8 +653,6 @@ void draw_animateCursor(int16 cursor) {
draw_cursorIndex = cursorIndex;
} else {
vid_waitRetrace(videoMode);
- if (minY < 50)
- util_delay(5);
}
vid_drawSprite(draw_backSurface, draw_frontSurface,
diff --git a/gob/game.cpp b/gob/game.cpp
index 15cf15e65a..3f0ccf76c1 100644
--- a/gob/game.cpp
+++ b/gob/game.cpp
@@ -684,6 +684,8 @@ int16 game_checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
if (handleMouse != 0)
draw_animateCursor(-1);
+ util_delay(10);
+
snd_loopSounds();
}
}
@@ -1247,6 +1249,7 @@ void game_collisionsBlock(void) {
case 20:
collResId = curCmd;
+ // Fall through to case 2
case 2:
key = inter_load16();
diff --git a/gob/global.cpp b/gob/global.cpp
index 9dd612a72c..25717edfde 100644
--- a/gob/global.cpp
+++ b/gob/global.cpp
@@ -61,7 +61,6 @@ uint16 language = 0x8000;
/* Timer variables */
int32 startTime = 0;
-char timer_enabled = 1;
int16 timer_delta = 1000;
int16 frameWaitTime = 0;
diff --git a/gob/global.h b/gob/global.h
index 169ea13552..acb2c8da6e 100644
--- a/gob/global.h
+++ b/gob/global.h
@@ -77,7 +77,6 @@ extern uint16 language;
/* Timer variables */
extern int32 startTime;
-extern char timer_enabled;
extern int16 timer_delta;
extern int16 frameWaitTime;
diff --git a/gob/gob.cpp b/gob/gob.cpp
index 275e9d8397..21c1837b6b 100644
--- a/gob/gob.cpp
+++ b/gob/gob.cpp
@@ -274,6 +274,12 @@ int GobEngine::init(GameDetector &detector) {
break;
}
+ // FIXME: This is the ugly way of reducing redraw overhead. It works
+ // well for 320x200 but it's unclear how well it will work for
+ // 640x480.
+
+ g_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true);
+
return 0;
}
diff --git a/gob/inter.cpp b/gob/inter.cpp
index c1b91b00c4..63028c93de 100644
--- a/gob/inter.cpp
+++ b/gob/inter.cpp
@@ -426,6 +426,13 @@ void inter_drawOperations(void) {
case 33:
if (_vm->_features & GF_GOB1) {
// Used in gob1 CD
+
+ // Some scripts busy-wait while calling this opcode.
+ // This is a very nasty thing to do, so let's add a
+ // short delay here. It's probably a safe thing to do.
+
+ util_longDelay(1);
+
int pos = cd_getTrackPos();
if (pos == -1)
pos = 32767;
diff --git a/gob/palanim.cpp b/gob/palanim.cpp
index 693d994748..ed0fd8a856 100644
--- a/gob/palanim.cpp
+++ b/gob/palanim.cpp
@@ -188,7 +188,6 @@ void pal_fade(PalDesc *palDesc, int16 fade, int16 allColors) {
}
if (allColors == 0) {
-
do {
if (tmpPalBuffer == 0)
vid_waitRetrace(videoMode);
@@ -206,7 +205,6 @@ void pal_fade(PalDesc *palDesc, int16 fade, int16 allColors) {
}
if (allColors == 1) {
-
do {
vid_waitRetrace(videoMode);
stop = pal_fadeStep(1);
diff --git a/gob/scenery.cpp b/gob/scenery.cpp
index d6ca0d0583..2e70b03792 100644
--- a/gob/scenery.cpp
+++ b/gob/scenery.cpp
@@ -389,7 +389,8 @@ int16 scen_loadAnim(char search) {
int16 sprIndex;
if (cd_globFlag) {
- while (cd_getTrackPos() != -1);
+ while (cd_getTrackPos() != -1)
+ util_longDelay(50);
cd_globFlag = false;
}
diff --git a/gob/util.cpp b/gob/util.cpp
index 68705cc382..d3580baa94 100644
--- a/gob/util.cpp
+++ b/gob/util.cpp
@@ -244,23 +244,15 @@ void util_setFrameRate(int16 rate) {
void util_waitEndFrame() {
int32 time;
- if (pPrimarySurfDesc) {
- g_system->copyRectToScreen(pPrimarySurfDesc->vidPtr, 320, 0, 0, 320, 200);
- g_system->updateScreen();
- }
+ vid_waitRetrace(videoMode);
time = util_getTimeKey() - startFrameTime;
if (time > 1000 || time < 0) {
startFrameTime = util_getTimeKey();
return;
}
- if (timer_enabled) {
- do {
- time = util_getTimeKey();
- } while (time - startFrameTime < frameWaitTime);
- } else {
- if (frameWaitTime - time > 0)
- util_delay(frameWaitTime - time);
+ if (frameWaitTime - time > 0) {
+ util_delay(frameWaitTime - time);
}
startFrameTime = util_getTimeKey();
}
@@ -502,6 +494,7 @@ void util_waitMouseRelease(char drawMouse) {
game_checkKeys(&mouseX, &mouseY, &buttons, drawMouse);
if (drawMouse != 0)
draw_animateCursor(2);
+ util_delay(10);
} while (buttons != 0);
}
diff --git a/gob/video.cpp b/gob/video.cpp
index 6df6c68d00..92aebe02e4 100644
--- a/gob/video.cpp
+++ b/gob/video.cpp
@@ -286,7 +286,7 @@ void vid_putPixel(int16 x, int16 y, int16 color, SurfaceDesc *dest) {
}
void vid_drawLetter(unsigned char item, int16 x, int16 y, FontDesc *fontDesc, int16 color1,
- int16 color2, int16 transp, SurfaceDesc * dest) {
+ int16 color2, int16 transp, SurfaceDesc *dest) {
_videoDriver->drawLetter(item, x, y, fontDesc, color1, color2, transp, dest);
}