diff -ur sexypsf/Makefile sexypsf-amd64/Makefile
--- sexypsf/Makefile	2004-12-16 06:06:26.000000000 +0000
+++ sexypsf-amd64/Makefile	2005-04-29 19:23:07.000000000 +0000
@@ -22,7 +22,7 @@
 FLAGS+=	`gtk-config --cflags`
 
 ifeq (${CPU}, ix86)
-	OPTIMIZE += -fomit-frame-pointer -mcpu=i686 -fno-exceptions
+	OPTIMIZE += -fomit-frame-pointer -march=k8 -fno-exceptions
 endif
 
 ifeq (${CPU}, ppc)
@@ -33,7 +33,7 @@
 	FLAGS+=-DMSB_FIRST
 endif
 
-CFLAGS = -Wall ${OPTIMIZE} -I. ${FLAGS}
+CFLAGS = -Wall ${OPTIMIZE} -I. ${FLAGS} -fPIC
 
 sexypsf: ${OBJS}
 	${CC} ${CFLAGS} ${OBJS} -o libsexypsf.so ${LIBS}
diff -ur sexypsf/PsxMem.c sexypsf-amd64/PsxMem.c
--- sexypsf/PsxMem.c	2004-09-02 05:18:10.000000000 +0000
+++ sexypsf-amd64/PsxMem.c	2005-04-29 19:15:32.000000000 +0000
@@ -56,8 +56,8 @@
 
 	writeok=1;
 
-	psxMemLUT = (u32*)malloc(0x10000 * 4);
-	memset(psxMemLUT, 0, 0x10000 * 4);
+	psxMemLUT = malloc(0x10000 * sizeof(psxMemLUT));
+	memset(psxMemLUT, 0, 0x10000 * sizeof(psxMemLUT));
 
 	psxM = (char*)malloc(0x00200000);
 	psxP = (char*)malloc(0x00010000);
@@ -67,16 +67,23 @@
 		printf("Error allocating memory"); return -1;
 	}
 
+#ifdef _LP64
+	for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = (u64)&psxM[(i & 0x1f) << 16];
+#else
 	for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = (u32)&psxM[(i & 0x1f) << 16];
-
-	memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * 4);
-	memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * 4);
-
+#endif
+	memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * sizeof(psxMemLUT));
+	memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * sizeof(psxMemLUT));
+
+#ifdef _LP64
+	for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f00] = (u64)&psxP[i << 16];
+	for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f80] = (u64)&psxH[i << 16];
+	for (i=0; i<0x08; i++) psxMemLUT[i + 0xbfc0] = (u64)&psxR[i << 16];
+#else
 	for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f00] = (u32)&psxP[i << 16];
-
 	for (i=0; i<0x01; i++) psxMemLUT[i + 0x1f80] = (u32)&psxH[i << 16];
-
 	for (i=0; i<0x08; i++) psxMemLUT[i + 0xbfc0] = (u32)&psxR[i << 16];
+#endif
 
 	return 0;
 }
@@ -215,16 +222,20 @@
 					case 0x800: case 0x804:
 						if (writeok == 0) break;
 						writeok = 0;
-						memset(psxMemLUT + 0x0000, 0, 0x80 * 4);
-						memset(psxMemLUT + 0x8000, 0, 0x80 * 4);
-						memset(psxMemLUT + 0xa000, 0, 0x80 * 4);
+						memset(psxMemLUT + 0x0000, 0, 0x80 * sizeof(psxMemLUT));
+						memset(psxMemLUT + 0x8000, 0, 0x80 * sizeof(psxMemLUT));
+						memset(psxMemLUT + 0xa000, 0, 0x80 * sizeof(psxMemLUT));
 						break;
 					case 0x1e988:
 						if (writeok == 1) break;
 						writeok = 1;
+#ifdef _LP64
+						for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = (u64)&psxM[(i & 0x1f) << 16];
+#else
 						for (i=0; i<0x80; i++) psxMemLUT[i + 0x0000] = (u32)&psxM[(i & 0x1f) << 16];
-						memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * 4);
-						memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * 4);
+#endif
+						memcpy(psxMemLUT + 0x8000, psxMemLUT, 0x80 * sizeof(psxMemLUT));
+						memcpy(psxMemLUT + 0xa000, psxMemLUT, 0x80 * sizeof(psxMemLUT));
 						break;
 					default:
 						break;
diff -ur sexypsf/PsxMem.h sexypsf-amd64/PsxMem.h
--- sexypsf/PsxMem.h	2004-02-07 06:36:57.000000000 +0000
+++ sexypsf-amd64/PsxMem.h	2005-04-29 19:15:32.000000000 +0000
@@ -55,7 +55,11 @@
 #define psxHu16(mem)   	(*(u16*)&psxH[(mem) & 0xffff])
 #define psxHu32(mem)   	(*(u32*)&psxH[(mem) & 0xffff])
 
+#ifdef _LP64
+u64 *psxMemLUT;
+#else
 u32 *psxMemLUT;
+#endif
 
 #define PSXM(mem)		(psxMemLUT[(mem) >> 16] == 0 ? NULL : (void*)(psxMemLUT[(mem) >> 16] + ((mem) & 0xffff)))
 
