aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-05-05 19:35:31 -0400
committerMatthew Hoops2011-05-05 19:35:31 -0400
commit1f39e0b6c676be72a4171964be770faf0411f9ba (patch)
treed360b7b414f65239652c859926a95de4cb8ac5fb
parent0f0ae4576e40ae7a2a7c6f23f12c2d56b52a9b75 (diff)
downloadscummvm-rg350-1f39e0b6c676be72a4171964be770faf0411f9ba.tar.gz
scummvm-rg350-1f39e0b6c676be72a4171964be770faf0411f9ba.tar.bz2
scummvm-rg350-1f39e0b6c676be72a4171964be770faf0411f9ba.zip
MOHAWK: Use new MacCursor code instead of convertCrsrCursor()
-rw-r--r--engines/mohawk/cursors.cpp69
-rw-r--r--engines/mohawk/cursors.h4
2 files changed, 25 insertions, 48 deletions
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 66669e35c9..3327860913 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -29,9 +29,11 @@
#include "common/macresman.h"
#include "common/system.h"
+#include "common/textconsole.h"
#include "common/winexe_ne.h"
#include "common/winexe_pe.h"
#include "graphics/cursorman.h"
+#include "graphics/maccursor.h"
#include "graphics/wincursor.h"
#ifdef ENABLE_MYST
@@ -41,11 +43,6 @@
namespace Mohawk {
-static const byte s_bwPalette[] = {
- 0x00, 0x00, 0x00, // Black
- 0xFF, 0xFF, 0xFF // White
-};
-
void CursorManager::showCursor() {
CursorMan.showMouse(true);
}
@@ -78,8 +75,13 @@ void CursorManager::setDefaultCursor() {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0
};
+ static const byte bwPalette[] = {
+ 0x00, 0x00, 0x00, // Black
+ 0xFF, 0xFF, 0xFF // White
+ };
+
CursorMan.replaceCursor(defaultCursor, 12, 20, 0, 0, 0);
- CursorMan.replaceCursorPalette(s_bwPalette, 1, 2);
+ CursorMan.replaceCursorPalette(bwPalette, 1, 2);
}
void CursorManager::setCursor(uint16 id) {
@@ -87,35 +89,24 @@ void CursorManager::setCursor(uint16 id) {
setDefaultCursor();
}
-void CursorManager::setMacXorCursor(Common::SeekableReadStream *stream) {
+void CursorManager::setMacCursor(Common::SeekableReadStream *stream) {
assert(stream);
- byte cursorBitmap[16 * 16];
+ Graphics::MacCursor *macCursor = new Graphics::MacCursor();
- // Get black and white data
- for (int i = 0; i < 32; i++) {
- byte imageByte = stream->readByte();
- for (int b = 0; b < 8; b++)
- cursorBitmap[i * 8 + b] = (imageByte & (0x80 >> b)) ? 1 : 2;
- }
+ if (!macCursor->readFromStream(*stream))
+ error("Could not parse Mac cursor");
- // Apply mask data
- for (int i = 0; i < 32; i++) {
- byte imageByte = stream->readByte();
- for (int b = 0; b < 8; b++)
- if ((imageByte & (0x80 >> b)) == 0)
- cursorBitmap[i * 8 + b] = 0;
- }
-
- uint16 hotspotY = stream->readUint16BE();
- uint16 hotspotX = stream->readUint16BE();
+ CursorMan.replaceCursor(macCursor->getSurface(), macCursor->getWidth(), macCursor->getHeight(),
+ macCursor->getHotspotX(), macCursor->getHotspotY(), macCursor->getKeyColor());
+ CursorMan.replaceCursorPalette(macCursor->getPalette(), 0, 256);
- CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0);
- CursorMan.replaceCursorPalette(s_bwPalette, 1, 2);
+ delete macCursor;
+ delete stream;
}
void DefaultCursorManager::setCursor(uint16 id) {
- setMacXorCursor(_vm->getResource(_tag, id));
+ setMacCursor(_vm->getResource(_tag, id));
}
#ifdef ENABLE_MYST
@@ -223,26 +214,12 @@ void MacCursorManager::setCursor(uint16 id) {
// Try a color cursor first
Common::SeekableReadStream *stream = _resFork->getResource(MKTAG('c','r','s','r'), id);
- if (stream) {
- byte *cursor, *palette;
- int width, height, hotspotX, hotspotY, keyColor, palSize;
-
- _resFork->convertCrsrCursor(stream, &cursor, width, height, hotspotX, hotspotY, keyColor, true, &palette, palSize);
-
- CursorMan.replaceCursor(cursor, width, height, hotspotX, hotspotY, keyColor);
- CursorMan.replaceCursorPalette(palette, 0, palSize);
-
- delete[] cursor;
- delete[] palette;
- delete stream;
- return;
- }
-
- // Fall back to b&w cursors
- stream = _resFork->getResource(MKTAG('C','U','R','S'), id);
+ // Fall back to monochrome cursors
+ if (!stream)
+ stream = _resFork->getResource(MKTAG('C','U','R','S'), id);
if (stream) {
- setMacXorCursor(stream);
+ setMacCursor(stream);
delete stream;
} else {
setDefaultCursor();
@@ -265,7 +242,7 @@ LivingBooksCursorManager_v2::~LivingBooksCursorManager_v2() {
void LivingBooksCursorManager_v2::setCursor(uint16 id) {
if (_sysArchive && _sysArchive->hasResource(ID_TCUR, id)) {
- setMacXorCursor(_sysArchive->getResource(ID_TCUR, id));
+ setMacCursor(_sysArchive->getResource(ID_TCUR, id));
} else {
// TODO: Handle generated cursors
}
diff --git a/engines/mohawk/cursors.h b/engines/mohawk/cursors.h
index 1fb8b35714..ba9700c9f9 100644
--- a/engines/mohawk/cursors.h
+++ b/engines/mohawk/cursors.h
@@ -63,8 +63,8 @@ public:
virtual bool hasSource() const { return false; }
protected:
- // Set a Mac XOR/AND map cursor to the screen
- void setMacXorCursor(Common::SeekableReadStream *stream);
+ // Set a Mac CURS/crsr cursor to the screen
+ void setMacCursor(Common::SeekableReadStream *stream);
};
// The default Mohawk cursor manager