aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMatthew Hoops2011-03-06 19:57:18 -0500
committerMatthew Hoops2011-03-06 19:57:18 -0500
commit6582b77f1c3c6f373d2aa3a55f30c254f5f0e244 (patch)
tree0809e5e8b39ea54893d22d5450511a002c3589f1 /common
parent5b907e828b519c71d1a042483ab0214f758a8ffd (diff)
downloadscummvm-rg350-6582b77f1c3c6f373d2aa3a55f30c254f5f0e244.tar.gz
scummvm-rg350-6582b77f1c3c6f373d2aa3a55f30c254f5f0e244.tar.bz2
scummvm-rg350-6582b77f1c3c6f373d2aa3a55f30c254f5f0e244.zip
SCUMM: Use the new WinCursor code in SCUMM HE
Also, updated the MacResManager cursor code to reflect the SCUMM resource extractor code changes
Diffstat (limited to 'common')
-rw-r--r--common/macresman.cpp138
-rw-r--r--common/macresman.h11
2 files changed, 70 insertions, 79 deletions
diff --git a/common/macresman.cpp b/common/macresman.cpp
index 4fd4e72ee3..e7d4a30789 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -550,118 +550,110 @@ void MacResManager::readMap() {
}
}
-void MacResManager::convertCrsrCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
- int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize) {
- MemoryReadStream dis(data, datasize);
- int i, b;
- byte imageByte;
- byte *iconData;
- int pixelsPerByte, bpp;
- int ctSize;
- byte bitmask;
- int iconRowBytes, iconBounds[4];
- int iconDataSize;
-
- dis.readUint16BE(); // type
- dis.readUint32BE(); // offset to pixel map
- dis.readUint32BE(); // offset to pixel data
- dis.readUint32BE(); // expanded cursor data
- dis.readUint16BE(); // expanded data depth
- dis.readUint32BE(); // reserved
+void MacResManager::convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX,
+ int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize) {
+
+ data->readUint16BE(); // type
+ data->readUint32BE(); // offset to pixel map
+ data->readUint32BE(); // offset to pixel data
+ data->readUint32BE(); // expanded cursor data
+ data->readUint16BE(); // expanded data depth
+ data->readUint32BE(); // reserved
// Grab B/W icon data
- *cursor = (byte *)malloc(16 * 16);
- for (i = 0; i < 32; i++) {
- imageByte = dis.readByte();
- for (b = 0; b < 8; b++)
- cursor[0][i*8+b] = (byte)((imageByte & (0x80 >> b)) > 0? 0x0F: 0x00);
+ *cursor = new byte[16 * 16];
+ for (int i = 0; i < 32; i++) {
+ byte imageByte = data->readByte();
+ for (int b = 0; b < 8; b++)
+ cursor[0][i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x0F : 0x00);
}
// Apply mask data
- for (i = 0; i < 32; i++) {
- imageByte = dis.readByte();
- for (b = 0; b < 8; b++)
+ for (int i = 0; i < 32; i++) {
+ byte imageByte = data->readByte();
+ for (int b = 0; b < 8; b++)
if ((imageByte & (0x80 >> b)) == 0)
- cursor[0][i*8+b] = 0xff;
+ cursor[0][i * 8 + b] = 0xff;
}
- *hotspot_y = dis.readUint16BE();
- *hotspot_x = dis.readUint16BE();
- *w = *h = 16;
- *keycolor = 0xff;
+ hotspotY = data->readUint16BE();
+ hotspotX = data->readUint16BE();
+ w = h = 16;
+ keycolor = 0xff;
// Use b/w cursor on backends which don't support cursor palettes
if (!colored)
return;
- dis.readUint32BE(); // reserved
- dis.readUint32BE(); // cursorID
+ data->readUint32BE(); // reserved
+ data->readUint32BE(); // cursorID
// Color version of cursor
- dis.readUint32BE(); // baseAddr
+ data->readUint32BE(); // baseAddr
// Keep only lowbyte for now
- dis.readByte();
- iconRowBytes = dis.readByte();
+ data->readByte();
+ int iconRowBytes = data->readByte();
if (!iconRowBytes)
return;
- iconBounds[0] = dis.readUint16BE();
- iconBounds[1] = dis.readUint16BE();
- iconBounds[2] = dis.readUint16BE();
- iconBounds[3] = dis.readUint16BE();
+ int iconBounds[4];
+ iconBounds[0] = data->readUint16BE();
+ iconBounds[1] = data->readUint16BE();
+ iconBounds[2] = data->readUint16BE();
+ iconBounds[3] = data->readUint16BE();
- dis.readUint16BE(); // pmVersion
- dis.readUint16BE(); // packType
- dis.readUint32BE(); // packSize
+ data->readUint16BE(); // pmVersion
+ data->readUint16BE(); // packType
+ data->readUint32BE(); // packSize
- dis.readUint32BE(); // hRes
- dis.readUint32BE(); // vRes
+ data->readUint32BE(); // hRes
+ data->readUint32BE(); // vRes
- dis.readUint16BE(); // pixelType
- dis.readUint16BE(); // pixelSize
- dis.readUint16BE(); // cmpCount
- dis.readUint16BE(); // cmpSize
+ data->readUint16BE(); // pixelType
+ data->readUint16BE(); // pixelSize
+ data->readUint16BE(); // cmpCount
+ data->readUint16BE(); // cmpSize
- dis.readUint32BE(); // planeByte
- dis.readUint32BE(); // pmTable
- dis.readUint32BE(); // reserved
+ data->readUint32BE(); // planeByte
+ data->readUint32BE(); // pmTable
+ data->readUint32BE(); // reserved
// Pixel data for cursor
- iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]);
- iconData = (byte *)malloc(iconDataSize);
- dis.read(iconData, iconDataSize);
+ int iconDataSize = iconRowBytes * (iconBounds[3] - iconBounds[1]);
+ byte *iconData = new byte[iconDataSize];
+ data->read(iconData, iconDataSize);
// Color table
- dis.readUint32BE(); // ctSeed
- dis.readUint16BE(); // ctFlag
- ctSize = dis.readUint16BE() + 1;
+ data->readUint32BE(); // ctSeed
+ data->readUint16BE(); // ctFlag
+ uint16 ctSize = data->readUint16BE() + 1;
- *palette = (byte *)malloc(ctSize * 3);
+ *palette = new byte[ctSize * 3];
// Read just high byte of 16-bit color
for (int c = 0; c < ctSize; c++) {
// We just use indices 0..ctSize, so ignore color ID
- dis.readUint16BE(); // colorID[c]
+ data->readUint16BE(); // colorID[c]
- palette[0][c * 3 + 0] = dis.readByte();
- dis.readByte();
+ palette[0][c * 3 + 0] = data->readByte();
+ data->readByte();
- palette[0][c * 3 + 1] = dis.readByte();
- dis.readByte();
+ palette[0][c * 3 + 1] = data->readByte();
+ data->readByte();
- palette[0][c * 3 + 2] = dis.readByte();
- dis.readByte();
+ palette[0][c * 3 + 2] = data->readByte();
+ data->readByte();
}
- *palSize = ctSize;
+ palSize = ctSize;
- pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
- bpp = 8 / pixelsPerByte;
+ int pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
+ int bpp = 8 / pixelsPerByte;
// build a mask to make sure the pixels are properly shifted out
- bitmask = 0;
+ int bitmask = 0;
for (int m = 0; m < bpp; m++) {
bitmask <<= 1;
bitmask |= 1;
@@ -669,16 +661,16 @@ void MacResManager::convertCrsrCursor(byte *data, int datasize, byte **cursor, i
// Extract pixels from bytes
for (int j = 0; j < iconDataSize; j++)
- for (b = 0; b < pixelsPerByte; b++) {
+ for (int b = 0; b < pixelsPerByte; b++) {
int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b);
if (cursor[0][idx] != 0xff) // if mask is not there
cursor[0][idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask);
}
- free(iconData);
+ delete[] iconData;
- assert(datasize - dis.pos() == 0);
+ assert(data->size() - data->pos() == 0);
}
} // End of namespace Common
diff --git a/common/macresman.h b/common/macresman.h
index 1cbebbcf4b..2ad0b608a1 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -154,14 +154,13 @@ public:
/**
* Convert cursor from crsr format to format suitable for feeding to CursorMan
- * @param data Pointer to the cursor data
- * @param datasize Size of the cursor data
+ * @param data Pointer to the cursor datax
* @param cursor Pointer to memory where result cursor will be stored. The memory
* block will be malloc()'ed
* @param w Pointer to int where the cursor width will be stored
* @param h Pointer to int where the cursor height will be stored
- * @param hotspot_x Storage for cursor hotspot X coordinate
- * @param hotspot_Y Storage for cursor hotspot Y coordinate
+ * @param hotspotX Storage for cursor hotspot X coordinate
+ * @param hotspotY Storage for cursor hotspot Y coordinate
* @param keycolor Pointer to int where the transpared color value will be stored
* @param colored If set to true then colored cursor will be returned (if any).
* b/w version will be used otherwise
@@ -169,8 +168,8 @@ public:
* The memory will be malloc()'ed
* @param palSize Pointer to integer where the palette size will be stored.
*/
- static void convertCrsrCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
- int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);
+ static void convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX,
+ int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize);
/**
* Return list of resource IDs with specified type ID