From 87ee8db10d27e760f095e30db79ab14e9fb56ad9 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 20 May 2006 08:06:21 +0000 Subject: Our GUI uses the "cursor palette" feature, but the SDL backend did not use the cursor palette in overlay mode. Now it does, which fixes bug #1476666. The reason it worked at all before was that blitCursor() was called while still not in overlay mode. This, of course, means that the GUI can corrupt the in-game cursor palette. I don't have any game that uses this feature, so I don't know if it's properly restored again afterwards. But if it isn't, that should be fairly easy to fix. svn-id: r22539 --- backends/sdl/graphics.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp index afd28fddb0..269bdbc16d 100644 --- a/backends/sdl/graphics.cpp +++ b/backends/sdl/graphics.cpp @@ -1062,8 +1062,7 @@ void OSystem_SDL::setCursorPalette(const byte *colors, uint start, uint num) { _cursorHasOwnPalette = true; _cursorPaletteDisabled = false; - if (!_overlayVisible) - blitCursor(); + blitCursor(); } void OSystem_SDL::setShakePos(int shake_pos) { @@ -1332,18 +1331,19 @@ void OSystem_SDL::blitCursor() { // Draw from [1,1] since AdvMame2x adds artefact at 0,0 dstPtr = (byte *)_mouseOrigSurface->pixels + _mouseOrigSurface->pitch + 2; + SDL_Color *palette; + + if (_cursorHasOwnPalette && !_cursorPaletteDisabled) + palette = _cursorPalette; + else + palette = _currentPalette; + for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { color = *srcPtr; if (color != _mouseKeyColor) { // transparent, don't draw - if (_cursorHasOwnPalette && !_overlayVisible && !_cursorPaletteDisabled) - *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, - _cursorPalette[color].r, _cursorPalette[color].g, - _cursorPalette[color].b); - else - *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, - _currentPalette[color].r, _currentPalette[color].g, - _currentPalette[color].b); + *(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format, + palette[color].r, palette[color].g, palette[color].b); } dstPtr += 2; srcPtr++; -- cgit v1.2.3