diff options
author | Matthew Hoops | 2011-05-05 19:46:33 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-05 19:46:33 -0400 |
commit | 04dd4cabdf9ff9749023bde18f4871302f8f6b05 (patch) | |
tree | ed44c759acf952d2a4bf45237b091e6adeb04fa6 /engines/scumm | |
parent | 1f39e0b6c676be72a4171964be770faf0411f9ba (diff) | |
download | scummvm-rg350-04dd4cabdf9ff9749023bde18f4871302f8f6b05.tar.gz scummvm-rg350-04dd4cabdf9ff9749023bde18f4871302f8f6b05.tar.bz2 scummvm-rg350-04dd4cabdf9ff9749023bde18f4871302f8f6b05.zip |
SCUMM: Use new MacCursor code instead of convertCrsrCursor()
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/he/resource_he.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index ecb094f29b..552c420755 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -32,6 +32,7 @@ #include "audio/decoders/wave.h" #include "graphics/cursorman.h" +#include "graphics/maccursor.h" #include "graphics/wincursor.h" #include "common/archive.h" @@ -172,11 +173,49 @@ bool MacResExtractor::extractResource(int id, CachedCursor *cc) { if (!dataStream) return false; - int keyColor; // HACK: key color is ignored - _resMgr->convertCrsrCursor(dataStream, &cc->bitmap, cc->width, cc->height, cc->hotspotX, cc->hotspotY, - keyColor, _vm->_system->hasFeature(OSystem::kFeatureCursorHasPalette), - &cc->palette, cc->palSize); + // If we don't have a cursor palette, force monochrome cursors + bool forceMonochrome = !_vm->_system->hasFeature(OSystem::kFeatureCursorHasPalette); + Graphics::MacCursor *macCursor = new Graphics::MacCursor(); + + if (!macCursor->readFromStream(*dataStream, forceMonochrome)) { + delete dataStream; + delete macCursor; + return false; + } + + cc->bitmap = new byte[macCursor->getWidth() * macCursor->getHeight()]; + cc->width = macCursor->getWidth(); + cc->height = macCursor->getHeight(); + cc->hotspotX = macCursor->getHotspotX(); + cc->hotspotY = macCursor->getHotspotY(); + + if (forceMonochrome) { + // Convert to the SCUMM palette + const byte *srcBitmap = macCursor->getSurface(); + + for (int i = 0; i < macCursor->getWidth() * macCursor->getHeight(); i++) { + if (srcBitmap[i] == macCursor->getKeyColor()) // Transparent + cc->bitmap[i] = 255; + else if (srcBitmap[i] == 0) // Black + cc->bitmap[i] = 253; + else // White + cc->bitmap[i] = 254; + } + } else { + // Copy data and palette + + // Sanity check. This code assumes that the key color is the same + assert(macCursor->getKeyColor() == 255); + + memcpy(cc->bitmap, macCursor->getSurface(), macCursor->getWidth() * macCursor->getHeight()); + + cc->palette = new byte[256 * 3]; + cc->palSize = 256; + memcpy(cc->palette, macCursor->getPalette(), 256 * 3); + } + + delete macCursor; delete dataStream; return true; } |