mirror of https://github.com/PCSX2/pcsx2.git
Changed some GS-related #define macros into more type-safe inline'd functions.
git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@274 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
787316e839
commit
25a67211e8
|
@ -138,7 +138,7 @@ void WriteFIFO(u32 mem, u64 *value) {
|
||||||
data[0] = value[0];
|
data[0] = value[0];
|
||||||
data[1] = value[1];
|
data[1] = value[1];
|
||||||
GSgifTransferDummy(2, (u32*)data, 1);
|
GSgifTransferDummy(2, (u32*)data, 1);
|
||||||
GSRINGBUF_DONECOPY(data, 16);
|
GSRINGBUF_DONECOPY((u8*)data, 16);
|
||||||
|
|
||||||
if( !CHECK_DUALCORE ) {
|
if( !CHECK_DUALCORE ) {
|
||||||
#if defined(_WIN32) && !defined(WIN32_PTHREADS)
|
#if defined(_WIN32) && !defined(WIN32_PTHREADS)
|
||||||
|
|
22
pcsx2/GS.cpp
22
pcsx2/GS.cpp
|
@ -730,13 +730,17 @@ typedef void (*GIFRegHandler)(u32* data);
|
||||||
static GIFRegHandler s_GSHandlers[3] = { GSRegHandlerSIGNAL, GSRegHandlerFINISH, GSRegHandlerLABEL };
|
static GIFRegHandler s_GSHandlers[3] = { GSRegHandlerSIGNAL, GSRegHandlerFINISH, GSRegHandlerLABEL };
|
||||||
extern "C" int Path3transfer;
|
extern "C" int Path3transfer;
|
||||||
|
|
||||||
#define TagPathTransfer /*midnight madness cares because the tag is 5 dwords*/ \
|
/*midnight madness cares because the tag is 5 dwords*/ \
|
||||||
int* psrc = (int*)ptag; \
|
static __forceinline void TagPathTransfer( GIFTAG* ptag, GIFTAG *path )
|
||||||
int* pdst = (int*)&g_path[path]; \
|
{
|
||||||
pdst[0] = psrc[0]; \
|
u32* psrc = (u32*)ptag;
|
||||||
pdst[1] = psrc[1]; \
|
u32* pdst = (u32*)path;
|
||||||
pdst[2] = psrc[2]; \
|
pdst[0] = psrc[0];
|
||||||
|
pdst[1] = psrc[1];
|
||||||
|
pdst[2] = psrc[2];
|
||||||
pdst[3] = psrc[3];
|
pdst[3] = psrc[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// simulates a GIF tag
|
// simulates a GIF tag
|
||||||
u32 GSgifTransferDummy(int path, u32 *pMem, u32 size)
|
u32 GSgifTransferDummy(int path, u32 *pMem, u32 size)
|
||||||
|
@ -827,7 +831,7 @@ u32 GSgifTransferDummy(int path, u32 *pMem, u32 size)
|
||||||
|
|
||||||
if( nloop > 0 ) {
|
if( nloop > 0 ) {
|
||||||
assert(size == 0);
|
assert(size == 0);
|
||||||
TagPathTransfer;
|
TagPathTransfer( ptag, &g_path[path] );
|
||||||
g_path[path].nloop = nloop;
|
g_path[path].nloop = nloop;
|
||||||
g_path[path].curreg = curreg;
|
g_path[path].curreg = curreg;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -865,7 +869,7 @@ u32 GSgifTransferDummy(int path, u32 *pMem, u32 size)
|
||||||
|
|
||||||
if( nloop > 0 ) {
|
if( nloop > 0 ) {
|
||||||
assert(size == 0);
|
assert(size == 0);
|
||||||
TagPathTransfer;
|
TagPathTransfer( ptag, &g_path[path] );
|
||||||
g_path[path].nloop = nloop;
|
g_path[path].nloop = nloop;
|
||||||
g_path[path].curreg = curreg;
|
g_path[path].curreg = curreg;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -878,7 +882,7 @@ u32 GSgifTransferDummy(int path, u32 *pMem, u32 size)
|
||||||
{
|
{
|
||||||
// simulate
|
// simulate
|
||||||
if( (int)size < nloop ) {
|
if( (int)size < nloop ) {
|
||||||
TagPathTransfer;
|
TagPathTransfer( ptag, &g_path[path] );
|
||||||
g_path[path].nloop = nloop-size;
|
g_path[path].nloop = nloop-size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
144
pcsx2/GS.h
144
pcsx2/GS.h
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u32 SIGID;
|
u32 SIGID;
|
||||||
u32 LBLID;
|
u32 LBLID;
|
||||||
} GSRegSIGBLID;
|
} GSRegSIGBLID;
|
||||||
|
|
||||||
#define GSPATH3FIX
|
#define GSPATH3FIX
|
||||||
|
@ -43,21 +43,21 @@ extern u8 g_RealGSMem[0x2000];
|
||||||
#define GSSIGLBLID ((GSRegSIGBLID*)(g_RealGSMem+0x1080))
|
#define GSSIGLBLID ((GSRegSIGBLID*)(g_RealGSMem+0x1080))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GS_RINGBUFFERBASE (u8*)(0x10200000)
|
#define GS_RINGBUFFERBASE (u8*)(0x10200000)
|
||||||
#define GS_RINGBUFFERSIZE 0x00300000 // 3Mb
|
#define GS_RINGBUFFERSIZE 0x00300000 // 3Mb
|
||||||
#define GS_RINGBUFFEREND (u8*)(GS_RINGBUFFERBASE+GS_RINGBUFFERSIZE)
|
#define GS_RINGBUFFEREND (u8*)(GS_RINGBUFFERBASE+GS_RINGBUFFERSIZE)
|
||||||
|
|
||||||
#define GS_RINGTYPE_RESTART 0
|
#define GS_RINGTYPE_RESTART 0
|
||||||
#define GS_RINGTYPE_P1 1
|
#define GS_RINGTYPE_P1 1
|
||||||
#define GS_RINGTYPE_P2 2
|
#define GS_RINGTYPE_P2 2
|
||||||
#define GS_RINGTYPE_P3 3
|
#define GS_RINGTYPE_P3 3
|
||||||
#define GS_RINGTYPE_VSYNC 4
|
#define GS_RINGTYPE_VSYNC 4
|
||||||
#define GS_RINGTYPE_VIFFIFO 5 // GSreadFIFO2
|
#define GS_RINGTYPE_VIFFIFO 5 // GSreadFIFO2
|
||||||
#define GS_RINGTYPE_FRAMESKIP 6
|
#define GS_RINGTYPE_FRAMESKIP 6
|
||||||
#define GS_RINGTYPE_MEMWRITE8 7
|
#define GS_RINGTYPE_MEMWRITE8 7
|
||||||
#define GS_RINGTYPE_MEMWRITE16 8
|
#define GS_RINGTYPE_MEMWRITE16 8
|
||||||
#define GS_RINGTYPE_MEMWRITE32 9
|
#define GS_RINGTYPE_MEMWRITE32 9
|
||||||
#define GS_RINGTYPE_MEMWRITE64 10
|
#define GS_RINGTYPE_MEMWRITE64 10
|
||||||
#define GS_RINGTYPE_SAVE 11
|
#define GS_RINGTYPE_SAVE 11
|
||||||
#define GS_RINGTYPE_LOAD 12
|
#define GS_RINGTYPE_LOAD 12
|
||||||
#define GS_RINGTYPE_RECORD 13
|
#define GS_RINGTYPE_RECORD 13
|
||||||
|
@ -73,34 +73,23 @@ extern u8* g_pGSWritePos;
|
||||||
extern FILE* g_fMTGSWrite, *g_fMTGSRead;
|
extern FILE* g_fMTGSWrite, *g_fMTGSRead;
|
||||||
extern u32 g_MTGSDebug, g_MTGSId;
|
extern u32 g_MTGSDebug, g_MTGSId;
|
||||||
|
|
||||||
#define MTGS_RECWRITE(start, size) { \
|
static __forceinline void MTGS_RECWRITE(const u8 *start, u32 size) {
|
||||||
if( g_MTGSDebug & 1 ) { \
|
if( g_MTGSDebug & 1 ) {
|
||||||
u32* pstart = (u32*)(start); \
|
const u32* pstart = (u32*)(start);
|
||||||
u32 cursize = (u32)(size); \
|
u32 cursize = (size);
|
||||||
fprintf(g_fMTGSWrite, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId); \
|
fprintf(g_fMTGSWrite, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId);
|
||||||
/*while(cursize > 0) { \
|
if( g_MTGSDebug & 2 ) fflush(g_fMTGSWrite);
|
||||||
fprintf(g_fMTGSWrite, "%x %x %x %x\n", pstart[0], pstart[1], pstart[2], pstart[3]); \
|
}
|
||||||
pstart += 4; \
|
}
|
||||||
cursize -= 16; \
|
|
||||||
}*/ \
|
|
||||||
if( g_MTGSDebug & 2 ) fflush(g_fMTGSWrite); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
|
|
||||||
#define MTGS_RECREAD(start, size) { \
|
|
||||||
if( g_MTGSDebug & 1 ) { \
|
|
||||||
u32* pstart = (u32*)(start); \
|
|
||||||
u32 cursize = (u32)(size); \
|
|
||||||
fprintf(g_fMTGSRead, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId); \
|
|
||||||
/*while(cursize > 0) { \
|
|
||||||
fprintf(g_fMTGSRead, "%x %x %x %x\n", pstart[0], pstart[1], pstart[2], pstart[3]); \
|
|
||||||
pstart += 4; \
|
|
||||||
cursize -= 16; \
|
|
||||||
}*/ \
|
|
||||||
if( g_MTGSDebug & 4 ) fflush(g_fMTGSRead); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
|
|
||||||
|
static __forceinline void MTGS_RECREAD( const u8* start, u32 size) {
|
||||||
|
if( g_MTGSDebug & 1 ) {
|
||||||
|
const u32* pstart = (u32*)(start);
|
||||||
|
u32 cursize = (size);
|
||||||
|
fprintf(g_fMTGSRead, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId);
|
||||||
|
if( g_MTGSDebug & 4 ) fflush(g_fMTGSRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define MTGS_RECWRITE 0&&
|
#define MTGS_RECWRITE 0&&
|
||||||
|
@ -109,21 +98,25 @@ extern u32 g_MTGSDebug, g_MTGSId;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mem and size are the ones from GSRingBufCopy
|
// mem and size are the ones from GSRingBufCopy
|
||||||
#define GSRINGBUF_DONECOPY(mem, size) { \
|
static __forceinline void GSRINGBUF_DONECOPY(const u8 *mem, u32 size) {
|
||||||
u8* temp = (u8*)(mem) + (size); \
|
u8* temp = (u8*)(mem) + (size);
|
||||||
assert( temp <= GS_RINGBUFFEREND); \
|
assert( temp <= GS_RINGBUFFEREND);
|
||||||
MTGS_RECWRITE(mem, size); \
|
MTGS_RECWRITE(mem, size);
|
||||||
if( temp == GS_RINGBUFFEREND ) temp = GS_RINGBUFFERBASE; \
|
if( temp == GS_RINGBUFFEREND ) temp = GS_RINGBUFFERBASE;
|
||||||
InterlockedExchangePointer((void**)&g_pGSWritePos, temp); \
|
InterlockedExchangePointer((void**)&g_pGSWritePos, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(WIN32_PTHREADS)
|
#if defined(_WIN32) && !defined(WIN32_PTHREADS)
|
||||||
|
|
||||||
#define GS_SETEVENT() SetEvent(g_hGsEvent)
|
#define GS_SETEVENT() SetEvent(g_hGsEvent)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
extern sem_t g_semGsThread;
|
extern sem_t g_semGsThread;
|
||||||
#define GS_SETEVENT() sem_post(&g_semGsThread)
|
#define GS_SETEVENT() sem_post(&g_semGsThread)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u32 GSgifTransferDummy(int path, u32 *pMem, u32 size);
|
u32 GSgifTransferDummy(int path, u32 *pMem, u32 size);
|
||||||
|
@ -184,56 +177,13 @@ extern int g_SaveGSStream;
|
||||||
extern int g_nLeftGSFrames;
|
extern int g_nLeftGSFrames;
|
||||||
extern gzFile g_fGSSave;
|
extern gzFile g_fGSSave;
|
||||||
|
|
||||||
#define GSGIFTRANSFER1(pMem, addr) { \
|
|
||||||
if( g_SaveGSStream == 2) { \
|
|
||||||
int type = GSRUN_TRANS1; \
|
|
||||||
int size = (0x4000-(addr))/16; \
|
|
||||||
gzwrite(g_fGSSave, &type, sizeof(type)); \
|
|
||||||
gzwrite(g_fGSSave, &size, 4); \
|
|
||||||
gzwrite(g_fGSSave, ((u8*)pMem)+(addr), size*16); \
|
|
||||||
} \
|
|
||||||
GSgifTransfer1(pMem, addr); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GSGIFTRANSFER2(pMem, size) { \
|
|
||||||
if( g_SaveGSStream == 2) { \
|
|
||||||
int type = GSRUN_TRANS2; \
|
|
||||||
int _size = size; \
|
|
||||||
gzwrite(g_fGSSave, &type, sizeof(type)); \
|
|
||||||
gzwrite(g_fGSSave, &_size, 4); \
|
|
||||||
gzwrite(g_fGSSave, pMem, _size*16); \
|
|
||||||
} \
|
|
||||||
GSgifTransfer2(pMem, size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define GSGIFTRANSFER3(pMem, size) { \
|
|
||||||
if( g_SaveGSStream == 2 ) { \
|
|
||||||
int type = GSRUN_TRANS3; \
|
|
||||||
int _size = size; \
|
|
||||||
gzwrite(g_fGSSave, &type, sizeof(type)); \
|
|
||||||
gzwrite(g_fGSSave, &_size, 4); \
|
|
||||||
gzwrite(g_fGSSave, pMem, _size*16); \
|
|
||||||
} \
|
|
||||||
GSgifTransfer3(pMem, size); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GSVSYNC() { \
|
|
||||||
if( g_SaveGSStream == 2 ) { \
|
|
||||||
int type = GSRUN_VSYNC; \
|
|
||||||
gzwrite(g_fGSSave, &type, sizeof(type)); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define GSGIFTRANSFER1(pMem, size) GSgifTransfer1(pMem, size)
|
|
||||||
#define GSGIFTRANSFER2(pMem, size) GSgifTransfer2(pMem, size)
|
|
||||||
#define GSGIFTRANSFER3(pMem, size) GSgifTransfer3(pMem, size)
|
|
||||||
#define GSVSYNC()
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void RunGSState(gzFile f);
|
void RunGSState(gzFile f);
|
||||||
|
|
||||||
#endif
|
extern void GSGIFTRANSFER1(u32 *pMem, u32 addr);
|
||||||
|
extern void GSGIFTRANSFER2(u32 *pMem, u32 addr);
|
||||||
|
extern void GSGIFTRANSFER3(u32 *pMem, u32 addr);
|
||||||
|
extern void GSVSYNC();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -47,6 +47,69 @@
|
||||||
|
|
||||||
extern _GSgifTransfer1 GSgifTransfer1;
|
extern _GSgifTransfer1 GSgifTransfer1;
|
||||||
|
|
||||||
|
#ifdef PCSX2_DEVBUILD
|
||||||
|
|
||||||
|
// These would amke more sense in GS.cpp, but then the legacy "C" files
|
||||||
|
// (like this one!) wouldn't be able to access them (C++ name mangling)
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER1(u32 *pMem, u32 addr) {
|
||||||
|
if( g_SaveGSStream == 2) {
|
||||||
|
u32 type = GSRUN_TRANS1;
|
||||||
|
u32 size = (0x4000-(addr))/16;
|
||||||
|
gzwrite(g_fGSSave, &type, sizeof(type));
|
||||||
|
gzwrite(g_fGSSave, &size, 4);
|
||||||
|
gzwrite(g_fGSSave, ((u8*)pMem)+(addr), size*16);
|
||||||
|
}
|
||||||
|
GSgifTransfer1(pMem, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER2(u32 *pMem, u32 size) {
|
||||||
|
if( g_SaveGSStream == 2) {
|
||||||
|
u32 type = GSRUN_TRANS2;
|
||||||
|
u32 _size = size;
|
||||||
|
gzwrite(g_fGSSave, &type, sizeof(type));
|
||||||
|
gzwrite(g_fGSSave, &_size, 4);
|
||||||
|
gzwrite(g_fGSSave, pMem, _size*16);
|
||||||
|
}
|
||||||
|
GSgifTransfer2(pMem, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER3(u32 *pMem, u32 size) {
|
||||||
|
if( g_SaveGSStream == 2 ) {
|
||||||
|
u32 type = GSRUN_TRANS3;
|
||||||
|
u32 _size = size;
|
||||||
|
gzwrite(g_fGSSave, &type, sizeof(type));
|
||||||
|
gzwrite(g_fGSSave, &_size, 4);
|
||||||
|
gzwrite(g_fGSSave, pMem, _size*16);
|
||||||
|
}
|
||||||
|
GSgifTransfer3(pMem, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSVSYNC(void) {
|
||||||
|
if( g_SaveGSStream == 2 ) {
|
||||||
|
u32 type = GSRUN_VSYNC;
|
||||||
|
gzwrite(g_fGSSave, &type, sizeof(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER1(const u32 *pMem, u32 addr) {
|
||||||
|
GSgifTransfer1(pMem, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER2(u32 *pMem, u32 size) {
|
||||||
|
GSgifTransfer2(pMem, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSGIFTRANSFER3(const u32 *pMem, u32 size) {
|
||||||
|
GSgifTransfer3(pMem, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void GSVSYNC(void) {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int g_VuNanHandling = 0; // for now enable all the time
|
int g_VuNanHandling = 0; // for now enable all the time
|
||||||
|
|
||||||
int vucycle;
|
int vucycle;
|
||||||
|
|
Loading…
Reference in New Issue