Skip to content

Commit

Permalink
BACKENDS: WII: Always retain cursor palette
Browse files Browse the repository at this point in the history
Calling setMouseCursor with a non-palette cursor no longer
clears the cursor palette, allowing a subsequent call with a
paletted cursor to re-use it. This fixes Trac defect #13895.
The approach taken was to just copy what the OpenGL
backend was doing in the same situation.
  • Loading branch information
fracturehill committed Oct 2, 2023
1 parent 7aae7ec commit 73b66c6
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions backends/platform/wii/osystem_gfx.cpp
Expand Up @@ -334,8 +334,13 @@ void OSystem_Wii::updateMousePalette() {
printf("%s() _cursorPaletteDisabled:%d\n", __func__, _cursorPaletteDisabled);
#endif

if (_texMouse.palette && _cursorPaletteDisabled) {
memcpy(_texMouse.palette, _cursorPalette, 256 * 2);
if (_texMouse.palette) {
if (!_cursorPaletteDisabled) {
memcpy(_texMouse.palette, _cursorPalette, 256 * 2);
} else {
memcpy(_texMouse.palette, _texGame.palette, 256 * 2);
}

_cursorPaletteDirty = true;
}
}
Expand All @@ -357,20 +362,7 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {

gfx_tex_flush_palette(&_texGame);

s = colors;
d = _cursorPalette;

for (uint i = 0; i < num; ++i, s += 3) {
d[start + i] = _pfRGB3444.ARGBToColor(0xff, s[0], s[1], s[2]);
}

if (_cursorPaletteDisabled) {
assert(_texMouse.palette);

memcpy((u8 *)_texMouse.palette + start * 2, (u8 *)_cursorPalette + start * 2, num * 2);

_cursorPaletteDirty = true;
}
updateMousePalette();
}

void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) const {
Expand Down Expand Up @@ -407,18 +399,16 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) {
gfx_tex_set_bilinear_filter(&_texMouse, _bilinearFilter);
}

if (_cursorPaletteDisabled) {
memcpy(_cursorPalette, _texMouse.palette, 256 * 2);
_cursorPaletteDisabled = false;
}
_cursorPaletteDisabled = false;

const byte *s = colors;
u16 *d = _texMouse.palette;
u16 *d = _cursorPalette;

for (uint i = 0; i < num; ++i, s += 3)
for (uint i = 0; i < num; ++i, s += 3) {
d[start + i] = _pfRGB3444.ARGBToColor(0xff, s[0], s[1], s[2]);
}

_cursorPaletteDirty = true;
updateMousePalette();
}

void OSystem_Wii::copyRectToScreen(const void *buf, int pitch, int x, int y,
Expand Down Expand Up @@ -788,6 +778,6 @@ void OSystem_Wii::setMouseCursor(const void *buf, uint w, uint h, int hotspotX,
_mouseHotspotY = hotspotY;
_cursorDontScale = dontScale;

if ((_texMouse.palette) && (oldKeycolor != _mouseKeyColor))
_cursorPaletteDirty = true;
if (_pfCursor.bytesPerPixel == 1 && oldKeycolor != _mouseKeyColor)
updateMousePalette();
}

0 comments on commit 73b66c6

Please sign in to comment.