zzogl-pg: Get Windows working again.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2812 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-04-03 11:17:40 +00:00
parent 176c451008
commit 564f443644
3 changed files with 560 additions and 558 deletions

View File

@ -21,6 +21,10 @@
#include "zerogs.h" #include "zerogs.h"
#include "GifTransfer.h" #include "GifTransfer.h"
#ifdef _DEBUG
static int count = 0;
#endif
/*void _GSgifPacket(pathInfo *path, u32 *pMem) // 128bit /*void _GSgifPacket(pathInfo *path, u32 *pMem) // 128bit
{ {
FUNCLOG FUNCLOG
@ -75,9 +79,9 @@ __forceinline void gifTransferLog(int index, u32 *pMem, u32 size)
static int nSaveIndex = 0; static int nSaveIndex = 0;
GS_LOG("%d: p:%d %x\n", nSaveIndex++, index + 1, size); GS_LOG("%d: p:%d %x\n", nSaveIndex++, index + 1, size);
int vals[4] = {0}; int vals[4] = {0};
for(int i = 0; i < size; i++) for(u32 i = 0; i < size; i++)
{ {
for(int j = 0; j < 4; ++j ) for(u32 j = 0; j < 4; ++j )
vals[j] ^= pMem[4*i+j]; vals[j] ^= pMem[4*i+j];
} }
GS_LOG("%x %x %x %x\n", vals[0], vals[1], vals[2], vals[3]); GS_LOG("%x %x %x %x\n", vals[0], vals[1], vals[2], vals[3]);
@ -185,7 +189,7 @@ template<int index> void _GSgifTransfer(u32 *pMem, u32 size)
case GIF_FLG_IMAGE: // FROM_VFRAM case GIF_FLG_IMAGE: // FROM_VFRAM
case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too. case GIF_FLG_IMAGE2: // Used in the DirectX version, so we'll use it here too.
{ {
int len = (int)min(size, path->nloop); int len = min(size, path->nloop);
//ERROR_LOG("GIF_FLG_IMAGE(%d)=%d\n", gs.imageTransfer, len); //ERROR_LOG("GIF_FLG_IMAGE(%d)=%d\n", gs.imageTransfer, len);
switch(gs.imageTransfer) switch(gs.imageTransfer)
@ -503,6 +507,3 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
_GSgifTransfer<2>(pMem, size); _GSgifTransfer<2>(pMem, size);
} }
#endif #endif
#ifdef _DEBUG
static int count = 0;
#endif

View File

@ -1,180 +1,180 @@
/* ZeroGS KOSMOS /* ZeroGS KOSMOS
* Copyright (C) 2005-2006 zerofrog@gmail.com * Copyright (C) 2005-2006 zerofrog@gmail.com
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef GIFTRANSFER_H_INCLUDED #ifndef GIFTRANSFER_H_INCLUDED
#define GIFTRANSFER_H_INCLUDED #define GIFTRANSFER_H_INCLUDED
#include "Regs.h" #include "Regs.h"
#include "Util.h" #include "Util.h"
// If you notice bugs in the newest revisions, you might try disabling this, // If you notice bugs in the newest revisions, you might try disabling this,
// to see if they are related. // to see if they are related.
#define NEW_GIF_TRANSFER #define NEW_GIF_TRANSFER
enum GIF_FLG enum GIF_FLG
{ {
GIF_FLG_PACKED = 0, GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1, GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2, GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3 GIF_FLG_IMAGE2 = 3
}; };
// //
// GIFTag // GIFTag
union GIFTag union GIFTag
{ {
u64 ai64[2]; u64 ai64[2];
u32 ai32[4]; u32 ai32[4];
struct struct
{ {
u32 NLOOP:15; u32 NLOOP:15;
u32 EOP:1; u32 EOP:1;
u32 _PAD1:16; u32 _PAD1:16;
u32 _PAD2:14; u32 _PAD2:14;
u32 PRE:1; u32 PRE:1;
u32 PRIM:11; u32 PRIM:11;
u32 FLG:2; // enum GIF_FLG u32 FLG:2; // enum GIF_FLG
u32 NREG:4; u32 NREG:4;
u64 REGS:64; u64 REGS:64;
}; };
void set(u32 *data) void set(u32 *data)
{ {
for(int i = 0; i <= 3; i++) for(int i = 0; i <= 3; i++)
{ {
ai32[i] = data[i]; ai32[i] = data[i];
} }
} }
GIFTag(u32 *data) GIFTag(u32 *data)
{ {
set(data); set(data);
} }
GIFTag(){ ai64[0] = 0; ai64[1] = 0; } GIFTag(){ ai64[0] = 0; ai64[1] = 0; }
}; };
// EE part. Data transfer packet description // EE part. Data transfer packet description
typedef struct typedef struct
{ {
#ifdef NEW_GIF_TRANSFER #ifdef NEW_GIF_TRANSFER
int mode; u32 mode;
int reg; int reg;
u64 regs; u64 regs;
int nloop; u32 nloop;
int eop; int eop;
int nreg; int nreg;
u32 adonly; u32 adonly;
GIFTag tag; GIFTag tag;
#else #else
int mode; int mode;
int regn; int regn;
u64 regs; u64 regs;
int nloop; int nloop;
int eop; int eop;
int nreg; int nreg;
u32 adonly; u32 adonly;
GIFTag tag; GIFTag tag;
#endif #endif
#ifdef NEW_GIF_TRANSFER #ifdef NEW_GIF_TRANSFER
void setTag(u32 *data) void setTag(u32 *data)
{ {
tag.set(data); tag.set(data);
nloop = tag.NLOOP; nloop = tag.NLOOP;
eop = tag.EOP; eop = tag.EOP;
mode = tag.FLG; mode = tag.FLG;
// Hmm.... // Hmm....
nreg = tag.NREG << 2; nreg = tag.NREG << 2;
if (nreg == 0) nreg = 64; if (nreg == 0) nreg = 64;
regs = tag.REGS; regs = tag.REGS;
reg = 0; reg = 0;
// GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n", // GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n",
// data[3], data[2], data[1], data[0], // data[3], data[2], data[1], data[0],
// path->eop, path->nloop, mode, path->nreg, tag.PRE); // path->eop, path->nloop, mode, path->nreg, tag.PRE);
} }
u32 GetReg() u32 GetReg()
{ {
return (regs >> reg) & 0xf; return (regs >> reg) & 0xf;
} }
bool StepReg() bool StepReg()
{ {
reg += 4; reg += 4;
if (reg == nreg) if (reg == nreg)
{ {
reg = 0; reg = 0;
nloop--; nloop--;
if (nloop == 0) if (nloop == 0)
{ {
return false; return false;
} }
} }
return true; return true;
} }
#else #else
void setTag(u32 *data) void setTag(u32 *data)
{ {
tag.set(data); tag.set(data);
nloop = tag.NLOOP; nloop = tag.NLOOP;
eop = tag.EOP; eop = tag.EOP;
u32 tagpre = tag.PRE; u32 tagpre = tag.PRE;
u32 tagprim = tag.PRIM; u32 tagprim = tag.PRIM;
u32 tagflg = tag.FLG; u32 tagflg = tag.FLG;
// Hmm.... // Hmm....
nreg = tag.NREG << 2; nreg = tag.NREG << 2;
if (nreg == 0) nreg = 64; if (nreg == 0) nreg = 64;
// GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n", // GS_LOG("GIFtag: %8.8lx_%8.8lx_%8.8lx_%8.8lx: EOP=%d, NLOOP=%x, FLG=%x, NREG=%d, PRE=%d\n",
// data[3], data[2], data[1], data[0], // data[3], data[2], data[1], data[0],
// path->eop, path->nloop, tagflg, path->nreg, tagpre); // path->eop, path->nloop, tagflg, path->nreg, tagpre);
mode = tagflg; mode = tagflg;
switch (mode) switch (mode)
{ {
case GIF_FLG_PACKED: case GIF_FLG_PACKED:
regs = *(u64 *)(data+2); regs = *(u64 *)(data+2);
regn = 0; regn = 0;
if (tagpre) GIFRegHandlerPRIM((u32*)&tagprim); if (tagpre) GIFRegHandlerPRIM((u32*)&tagprim);
break; break;
case GIF_FLG_REGLIST: case GIF_FLG_REGLIST:
regs = *(u64 *)(data+2); regs = *(u64 *)(data+2);
regn = 0; regn = 0;
break; break;
} }
} }
#endif #endif
} pathInfo; } pathInfo;
void _GSgifPacket(pathInfo *path, u32 *pMem); void _GSgifPacket(pathInfo *path, u32 *pMem);
void _GSgifRegList(pathInfo *path, u32 *pMem); void _GSgifRegList(pathInfo *path, u32 *pMem);
void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size); void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size);
extern GIFRegHandler g_GIFPackedRegHandlers[]; extern GIFRegHandler g_GIFPackedRegHandlers[];
extern GIFRegHandler g_GIFRegHandlers[]; extern GIFRegHandler g_GIFRegHandlers[];
#endif // GIFTRANSFER_H_INCLUDED #endif // GIFTRANSFER_H_INCLUDED

View File

@ -1,383 +1,384 @@
/* ZeroGS KOSMOS /* ZeroGS KOSMOS
* Copyright (C) 2005-2006 zerofrog@gmail.com * Copyright (C) 2005-2006 zerofrog@gmail.com
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef UTIL_H_INCLUDED #ifndef UTIL_H_INCLUDED
#define UTIL_H_INCLUDED #define UTIL_H_INCLUDED
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
extern HWND GShwnd; extern HWND GShwnd;
#else // linux basic definitions #else // linux basic definitions
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glx.h> #include <GL/glx.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/extensions/xf86vmode.h> #include <X11/extensions/xf86vmode.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <assert.h> #include <assert.h>
#define GSdefs #define GSdefs
#include "PS2Edefs.h" #include "PS2Edefs.h"
// need C definitions -- no mangling please! // need C definitions -- no mangling please!
extern "C" u32 CALLBACK PS2EgetLibType(void); extern "C" u32 CALLBACK PS2EgetLibType(void);
extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type); extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
extern "C" char* CALLBACK PS2EgetLibName(void); extern "C" char* CALLBACK PS2EgetLibName(void);
#include "zerogsmath.h" #include "zerogsmath.h"
#include <assert.h> #include <assert.h>
#include <vector> #include <vector>
#include <string> #include <string>
extern u32 THR_KeyEvent; // value for passing out key events beetwen threads extern u32 THR_KeyEvent; // value for passing out key events beetwen threads
extern bool THR_bShift; extern bool THR_bShift;
extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path extern std::string s_strIniPath; // Air's new (r2361) new constant for ini file path
///////////////////// /////////////////////
// define when releasing // define when releasing
// The only code that uses it is commented out! // The only code that uses it is commented out!
//#define ZEROGS_CACHEDCLEAR // much better performance //#define ZEROGS_CACHEDCLEAR // much better performance
//#define RELEASE_TO_PUBLIC //#define RELEASE_TO_PUBLIC
// fixme - We should use ZEROGS_DEVBUILD to determine devel/debug builds from "public release" builds. // fixme - We should use ZEROGS_DEVBUILD to determine devel/debug builds from "public release" builds.
// Means a lot of search-and-replace though. (air) // Means a lot of search-and-replace though. (air)
#ifdef ZEROGS_DEVBUILD #ifdef ZEROGS_DEVBUILD
#define GS_LOG __Log #define GS_LOG __Log
#else #else
#define GS_LOG 0&& #define GS_LOG 0&&
#endif #endif
#define ERROR_LOG __LogToConsole #define ERROR_LOG __LogToConsole
//Logging for errors that are called often should have a time counter. //Logging for errors that are called often should have a time counter.
#if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC) #if !defined(_MSC_VER) && !defined(HAVE_ALIGNED_MALLOC)
// declare linux equivalents // declare linux equivalents
static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align) static __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
{ {
assert( align < 0x10000 ); assert( align < 0x10000 );
char* p = (char*)malloc(size+align); char* p = (char*)malloc(size+align);
int off = 2+align - ((int)(uptr)(p+2) % align); int off = 2+align - ((int)(uptr)(p+2) % align);
p += off; p += off;
*(u16*)(p-2) = off; *(u16*)(p-2) = off;
return p; return p;
} }
static __forceinline void pcsx2_aligned_free(void* pmem) static __forceinline void pcsx2_aligned_free(void* pmem)
{ {
if( pmem != NULL ) { if( pmem != NULL ) {
char* p = (char*)pmem; char* p = (char*)pmem;
free(p - (int)*(u16*)(p-2)); free(p - (int)*(u16*)(p-2));
} }
} }
#define _aligned_malloc pcsx2_aligned_malloc #define _aligned_malloc pcsx2_aligned_malloc
#define _aligned_free pcsx2_aligned_free #define _aligned_free pcsx2_aligned_free
#endif #include <sys/timeb.h> // ftime(), struct timeb
#include <sys/timeb.h> // ftime(), struct timeb inline unsigned long timeGetTime()
{
inline unsigned long timeGetTime() #ifdef _WIN32
{ _timeb t;
#ifdef _WIN32 _ftime(&t);
_timeb t; #else
_ftime(&t); timeb t;
#else ftime(&t);
timeb t; #endif
ftime(&t);
#endif return (unsigned long)(t.time*1000+t.millitm);
}
return (unsigned long)(t.time*1000+t.millitm);
} struct RECT
{
#define max(a,b) (((a) > (b)) ? (a) : (b)) int left, top;
#define min(a,b) (((a) < (b)) ? (a) : (b)) int right, bottom;
};
struct RECT
{ #endif
int left, top;
int right, bottom; #define max(a,b) (((a) > (b)) ? (a) : (b))
}; #define min(a,b) (((a) < (b)) ? (a) : (b))
typedef struct {
int x, y, w, h; typedef struct {
} Rect; int x, y, w, h;
} Rect;
typedef struct {
int x, y; typedef struct {
} Point; int x, y;
} Point;
typedef struct {
int x0, y0; typedef struct {
int x1, y1; int x0, y0;
} Rect2; int x1, y1;
} Rect2;
typedef struct {
int x, y, c; typedef struct {
} PointC; int x, y, c;
} PointC;
#define GSOPTION_FULLSCREEN 0x2
#define GSOPTION_TGASNAP 0x4 #define GSOPTION_FULLSCREEN 0x2
#define GSOPTION_CAPTUREAVI 0x8 #define GSOPTION_TGASNAP 0x4
#define GSOPTION_CAPTUREAVI 0x8
#define GSOPTION_WINDIMS 0x30
#define GSOPTION_WIN640 0x00 #define GSOPTION_WINDIMS 0x30
#define GSOPTION_WIN800 0x10 #define GSOPTION_WIN640 0x00
#define GSOPTION_WIN1024 0x20 #define GSOPTION_WIN800 0x10
#define GSOPTION_WIN1280 0x30 #define GSOPTION_WIN1024 0x20
#define GSOPTION_WIDESCREEN 0x40 #define GSOPTION_WIN1280 0x30
#define GSOPTION_WIDESCREEN 0x40
#define GSOPTION_WIREFRAME 0x100
#define GSOPTION_LOADED 0x8000 #define GSOPTION_WIREFRAME 0x100
#define GSOPTION_LOADED 0x8000
//Configuration values.
typedef struct //Configuration values.
{ typedef struct
u8 mrtdepth; // write color in render target {
u8 interlace; // intelacing mode 0, 1, 3-off u8 mrtdepth; // write color in render target
u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x, 3 - 8x, 4 - 16x u8 interlace; // intelacing mode 0, 1, 3-off
u8 negaa; // negative aliasing u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x, 3 - 8x, 4 - 16x
u8 bilinear; // set to enable bilinear support. 0 - off, 1 -- on, 2 -- force (use for textures that usually need it) u8 negaa; // negative aliasing
u32 options; // game options -- different hacks. u8 bilinear; // set to enable bilinear support. 0 - off, 1 -- on, 2 -- force (use for textures that usually need it)
u32 gamesettings;// default game settings u32 options; // game options -- different hacks.
int width, height; // View target size, has no impact towards speed u32 gamesettings;// default game settings
bool isWideScreen; // Widescreen support int width, height; // View target size, has no impact towards speed
#ifdef GS_LOG bool isWideScreen; // Widescreen support
u32 log; #ifdef GS_LOG
#endif u32 log;
} GSconf; #endif
} GSconf;
#ifdef __LINUX__
static u32 __attribute__((unused)) lasttime = 0; #ifdef __LINUX__
static u32 __attribute__((unused)) BigTime = 5000; static u32 __attribute__((unused)) lasttime = 0;
static bool __attribute__((unused)) SPAM_PASS; static u32 __attribute__((unused)) BigTime = 5000;
#else static bool __attribute__((unused)) SPAM_PASS;
static u32 lasttime = 0; #else
static u32 BigTime = 5000; static u32 lasttime = 0;
static bool SPAM_PASS; static u32 BigTime = 5000;
#endif static bool SPAM_PASS;
#endif
#define ERROR_LOG_SPAM(text) { \
if( timeGetTime() - lasttime > BigTime ) { \ #define ERROR_LOG_SPAM(text) { \
ERROR_LOG(text); \ if( timeGetTime() - lasttime > BigTime ) { \
lasttime = timeGetTime(); \ ERROR_LOG(text); \
} \ lasttime = timeGetTime(); \
} } \
// The same macro with one-argument substitution. }
#define ERROR_LOG_SPAMA(fmt, value) { \ // The same macro with one-argument substitution.
if( timeGetTime() - lasttime > BigTime ) { \ #define ERROR_LOG_SPAMA(fmt, value) { \
ERROR_LOG(fmt, value); \ if( timeGetTime() - lasttime > BigTime ) { \
lasttime = timeGetTime(); \ ERROR_LOG(fmt, value); \
} \ lasttime = timeGetTime(); \
} } \
}
#define ERROR_LOG_SPAM_TEST(text) {\
if( timeGetTime() - lasttime > BigTime ) { \ #define ERROR_LOG_SPAM_TEST(text) {\
ERROR_LOG(text); \ if( timeGetTime() - lasttime > BigTime ) { \
lasttime = timeGetTime(); \ ERROR_LOG(text); \
SPAM_PASS = true; \ lasttime = timeGetTime(); \
} \ SPAM_PASS = true; \
else \ } \
SPAM_PASS = false; \ else \
} SPAM_PASS = false; \
}
#if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0)) #if DEBUG_PROF
#define FILE_IS_IN_CHECK ((strcmp(__FILE__, "targets.cpp") == 0) || (strcmp(__FILE__, "ZZoglFlush.cpp") == 0))
#define FUNCLOG {\
static bool Was_Here = false; \ #define FUNCLOG {\
static unsigned long int waslasttime = 0; \ static bool Was_Here = false; \
if (!Was_Here && FILE_IS_IN_CHECK) { \ static unsigned long int waslasttime = 0; \
Was_Here = true;\ if (!Was_Here && FILE_IS_IN_CHECK) { \
ERROR_LOG("%s:%d %s\n", __FILE__, __LINE__, __func__); \ Was_Here = true;\
waslasttime = timeGetTime(); \ ERROR_LOG("%s:%d %s\n", __FILE__, __LINE__, __func__); \
} \ waslasttime = timeGetTime(); \
if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \ } \
Was_Here = false; \ if (FILE_IS_IN_CHECK && (timeGetTime() - waslasttime > BigTime )) { \
} \ Was_Here = false; \
} } \
#else }
#define FUNCLOG #else
#endif #define FUNCLOG
#endif
#define DEBUG_LOG printf
#define DEBUG_LOG printf
#ifdef RELEASE_TO_PUBLIC
#define WARN_LOG 0&& #ifdef RELEASE_TO_PUBLIC
#define PRIM_LOG 0&& #define WARN_LOG 0&&
#else #define PRIM_LOG 0&&
#define WARN_LOG printf #else
#define PRIM_LOG if (conf.log & 0x00000010) GS_LOG #define WARN_LOG printf
#endif #define PRIM_LOG if (conf.log & 0x00000010) GS_LOG
#endif
#ifndef GREG_LOG
#define GREG_LOG 0&& #ifndef GREG_LOG
#endif #define GREG_LOG 0&&
#ifndef PRIM_LOG #endif
#define PRIM_LOG 0&& #ifndef PRIM_LOG
#endif #define PRIM_LOG 0&&
#ifndef WARN_LOG #endif
#define WARN_LOG 0&& #ifndef WARN_LOG
#endif #define WARN_LOG 0&&
#endif
#define REG64(name) \
union name \ #define REG64(name) \
{ \ union name \
u64 i64; \ { \
u32 ai32[2]; \ u64 i64; \
struct { \ u32 ai32[2]; \
struct { \
#define REG128(name)\
union name \ #define REG128(name)\
{ \ union name \
u64 ai64[2]; \ { \
u32 ai32[4]; \ u64 ai64[2]; \
struct { \ u32 ai32[4]; \
struct { \
#define REG64_(prefix, name) REG64(prefix##name)
#define REG128_(prefix, name) REG128(prefix##name) #define REG64_(prefix, name) REG64(prefix##name)
#define REG128_(prefix, name) REG128(prefix##name)
#define REG_END }; };
#define REG_END2 }; #define REG_END }; };
#define REG_END2 };
#define REG64_SET(name) \
union name \ #define REG64_SET(name) \
{ \ union name \
u64 i64; \ { \
u32 ai32[2]; \ u64 i64; \
u32 ai32[2]; \
#define REG128_SET(name)\
union name \ #define REG128_SET(name)\
{ \ union name \
u64 ai64[2]; \ { \
u32 ai32[4]; \ u64 ai64[2]; \
u32 ai32[4]; \
#define REG_SET_END };
#define REG_SET_END };
extern FILE *gsLog;
extern FILE *gsLog;
extern void __Log(const char *fmt, ...);
extern void __LogToConsole(const char *fmt, ...); extern void __Log(const char *fmt, ...);
extern void __LogToConsole(const char *fmt, ...);
extern void LoadConfig();
extern void SaveConfig(); extern void LoadConfig();
extern void SaveConfig();
extern void (*GSirq)();
extern void (*GSirq)();
extern void *SysLoadLibrary(char *lib); // Loads Library
extern void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library extern void *SysLoadLibrary(char *lib); // Loads Library
extern char *SysLibError(); // Gets previous error loading sysbols extern void *SysLoadSym(void *lib, char *sym); // Loads Symbol from Library
extern void SysCloseLibrary(void *lib); // Closes Library extern char *SysLibError(); // Gets previous error loading sysbols
extern void SysMessage(const char *fmt, ...); extern void SysCloseLibrary(void *lib); // Closes Library
extern void SysMessage(const char *fmt, ...);
#ifdef __LINUX__
#include "Utilities/MemcpyFast.h" #ifdef __LINUX__
#define memcpy_amd memcpy_fast #include "Utilities/MemcpyFast.h"
#else #define memcpy_amd memcpy_fast
extern "C" void * memcpy_amd(void *dest, const void *src, size_t n); #else
extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n); extern "C" void * memcpy_amd(void *dest, const void *src, size_t n);
#endif extern "C" u8 memcmp_mmx(const void *dest, const void *src, int n);
#endif
template <typename T>
class CInterfacePtr template <typename T>
{ class CInterfacePtr
public: {
inline CInterfacePtr() : ptr(NULL) {} public:
inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if ( ptr != NULL ) ptr->AddRef(); } inline CInterfacePtr() : ptr(NULL) {}
inline ~CInterfacePtr() { if( ptr != NULL ) ptr->Release(); } inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if ( ptr != NULL ) ptr->AddRef(); }
inline ~CInterfacePtr() { if( ptr != NULL ) ptr->Release(); }
inline T* operator* () { assert( ptr != NULL); return *ptr; }
inline T* operator->() { return ptr; } inline T* operator* () { assert( ptr != NULL); return *ptr; }
inline T* get() { return ptr; } inline T* operator->() { return ptr; }
inline T* get() { return ptr; }
inline void release() {
if( ptr != NULL ) { ptr->Release(); ptr = NULL; } inline void release() {
} if( ptr != NULL ) { ptr->Release(); ptr = NULL; }
}
inline operator T*() { return ptr; }
inline operator T*() { return ptr; }
inline bool operator==(T* rhs) { return ptr == rhs; }
inline bool operator!=(T* rhs) { return ptr != rhs; } inline bool operator==(T* rhs) { return ptr == rhs; }
inline bool operator!=(T* rhs) { return ptr != rhs; }
inline CInterfacePtr& operator= (T* newptr) {
if( ptr != NULL ) ptr->Release(); inline CInterfacePtr& operator= (T* newptr) {
ptr = newptr; if( ptr != NULL ) ptr->Release();
ptr = newptr;
if( ptr != NULL ) ptr->AddRef();
return *this; if( ptr != NULL ) ptr->AddRef();
} return *this;
}
private:
T* ptr; private:
}; T* ptr;
};
// IMPORTANT: For every Register there must be an End
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers // IMPORTANT: For every Register there must be an End
void DVProfEnd(u32 dwUserData); void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
void DVProfWrite(char* pfilename, u32 frames = 0); void DVProfEnd(u32 dwUserData);
void DVProfClear(); // clears all the profilers void DVProfWrite(char* pfilename, u32 frames = 0);
void DVProfClear(); // clears all the profilers
#define DVPROFILE
#ifdef DVPROFILE #define DVPROFILE
#ifdef DVPROFILE
class DVProfileFunc
{ class DVProfileFunc
public: {
u32 dwUserData; public:
DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; } u32 dwUserData;
DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); } DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
~DVProfileFunc() { DVProfEnd(dwUserData); } DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
}; ~DVProfileFunc() { DVProfEnd(dwUserData); }
};
#else
#else
class DVProfileFunc
{ class DVProfileFunc
public: {
u32 dwUserData; public:
static __forceinline DVProfileFunc(char* pname) {} u32 dwUserData;
static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { } static __forceinline DVProfileFunc(char* pname) {}
~DVProfileFunc() {} static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
}; ~DVProfileFunc() {}
};
#endif
#endif
#endif // UTIL_H_INCLUDED #endif // UTIL_H_INCLUDED