aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-07 14:53:15 +0000
committerMartin Kiewitz2009-10-07 14:53:15 +0000
commit1dfe7578cba4894630bd6fa093cfa1607fbdad6e (patch)
treef8b14f9eea63060f11f27fd38320ec3c32d53128 /engines/sci
parentece4f55db970c27a82d99aac76bc621790478b61 (diff)
downloadscummvm-rg350-1dfe7578cba4894630bd6fa093cfa1607fbdad6e.tar.gz
scummvm-rg350-1dfe7578cba4894630bd6fa093cfa1607fbdad6e.tar.bz2
scummvm-rg350-1dfe7578cba4894630bd6fa093cfa1607fbdad6e.zip
SCI/newgui: kSetCursor (show, hide, pos, shape) implemented
svn-id: r44734
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kgraphics.cpp19
-rw-r--r--engines/sci/gui/gui.cpp12
-rw-r--r--engines/sci/gui/gui.h3
-rw-r--r--engines/sci/gui/gui_cursor.cpp69
-rw-r--r--engines/sci/gui/gui_cursor.h10
-rw-r--r--engines/sci/gui32/gui32.cpp16
-rw-r--r--engines/sci/gui32/gui32.h3
7 files changed, 123 insertions, 9 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 57b884ee09..0a0b9e51d7 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -269,13 +269,7 @@ PaletteEntry get_pic_color(EngineState *s, int color) {
static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) {
Common::Point pos;
-
- int16 cursor = argv[0].toSint16();
-
- if ((argc >= 2) && (argv[1].toSint16() == 0))
- cursor = GFXOP_NO_POINTER;
-
- gfxop_set_pointer_cursor(s->gfx_state, cursor);
+ GuiResourceId cursorId = argv[0].toSint16();
// Set pointer position, if requested
if (argc >= 4) {
@@ -283,6 +277,12 @@ static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) {
pos.x = argv[2].toSint16();
s->gui->setCursorPos(pos);
}
+
+ if ((argc >= 2) && (argv[1].toSint16() == 0)) {
+ cursorId = -1;
+ }
+
+ s->gui->setCursorShape(cursorId);
return s->r_acc;
}
@@ -292,7 +292,10 @@ static reg_t kSetCursorSci11(EngineState *s, int argc, reg_t *argv) {
switch (argc) {
case 1:
- CursorMan.showMouse(argv[0].toSint16() != 0);
+ if (argv[0].isNull())
+ s->gui->setCursorHide();
+ else
+ s->gui->setCursorShow();
break;
case 2:
pos.y = argv[1].toSint16();
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 36e24a10fc..25c61ae7fb 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -461,6 +461,18 @@ void SciGui::setNowSeen(reg_t objectReference) {
_gfx->SetNowSeen(objectReference);
}
+void SciGui::setCursorHide() {
+ _cursor->hide();
+}
+
+void SciGui::setCursorShow() {
+ _cursor->show();
+}
+
+void SciGui::setCursorShape(GuiResourceId cursorId) {
+ _cursor->setShape(cursorId);
+}
+
void SciGui::setCursorPos(Common::Point pos) {
// FIXME: try to find out if we need to adjust position somehow, currently just forwarding to moveCursor()
moveCursor(pos);
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index 4997d0ff03..fafc6a8a10 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -84,6 +84,9 @@ public:
virtual void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
virtual void setNowSeen(reg_t objectReference);
+ virtual void setCursorHide();
+ virtual void setCursorShow();
+ virtual void setCursorShape(GuiResourceId cursorId);
virtual void setCursorPos(Common::Point pos);
virtual void moveCursor(Common::Point pos);
diff --git a/engines/sci/gui/gui_cursor.cpp b/engines/sci/gui/gui_cursor.cpp
index c77c85968a..baf2be01f8 100644
--- a/engines/sci/gui/gui_cursor.cpp
+++ b/engines/sci/gui/gui_cursor.cpp
@@ -23,7 +23,7 @@
*
*/
-#include "common/timer.h"
+#include "graphics/cursorman.h"
#include "common/util.h"
#include "sci/sci.h"
@@ -44,6 +44,73 @@ SciGuiCursor::~SciGuiCursor() {
}
void SciGuiCursor::init() {
+ _rawBitmap = NULL;
+}
+
+void SciGuiCursor::show() {
+ CursorMan.showMouse(true);
+}
+
+void SciGuiCursor::hide() {
+ CursorMan.showMouse(false);
+}
+
+void SciGuiCursor::setShape(GuiResourceId resourceId) {
+ Resource *resource;
+ byte *resourceData;
+ Common::Point hotspot = Common::Point(0, 0);
+ byte colorMapping[4];
+ int16 x, y;
+ byte color;
+ int16 maskA, maskB;
+ byte *pOut;
+
+ if (resourceId == -1) {
+ // no resourceId given, so we actually hide the cursor
+ hide();
+ return;
+ }
+
+ // Load cursor resource...
+ resource = _s->resMan->findResource(ResourceId(kResourceTypeCursor, resourceId), false);
+ if (!resource)
+ error("cursor resource %d not found", resourceId);
+ if (resource->size != SCI_CURSOR_SCI0_RESOURCESIZE)
+ error("cursor resource %d has invalid size", resourceId);
+
+ resourceData = resource->data;
+ // hotspot is specified for SCI1 cursors
+ hotspot.x = READ_LE_UINT16(resourceData);
+ hotspot.y = READ_LE_UINT16(resourceData + 2);
+ // bit 0 of resourceData[3] is set on <SCI1 games, which means center hotspot
+ if ((hotspot.x == 0) && (hotspot.y == 256))
+ hotspot.x = hotspot.y = SCI_CURSOR_SCI0_HEIGHTWIDTH / 2;
+
+ // Now find out what colors we are supposed to use
+ colorMapping[0] = 0; // Black is hardcoded
+ colorMapping[1] = _palette->matchColor(&_palette->_sysPalette, 255, 255, 255); // White
+ colorMapping[2] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR;
+ colorMapping[3] = _palette->matchColor(&_palette->_sysPalette, 170, 170, 170); // Grey
+
+ // Seek to actual data
+ resourceData += 4;
+
+ if (!_rawBitmap)
+ _rawBitmap = new byte[SCI_CURSOR_SCI0_HEIGHTWIDTH*SCI_CURSOR_SCI0_HEIGHTWIDTH];
+
+ pOut = _rawBitmap;
+ for (y = 0; y < SCI_CURSOR_SCI0_HEIGHTWIDTH; y++) {
+ maskA = READ_LE_UINT16(resourceData + (y << 1));
+ maskB = READ_LE_UINT16(resourceData + 32 + (y << 1));
+
+ for (x = 0; x < SCI_CURSOR_SCI0_HEIGHTWIDTH; x++) {
+ color = (((maskA << x) & 0x8000) | (((maskB << x) >> 1) & 0x4000)) >> 14;
+ *pOut++ = colorMapping[color];
+ }
+ }
+
+ CursorMan.replaceCursor(_rawBitmap, SCI_CURSOR_SCI0_HEIGHTWIDTH, SCI_CURSOR_SCI0_HEIGHTWIDTH, hotspot.x, hotspot.y, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
+ CursorMan.showMouse(true);
}
void SciGuiCursor::setPosition(Common::Point pos) {
diff --git a/engines/sci/gui/gui_cursor.h b/engines/sci/gui/gui_cursor.h
index bf2dad04e8..2a14f9e5e5 100644
--- a/engines/sci/gui/gui_cursor.h
+++ b/engines/sci/gui/gui_cursor.h
@@ -30,6 +30,11 @@
namespace Sci {
+#define SCI_CURSOR_SCI0_HEIGHTWIDTH 16
+#define SCI_CURSOR_SCI0_RESOURCESIZE 68
+
+#define SCI_CURSOR_SCI0_TRANSPARENCYCOLOR 1
+
class SciGuiView;
class SciGuiPalette;
class SciGuiCursor {
@@ -37,6 +42,9 @@ public:
SciGuiCursor(EngineState *state, SciGuiPalette *palette);
~SciGuiCursor();
+ void show();
+ void hide();
+ void setShape(GuiResourceId resourceId);
void setPosition(Common::Point pos);
private:
@@ -45,6 +53,8 @@ private:
EngineState *_s;
SciGuiScreen *_screen;
SciGuiPalette *_palette;
+
+ byte *_rawBitmap;
};
} // End of namespace Sci
diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp
index 2248a58455..4fdffe3267 100644
--- a/engines/sci/gui32/gui32.cpp
+++ b/engines/sci/gui32/gui32.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "graphics/cursorman.h"
#include "common/util.h"
#include "sci/sci.h"
@@ -2002,6 +2003,21 @@ void SciGui32::setNowSeen(reg_t objectReference) {
_k_set_now_seen(objectReference);
}
+void SciGui32::setCursorHide() {
+ CursorMan.showMouse(false);
+}
+
+void SciGui32::setCursorShow() {
+ CursorMan.showMouse(true);
+}
+
+void SciGui32::setCursorShape(GuiResourceId cursorId) {
+ if (cursorId == -1)
+ gfxop_set_pointer_cursor(s->gfx_state, GFXOP_NO_POINTER);
+ else
+ gfxop_set_pointer_cursor(s->gfx_state, cursorId);
+}
+
void SciGui32::setCursorPos(Common::Point pos) {
pos.y += s->port->_bounds.y;
pos.x += s->port->_bounds.x;
diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h
index 5af02a26f7..d9d5909b98 100644
--- a/engines/sci/gui32/gui32.h
+++ b/engines/sci/gui32/gui32.h
@@ -77,6 +77,9 @@ public:
void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
void setNowSeen(reg_t objectReference);
+ void setCursorHide();
+ void setCursorShow();
+ void setCursorShape(GuiResourceId cursorId);
void setCursorPos(Common::Point pos);
void moveCursor(Common::Point pos);