161 lines
3.8 KiB
Text
161 lines
3.8 KiB
Text
$NetBSD: patch-ag,v 1.2 2013/03/02 18:13:14 joerg Exp $
|
|
|
|
Thou shalt not use reserved identifiers.
|
|
|
|
--- tplx.c.orig 2004-12-27 15:57:42.000000000 +0000
|
|
+++ tplx.c
|
|
@@ -37,13 +37,13 @@
|
|
|
|
# define BSWAP_16(B)\
|
|
({\
|
|
- __u16 _B = (B);\
|
|
- (((__u16) ((_B) << 8) | ((_B) >> 8)));\
|
|
+ __u16 m_B = (B);\
|
|
+ (((__u16) ((m_B) << 8) | ((m_B) >> 8)));\
|
|
})
|
|
# define BSWAP_32(B)\
|
|
({\
|
|
- __u32 _B = (B);\
|
|
- (((__u32) (_B << 24) | ((_B << 8) & 0xff0000) | ((_B >> 8) & 0xff00) | (_B >> 24)));\
|
|
+ __u32 m_B = (B);\
|
|
+ (((__u32) (m_B << 24) | ((m_B << 8) & 0xff0000) | ((m_B >> 8) & 0xff00) | (m_B >> 24)));\
|
|
})
|
|
|
|
#ifdef LIL_ENDIAN
|
|
@@ -103,21 +103,17 @@ typedef struct
|
|
__u32 offset;
|
|
} TPLPaletteHeader;
|
|
|
|
-
|
|
-#define TPLHeader(n) \
|
|
- struct\
|
|
- {\
|
|
- __u32 magic;\
|
|
- __u32 ntextures;\
|
|
- __u32 texture_size;\
|
|
- TPLTexture textures[n];\
|
|
- }\
|
|
-
|
|
+struct tplheader {
|
|
+ __u32 magic;
|
|
+ __u32 ntextures;
|
|
+ __u32 texture_size;
|
|
+ TPLTexture textures[];
|
|
+};
|
|
|
|
__u8 texbuff[1024*1024*4];
|
|
|
|
|
|
-inline __u32 color_unpack_rgb565 (__u32 X)
|
|
+__u32 color_unpack_rgb565 (__u32 X)
|
|
{
|
|
#ifdef LIL_ENDIAN
|
|
return (((X & 0xf800) >> 8) | ((X & 0xe000) >> 13) |
|
|
@@ -133,21 +129,21 @@ inline __u32 color_unpack_rgb565 (__u32
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_rgba4 (__u32 X)
|
|
+__u32 color_unpack_rgba4 (__u32 X)
|
|
{
|
|
- __u32 _X = X;
|
|
+ __u32 m_X = X;
|
|
|
|
|
|
#ifdef LIL_ENDIAN
|
|
- _X = ((X & 0x0f00) << 0) | ((X & 0x00f0) << 12) | ((X & 0x000f) << 24) | ((X & 0xf000) >> 12);
|
|
+ m_X = ((X & 0x0f00) << 0) | ((X & 0x00f0) << 12) | ((X & 0x000f) << 24) | ((X & 0xf000) >> 12);
|
|
#else
|
|
- _X = ((X & 0x0f00) << 8) | ((X & 0x00f0) << 4) | ((X & 0x000f) << 0) | ((X & 0xf000) << 12);
|
|
+ m_X = ((X & 0x0f00) << 8) | ((X & 0x00f0) << 4) | ((X & 0x000f) << 0) | ((X & 0xf000) << 12);
|
|
#endif
|
|
- return (_X | (_X << 4));
|
|
+ return (m_X | (m_X << 4));
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_rgba6 (__u32 X)
|
|
+__u32 color_unpack_rgba6 (__u32 X)
|
|
{
|
|
#ifdef LIL_ENDIAN
|
|
return ((X & 0xfc0000) >> 16) | ((X & 0xc00000) >> 22) |
|
|
@@ -163,7 +159,7 @@ inline __u32 color_unpack_rgba6 (__u32 X
|
|
}
|
|
|
|
// RGB5 1rrr rrgg gggb bbbb
|
|
-inline __u32 color_unpack_rgb555 (__u32 X)
|
|
+__u32 color_unpack_rgb555 (__u32 X)
|
|
{
|
|
#ifdef LIL_ENDIAN
|
|
return ((X & 0x7c00) >> 7) | ((X & 0x7000) >> 12) |
|
|
@@ -178,7 +174,7 @@ inline __u32 color_unpack_rgb555 (__u32
|
|
|
|
|
|
// RGB4A3 0aaa rrrr gggg bbbb
|
|
-inline __u32 color_unpack_rgb4a3 (__u32 X)
|
|
+__u32 color_unpack_rgb4a3 (__u32 X)
|
|
{
|
|
#ifdef LIL_ENDIAN
|
|
return ((X & 0x0f00) >> 4) | ((X & 0x0f00) >> 8) |
|
|
@@ -194,7 +190,7 @@ inline __u32 color_unpack_rgb4a3 (__u32
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_rgb5a3 (__u32 X)
|
|
+__u32 color_unpack_rgb5a3 (__u32 X)
|
|
{
|
|
if (X & 0x8000)
|
|
return (color_unpack_rgb555 (X) | MASK_ALPHA);
|
|
@@ -203,7 +199,7 @@ inline __u32 color_unpack_rgb5a3 (__u32
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_i4 (__u32 X)
|
|
+__u32 color_unpack_i4 (__u32 X)
|
|
{
|
|
X |= X << 4;
|
|
X |= X << 8;
|
|
@@ -211,14 +207,14 @@ inline __u32 color_unpack_i4 (__u32 X)
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_i8 (__u32 X)
|
|
+__u32 color_unpack_i8 (__u32 X)
|
|
{
|
|
X |= X << 8;
|
|
return (X | (X << 16));
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_ia4 (__u32 X)
|
|
+__u32 color_unpack_ia4 (__u32 X)
|
|
{
|
|
__u32 a = X & 0xf0;
|
|
|
|
@@ -234,7 +230,7 @@ inline __u32 color_unpack_ia4 (__u32 X)
|
|
}
|
|
|
|
|
|
-inline __u32 color_unpack_ia8 (__u32 X)
|
|
+__u32 color_unpack_ia8 (__u32 X)
|
|
{
|
|
__u32 a = X & 0xff00;
|
|
|
|
@@ -826,7 +822,7 @@ int extract_textures (char *buff)
|
|
{
|
|
char temp[256];
|
|
int i;
|
|
- TPLHeader (1) *hdr = (void *)buff;
|
|
+ struct tplheader *hdr = (void *)buff;
|
|
|
|
|
|
if (BSWAP32 (hdr->magic) != TPL_MAGIC)
|
|
@@ -839,7 +835,7 @@ int extract_textures (char *buff)
|
|
{
|
|
int n = BSWAP32 (((__u32 *)buff)[1]);
|
|
// using variable length array
|
|
- TPLHeader (n) *hdr = (void *) buff;
|
|
+ struct tplheader *hdr = (void *)buff;
|
|
TPLTextureHeader *texhdr = (void *) &buff[BSWAP32 (hdr->textures[0].texture_header_offset)];
|
|
TPLPaletteHeader *palhdr;
|
|
|