[Pkg-nethack-devel] nethack/win/share tile2bmp.c,1.1.1.1,1.2
Joshua Kwan
joshk-guest@quantz.debian.org
Tue, 09 Dec 2003 16:14:48 +0000
- Previous message: [Pkg-nethack-devel] nethack/util makedefs.c,1.1.1.1,1.2
- Next message: [Pkg-nethack-devel] nethack/win/gnome gnbind.c,1.1.1.1,1.2 gnmain.c,1.1.1.1,1.2 gnmenu.c,1.1.1.1,1.2 gnmenu.h,1.1.1.1,1.2 gnopts.c,1.1.1.1,1.2 gnplayer.c,1.1.1.1,1.2 gnsignal.c,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/pkg-nethack/nethack/win/share
In directory quantz:/tmp/cvs-serv9687/win/share
Modified Files:
tile2bmp.c
Log Message:
Merge Nethack 3.4.3 upstream source.
Index: tile2bmp.c
===================================================================
RCS file: /cvsroot/pkg-nethack/nethack/win/share/tile2bmp.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- tile2bmp.c 7 Oct 2003 19:00:43 -0000 1.1.1.1
+++ tile2bmp.c 9 Dec 2003 16:14:45 -0000 1.2
@@ -48,6 +48,25 @@
#define PACK
#endif
+static short leshort(short x)
+{
+#ifdef __BIG_ENDIAN__
+ return ((x&0xff)<<8)|((x>>8)&0xff);
+#else
+ return x;
+#endif
+}
+
+
+static long lelong(long x)
+{
+#ifdef __BIG_ENDIAN__
+ return ((x&0xff)<<24)|((x&0xff00)<<8)|((x>>8)&0xff00)|((x>>24)&0xff);
+#else
+ return x;
+#endif
+}
+
#ifdef __GNUC__
typedef struct tagBMIH {
unsigned long biSize;
@@ -231,12 +250,12 @@
build_bmfh(pbmfh)
BITMAPFILEHEADER *pbmfh;
{
- pbmfh->bfType = (UINT)0x4D42;
- pbmfh->bfSize = (DWORD)BMPFILESIZE;
+ pbmfh->bfType = leshort(0x4D42);
+ pbmfh->bfSize = lelong(BMPFILESIZE);
pbmfh->bfReserved1 = (UINT)0;
pbmfh->bfReserved2 = (UINT)0;
- pbmfh->bfOffBits = sizeof(bmp.bmfh) + sizeof(bmp.bmih) +
- (RGBQUAD_COUNT * sizeof(RGBQUAD));
+ pbmfh->bfOffBits = lelong(sizeof(bmp.bmfh) + sizeof(bmp.bmih) +
+ (RGBQUAD_COUNT * sizeof(RGBQUAD)));
}
static void
@@ -244,20 +263,22 @@
BITMAPINFOHEADER *pbmih;
{
WORD cClrBits;
- pbmih->biSize = (DWORD) sizeof(bmp.bmih);
+ int w,h;
+ pbmih->biSize = lelong(sizeof(bmp.bmih));
#if BITCOUNT==4
- pbmih->biWidth = (LONG) MAX_X * 2;
+ pbmih->biWidth = lelong(w = MAX_X * 2);
#else
- pbmih->biWidth = (LONG) MAX_X;
+ pbmih->biWidth = lelong(w = MAX_X);
#endif
- pbmih->biHeight = (LONG) MAX_Y;
- pbmih->biPlanes = (WORD) 1;
+ pbmih->biHeight = lelong(h = MAX_Y);
+ pbmih->biPlanes = leshort(1);
#if BITCOUNT==4
- pbmih->biBitCount = (WORD) 4;
+ pbmih->biBitCount = leshort(4);
+ cClrBits = 4;
#else
- pbmih->biBitCount = (WORD) 8;
+ pbmih->biBitCount = leshort(8);
+ cClrBits = 8;
#endif
- cClrBits = (WORD)(pbmih->biPlanes * pbmih->biBitCount);
if (cClrBits == 1)
cClrBits = 1;
else if (cClrBits <= 4)
@@ -269,21 +290,20 @@
else if (cClrBits <= 24)
cClrBits = 24;
else cClrBits = 32;
- pbmih->biCompression = (DWORD) BI_RGB;
- pbmih->biXPelsPerMeter = (LONG)0;
- pbmih->biYPelsPerMeter = (LONG)0;
+ pbmih->biCompression = lelong(BI_RGB);
+ pbmih->biXPelsPerMeter = lelong(0);
+ pbmih->biYPelsPerMeter = lelong(0);
#if (TILE_X==32)
if (cClrBits < 24)
- pbmih->biClrUsed = (1<<cClrBits);
+ pbmih->biClrUsed = lelong(1<<cClrBits);
#else
- pbmih->biClrUsed = (DWORD)RGBQUAD_COUNT;
+ pbmih->biClrUsed = lelong(RGBQUAD_COUNT);
#endif
#if (TILE_X==16)
- pbmih->biSizeImage = 0;
+ pbmih->biSizeImage = lelong(0);
#else
- pbmih->biSizeImage = ((pbmih->biWidth * cClrBits +31) & ~31) /8
- * pbmih->biHeight;
+ pbmih->biSizeImage = lelong(((w * cClrBits +31) & ~31) /8 * h);
#endif
pbmih->biClrImportant = (DWORD)0;
}
- Previous message: [Pkg-nethack-devel] nethack/util makedefs.c,1.1.1.1,1.2
- Next message: [Pkg-nethack-devel] nethack/win/gnome gnbind.c,1.1.1.1,1.2 gnmain.c,1.1.1.1,1.2 gnmenu.c,1.1.1.1,1.2 gnmenu.h,1.1.1.1,1.2 gnopts.c,1.1.1.1,1.2 gnplayer.c,1.1.1.1,1.2 gnsignal.c,1.1.1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]