diff options
author | Matthew Hoops | 2011-03-07 01:07:53 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-03-07 01:10:01 -0500 |
commit | ad7400524b8e024577169f7dd4cb4d586ee37fa0 (patch) | |
tree | 505324966b7675a277b5d14cb37b138f61e5829c /engines/mohawk/cursors.cpp | |
parent | d49f3a8a781b28ba46e22e8f8a2c486a146b7e8c (diff) | |
download | scummvm-rg350-ad7400524b8e024577169f7dd4cb4d586ee37fa0.tar.gz scummvm-rg350-ad7400524b8e024577169f7dd4cb4d586ee37fa0.tar.bz2 scummvm-rg350-ad7400524b8e024577169f7dd4cb4d586ee37fa0.zip |
MOHAWK: Make Riven use original executables for cursors
It will try both Windows and Macintosh executables. The hardcoded cursors have been removed.
Diffstat (limited to 'engines/mohawk/cursors.cpp')
-rw-r--r-- | engines/mohawk/cursors.cpp | 201 |
1 files changed, 60 insertions, 141 deletions
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index fe4b434f9c..fdf19b624a 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -28,11 +28,11 @@ #include "mohawk/resource.h" #include "mohawk/graphics.h" #include "mohawk/myst.h" -#include "mohawk/riven_cursors.h" #include "common/macresman.h" #include "common/system.h" #include "common/winexe_ne.h" +#include "common/winexe_pe.h" #include "graphics/cursorman.h" #include "graphics/wincursor.h" @@ -84,15 +84,16 @@ void CursorManager::setCursor(uint16 id) { setDefaultCursor(); } -void CursorManager::decodeMacXorCursor(Common::SeekableReadStream *stream, byte *cursor) { +void CursorManager::setMacXorCursor(Common::SeekableReadStream *stream) { assert(stream); - assert(cursor); + + byte cursorBitmap[16 * 16]; // Get black and white data for (int i = 0; i < 32; i++) { byte imageByte = stream->readByte(); for (int b = 0; b < 8; b++) - cursor[i * 8 + b] = (imageByte & (0x80 >> b)) ? 1 : 2; + cursorBitmap[i * 8 + b] = (imageByte & (0x80 >> b)) ? 1 : 2; } // Apply mask data @@ -100,28 +101,18 @@ void CursorManager::decodeMacXorCursor(Common::SeekableReadStream *stream, byte byte imageByte = stream->readByte(); for (int b = 0; b < 8; b++) if ((imageByte & (0x80 >> b)) == 0) - cursor[i * 8 + b] = 0; + cursorBitmap[i * 8 + b] = 0; } -} -void CursorManager::setStandardCursor(Common::SeekableReadStream *stream) { - // The Broderbund devs decided to rip off the Mac format, it seems. - // However, they reversed the x/y hotspot. That makes it totally different!!!! - assert(stream); - - byte cursorBitmap[16 * 16]; - decodeMacXorCursor(stream, cursorBitmap); uint16 hotspotY = stream->readUint16BE(); uint16 hotspotX = stream->readUint16BE(); CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0); CursorMan.replaceCursorPalette(s_bwPalette, 1, 2); - - delete stream; } void DefaultCursorManager::setCursor(uint16 id) { - setStandardCursor(_vm->getResource(_tag, id)); + setMacXorCursor(_vm->getResource(_tag, id)); } MystCursorManager::MystCursorManager(MohawkEngine_Myst *vm) : _vm(vm) { @@ -168,119 +159,6 @@ void MystCursorManager::setDefaultCursor() { setCursor(kDefaultMystCursor); } -void RivenCursorManager::setCursor(uint16 id) { - // All of Riven's cursors are hardcoded. See riven_cursors.h for these definitions. - - switch (id) { - case 1002: - // Zip Mode - CursorMan.replaceCursor(s_zipModeCursor, 16, 16, 8, 8, 0); - CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 3); - break; - case 2003: - // Hand Over Object - CursorMan.replaceCursor(s_objectHandCursor, 16, 16, 8, 8, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 2004: - // Grabbing/Using Object - CursorMan.replaceCursor(s_grabbingHandCursor, 13, 13, 6, 6, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3000: - // Standard Hand - CursorMan.replaceCursor(s_standardHandCursor, 15, 16, 6, 0, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3001: - // Pointing Left - CursorMan.replaceCursor(s_pointingLeftCursor, 15, 13, 0, 3, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3002: - // Pointing Right - CursorMan.replaceCursor(s_pointingRightCursor, 15, 13, 14, 3, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3003: - // Pointing Down (Palm Up) - CursorMan.replaceCursor(s_pointingDownCursorPalmUp, 13, 16, 3, 15, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3004: - // Pointing Up (Palm Up) - CursorMan.replaceCursor(s_pointingUpCursorPalmUp, 13, 16, 3, 0, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3005: - // Pointing Left (Curved) - CursorMan.replaceCursor(s_pointingLeftCursorBent, 15, 13, 0, 5, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3006: - // Pointing Right (Curved) - CursorMan.replaceCursor(s_pointingRightCursorBent, 15, 13, 14, 5, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 3007: - // Pointing Down (Palm Down) - CursorMan.replaceCursor(s_pointingDownCursorPalmDown, 15, 16, 7, 15, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); - break; - case 4001: - // Red Marble - CursorMan.replaceCursor(s_redMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 3); - break; - case 4002: - // Orange Marble - CursorMan.replaceCursor(s_orangeMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 3); - break; - case 4003: - // Yellow Marble - CursorMan.replaceCursor(s_yellowMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 3); - break; - case 4004: - // Green Marble - CursorMan.replaceCursor(s_greenMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 3); - break; - case 4005: - // Blue Marble - CursorMan.replaceCursor(s_blueMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 3); - break; - case 4006: - // Violet Marble - CursorMan.replaceCursor(s_violetMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 3); - break; - case 5000: - // Pellet - CursorMan.replaceCursor(s_pelletCursor, 8, 8, 4, 4, 0); - CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 3); - break; - case 9000: - // Hide Cursor - CursorMan.showMouse(false); - break; - default: - error("Cursor %d does not exist!", id); - } - - if (id != 9000) // Show Cursor - CursorMan.showMouse(true); - - // Should help in cases where we need to hide the cursor immediately. - g_system->updateScreen(); -} - -void RivenCursorManager::setDefaultCursor() { - setCursor(kRivenMainCursor); -} - NECursorManager::NECursorManager(const Common::String &appName) { _exe = new Common::NEResources(); @@ -333,22 +211,33 @@ void MacCursorManager::setCursor(uint16 id) { return; } - Common::SeekableReadStream *stream = _resFork->getResource(MKID_BE('CURS'), id); + // Try a color cursor first + Common::SeekableReadStream *stream = _resFork->getResource(MKID_BE('crsr'), id); - if (!stream) { - setDefaultCursor(); + 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; } - byte cursorBitmap[16 * 16]; - decodeMacXorCursor(stream, cursorBitmap); - uint16 hotspotX = stream->readUint16BE(); - uint16 hotspotY = stream->readUint16BE(); + // Fall back to b&w cursors + stream = _resFork->getResource(MKID_BE('CURS'), id); - CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0); - CursorMan.replaceCursorPalette(s_bwPalette, 1, 2); - - delete stream; + if (stream) { + setMacXorCursor(stream); + delete stream; + } else { + setDefaultCursor(); + } } LivingBooksCursorManager_v2::LivingBooksCursorManager_v2() { @@ -367,10 +256,40 @@ LivingBooksCursorManager_v2::~LivingBooksCursorManager_v2() { void LivingBooksCursorManager_v2::setCursor(uint16 id) { if (_sysArchive && _sysArchive->hasResource(ID_TCUR, id)) { - setStandardCursor(_sysArchive->getResource(ID_TCUR, id)); + setMacXorCursor(_sysArchive->getResource(ID_TCUR, id)); } else { // TODO: Handle generated cursors } } +PECursorManager::PECursorManager(const Common::String &appName) { + _exe = new Common::PEResources(); + + if (!_exe->loadFromEXE(appName)) { + // Not all have cursors anyway, so this is not a problem + delete _exe; + _exe = 0; + } +} + +PECursorManager::~PECursorManager() { + delete _exe; +} + +void PECursorManager::setCursor(uint16 id) { + if (_exe) { + Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, id); + + if (cursorGroup) { + Graphics::WinCursor *cursor = cursorGroup->cursors[0].cursor; + CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor()); + CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256); + return; + } + } + + // Last resort (not all have cursors) + setDefaultCursor(); +} + } // End of namespace Mohawk |