Correctly implemented little-endian masks in BRA.
svn-id: r30807
This commit is contained in:
parent
782563f749
commit
715e33d63d
3 changed files with 13 additions and 3 deletions
|
@ -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
|
||||
// have already been loaded
|
||||
info.mask.create(info.width, info.height);
|
||||
info.mask.bigEndian = false;
|
||||
stream.read(info.mask.data, info.mask.size);
|
||||
stream.close();
|
||||
}
|
||||
|
|
|
@ -568,6 +568,7 @@ void DosDisk_ns::loadBackground(BackgroundInfo& info, const char *filename) {
|
|||
|
||||
info.bg.create(info.width, info.height, 1);
|
||||
info.mask.create(info.width, info.height);
|
||||
info.mask.bigEndian = true;
|
||||
info.path.create(info.width, info.height);
|
||||
|
||||
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);
|
||||
|
||||
info.mask.create(info.width, info.height);
|
||||
info.mask.bigEndian = true;
|
||||
_resArchive.read(info.mask.data, info.mask.size);
|
||||
|
||||
return;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define PARALLACTION_GRAPHICS_H
|
||||
|
||||
#include "common/rect.h"
|
||||
#include "common/hash-str.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
#include "graphics/surface.h"
|
||||
|
@ -174,9 +175,10 @@ struct MaskBuffer {
|
|||
uint16 h;
|
||||
uint size;
|
||||
byte *data;
|
||||
bool bigEndian;
|
||||
|
||||
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) {
|
||||
|
@ -198,8 +200,13 @@ public:
|
|||
|
||||
inline byte getValue(uint16 x, uint16 y) {
|
||||
byte m = data[(x >> 2) + y * internalWidth];
|
||||
uint n = (x & 3) << 1;
|
||||
return ((3 << n) & m) >> n;
|
||||
uint n;
|
||||
if (bigEndian) {
|
||||
n = (x & 3) << 1;
|
||||
} else {
|
||||
n = (3 - (x & 3)) << 1;
|
||||
}
|
||||
return (m >> n) & 3;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue