Skip to content

Commit

Permalink
Fix: encoding tiles on PowerPC caused sprites to be incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed May 3, 2024
1 parent f6aa952 commit 2d493d5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ static int decodetile(U8 *buffer, int sx, int sy, CommonPixel *imgbuffer, long t
for (int y=0; y<sy; y++) {
long offset;
if (long_format) {
U32 *ibuffer = (U32*)buffer;
offset = BE_SWAP32(ibuffer[y]);
offset = y * sizeof(U32);
offset = buffer[offset + 3] << 24 | buffer[offset + 2] << 16 | buffer[offset + 1] << 8 | buffer[offset + 0];
} else {
U16 *ibuffer = (U16*)buffer;
offset = BE_SWAP16(ibuffer[y]);
offset = y * sizeof(U16);
offset = buffer[offset + 1] << 8 | buffer[offset + 0];
}

long x, islast, chunkstart=0, len, ofs;
Expand Down Expand Up @@ -683,11 +683,15 @@ long encodetile(U8 **compressed_data, long *uncompressed_size, const CommonPixel
int x1 = 0, x2 = 0;

if (long_format) {
U32 *lineofs = (U32*)tile;
lineofs[y] = BE_SWAP32(tileofs);
size_t offset = y * sizeof(U32);
tile[offset++] = tileofs & 0xFF;
tile[offset++] = (tileofs >> 8) & 0xFF;
tile[offset++] = (tileofs >> 16) & 0xFF;
tile[offset++] = tileofs >> 24;
} else {
U16 *lineofs = (U16*)tile;
lineofs[y] = BE_SWAP16(tileofs);
size_t offset = y * sizeof(U16);
tile[offset++] = tileofs & 0xFF;
tile[offset++] = tileofs >> 8;
}
long lastlenofs = tileofs;

Expand Down

0 comments on commit 2d493d5

Please sign in to comment.