Added code to unpack and render animations in BRA.

svn-id: r30755
This commit is contained in:
Nicola Mettifogo 2008-02-03 10:48:07 +00:00
parent e51bf80218
commit 748a90ca23
5 changed files with 87 additions and 3 deletions

View File

@ -73,7 +73,16 @@ struct Sprites : public Frames {
r.setWidth(_sprites[index].w);
r.setHeight(_sprites[index].h);
r.moveTo(_sprites[index].x, _sprites[index].y);
}
}
uint getRawSize(uint16 index) {
assert(index < _num);
return _sprites[index].size;
}
uint getSize(uint16 index) {
assert(index < _num);
return _sprites[index].w * _sprites[index].h;
}
};

View File

@ -28,6 +28,7 @@
#include "disk.h"
#include "common/algorithm.h"
#include "parallaction/parallaction.h"
namespace Parallaction {
@ -68,6 +69,13 @@ byte *GfxObj::getData(uint f) {
return _frames->getData(f);
}
uint GfxObj::getRawSize(uint f) {
return _frames->getRawSize(f);
}
uint GfxObj::getSize(uint f) {
return _frames->getSize(f);
}
void GfxObj::setFlags(uint32 flags) {
_flags |= flags;
@ -157,7 +165,11 @@ void Gfx::drawGfxObjects(Graphics::Surface &surf) {
obj->getRect(obj->frame, rect);
rect.moveTo(obj->x, obj->y);
data = obj->getData(obj->frame);
blt(rect, data, &surf, obj->layer, 0);
if (obj->getSize(obj->frame) == obj->getRawSize(obj->frame)) {
blt(rect, data, &surf, obj->layer, 0);
} else {
unpackBlt(rect, data, obj->getRawSize(obj->frame), &surf, obj->layer, 0);
}
}
}
}

View File

@ -422,6 +422,30 @@ void Gfx::invertBackground(const Common::Rect& r) {
}
byte _unpackedBitmap[320*200];
void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) {
byte *d = _unpackedBitmap;
while (size > 0) {
uint8 p = *data++;
size--;
uint8 color = p & 0xF;
uint8 repeat = (p & 0xF0) >> 4;
if (repeat == 0) {
repeat = *data++;
size--;
}
memset(d, color, repeat);
d += repeat;
}
blt(r, _unpackedBitmap, surf, z, transparentColor);
}
void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) {
Common::Point dp;

View File

@ -78,6 +78,8 @@ struct Frames {
virtual uint16 getNum() = 0;
virtual byte* getData(uint16 index) = 0;
virtual void getRect(uint16 index, Common::Rect &r) = 0;
virtual uint getRawSize(uint16 index) = 0;
virtual uint getSize(uint16 index) = 0;
virtual ~Frames() { }
@ -110,6 +112,15 @@ public:
r.setWidth(_surf->w);
r.setHeight(_surf->h);
}
uint getRawSize(uint16 index) {
assert(index == 0);
return getSize(index);
}
uint getSize(uint16 index) {
assert(index == 0);
return _surf->w * _surf->h;
}
};
/*
@ -144,6 +155,15 @@ struct SurfaceToMultiFrames : public Frames {
r.setWidth(_width);
r.setHeight(_height);
}
uint getRawSize(uint16 index) {
assert(index == 0);
return getSize(index);
}
uint getSize(uint16 index) {
assert(index == 0);
return _width * _height;
}
};
struct MaskBuffer {
@ -284,6 +304,15 @@ public:
r.setWidth(_width);
r.setHeight(_height);
}
uint getRawSize(uint16 index) {
assert(index < _count);
return getSize(index);
}
uint getSize(uint16 index) {
assert(index < _count);
return _width * _height;
}
};
@ -346,6 +375,9 @@ public:
uint getNum();
void getRect(uint frame, Common::Rect &r);
byte *getData(uint frame);
uint getRawSize(uint frame);
uint getSize(uint frame);
void setFlags(uint32 flags);
void clearFlags(uint32 flags);
@ -540,6 +572,7 @@ protected:
void drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth);
void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor);
void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor);
};

View File

@ -206,8 +206,14 @@ void Parallaction_br::changeLocation(char *location) {
// free open location stuff
clearSubtitles();
freeBackground();
freeZones();
// freeAnimations();
// free(_location._comment);
// _location._comment = 0;
// _location._commands.clear();
// _location._aCommands.clear();
freeLocation();
// load new location
parseLocation(location);