aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2005-07-29 16:50:09 +0000
committerAndrew Kurushin2005-07-29 16:50:09 +0000
commit922c5e29a04ec80b4f34a11e755568a8677264a0 (patch)
tree330a520a89ffd5c70098675b60d812ee408ee5fe
parent1a1db4611a7e262fe5f48e19fd4d40858619efaf (diff)
downloadscummvm-rg350-922c5e29a04ec80b4f34a11e755568a8677264a0.tar.gz
scummvm-rg350-922c5e29a04ec80b4f34a11e755568a8677264a0.tar.bz2
scummvm-rg350-922c5e29a04ec80b4f34a11e755568a8677264a0.zip
fix chunk size
svn-id: r18590
-rw-r--r--graphics/ilbm.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/graphics/ilbm.cpp b/graphics/ilbm.cpp
index 87997ebd0c..e4cdaaa79c 100644
--- a/graphics/ilbm.cpp
+++ b/graphics/ilbm.cpp
@@ -20,7 +20,6 @@
#include "common/stdafx.h"
#include "common/stream.h"
-#include "common/file.h"
#include "graphics/surface.h"
namespace Graphics {
@@ -47,9 +46,6 @@ struct Chunk {
void readHeader() {
id = _input->readUint32BE();
size = _input->readUint32BE();
- if (size % 2) {
- size++;
- }
bytesRead = 0;
}
@@ -58,7 +54,10 @@ struct Chunk {
}
void feed() {
- while(!eos()) {
+ if (size % 2) {
+ size++;
+ }
+ while(!_input->eos() && !eos()) {
readByte();
}
}
@@ -224,7 +223,7 @@ void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors) {
Chunk formChunk(&input);
Chunk chunk(&input);
uint32 colorCount = 0, i, j, si;
- int8 byteRun;
+ byte byteRun;
byte idx;
colors = NULL;
si = 0;
@@ -242,7 +241,6 @@ void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors) {
while (!formChunk.eos()) {
formChunk.incBytesRead(8);
chunk.readHeader();
- formChunk.incBytesRead(chunk.size);
switch(chunk.id) {
case ID_BMHD:
@@ -289,33 +287,22 @@ void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors) {
while (!chunk.eos()) {
idx = chunk.readByte();
((byte*)surface.pixels)[si++] = idx;
- /*colorMap[idx];
- colorMap[idx];
- colorMap[idx];*/
}
break;
case 1:
while (!chunk.eos()) {
- byteRun = chunk.readSByte();
- if (byteRun >= 0) {
+ byteRun = chunk.readByte();
+ if (byteRun <= 127) {
i = byteRun + 1;
for (j = 0; j < i; j++){
idx = chunk.readByte();
((byte*)surface.pixels)[si++] = idx;
- /*colorMap[idx];
- colorMap[idx];
- colorMap[idx];*/
}
- } else if (byteRun == -128) {
- // nop
- } else {
- i = (-byteRun) + 1;
+ } else if (byteRun != 128) {
+ i = (256 - byteRun) + 1;
idx = chunk.readByte();
for (j = 0; j < i; j++) {
((byte*)surface.pixels)[si++] = idx;
- /*colorMap[idx];
- colorMap[idx];
- colorMap[idx];*/
}
}
}
@@ -329,6 +316,7 @@ void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors) {
}
chunk.feed();
+ formChunk.incBytesRead(chunk.size);
}
}