aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMatthew Hoops2010-08-14 04:21:09 +0000
committerMatthew Hoops2010-08-14 04:21:09 +0000
commitf252c0b67ef74da5376fcf3a08d514fb311c4316 (patch)
tree86414e24710278916e78353946d32fd18fb357d0 /engines/sci
parentd882661aecbe8dc27979f15fadfc83882fe58a8d (diff)
downloadscummvm-rg350-f252c0b67ef74da5376fcf3a08d514fb311c4316.tar.gz
scummvm-rg350-f252c0b67ef74da5376fcf3a08d514fb311c4316.tar.bz2
scummvm-rg350-f252c0b67ef74da5376fcf3a08d514fb311c4316.zip
SCI: Add support for Mac 'crsr' cursors used in SCI2+ games
svn-id: r52076
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/cursor.cpp63
-rw-r--r--engines/sci/resource.cpp18
2 files changed, 49 insertions, 32 deletions
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index f6e2077cb3..a906899113 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -23,10 +23,11 @@
*
*/
-#include "graphics/cursorman.h"
-#include "common/util.h"
#include "common/events.h"
+#include "common/macresman.h"
#include "common/system.h"
+#include "common/util.h"
+#include "graphics/cursorman.h"
#include "sci/sci.h"
#include "sci/event.h"
@@ -206,7 +207,7 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
// See http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-402.html
// for more information.
- // View 998 seems to be a fake resource used to call for the Mac CURS resources.
+ // View 998 seems to be a fake resource used to call for Mac cursor resources.
// For other resources, they're still in the views, so use them.
if (viewNum != 998) {
kernelSetView(viewNum, loopNum, celNum, hotspot);
@@ -214,43 +215,53 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
}
// TODO: What about the 2000 resources? Inventory items? How to handle?
- // TODO: What games does this work for? At least it does for KQ6.
- // TODO: Stop asking rhetorical questions.
- // TODO: It was fred all along!
+ // TODO: 1000 + celNum won't work for GK1
Resource *resource = _resMan->findResource(ResourceId(kResourceTypeCursor, 1000 + celNum), false);
if (!resource) {
- warning("CURS %d not found", 1000 + celNum);
+ warning("Mac cursor %d not found", 1000 + celNum);
return;
}
assert(resource);
- byte *cursorBitmap = new byte[16 * 16];
- byte *data = resource->data;
+ if (resource->size == 32 * 2 + 4) {
+ // Mac CURS cursor
+ byte *cursorBitmap = new byte[16 * 16];
+ byte *data = resource->data;
- // Get B&W data
- for (byte i = 0; i < 32; i++) {
- byte imageByte = *data++;
- for (byte b = 0; b < 8; b++)
- cursorBitmap[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x00 : 0xFF);
- }
+ // Get B&W data
+ for (byte i = 0; i < 32; i++) {
+ byte imageByte = *data++;
+ for (byte b = 0; b < 8; b++)
+ cursorBitmap[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x00 : 0xFF);
+ }
- // Apply mask data
- for (byte i = 0; i < 32; i++) {
- byte imageByte = *data++;
- for (byte b = 0; b < 8; b++)
- if ((imageByte & (0x80 >> b)) == 0)
- cursorBitmap[i * 8 + b] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; // Doesn't matter, just is transparent
- }
+ // Apply mask data
+ for (byte i = 0; i < 32; i++) {
+ byte imageByte = *data++;
+ for (byte b = 0; b < 8; b++)
+ if ((imageByte & (0x80 >> b)) == 0)
+ cursorBitmap[i * 8 + b] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; // Doesn't matter, just is transparent
+ }
- uint16 hotspotX = READ_BE_UINT16(data);
- uint16 hotspotY = READ_BE_UINT16(data + 2);
+ uint16 hotspotX = READ_BE_UINT16(data);
+ uint16 hotspotY = READ_BE_UINT16(data + 2);
- CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
+ CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
- delete[] cursorBitmap;
+ delete[] cursorBitmap;
+ } else {
+ // Mac crsr cursor
+ byte *cursorBitmap, *palette;
+ int width, height, hotspotX, hotspotY, palSize, keycolor;
+ Common::MacResManager::convertCrsrCursor(resource->data, resource->size, &cursorBitmap, &width, &height, &hotspotX, &hotspotY, &keycolor, true, &palette, &palSize);
+ CursorMan.replaceCursor(cursorBitmap, width, height, hotspotX, hotspotY, keycolor);
+ CursorMan.replaceCursorPalette(palette, 0, palSize);
+ free(cursorBitmap);
+ free(palette);
+ }
kernelShow();
}
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index fe8922b852..00f50714af 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -365,8 +365,6 @@ Common::SeekableReadStream *ResourceManager::getVolumeFile(ResourceSource *sourc
return NULL;
}
-static uint32 resTypeToMacTag(ResourceType type);
-
void ResourceManager::loadResource(Resource *res) {
res->_source->loadResource(this, res);
}
@@ -382,8 +380,14 @@ void PatchResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
}
}
+static Common::Array<uint32> resTypeToMacTags(ResourceType type);
+
void MacResourceForkResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
- Common::SeekableReadStream *stream = _macResMan->getResource(resTypeToMacTag(res->getType()), res->getNumber());
+ Common::SeekableReadStream *stream = 0;
+ Common::Array<uint32> tagArray = resTypeToMacTags(res->getType());
+
+ for (uint32 i = 0; i < tagArray.size() && !stream; i++)
+ stream = _macResMan->getResource(tagArray[i], res->getNumber());
if (!stream)
error("Could not get Mac resource fork resource: %s %d", getResourceTypeName(res->getType()), res->getNumber());
@@ -1588,12 +1592,14 @@ struct {
{ MKID_BE('SYN '), kResourceTypeSync }
};
-static uint32 resTypeToMacTag(ResourceType type) {
+static Common::Array<uint32> resTypeToMacTags(ResourceType type) {
+ Common::Array<uint32> tags;
+
for (uint32 i = 0; i < ARRAYSIZE(macResTagMap); i++)
if (macResTagMap[i].type == type)
- return macResTagMap[i].tag;
+ tags.push_back(macResTagMap[i].tag);
- return 0;
+ return tags;
}
void MacResourceForkResourceSource::scanSource(ResourceManager *resMan) {