diff options
author | Jody Northup | 2009-06-05 06:41:04 +0000 |
---|---|---|
committer | Jody Northup | 2009-06-05 06:41:04 +0000 |
commit | f8361b5c53b96faddb56024bb932ce46b7005dbf (patch) | |
tree | 54235722ffac47e02e855778f129a9665481a00d | |
parent | 1f43d9b860b9c1a6d5e62cc261ff5da94b42d50e (diff) | |
download | scummvm-rg350-f8361b5c53b96faddb56024bb932ce46b7005dbf.tar.gz scummvm-rg350-f8361b5c53b96faddb56024bb932ce46b7005dbf.tar.bz2 scummvm-rg350-f8361b5c53b96faddb56024bb932ce46b7005dbf.zip |
Converted cursor code to use 16-bit.
svn-id: r41191
-rw-r--r-- | backends/platform/sdl/graphics.cpp | 17 | ||||
-rw-r--r-- | engines/scumm/costume.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/cursor.cpp | 14 | ||||
-rw-r--r-- | engines/scumm/he/wiz_he.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 5 | ||||
-rw-r--r-- | graphics/cursorman.cpp | 4 |
6 files changed, 37 insertions, 9 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp index 389a7a0735..1a80b9be19 100644 --- a/backends/platform/sdl/graphics.cpp +++ b/backends/platform/sdl/graphics.cpp @@ -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; } diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 4358e03a2a..089e7a2fbe 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -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++) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 64829114ca..66dd3807db 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -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; } diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 8fe2639fbb..e91eb48cd4 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -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); diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index c4b2ab9e56..5580c4c73d 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -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; diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index fe5f653b94..f303749572 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -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; |