Converted cursor code to use 16-bit.
svn-id: r41191
This commit is contained in:
parent
1f43d9b860
commit
f8361b5c53
6 changed files with 37 additions and 9 deletions
|
@ -1438,8 +1438,13 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
|
|||
|
||||
free(_mouseData);
|
||||
|
||||
#ifdef ENABLE_16BIT
|
||||
_mouseData = (byte *)malloc(w * h * 2);
|
||||
memcpy(_mouseData, buf, w * h * 2);
|
||||
#else
|
||||
_mouseData = (byte *)malloc(w * h);
|
||||
memcpy(_mouseData, buf, w * h);
|
||||
#endif
|
||||
blitCursor();
|
||||
}
|
||||
|
||||
|
@ -1481,12 +1486,24 @@ void OSystem_SDL::blitCursor() {
|
|||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
color = *srcPtr;
|
||||
#ifdef ENABLE_16BIT
|
||||
if (color != _mouseKeyColor) { // transparent, don't draw
|
||||
int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3;
|
||||
int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3;
|
||||
int8 b = (*(uint16 *)srcPtr & 0x1F) << 3;
|
||||
*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
|
||||
r, g, b);
|
||||
}
|
||||
dstPtr += 2;
|
||||
srcPtr += 2;
|
||||
#else
|
||||
if (color != _mouseKeyColor) { // transparent, don't draw
|
||||
*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
|
||||
palette[color].r, palette[color].g, palette[color].b);
|
||||
}
|
||||
dstPtr += 2;
|
||||
srcPtr++;
|
||||
#endif
|
||||
}
|
||||
dstPtr += _mouseOrigSurface->pitch - w * 2;
|
||||
}
|
||||
|
|
|
@ -876,7 +876,7 @@ void ClassicCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask)
|
|||
|
||||
void ClassicCostumeRenderer::setPalette(uint16 *palette) {
|
||||
int i;
|
||||
byte color;
|
||||
byte color = 0;
|
||||
|
||||
if (_loaded._format == 0x57) {
|
||||
for (i = 0; i < 13; i++)
|
||||
|
|
|
@ -111,7 +111,13 @@ void ScummEngine_v6::setCursorTransparency(int a) {
|
|||
}
|
||||
|
||||
void ScummEngine::updateCursor() {
|
||||
const int transColor = (_game.heversion >= 80) ? 5 : 255;
|
||||
//HACK Put the 16-bit mapped color, and
|
||||
//hope no other palette entry shares it
|
||||
int transColor = (_game.heversion >= 80) ? 5 : 255;
|
||||
if (_game.features & GF_16BIT_COLOR && _hePalettes)
|
||||
transColor = READ_LE_UINT16(_hePalettes + 2048 + transColor * 2);
|
||||
else
|
||||
transColor = 0;
|
||||
CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
|
||||
_cursor.hotspotX, _cursor.hotspotY,
|
||||
(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
|
||||
|
@ -138,7 +144,7 @@ void ScummEngine::setCursorFromBuffer(const byte *ptr, int width, int height, in
|
|||
uint size;
|
||||
byte *dst;
|
||||
|
||||
size = width * height;
|
||||
size = width * height * _bitDepth;
|
||||
if (size > sizeof(_grabbedCursor))
|
||||
error("grabCursor: grabbed cursor too big");
|
||||
|
||||
|
@ -148,8 +154,8 @@ void ScummEngine::setCursorFromBuffer(const byte *ptr, int width, int height, in
|
|||
|
||||
dst = _grabbedCursor;
|
||||
for (; height; height--) {
|
||||
memcpy(dst, ptr, width);
|
||||
dst += width;
|
||||
memcpy(dst, ptr, width * _bitDepth);
|
||||
dst += width * _bitDepth;
|
||||
ptr += pitch;
|
||||
}
|
||||
|
||||
|
|
|
@ -1800,14 +1800,12 @@ void Wiz::loadWizCursor(int resId, int palette) {
|
|||
}
|
||||
|
||||
const Common::Rect *r = NULL;
|
||||
_vm->_bitDepth = 1;
|
||||
uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette));
|
||||
_vm->_bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1;
|
||||
|
||||
int32 cw, ch;
|
||||
getWizImageDim(resId, 0, cw, ch);
|
||||
_vm->setCursorHotspot(x, y);
|
||||
_vm->setCursorFromBuffer(cursor, cw, ch, cw);
|
||||
_vm->setCursorFromBuffer(cursor, cw, ch, cw * _vm->_bitDepth);
|
||||
|
||||
// Since we set up cursor palette for default cursor, disable it now
|
||||
CursorMan.disableCursorPalette(true);
|
||||
|
|
|
@ -974,7 +974,10 @@ protected:
|
|||
byte animate, animateIndex;
|
||||
int8 state;
|
||||
} _cursor;
|
||||
byte _grabbedCursor[8192];
|
||||
|
||||
// HACK Double the array size to handle 16-bit images.
|
||||
// this should be dynamically allocated based on game depth instead.
|
||||
byte _grabbedCursor[16384];
|
||||
byte _currentCursor;
|
||||
|
||||
byte _newEffect, _switchRoomEffect2, _switchRoomEffect;
|
||||
|
|
|
@ -108,7 +108,11 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX,
|
|||
}
|
||||
|
||||
Cursor *cur = _cursorStack.top();
|
||||
#ifdef ENABLE_16BIT
|
||||
uint size = w * h * 2;
|
||||
#else
|
||||
uint size = w * h;
|
||||
#endif
|
||||
|
||||
if (cur->_size < size) {
|
||||
delete[] cur->_data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue