From fead2da8af1b2e11861d7f191c64ffbdc6c0d733 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 12 May 2019 04:26:13 +0200 Subject: [PATCH] Make UI image loading endian agnostic --- SourceX/storm/storm.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 645a54678..d97bbf81a 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -197,15 +198,15 @@ BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffe return false; } - int width = pcxhdr.xmax - pcxhdr.xmin + 1; - int height = pcxhdr.ymax - pcxhdr.ymin + 1; + int width = SDL_SwapLE16(pcxhdr.xmax) - SDL_SwapLE16(pcxhdr.xmin) + 1; + int height = SDL_SwapLE16(pcxhdr.ymax) - SDL_SwapLE16(pcxhdr.ymin) + 1; if (pdwWidth) *pdwWidth = width; if (dwHeight) *dwHeight = height; if (pdwBpp) - *pdwBpp = pcxhdr.bitsPerPixel; + *pdwBpp = SDL_SwapLE16(pcxhdr.bitsPerPixel); if (!pBuffer) { SFileSetFilePointer(hFile, 0, 0, 2); @@ -241,7 +242,7 @@ BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffe free(fileBuffer); } - if (pPalette && pcxhdr.bitsPerPixel == 8) { + if (pPalette && SDL_SwapLE16(pcxhdr.bitsPerPixel) == 8) { SFileSetFilePointer(hFile, -768, 0, 1); SFileReadFile(hFile, paldata, 768, 0, 0); for (int i = 0; i < 256; i++) { @@ -544,7 +545,7 @@ BOOL SVidPlayContinue(void) double now = SDL_GetTicks() * 1000; if (now < SVidFrameEnd) { - SDL_Delay((SVidFrameEnd - now)/1000); // wait with next frame if the system is to fast + SDL_Delay((SVidFrameEnd - now) / 1000); // wait with next frame if the system is to fast } return SVidLoadNextFrame();