From 98fa822d58b7c094804e724d547c9d9af01a6af7 Mon Sep 17 00:00:00 2001 From: wrstuden Date: Mon, 2 Apr 2001 20:16:42 +0000 Subject: Fix big-endian support. Problem was that the targa code would load a little-endian short into an int, then byteswap the int. That's essentially le32toh() when it should be le16toh(). This ended up in making numbers 0x10000 times too big. Also got rid of a potential unaligned-access. --- graphics/clanlib/patches/patch-ak | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 graphics/clanlib/patches/patch-ak (limited to 'graphics/clanlib/patches') diff --git a/graphics/clanlib/patches/patch-ak b/graphics/clanlib/patches/patch-ak new file mode 100644 index 00000000000..096ec17b453 --- /dev/null +++ b/graphics/clanlib/patches/patch-ak @@ -0,0 +1,39 @@ +$NetBSD: patch-ak,v 1.3 2001/04/02 20:16:42 wrstuden Exp $ +--- Sources/Core/SurfaceProviders/provider_targa.cpp.orig Sat Mar 24 10:39:52 2001 ++++ Sources/Core/SurfaceProviders/provider_targa.cpp Sat Mar 24 10:46:53 2001 +@@ -151,8 +151,7 @@ + // read or skip the colormap (rgb-palette) + if (colormaptype == 1) + { +- map_length = *((unsigned short *) &file[5]); +- SWAP_IF_BIG(map_length); ++ map_length = file[5] + 256 * file[6]; + unsigned char map_size = file[7]>>3; + + if (!read_colormap) +@@ -194,13 +193,11 @@ + } + + // read pitch, height and bits-pr-pixel +- pitch = *((unsigned short *) &file[12]); +- SWAP_IF_BIG(pitch); ++ pitch = file[12] + 256 * file[13]; + bounding_left = pitch; + bounding_right = 0; + +- height = *((unsigned short *) &file[14]); +- SWAP_IF_BIG(height); ++ height = file[14] + 256 * file[15]; + bounding_top = height; + bounding_bottom = 0; + +@@ -456,8 +453,7 @@ + } + else + { +- entry = *((unsigned short *) &file[pos]); +- SWAP_IF_BIG(entry); ++ entry = file[pos] + 256 * file[pos + 1]; + pos += 2; + } + -- cgit v1.2.3