pkgsrc/games/xdoom/patches/patch-ai
wiz 5ea5107654 Re-add xdoom, requested by drochner.
Address PR 24024 by marking it as not-for-lp64platforms.
2010-02-22 21:58:47 +00:00

137 lines
4.1 KiB
Text

$NetBSD: patch-ai,v 1.6 2010/02/22 21:58:47 wiz Exp $
--- linuxdoom-1.10/i_video.c.orig Mon Dec 22 20:39:01 1997
+++ linuxdoom-1.10/i_video.c Thu Aug 22 04:42:18 2002
@@ -36,7 +36,7 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 2
#include <X11/extensions/XShm.h>
// Had to dig up XShm.c for this one.
// It is in the libXext, but not in the XFree86 headers.
-#ifdef LINUX
+#if defined(LINUX) || defined (__NetBSD__)
int XShmGetEventBase( Display* dpy ); // problems with g++?
#endif
@@ -46,13 +46,14 @@ int XShmGetEventBase( Display* dpy ); //
#include <sys/socket.h>
#include <netinet/in.h>
-#include <errnos.h>
+#include <errno.h>
#include <signal.h>
#include "doomstat.h"
#include "i_system.h"
#include "v_video.h"
#include "m_argv.h"
+#include "m_swap.h" /* For BYTE_ORDER == BIG_ENDIAN */
#include "d_main.h"
#include "doomdef.h"
@@ -164,15 +165,20 @@ int xlatekey(void)
void I_ShutdownGraphics(void)
{
// Detach from X server
- if (!XShmDetach(X_display, &X_shminfo))
+ if (X_shminfo.shmid)
+ {
+ if (!XShmDetach(X_display, &X_shminfo))
I_Error("XShmDetach() failed in I_ShutdownGraphics()");
- // Release shared memory.
- shmdt(X_shminfo.shmaddr);
- shmctl(X_shminfo.shmid, IPC_RMID, 0);
+ // Release shared memory.
+ shmdt(X_shminfo.shmaddr);
+ shmctl(X_shminfo.shmid, IPC_RMID, 0);
+ X_shminfo.shmid = 0;
+ }
// Paranoia.
- image->data = NULL;
+ if (image)
+ image->data = NULL;
}
@@ -666,7 +672,6 @@ void grabsharedmemory(int size)
id = shmget((key_t)key, size, IPC_CREAT|0777);
if (id==-1)
{
- extern int errno;
fprintf(stderr, "errno=%d\n", errno);
I_Error("Could not get any shared memory");
}
@@ -685,8 +690,7 @@ void grabsharedmemory(int size)
// attach to the shared memory segment
image->data = X_shminfo.shmaddr = shmat(id, 0, 0);
- fprintf(stderr, "shared memory id=%d, addr=0x%x\n", id,
- (int) (image->data));
+ fprintf(stderr, "shared memory id=%d, addr=%p\n", id, image->data);
}
void I_InitGraphics(void)
@@ -986,13 +990,13 @@ Expand4
{
fourpixels = lineptr[0];
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) );
xline[0] = dpixel;
xline[160] = dpixel;
xline[320] = dpixel;
xline[480] = dpixel;
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) );
xline[1] = dpixel;
xline[161] = dpixel;
xline[321] = dpixel;
@@ -1000,13 +1004,13 @@ Expand4
fourpixels = lineptr[1];
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) );
xline[2] = dpixel;
xline[162] = dpixel;
xline[322] = dpixel;
xline[482] = dpixel;
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) );
xline[3] = dpixel;
xline[163] = dpixel;
xline[323] = dpixel;
@@ -1014,13 +1018,13 @@ Expand4
fourpixels = lineptr[2];
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) );
xline[4] = dpixel;
xline[164] = dpixel;
xline[324] = dpixel;
xline[484] = dpixel;
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) );
xline[5] = dpixel;
xline[165] = dpixel;
xline[325] = dpixel;
@@ -1028,13 +1032,13 @@ Expand4
fourpixels = lineptr[3];
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff0000)>>13) );
xline[6] = dpixel;
xline[166] = dpixel;
xline[326] = dpixel;
xline[486] = dpixel;
- dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
+ dpixel = *(double *)( (long)exp + ( (fourpixels&0xffff)<<3 ) );
xline[7] = dpixel;
xline[167] = dpixel;
xline[327] = dpixel;