Package-Name: pcsx2
# FIXME: Download-Requires not implemented
Download-Requires: p7zip
Compile-Requires: autoconf
Source: http://www.pcsx2.net/downloads.php/<a\x20(href="([^"]*)"\x20title="Pcsx2_(\d+(\.\d+)+)_src\.7z")>/[\0-\377]*?href="([^"]*)"\x20title="Pcsx2_(\d+(.\d+)+)_src.7z" $2 http://www.pcsx2.net/$1
#More-Source-1: http://www.pcsx2.net/spu2PeopsSound.7z
Repack:
	mkdir pcsx2-"$(VERSION)"
	cd pcsx2-"$(VERSION)" && 7za x -bd "$(SOURCE)"
Compile:
	# FIXME: temp until we fix Vif.c up
	sleep 1; touch Vif.o
	$(MAKE) -C Linux CFLAGS='-Wall $${OPTIMIZE} -I. -I.. -I../IPU -I../pcl -I../DebugTools $${FLAGS} $$(shell gtk-config --cflags) -O2 -march=pentium4 -Wno-unused-value -Wno-pointer-sign'
Install:
Patch: <<EOT
######## begin Linux changes
--- CDVDiso.c.old	2006-01-13 02:26:06 +0900
+++ CDVDiso.c	2006-08-17 16:53:54 +0900
@@ -198,7 +198,7 @@
 //			case CdSecS2064:
 				((u32*)buf)[0] = i + 0x30000;
 				memcpy((u8*)buf+12, buff, 2048); 
-				(u8*)buf+= 2064; break;
+				buf = (u8*)buf+2064; break;
 //			default:
 //				return 0;
 //		}
@@ -300,13 +300,13 @@
 	//CdSync(0x00);
 
 	// point the tocEntryPointer at the first real toc entry
-	(char*)tocEntryPointer = toc;
+	tocEntryPointer = (struct dirTocEntry*)toc;
 
 	num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11;	//round up fix
 	current_sector = tocEntryPointer->fileLBA;
 
-	(char*)tocEntryPointer += tocEntryPointer->length;
-	(char*)tocEntryPointer += tocEntryPointer->length;
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 
 	localTocEntry.fileLBA = CDVolDesc.rootToc.tocLBA;
@@ -338,7 +338,7 @@
 			}
 
 			// point to the next entry
-			(char*)tocEntryPointer += tocEntryPointer->length;
+			tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer) + tocEntryPointer->length);
 		}
 */
 		while(1)
@@ -360,7 +360,7 @@
 					}
 //					CdSync(0x00);
 
-					(char*)tocEntryPointer = toc;
+					tocEntryPointer = (struct dirTocEntry*)toc;
 				}
 				else
 				{
@@ -385,7 +385,7 @@
 			}
 
 			// point to the next entry
-			(char*)tocEntryPointer += tocEntryPointer->length;
+			tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 		}
 
 		// If we havent found the directory name we wanted then fail
@@ -410,23 +410,23 @@
 		current_sector = localTocEntry.fileLBA;
 
 		// and point the tocEntryPointer at the first real toc entry
-		(char*)tocEntryPointer = toc;
-		(char*)tocEntryPointer += tocEntryPointer->length;
-		(char*)tocEntryPointer += tocEntryPointer->length;
+		tocEntryPointer = (struct dirTocEntry*)toc;
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 	}
 
 #ifdef DEBUG
 	printf("CDVD_findfile: found dir, now looking for file\n");
 #endif
 
-	(char*)tocEntryPointer = toc;
+	tocEntryPointer = (struct dirTocEntry*)toc;
 
 	num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11;	//round up fix
 	dir_lba = tocEntryPointer->fileLBA;
 
-	(char*)tocEntryPointer = toc;
-	(char*)tocEntryPointer += tocEntryPointer->length;
-	(char*)tocEntryPointer += tocEntryPointer->length;
+	tocEntryPointer = (struct dirTocEntry*)toc;
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 	while (num_dir_sectors > 0)
 	{
@@ -455,7 +455,7 @@
 				return TRUE;
 			}
 
-			(char*)tocEntryPointer += tocEntryPointer->length;
+			tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 		}
 
 		num_dir_sectors--;
@@ -470,7 +470,7 @@
 			}
 //			CdSync(0x00);
 
-			(char*)tocEntryPointer = toc;
+			tocEntryPointer = (struct dirTocEntry*)toc;
 		}
 	}
 
@@ -521,13 +521,13 @@
 	//CdSync(0x00);
 
 	// point the tocEntryPointer at the first real toc entry
-	(char*)tocEntryPointer = toc;
+	tocEntryPointer = (struct dirTocEntry*)toc;
 
 	num_dir_sectors = (tocEntryPointer->fileSize+2047) >> 11;
 	current_sector = tocEntryPointer->fileLBA;
 
-	(char*)tocEntryPointer += tocEntryPointer->length;
-	(char*)tocEntryPointer += tocEntryPointer->length;
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 	// use strtok to get the next dir name
 
@@ -563,7 +563,7 @@
 					}
 					//CdSync(0x00);
 
-					(char*)tocEntryPointer = toc;
+					tocEntryPointer = (struct dirTocEntry*)toc;
 				}
 				else{
 					// Couldnt find the directory, and got to end of directory
@@ -588,7 +588,7 @@
 			}
 
 			// point to the next entry
-			(char*)tocEntryPointer += tocEntryPointer->length;
+			tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 		}
 
 		// If we havent found the directory name we wanted then fail
@@ -611,9 +611,9 @@
 		current_sector = localTocEntry.fileLBA;
 
 		// and point the tocEntryPointer at the first real toc entry
-		(char*)tocEntryPointer = toc;
-		(char*)tocEntryPointer += tocEntryPointer->length;
-		(char*)tocEntryPointer += tocEntryPointer->length;
+		tocEntryPointer = (struct dirTocEntry*)toc;
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 	}
 
 	// We know how much data we need to read in from the DirTocHeader
@@ -625,7 +625,7 @@
 	// This is a bit of a waste of reads since we're not actually copying the data out yet,
 	// but we dont know how big this TOC might be, so we cant allocate a specific size
 
-	(char*)tocEntryPointer = toc;
+	tocEntryPointer = (struct dirTocEntry*)toc;
 
 	// Need to STORE the start LBA and number of Sectors, for use by the retrieve func.
 	getDirTocData.start_LBA = localTocEntry.fileLBA;
@@ -637,9 +637,9 @@
 
 	num_dir_sectors = getDirTocData.num_sectors;
 
-	(char*)tocEntryPointer = toc;
-	(char*)tocEntryPointer += tocEntryPointer->length;
-	(char*)tocEntryPointer += tocEntryPointer->length;
+	tocEntryPointer = (struct dirTocEntry*)toc;
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+	tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 	toc_entry_num=0;
 
@@ -661,7 +661,7 @@
 				}
 				//CdSync(0x00);
 
-				(char*)tocEntryPointer = toc;
+				tocEntryPointer = (struct dirTocEntry*)toc;
 
 //				continue;
 			}
@@ -694,7 +694,7 @@
 			}
 		}
 
-		(char*)tocEntryPointer += tocEntryPointer->length;
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 	}
 
@@ -731,14 +731,14 @@
 
 	if (getDirTocData.current_entry == 0){
 		// if this is the first read then make sure we point to the first real entry
-		(char*)tocEntryPointer = toc;
-		(char*)tocEntryPointer += tocEntryPointer->length;
-		(char*)tocEntryPointer += tocEntryPointer->length;
+		tocEntryPointer = (struct dirTocEntry*)toc;
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
+		tocEntryPointer = (struct dirTocEntry*)((char*)tocEntryPointer + tocEntryPointer->length);
 
 		getDirTocData.current_sector_offset = (char*)tocEntryPointer - toc;
 	}
 	else{
-		(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
+		tocEntryPointer = (struct dirTocEntry*)(toc + getDirTocData.current_sector_offset);
 	}
 
 	if (req_entries > 128)
@@ -763,7 +763,7 @@
 				//CdSync(0x00);
 
 				getDirTocData.current_sector_offset = 0;
-				(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
+				tocEntryPointer = (struct dirTocEntry *)(toc + getDirTocData.current_sector_offset);
 
 //				continue;
 			}
@@ -789,7 +789,7 @@
 			}
 
 			getDirTocData.current_sector_offset += tocEntryPointer->length;
-			(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
+			tocEntryPointer = (struct dirTocEntry*)(toc + getDirTocData.current_sector_offset);
 		}
 		else{
 			if (strlen(getDirTocData.extension_list) > 0){
@@ -799,13 +799,13 @@
 				}
 
 				getDirTocData.current_sector_offset += tocEntryPointer->length;
-				(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
+				tocEntryPointer = (struct dirTocEntry*)(toc + getDirTocData.current_sector_offset);
 
 			}
 			else{
 				toc_entry_num++;
 				getDirTocData.current_sector_offset += tocEntryPointer->length;
-				(char*)tocEntryPointer = toc + getDirTocData.current_sector_offset;
+				tocEntryPointer = (struct dirTocEntry*)(toc + getDirTocData.current_sector_offset);
 			}
 		}
 /*
--- Common.h.old	2006-07-02 07:53:42 +0900
+++ Common.h	2006-08-18 16:40:30 +0900
@@ -36,27 +36,7 @@
 
 #elif defined (__LINUX__) 
 
-#include <sys/types.h>
-#include <stdlib.h> // posix_memalign()
-#define BOOL int
-
-#undef TRUE
-#define TRUE  1
-#undef FALSE
-#define FALSE 0
-
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-
-#define strnicmp strncasecmp
-#define stricmp strcasecmp
-
-// Definitions added Feb 16, 2006 by efp
-#define __declspec(x)
-#define __forceinline inline
-#define _aligned_malloc(x,y) posix_memalign(y,x)
-#define _aligned_free(x) free(x)
-#define pthread_mutex__unlock pthread_mutex_unlock
+#include "winlinux.h"
 
 #endif
 
@@ -240,10 +220,6 @@
 extern float (*fpuatanf)(float fval);
 extern float (*fpuatan2f)(float fvalx, float fvaly);
 #endif
-// Added Feb 16, 2006 by efp
-#ifdef __LINUX__
-#include <errno.h> // EBUSY
-#endif /* __LINUX__ */
 
 #define DESTROY_MUTEX(mutex) { \
 	int err = pthread_mutex_destroy(&mutex); \
--- GS.c.old	2006-06-28 03:04:06 +0900
+++ GS.c	2006-08-18 17:48:29 +0900
@@ -23,7 +23,7 @@
 #include <xmmintrin.h>
 
 #include <assert.h>
-#include "ir5900.h"
+#include "iR5900.h"
 #include "VUmicro.h"
 
 #ifdef WIN32_VIRTUAL_MEM
@@ -65,7 +65,7 @@
 } GIFTAG;
 
 static GIFTAG g_path[3];
-__declspec(align(16)) static BYTE s_byRegs[3][16];
+__ALIGN(16) static BYTE s_byRegs[3][16];
 
 // could convert to pthreads easily, just don't have the time	
 HANDLE g_hGsEvent = NULL, // set when path3 is ready to be processed
@@ -74,9 +74,12 @@
 HANDLE g_hVuGSThread = NULL;
 u32 CSRw;
 
-HANDLE g_hAllGsReady[3] = {NULL};
+// not used? --AC
+//HANDLE g_hAllGsReady[3] = {NULL};
 
+#ifndef __LINUX__
 DWORD WINAPI VuGSThreadProc(LPVOID lpParam);
+#endif
 
 // g_pGSRingPos == g_pGSWritePos => fifo is empty
 u8* g_pGSRingPos = NULL, // cur pos ring is at
@@ -98,6 +101,7 @@
 	}
 	memset(GS_PAGEADDRS, 0, GSPAGES_STRIDE*(0x02000000>>GS_SHIFT));
 
+#ifndef __LINUX__
 	if( CHECK_MULTIGS ) {
 		g_hGsEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
 
@@ -124,6 +128,7 @@
 		InterlockedExchangePointer(&g_pGSWritePos, GS_RINGBUFFERBASE);
 		g_hVuGSThread = CreateThread(NULL, 0, VuGSThreadProc, NULL, 0, NULL);
 	}
+#endif
 }
 
 void gsWaitGS()
@@ -136,6 +141,7 @@
 {
 	VirtualFree(GS_PAGEADDRS, GSPAGES_STRIDE*(0x02000000>>GS_SHIFT), MEM_DECOMMIT|MEM_RELEASE);
 
+#ifndef __LINUX__
 	if( CHECK_MULTIGS ) {
 
 		SetEvent(g_hVuGSExit);
@@ -155,7 +161,9 @@
 		VirtualFree(GS_RINGBUFFERBASE, GS_RINGBUFFERSIZE, MEM_DECOMMIT|MEM_RELEASE);
 		VirtualFree(GS_RINGTEMPBASE, GS_RINGTEMPSIZE, MEM_DECOMMIT|MEM_RELEASE);
 	}
-	else GSclose();
+	else
+#endif
+		GSclose();
 }
 
 static void GSRingTempReserve(u32 size)
@@ -431,6 +439,7 @@
 	//if( GSreset ) GSreset();
 	memset(GS_PAGEADDRS, 0, GSPAGES_STRIDE*(0x02000000>>GS_SHIFT));
 
+#ifndef __LINUX__
 	if( CHECK_MULTIGS ) {
 		ResetEvent(g_hGsEvent);
 		ResetEvent(g_hVuGSExit);
@@ -439,6 +448,7 @@
 		g_pGSCurFreePages = g_pGSWriteFreePages;
 		g_pGSTempReadPos = g_pGSTempWritePos = GS_RINGTEMPBASE;
 	}
+#endif
 
 	memset(g_path, 0, sizeof(g_path));
 	memset(s_byRegs, 0, sizeof(s_byRegs));
@@ -1150,6 +1160,7 @@
 #define WRITINGDMA_TRANSFER(pMem, qwc) GSgifTransfer3(pMem, qwc);
 #endif
 
+#ifndef __LINUX__
 #define WRITERING_DMA(pMem, qwc) { \
 	if( CHECK_MULTIGS) { \
 		u8* pgsmem = GSRingBufCopy(pMem, (qwc)<<4, GS_RINGTYPE_P3); \
@@ -1170,7 +1181,14 @@
 		FreezeXMMRegs(1); \
 		WRITINGDMA_TRANSFER(pMem, qwc); \
 	} \
-} \
+}
+#else  // __LINUX__
+#define WRITERING_DMA(pMem, qwc) { \
+	FreezeMMXRegs(1); \
+	FreezeXMMRegs(1); \
+	WRITINGDMA_TRANSFER(pMem, qwc); \
+}
+#endif
 
 int  _GIFchain() {
 	u32 qwc = gif->qwc;
@@ -1497,6 +1515,7 @@
 }
 
 extern long pDsp;
+#ifndef __LINUX__
 DWORD WINAPI VuGSThreadProc(LPVOID lpParam)
 {
 	HANDLE handles[2] = { g_hGsEvent, g_hVuGSExit };
@@ -1693,6 +1712,7 @@
 
 	return 0;
 }
+#endif
 
 int gsFreeze(gzFile f, int Mode) {
 
@@ -1704,4 +1724,4 @@
 	return 0;
 }
 
-#undef GIFchain
\ No newline at end of file
+#undef GIFchain
--- Hw.c.old	2006-07-02 07:51:26 +0900
+++ Hw.c	2006-08-18 16:46:52 +0900
@@ -21,7 +21,7 @@
 #include <malloc.h>
 
 #include "Common.h"
-#include "ir5900.h"
+#include "iR5900.h"
 #include "VUmicro.h"
 #include "PsxMem.h"
 #include "IPU.h"
@@ -719,7 +719,7 @@
 #endif
 }
 
-__declspec(align(16)) u32 s_TempFIFO[4];
+__ALIGN(16) u32 s_TempFIFO[4];
 void hwConstRead128(u32 mem, int xmmreg) {
 	if (mem >= 0x10004000 && mem < 0x10008000) {
 		iFlushCall(0);
@@ -1101,7 +1101,7 @@
 		_eeMoveMMREGtoR(EAX, mmreg); \
 		_eeWriteConstMem16((u32)&PS2MEM_HW[(mem) & 0xffff], mmreg); \
 		\
-		TEST8ItoR(EAX, 0x100); \
+		TEST8ItoR(EAX, 0); /* was 0x100, but that's 9 bits! --AC */ \
 		j8Ptr[5] = JZ8(0); \
 		TEST8ItoM((u32)&PS2MEM_HW[DMAC_CTRL&0xffff], 1); \
 		j8Ptr[6] = JZ8(0); \
--- Memory.c.old	2006-07-02 07:51:36 +0900
+++ Memory.c	2006-08-17 16:24:20 +0900
@@ -54,10 +54,10 @@
 #include <sys/stat.h>
 
 #include "Common.h"
-#include "ir5900.h"
+#include "iR5900.h"
 #include "PsxMem.h"
 #include "R3000A.h"
-#include "psxhw.h"
+#include "PsxHw.h"
 #include "VUmicro.h"
 
 #include <assert.h>
--- Misc.c.old	2006-07-02 07:51:44 +0900
+++ Misc.c	2006-08-18 16:49:28 +0900
@@ -234,7 +234,7 @@
 		char percent[6];
 
 		if (buf.st_size<(int)fileOffset){
-			sprintf(percent, " %d%%", buf.st_size*100/(int)fileOffset);
+			sprintf(percent, " %d%%", (int)(buf.st_size*100/(int)fileOffset));
 			strcat(description, percent);//we force users to have correct bioses,
 											//not that lame scph10000 of 513KB ;-)
 		}
@@ -580,7 +580,6 @@
 	gzFile f;
 	freezeData fP;
 	int i;
-	DWORD OldProtect;
 	DWORD dwVer;
 
 #ifdef _DEBUG
@@ -761,7 +760,7 @@
 	for (i=0; name[i] && name[i]!='.' && i<10; i++) name[i]=toupper(name[i]);name[i]=0;
 
 	//phase 1: find ROMDIR in bios
-	for (p=PS2MEM_ROM; p<PS2MEM_ROM+0x80000; p++)
+	for (p=(char *)PS2MEM_ROM; p<(char *)PS2MEM_ROM+0x80000; p++)
 		if (strncmp(p, "RESET", 5)==0)
 			break;
 	rd=(struct romdir*)p;
--- PS2Etypes.h.old	2006-06-20 12:09:16 +0900
+++ PS2Etypes.h	2006-08-18 16:18:00 +0900
@@ -24,6 +24,9 @@
 typedef u32 uptr;
 #endif
 
+// here because this is the only file included by everything... --AC
+#define __ALIGN(n) __declspec(align(n))
+
 #elif defined(__LINUX__) || defined(__MINGW32__)
 
 typedef char s8;
@@ -42,6 +45,8 @@
 typedef u32 uptr;
 #endif
 
+#define __ALIGN(n) __attribute__((aligned(n)))
+
 #endif
 
 #endif /* __PS2ETYPES_H__ */
--- PsxCommon.h.old	2006-03-02 13:58:16 +0900
+++ PsxCommon.h	2006-08-17 16:24:36 +0900
@@ -18,7 +18,11 @@
 #ifndef __PSXCOMMON_H__
 #define __PSXCOMMON_H__
 
+#ifndef __LINUX__
 #include <windows.h>
+#else  /* Linux */
+#include "winlinux.h"
+#endif
 #include "PS2Etypes.h"
 
 //#include "Common.h"
--- PsxHw.c.old	2006-07-02 07:52:12 +0900
+++ PsxHw.c	2006-08-17 16:19:51 +0900
@@ -20,7 +20,7 @@
 #include <string.h>
 
 #include "PsxCommon.h"
-#include "ir5900.h"
+#include "iR5900.h"
 
 #ifdef __MSCW32__
 #pragma warning(disable:4244)
--- PsxMem.c.old	2006-07-02 13:43:34 +0900
+++ PsxMem.c	2006-08-18 10:01:06 +0900
@@ -23,7 +23,7 @@
 #include "PsxCommon.h"
 #include "VU.h"
 #include "iCore.h"
-#include "ir3000A.h"
+#include "iR3000A.h"
 
 extern u32 g_psxMaxRecMem;
 int g_psxWriteOk=1;
@@ -1602,4 +1602,4 @@
 	}
 }
 
-#endif
\ No newline at end of file
+#endif
--- R3000A.c.old	2006-07-03 23:20:52 +0900
+++ R3000A.c	2006-08-18 16:21:12 +0900
@@ -27,7 +27,7 @@
 u32 g_psxConstRegs[32];
 u32 g_psxHasConstReg, g_psxFlushedConstReg;
 
-__declspec(align(16)) psxRegisters psxRegs;
+__ALIGN(16) psxRegisters psxRegs;
 
 int psxInit()
 {
--- R5900.c.old	2006-07-03 23:20:56 +0900
+++ R5900.c	2006-08-18 16:21:01 +0900
@@ -28,10 +28,10 @@
 
 static int inter;
 
-__declspec(align(16)) cpuRegisters cpuRegs;
-__declspec(align(16)) fpuRegisters fpuRegs;
-__declspec(align(16)) tlbs tlb[48];
-__declspec(align(16)) GPR_reg64 g_cpuConstRegs[32] = {0};
+__ALIGN(16) cpuRegisters cpuRegs;
+__ALIGN(16) fpuRegisters fpuRegs;
+__ALIGN(16) tlbs tlb[48];
+__ALIGN(16) GPR_reg64 g_cpuConstRegs[32] = {0};
 u32 g_cpuHasConstReg = 0, g_cpuFlushedConstReg = 0;
 R5900cpu *Cpu;
 
--- Sif.c.old	2006-06-13 11:26:32 +0900
+++ Sif.c	2006-08-18 16:23:03 +0900
@@ -304,7 +304,7 @@
 				}
 				else if(sif0.fifoSize >= 4) // Read a tag
 				{
-					__declspec(align(16)) static u32 tag[4];
+					__ALIGN(16) static u32 tag[4];
 					SIF0read((u32*)&tag[0], 4); // Tag
 
 					sif0dma->qwc = (u16)tag[0];
--- SPR.c.old	2006-07-04 02:29:56 +0900
+++ SPR.c	2006-08-17 16:19:58 +0900
@@ -22,7 +22,7 @@
 #include "Common.h"
 #include "SPR.h"
 
-#include "ir5900.h"
+#include "iR5900.h"
 
 #define spr0 ((DMACh*)&PS2MEM_HW[0xD000])
 #define spr1 ((DMACh*)&PS2MEM_HW[0xD400])
--- VU0.c.old	2006-07-02 07:53:06 +0900
+++ VU0.c	2006-08-18 16:23:15 +0900
@@ -48,7 +48,7 @@
 
 #include "VUflags.h"
 
-__declspec(align(16)) VURegs VU0;
+__ALIGN(16) VURegs VU0;
 
 void COP2() {
 #ifdef VU0_LOG
--- Vif.c.old	2006-07-03 23:21:32 +0900
+++ Vif.c	2006-08-18 16:23:10 +0900
@@ -28,7 +28,7 @@
 
 VIFregisters *_vifRegs;
 u32* _vifMaskRegs = NULL;
-__declspec(align(16)) u32 g_vifRow0[4], g_vifCol0[4], g_vifRow1[4], g_vifCol1[4];
+__ALIGN(16) u32 g_vifRow0[4], g_vifCol0[4], g_vifRow1[4], g_vifCol1[4];
 u32* _vifRow = NULL;
 
 vifStruct *_vif;
@@ -675,7 +675,7 @@
 #include <xmmintrin.h>
 #include <emmintrin.h>
 
-__declspec(align(16)) u32 g_vif1Masks[64], g_vif0Masks[64];
+__ALIGN(16) u32 g_vif1Masks[64], g_vif0Masks[64];
 u32 g_vif1HasMask3[4] = {0}, g_vif0HasMask3[4] = {0};
 
 //static const u32 writearr[4] = { 0xffffffff, 0, 0, 0 };
@@ -684,7 +684,7 @@
 //static const u32 updatearr[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0 };
 
 // arranged in writearr, rowarr, colarr, updatearr
-static __declspec(align(16)) s_maskarr[16][4] = {
+static __ALIGN(16) s_maskarr[16][4] = {
 	0xffffffff, 0x00000000, 0x00000000, 0xffffffff,
 	0xffff0000, 0x0000ffff, 0x00000000, 0xffffffff,
 	0xffff0000, 0x00000000, 0x0000ffff, 0xffffffff,
@@ -2168,7 +2168,7 @@
 } \
 
 // V4-5
-__declspec(align(16)) static u32 s_TempDecompress[4] = {0};
+__ALIGN(16) static u32 s_TempDecompress[4] = {0};
 
 #define DECOMPRESS_RGBA(OFFSET) { \
 	/* R */ \
--- VifDma.c.old	2006-07-02 07:52:32 +0900
+++ VifDma.c	2006-08-18 18:02:15 +0900
@@ -291,12 +291,22 @@
 //			VIFfuncTableSSE[1].funcS[6](dest, (u32*)tempdata, 8);
 
 			if( VIFdmanum ) {
+#ifdef __GNUC__
+				asm("movaps %0, %%xmm6" : : "m" (g_vifRow1[0]));
+				asm("movaps %0, %%xmm7" : : "m" (g_vifCol1[0]));
+#else
 				__asm movaps XMM_ROW, qword ptr [g_vifRow1]
 				__asm movaps XMM_COL, qword ptr [g_vifCol1]
+#endif
 			}
 			else {
+#ifdef __GNUC__
+				asm("movaps %0, %%xmm6" : : "m" (g_vifRow0[0]));
+				asm("movaps %0, %%xmm7" : : "m" (g_vifCol0[0]));
+#else
 				__asm movaps XMM_ROW, qword ptr [g_vifRow0]
 				__asm movaps XMM_COL, qword ptr [g_vifCol0]
+#endif
 			}
 
 			if( vifRegs->cycle.cl == 0 || vifRegs->cycle.wl == 0 || (vifRegs->cycle.cl == vifRegs->cycle.wl && !(vifRegs->code&0x10000000)) ) {
@@ -1869,4 +1879,4 @@
 		SetNewMask(g_vif1Masks, g_vif1HasMask3, vif1Regs->mask, ~vif1Regs->mask);
 
 	return 0;
-}
\ No newline at end of file
+}
--- VU.h.old	2006-06-26 23:38:52 +0900
+++ VU.h	2006-08-18 16:54:09 +0900
@@ -113,7 +113,7 @@
 	u32 cycle;
 	u32 flags;
 
-	void (*vuExec)(void*);
+	void (*vuExec)(u32);
 	VIFregisters *vifRegs;
 
 	u8 *Mem;
--- VU1micro.c.old	2006-07-02 13:43:42 +0900
+++ VU1micro.c	2006-08-17 16:39:18 +0900
@@ -29,7 +29,7 @@
 #include "VUmicro.h"
 #include "VUops.h"
 #include "VUflags.h"
-#include "ivu1micro.h"
+#include "iVU1micro.h"
 
 #include "iVUzerorec.h"
 
--- IPU/IPU.c.old	2006-06-25 00:29:44 +0900
+++ IPU/IPU.c	2006-08-18 16:21:47 +0900
@@ -27,7 +27,7 @@
 #include <xmmintrin.h>
 #include <emmintrin.h>
 
-#include "ir5900.h"
+#include "iR5900.h"
 #include "pcl.h"
 
 #ifdef __WIN32__
@@ -64,7 +64,7 @@
 void fifo_wclear();
 
 static int readwpos = 0, writewpos = 0;
-__declspec(align(16)) u32 fifo_input[32];
+__ALIGN(16) u32 fifo_input[32];
 
 void ReorderBitstream();
 u8 FillInternalBuffer(u32 * pointer, u32 advance);
@@ -97,10 +97,10 @@
 u16 vqclut[16];			//clut conversion table
 static u8 s_thresh[2];		//thresholds for color conversions
 int coded_block_pattern=0;
-__declspec(align(16)) struct macroblock_8  mb8;
-__declspec(align(16)) struct macroblock_16 mb16;
-__declspec(align(16)) struct macroblock_rgb32 rgb32;
-__declspec(align(16)) struct macroblock_rgb16 rgb16;
+__ALIGN(16) struct macroblock_8  mb8;
+__ALIGN(16) struct macroblock_16 mb16;
+__ALIGN(16) struct macroblock_rgb32 rgb32;
+__ALIGN(16) struct macroblock_rgb16 rgb16;
 
 u8 indx4[16*16/2];
 u32	mpeg2_inited;		//mpeg2_idct_init() must be called only once
@@ -111,7 +111,7 @@
 extern u8 mpeg2_scan_norm[64];
 extern u8 mpeg2_scan_alt[64];
 
-__declspec(align(16)) u8 _readbits[80];	//local buffer (ring buffer)
+__ALIGN(16) u8 _readbits[80];	//local buffer (ring buffer)
 u8* readbits = _readbits; // always can decrement by one 1qw
 
 #define SATURATE_4BITS(val)		((val)>15 ? 15 : (val))
--- ix86-32/iR5900LoadStore.c.old	2006-07-02 13:42:56 +0900
+++ ix86-32/iR5900LoadStore.c	2006-08-18 16:23:57 +0900
@@ -63,7 +63,7 @@
 
 #else
 
-__declspec(align(16)) u64 retValues[2];
+__ALIGN(16) u64 retValues[2];
 extern u32 maxrecmem;
 static u32 s_bCachingMem = 0;
 static u32 s_nAddMemOffset = 0;
@@ -3715,7 +3715,7 @@
 
 #else
 
-__declspec(align(16)) u32 dummyValue[4];
+__ALIGN(16) u32 dummyValue[4];
 
 ////////////////////////////////////////////////////
 void recLB( void ) 
@@ -4215,4 +4215,4 @@
 
 #endif
 
-#endif
\ No newline at end of file
+#endif
--- ix86-32/iR5900Move.c.old	2006-07-04 21:08:22 +0900
+++ ix86-32/iR5900Move.c	2006-08-18 16:24:03 +0900
@@ -448,7 +448,7 @@
 	}
 }
 
-__declspec(align(16)) static s_zero[4] = {0,0,0xffffffff, 0xffffffff};
+__ALIGN(16) static s_zero[4] = {0,0,0xffffffff, 0xffffffff};
 
 void recMOVZtemp_consts(int info)
 {
--- ix86-32/iR5900MultDiv.c.old	2006-07-02 07:48:44 +0900
+++ ix86-32/iR5900MultDiv.c	2006-08-18 16:24:08 +0900
@@ -745,7 +745,7 @@
 //do EEINST_SETSIGNEXT
 REC_FUNC( MADD, _Rd_ );
 
-__declspec(align(16)) static u32 s_MaddMask[] = { 0x80000000, 0, 0x80000000, 0 };
+__ALIGN(16) static u32 s_MaddMask[] = { 0x80000000, 0, 0x80000000, 0 };
 
 void recMADDU()
 {
--- ix86-32/iR5900Shift.c.old	2006-06-21 07:10:22 +0900
+++ ix86-32/iR5900Shift.c	2006-08-18 16:24:24 +0900
@@ -573,7 +573,7 @@
 * Format:  OP rd, rt, rs                                 *
 *********************************************************/
 
-__declspec(align(16)) u32 s_sa[4] = {0x1f, 0, 0x3f, 0};
+__ALIGN(16) u32 s_sa[4] = {0x1f, 0, 0x3f, 0};
 
 int recSetShiftV(int info, int* rsreg, int* rtreg, int* rdreg, int* rstemp, int forcemmx, int shift64)
 {
--- Linux/Config.c.old	2006-02-17 06:51:40 +0900
+++ Linux/Config.c	2006-08-18 10:09:46 +0900
@@ -77,13 +77,12 @@
 	GetValue("Mcd2", Config.Mcd2);
 	GetValue("PluginsDir", Config.PluginsDir);
 	GetValue("BiosDir",    Config.BiosDir);
-	GetValuel("Cpu",        Config.Cpu);
 	GetValuel("PsxOut",     Config.PsxOut);
-	GetValuel("RegCaching", Config.Regcaching);
 	GetValuel("Patch",      Config.Patch);
-	GetValuel("VUrec",      Config.VUrec);
 // 	GetValuel("PadHack",    Config.PadHack);
+#ifdef PCSX2_DEVBUILD
 	GetValuel("varLog", varLog);
+#endif
 	Config.Lang[0] = 0;
 	GetValue("Lang", Config.Lang);
 
@@ -122,11 +121,8 @@
 	SetValue("Mcd2", Config.Mcd2);
 	SetValue("PluginsDir", Config.PluginsDir);
 	SetValue("BiosDir",    Config.BiosDir);
-	SetValuel("Cpu",        Config.Cpu);
 	SetValuel("PsxOut",     Config.PsxOut);
-	SetValuel("RegCaching", Config.Regcaching);
 	SetValuel("Patch",      Config.Patch);
-	SetValuel("VUrec",      Config.VUrec);
 // 	SetValuel("PadHack",    Config.PadHack);
 	SetValuel("varLog", varLog);
 	SetValue("Lang",    Config.Lang);
--- Linux/configure.in.old	2006-01-13 02:26:06 +0900
+++ Linux/configure.in	2006-08-17 16:02:34 +0900
@@ -4,7 +4,7 @@
 
 AC_INIT(LnxMain.c)
 AM_INIT_AUTOMAKE(PCSX2, 0.9)
-AM_MAINTAINTER_MODE
+AM_MAINTAINER_MODE
 AC_PROG_CC
 AC_CHECK_PROG(STRIP, strip, strip)
 AC_CHECK_PROG(RM, rm, rm)
@@ -17,7 +17,7 @@
 
 AC_MSG_CHECKING(gtk+)
 
-AC_CHECK_PROG(GTK-CONFIG, gtk-config, gtk-config)
+AC_CHECK_PROG(GTK_CONFIG, gtk-config, gtk-config)
 
 dnl end
 
--- Linux/GladeGui.c.old	2006-01-13 02:26:06 +0900
+++ Linux/GladeGui.c	2006-08-18 10:12:58 +0900
@@ -1416,9 +1416,6 @@
   GtkWidget *GtkCheckButton_Patches;
   GtkWidget *frame6;
   GtkWidget *vbox26;
-  GtkWidget *GtkCheckButton_Cpu;
-  GtkWidget *GtkCheckButton_RegCaching;
-  GtkWidget *GtkCheckButton_VUrec;
   GtkWidget *hbuttonbox3;
   GtkWidget *GtkButton_Ok;
   GtkWidget *GtkButton_Cancel;
@@ -1490,27 +1487,6 @@
   gtk_container_add (GTK_CONTAINER (frame6), vbox26);
   gtk_container_set_border_width (GTK_CONTAINER (vbox26), 5);
 
-  GtkCheckButton_Cpu = gtk_check_button_new_with_label (_("Disable Recompiler"));
-  gtk_widget_ref (GtkCheckButton_Cpu);
-  gtk_object_set_data_full (GTK_OBJECT (CpuDlg), "GtkCheckButton_Cpu", GtkCheckButton_Cpu,
-                            (GtkDestroyNotify) gtk_widget_unref);
-  gtk_widget_show (GtkCheckButton_Cpu);
-  gtk_box_pack_start (GTK_BOX (vbox26), GtkCheckButton_Cpu, FALSE, FALSE, 0);
-
-  GtkCheckButton_RegCaching = gtk_check_button_new_with_label (_("Enable Reg Caching"));
-  gtk_widget_ref (GtkCheckButton_RegCaching);
-  gtk_object_set_data_full (GTK_OBJECT (CpuDlg), "GtkCheckButton_RegCaching", GtkCheckButton_RegCaching,
-                            (GtkDestroyNotify) gtk_widget_unref);
-  gtk_widget_show (GtkCheckButton_RegCaching);
-  gtk_box_pack_start (GTK_BOX (vbox26), GtkCheckButton_RegCaching, FALSE, FALSE, 0);
-
-  GtkCheckButton_VUrec = gtk_check_button_new_with_label (_("Disable VUs recompilation"));
-  gtk_widget_ref (GtkCheckButton_VUrec);
-  gtk_object_set_data_full (GTK_OBJECT (CpuDlg), "GtkCheckButton_VUrec", GtkCheckButton_VUrec,
-                            (GtkDestroyNotify) gtk_widget_unref);
-  gtk_widget_show (GtkCheckButton_VUrec);
-  gtk_box_pack_start (GTK_BOX (vbox26), GtkCheckButton_VUrec, FALSE, FALSE, 0);
-
   hbuttonbox3 = gtk_hbutton_box_new ();
   gtk_widget_ref (hbuttonbox3);
   gtk_object_set_data_full (GTK_OBJECT (CpuDlg), "hbuttonbox3", hbuttonbox3,
--- Linux/GtkGui.c.old	2006-01-13 02:26:06 +0900
+++ Linux/GtkGui.c	2006-08-18 10:15:45 +0900
@@ -478,22 +478,9 @@
 	GtkWidget *Btn;
 	long t;
 
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_RegCaching");
-	Config.Regcaching = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
-
 	Btn = lookup_widget(CpuDlg, "GtkCheckButton_Patches");
 	Config.Patch = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
 
-	t = Config.Cpu;
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_Cpu");
-	Config.Cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
-	if (t != Config.Cpu) {
-		cpuRestartCPU();
-	}
-
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_VUrec");
-	Config.VUrec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
-
 	Btn = lookup_widget(CpuDlg, "GtkCheckButton_PsxOut");
 	Config.PsxOut = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
 
@@ -517,28 +504,12 @@
 	CpuDlg = create_CpuDlg();
 	gtk_window_set_title(GTK_WINDOW(CpuDlg), _("Configuration"));
 
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_Cpu");
-	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), Config.Cpu);
-
 	Btn = lookup_widget(CpuDlg, "GtkCheckButton_PsxOut");
 	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), Config.PsxOut);
 
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_RegCaching");
-	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), Config.Regcaching);
-
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_VUrec");
-	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), Config.VUrec);
-
 	Btn = lookup_widget(CpuDlg, "GtkCheckButton_Patches");
 	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), Config.Patch);
 
-#ifndef CPU_LOG
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_RegCaching");
-	gtk_widget_set_sensitive(Btn, FALSE);
-	Btn = lookup_widget(CpuDlg, "GtkCheckButton_VUrec");
-	gtk_widget_set_sensitive(Btn, FALSE);
-#endif
-
 	gtk_widget_show_all(CpuDlg);
 	if (Window) gtk_widget_set_sensitive(Window, FALSE);
 	gtk_main();
@@ -1111,7 +1082,9 @@
 }
 
 void OnDebug_Log() {
+#ifdef PCSX2_DEVBUILD
 	Log = 1 - Log;
+#endif
 }
 
 void OnDebug_EEMode() {
@@ -1203,28 +1176,36 @@
 		sprintf(str, "Log%d", i);
 		Btn = lookup_widget(LogDlg, str);
 		ret = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
+#ifdef PCSX2_DEVBUILD
 		if (ret) varLog|= 1<<i;
 		else varLog&=~(1<<i);
+#endif
 	}
 
 	for (i=20; i<29; i++) {
 		sprintf(str, "Log%d", i);
 		Btn = lookup_widget(LogDlg, str);
 		ret = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
+#ifdef PCSX2_DEVBUILD
 		if (ret) varLog|= 1<<i;
 		else varLog&=~(1<<i);
+#endif
 	}
 
 	for (i=30; i<32; i++) {
 		sprintf(str, "Log%d", i);
 		Btn = lookup_widget(LogDlg, str);
 		ret = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
+#ifdef PCSX2_DEVBUILD
 		if (ret) varLog|= 1<<i;
 		else varLog&=~(1<<i);
+#endif
 	}
 
 	Btn = lookup_widget(LogDlg, "Log");
+#ifdef PCSX2_DEVBUILD
 	Log = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
+#endif
 
 	SaveConfig();
 
--- Linux/LnxMain.c.old	2006-01-13 02:26:06 +0900
+++ Linux/LnxMain.c	2006-08-18 18:31:22 +0900
@@ -97,7 +97,6 @@
 		memset(&Config, 0, sizeof(Config));
 		strcpy(Config.BiosDir,    "Bios/");
 		strcpy(Config.PluginsDir, "Plugins/");
-		Config.Cpu = 1;
 
 		SysMessage(_("Pcsx2 needs to be configured"));
 		Pcsx2Configure();
@@ -222,7 +221,9 @@
 			break;
 #ifdef CPU_LOG
 		case XK_F9:
+#ifdef PCSX2_DEVBUILD
 			Log = 1 - Log;
+#endif
 			SysPrintf("Log : %d\n", Log);
 			break;
 		case XK_F10:
@@ -325,3 +326,14 @@
 	munmap((uptr*)base, size);
 }
 
+/***** FIXME: here for now until put into a new file or implemented properly --AC *****/
+
+void *memcpy_amd(void *d, const void *s, size_t len) { return memcpy(d,s,len); }
+void *memcpy_mmx(void *d, const void *s, size_t len) { return memcpy(d,s,len); }
+void memxor_mmx(void *d, const void *s, int len) {
+	const u32 *ptr = s;
+	u32 res = 0;
+	while (len > 0)
+		res ^= *ptr++;
+	*((u32 *)d) = res;
+}
--- Linux/Makefile.old	2006-08-17 16:21:00 +0900
+++ Linux/Makefile	2006-08-18 18:12:30 +0900
@@ -11,6 +11,7 @@
 PCSX2 = pcsx2
 
 CC = gcc
+CXX = g++
 RM = rm -f
 AR = ar
 STRIP = strip
@@ -18,7 +19,8 @@
 OPTIMIZE = -O2 -fomit-frame-pointer -finline-functions -ffast-math -fno-strict-aliasing -m128bit-long-double
 SSEOPTIMIZE = -O4 -fomit-frame-pointer -finline-functions -ffast-math -fno-strict-aliasing -m128bit-long-double -mfpmath=sse -march=athlon64
 
-FLAGS = -D__LINUX__ -DENABLE_NLS -DPACKAGE=\"pcsx2\"
+# _GNU_SOURCE is for posix_memalign()
+FLAGS = -D__LINUX__ -D_GNU_SOURCE -DENABLE_NLS -DPACKAGE=\"pcsx2\"
 # this includes the option -rdynamic and we don't want that
 LIBST = $(shell gtk-config --libs)
 LIBS = $(subst -rdynamic,,${LIBST}) -lz -lpthread
@@ -46,7 +48,8 @@
 		   ../ix86-32/iR5900Move.o ../ix86-32/iR5900MultDiv.o ../ix86-32/iR5900Shift.o \
 		   ../x86/recCOP2.o ../x86/iCP0.o \
 		   ../x86/iFPU.o ../x86/iMMI.o ../x86/iVUmicro.o \
-		   ../x86/iVU0micro.o ../x86/iVU1micro.o ../x86/iR3000A.o
+		   ../x86/iVU0micro.o ../x86/iVU1micro.o ../x86/iR3000A.o \
+		   ../x86/iCore.o
 	OBJS+= ../x86/ix86/ix86.o ../x86/ix86/ix86_fpu.o \
 		   ../x86/ix86/ix86_3dnow.o ../x86/ix86/ix86_mmx.o \
 		   ../x86/ix86/ix86_cpudetect.o ../x86/ix86/ix86_sse.o
@@ -59,7 +62,8 @@
 		   ../x86-64/iR5900Move.o ../x86-64/iR5900MultDiv.o ../x86-64/iR5900Shift.o \
 		   ../x86/recCOP2.o ../x86/iCP0.o \
 		   ../x86/iFPU.o ../x86/iMMI.o ../x86/iVUmicro.o \
-		   ../x86/iVU0micro.o ../x86/iVU1micro.o ../x86/iR3000A.o
+		   ../x86/iVU0micro.o ../x86/iVU1micro.o ../x86/iR3000A.o \
+		   ../x86/iCore.o
 	OBJS+= ../x86/ix86/ix86.o ../x86/ix86/ix86_fpu.o \
 		   ../x86/ix86/ix86_3dnow.o ../x86/ix86/ix86_mmx.o \
 		   ../x86/ix86/ix86_cpudetect.o ../x86/ix86/ix86_sse.o
@@ -70,8 +74,8 @@
 ROBJS:= $(OBJS:.o=.ro)
 RSOBJS:= $(OBJS:.o=.rso)
 
-CFLAGS = -Wall ${OPTIMIZE} -I. -I.. -I../IPU -I../DebugTools ${FLAGS}
-CSSEFLAGS = -Wall ${SSEOPTIMIZE} -I. -I.. -I../IPU -I../DebugTools ${FLAGS}
+CFLAGS = -Wall ${OPTIMIZE} -I. -I.. -I../IPU -I../pcl -I../DebugTools ${FLAGS}
+CSSEFLAGS = -Wall ${SSEOPTIMIZE} -I. -I.. -I../IPU -I../pcl -I../DebugTools ${FLAGS}
 CFLAGS+= $(shell gtk-config --cflags)
 CSSEFLAGS+= $(shell gtk-config --cflags)
 
@@ -101,6 +105,15 @@
 %.rso: %.c
 	${CC} ${CSSEFLAGS} -D_RELEASE -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
 
+%.o: %.cpp
+	${CC} ${CFLAGS} -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
+
+%.ro: %.cpp
+	${CC} ${CFLAGS} -D_RELEASE -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
+
+%.rso: %.cpp
+	${CC} ${CSSEFLAGS} -D_RELEASE -c -o $@ $< -MD -MF $(patsubst %.o,%.d,$@)
+
 -include ${DEPS}
 
 
--- /no/such/file	1994-07-18 08:46:18 +0900
+++ Linux/winlinux.h	2006-08-18 18:02:46 +0900
@@ -0,0 +1,130 @@
+/* Define some Windows-specific types and stuff used by PCSX2 */
+
+#ifndef WINLINUX_H
+#define WINLINUX_H
+
+#include <assert.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h> // mmap()
+#include <sys/stat.h> // mkdir()
+#include <sys/types.h>
+
+typedef int8_t BYTE;
+typedef uint32_t DWORD;
+#define BOOL int
+
+#undef TRUE
+#define TRUE  1
+#undef FALSE
+#define FALSE 0
+
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+
+#define strnicmp strncasecmp
+#define stricmp strcasecmp
+
+#define fpusqrtf sqrtf
+#define fpufabsf fabsf
+#define fpusinf sinf
+#define fpucosf cosf
+#define fpuexpf expf
+#define fpuatanf atanf
+#define fpuatan2f atan2f
+
+#define __declspec(x...)
+#define __forceinline inline
+#define _aligned_malloc(x,y) __extension__({void *ptr; posix_memalign(&ptr,y,x) ? ptr : NULL;})
+#define _aligned_free(x) free(x)
+#define pthread_mutex__unlock pthread_mutex_unlock
+#define __assume(x) assert(x)
+
+typedef void *HANDLE;
+typedef union _LARGE_INTEGER {
+	struct {
+		uint32_t LowPart;
+	    int32_t HighPart;
+	};
+	struct {
+		uint32_t LowPart;
+		int32_t HighPart;
+	} u;
+	int64_t QuadPart;
+} LARGE_INTEGER;
+
+#define MessageBox(a,b,c,d) \
+	fprintf(stderr, "%s: %s\n", (c), (b));
+#define MB_OK 0
+
+#define Sleep sleep
+
+#define VirtualAlloc(addr,size,flags,protect) \
+	mmap((addr), (size), (protect), MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, 0, 0)
+#define VirtualFree(addr,size,flags) \
+	munmap((addr), (size))
+#define PAGE_NOACCESS	(PROT_NONE)
+#define PAGE_READONLY	(PROT_READ)
+#define PAGE_READWRITE	(PROT_READ | PROT_WRITE)
+#define PAGE_EXECUTE	(PROT_EXEC)
+#define PAGE_EXECUTE_READ	(PROT_EXEC | PROT_READ)
+#define PAGE_EXECUTE_READWRITE	(PROT_EXEC | PROT_READ | PROT_WRITE)
+
+#define InitializeCriticalSection(mutex) \
+	pthread_mutex_init(mutex)
+#define EnterCriticalSection(mutex) \
+	pthread_mutex_lock(mutex)
+#define LeaveCriticalSection(mutex) \
+	pthread_mutex_unlock(mutex)
+#define DeleteCriticalSection(mutex) \
+	pthread_mutex_destroy(mutex)
+#define CRITICAL_SECTION pthread_mutex_t
+
+/* buh. yeah, this is a cop out. --AC */
+#define InterlockedExchangePointer(target,value) \
+	__extension__({void *__old = *(target); *(target) = (value); __old;})
+#define InterlockedExchangeAdd(target,value) \
+	__extension__({void *__old = *(target); *(target) += (value); __old;})
+
+/* really, really ugly; these should be separate routines somewhere --AC */
+struct __event {
+	int __state;
+	int __manual;
+};
+#define CreateEvent(attr,manual,state,name) __extension__({ \
+	static struct __event __events[8]; \
+	static int __next = 0; \
+	if (__next > ARRAYSIZE(__events)) { \
+		fprintf(stderr, "CreateEvent: no more events\n"); \
+		exit(1); \
+	} \
+	__events[__next].__state = (state); \
+	__events[__next].__manual = (manual); \
+	&__events[__next++]; \
+})
+#define SetEvent(event) (((struct __event *)(event))->__state = 1, 1)
+#define ResetEvent(event) (((struct __event *)(event))->__state = 0, 1)
+#define CloseHandle(handle) 1
+#define WaitForSingleObject(handle,delay) __extension__({ \
+	struct __event *__ev = (struct __event *)(handle); \
+	int __ms = (delay); \
+	void *__ret = NULL; \
+	do { \
+		if (__ev->__state) { \
+			if (!__ev->__manual) \
+				__ev->__state = 0; \
+			__ret = __ev; \
+		} \
+		if (__ms > 0) { \
+			usleep(10000); \
+			__ms -= 10; \
+		} \
+	} while (__ms > 0); \
+	__ret; \
+})
+#define INFINITE 0x7FFFFFFF
+
+#endif
--- x86/iCore.cpp.old	2006-07-04 21:09:10 +0900
+++ x86/iCore.cpp	2006-08-18 18:21:37 +0900
@@ -5,8 +5,10 @@
 
 extern "C" {
 
-#if defined(__WIN32__)
+#if defined(__WIN32__)
 #include <windows.h>
+#elif defined(__LINUX__)
+#include "winlinux.h"
 #endif
 
 #include "PS2Etypes.h"
@@ -39,8 +41,8 @@
 
 _xmmregs xmmregs[XMMREGS], s_saveXMMregs[XMMREGS];
 
-__declspec(align(16)) u64 g_globalMMXData[8];
-__declspec(align(16)) u64 g_globalXMMData[2*XMMREGS];
+__ALIGN(16) u64 g_globalMMXData[8];
+__ALIGN(16) u64 g_globalXMMData[2*XMMREGS];
 
 // X86 caching
 _x86regs x86regs[X86REGS], s_saveX86regs[X86REGS];
@@ -803,6 +805,16 @@
 			return;
 		g_globalMMXSaved = 1;
 
+#ifdef __GNUC__
+		asm("movntq %%mm0, %0" : "=m" (g_globalMMXData[0]));
+		asm("movntq %%mm1, %0" : "=m" (g_globalMMXData[1]));
+		asm("movntq %%mm2, %0" : "=m" (g_globalMMXData[2]));
+		asm("movntq %%mm3, %0" : "=m" (g_globalMMXData[3]));
+		asm("movntq %%mm4, %0" : "=m" (g_globalMMXData[4]));
+		asm("movntq %%mm5, %0" : "=m" (g_globalMMXData[5]));
+		asm("movntq %%mm6, %0" : "=m" (g_globalMMXData[6]));
+		asm("movntq %%mm7, %0" : "=m" (g_globalMMXData[7]));
+#else
 		__asm {
 			movntq mmword ptr [g_globalMMXData + 0], mm0
 			movntq mmword ptr [g_globalMMXData + 8], mm1
@@ -814,12 +826,24 @@
 			movntq mmword ptr [g_globalMMXData + 56], mm7
 			emms
 		}
+#endif
 	}
 	else {
 		if( !g_globalMMXSaved )
 			return;
 		g_globalMMXSaved = 0;
 
+#ifdef __GNUC__
+		asm("movq %0, %%mm0" : : "m" (g_globalMMXData[0]));
+		asm("movq %0, %%mm1" : : "m" (g_globalMMXData[1]));
+		asm("movq %0, %%mm2" : : "m" (g_globalMMXData[2]));
+		asm("movq %0, %%mm3" : : "m" (g_globalMMXData[3]));
+		asm("movq %0, %%mm4" : : "m" (g_globalMMXData[4]));
+		asm("movq %0, %%mm5" : : "m" (g_globalMMXData[5]));
+		asm("movq %0, %%mm6" : : "m" (g_globalMMXData[6]));
+		asm("movq %0, %%mm7" : : "m" (g_globalMMXData[7]));
+		asm("emms");
+#else
 		__asm {
 			movq mm0, mmword ptr [g_globalMMXData + 0]
 			movq mm1, mmword ptr [g_globalMMXData + 8]
@@ -831,6 +855,7 @@
 			movq mm7, mmword ptr [g_globalMMXData + 56]
 			emms
 		}
+#endif
 	}
 }
 
@@ -1736,6 +1761,16 @@
 			return;
 		g_globalXMMSaved = 1;
 
+#ifdef __GNUC__
+		asm("movaps %%xmm0, %0" : "=m" (g_globalXMMData[ 0]), "=m" (g_globalXMMData[ 1]));
+		asm("movaps %%xmm1, %0" : "=m" (g_globalXMMData[ 2]), "=m" (g_globalXMMData[ 3]));
+		asm("movaps %%xmm2, %0" : "=m" (g_globalXMMData[ 4]), "=m" (g_globalXMMData[ 5]));
+		asm("movaps %%xmm3, %0" : "=m" (g_globalXMMData[ 6]), "=m" (g_globalXMMData[ 7]));
+		asm("movaps %%xmm4, %0" : "=m" (g_globalXMMData[ 8]), "=m" (g_globalXMMData[ 9]));
+		asm("movaps %%xmm5, %0" : "=m" (g_globalXMMData[10]), "=m" (g_globalXMMData[11]));
+		asm("movaps %%xmm6, %0" : "=m" (g_globalXMMData[12]), "=m" (g_globalXMMData[13]));
+		asm("movaps %%xmm7, %0" : "=m" (g_globalXMMData[14]), "=m" (g_globalXMMData[15]));
+#else
 		__asm {
 			movaps xmmword ptr [g_globalXMMData + 0], xmm0
 			movaps xmmword ptr [g_globalXMMData + 16], xmm1
@@ -1746,6 +1781,7 @@
 			movaps xmmword ptr [g_globalXMMData + 96], xmm6
 			movaps xmmword ptr [g_globalXMMData + 112], xmm7
 		}
+#endif
 	}
 	else {
 		if( !g_globalXMMSaved )
@@ -1753,6 +1789,16 @@
 
 		g_globalXMMSaved = 0;
 
+#ifdef __GNUC__
+		asm("movaps %0, %%xmm0" : : "m" (g_globalXMMData[ 0]), "m" (g_globalXMMData[ 1]));
+		asm("movaps %0, %%xmm1" : : "m" (g_globalXMMData[ 2]), "m" (g_globalXMMData[ 3]));
+		asm("movaps %0, %%xmm2" : : "m" (g_globalXMMData[ 4]), "m" (g_globalXMMData[ 5]));
+		asm("movaps %0, %%xmm3" : : "m" (g_globalXMMData[ 6]), "m" (g_globalXMMData[ 7]));
+		asm("movaps %0, %%xmm4" : : "m" (g_globalXMMData[ 8]), "m" (g_globalXMMData[ 9]));
+		asm("movaps %0, %%xmm5" : : "m" (g_globalXMMData[10]), "m" (g_globalXMMData[11]));
+		asm("movaps %0, %%xmm6" : : "m" (g_globalXMMData[12]), "m" (g_globalXMMData[13]));
+		asm("movaps %0, %%xmm7" : : "m" (g_globalXMMData[14]), "m" (g_globalXMMData[15]));
+#else
 		__asm {
 			movaps xmm0, xmmword ptr [g_globalXMMData + 0]
 			movaps xmm1, xmmword ptr [g_globalXMMData + 16]
@@ -1763,6 +1809,7 @@
 			movaps xmm6, xmmword ptr [g_globalXMMData + 96]
 			movaps xmm7, xmmword ptr [g_globalXMMData + 112]
 		}
+#endif
 	}
 }
 
@@ -1992,7 +2039,7 @@
 	assert(0);
 }
 
-__declspec(align(16)) u32 s_zeros[4] = {0};
+__ALIGN(16) u32 s_zeros[4] = {0};
 int _signExtendXMMtoM(u32 to, x86SSERegType from, int candestroy)
 {
 	int t0reg;
@@ -2170,7 +2217,7 @@
 	return NULL;
 }
 
-__declspec(align(16)) static u32 s_ones[2] = {0xffffffff, 0xffffffff};
+__ALIGN(16) static u32 s_ones[2] = {0xffffffff, 0xffffffff};
 
 void LogicalOpRtoR(x86MMXRegType to, x86MMXRegType from, int op)
 {
--- x86/iCore.h.old	2006-06-20 15:28:14 +0900
+++ x86/iCore.h	2006-08-18 15:57:43 +0900
@@ -19,7 +19,7 @@
 #ifndef _PCSX2_CORE_RECOMPILER_
 #define _PCSX2_CORE_RECOMPILER_
 
-#include "ivumicro.h"
+#include "iVUmicro.h"
 
 // used to keep block information
 #define BLOCKTYPE_STARTPC	4		// startpc offset
@@ -32,7 +32,9 @@
 	u32 startpc;
 } BASEBLOCK;
 
+#ifndef __LINUX__
 C_ASSERT( sizeof(BASEBLOCK) == 8 );
+#endif
 
 // extra block info (only valid for start of fn)
 typedef struct _BASEBLOCKEX
@@ -96,8 +98,6 @@
 void _eeSetLoadStoreReg(int gprreg, u32 offset, int x86reg);
 int _eeGeLoadStoreReg(int gprreg, int* poffset);
 
-void recReset();
-
 // when using mmx/xmm regs, use; 0 is load
 // freezes no matter the state
 void FreezeMMXRegs_(int save);
@@ -413,4 +413,4 @@
 
 BASEBLOCKEX** GetAllBaseBlocks(int* pnum, int cpu);
 
-#endif
\ No newline at end of file
+#endif
--- x86/iFPU.c.old	2006-07-04 21:08:30 +0900
+++ x86/iFPU.c	2006-08-18 16:26:33 +0900
@@ -643,8 +643,8 @@
 
 FPURECOMPILE_CONSTCODE(DIV_S, XMMINFO_WRITED|XMMINFO_READS|XMMINFO_READT);
 
-__declspec(align(16)) static u32 s_neg[4] = { 0x80000000, 0, 0, 0 };
-__declspec(align(16)) static u32 s_pos[4] = { 0x7fffffff, 0, 0, 0 };
+__ALIGN(16) static u32 s_neg[4] = { 0x80000000, 0, 0, 0 };
+__ALIGN(16) static u32 s_pos[4] = { 0x7fffffff, 0, 0, 0 };
 
 void recSQRT_S_xmm(int info)
 {
--- x86/iMMI.c.old	2006-07-02 07:49:52 +0900
+++ x86/iMMI.c	2006-08-18 16:26:32 +0900
@@ -208,7 +208,7 @@
 	GPR_DEL_CONST(_Rd_);
 }
 
-__declspec(align(16)) static u32 s_CmpMasks[] = {
+__ALIGN(16) static u32 s_CmpMasks[] = {
 	0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff };
 
 void recPMFHL()
@@ -1541,8 +1541,8 @@
 #else
 
 ////////////////////////////////////////////////////
-__declspec(align(16)) int s_MaskHighBitD[4] = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
-__declspec(align(16)) int s_MaskHighBitW[4] = { 0x80008000, 0x80008000, 0x80008000, 0x80008000 };
+__ALIGN(16) int s_MaskHighBitD[4] = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
+__ALIGN(16) int s_MaskHighBitW[4] = { 0x80008000, 0x80008000, 0x80008000, 0x80008000 };
 
 void recPABSW()
 {
@@ -2925,7 +2925,7 @@
 REC_FUNC( PSRAVW, _Rd_ ); 
 
 ////////////////////////////////////////////////////
-__declspec(align(16)) u32 s_tempPINTEH[4] = {0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff };
+__ALIGN(16) u32 s_tempPINTEH[4] = {0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff };
 
 void recPINTEH()
 {
@@ -3334,4 +3334,4 @@
 	//POP32R( EBX );
 }
 
-#endif
\ No newline at end of file
+#endif
--- x86/iR3000A.cpp.old	2006-07-03 23:21:44 +0900
+++ x86/iR3000A.cpp	2006-08-18 18:10:48 +0900
@@ -34,8 +34,10 @@
 #include <assert.h>
 #include <malloc.h>
 
-#if defined(__WIN32__)
+#if defined(__WIN32__)
 #include <windows.h>
+#elif defined(__LINUX__)
+#include "winlinux.h"
 #endif
 
 #include "PS2Etypes.h"
@@ -52,7 +54,7 @@
 #include "ix86/ix86.h"
 
 #include "iCore.h"
-#include "ir3000A.h"
+#include "iR3000A.h"
 #include "PsxCounters.h"
 
 extern u32 psxNextCounter, psxNextsCounter;
@@ -526,7 +528,11 @@
 	ResetBaseBlockEx(1);
 	g_psxMaxRecMem = 0;
 
+#ifdef __GNUC__
+	asm("emms");
+#else
 	__asm emms
+#endif
 
 	recPtr = recMem;
 	psxbranch = 0;
@@ -571,6 +577,17 @@
 #ifdef _DEBUG
 
 		fnptr = (u8*)pblock->pFnptr;
+# ifdef __GNUC__
+	asm("mov %%esi, %0;"
+		    "mov %%esp, %1;"
+		    "sub $8, %1;"
+		    "call *%2;"
+		    "pop %%ebp;"
+		    "mov %0, %%esi"
+		    : "=m" (oldesi), "=m" (s_uSaveESP)
+		    : "r" (fnptr)
+		);
+# else
 		__asm {
 			// save data
 			mov oldesi, esi
@@ -583,10 +600,15 @@
 			pop ebp
 			mov esi, oldesi
 		}
+# endif
 #else
 		pfn = ((R3000AFNPTR)pblock->pFnptr);
 		// use call instead of pfn()
+# ifdef __GNUC__
+		asm("call *%0" : : "r" (pfn));
+# else
 		__asm call pfn
+# endif
 #endif
 	}
 }
@@ -595,15 +617,44 @@
 u32 g_psxlastpc = 0;
 static u32 g_temp;
 
+#ifdef __GNUC__
+/* GCC doesn't support naked functions */
+extern "C" {
+u32 gcc_edxtemp, gcc_esptemp, gcc_ebptemp;  // not static! that would hide the symbols from the asm
+#define MAKE_WRAPPER(func) \
+	asm(".globl " #func ";" \
+	    #func ":" \
+	    "mov %edx, gcc_edxtemp;" \
+	    "mov %esp, gcc_esptemp;" \
+	    "mov %ebp, gcc_ebptemp;" \
+	    "jmp _" #func \
+	); \
+	__attribute__((noreturn)) void func(void);
+#define RESTORE_STACK \
+	asm("mov %0, %%esp; mov %1, %%ebp" : : "m" (gcc_esptemp), "m" (gcc_ebptemp))
+#endif
+
 // jumped to when invalid psxpc address
+#ifdef __GNUC__
+MAKE_WRAPPER(psxDispatcher)
+__attribute__((noreturn)) void _psxDispatcher()
+{
+	RESTORE_STACK;
+	asm("push %0" : : "m" (gcc_edxtemp));
+#else // !__GNUC__
 __declspec(naked,noreturn) void psxDispatcher()
 {
 	// EDX contains the current psxpc to jump to, stack contains the jump addr to modify
 	__asm push edx
+#endif // __GNUC__
 
 	// calc PSX_GETBLOCK
 	s_pDispatchBlock = PSX_GETBLOCK(psxRegs.pc);
 	
+#ifdef __GNUC__
+	if (psxRegs.pc != s_pDispatchBlock->startpc)
+		recRecompile(psxRegs.pc);
+#else
 	__asm {
 		mov eax, s_pDispatchBlock
 
@@ -621,9 +672,14 @@
 CheckPtr:
 		mov eax, dword ptr [eax]
 	}
+#endif
 
 #ifdef _DEBUG
+# ifdef __GNUC__
+	g_temp = *((u32 *)s_pDispatchBlock);
+# else
 	__asm mov g_temp, eax
+# endif
 	assert( g_temp );
 #endif
 
@@ -635,6 +691,18 @@
 //		mov ecx, psxRegs.pc
 //		mov dword ptr [eax+1], ecx
 //	}
+#ifdef __GNUC__
+	asm("mov %%eax, %%edx;"
+	    "pop %%ecx;"
+	    "sub %%ecx, %%edx;"
+	    "sub $4, %%edx;"
+	    "mov %%edx, (%%ecx);"
+	    "call *%%eax"
+	    : /* no outputs */
+	    : "a" (s_pDispatchBlock->pFnptr)
+	    : "ecx"
+	);
+#else
 	__asm {
 		and eax, 0x0fffffff
 		mov edx, eax
@@ -645,13 +713,23 @@
 
 		jmp eax
 	}
+#endif
 }
 
+#ifdef __GNUC__
+MAKE_WRAPPER(psxDispatcherClear)
+__attribute__((noreturn)) void _psxDispatcherClear()
+{
+	RESTORE_STACK;
+	psxRegs.pc = gcc_edxtemp;
+	asm("push %0" : : "m" (gcc_edxtemp));
+#else // !__GNUC__
 __declspec(naked,noreturn) void psxDispatcherClear()
 {
 	// EDX contains the current psxpc
 	__asm mov psxRegs.pc, edx
 	__asm push edx
+#endif // __GNUC__
 
 	// calc PSX_GETBLOCK
 	s_pDispatchBlock = PSX_GETBLOCK(psxRegs.pc);
@@ -660,6 +738,14 @@
 		assert( s_pDispatchBlock->pFnptr != 0 );
 
 		// already modded the code, jump to the new place
+#ifdef __GNUC__
+		asm("pop %%edx;"
+		    "add $4, %%esp;"
+		    "call *%0"
+		    : /* no outputs */
+		    : "a" (s_pDispatchBlock->pFnptr)
+		);
+#else
 		__asm {
 			pop edx
 			add esp, 4 // ignore stack
@@ -668,8 +754,22 @@
 			and eax, 0x0fffffff
 			jmp eax
 		}
+#endif
 	}
 
+#ifdef __GNUC__
+	asm("call recRecompile; add $4, %%esp;" : : );
+	asm("pop %%ecx;"
+	    "movb $0xE9, (%%ecx);"
+	    "mov %%eax, %%edx;"
+	    "sub %%ecx, %%edx;"
+	    "sub $5, %%ecx;"
+	    "mov %%edx, 1(%%ecx);"
+	    "jmp *%%eax;"
+	    : /* no outputs */
+	    : "a" (s_pDispatchBlock->pFnptr)
+	);
+#else // !__GNUC__
 	__asm {
 		call recRecompile
 		add esp, 4 // pop old param
@@ -687,9 +787,25 @@
 
 		jmp eax
 	}
+#endif // __GNUC__
 }
 
 // called when jumping to variable psxpc address
+#ifdef __GNUC__
+
+MAKE_WRAPPER(psxDispatcherReg)
+__attribute__((noreturn)) void _psxDispatcherReg()
+{
+	BASEBLOCK* p = (BASEBLOCK*)(psxRecLUT[psxRegs.pc>>16] + (psxRegs.pc & 0xFFFC));
+	if (psxRegs.pc != p->startpc)
+		recRecompile(psxRegs.pc);
+	asm("jmp *%%eax" : : "a" (p->pFnptr));
+}
+
+} // extern "C"
+
+#else  // !__GNUC__
+
 __declspec(naked,noreturn) void psxDispatcherReg()
 {
 	__asm {
@@ -742,6 +858,8 @@
 	}
 }
 
+#endif  // __GNUC__
+
 static void recClear(u32 Addr, u32 Size)
 {
 	u32 i;
@@ -774,8 +892,13 @@
 	int lastdelay;
 
 	// necessary since recompiler doesn't call femms/emms
+#ifdef __GNUC__
+	if (cpucaps.has3DNOWInstructionExtensions) asm("femms");
+	else asm("emms");
+#else
 	if (cpucaps.has3DNOWInstructionExtensions) __asm femms
 	else __asm emms
+#endif
 		
 	assert( p != NULL );
 
@@ -910,7 +1033,11 @@
 {
 	int pctemp;
 
+#ifdef __GNUC__
+	asm("mov %%eax, %0" : "=r" (pctemp) : : "eax");
+#else
 	__asm mov pctemp, eax
+#endif
 	SysPrintf("iop code changed! %x\n", pctemp);
 }
 
@@ -1043,7 +1170,7 @@
 void iDumpPsxRegisters(u32 startpc, u32 temp)
 {
 	int i;
-	char* pstr = temp ? "t" : "";
+	const char* pstr = temp ? "t" : "";
 
 	__Log("%spsxreg: %x %x\n", pstr, startpc, psxRegs.interrupt);
 	for(i = 0; i < 34; i+=2) __Log("%spsx%d: %x %x\n", pstr, i, psxRegs.GPR.r[i], psxRegs.GPR.r[i+1]);
@@ -1368,4 +1495,4 @@
 	recShutdown
 };
 
-#endif
\ No newline at end of file
+#endif
--- x86/iR5900.c.old	2006-07-03 23:20:02 +0900
+++ x86/iR5900.c	2006-08-18 18:10:01 +0900
@@ -1447,7 +1447,11 @@
 						// changing the rounding mode to 0x0000 or 0x4000 totally kills gitaroo
 						// so... grandia III wins
 
+#ifdef __GNUC__
+	asm("ldmxcsr %0" : : "m" (g_sseMXCSR));
+#else
 	__asm ldmxcsr g_sseMXCSR // set the new sse control
+#endif
 	g_sseVUMXCSR = g_sseMXCSR|0x6000;
 }
 
@@ -1504,6 +1508,13 @@
 	memset(recMem, 0xcd, 0x00c00000);
 	memset(recStack, 0, RECSTACK_SIZE);
 
+#ifdef __GNUC__
+	/* Is there any reason we don't just call CPUID to check SSE3? --AC */
+	asm("cpuid; and $1,%%ecx"
+	    : "=c" (cpucaps.hasStreamingSIMD3Extensions)  // store ECX here
+	    : "a" (1)  // load 1 into EAX
+	);
+#else // !__GNUC__
 	// SSE3 detection, manually create the code
 	x86SetPtr(recMem);
 	SSE3_MOVSLDUP_XMM_to_XMM(XMM0, XMM0);
@@ -1521,6 +1532,7 @@
 		install_my_handler();
 #endif
 	}
+#endif // __GNUC__
 
 	SysPrintf( "x86Init: \n" );
 	SysPrintf( "\tCPU vender name =  %s\n", cpuinfo.x86ID );
@@ -1563,7 +1575,7 @@
 }
 
 ////////////////////////////////////////////////////
-void recReset( void ) {
+static void recReset( void ) {
 #ifdef PCSX2_DEVBUILD
 	SysPrintf("EE Recompiler data reset\n");
 #endif
@@ -1577,7 +1589,11 @@
 	if( s_pInstCache ) memset( s_pInstCache, 0, sizeof(EEINST)*s_nInstCacheSize );
 	ResetBaseBlockEx(0);
 
+#ifdef __GNUC__
+	asm("emms" : : : "memory");
+#else
 	__asm emms
+#endif
 
 #ifdef _DEBUG
 	// don't clear since save states won't work
@@ -1640,6 +1656,18 @@
 	// skip the POPs
 #ifdef _DEBUG
 	fnptr = (u8*)pblock->pFnptr;
+# ifdef __GNUC__
+	asm("mov %%esi, %0;"
+	    "mov %%esp, %1;"
+	    "sub $8, %1;"
+	    "mov %%ebp, %2;"
+	    "call *%3;"
+	    "pop %%ebp;"
+	    "mov %0, %%esi"
+	    : "=m" (oldesi), "=m" (s_uSaveESP), "=m" (s_uSaveEBP)
+	    : "r" (fnptr)
+	);
+# else
 	__asm {
 		// save data
 		mov oldesi, esi
@@ -1653,11 +1681,16 @@
 		pop ebp
 		mov esi, oldesi
 	}
+# endif
 #else
-	pfn = ((R5900FNPTR)pblock->pFnptr);
+	pfn = ((R5900FNPTR)(u32)pblock->pFnptr);
 	// use call instead of pfn()
+# ifdef __GNUC__
+	asm("call *%0" : : "r" (pfn));
+# else
 	//__asm mov s_uSaveEBP, ebp
 	__asm call pfn
+# endif
 
 #endif
 
@@ -1686,15 +1719,43 @@
 u32 g_lastpc = 0;
 static u32 g_temp;
 
+#ifdef __GNUC__
+/* GCC doesn't support naked functions */
+u32 gcc_edxtemp, gcc_esptemp, gcc_ebptemp;  // not static! that would hide the symbols from the asm
+#define MAKE_WRAPPER(func) \
+	asm(".globl " #func ";" \
+	    #func ":" \
+	    "mov %edx, gcc_edxtemp;" \
+	    "mov %esp, gcc_esptemp;" \
+	    "mov %ebp, gcc_ebptemp;" \
+	    "jmp _" #func \
+	); \
+	__attribute__((noreturn)) void func(void);
+#define RESTORE_STACK \
+	asm("mov %0, %%esp; mov %1, %%ebp" : : "m" (gcc_esptemp), "m" (gcc_ebptemp))
+#endif
+
 // jumped to when invalid pc address
+#ifdef __GNUC__
+MAKE_WRAPPER(Dispatcher)
+__attribute__((noreturn)) void _Dispatcher()
+{
+	RESTORE_STACK;
+	asm("push %0" : : "m" (gcc_edxtemp));
+#else // !__GNUC__
 __declspec(naked,noreturn) void Dispatcher()
 {
 	// EDX contains the current pc to jump to, stack contains the jump addr to modify
 	__asm push edx
+#endif // __GNUC__
 
 	// calc PC_GETBLOCK
 	s_pDispatchBlock = PC_GETBLOCK(cpuRegs.pc);
 	
+#ifdef __GNUC__
+	if (cpuRegs.pc != s_pDispatchBlock->startpc)
+		recRecompile(cpuRegs.pc);
+#else
 	__asm {
 		mov eax, s_pDispatchBlock
 
@@ -1712,9 +1773,14 @@
 CheckPtr:
 		mov eax, dword ptr [eax]
 	}
+#endif
 
 #ifdef _DEBUG
+# ifdef __GNUC__
+	g_temp = *((u32 *)s_pDispatchBlock);
+# else
 	__asm mov g_temp, eax
+# endif
 	assert( g_temp );
 #endif
 
@@ -1726,6 +1792,18 @@
 //		mov ecx, cpuRegs.pc
 //		mov dword ptr [eax+1], ecx
 //	}
+#ifdef __GNUC__
+	asm("mov %%eax, %%edx;"
+	    "pop %%ecx;"
+	    "sub %%ecx, %%edx;"
+	    "sub $4, %%edx;"
+	    "mov %%edx, (%%ecx);"
+	    "call *%%eax"
+	    : /* no outputs */
+	    : "a" (s_pDispatchBlock->pFnptr)
+	    : "ecx"
+	);
+#else
 	__asm {
 		and eax, 0x0fffffff
 		mov edx, eax
@@ -1736,13 +1814,23 @@
 
 		jmp eax
 	}
+#endif
 }
 
+#ifdef __GNUC__
+MAKE_WRAPPER(DispatcherClear)
+__attribute__((noreturn)) void _DispatcherClear()
+{
+	RESTORE_STACK;
+	cpuRegs.pc = gcc_edxtemp;
+	asm("push %0" : : "m" (gcc_edxtemp));
+#else // !__GNUC__
 __declspec(naked,noreturn) void DispatcherClear()
 {
 	// EDX contains the current pc
 	__asm mov cpuRegs.pc, edx
 	__asm push edx
+#endif // __GNUC__
 
 	// calc PC_GETBLOCK
 	s_pDispatchBlock = PC_GETBLOCK(cpuRegs.pc);
@@ -1751,6 +1839,14 @@
 		assert( s_pDispatchBlock->pFnptr != 0 );
 
 		// already modded the code, jump to the new place
+#ifdef __GNUC__
+		asm("pop %%edx;"
+		    "add $4, %%esp;"
+		    "call *%0"
+		    : /* no outputs */
+		    : "a" (s_pDispatchBlock->pFnptr)
+		);
+#else
 		__asm {
 			pop edx
 			add esp, 4 // ignore stack
@@ -1759,8 +1855,22 @@
 			and eax, 0x0fffffff
 			jmp eax
 		}
+#endif
 	}
 
+#ifdef __GNUC__
+	asm("call recRecompile; add $4, %%esp;" : : );
+	asm("pop %%ecx;"
+	    "movb $0xE9, (%%ecx);"
+	    "mov %%eax, %%edx;"
+	    "sub %%ecx, %%edx;"
+	    "sub $5, %%ecx;"
+	    "mov %%edx, 1(%%ecx);"
+	    "jmp *%%eax;"
+	    : /* no outputs */
+	    : "a" (s_pDispatchBlock->pFnptr)
+	);
+#else // !__GNUC__
 	__asm {
 		call recRecompile
 		add esp, 4 // pop old param
@@ -1778,9 +1888,23 @@
 
 		jmp eax
 	}
+#endif // __GNUC__
 }
 
 // called when jumping to variable pc address
+#ifdef __GNUC__
+
+MAKE_WRAPPER(DispatcherReg)
+__attribute__((noreturn)) void _DispatcherReg()
+{
+	BASEBLOCK* p = (BASEBLOCK*)(recLUT[cpuRegs.pc>>16] + (cpuRegs.pc & 0xFFFC));
+	if (cpuRegs.pc != p->startpc)
+		recRecompile(cpuRegs.pc);
+	asm("jmp *%%eax" : : "a" (p->pFnptr));
+}
+
+#else  // !__GNUC__
+
 __declspec(naked,noreturn) void DispatcherReg()
 {
 	__asm {
@@ -1833,6 +1957,8 @@
 	}
 }
 
+#endif  // __GNUC__
+
 ////////////////////////////////////////////////////
 void recClear64(BASEBLOCK* p)
 {
@@ -1869,8 +1995,13 @@
 	int lastdelay;
 
 	// necessary since recompiler doesn't call femms/emms
+#ifdef __GNUC__
+	if (cpucaps.has3DNOWInstructionExtensions) asm("femms");
+	else asm("emms");
+#else
 	if (cpucaps.has3DNOWInstructionExtensions) __asm femms
 	else __asm emms
+#endif
 		
 	assert( p != NULL );
 
@@ -1883,13 +2014,13 @@
 	assert( p->pFnptr != 0 );
 	assert( p->startpc );
 
-	x86Ptr = (s8*)p->pFnptr;
+	x86Ptr = (s8*)(u32)p->pFnptr;
 
 	// there is a small problem: mem can be ored with 0xa<<28 or 0x8<<28, and don't know which
 	MOV32ItoR(EDX, p->startpc);
 	PUSH32I((u32)x86Ptr); // will be replaced by JMP32
 	JMP32((u32)DispatcherClear - ( (u32)x86Ptr + 5 ));
-	assert( x86Ptr == (s8*)p->pFnptr + EE_MIN_BLOCK_BYTES );
+	assert( x86Ptr == (s8*)(u32)p->pFnptr + EE_MIN_BLOCK_BYTES );
 
 	pstart = PC_GETBLOCK(p->startpc);
 	pexblock = PC_GETBLOCKEX(pstart);
@@ -2291,7 +2422,11 @@
 {
 	int pctemp;
 
+#ifdef __GNUC__
+	asm("mov %%eax, %0" : "=r" (pctemp) : : "eax");
+#else
 	__asm mov pctemp, eax
+#endif
 	SysPrintf("code changed! %x\n", pctemp);
 	assert(0);
 }
@@ -2485,6 +2620,7 @@
 	_clearNeededXMMregs();
 }
 
+#ifndef __GNUC__  // not used? --AC
 __declspec(naked) void iDummyBlock()
 {
 //	g_lastpc = cpuRegs.pc;
@@ -2504,9 +2640,10 @@
 		jmp DispatcherReg
 	}
 }
+#endif
 
 ////////////////////////////////////////////////////
-#include "r3000a.h"
+#include "R3000A.h"
 #include "PsxCounters.h"
 extern tIPU_BP g_BP;
 
--- x86/iVUmicro.c.old	2006-07-04 21:08:56 +0900
+++ x86/iVUmicro.c	2006-08-18 16:26:30 +0900
@@ -80,13 +80,13 @@
 
 #define _X_Y_Z_W  ((( VU->code >> 21 ) & 0xF ) )
 
-__declspec(align(16)) float recMult_float_to_int4[4] = { 16.0, 16.0, 16.0, 16.0 };
-__declspec(align(16)) float recMult_float_to_int12[4] = { 4096.0, 4096.0, 4096.0, 4096.0 };
-__declspec(align(16)) float recMult_float_to_int15[4] = { 32768.0, 32768.0, 32768.0, 32768.0 };
-
-__declspec(align(16)) float recMult_int_to_float4[4] = { 0.0625f, 0.0625f, 0.0625f, 0.0625f };
-__declspec(align(16)) float recMult_int_to_float12[4] = { 0.000244140625, 0.000244140625, 0.000244140625, 0.000244140625 };
-__declspec(align(16)) float recMult_int_to_float15[4] = { 0.000030517578125, 0.000030517578125, 0.000030517578125, 0.000030517578125 };
+__ALIGN(16) float recMult_float_to_int4[4] = { 16.0, 16.0, 16.0, 16.0 };
+__ALIGN(16) float recMult_float_to_int12[4] = { 4096.0, 4096.0, 4096.0, 4096.0 };
+__ALIGN(16) float recMult_float_to_int15[4] = { 32768.0, 32768.0, 32768.0, 32768.0 };
+
+__ALIGN(16) float recMult_int_to_float4[4] = { 0.0625f, 0.0625f, 0.0625f, 0.0625f };
+__ALIGN(16) float recMult_int_to_float12[4] = { 0.000244140625, 0.000244140625, 0.000244140625, 0.000244140625 };
+__ALIGN(16) float recMult_int_to_float15[4] = { 0.000030517578125, 0.000030517578125, 0.000030517578125, 0.000030517578125 };
 static s32 bpc;
 _VURegsNum* g_VUregs = NULL;
 u8 g_MACFlagTransform[256] = {0}; // used to flip xyzw bits
@@ -776,21 +776,21 @@
 	return t1reg;
 }
 
-__declspec(align(16)) u32 g_minvals[4] = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff};
-__declspec(align(16)) u32 g_maxvals[4] = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff};
+__ALIGN(16) u32 g_minvals[4] = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff};
+__ALIGN(16) u32 g_maxvals[4] = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff};
 
-static __declspec(align(16)) int const_clip[] = {
+static __ALIGN(16) int const_clip[] = {
 	0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
 	0x80000000, 0x80000000, 0x80000000, 0x80000000 };
 
-static __declspec(align(16)) u32 s_FloatMinMax[] = {
+static __ALIGN(16) u32 s_FloatMinMax[] = {
 	0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff,
 	0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff,
 	0,			0,			0,			0 };
 
-static __declspec(align(16)) float s_fones[] = { 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f };
-static __declspec(align(16)) u32 s_mask[] = {0x7fffff, 0x7fffff, 0x7fffff, 0x7fffff };
-static __declspec(align(16)) u32 s_expmask[] = {0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000};
+static __ALIGN(16) float s_fones[] = { 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f };
+static __ALIGN(16) u32 s_mask[] = {0x7fffff, 0x7fffff, 0x7fffff, 0x7fffff };
+static __ALIGN(16) u32 s_expmask[] = {0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000};
 
 void CheckForOverflowSS_(int fdreg, int t0reg)
 {
@@ -942,7 +942,7 @@
 /*   VU Upper instructions    */
 /******************************/
 
-static __declspec(align(16)) int const_abs_table[16][4] = 
+static __ALIGN(16) int const_abs_table[16][4] = 
 {
    { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff },
    { 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff },
@@ -977,7 +977,7 @@
 	}
 }
 
-__declspec(align(16)) float s_two[4] = {0,0,0,2};
+__ALIGN(16) float s_two[4] = {0,0,0,2};
 
 void recVUMI_ADD(VURegs *VU, int info)
 {
@@ -1369,7 +1369,7 @@
 	if( addr == VU_REGQ_ADDR ) CheckForOverflow(info, EEREC_D);
 }
 
-static __declspec(align(16)) s_unaryminus[4] = {0x80000000, 0, 0, 0};
+static __ALIGN(16) s_unaryminus[4] = {0x80000000, 0, 0, 0};
 
 void recVUMI_SUB_xyzw(VURegs *VU, int xyzw, int info)
 {
@@ -4173,7 +4173,7 @@
 	}
 }
 
-static __declspec(align(16)) float s_tempmem[4];
+static __ALIGN(16) float s_tempmem[4];
 
 void recVUMI_WAITP(VURegs *VU, int info)
 {
--- x86/iVUzerorec.cpp.old	2006-07-02 07:53:22 +0900
+++ x86/iVUzerorec.cpp	2006-08-18 16:26:28 +0900
@@ -2604,7 +2604,7 @@
 
 void VuInstruction::Recompile(list<VuInstruction>::const_iterator& itinst, u32 vuxyz)
 {
-	__declspec(align(16)) static VECTOR _VF, _VFc;
+	__ALIGN(16) static VECTOR _VF, _VFc;
 	u32 *ptr;
 	u8* pjmp;
 	int vfregstore=0, viregstore=0;
--- x86/ix86/ix86_sse.c.old	2006-07-04 21:08:26 +0900
+++ x86/ix86/ix86_sse.c	2006-08-18 16:21:25 +0900
@@ -1,7 +1,7 @@
 
 #include "ix86.h"
-__declspec(align(16)) unsigned int p[4],p2[4];
-__declspec(align(16)) float f[4];
+__ALIGN(16) unsigned int p[4],p2[4];
+__ALIGN(16) float f[4];
 
 
 XMMSSEType g_xmmtypes[XMMREGS] = {0};
######## end Linux changes
######## begin warning fixes
--- Interpreter.c.old	2006-07-02 07:51:30 +0900
+++ Interpreter.c	2006-08-18 16:36:47 +0900
@@ -528,8 +528,8 @@
 	}
 }
 
-u64 LDL_MASK[8] = { 0x00ffffffffffffff, 0x0000ffffffffffff, 0x000000ffffffffff, 0x00000000ffffffff, 
-					0x0000000000ffffff, 0x000000000000ffff, 0x00000000000000ff, 0x0000000000000000 };
+u64 LDL_MASK[8] = { 0x00ffffffffffffffULL, 0x0000ffffffffffffULL, 0x000000ffffffffffULL, 0x00000000ffffffffULL,
+					0x0000000000ffffffULL, 0x000000000000ffffULL, 0x00000000000000ffULL, 0x0000000000000000ULL };
 u32 LDL_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 };
 
 void LDL() {
@@ -543,8 +543,8 @@
 								(mem << LDL_SHIFT[shift]);
 }
 
-u64 LDR_MASK[8] = { 0x0000000000000000, 0xff00000000000000, 0xffff000000000000, 0xffffff0000000000,
-					0xffffffff00000000, 0xffffffffff000000, 0xffffffffffff0000, 0xffffffffffffff00 };
+u64 LDR_MASK[8] = { 0x0000000000000000ULL, 0xff00000000000000ULL, 0xffff000000000000ULL, 0xffffff0000000000ULL,
+					0xffffffff00000000ULL, 0xffffffffff000000ULL, 0xffffffffffff0000ULL, 0xffffffffffffff00ULL };
 u32 LDR_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 };
 
 void LDR() {  
@@ -645,8 +645,8 @@
     memWrite64(addr,cpuRegs.GPR.r[_Rt_].UD[0]); 
 }
 
-u64 SDL_MASK[8] = { 0xffffffffffffff00, 0xffffffffffff0000, 0xffffffffff000000, 0xffffffff00000000, 
-					0xffffff0000000000, 0xffff000000000000, 0xff00000000000000, 0x0000000000000000 };
+u64 SDL_MASK[8] = { 0xffffffffffffff00ULL, 0xffffffffffff0000ULL, 0xffffffffff000000ULL, 0xffffffff00000000ULL,
+					0xffffff0000000000ULL, 0xffff000000000000ULL, 0xff00000000000000ULL, 0x0000000000000000ULL };
 u32 SDL_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 };
 
 void SDL() {
@@ -660,8 +660,8 @@
 		      ( mem & SDL_MASK[shift]) );
 }
 
-u64 SDR_MASK[8] = { 0x0000000000000000, 0x00000000000000ff, 0x000000000000ffff, 0x0000000000ffffff,
-					0x00000000ffffffff, 0x000000ffffffffff, 0x0000ffffffffffff, 0x00ffffffffffffff };
+u64 SDR_MASK[8] = { 0x0000000000000000ULL, 0x00000000000000ffULL, 0x000000000000ffffULL, 0x0000000000ffffffULL,
+					0x00000000ffffffffULL, 0x000000ffffffffffULL, 0x0000ffffffffffffULL, 0x00ffffffffffffffULL };
 u32 SDR_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 };
 
 void SDR() {
--- MMI.c.old	2006-06-25 12:59:48 +0900
+++ MMI.c	2006-08-18 17:54:52 +0900
@@ -191,19 +191,19 @@
 		case 0x02: // SLW
 			{
 				u64 TempU64 = ((u64)cpuRegs.HI.UL[0] << 32) | (u64)cpuRegs.LO.UL[0];
-				if (TempU64 >= 0x000000007fffffff) {
-					cpuRegs.GPR.r[_Rd_].UD[0] = 0x000000007fffffff;
-				} else if (TempU64 <= 0xffffffff80000000) {
-					cpuRegs.GPR.r[_Rd_].UD[0] = 0xffffffff80000000;
+				if (TempU64 >= 0x000000007fffffffULL) {
+					cpuRegs.GPR.r[_Rd_].UD[0] = 0x000000007fffffffULL;
+				} else if (TempU64 <= 0xffffffff80000000ULL) {
+					cpuRegs.GPR.r[_Rd_].UD[0] = 0xffffffff80000000ULL;
 				} else {
 					cpuRegs.GPR.r[_Rd_].UD[0] = (s64)cpuRegs.LO.SL[0];
 				}
 
 				TempU64 = ((u64)cpuRegs.HI.UL[2] << 32) | (u64)cpuRegs.LO.UL[2];
-				if (TempU64 >= 0x000000007fffffff) {
-					cpuRegs.GPR.r[_Rd_].UD[1] = 0x000000007fffffff;
-				} else if (TempU64 <= 0xffffffff80000000) {
-					cpuRegs.GPR.r[_Rd_].UD[1] = 0xffffffff80000000;
+				if (TempU64 >= 0x000000007fffffffULL) {
+					cpuRegs.GPR.r[_Rd_].UD[1] = 0x000000007fffffffULL;
+				} else if (TempU64 <= 0xffffffff80000000ULL) {
+					cpuRegs.GPR.r[_Rd_].UD[1] = 0xffffffff80000000ULL;
 				} else {
 					cpuRegs.GPR.r[_Rd_].UD[1] = (s64)cpuRegs.LO.SL[2];
 				}
@@ -426,10 +426,10 @@
 
 #define _PADDSW(n) \
     sTemp64 = (s64)cpuRegs.GPR.r[_Rs_].SL[n] + (s64)cpuRegs.GPR.r[_Rt_].SL[n]; \
-    if (sTemp64 > 0x7FFFFFFF) { \
+    if (sTemp64 > 0x7FFFFFFFLL) { \
         cpuRegs.GPR.r[_Rd_].UL[n] = 0x7FFFFFFF; \
     } else \
-    if ((sTemp64 < 0x180000000) && (sTemp64 >= 0x100000000)) { \
+    if ((sTemp64 < 0x180000000LL) && (sTemp64 >= 0x100000000LL)) { \
         cpuRegs.GPR.r[_Rd_].UL[n] = 0x80000000; \
     } else { \
         cpuRegs.GPR.r[_Rd_].UL[n] = (s32)sTemp64; \
@@ -445,10 +445,10 @@
 
 #define _PSUBSW(n) \
     sTemp64 = (s64)cpuRegs.GPR.r[_Rs_].UL[n] - (s64)cpuRegs.GPR.r[_Rt_].UL[n]; \
-    if (sTemp64 >= 0x7FFFFFFF) { \
+    if (sTemp64 >= 0x7FFFFFFFLL) { \
         cpuRegs.GPR.r[_Rd_].UL[n] = 0x7FFFFFFF; \
     } else \
-    if ((sTemp64 < 0x180000000) && (sTemp64 >= 0x100000000)) { \
+    if ((sTemp64 < 0x180000000LL) && (sTemp64 >= 0x100000000LL)) { \
         cpuRegs.GPR.r[_Rd_].UL[n] = 0x80000000; \
     } else { \
         cpuRegs.GPR.r[_Rd_].UL[n] = (s32)sTemp64; \
######## end warning fixes
EOT

/pkg/pcsx2/
