Instead of drawing the mouse cursor as a sprite, let the backend handle it

svn-id: r23464
This commit is contained in:
Sven Hesse 2006-07-09 18:54:12 +00:00
parent 75e64b91de
commit dcbbfa01c0
11 changed files with 78 additions and 97 deletions

View file

@ -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();

View file

@ -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];

View file

@ -23,6 +23,7 @@
#include "common/stdafx.h"
#include "common/endian.h"
#include "graphics/cursorman.h"
#include "gob/gob.h"
#include "gob/draw.h"
@ -493,19 +494,8 @@ 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);
_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 (_noInvalidated == 0) {
cursorIndex = _cursorIndex;
_cursorIndex = -1;
blitInvalidated();
_cursorIndex = cursorIndex;
} else {
_vm->_video->waitRetrace(_vm->_global->_videoMode);
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;
}
}
_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 {
} else
blitCursor();
}
_cursorX = newX;
_cursorY = newY;

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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();

View file

@ -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;