diff options
author | Matthew Hoops | 2011-10-28 13:26:43 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-10-28 13:26:43 -0400 |
commit | 6550d851843d794f0b50185e1fdbb4f1108734a3 (patch) | |
tree | 6ac799e0ee8c04b000212881da1480fd9a0ceebc /engines/pegasus | |
parent | 020f3842478b6eaa67e2b8efbc16502db3fe4599 (diff) | |
download | scummvm-rg350-6550d851843d794f0b50185e1fdbb4f1108734a3.tar.gz scummvm-rg350-6550d851843d794f0b50185e1fdbb4f1108734a3.tar.bz2 scummvm-rg350-6550d851843d794f0b50185e1fdbb4f1108734a3.zip |
PEGASUS: Fix 1bpp cicn cursors
Diffstat (limited to 'engines/pegasus')
-rwxr-xr-x | engines/pegasus/cursor.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp index ee3ab87268..430b319e33 100755 --- a/engines/pegasus/cursor.cpp +++ b/engines/pegasus/cursor.cpp @@ -169,7 +169,7 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) { cicnStream->readUint16BE(); // always 0 cursorInfo.colorCount = cicnStream->readUint16BE() + 1; - cursorInfo.palette = new byte[256 * cursorInfo.colorCount]; + cursorInfo.palette = new byte[cursorInfo.colorCount * 3]; for (uint16 i = 0; i < cursorInfo.colorCount; i++) { cicnStream->readUint16BE(); cursorInfo.palette[i * 3] = cicnStream->readUint16BE() >> 8; @@ -178,8 +178,34 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) { } // PixMap data - cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8()); - cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height()); + if (pixMap.pixelSize == 8) { + cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8()); + cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height()); + + // While this looks sensible, it actually doesn't work for some cursors + // (ie. the 'can grab' hand) + //cursorInfo.surface->w = pixMap.bounds.width(); + } else if (pixMap.pixelSize == 1) { + cursorInfo.surface->create(pixMap.bounds.width(), pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8()); + + for (int y = 0; y < pixMap.bounds.height(); y++) { + byte *line = (byte *)cursorInfo.surface->getBasePtr(0, y); + + for (int x = 0; x < pixMap.bounds.width();) { + byte b = cicnStream->readByte(); + + for (int i = 0; i < 8; i++) { + *line++ = ((b & (1 << (7 - i))) != 0) ? 1 : 0; + + if (++x == pixMap.bounds.width()) + break; + } + } + } + } else { + error("Unhandled %dbpp cicn images", pixMap.pixelSize); + } + delete cicnStream; } |