Correctly implemented little-endian masks in BRA.

svn-id: r30807
This commit is contained in:
Nicola Mettifogo 2008-02-06 13:57:44 +00:00
parent 782563f749
commit 715e33d63d
3 changed files with 13 additions and 3 deletions

View file

@ -345,6 +345,7 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char
// NOTE: info.width and info.height are only valid if the background graphics // NOTE: info.width and info.height are only valid if the background graphics
// have already been loaded // have already been loaded
info.mask.create(info.width, info.height); info.mask.create(info.width, info.height);
info.mask.bigEndian = false;
stream.read(info.mask.data, info.mask.size); stream.read(info.mask.data, info.mask.size);
stream.close(); stream.close();
} }

View file

@ -568,6 +568,7 @@ void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) {
info.bg.create(info.width, info.height, 1); info.bg.create(info.width, info.height, 1);
info.mask.create(info.width, info.height); info.mask.create(info.width, info.height);
info.mask.bigEndian = true;
info.path.create(info.width, info.height); info.path.create(info.width, info.height);
Graphics::PackBitsReadStream stream(_resArchive); Graphics::PackBitsReadStream stream(_resArchive);
@ -595,6 +596,7 @@ void DosDisk_ns::loadMaskAndPath(BackgroundInfo& info, const char *name) {
_resArchive.read(info.path.data, info.path.size); _resArchive.read(info.path.data, info.path.size);
info.mask.create(info.width, info.height); info.mask.create(info.width, info.height);
info.mask.bigEndian = true;
_resArchive.read(info.mask.data, info.mask.size); _resArchive.read(info.mask.data, info.mask.size);
return; return;

View file

@ -27,6 +27,7 @@
#define PARALLACTION_GRAPHICS_H #define PARALLACTION_GRAPHICS_H
#include "common/rect.h" #include "common/rect.h"
#include "common/hash-str.h"
#include "common/stream.h" #include "common/stream.h"
#include "graphics/surface.h" #include "graphics/surface.h"
@ -174,9 +175,10 @@ struct MaskBuffer {
uint16 h; uint16 h;
uint size; uint size;
byte *data; byte *data;
bool bigEndian;
public: public:
MaskBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) { MaskBuffer() : w(0), internalWidth(0), h(0), size(0), data(0), bigEndian(true) {
} }
void create(uint16 width, uint16 height) { void create(uint16 width, uint16 height) {
@ -198,8 +200,13 @@ public:
inline byte getValue(uint16 x, uint16 y) { inline byte getValue(uint16 x, uint16 y) {
byte m = data[(x >> 2) + y * internalWidth]; byte m = data[(x >> 2) + y * internalWidth];
uint n = (x & 3) << 1; uint n;
return ((3 << n) & m) >> n; if (bigEndian) {
n = (x & 3) << 1;
} else {
n = (3 - (x & 3)) << 1;
}
return (m >> n) & 3;
} }
}; };