aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gui
diff options
context:
space:
mode:
authorFilippos Karapetis2009-10-31 15:44:59 +0000
committerFilippos Karapetis2009-10-31 15:44:59 +0000
commit6fd5fdcf7ba66daf6e1de53efe2197a75afcaada (patch)
tree50042bbfc93d77132a427dbeebb35d51a680e035 /engines/sci/gui
parent99cd8d5d2f489cdfe764da46903446eb2f6d5914 (diff)
downloadscummvm-rg350-6fd5fdcf7ba66daf6e1de53efe2197a75afcaada.tar.gz
scummvm-rg350-6fd5fdcf7ba66daf6e1de53efe2197a75afcaada.tar.bz2
scummvm-rg350-6fd5fdcf7ba66daf6e1de53efe2197a75afcaada.zip
Upscale the mouse cursor when the screen is upscaled. Also, reapplied some code which was accidentally reverted in commit #45562
svn-id: r45565
Diffstat (limited to 'engines/sci/gui')
-rw-r--r--engines/sci/gui/gui_cursor.cpp38
-rw-r--r--engines/sci/gui/gui_screen.cpp18
-rw-r--r--engines/sci/gui/gui_screen.h2
3 files changed, 45 insertions, 13 deletions
diff --git a/engines/sci/gui/gui_cursor.cpp b/engines/sci/gui/gui_cursor.cpp
index cad6b2178a..37ba42c895 100644
--- a/engines/sci/gui/gui_cursor.cpp
+++ b/engines/sci/gui/gui_cursor.cpp
@@ -40,8 +40,9 @@ SciGuiCursor::SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette, SciG
: _resMan(resMan), _palette(palette), _screen(screen) {
_upscaledHires = _screen->getUpscaledHires();
- setPosition(Common::Point(160, 150)); // TODO: how is that different in 640x400 games?
- setMoveZone(Common::Rect(0, 0, 320, 200)); // TODO: hires games
+ // center mouse cursor
+ setPosition(Common::Point(_screen->_displayWidth / 2, _screen->_displayHeight / 2));
+ setMoveZone(Common::Rect(0, 0, _screen->_displayWidth, _screen->_displayHeight));
}
SciGuiCursor::~SciGuiCursor() {
@@ -149,9 +150,23 @@ void SciGuiCursor::setView(GuiResourceId viewNum, int loopNum, int celNum, Commo
return;
}
- cursorView->getBitmap(loopNum, celNum);
+ byte *cursorBitmap = cursorView->getBitmap(loopNum, celNum);
+
+ if (_upscaledHires) {
+ // Scale cursor by 2x
+ width *= 2;
+ height *= 2;
+ cursorHotspot->x *= 2;
+ cursorHotspot->y *= 2;
+ cursorBitmap = new byte[width * height];
+ _screen->scale2x(celInfo->rawBitmap, cursorBitmap, celInfo->width, celInfo->height);
+ }
+
+ CursorMan.replaceCursor(cursorBitmap, width, height, cursorHotspot->x, cursorHotspot->y, clearKey);
+
+ if (_upscaledHires)
+ delete cursorBitmap;
- CursorMan.replaceCursor(celInfo->rawBitmap, width, height, cursorHotspot->x, cursorHotspot->y, clearKey);
show();
delete cursorHotspot;
@@ -166,13 +181,14 @@ void SciGuiCursor::setPosition(Common::Point pos) {
}
Common::Point SciGuiCursor::getPosition() {
- if (!_upscaledHires) {
- return g_system->getEventManager()->getMousePos();
- } else {
- Common::Point mousePos = g_system->getEventManager()->getMousePos();
- mousePos.x /= 2; mousePos.y /= 2;
- return mousePos;
+ Common::Point mousePos = g_system->getEventManager()->getMousePos();
+
+ if (_upscaledHires) {
+ mousePos.x /= 2;
+ mousePos.y /= 2;
}
+
+ return mousePos;
}
void SciGuiCursor::refreshPosition() {
@@ -197,7 +213,7 @@ void SciGuiCursor::refreshPosition() {
// FIXME: Do this only when mouse is grabbed?
if (clipped)
- g_system->warpMouse(mousePoint.x, mousePoint.y);
+ setPosition(mousePoint);
}
} // End of namespace Sci
diff --git a/engines/sci/gui/gui_screen.cpp b/engines/sci/gui/gui_screen.cpp
index 6418751a66..5fe037dd42 100644
--- a/engines/sci/gui/gui_screen.cpp
+++ b/engines/sci/gui/gui_screen.cpp
@@ -119,14 +119,13 @@ byte SciGuiScreen::getDrawingMask(byte color, byte prio, byte control) {
void SciGuiScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) {
int offset = y * _width + x;
- int displayOffset;
if (drawMask & SCI_SCREEN_MASK_VISUAL) {
_visualScreen[offset] = color;
if (!_upscaledHires) {
_displayScreen[offset] = color;
} else {
- displayOffset = y * 2 * _displayWidth + x * 2;
+ int displayOffset = y * 2 * _displayWidth + x * 2;
_displayScreen[displayOffset] = color;
_displayScreen[displayOffset + 1] = color;
_displayScreen[displayOffset + _displayWidth] = color;
@@ -494,4 +493,19 @@ void SciGuiScreen::debugShowMap(int mapNo) {
copyToScreen();
}
+void SciGuiScreen::scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight) {
+ int newWidth = srcWidth * 2;
+
+ for (int y = 0; y < srcHeight; y++) {
+ for (int x = 0; x < srcWidth; x++) {
+ int destOffset = y * 2 * newWidth + x * 2;
+ int color = src[y * srcWidth + x];
+ dst[destOffset] = color;
+ dst[destOffset + 1] = color;
+ dst[destOffset + newWidth] = color;
+ dst[destOffset + newWidth + 1] = color;
+ }
+ }
+}
+
} // End of namespace Sci
diff --git a/engines/sci/gui/gui_screen.h b/engines/sci/gui/gui_screen.h
index 4759b094d9..e82c22f16a 100644
--- a/engines/sci/gui/gui_screen.h
+++ b/engines/sci/gui/gui_screen.h
@@ -75,6 +75,8 @@ public:
void setVerticalShakePos(uint16 shakePos);
+ void scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight);
+
void dither(bool addToFlag);
void unditherSetState(bool flag);
int16 *unditherGetMemorial();