aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/video/rpza.cpp
diff options
context:
space:
mode:
authorDavid Turner2010-01-04 08:10:29 +0000
committerDavid Turner2010-01-04 08:10:29 +0000
commitae9cf4d51e8c5f91e9009cab7cef54e23eb83a51 (patch)
treecc6aa33e5fa8421f947d6ba0776b578a7d303cc9 /engines/mohawk/video/rpza.cpp
parented06df7a25874f1ba98ed51fbc3669a4ef637501 (diff)
downloadscummvm-rg350-ae9cf4d51e8c5f91e9009cab7cef54e23eb83a51.tar.gz
scummvm-rg350-ae9cf4d51e8c5f91e9009cab7cef54e23eb83a51.tar.bz2
scummvm-rg350-ae9cf4d51e8c5f91e9009cab7cef54e23eb83a51.zip
Mohawk : Improved code formatting conventions compliance.
svn-id: r46965
Diffstat (limited to 'engines/mohawk/video/rpza.cpp')
-rw-r--r--engines/mohawk/video/rpza.cpp246
1 files changed, 123 insertions, 123 deletions
diff --git a/engines/mohawk/video/rpza.cpp b/engines/mohawk/video/rpza.cpp
index 937a6066fb..ae003fa491 100644
--- a/engines/mohawk/video/rpza.cpp
+++ b/engines/mohawk/video/rpza.cpp
@@ -47,14 +47,14 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
}
#define ADVANCE_BLOCK() \
- pixelPtr += 4; \
- if (pixelPtr >= _surface->w) { \
- pixelPtr = 0; \
- rowPtr += _surface->w * 4; \
- } \
- totalBlocks--; \
- if (totalBlocks < 0) \
- error("block counter just went negative (this should not happen)") \
+ pixelPtr += 4; \
+ if (pixelPtr >= _surface->w) { \
+ pixelPtr = 0; \
+ rowPtr += _surface->w * 4; \
+ } \
+ totalBlocks--; \
+ if (totalBlocks < 0) \
+ error("block counter just went negative (this should not happen)") \
// Convert from RGB555 to the format specified by the screen
#define PUT_PIXEL(color) \
@@ -69,139 +69,139 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Graphics::Codec() {
blockPtr++
Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
- uint16 colorA = 0, colorB = 0;
- uint16 color4[4];
+ uint16 colorA = 0, colorB = 0;
+ uint16 color4[4];
- uint32 rowPtr = 0;
- uint32 pixelPtr = 0;
- uint32 blockPtr = 0;
+ uint32 rowPtr = 0;
+ uint32 pixelPtr = 0;
+ uint32 blockPtr = 0;
uint32 rowInc = _surface->w - 4;
uint16 ta;
uint16 tb;
- // First byte is always 0xe1. Warn if it's different
+ // First byte is always 0xe1. Warn if it's different
byte firstByte = stream->readByte();
- if (firstByte != 0xe1)
- warning("First RPZA chunk byte is 0x%02x instead of 0xe1", firstByte);
+ if (firstByte != 0xe1)
+ warning("First RPZA chunk byte is 0x%02x instead of 0xe1", firstByte);
- // Get chunk size, ingnoring first byte
- uint32 chunkSize = stream->readUint16BE() << 8;
+ // Get chunk size, ingnoring first byte
+ uint32 chunkSize = stream->readUint16BE() << 8;
chunkSize += stream->readByte();
- // If length mismatch use size from MOV file and try to decode anyway
- if (chunkSize != (uint32)stream->size()) {
- warning("MOV chunk size != encoded chunk size; using MOV chunk size");
+ // If length mismatch use size from MOV file and try to decode anyway
+ if (chunkSize != (uint32)stream->size()) {
+ warning("MOV chunk size != encoded chunk size; using MOV chunk size");
chunkSize = stream->size();
}
- // Number of 4x4 blocks in frame
- int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
-
- // Process chunk data
- while ((uint32)stream->pos() < chunkSize) {
- byte opcode = stream->readByte(); // Get opcode
- byte numBlocks = (opcode & 0x1f) + 1; // Extract block counter from opcode
-
- // If opcode MSbit is 0, we need more data to decide what to do
- if ((opcode & 0x80) == 0) {
- colorA = (opcode << 8) | stream->readByte();
- opcode = 0;
- if (stream->readByte() & 0x80) {
- // Must behave as opcode 110xxxxx, using colorA computed
- // above. Use fake opcode 0x20 to enter switch block at
- // the right place
- opcode = 0x20;
- numBlocks = 1;
- }
+ // Number of 4x4 blocks in frame
+ int32 totalBlocks = ((_surface->w + 3) / 4) * ((_surface->h + 3) / 4);
+
+ // Process chunk data
+ while ((uint32)stream->pos() < chunkSize) {
+ byte opcode = stream->readByte(); // Get opcode
+ byte numBlocks = (opcode & 0x1f) + 1; // Extract block counter from opcode
+
+ // If opcode MSbit is 0, we need more data to decide what to do
+ if ((opcode & 0x80) == 0) {
+ colorA = (opcode << 8) | stream->readByte();
+ opcode = 0;
+ if (stream->readByte() & 0x80) {
+ // Must behave as opcode 110xxxxx, using colorA computed
+ // above. Use fake opcode 0x20 to enter switch block at
+ // the right place
+ opcode = 0x20;
+ numBlocks = 1;
+ }
stream->seek(-1, SEEK_CUR);
- }
-
- switch (opcode & 0xe0) {
- case 0x80: // Skip blocks
- while (numBlocks--) {
- ADVANCE_BLOCK();
- }
- break;
- case 0xa0: // Fill blocks with one color
- colorA = stream->readUint16BE();
- while (numBlocks--) {
- blockPtr = rowPtr + pixelPtr;
- for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (byte pixel_x = 0; pixel_x < 4; pixel_x++) {
+ }
+
+ switch (opcode & 0xe0) {
+ case 0x80: // Skip blocks
+ while (numBlocks--) {
+ ADVANCE_BLOCK();
+ }
+ break;
+ case 0xa0: // Fill blocks with one color
+ colorA = stream->readUint16BE();
+ while (numBlocks--) {
+ blockPtr = rowPtr + pixelPtr;
+ for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (byte pixel_x = 0; pixel_x < 4; pixel_x++) {
PUT_PIXEL(colorA);
- }
- blockPtr += rowInc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- // Fill blocks with 4 colors
- case 0xc0:
- colorA = stream->readUint16BE();
- case 0x20:
- colorB = stream->readUint16BE();
-
- // Sort out the colors
- color4[0] = colorB;
- color4[1] = 0;
- color4[2] = 0;
- color4[3] = colorA;
-
- // Red components
- ta = (colorA >> 10) & 0x1F;
- tb = (colorB >> 10) & 0x1F;
- color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
- color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
-
- // Green components
- ta = (colorA >> 5) & 0x1F;
- tb = (colorB >> 5) & 0x1F;
- color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
- color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
-
- // Blue components
- ta = colorA & 0x1F;
- tb = colorB & 0x1F;
- color4[1] |= ((11 * ta + 21 * tb) >> 5);
- color4[2] |= ((21 * ta + 11 * tb) >> 5);
-
- while (numBlocks--) {
- blockPtr = rowPtr + pixelPtr;
- for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
- byte index = stream->readByte();
- for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
- byte idx = (index >> (2 * (3 - pixel_x))) & 0x03;
+ }
+ blockPtr += rowInc;
+ }
+ ADVANCE_BLOCK();
+ }
+ break;
+
+ // Fill blocks with 4 colors
+ case 0xc0:
+ colorA = stream->readUint16BE();
+ case 0x20:
+ colorB = stream->readUint16BE();
+
+ // Sort out the colors
+ color4[0] = colorB;
+ color4[1] = 0;
+ color4[2] = 0;
+ color4[3] = colorA;
+
+ // Red components
+ ta = (colorA >> 10) & 0x1F;
+ tb = (colorB >> 10) & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
+ color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
+
+ // Green components
+ ta = (colorA >> 5) & 0x1F;
+ tb = (colorB >> 5) & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
+ color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
+
+ // Blue components
+ ta = colorA & 0x1F;
+ tb = colorB & 0x1F;
+ color4[1] |= ((11 * ta + 21 * tb) >> 5);
+ color4[2] |= ((21 * ta + 11 * tb) >> 5);
+
+ while (numBlocks--) {
+ blockPtr = rowPtr + pixelPtr;
+ for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
+ byte index = stream->readByte();
+ for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
+ byte idx = (index >> (2 * (3 - pixel_x))) & 0x03;
PUT_PIXEL(color4[idx]);
- }
- blockPtr += rowInc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- // Fill block with 16 colors
- case 0x00:
- blockPtr = rowPtr + pixelPtr;
- for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
- // We already have color of upper left pixel
- if (pixel_y != 0 || pixel_x != 0)
- colorA = stream->readUint16BE();
+ }
+ blockPtr += rowInc;
+ }
+ ADVANCE_BLOCK();
+ }
+ break;
+
+ // Fill block with 16 colors
+ case 0x00:
+ blockPtr = rowPtr + pixelPtr;
+ for (byte pixel_y = 0; pixel_y < 4; pixel_y++) {
+ for (byte pixel_x = 0; pixel_x < 4; pixel_x++){
+ // We already have color of upper left pixel
+ if (pixel_y != 0 || pixel_x != 0)
+ colorA = stream->readUint16BE();
PUT_PIXEL(colorA);
- }
- blockPtr += rowInc;
- }
- ADVANCE_BLOCK();
- break;
-
- // Unknown opcode
- default:
- error("Unknown opcode %02x in rpza chunk", opcode);
- }
+ }
+ blockPtr += rowInc;
+ }
+ ADVANCE_BLOCK();
+ break;
+
+ // Unknown opcode
+ default:
+ error("Unknown opcode %02x in rpza chunk", opcode);
+ }
}
-
+
return _surface;
}