[Midnightbsd-cvs] mports: mports/games: add doom legacy
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Oct 20 01:40:02 EDT 2007
Log Message:
-----------
add doom legacy
Modified Files:
--------------
mports/games:
Makefile (r1.14 -> r1.15)
Added Files:
-----------
mports/games/doomlegacy:
Makefile (r1.1)
distinfo (r1.1)
pkg-descr (r1.1)
pkg-plist (r1.1)
mports/games/doomlegacy/files:
legacy.in (r1.1)
patch-byteptr.h (r1.1)
patch-i_sound.c (r1.1)
patch-i_tcp.c (r1.1)
patch-makefile (r1.1)
patch-sndserv_Makefile (r1.1)
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mports/games/Makefile,v
retrieving revision 1.14
retrieving revision 1.15
diff -Lgames/Makefile -Lgames/Makefile -u -r1.14 -r1.15
--- games/Makefile
+++ games/Makefile
@@ -6,6 +6,7 @@
SUBDIR += bass
SUBDIR += battalion
SUBDIR += doom-data
+ SUBDIR += doomlegacy
SUBDIR += fortunate
SUBDIR += fotaq
SUBDIR += goonies
--- /dev/null
+++ games/doomlegacy/pkg-descr
@@ -0,0 +1,12 @@
+DooM Legacy is a DooM port. Some of the supported features are:
+ * VIDEO OPTIONS MENU
+ * TRANSLUCENCY ON SPRITES AND WALLS
+ * SETUP CONTROLS MENU
+ * LOOK UP AND DOWN (FREELOOK)
+ * CHASE-CAM : also called a 'third-person' view, or 'Tomb Raider' view.
+ * CONSOLE
+ * STATUS BAR OVERLAY
+ * SKINS
+
+WWW: http://legacy.newdoom.com/
+WWW: http://sourceforge.net/projects/doomlegacy
--- /dev/null
+++ games/doomlegacy/pkg-plist
@@ -0,0 +1,27 @@
+bin/doomlegacy
+%%DATADIR%%/legacy.dat
+%%DATADIR%%/llsndserv
+%%DATADIR%%/lsdldoom
+%%DATADIR%%/r_opengl.so
+%%PORTDOCS%%%%DOCSDIR%%/3dfloors.html
+%%PORTDOCS%%%%DOCSDIR%%/Doublescan.txt
+%%PORTDOCS%%%%DOCSDIR%%/README_SDL
+%%PORTDOCS%%%%DOCSDIR%%/boomref.html
+%%PORTDOCS%%%%DOCSDIR%%/Console.html
+%%PORTDOCS%%%%DOCSDIR%%/copying
+%%PORTDOCS%%%%DOCSDIR%%/doomatic.txt
+%%PORTDOCS%%%%DOCSDIR%%/doomlic.txt
+%%PORTDOCS%%%%DOCSDIR%%/Editing.html
+%%PORTDOCS%%%%DOCSDIR%%/editspecs.html
+%%PORTDOCS%%%%DOCSDIR%%/Faq.html
+%%PORTDOCS%%%%DOCSDIR%%/fsbasic.html
+%%PORTDOCS%%%%DOCSDIR%%/fsfuncs.html
+%%PORTDOCS%%%%DOCSDIR%%/index.html
+%%PORTDOCS%%%%DOCSDIR%%/Legacy.html
+%%PORTDOCS%%%%DOCSDIR%%/rules.txt
+%%PORTDOCS%%%%DOCSDIR%%/Skinspec.html
+%%PORTDOCS%%%%DOCSDIR%%/sound.cfg
+%%PORTDOCS%%%%DOCSDIR%%/source.html
+%%PORTDOCS%%%%DOCSDIR%%/Whatsnew.html
+ at dirrm %%DOCSDIR%%
+ at dirrm %%DATADIR%%
--- /dev/null
+++ games/doomlegacy/Makefile
@@ -0,0 +1,77 @@
+# New ports collection makefile for: doomlegacy
+# Date Created: 10 April 2002
+# Whom: Alexander G. Chetirbock <bock at bock.nnov.ru>
+#
+# $MidnightBSD: mports/games/doomlegacy/Makefile,v 1.1 2007/10/20 05:40:00 laffer1 Exp $
+# $FreeBSD: ports/games/doomlegacy/Makefile,v 1.15 2007/06/07 00:00:30 alepulver Exp $
+
+PORTNAME= doomlegacy
+PORTVERSION= 142
+PORTREVISION= 4
+CATEGORIES= games
+MASTER_SITES= SF
+DISTNAME= legacy_${PORTVERSION}_src
+DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${WADFILE}
+EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX}
+
+MAINTAINER= ports at MidnightBSD.org
+COMMENT= DooM Legacy: popular DooM clone!
+
+EXTRACT_DEPENDS=unzip:${PORTSDIR}/archivers/unzip
+
+USE_GL= yes
+USE_GMAKE= yes
+USE_SDL= mixer sdl
+MAKEFILE= makefile
+MAKE_ENV= FREEBSD=1 FBSD_SDL=1 PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" \
+ PTHREAD_LIBS="${PTHREAD_LIBS}"
+WRKSRC= ${WRKDIR}/doomlegacy_${PORTVERSION}_src
+
+OPTIONS= X86_ASM "Enable use of x86 assembly code" on
+
+DATADIR= ${PREFIX}/lib/${PORTNAME}
+SUB_FILES= legacy
+
+WADFILE= legacy_dat.zip
+
+.include "${.CURDIR}/../doom-data/Makefile.include"
+
+.include <bsd.port.pre.mk>
+
+.if defined(WITH_X86_ASM) && ${ARCH} == "i386"
+BUILD_DEPENDS+= nasm:${PORTSDIR}/devel/nasm
+MAKE_ARGS+= USEASM=1
+.endif
+
+post-extract:
+ @${UNZIP_CMD} -q ${DISTDIR}/${WADFILE} -d ${WRKDIR}/bin
+
+post-patch:
+ @${REINPLACE_CMD} -e \
+ 's|-I/usr/local/include/SDL11|`${SDL_CONFIG} --cflags`|; \
+ s|-lSDL-1\.1|`${SDL_CONFIG} --libs`|; \
+ s|/usr/local|${LOCALBASE}|; \
+ s|/usr/X11R6|${X11BASE}|' \
+ ${WRKSRC}/${MAKEFILE}
+
+pre-build:
+ @cd ${WRKSRC}/linux_x/sndserv && ${GMAKE} clean
+
+post-build:
+ @${LN} -sf ${WRKSRC}/linux_x/sndserv/linux/llsndserv ${WRKDIR}/bin
+
+do-install:
+ ${MKDIR} ${DATADIR}
+ cd ${WRKDIR}/bin && ${INSTALL_PROGRAM} llsndserv r_opengl.so ${DATADIR}
+ ${INSTALL} -c -s -o root -g kmem -m 2555 ${WRKDIR}/bin/lsdldoom \
+ ${DATADIR}
+ ${INSTALL_DATA} ${WRKDIR}/bin/legacy.dat ${DATADIR}
+ ${INSTALL_SCRIPT} ${WRKDIR}/legacy ${PREFIX}/bin/${PORTNAME}
+.ifndef(NOPORTDOCS)
+ ${MKDIR} ${DOCSDIR}
+. for f in *.html *.txt *.cfg README_SDL copying
+ ${INSTALL_DATA} ${WRKSRC}/_doc/${f} ${DOCSDIR}
+. endfor
+.endif
+
+.include <bsd.port.post.mk>
--- /dev/null
+++ games/doomlegacy/distinfo
@@ -0,0 +1,6 @@
+MD5 (legacy_142_src.tar.gz) = 62f5cdad464463038d568a53b13c22f7
+SHA256 (legacy_142_src.tar.gz) = f5d80aaafddb1a9525af72f118cc63f724f3542c9f58496ad5eabd334b8e2d98
+SIZE (legacy_142_src.tar.gz) = 1687954
+MD5 (legacy_dat.zip) = 8182e1aebac3696ddc7f9e0663740d9a
+SHA256 (legacy_dat.zip) = 2904fb4e14f60b85aeb49b4fe046ac360156dbe79acb26b640507d00ab949dfb
+SIZE (legacy_dat.zip) = 340934
--- /dev/null
+++ games/doomlegacy/files/patch-i_tcp.c
@@ -0,0 +1,13 @@
+--- i_tcp.c.orig Fri Jan 17 17:26:18 2003
++++ i_tcp.c Fri Jan 17 17:27:09 2003
+@@ -219,6 +219,10 @@
+ #include "doomstat.h"
+ #include "mserv.h" //Hurdler: support master server
+
++// somewhere on the track between 4.5 and -current this one has disappered.
++#ifndef IPPORT_USERRESERVED
++ #define IPPORT_USERRESERVED 5000
++#endif
+ #ifdef __WIN32__
+ // some undifined under win32
+ #define IPPORT_USERRESERVED 5000
--- /dev/null
+++ games/doomlegacy/files/patch-sndserv_Makefile
@@ -0,0 +1,12 @@
+--- linux_x/sndserv/Makefile.orig Sun Apr 18 18:02:24 2004
++++ linux_x/sndserv/Makefile Sun Sep 18 13:09:38 2005
+@@ -26,8 +26,7 @@
+ #
+ #
+
+-CC=gcc
+-CFLAGS=-O2 -m486 -Wall -DNORMALUNIX -DLINUX
++CFLAGS=-DNORMALUNIX -DLINUX
+ ifdef FREEBSD
+ CFLAGS:=${CFLAGS} -DFREEBSD
+ endif
--- /dev/null
+++ games/doomlegacy/files/patch-i_sound.c
@@ -0,0 +1,11 @@
+--- sdl/i_sound.c.orig Mon Apr 19 01:02:24 2004
++++ sdl/i_sound.c Sat Mar 5 23:04:27 2005
+@@ -118,7 +118,7 @@
+
+ #define SAMPLERATE 11025 // Hz
+
+-static int samplecount = 512;
++static int samplecount = 1024;
+
+ static int lengths[NUMSFX]; // The actual lengths of all sound effects.
+ static unsigned int channelstep[NUM_CHANNELS]; // The channel step amount...
--- /dev/null
+++ games/doomlegacy/files/legacy.in
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# The executable needs to run from a directory with the Doom Legacy data
+# files, libraries and executables. So we mirror the Doom Legacy data
+# directory to ~/.doomlegacy, and create symlinks to the data files.
+
+DOOMWADDIR="%%DMDIR%%"; export DOOMWADDIR
+
+if [ -d ~/.doomlegacy ]
+then
+ echo "Using existing ~/.doomlegacy directory."
+else
+ echo "Creating ~/.doomlegacy directory."
+ cd %%DATADIR%% || exit 1
+ mkdir -p ~/.doomlegacy
+ ln -s %%DATADIR%%/* ~/.doomlegacy
+fi
+
+cd ~/.doomlegacy || exit 1
+exec ./lsdldoom -nocheckwadversion "$@"
--- /dev/null
+++ games/doomlegacy/files/patch-makefile
@@ -0,0 +1,99 @@
+--- makefile.orig Sun Apr 18 18:02:24 2004
++++ makefile Mon Sep 19 20:44:29 2005
+@@ -260,12 +260,10 @@
+
+ # gcc or g++
+ #CC=@gcc
+-CC=gcc
+
+ #if use PGCC or EGCS
+ PGCC=1
+
+-WFLAGS=-Wall # -W -Wno-unused -Wno-sign-compare
+
+ #uncomment if you want to use the POLL_POINTER hack
+ #POLL_POINTER=-DPOLL_POINTER
+@@ -407,7 +405,8 @@
+
+ OPTS := $(OPTS) -DVID_X11 $(POLL_POINTER) -I. -I/usr/X11R6/include
+ LDFLAGS=-L/usr/X11R6/lib
+- LIBS=-lXext -lX11 -lm -lXxf86vm -lipx -lkvm -pthread
++ LIBS=-lXext -lX11 -lm -lXxf86vm -lipx -lkvm ${PTHREAD_LIBS}
++ CFLAGS+=${PTHREAD_CFLAGS}
+ # name of the exefile
+ EXENAME=llxdoom
+ SFLAGS=-g $(OPTS)
+@@ -418,7 +417,7 @@
+ else #ifdef X
+ ifdef FBSD_SDL
+ INTERFACE=sdl
+- OPTS := -DLINUX -DFREEBSD -DHWRENDER -DDIRECTFULLSCREEN -DHAVE_MIXER -DSDL -DVID_X11 $(POLL_POINTER) -I. -I/usr/local/include/SDL11 -I/usr/X11R6/include -Wall
++ OPTS := -DLINUX -DFREEBSD -DHWRENDER -DDIRECTFULLSCREEN -DHAVE_MIXER -DSDL -DVID_X11 $(POLL_POINTER) -I. -I/usr/local/include/SDL -I/usr/local/include -I/usr/X11R6/include
+ SFLAGS=-g $(OPTS)
+ OBJS=$(O)/i_video.o $(O)/dosstr.o $(O)/endtxt.o \
+ $(O)/hw_bsp.o $(O)/hw_draw.o $(O)/hw_light.o $(O)/hw_main.o \
+@@ -428,7 +427,8 @@
+ DEBUGLIBS=$(LIBS)
+
+ LDFLAGS=-L/usr/X11R6/lib -L/usr/local/lib
+- LIBS=-lm -lSDL-1.1 -lSDL_mixer -lGL -lGLU -lipx -lkvm -pthread
++ LIBS=-lm -lSDL -lSDL_mixer -lGL -lGLU -lipx -lkvm ${PTHREAD_LIBS}
++ CFLAGS+=${PTHREAD_CFLAGS}
+ DEBUGLIBS=$(LIBS)
+
+ # name of the exefile
+@@ -533,11 +533,7 @@
+
+ ifndef SOLARIS
+ ifdef GCC30
+- M5=-march=pentium
+- M4=-march=486
+ else
+- M5=-mpentium
+- M4=-m486
+ endif
+ endif
+
+@@ -555,13 +551,13 @@
+
+ # build a normal optimised version
+ ifdef PGCC
+- CFLAGS = $(OPTS) $(M5) -O6 -ffast-math -fomit-frame-pointer -fwritable-strings
++ CFLAGS += $(OPTS)
+ # -fgcse -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -ffunction-cse \
+ # -fexpensive-optimizations -fforce-mem -fstrength-reduce -fthread-jumps \
+ # -fregmove -fschedule-insns -fschedule-insns2 -fmove-all-movables \
+ # -fcaller-saves -finline-functions -mieee-fp -mfp-ret-in-387 -m80387 -mhard-float -finline
+ else
+- CFLAGS = $(M4) -O3 -ffast-math -fomit-frame-pointer -fwritable-strings $(OPTS)
++ CFLAGS += $(OPTS)
+ endif
+ endif
+
+@@ -735,7 +731,7 @@
+
+ #dll
+ dll : $(O)/r_opengl.o $(O)/ogl_x11.o
+- $(CC) $(M5) -O6 -o $(BIN)/r_opengl.so -shared -nostartfiles $(O)/r_opengl.o $(O)/ogl_x11.o -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXext -lGL -lGLU -lm
++ $(CC) $(CFLAGS) -o $(BIN)/r_opengl.so -shared -nostartfiles $(O)/r_opengl.o $(O)/ogl_x11.o -L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXext -lGL -lGLU -lm
+
+ musserv:
+ @mkdir -p $(MUSSERV)/linux
+@@ -760,7 +756,7 @@
+ ifdef FREEBSD
+ ifdef FBSD_SDL
+ $(O)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
+- $(CC) $(CFLAGS) $(LDFLAGS) $(WFLAGS) -I/usr/X11R6/include -c $< -o $@
++ $(CC) -fPIC $(CFLAGS) $(LDFLAGS) $(WFLAGS) -I/usr/X11R6/include -c $< -o $@
+ else #FBSD_SDL
+ $(O)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h
+ $(CC) $(M5) -O6 -o $(O)/r_opengl.o -DHWRENDER -DVID_X11 -DLINUX -DFREEBSD $(POLL_POINTER) -shared -nostartfiles -I/usr/X11R6/include -c hardware/r_opengl/r_opengl.c
+@@ -777,7 +773,7 @@
+ $(CC) $(M5) -O6 -o $(O)/ogl_x11.o -DHWRENDER -DVID_X11 -DLINUX $(POLL_POINTER) -shared -nostartfiles -I/usr/X11R6/include -c hardware/r_opengl/ogl_x11.c
+ else
+ $(O)/ogl_x11.o: hardware/r_opengl/ogl_x11.c hardware/r_opengl/r_opengl.h
+- $(CC) $(M5) -O6 -o $(O)/ogl_x11.o -DHWRENDER -DVID_X11 -DLINUX -DFREEBSD $(POLL_POINTER) -shared -nostartfiles -I/usr/X11R6/include -c hardware/r_opengl/ogl_x11.c
++ $(CC) -fPIC $(CFLAGS) -o $(O)/ogl_x11.o -DHWRENDER -DVID_X11 -DLINUX -DFREEBSD $(POLL_POINTER) -shared -nostartfiles -I/usr/X11R6/include -c hardware/r_opengl/ogl_x11.c
+ endif
+
+
--- /dev/null
+++ games/doomlegacy/files/patch-byteptr.h
@@ -0,0 +1,208 @@
+--- byteptr.h.orig Sun Apr 18 18:02:24 2004
++++ byteptr.h Wed Jun 6 20:09:36 2007
+@@ -32,109 +32,123 @@
+ //
+ //-----------------------------------------------------------------------------
+
+-#ifndef __BIG_ENDIAN__
+-//
+-// Little-endian machines
+-//
+-#define writeshort(p,b) *(short*) (p) = b
+-#define writelong(p,b) *(long *) (p) = b
+-#define WRITEBYTE(p,b) *((byte *)p)++ = b
+-#define WRITECHAR(p,b) *((char *)p)++ = b
+-#define WRITESHORT(p,b) *((short *)p)++ = b
+-#define WRITEUSHORT(p,b) *((USHORT *)p)++ = b
+-#define WRITELONG(p,b) *((long *)p)++ = b
+-#define WRITEULONG(p,b) *((ULONG *)p)++ = b
+-#define WRITEFIXED(p,b) *((fixed_t*)p)++ = b
+-#define WRITEANGLE(p,b) *((angle_t*)p)++ = b
+-#define WRITESTRING(p,b) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); } while(b[tmp_i++]); }
+-#define WRITESTRINGN(p,b,n) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); if(!b[tmp_i]) break;tmp_i++; } while(tmp_i<n); }
+-#define WRITEMEM(p,s,n) memcpy(p, s, n);p+=n
++#include <assert.h>
++#include <stdint.h>
+
+-#define readshort(p) *((short *)p)
+-#define readlong(p) *((long *)p)
+-#define READBYTE(p) *((byte *)p)++
+-#define READCHAR(p) *((char *)p)++
+-#define READSHORT(p) *((short *)p)++
+-#define READUSHORT(p) *((USHORT *)p)++
+-#define READLONG(p) *((long *)p)++
+-#define READULONG(p) *((ULONG *)p)++
+-#define READFIXED(p) *((fixed_t*)p)++
+-#define READANGLE(p) *((angle_t*)p)++
+-#define READSTRING(p,s) { int tmp_i=0; do { s[tmp_i]=READBYTE(p); } while(s[tmp_i++]); }
+-#define SKIPSTRING(p) while(READBYTE(p))
+-#define READMEM(p,s,n) memcpy(s, p, n);p+=n
+-#else
+-//
+-// definitions for big-endian machines with alignment constraints.
+-//
+-// Write a value to a little-endian, unaligned destination.
+-//
+-static inline void writeshort(void * ptr, int val)
++#ifdef __BIG_ENDIAN__
++#define ptrtole(ptr, size) endian_swap(ptr, size)
++#else
++#define ptrtole(ptr, size)
++#endif
++
++static inline void *endian_swap(void *ptr, size_t size)
+ {
+- char * cp = ptr;
+- cp[0] = val ; val >>= 8;
+- cp[1] = val ;
++ unsigned char *myptr = ptr;
++ int i, x;
++
++ for (i = 1; i <= size / 2; i++) {
++ x = myptr[i-1];
++ myptr[i-1] = myptr[size-i];
++ myptr[size-i] = x;
++ }
++
++ return (ptr);
+ }
+
+-static inline void writelong(void * ptr, int val)
++static inline void *incptr(void **ptr, size_t size)
+ {
+- char * cp = ptr;
+- cp[0] = val ; val >>= 8;
+- cp[1] = val ; val >>= 8;
+- cp[2] = val ; val >>= 8;
+- cp[3] = val ;
++ unsigned char **myptr = ptr;
++ void *oldptr = *ptr;
++ int i;
++
++ for (i = 0; i < size; i++)
++ (*myptr)++;
++
++ return (oldptr);
+ }
+
+-#define WRITEBYTE(p,b) *((byte *)p)++ = (b)
+-#define WRITECHAR(p,b) *((char *)p)++ = (b)
+-#define WRITESHORT(p,b) writeshort(((short *)p)++, (b))
+-#define WRITEUSHORT(p,b) writeshort(((u_short*)p)++, (b))
+-#define WRITELONG(p,b) writelong (((long *)p)++, (b))
+-#define WRITEULONG(p,b) writelong (((u_long *)p)++, (b))
+-#define WRITEFIXED(p,b) writelong (((fixed_t*)p)++, (b))
+-#define WRITEANGLE(p,b) writelong (((angle_t*)p)++, (long) (b))
+-#define WRITESTRING(p,b) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); } while(b[tmp_i++]); }
+-#define WRITESTRINGN(p,b,n) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); if(!b[tmp_i]) break;tmp_i++; } while(tmp_i<n); }
+-#define WRITEMEM(p,s,n) memcpy(p, s, n);p+=n
++static inline intmax_t readptr(void **ptr, size_t size)
++{
++ intmax_t res = 0;
+
+-// Read a signed quantity from little-endian, unaligned data.
+-//
+-static inline short readshort(void * ptr)
++ // Check if it won't work
++ assert(size > 0 && size <= sizeof(intmax_t));
++
++ memcpy(&res, incptr(ptr, size), size);
++ ptrtole(&res, size);
++
++ return (res);
++}
++
++static inline intmax_t writeptr(void **dst, intmax_t src, size_t size)
+ {
+- char *cp = ptr;
+- u_char *ucp = ptr;
+- return (cp[1] << 8) | ucp[0] ;
++ intmax_t res = 0;
++
++ // Check if it won't work
++ assert(size > 0 && size <= sizeof(intmax_t));
++
++ memcpy(*dst, &src, size);
++ ptrtole(*dst, size);
++ memcpy(&res, *dst, size);
++ incptr(dst, size);
++
++ return (res);
+ }
+
+-static inline u_short readushort(void * ptr)
++static inline short readshort(void *ptr)
+ {
+- u_char *ucp = ptr;
+- return (ucp[1] << 8) | ucp[0] ;
++ short res = *(short *)ptr;
++
++ ptrtole(&res, sizeof(short));
++
++ return (res);
+ }
+
+-static inline long readlong(void * ptr)
++static inline long readlong(void *ptr)
+ {
+- char *cp = ptr;
+- u_char *ucp = ptr;
+- return (cp[3] << 24) | (ucp[2] << 16) | (ucp[1] << 8) | ucp[0] ;
++ long res = *(long *)ptr;
++
++ ptrtole(&res, sizeof(long));
++
++ return (res);
+ }
+
+-static inline u_long readulong(void * ptr)
++static inline void writeshort(void *ptr, int val)
+ {
+- u_char *ucp = ptr;
+- return (ucp[3] << 24) | (ucp[2] << 16) | (ucp[1] << 8) | ucp[0] ;
++ short *myptr = ptr;
++
++ *myptr = val;
++ ptrtole(myptr, sizeof(*myptr));
+ }
+
++static inline void writelong(void *ptr, int val)
++{
++ long *myptr = ptr;
+
+-#define READBYTE(p) *((byte *)p)++
+-#define READCHAR(p) *((char *)p)++
+-#define READSHORT(p) readshort ( ((short*) p)++)
+-#define READUSHORT(p) readushort(((USHORT*) p)++)
+-#define READLONG(p) readlong ( ((long*) p)++)
+-#define READULONG(p) readulong ( ((ULONG*) p)++)
+-#define READFIXED(p) readlong ( ((long*) p)++)
+-#define READANGLE(p) readulong ( ((ULONG*) p)++)
++ *myptr = val;
++ ptrtole(myptr, sizeof(*myptr));
++}
++
++#define WRITEBYTE(p,b) writeptr(&p, b, sizeof(byte))
++#define WRITECHAR(p,b) writeptr(&p, b, sizeof(char))
++#define WRITESHORT(p,b) writeptr(&p, b, sizeof(short))
++#define WRITEUSHORT(p,b) writeptr(&p, b, sizeof(USHORT))
++#define WRITELONG(p,b) writeptr(&p, b, sizeof(long))
++#define WRITEULONG(p,b) writeptr(&p, b, sizeof(ULONG))
++#define WRITEFIXED(p,b) writeptr(&p, b, sizeof(fixed_t))
++#define WRITEANGLE(p,b) writeptr(&p, b, sizeof(angle_t))
++#define WRITESTRING(p,b) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); } while(b[tmp_i++]); }
++#define WRITESTRINGN(p,b,n) { int tmp_i=0; do { WRITECHAR(p,b[tmp_i]); if(!b[tmp_i]) break;tmp_i++; } while(tmp_i<n); }
++#define WRITEMEM(p,s,n) memcpy(p, s, n);p+=n
++
++#define READBYTE(p) readptr(&p, sizeof(byte))
++#define READCHAR(p) readptr(&p, sizeof(char))
++#define READSHORT(p) readptr(&p, sizeof(short))
++#define READUSHORT(p) readptr(&p, sizeof(USHORT))
++#define READLONG(p) readptr(&p, sizeof(long))
++#define READULONG(p) readptr(&p, sizeof(ULONG))
++#define READFIXED(p) readptr(&p, sizeof(fixed_t))
++#define READANGLE(p) readptr(&p, sizeof(angle_t))
+ #define READSTRING(p,s) { int tmp_i=0; do { s[tmp_i]=READBYTE(p); } while(s[tmp_i++]); }
+ #define SKIPSTRING(p) while(READBYTE(p))
+ #define READMEM(p,s,n) memcpy(s, p, n);p+=n
+-#endif //__BIG_ENDIAN__
More information about the Midnightbsd-cvs
mailing list