Fix PCX loading on big-endian systems

This commit is contained in:
Jeff Teunissen 2000-12-01 08:59:44 +00:00
parent 778fa713a6
commit 7b82e44ca1
3 changed files with 36 additions and 16 deletions

View file

@ -32,6 +32,7 @@
#include "console.h"
#include "pcx.h"
#include "qendian.h"
#include "qtypes.h"
#include "quakefs.h"
@ -56,6 +57,15 @@ void LoadPCX (QFile *f)
pcx = &pcxbuf;
pcx->xmax = LittleShort (pcx->xmax);
pcx->xmin = LittleShort (pcx->xmin);
pcx->ymax = LittleShort (pcx->ymax);
pcx->ymin = LittleShort (pcx->ymin);
pcx->hres = LittleShort (pcx->hres);
pcx->vres = LittleShort (pcx->vres);
pcx->bytes_per_line = LittleShort (pcx->bytes_per_line);
pcx->palette_type = LittleShort (pcx->palette_type);
if (pcx->manufacturer != 0x0a
|| pcx->version != 5
|| pcx->encoding != 1
@ -83,9 +93,9 @@ void LoadPCX (QFile *f)
if((dataByte & 0xC0) == 0xC0) {
runLength = dataByte & 0x3F;
dataByte = Qgetc (f);
}
else
} else {
runLength = 1;
}
while (runLength-- > 0) {
pix[0] = palette[dataByte * 3];

View file

@ -38,6 +38,7 @@
#include "msg.h"
#include "pcx.h"
#include "sys.h"
#include "qendian.h"
#include "va.h"
#include "skin.h"
#include "cl_parse.h"
@ -159,6 +160,15 @@ byte *Skin_Cache (skin_t *skin)
pcx = (pcx_t *)raw;
raw = &pcx->data;
pcx->xmax = LittleShort (pcx->xmax);
pcx->xmin = LittleShort (pcx->xmin);
pcx->ymax = LittleShort (pcx->ymax);
pcx->ymin = LittleShort (pcx->ymin);
pcx->hres = LittleShort (pcx->hres);
pcx->vres = LittleShort (pcx->vres);
pcx->bytes_per_line = LittleShort (pcx->bytes_per_line);
pcx->palette_type = LittleShort (pcx->palette_type);
if (pcx->manufacturer != 0x0a
|| pcx->version != 5
|| pcx->encoding != 1