aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorFilippos Karapetis2016-08-22 19:56:06 +0300
committerFilippos Karapetis2016-08-22 19:56:06 +0300
commitba8d6f6c0336b105127efb229989c6c76ad5e677 (patch)
treec8e6e9e49b2e7c547bf4e3478318c47e9256d649 /engines/sci/graphics
parent39307d1f4da51d9adc78da70ba1eddec237ff48b (diff)
downloadscummvm-rg350-ba8d6f6c0336b105127efb229989c6c76ad5e677.tar.gz
scummvm-rg350-ba8d6f6c0336b105127efb229989c6c76ad5e677.tar.bz2
scummvm-rg350-ba8d6f6c0336b105127efb229989c6c76ad5e677.zip
SCI32: Move the SCI32 Mac cursor handling code into GfxCursor32
This was left in the SCI16 code in commit 80d9182554
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/cursor.cpp41
-rw-r--r--engines/sci/graphics/cursor.h5
-rw-r--r--engines/sci/graphics/cursor32.cpp54
-rw-r--r--engines/sci/graphics/cursor32.h5
4 files changed, 69 insertions, 36 deletions
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index c3229121c8..7cf9a574ef 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -512,32 +512,18 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
// automatically. The view resources may exist, but none of the games actually
// use them.
- if (_macCursorRemap.empty()) {
- // QFG1/Freddy/Hoyle4 use a straight viewNum->cursor ID mapping
- // KQ6 uses this mapping for its cursors
- if (g_sci->getGameId() == GID_KQ6) {
- if (viewNum == 990) // Inventory Cursors
- viewNum = loopNum * 16 + celNum + 2000;
- else if (viewNum == 998) // Regular Cursors
- viewNum = celNum + 1000;
- else // Unknown cursor, ignored
- return;
- }
- if (g_sci->hasMacIconBar())
- g_sci->_gfxMacIconBar->setInventoryIcon(viewNum);
- } else {
- // If we do have the list, we'll be using a remap based on what the
- // scripts have given us.
- for (uint32 i = 0; i < _macCursorRemap.size(); i++) {
- if (viewNum == _macCursorRemap[i]) {
- viewNum = (i + 1) * 0x100 + loopNum * 0x10 + celNum;
- break;
- }
-
- if (i == _macCursorRemap.size())
- error("Unmatched Mac cursor %d", viewNum);
- }
+ // QFG1/Freddy/Hoyle4 use a straight viewNum->cursor ID mapping
+ // KQ6 uses this mapping for its cursors
+ if (g_sci->getGameId() == GID_KQ6) {
+ if (viewNum == 990) // Inventory Cursors
+ viewNum = loopNum * 16 + celNum + 2000;
+ else if (viewNum == 998) // Regular Cursors
+ viewNum = celNum + 1000;
+ else // Unknown cursor, ignored
+ return;
}
+ if (g_sci->hasMacIconBar())
+ g_sci->_gfxMacIconBar->setInventoryIcon(viewNum);
Resource *resource = _resMan->findResource(ResourceId(kResourceTypeCursor, viewNum), false);
@@ -568,9 +554,4 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
kernelShow();
}
-void GfxCursor::setMacCursorRemapList(int cursorCount, reg_t *cursors) {
- for (int i = 0; i < cursorCount; i++)
- _macCursorRemap.push_back(cursors[i].toUint16());
-}
-
} // End of namespace Sci
diff --git a/engines/sci/graphics/cursor.h b/engines/sci/graphics/cursor.h
index c57d9dab52..36518ea5db 100644
--- a/engines/sci/graphics/cursor.h
+++ b/engines/sci/graphics/cursor.h
@@ -95,8 +95,6 @@ public:
void kernelSetPos(Common::Point pos);
void kernelMoveCursor(Common::Point pos);
- void setMacCursorRemapList(int cursorCount, reg_t *cursors);
-
private:
void purgeCache();
@@ -136,9 +134,6 @@ private:
// these instead and replace the game's gold cursors with their silver
// equivalents.
bool _useSilverSQ4CDCursors;
-
- // Mac versions of games use a remap list to remap their cursors
- Common::Array<uint16> _macCursorRemap;
};
} // End of namespace Sci
diff --git a/engines/sci/graphics/cursor32.cpp b/engines/sci/graphics/cursor32.cpp
index 014b617c74..88150db6e6 100644
--- a/engines/sci/graphics/cursor32.cpp
+++ b/engines/sci/graphics/cursor32.cpp
@@ -22,7 +22,9 @@
#include "common/rational.h" // for Rational, operator*
#include "common/system.h" // for OSystem, g_system
+#include "common/memstream.h"
#include "graphics/cursorman.h" // for CursorMan
+#include "graphics/maccursor.h"
#include "sci/graphics/celobj32.h" // for CelObjView, CelInfo32, Ratio
#include "sci/graphics/cursor32.h"
#include "sci/graphics/frameout.h" // for GfxFrameout
@@ -176,7 +178,7 @@ void GfxCursor32::setView(const GuiResourceId viewId, const int16 loopNo, const
_cursorInfo.loopNo = loopNo;
_cursorInfo.celNo = celNo;
- if (viewId != -1) {
+ if (_macCursorRemap.empty() && viewId != -1) {
CelObjView view(viewId, loopNo, celNo);
_hotSpot = view._displace;
@@ -217,6 +219,50 @@ void GfxCursor32::setView(const GuiResourceId viewId, const int16 loopNo, const
} else {
view.draw(target, _cursor.rect, Common::Point(0, 0), false);
}
+ } else if (!_macCursorRemap.empty() && viewId != -1) {
+ // Mac cursor handling
+ GuiResourceId viewNum = viewId;
+
+ // Remap cursor view based on what the scripts have given us.
+ for (uint32 i = 0; i < _macCursorRemap.size(); i++) {
+ if (viewNum == _macCursorRemap[i]) {
+ viewNum = (i + 1) * 0x100 + loopNo * 0x10 + celNo;
+ break;
+ }
+
+ if (i == _macCursorRemap.size())
+ error("Unmatched Mac cursor %d", viewNum);
+ }
+
+ _cursorInfo.resourceId = viewNum;
+
+ Resource *resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeCursor, viewNum), false);
+
+ if (!resource) {
+ // The cursor resources often don't exist, this is normal behavior
+ debug(0, "Mac cursor %d not found", viewNum);
+ return;
+ }
+ Common::MemoryReadStream resStream(resource->data, resource->size);
+ Graphics::MacCursor *macCursor = new Graphics::MacCursor();
+
+ if (!macCursor->readFromStream(resStream)) {
+ warning("Failed to load Mac cursor %d", viewNum);
+ delete macCursor;
+ return;
+ }
+
+ _hotSpot = Common::Point(macCursor->getHotspotX(), macCursor->getHotspotY());
+ _width = macCursor->getWidth();
+ _height = macCursor->getHeight();
+
+ _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
+ memcpy(_cursor.data, macCursor->getSurface(), _width * _height);
+ _cursor.rect = Common::Rect(_width, _height);
+ _cursor.skipColor = macCursor->getKeyColor();
+
+ // The cursor will be drawn on next refresh
+ delete macCursor;
} else {
_hotSpot = Common::Point(0, 0);
_width = _height = 1;
@@ -393,4 +439,10 @@ void GfxCursor32::move() {
drawToHardware(_drawBuff2);
}
}
+
+void GfxCursor32::setMacCursorRemapList(int cursorCount, reg_t *cursors) {
+ for (int i = 0; i < cursorCount; i++)
+ _macCursorRemap.push_back(cursors[i].toUint16());
+}
+
} // End of namespace Sci
diff --git a/engines/sci/graphics/cursor32.h b/engines/sci/graphics/cursor32.h
index d4745536b1..88a75beb7f 100644
--- a/engines/sci/graphics/cursor32.h
+++ b/engines/sci/graphics/cursor32.h
@@ -109,6 +109,8 @@ public:
*/
void clearRestrictedArea();
+ void setMacCursorRemapList(int cursorCount, reg_t *cursors);
+
virtual void saveLoadWithSerializer(Common::Serializer &ser);
private:
@@ -203,6 +205,9 @@ private:
*/
bool _writeToVMAP;
+ // Mac versions of games use a remap list to remap their cursors
+ Common::Array<uint16> _macCursorRemap;
+
/**
* Reads data from the output buffer or hardware
* to the given draw region.