(svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it

This commit is contained in:
tron 2005-02-10 12:26:41 +00:00
parent d2703fd672
commit dc54a3e627
2 changed files with 20 additions and 16 deletions

18
gfx.c
View File

@ -1335,9 +1335,9 @@ static void GfxMainBlitter(Sprite *sprite, int x, int y, int mode)
}; };
/* decode sprite header */ /* decode sprite header */
x += (int16)TO_LE16(sprite->x_offs); x += sprite->x_offs;
y += (int16)TO_LE16(sprite->y_offs); y += sprite->y_offs;
bp.width_org = bp.width = TO_LE16(sprite->width); bp.width_org = bp.width = sprite->width;
bp.height_org = bp.height = sprite->height; bp.height_org = bp.height = sprite->height;
info = sprite->info; info = sprite->info;
bp.info = info; bp.info = info;
@ -1628,15 +1628,15 @@ void LoadStringWidthTable(void)
// 2 equals space. // 2 equals space.
for(i=2; i != 0xE2; i++) { for(i=2; i != 0xE2; i++) {
*b++ = (byte)((i < 93 || i >= 129 || i == 98) ? TO_LE16(GetSprite(i)->width) : 0); *b++ = (byte)((i < 93 || i >= 129 || i == 98) ? GetSprite(i)->width : 0);
} }
for(i=0xE2; i != 0x1C2; i++) { for(i=0xE2; i != 0x1C2; i++) {
*b++ = (byte)((i < 317 || i >= 353) ? TO_LE16(GetSprite(i)->width) + 1 : 0); *b++ = (byte)((i < 317 || i >= 353) ? GetSprite(i)->width + 1 : 0);
} }
for(i=0x1C2; i != 0x2A2; i++) { for(i=0x1C2; i != 0x2A2; i++) {
*b++ = (byte)((i < 541 || i >= 577) ? TO_LE16(GetSprite(i)->width) + 1 : 0); *b++ = (byte)((i < 541 || i >= 577) ? GetSprite(i)->width + 1 : 0);
} }
} }
@ -1914,9 +1914,9 @@ static void SetCursorSprite(uint cursor)
p = GetSprite(cursor & 0x3FFF); p = GetSprite(cursor & 0x3FFF);
cv->sprite = cursor; cv->sprite = cursor;
cv->size.y = p->height; cv->size.y = p->height;
cv->size.x = TO_LE16(p->width); cv->size.x = p->width;
cv->offs.x = (int16)TO_LE16(p->x_offs); cv->offs.x = p->x_offs;
cv->offs.y = (int16)TO_LE16(p->y_offs); cv->offs.y = p->y_offs;
cv->dirty = true; cv->dirty = true;
} }

View File

@ -149,15 +149,19 @@ static void ReadSprite(int num, byte *dest)
byte type; byte type;
byte *rel; byte *rel;
int8 i; int8 i;
int j, dist; int dist;
type = FioReadByte(); type = FioReadByte();
/* We've decoded special sprites when reading headers. */ /* We've decoded special sprites when reading headers. */
if (type != 0xFF) { if (type != 0xFF) {
/* read sprite hdr */ /* read sprite hdr */
*dest++ = type; Sprite* sprite = dest;
for(j=0; j!=7; j++) sprite->info = type;
*dest++ = FioReadByte(); sprite->height = FioReadByte();
sprite->width = FioReadWord();
sprite->x_offs = FioReadWord();
sprite->y_offs = FioReadWord();
dest = sprite->data;
num -= 8; num -= 8;
} }
@ -996,9 +1000,9 @@ const SpriteDimension *GetSpriteDimension(SpriteID sprite)
/* decode sprite header */ /* decode sprite header */
sd = &sd_static; sd = &sd_static;
sd->xoffs = (int16)TO_LE16(p->x_offs); sd->xoffs = p->x_offs;
sd->yoffs = (int16)TO_LE16(p->y_offs); sd->yoffs = p->y_offs;
sd->xsize = TO_LE16(p->width); sd->xsize = p->width;
sd->ysize = p->height; sd->ysize = p->height;
#else #else
sd = &sd_static; sd = &sd_static;