aboutsummaryrefslogtreecommitdiff
path: root/graphics/wincursor.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-03-05 13:36:55 -0500
committerMatthew Hoops2011-03-05 13:36:55 -0500
commit6143fe965bb5332d8f32709ff1cce3624cd0e51d (patch)
treefc4819a5e941bcc84485d81d73813abca8a72c4d /graphics/wincursor.cpp
parentc66233f83e2d86b72f45aff20fb3198976850e42 (diff)
downloadscummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.tar.gz
scummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.tar.bz2
scummvm-rg350-6143fe965bb5332d8f32709ff1cce3624cd0e51d.zip
GRAPHICS: Add support for PE cursors in WinCursorGroup
Only 1bpp still
Diffstat (limited to 'graphics/wincursor.cpp')
-rw-r--r--graphics/wincursor.cpp64
1 files changed, 64 insertions, 0 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