aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Hesse2006-07-09 18:54:12 +0000
committerSven Hesse2006-07-09 18:54:12 +0000
commitdcbbfa01c09854903666cce7ec855883b4257c00 (patch)
treeb1d1c0cf044c9ebfc9f465f3dc22dce173ccbedd
parent75e64b91defc913956767698b6d8eccc7bc59e7f (diff)
downloadscummvm-rg350-dcbbfa01c09854903666cce7ec855883b4257c00.tar.gz
scummvm-rg350-dcbbfa01c09854903666cce7ec855883b4257c00.tar.bz2
scummvm-rg350-dcbbfa01c09854903666cce7ec855883b4257c00.zip
Instead of drawing the mouse cursor as a sprite, let the backend handle it
svn-id: r23464
-rw-r--r--engines/gob/draw.cpp4
-rw-r--r--engines/gob/draw.h9
-rw-r--r--engines/gob/draw_v1.cpp71
-rw-r--r--engines/gob/draw_v2.cpp64
-rw-r--r--engines/gob/game.cpp7
-rw-r--r--engines/gob/game_v1.cpp3
-rw-r--r--engines/gob/inter_v1.cpp6
-rw-r--r--engines/gob/inter_v2.cpp6
-rw-r--r--engines/gob/video.h1
-rw-r--r--engines/gob/video_v1.cpp3
-rw-r--r--engines/gob/video_v2.cpp5
11 files changed, 80 insertions, 99 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp
index 4d305c49a1..d66b019ae5 100644
--- a/engines/gob/draw.cpp
+++ b/engines/gob/draw.cpp
@@ -117,10 +117,11 @@ Draw::Draw(GobEngine *vm) : _vm(vm) {
_cursorAnimDelays[i] = 0;
}
+ _showCursor = 0;
_cursorIndex = 0;
_transparentCursor = 0;
_cursorSprites = 0;
- _cursorBack = 0;
+ _scummvmCursor = 0;
_cursorAnim = 0;
_palLoadData1[0] = 0;
@@ -261,6 +262,7 @@ void Draw::blitInvalidated(void) {
return;
}
+ _showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
if (_applyPal) {
clearPalette();
diff --git a/engines/gob/draw.h b/engines/gob/draw.h
index 7010f95425..40eee165aa 100644
--- a/engines/gob/draw.h
+++ b/engines/gob/draw.h
@@ -87,6 +87,12 @@ public:
Video::Color _vgaPalette[256];
Video::Color _vgaSmallPalette[16];
+ // 0 (00b): No cursor
+ // 1 (01b): Cursor would be on _backSurface
+ // 2 (10b): Cursor would be on _frontSurface
+ // 3 (11b): Cursor would be on _backSurface and _frontSurface
+ uint8 _showCursor;
+
int16 _cursorX;
int16 _cursorY;
int16 _cursorWidth;
@@ -97,7 +103,8 @@ public:
Video::SurfaceDesc *_cursorSprites;
Video::SurfaceDesc *_cursorSpritesBack;
- Video::SurfaceDesc *_cursorBack;
+ Video::SurfaceDesc *_scummvmCursor;
+
int16 _cursorAnim;
int8 _cursorAnimLow[40];
int8 _cursorAnimHigh[40];
diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp
index e355ebcfcb..e06cd95467 100644
--- a/engines/gob/draw_v1.cpp
+++ b/engines/gob/draw_v1.cpp
@@ -23,6 +23,7 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "graphics/cursorman.h"
#include "gob/gob.h"
#include "gob/draw.h"
@@ -492,20 +493,9 @@ void Draw_v1::spriteOperation(int16 operation) {
void Draw_v1::blitCursor(void) {
if (_cursorIndex == -1)
return;
-
- _cursorIndex = -1;
-
- if (_noInvalidated) {
- _vm->_video->drawSprite(_backSurface, _frontSurface,
- _cursorX, _cursorY,
- _cursorX + _cursorWidth - 1,
- _cursorY + _cursorHeight - 1, _cursorX,
- _cursorY, 0);
- } else {
- invalidateRect(_cursorX, _cursorY,
- _cursorX + _cursorWidth - 1,
- _cursorY + _cursorHeight - 1);
- }
+
+ if (_showCursor == 2)
+ _showCursor = 0;
}
void Draw_v1::animateCursor(int16 cursor) {
@@ -518,6 +508,7 @@ void Draw_v1::animateCursor(int16 cursor) {
int16 maxY;
int16 cursorIndex;
+ _showCursor = 2;
cursorIndex = cursor;
if (cursorIndex == -1) {
@@ -556,9 +547,11 @@ void Draw_v1::animateCursor(int16 cursor) {
_cursorAnim++;
_cursorTimeKey = _vm->_util->getTimeKey();
} else {
-/* if (_noInvalidated &&
- inter_mouseX == _cursorX && inter_mouseY == _cursorY)
- return;*/
+ if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
+ (_vm->_global->_inter_mouseY == _cursorY)) {
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ return;
+ }
}
} else {
_cursorIndex = cursorIndex;
@@ -589,33 +582,27 @@ void Draw_v1::animateCursor(int16 cursor) {
minY = MIN(newY, _cursorY);
maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
- _vm->_video->drawSprite(_backSurface, _cursorBack,
- newX, newY, newX + _cursorWidth - 1,
- newY + _cursorHeight - 1, 0, 0, 0);
-
- _vm->_video->drawSprite(_cursorSprites, _backSurface,
- _cursorWidth * _cursorAnim, 0,
- _cursorWidth * (_cursorAnim + 1) - 1,
- _cursorHeight - 1, newX, newY, _transparentCursor);
-
- if (_noInvalidated == 0) {
- cursorIndex = _cursorIndex;
- _cursorIndex = -1;
- blitInvalidated();
- _cursorIndex = cursorIndex;
- } else {
- _vm->_video->waitRetrace(_vm->_global->_videoMode);
- }
- _vm->_video->drawSprite(_backSurface, _frontSurface,
- minX, minY, maxX, maxY, minX, minY, 0);
-
- _vm->_video->drawSprite(_cursorBack, _backSurface,
- 0, 0, _cursorWidth - 1, _cursorHeight - 1,
- newX, newY, 0);
- } else {
+ _vm->_video->drawSprite(_cursorSprites, _scummvmCursor, _cursorWidth * _cursorAnim,
+ 0, _cursorWidth * (_cursorAnim + 1) - 1, _cursorHeight - 1, 0, 0, 0);
+ CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight, 0, 0, 0);
+
+ if (_frontSurface != _backSurface) {
+ _showCursor = 3;
+ if (_noInvalidated == 0) {
+ int16 tmp = _cursorIndex;
+ _cursorIndex = -1;
+ blitInvalidated();
+ _cursorIndex = tmp;
+ } else {
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ if (minY < 50)
+ _vm->_util->delay(5);
+ _showCursor = 0;
+ }
+ }
+ } else
blitCursor();
- }
_cursorX = newX;
_cursorY = newY;
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index af1d61fbb3..7be6f20f52 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -23,6 +23,7 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "graphics/cursorman.h"
#include "gob/gob.h"
#include "gob/draw.h"
@@ -877,27 +878,11 @@ void Draw_v2::spriteOperation(int16 operation) {
}
void Draw_v2::blitCursor(void) {
- int16 width;
- int16 height;
-
if (_cursorIndex == -1)
return;
-
- _cursorIndex = -1;
- width = _cursorWidth;
- height = _cursorHeight;
- if(_backSurface->width < (_cursorX + _cursorWidth))
- width -= _cursorX;
- if(_backSurface->height < (_cursorY + _cursorHeight))
- height -= _cursorY;
- if (_frontSurface == _backSurface)
- _vm->_video->drawSprite(_cursorBack, _frontSurface, 0, 0, width - 1, height - 1,
- _cursorX, _cursorY, 0);
- else if (_noInvalidated == 0)
- invalidateRect(_cursorX, _cursorY, _cursorX + width - 1, _cursorY + height - 1);
- else
- _vm->_video->drawSprite(_backSurface, _frontSurface, _cursorX, _cursorY,
- _cursorX + width - 1, _cursorY + height - 1, _cursorX, _cursorY, 0);
+
+ if (_showCursor == 2)
+ _showCursor = 0;
}
void Draw_v2::animateCursor(int16 cursor) {
@@ -909,9 +894,8 @@ void Draw_v2::animateCursor(int16 cursor) {
int16 maxX;
int16 maxY;
int16 cursorIndex;
- bool oldCursor;
- oldCursor = _cursorIndex != -1;
+ _showCursor |= 2;
if (((_backSurface->width - 9) < _vm->_global->_inter_mouseX) ||
((_backSurface->height - 4) < _vm->_global->_inter_mouseY)) {
@@ -968,6 +952,8 @@ void Draw_v2::animateCursor(int16 cursor) {
} else {
if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
(_vm->_global->_inter_mouseY == _cursorY)) {
+ if (!CursorMan.isVisible())
+ _showCursor = 0;
_vm->_video->waitRetrace(_vm->_global->_videoMode);
return;
}
@@ -1000,26 +986,16 @@ void Draw_v2::animateCursor(int16 cursor) {
minY = MIN(newY, _cursorY);
maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
- if (_frontSurface == _backSurface) { // loc_177C2
- if ((newX != _cursorX) || (newY != _cursorY)) {
- if (oldCursor)
- _vm->_video->drawSprite(_cursorBack, _frontSurface, 0, 0,
- _cursorWidth - 1, _cursorHeight - 1, _cursorX, _cursorY, 0);
- _vm->_video->drawSprite(_frontSurface, _cursorBack, newX, newY,
- newX + _cursorWidth - 1, newY + _cursorHeight - 1, 0, 0, 0);
- _vm->_video->drawSprite(_cursorSprites, _frontSurface,
- cursorIndex * _cursorWidth, 0,
- (cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1,
- newX, newY, _transparentCursor);
- }
- } else { // loc_1787D
- _vm->_video->drawSprite(_backSurface, _cursorBack, newX, newY,
- newX + _cursorWidth - 1, newY + _cursorHeight - 1, 0, 0, 0);
- _vm->_video->drawSprite(_cursorSprites, _backSurface,
- cursorIndex * _cursorWidth, 0,
- (cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1,
- newX, newY, _transparentCursor);
+
+ _vm->_video->clearSurf(_scummvmCursor);
+ _vm->_video->drawSprite(_cursorSprites, _scummvmCursor, cursorIndex * _cursorWidth,
+ 0, (cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1, 0, 0, 0);
+ CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight, 0, 0, 0);
+
+ if (_frontSurface != _backSurface) {
+ _showCursor |= 1;
if (_noInvalidated == 0) {
+ _showCursor = CursorMan.isVisible() ? 2 : 0;
int16 tmp = _cursorIndex;
_cursorIndex = -1;
blitInvalidated();
@@ -1028,15 +1004,15 @@ void Draw_v2::animateCursor(int16 cursor) {
_vm->_video->waitRetrace(_vm->_global->_videoMode);
if (minY < 50)
_vm->_util->delay(5);
+ _showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
}
- _vm->_video->drawSprite(_backSurface, _frontSurface,
- minX, minY, maxX, maxY, minX, minY, 0);
- _vm->_video->drawSprite(_cursorBack, _backSurface, 0, 0,
- _cursorWidth - 1, _cursorHeight - 1, newX, newY, 0);
+ _showCursor &= ~1;
}
} else
blitCursor();
+ if (CursorMan.isVisible())
+ _showCursor = 2;
_cursorX = newX;
_cursorY = newY;
}
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index d34004729f..3445c66074 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -675,7 +675,7 @@ void Game::start(void) {
delete[] _collisionAreas;
_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
- _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+ _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
_vm->_video->freeSurfDesc(_vm->_draw->_backSurface);
}
@@ -985,7 +985,8 @@ void Game::sub_ADD2(void) {
// TODO: That assignment is not in the original assembly, why?
_vm->_draw->_cursorSpritesBack = _vm->_draw->_spritesArray[23];
_vm->_draw->_cursorSprites = _vm->_draw->_cursorSpritesBack;
- _vm->_draw->_cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0);
+ _vm->_draw->_scummvmCursor =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
_vm->_draw->_spritesArray[20] = _vm->_draw->_frontSurface;
_vm->_draw->_spritesArray[21] = _vm->_draw->_backSurface;
@@ -999,7 +1000,7 @@ void Game::sub_ADD2(void) {
// "DEVclosescreen"
void Game::sub_BB28(void) {
_vm->_draw->freeSprite(23);
- _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+ _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
if (_off_2E51B != 0) {
memcpy(_vm->_draw->_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc));
_vm->_draw->_frontSurface->width = 320;
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index 053061f2ba..4ef194ed86 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -622,7 +622,8 @@ void Game_v1::prepareStart(void) {
_vm->_draw->_cursorAnimLow[1] = 0;
_vm->_draw->_cursorSprites = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 32, 16, 2);
- _vm->_draw->_cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0);
+ _vm->_draw->_scummvmCursor =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
_vm->_draw->_renderFlags = 0;
_vm->_draw->_backDeltaX = 0;
_vm->_draw->_backDeltaY = 0;
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index c83e76874a..2c25322f38 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -804,7 +804,7 @@ void Inter_v1::o1_initCursor(void) {
_vm->_draw->_cursorSprites->width != width * count) {
_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
- _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+ _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
_vm->_draw->_cursorWidth = width;
_vm->_draw->_cursorHeight = height;
@@ -822,9 +822,9 @@ void Inter_v1::o1_initCursor(void) {
_vm->_draw->_cursorHeight, 2);
_vm->_draw->_spritesArray[23] = _vm->_draw->_cursorSprites;
- _vm->_draw->_cursorBack =
+ _vm->_draw->_scummvmCursor =
_vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth,
- _vm->_draw->_cursorHeight, 0);
+ _vm->_draw->_cursorHeight, SCUMMVM_CURSOR);
for (i = 0; i < 40; i++) {
_vm->_draw->_cursorAnimLow[i] = -1;
_vm->_draw->_cursorAnimDelays[i] = 0;
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 2c3454e406..608ffa4e05 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -1812,7 +1812,7 @@ void Inter_v2::o2_initCursor(void) {
_vm->_draw->_cursorSprites->width != width * count) {
_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
- _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+ _vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
_vm->_draw->_cursorWidth = width;
_vm->_draw->_cursorHeight = height;
@@ -1830,9 +1830,9 @@ void Inter_v2::o2_initCursor(void) {
_vm->_draw->_cursorSpritesBack = _vm->_draw->_spritesArray[23];
_vm->_draw->_cursorSprites = _vm->_draw->_cursorSpritesBack;
- _vm->_draw->_cursorBack =
+ _vm->_draw->_scummvmCursor =
_vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth,
- _vm->_draw->_cursorHeight, 0);
+ _vm->_draw->_cursorHeight, SCUMMVM_CURSOR);
for (i = 0; i < 40; i++) {
_vm->_draw->_cursorAnimLow[i] = -1;
_vm->_draw->_cursorAnimDelays[i] = 0;
diff --git a/engines/gob/video.h b/engines/gob/video.h
index 880df95e84..8bb7a6f14c 100644
--- a/engines/gob/video.h
+++ b/engines/gob/video.h
@@ -71,6 +71,7 @@ public:
#define PRIMARY_SURFACE 0x80
#define RETURN_PRIMARY 0x01
#define DISABLE_SPR_ALLOC 0x20
+#define SCUMMVM_CURSOR 0x100
#if defined(START_PACK_STRUCTS)
#pragma START_PACK_STRUCTS
diff --git a/engines/gob/video_v1.cpp b/engines/gob/video_v1.cpp
index 61b565bcc4..7f7910fad6 100644
--- a/engines/gob/video_v1.cpp
+++ b/engines/gob/video_v1.cpp
@@ -23,10 +23,12 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "graphics/cursorman.h"
#include "gob/gob.h"
#include "gob/global.h"
#include "gob/video.h"
+#include "gob/draw.h"
namespace Gob {
@@ -36,6 +38,7 @@ Video_v1::Video_v1(GobEngine *vm) : Video(vm) {
//XXX: Use this function to update the screen for now.
// This should be moved to a better location later on.
void Video_v1::waitRetrace(int16) {
+ CursorMan.showMouse((bool) (_vm->_draw->_showCursor & 2));
if (_vm->_global->_pPrimarySurfDesc) {
g_system->copyRectToScreen(_vm->_global->_pPrimarySurfDesc->vidPtr, 320, 0, 0, 320, 200);
g_system->updateScreen();
diff --git a/engines/gob/video_v2.cpp b/engines/gob/video_v2.cpp
index edb2ea0287..22af58a0a8 100644
--- a/engines/gob/video_v2.cpp
+++ b/engines/gob/video_v2.cpp
@@ -23,6 +23,7 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "graphics/cursorman.h"
#include "gob/gob.h"
#include "gob/global.h"
@@ -37,6 +38,7 @@ Video_v2::Video_v2(GobEngine *vm) : Video_v1(vm) {
//XXX: Use this function to update the screen for now.
// This should be moved to a better location later on.
void Video_v2::waitRetrace(int16) {
+ CursorMan.showMouse((bool) (_vm->_draw->_showCursor & 2));
if (_vm->_draw->_frontSurface) {
g_system->copyRectToScreen(_vm->_draw->_frontSurface->vidPtr, 320, 0, 0, 320, 200);
g_system->updateScreen();
@@ -106,7 +108,8 @@ Video::SurfaceDesc *Video_v2::initSurfDesc(int16 vidMode, int16 width, int16 hei
else
flagsAnd2 = 0;
- width = (width + 7) & 0xFFF8;
+ if ((flags & SCUMMVM_CURSOR) == 0)
+ width = (width + 7) & 0xFFF8;
if (flags & PRIMARY_SURFACE) {
_vm->_global->_primaryWidth = width;