diff options
author | Matthew Hoops | 2011-03-05 13:36:55 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-03-05 13:36:55 -0500 |
commit | 6143fe965bb5332d8f32709ff1cce3624cd0e51d (patch) | |
tree | fc4819a5e941bcc84485d81d73813abca8a72c4d | |
parent | c66233f83e2d86b72f45aff20fb3198976850e42 (diff) | |
download | scummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.tar.gz scummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.tar.bz2 scummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.zip |
GRAPHICS: Add support for PE cursors in WinCursorGroup
Only 1bpp still
-rw-r--r-- | graphics/wincursor.cpp | 64 | ||||
-rw-r--r-- | graphics/wincursor.h | 2 |
2 files changed, 65 insertions, 1 deletions
diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 68b4023c0a..8690e1b18f 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -29,6 +29,7 @@ #include "common/str.h" #include "common/stream.h" #include "common/winexe_ne.h" +#include "common/winexe_pe.h" #include "graphics/wincursor.h" @@ -232,4 +233,67 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons return group; } +WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id) { + Common::SeekableReadStream *stream = exe.getResource(Common::kPEGroupCursor, id); + + if (!stream || stream->size() <= 6) + return 0; + + stream->skip(4); + uint32 cursorCount = stream->readUint16LE(); + if ((uint32)stream->size() < (6 + cursorCount * 16)) + return 0; + + WinCursorGroup *group = new WinCursorGroup(); + group->cursors.reserve(cursorCount); + + for (uint32 i = 0; i < cursorCount; i++) { + stream->readUint16LE(); // width + stream->readUint16LE(); // height + + // Plane count + if (stream->readUint16LE() != 1) { + delete stream; + delete group; + return 0; + } + + // Bit count + if (stream->readUint16LE() != 1) { + delete stream; + delete group; + return 0; + } + + stream->readUint32LE(); // data size + uint32 cursorId = stream->readUint32LE(); + + Common::SeekableReadStream *cursorStream = exe.getResource(Common::kPECursor, cursorId); + if (!cursorStream) { + delete stream; + delete group; + return 0; + } + + WinCursor *cursor = new WinCursor(); + if (!cursor->readFromStream(*cursorStream)) { + delete stream; + delete cursorStream; + delete cursor; + delete group; + return 0; + } + + delete cursorStream; + + CursorItem item; + item.id = cursorId; + item.cursor = cursor; + group->cursors.push_back(item); + } + + delete stream; + return group; +} + } // End of namespace Graphics diff --git a/graphics/wincursor.h b/graphics/wincursor.h index 3e2fc55bb8..b89bda9cd4 100644 --- a/graphics/wincursor.h +++ b/graphics/wincursor.h @@ -86,7 +86,7 @@ struct WinCursorGroup { Common::Array<CursorItem> cursors; static WinCursorGroup *createCursorGroup(Common::NEResources &exe, const Common::WinResourceID &id); - //static WinCursorGroup *createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id); + static WinCursorGroup *createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id); }; } // End of namespace Graphics |