aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2009-06-29 18:00:18 +0000
committerJohannes Schickel2009-06-29 18:00:18 +0000
commit67f69bcaf2a0e425eb0799683fc631213775aabb (patch)
treeaaa6b93b19599af651d45522e247595706722b0c /engines
parentc810f9645af0259c2ff89a76bcc3d565f2f58601 (diff)
downloadscummvm-rg350-67f69bcaf2a0e425eb0799683fc631213775aabb.tar.gz
scummvm-rg350-67f69bcaf2a0e425eb0799683fc631213775aabb.tar.bz2
scummvm-rg350-67f69bcaf2a0e425eb0799683fc631213775aabb.zip
- Get rid of code duplication for mouse cursor setup
- Fix mouse cursor colors in LoL PC98 (This commit might introduce regressions, since it changes the key color the mouse cursor uses) svn-id: r41959
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/screen.cpp9
-rw-r--r--engines/kyra/screen.h5
-rw-r--r--engines/kyra/screen_lok.cpp56
-rw-r--r--engines/kyra/screen_lok.h5
-rw-r--r--engines/kyra/screen_lol.cpp12
-rw-r--r--engines/kyra/screen_lol.h1
6 files changed, 26 insertions, 62 deletions
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 3c9759d88d..84be942a1f 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -2622,12 +2622,12 @@ void Screen::setMouseCursor(int x, int y, const byte *shape) {
y <<= 1;
mouseWidth <<= 1;
mouseHeight <<= 1;
- fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 0, 8);
+ fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 255, 8);
}
uint8 *cursor = new uint8[mouseHeight * mouseWidth];
- fillRect(0, 0, mouseWidth, mouseHeight, 0, 8);
+ fillRect(0, 0, mouseWidth, mouseHeight, 255, 8);
drawShape(8, shape, 0, 0, 0, 0);
int xOffset = 0;
@@ -2635,11 +2635,14 @@ void Screen::setMouseCursor(int x, int y, const byte *shape) {
if (_vm->gameFlags().useHiResOverlay) {
xOffset = mouseWidth;
scale2x(getPagePtr(8) + mouseWidth, SCREEN_W, getPagePtr(8), SCREEN_W, mouseWidth, mouseHeight);
+ postProcessCursor(getPagePtr(8) + mouseWidth, mouseWidth, mouseHeight, SCREEN_W);
+ } else {
+ postProcessCursor(getPagePtr(8), mouseWidth, mouseHeight, SCREEN_W);
}
CursorMan.showMouse(false);
copyRegionToBuffer(8, xOffset, 0, mouseWidth, mouseHeight, cursor);
- CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 0);
+ CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 255);
if (isMouseVisible())
CursorMan.showMouse(true);
delete[] cursor;
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index ba69aea3cc..3d2bda3b59 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -298,7 +298,7 @@ public:
void hideMouse();
void showMouse();
bool isMouseVisible() const;
- virtual void setMouseCursor(int x, int y, const byte *shape);
+ void setMouseCursor(int x, int y, const byte *shape);
// rect handling
virtual int getRectSize(int w, int h) = 0;
@@ -396,8 +396,11 @@ protected:
uint8 *_animBlockPtr;
int _animBlockSize;
+ // mouse handling
int _mouseLockCount;
+ virtual void postProcessCursor(uint8 *data, int w, int h, int pitch) {};
+
enum {
kMaxDirtyRects = 50
};
diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp
index 8ab1ee853c..9fdeae1398 100644
--- a/engines/kyra/screen_lok.cpp
+++ b/engines/kyra/screen_lok.cpp
@@ -324,62 +324,6 @@ int Screen_LoK_16::fadePalStep(const Palette &pal, int diff) {
return 0;
}
-// TODO: This is currently nearly the same as Screen::setMouseCursor, only that
-// we added conversion to 16 colors, when usehiResOverlay is enabled and that the
-// key color is 255 instead of 0. We might consider merging this again with
-// Screen::setMouseCursor.
-void Screen_LoK_16::setMouseCursor(int x, int y, const byte *shape) {
- if (!shape)
- return;
- // if mouseDisabled
- // return _mouseShape
-
- if (_vm->gameFlags().useAltShapeHeader)
- shape += 2;
-
- int mouseHeight = *(shape + 2);
- int mouseWidth = (READ_LE_UINT16(shape + 3)) + 2;
-
- if (_vm->gameFlags().useAltShapeHeader)
- shape -= 2;
-
- if (_vm->gameFlags().useHiResOverlay) {
- x <<= 1;
- y <<= 1;
- mouseWidth <<= 1;
- mouseHeight <<= 1;
- fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 0, 8);
- }
-
-
- uint8 *cursor = new uint8[mouseHeight * mouseWidth];
- // Since color id '0' is used for black in some tiems, we must switch to 255 as color key.
- fillRect(0, 0, mouseWidth, mouseHeight, 255, 8);
- drawShape(8, shape, 0, 0, 0, 0);
-
- int xOffset = 0;
-
- if (_vm->gameFlags().useHiResOverlay) {
- xOffset = mouseWidth;
- scale2x(getPagePtr(8) + mouseWidth, SCREEN_W, getPagePtr(8), SCREEN_W, mouseWidth, mouseHeight);
- // We need to pass the color key number to our conversion function, else it'll convert the color too.
- convertTo16Colors(getPagePtr(8) + mouseWidth, mouseWidth * 2, mouseHeight * 2, 320, 255);
- }
-
- CursorMan.showMouse(false);
- copyRegionToBuffer(8, xOffset, 0, mouseWidth, mouseHeight, cursor);
- CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 255);
- if (isMouseVisible())
- CursorMan.showMouse(true);
- delete[] cursor;
-
- // makes sure that the cursor is drawn
- // we do not use Screen::updateScreen here
- // so we can be sure that changes to page 0
- // are NOT updated on the real screen here
- _system->updateScreen();
-}
-
void Screen_LoK_16::paletteMap(uint8 idx, int r, int g, int b) {
const int red = r;
const int green = g;
diff --git a/engines/kyra/screen_lok.h b/engines/kyra/screen_lok.h
index 7ab0bb2811..f845261f29 100644
--- a/engines/kyra/screen_lok.h
+++ b/engines/kyra/screen_lok.h
@@ -86,12 +86,13 @@ public:
void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
int fadePalStep(const Palette &pal, int diff);
-
- void setMouseCursor(int x, int y, const byte *shape);
private:
void updateDirtyRectsOvl();
void convertTo16Colors(uint8 *page, int w, int h, int pitch, int keyColor = -1);
+ void postProcessCursor(uint8 *data, int width, int height, int pitch) {
+ convertTo16Colors(data, width, height, pitch, 255);
+ }
void mergeOverlay(int x, int y, int w, int h);
void set16ColorPalette(const uint8 *pal);
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index a3c5cc6123..ad7061dd97 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -994,6 +994,18 @@ void Screen_LoL::convertPC98Gfx(uint8 *data, int w, int h, int pitch) {
}
}
+void Screen_LoL::postProcessCursor(uint8 *data, int w, int h, int pitch) {
+ while (h--) {
+ for (int i = 0; i < w; ++i) {
+ if (*data != 255)
+ *data = _paletteConvTable[*data];
+ ++data;
+ }
+
+ data += pitch - w;
+ }
+}
+
} // end of namespace Kyra
#endif // ENABLE_LOL
diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h
index 1c94392b4e..db355977f8 100644
--- a/engines/kyra/screen_lol.h
+++ b/engines/kyra/screen_lol.h
@@ -111,6 +111,7 @@ private:
static const uint8 _paletteConvTable[256];
void mergeOverlay(int x, int y, int w, int h);
+ void postProcessCursor(uint8 *data, int width, int height, int pitch);
// magic atlas
void calcBoundariesIntern(int dstX, int dstY, int c, int d);