aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2016-08-22 19:56:06 +0300
committerFilippos Karapetis2016-08-22 19:56:06 +0300
commitba8d6f6c0336b105127efb229989c6c76ad5e677 (patch)
treec8e6e9e49b2e7c547bf4e3478318c47e9256d649
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
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kmisc.cpp11
-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
6 files changed, 80 insertions, 38 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 023a2c024b..3bfc6efc4b 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -711,6 +711,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(PicNotValid), SIG_EVERYWHERE, "(i)", NULL, NULL },
{ MAP_CALL(Platform), SIG_SCI16, SIGFOR_ALL, "(.*)", NULL, NULL },
#ifdef ENABLE_SCI32
+ { "Platform", kPlatform32, SIG_SCI32, SIGFOR_MAC, "(.*)", NULL, NULL },
{ "Platform", kPlatform32, SIG_SCI32, SIGFOR_ALL, "(i)", NULL, NULL },
#endif
{ MAP_CALL(Portrait), SIG_EVERYWHERE, "i(.*)", NULL, NULL }, // subop
@@ -752,6 +753,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(ShowMovie), SIG_SCI16, SIGFOR_ALL, "(.*)", NULL, NULL },
#ifdef ENABLE_SCI32
{ "ShowMovie", kShowMovie32, SIG_SCI32, SIGFOR_DOS, "ri(i)(i)", NULL, NULL },
+ { "ShowMovie", kShowMovie32, SIG_SCI32, SIGFOR_MAC, "ri(i)(i)", NULL, NULL },
{ "ShowMovie", kShowMovieWin, SIG_SCI32, SIGFOR_WIN, "(.*)", kShowMovieWin_subops, NULL },
#endif
{ MAP_CALL(Show), SIG_EVERYWHERE, "i", NULL, NULL },
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index ff7370a002..70a1d696e8 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -30,6 +30,9 @@
#include "sci/engine/kernel.h"
#include "sci/engine/gc.h"
#include "sci/graphics/cursor.h"
+#ifdef ENABLE_SCI32
+#include "sci/graphics/cursor32.h"
+#endif
#include "sci/graphics/maciconbar.h"
#include "sci/console.h"
@@ -512,7 +515,7 @@ reg_t kMacPlatform(EngineState *s, int argc, reg_t *argv) {
// In SCI1.1, it's NOP
// In SCI32, it's used for remapping cursor ID's
if (getSciVersion() >= SCI_VERSION_2_1_EARLY) // Set Mac cursor remap
- g_sci->_gfxCursor->setMacCursorRemapList(argc - 1, argv + 1);
+ g_sci->_gfxCursor32->setMacCursorRemapList(argc - 1, argv + 1);
else if (getSciVersion() != SCI_VERSION_1_1)
warning("Unknown SCI1 kMacPlatform(0) call");
break;
@@ -613,7 +616,11 @@ reg_t kPlatform32(EngineState *s, int argc, reg_t *argv) {
case Common::kPlatformWindows:
return make_reg(0, kSciPlatformWindows);
case Common::kPlatformMacintosh:
- return make_reg(0, kSciPlatformMacintosh);
+ // For Mac versions, kPlatform(0) with other args has more functionality
+ if (argc > 1)
+ return kMacPlatform(s, argc - 1, argv + 1);
+ else
+ return make_reg(0, kSciPlatformMacintosh);
default:
error("Unknown platform %d", g_sci->getPlatform());
}
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.