Various ZeroGS cleanups. A few things got mirrored from the dx version to the opengl version, and vice-versa. A few defines became inlined functions, and if statements became switch statements...

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@574 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2009-01-10 11:30:47 +00:00 committed by Gregory Hainaut
parent 0c2f86a870
commit 84c7b1bdc3
15 changed files with 774 additions and 766 deletions

View File

@ -70,7 +70,8 @@ struct Vector_16F
/////////////////////
// define when releasing
#define ZEROGS_CACHEDCLEAR // much better performance
// The only code that uses it is commented out!
//#define ZEROGS_CACHEDCLEAR // much better performance
//#define RELEASE_TO_PUBLIC
#if !defined(_RELEASE)
@ -79,6 +80,9 @@ struct Vector_16F
#define GS_LOG 0&&
#endif
#define ERROR_LOG __LogToConsole
#define DEBUG_LOG printf
#ifdef RELEASE_TO_PUBLIC
#define WARN_LOG 0&&
#define PRIM_LOG 0&&
@ -632,8 +636,8 @@ extern GSinternal gs;
extern FILE *gsLog;
void __Log(char *fmt, ...);
void ERROR_LOG(char *fmt, ...);
void __Log(const char *fmt, ...);
void __LogToConsole(const char *fmt, ...);
void LoadConfig();
void SaveConfig();

View File

@ -127,8 +127,7 @@ void SysMessage(char *fmt, ...) {
#endif
#ifdef GS_LOG
void __Log(char *fmt, ...) {
void __Log(const char *fmt, ...) {
va_list list;
if (!conf.log) return;
@ -137,9 +136,8 @@ void __Log(char *fmt, ...) {
vfprintf(gsLog, fmt, list);
va_end(list);
}
#endif
void ERROR_LOG(char *fmt, ...) {
void __LogToConsole(const char *fmt, ...) {
va_list list;
printf("ZeroGS: ");
@ -193,7 +191,7 @@ void CALLBACK GSsetGameCRC(int crc, int options)
break;
}
printf("ZeroGS: Set game options: 0x%8.8x\n", g_GameSettings);
DEBUG_LOG("ZeroGS: Set game options: 0x%8.8x\n", g_GameSettings);
}
void CALLBACK GSsetFrameSkip(int frameskip)
@ -256,7 +254,7 @@ void CALLBACK GSreset() {
gs.q = 1;
}
void CALLBACK GSgifSoftReset(int mask)
void CALLBACK GSgifSoftReset(u32 mask)
{
if( mask & 1 ) memset(&gs.path1, 0, sizeof(gs.path1));
if( mask & 2 ) memset(&gs.path2, 0, sizeof(gs.path2));
@ -283,10 +281,7 @@ s32 CALLBACK GSinit()
#endif
GSreset();
#ifdef GS_LOG
GS_LOG("GSinit ok\n");
#endif
return 0;
}
@ -318,7 +313,7 @@ LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
case WM_ACTIVATE:
if( wParam != WA_INACTIVE ) {
//printf("restoring device\n");
//DEBUG_LOG("restoring device\n");
ZeroGS::Restore();
}
@ -350,9 +345,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
g_GSMultiThreaded = multithread;
#ifdef GS_LOG
GS_LOG("GSopen\n");
#endif
#ifdef _DEBUG
g_hCurrentThread = GetCurrentThread();
@ -389,12 +382,12 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
if( pDsp != NULL )
*(int*)pDsp = (int)GShwnd;
printf("creating zerogs\n");
DEBUG_LOG("creating zerogs\n");
//if (conf.record) recOpen();
if( FAILED(ZeroGS::Create(conf.width, conf.height)) )
return -1;
printf("init zerogs\n");
DEBUG_LOG("initialization successful\n");
if( FAILED(ZeroGS::InitDeviceObjects()) )
return -1;
@ -430,9 +423,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
luPerfFreq.QuadPart = 1;
#endif
#ifdef GS_LOG
GS_LOG("GSopen ok\n");
#endif
gs.path1.mode = 0;
gs.path2.mode = 0;
@ -508,9 +499,7 @@ float fFPS = 0;
void CALLBACK GSvsync(int interlace)
{
#ifdef GS_LOG
GS_LOG("\nGSvsync\n\n");
#endif
static u32 dwTime = timeGetTime();
static int nToNextUpdate = 1;
@ -694,22 +683,21 @@ void CALLBACK GSvsync(int interlace)
}
void GIFtag(pathInfo *path, u32 *data) {
path->tag.nloop = data[0] & 0x7fff;
path->tag.eop = (data[0] >> 15) & 0x1;
u32 tagpre = (data[1] >> 14) & 0x1;
u32 tagprim = (data[1] >> 15) & 0x7ff;
u32 tagflg = (data[1] >> 26) & 0x3;
path->tag.nreg = (data[1] >> 28)<<2;
path->tag.nloop = data[0] & 0x7fff;
path->tag.eop = (data[0] >> 15) & 0x1;
u32 tagpre = (data[1] >> 14) & 0x1;
u32 tagprim = (data[1] >> 15) & 0x7ff;
u32 tagflg = (data[1] >> 26) & 0x3;
path->tag.nreg = (data[1] >> 28)<<2;
if (path->tag.nreg == 0) path->tag.nreg = 64;
gs.q = 1;
#ifdef GS_LOG
// 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],
// path->tag.eop, path->tag.nloop, tagflg, path->tag.nreg, tagpre);
#endif
path->mode = tagflg+1;
@ -759,9 +747,6 @@ static int nPath3Hack = 0;
void CALLBACK GSgetLastTag(u64* ptag)
{
// int mode = s_pLastPath->mode > 0 ? s_pLastPath->mode-1 : 0;
// *(u32*)ptag = s_pLastPath->tag.nloop|(s_pLastPath->tag.eop<<15);
// *((u32*)ptag+1) = (mode<<26)|(s_pLastPath->regn<<28);
*(u32*)ptag = nPath3Hack;
nPath3Hack = 0;
}
@ -785,20 +770,23 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
while(size > 0)
{
//LOG(_T("Transfer(%08x, %d) START\n"), pMem, size);
if(path->tag.nloop == 0) {
if (path->tag.nloop == 0)
{
GIFtag(path, pMem);
pMem+= 4;
size--;
if( (g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop )
if ((g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop)
nPath3Hack = 1;
if( path == &gs.path1 ) {
if (path == &gs.path1)
{
// if too much data, just ignore
if( path->tag.nloop * (path->tag.nreg / 4) > (int)size * (path->mode==2?2:1)) {
if (path->tag.nloop * (path->tag.nreg / 4) > (int)size * (path->mode==2?2:1))
{
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
if( timeGetTime() - lasttime > 5000 )
{
ERROR_LOG("VU1 too much data, ignore if gfx are fine\n");
lasttime = timeGetTime();
}
@ -806,13 +794,16 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
return;
}
if( path->mode == 1 ) {
if (path->mode == 1)
{
// check if 0xb is in any reg, if yes, exit (kh2)
for(int i = 0; i < path->tag.nreg; i += 4) {
if( ((path->regs >> i)&0xf) == 11 ) {
for(int i = 0; i < path->tag.nreg; i += 4)
{
if (((path->regs >> i)&0xf) == 11)
{
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
if( timeGetTime() - lasttime > 5000 )
{
ERROR_LOG("Invalid unpack type\n");
lasttime = timeGetTime();
}
@ -823,11 +814,13 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
}
if(path->tag.nloop == 0 ) {
//bAfter0Tag = 1;
if( path == &gs.path1 ) {
if(path->tag.nloop == 0 )
{
if( path == &gs.path1 )
{
// ffx hack
if( g_GameSettings & GAME_FFXHACK ) {
if( g_GameSettings & GAME_FFXHACK )
{
if( path->tag.eop )
return;
continue;
@ -836,32 +829,19 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
return;
}
if( !path->tag.eop ) {
//printf("contuing from eop\n");
if( !path->tag.eop )
{
//DEBUG_LOG("continuing from eop\n");
continue;
}
break;
}
// else {
// if( bAfter0Tag ) {
// // hack!! if all 0s, then break
// if( pMem[-3] == 0 && pMem[-2] == 0 ) {
// path->tag.nloop = 0;
// return;
// }
// }
// }
}
switch(path->mode) {
case 1: // PACKED
{
// if( path->tag.nreg == 9 && gs.regs == 0x412412412L && gs.primC == 0) {
// // draw 3 points
// }
//__Log("%8.8x%8.8x %d\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
assert( path->tag.nloop > 0 );
for(; size > 0; size--, pMem += 4)
{
@ -870,9 +850,11 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
g_GIFPackedRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn) {
if (path->tag.nreg == path->regn)
{
path->regn = 0;
if( path->tag.nloop-- <= 1 ) {
if( path->tag.nloop-- <= 1 )
{
size--;
pMem += 4;
break;
@ -883,7 +865,7 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
case 2: // REGLIST
{
//__Log("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
//GS_LOG("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
assert( path->tag.nloop > 0 );
size *= 2;
for(; size > 0; pMem+= 2, size--)
@ -891,9 +873,11 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
int reg = (int)((path->regs >> path->regn) & 0xf);
g_GIFRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn) {
if (path->tag.nreg == path->regn)
{
path->regn = 0;
if( path->tag.nloop-- <= 1 ) {
if( path->tag.nloop-- <= 1 )
{
size--;
pMem += 2;
break;
@ -912,9 +896,12 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
{
int process = min((int)size, path->tag.nloop);
if( process > 0 ) {
if( gs.imageTransfer ) ZeroGS::TransferLocalHost(pMem, process);
else ZeroGS::TransferHostLocal(pMem, process*4);
if( process > 0 )
{
if (gs.imageTransfer)
ZeroGS::TransferLocalHost(pMem, process);
else
ZeroGS::TransferHostLocal(pMem, process*4);
path->tag.nloop -= process;
pMem += process*4; size -= process;
@ -923,7 +910,8 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
break;
}
else {
else
{
// simulate
int process = min((int)size, path->tag.nloop);
path->tag.nloop -= process;
@ -933,11 +921,8 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
break;
}
default: // GIF_IMAGE
GS_LOG(_T("*** WARNING **** Unexpected GIFTag flag\n"));
GS_LOG("*** WARNING **** Unexpected GIFTag flag\n");
assert(0);
// ZeroGS::TransferLocalHost(pMem, size);
// pMem+= size*4; path->tag.nloop-= size;
// size = 0; path->mode = 0;
path->tag.nloop = 0;
break;
@ -950,29 +935,15 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size)
{
#ifdef GS_LOG
//GS_LOG("GSgifTransfer2 size = %lx (mode %d, gs.path2.tag.nloop = %d)\n", size, gs.path2.mode, gs.path2.tag.nloop);
#endif
// if(!g_GSMultiThreaded)
// CSR->FINISH = 0;
//DVProfileFunc _pf("Transf2");
//assert( ((u32)pMem & 0xf) == 0 );
_GSgifTransfer(&gs.path2, pMem, size);
}
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
{
#ifdef GS_LOG
//GS_LOG("GSgifTransfer3 size = %lx (mode %d, gs.path3.tag.nloop = %d)\n", size, gs.path3.mode, gs.path3.tag.nloop);
#endif
// if(!g_GSMultiThreaded)
// CSR->FINISH = 0;
//DVProfileFunc _pf("Transf3");
//assert( ((u32)pMem & 0xf) == 0 );
nPath3Hack = 0;
_GSgifTransfer(&gs.path3, pMem, size);
}
@ -982,20 +953,13 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
{
pathInfo *path = &gs.path1;
#ifdef GS_LOG
//GS_LOG("GSgifTransfer1 0x%x (mode %d)\n", addr, path->mode);
#endif
addr &= 0x3fff;
#ifdef _DEBUG
PRIM_LOG("count: %d\n", count);
count++;
// for(int i = addr; i < 0x4000; i += 16 ) {
// u32* mem = (u32*)((u8*)pMem+i);
// PRIM_LOG("%x: %x %x %x %x\n", i, mem[0], mem[1], mem[2], mem[3]);
// }
#endif
gs.path1.tag.nloop = 0;
@ -1006,25 +970,20 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
assert( (addr&0xf) == 0 ); //BUG
gs.path1.tag.nloop = 0;
ERROR_LOG("Transfer1 - 2\n");
//_GSgifTransfer(&gs.path1, (u32*)((u8*)pMem+0x4000-addr), addr/16);
return;
}
}
void CALLBACK GSreadFIFO(u64 *pMem)
{
#ifdef GS_LOG
//GS_LOG("GSreadFIFO\n");
#endif
ZeroGS::TransferLocalHost((u32*)pMem, 1);
}
void CALLBACK GSreadFIFO2(u64 *pMem, int qwc)
{
#ifdef GS_LOG
//GS_LOG("GSreadFIFO2\n");
#endif
ZeroGS::TransferLocalHost((u32*)pMem, qwc);
}
@ -1037,14 +996,14 @@ int CALLBACK GSsetupRecording(int start, void* pData)
if( !ZeroGS::StartCapture() )
return 0;
conf.options |= GSOPTION_CAPTUREAVI;
printf("ZeroGS: started recording at zerogs.avi\n");
DEBUG_LOG("ZeroGS: started recording at zerogs.avi\n");
}
else {
if( !(conf.options & GSOPTION_CAPTUREAVI) )
return 1;
conf.options &= ~GSOPTION_CAPTUREAVI;
ZeroGS::StopCapture();
printf("ZeroGS: stopped recording\n");
DEBUG_LOG("ZeroGS: stopped recording\n");
}
return 1;
@ -1053,7 +1012,7 @@ int CALLBACK GSsetupRecording(int start, void* pData)
s32 CALLBACK GSfreeze(int mode, freezeData *data) {
if (mode == FREEZE_LOAD) {
if( !ZeroGS::Load(data->data) )
printf("GS: Bad load format!");
DEBUG_LOG("GS: Bad load format!");
g_nRealFrame += 100;
} else if (mode == FREEZE_SAVE) {

View File

@ -242,7 +242,7 @@ u32 g_pageTable8[64][128];
u32 g_pageTable4[128][128];
BLOCK m_Blocks[0x40]; // do so blocks are indexable
static __declspec(align(16)) u32 tempblock[64];
static PCSX2_ALIGNED16(u32 tempblock[64]);
#define DSTPSM gs.dstbuf.psm
@ -503,13 +503,13 @@ End: \
#define SwizzleBlock4HLu SwizzleBlock4HL
// ------------------------
// | Y |
// | Y |
// ------------------------
// | block | |
// | block | |
// | aligned area | X |
// | | |
// | | |
// ------------------------
// | Y |
// | Y |
// ------------------------
#define DEFINE_TRANSFERLOCAL(psm, T, widthlimit, blockbits, blockwidth, blockheight, TransSfx, SwizzleBlock) \
int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
@ -521,16 +521,18 @@ int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
int nSize = nQWordSize*4*2/TRANSMIT_PITCH##TransSfx(2, T); \
nSize = min(nSize, gs.imageWnew * gs.imageHnew); \
\
int pitch, area, fracX; \
int endY = ROUND_UPPOW2(i, blockheight); \
int alignedY = ROUND_DOWNPOW2(gs.imageEndY, blockheight); \
int alignedX = ROUND_DOWNPOW2(gs.imageEndX, blockwidth); \
bool bCanAlign = MOD_POW2(gs.trxpos.dx, blockwidth) == 0 && (j == gs.trxpos.dx) && (alignedY > endY) && alignedX > gs.trxpos.dx; \
bool bAligned, bCanAlign = MOD_POW2(gs.trxpos.dx, blockwidth) == 0 && (j == gs.trxpos.dx) && (alignedY > endY) && alignedX > gs.trxpos.dx; \
\
if( (gs.imageEndX-gs.trxpos.dx)%widthlimit ) { \
/* hack */ \
if( abs((int)nSize - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx)) <= widthlimit ) { \
/* don't transfer */ \
/*printf("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/ \
int testwidth = (int)nSize - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx); \
if ((testwidth <= widthlimit) && (testwidth >= -widthlimit)) { \
/* Don't transfer */ \
/*DEBUG_LOG("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/ \
gs.imageTransfer = -1; \
} \
bCanAlign = false; \
@ -559,12 +561,12 @@ int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
assert( MOD_POW2(i, blockheight) == 0 && j == gs.trxpos.dx); \
\
/* can align! */ \
int pitch = gs.imageEndX-gs.trxpos.dx; \
int area = pitch*blockheight; \
int fracX = gs.imageEndX-alignedX; \
pitch = gs.imageEndX-gs.trxpos.dx; \
area = pitch*blockheight; \
fracX = gs.imageEndX-alignedX; \
\
/* on top of checking whether pbuf is alinged, make sure that the width is at least aligned to its limits (due to bugs in pcsx2) */ \
bool bAligned = !((u32)pbuf & 0xf) && (TRANSMIT_PITCH##TransSfx(pitch, T)&0xf) == 0; \
bAligned = !((uptr)pbuf & 0xf) && (TRANSMIT_PITCH##TransSfx(pitch, T)&0xf) == 0; \
\
/* transfer aligning to blocks */ \
for(; i < alignedY && nSize >= area; i += blockheight, nSize -= area) { \
@ -638,7 +640,7 @@ DEFINE_TRANSFERLOCAL(4HH, u8, 8, 32, 8, 8, _4, SwizzleBlock4HH);
// /* hack */
// if( abs((int)nSize - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx)) <= widthlimit ) {
// /* don't transfer */
// /*printf("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/
// /*DEBUG_LOG("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/
// gs.imageTransfer = -1;
// }
// bCanAlign = false;

View File

@ -83,7 +83,7 @@ extern u32 g_pageTable16SZ[64][64];
extern u32 g_pageTable8[64][128];
extern u32 g_pageTable4[128][128];
__forceinline u32 getPixelAddress32(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress32(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>5) * (bw>>6)) + (x>>6);
u32 word = bp * 64 + basepage * 2048 + g_pageTable32[y&31][x&63];
//assert (word < 0x100000);
@ -91,7 +91,7 @@ __forceinline u32 getPixelAddress32(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress32_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress32_0(int x, int y, u32 bw) {
u32 basepage = ((y>>5) * (bw>>6)) + (x>>6);
u32 word = basepage * 2048 + g_pageTable32[y&31][x&63];
//assert (word < 0x100000);
@ -108,7 +108,7 @@ __forceinline u32 getPixelAddress32_0(int x, int y, u32 bw) {
#define getPixelAddress4HH getPixelAddress32
#define getPixelAddress4HH_0 getPixelAddress32_0
__forceinline u32 getPixelAddress16(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress16(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = bp * 128 + basepage * 4096 + g_pageTable16[y&63][x&63];
//assert (word < 0x200000);
@ -116,7 +116,7 @@ __forceinline u32 getPixelAddress16(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress16_0(int x, int y, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = basepage * 4096 + g_pageTable16[y&63][x&63];
//assert (word < 0x200000);
@ -124,7 +124,7 @@ __forceinline u32 getPixelAddress16_0(int x, int y, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16S(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress16S(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = bp * 128 + basepage * 4096 + g_pageTable16S[y&63][x&63];
//assert (word < 0x200000);
@ -132,7 +132,7 @@ __forceinline u32 getPixelAddress16S(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16S_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress16S_0(int x, int y, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = basepage * 4096 + g_pageTable16S[y&63][x&63];
//assert (word < 0x200000);
@ -140,7 +140,7 @@ __forceinline u32 getPixelAddress16S_0(int x, int y, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress8(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress8(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>6) * ((bw+127)>>7)) + (x>>7);
u32 word = bp * 256 + basepage * 8192 + g_pageTable8[y&63][x&127];
//assert (word < 0x400000);
@ -148,7 +148,7 @@ __forceinline u32 getPixelAddress8(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress8_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress8_0(int x, int y, u32 bw) {
u32 basepage = ((y>>6) * ((bw+127)>>7)) + (x>>7);
u32 word = basepage * 8192 + g_pageTable8[y&63][x&127];
//assert (word < 0x400000);
@ -156,7 +156,7 @@ __forceinline u32 getPixelAddress8_0(int x, int y, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress4(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress4(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>7) * ((bw+127)>>7)) + (x>>7);
u32 word = bp * 512 + basepage * 16384 + g_pageTable4[y&127][x&127];
//assert (word < 0x800000);
@ -164,7 +164,7 @@ __forceinline u32 getPixelAddress4(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress4_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress4_0(int x, int y, u32 bw) {
u32 basepage = ((y>>7) * ((bw+127)>>7)) + (x>>7);
u32 word = basepage * 16384 + g_pageTable4[y&127][x&127];
//assert (word < 0x800000);
@ -172,7 +172,7 @@ __forceinline u32 getPixelAddress4_0(int x, int y, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress32Z(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress32Z(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>5) * (bw>>6)) + (x>>6);
u32 word = bp * 64 + basepage * 2048 + g_pageTable32Z[y&31][x&63];
//assert (word < 0x100000);
@ -180,7 +180,7 @@ __forceinline u32 getPixelAddress32Z(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress32Z_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress32Z_0(int x, int y, u32 bw) {
u32 basepage = ((y>>5) * (bw>>6)) + (x>>6);
u32 word = basepage * 2048 + g_pageTable32Z[y&31][x&63];
//assert (word < 0x100000);
@ -191,7 +191,7 @@ __forceinline u32 getPixelAddress32Z_0(int x, int y, u32 bw) {
#define getPixelAddress24Z getPixelAddress32Z
#define getPixelAddress24Z_0 getPixelAddress32Z_0
__forceinline u32 getPixelAddress16Z(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress16Z(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = bp * 128 + basepage * 4096 + g_pageTable16Z[y&63][x&63];
//assert (word < 0x200000);
@ -199,7 +199,7 @@ __forceinline u32 getPixelAddress16Z(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16Z_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress16Z_0(int x, int y, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = basepage * 4096 + g_pageTable16Z[y&63][x&63];
//assert (word < 0x200000);
@ -207,7 +207,7 @@ __forceinline u32 getPixelAddress16Z_0(int x, int y, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16SZ(int x, int y, u32 bp, u32 bw) {
static __forceinline u32 getPixelAddress16SZ(int x, int y, u32 bp, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = bp * 128 + basepage * 4096 + g_pageTable16SZ[y&63][x&63];
//assert (word < 0x200000);
@ -215,7 +215,7 @@ __forceinline u32 getPixelAddress16SZ(int x, int y, u32 bp, u32 bw) {
return word;
}
__forceinline u32 getPixelAddress16SZ_0(int x, int y, u32 bw) {
static __forceinline u32 getPixelAddress16SZ_0(int x, int y, u32 bw) {
u32 basepage = ((y>>6) * (bw>>6)) + (x>>6);
u32 word = basepage * 4096 + g_pageTable16SZ[y&63][x&63];
//assert (word < 0x200000);
@ -223,95 +223,95 @@ __forceinline u32 getPixelAddress16SZ_0(int x, int y, u32 bw) {
return word;
}
__forceinline void writePixel32(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel32(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u32*)pmem)[getPixelAddress32(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel24(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel24(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
u8 *buf = (u8*)&((u32*)pmem)[getPixelAddress32(x, y, bp, bw)];
u8 *pix = (u8*)&pixel;
buf[0] = pix[0]; buf[1] = pix[1]; buf[2] = pix[2];
}
__forceinline void writePixel16(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel16(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u16*)pmem)[getPixelAddress16(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel16S(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel16S(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u16*)pmem)[getPixelAddress16S(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel8(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel8(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u8*)pmem)[getPixelAddress8(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel8H(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel8H(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u8*)pmem)[4*getPixelAddress32(x, y, bp, bw)+3] = pixel;
}
__forceinline void writePixel4(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel4(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
u32 addr = getPixelAddress4(x, y, bp, bw);
u8 pix = ((u8*)pmem)[addr/2];
if (addr & 0x1) ((u8*)pmem)[addr/2] = (pix & 0x0f) | (pixel << 4);
else ((u8*)pmem)[addr/2] = (pix & 0xf0) | (pixel);
}
__forceinline void writePixel4HL(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel4HL(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
u8 *p = (u8*)pmem + 4*getPixelAddress4HL(x, y, bp, bw)+3;
*p = (*p & 0xf0) | pixel;
}
__forceinline void writePixel4HH(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel4HH(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
u8 *p = (u8*)pmem + 4*getPixelAddress4HH(x, y, bp, bw)+3;
*p = (*p & 0x0f) | (pixel<<4);
}
__forceinline void writePixel32Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel32Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u32*)pmem)[getPixelAddress32Z(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel24Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel24Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
u8 *buf = (u8*)pmem + 4*getPixelAddress32Z(x, y, bp, bw);
u8 *pix = (u8*)&pixel;
buf[0] = pix[0]; buf[1] = pix[1]; buf[2] = pix[2];
}
__forceinline void writePixel16Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel16Z(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u16*)pmem)[getPixelAddress16Z(x, y, bp, bw)] = pixel;
}
__forceinline void writePixel16SZ(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
static __forceinline void writePixel16SZ(void* pmem, int x, int y, u32 pixel, u32 bp, u32 bw) {
((u16*)pmem)[getPixelAddress16SZ(x, y, bp, bw)] = pixel;
}
///////////////
__forceinline u32 readPixel32(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel32(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32(x, y, bp, bw)];
}
__forceinline u32 readPixel24(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel24(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32(x, y, bp, bw)] & 0xffffff;
}
__forceinline u32 readPixel16(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel16(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16(x, y, bp, bw)];
}
__forceinline u32 readPixel16S(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel16S(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16S(x, y, bp, bw)];
}
__forceinline u32 readPixel8(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel8(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u8*)pmem)[getPixelAddress8(x, y, bp, bw)];
}
__forceinline u32 readPixel8H(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel8H(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u8*)pmem)[4*getPixelAddress32(x, y, bp, bw) + 3];
}
__forceinline u32 readPixel4(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel4(const void* pmem, int x, int y, u32 bp, u32 bw) {
u32 addr = getPixelAddress4(x, y, bp, bw);
u8 pix = ((const u8*)pmem)[addr/2];
if (addr & 0x1)
@ -319,31 +319,31 @@ __forceinline u32 readPixel4(const void* pmem, int x, int y, u32 bp, u32 bw) {
else return pix & 0xf;
}
__forceinline u32 readPixel4HL(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel4HL(const void* pmem, int x, int y, u32 bp, u32 bw) {
const u8 *p = (const u8*)pmem+4*getPixelAddress4HL(x, y, bp, bw)+3;
return *p & 0x0f;
}
__forceinline u32 readPixel4HH(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel4HH(const void* pmem, int x, int y, u32 bp, u32 bw) {
const u8 *p = (const u8*)pmem+4*getPixelAddress4HH(x, y, bp, bw) + 3;
return *p >> 4;
}
///////////////
__forceinline u32 readPixel32Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel32Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32Z(x, y, bp, bw)];
}
__forceinline u32 readPixel24Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel24Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32Z(x, y, bp, bw)] & 0xffffff;
}
__forceinline u32 readPixel16Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel16Z(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16Z(x, y, bp, bw)];
}
__forceinline u32 readPixel16SZ(const void* pmem, int x, int y, u32 bp, u32 bw) {
static __forceinline u32 readPixel16SZ(const void* pmem, int x, int y, u32 bp, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16SZ(x, y, bp, bw)];
}
@ -351,11 +351,11 @@ __forceinline u32 readPixel16SZ(const void* pmem, int x, int y, u32 bp, u32 bw)
// Functions that take 0 bps //
///////////////////////////////
__forceinline void writePixel32_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel32_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u32*)pmem)[getPixelAddress32_0(x, y, bw)] = pixel;
}
__forceinline void writePixel24_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel24_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
u8 *buf = (u8*)&((u32*)pmem)[getPixelAddress32_0(x, y, bw)];
u8 *pix = (u8*)&pixel;
#if defined(_MSC_VER) && defined(__x86_64__)
@ -365,44 +365,44 @@ __forceinline void writePixel24_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
#endif
}
__forceinline void writePixel16_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel16_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u16*)pmem)[getPixelAddress16_0(x, y, bw)] = pixel;
}
__forceinline void writePixel16S_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel16S_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u16*)pmem)[getPixelAddress16S_0(x, y, bw)] = pixel;
}
__forceinline void writePixel8_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel8_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u8*)pmem)[getPixelAddress8_0(x, y, bw)] = pixel;
}
__forceinline void writePixel8H_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel8H_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u8*)pmem)[4*getPixelAddress32_0(x, y, bw)+3] = pixel;
}
__forceinline void writePixel4_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel4_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
u32 addr = getPixelAddress4_0(x, y, bw);
u8 pix = ((u8*)pmem)[addr/2];
if (addr & 0x1) ((u8*)pmem)[addr/2] = (pix & 0x0f) | (pixel << 4);
else ((u8*)pmem)[addr/2] = (pix & 0xf0) | (pixel);
}
__forceinline void writePixel4HL_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel4HL_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
u8 *p = (u8*)pmem + 4*getPixelAddress4HL_0(x, y, bw)+3;
*p = (*p & 0xf0) | pixel;
}
__forceinline void writePixel4HH_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel4HH_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
u8 *p = (u8*)pmem + 4*getPixelAddress4HH_0(x, y, bw)+3;
*p = (*p & 0x0f) | (pixel<<4);
}
__forceinline void writePixel32Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel32Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u32*)pmem)[getPixelAddress32Z_0(x, y, bw)] = pixel;
}
__forceinline void writePixel24Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel24Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
u8 *buf = (u8*)pmem + 4*getPixelAddress32Z_0(x, y, bw);
u8 *pix = (u8*)&pixel;
#if defined(_MSC_VER) && defined(__x86_64__)
@ -412,42 +412,42 @@ __forceinline void writePixel24Z_0(void* pmem, int x, int y, u32 pixel, u32 bw)
#endif
}
__forceinline void writePixel16Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel16Z_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u16*)pmem)[getPixelAddress16Z_0(x, y, bw)] = pixel;
}
__forceinline void writePixel16SZ_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
static __forceinline void writePixel16SZ_0(void* pmem, int x, int y, u32 pixel, u32 bw) {
((u16*)pmem)[getPixelAddress16SZ_0(x, y, bw)] = pixel;
}
///////////////
__forceinline u32 readPixel32_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel32_0(const void* pmem, int x, int y, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32_0(x, y, bw)];
}
__forceinline u32 readPixel24_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel24_0(const void* pmem, int x, int y, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32_0(x, y, bw)] & 0xffffff;
}
__forceinline u32 readPixel16_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel16_0(const void* pmem, int x, int y, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16_0(x, y, bw)];
}
__forceinline u32 readPixel16S_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel16S_0(const void* pmem, int x, int y, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16S_0(x, y, bw)];
}
__forceinline u32 readPixel8_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel8_0(const void* pmem, int x, int y, u32 bw) {
return ((const u8*)pmem)[getPixelAddress8_0(x, y, bw)];
}
__forceinline u32 readPixel8H_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel8H_0(const void* pmem, int x, int y, u32 bw) {
return ((const u8*)pmem)[4*getPixelAddress32_0(x, y, bw) + 3];
}
__forceinline u32 readPixel4_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel4_0(const void* pmem, int x, int y, u32 bw) {
u32 addr = getPixelAddress4_0(x, y, bw);
u8 pix = ((const u8*)pmem)[addr/2];
if (addr & 0x1)
@ -455,31 +455,31 @@ __forceinline u32 readPixel4_0(const void* pmem, int x, int y, u32 bw) {
else return pix & 0xf;
}
__forceinline u32 readPixel4HL_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel4HL_0(const void* pmem, int x, int y, u32 bw) {
const u8 *p = (const u8*)pmem+4*getPixelAddress4HL_0(x, y, bw)+3;
return *p & 0x0f;
}
__forceinline u32 readPixel4HH_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel4HH_0(const void* pmem, int x, int y, u32 bw) {
const u8 *p = (const u8*)pmem+4*getPixelAddress4HH_0(x, y, bw) + 3;
return *p >> 4;
}
///////////////
__forceinline u32 readPixel32Z_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel32Z_0(const void* pmem, int x, int y, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32Z_0(x, y, bw)];
}
__forceinline u32 readPixel24Z_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel24Z_0(const void* pmem, int x, int y, u32 bw) {
return ((const u32*)pmem)[getPixelAddress32Z_0(x, y, bw)] & 0xffffff;
}
__forceinline u32 readPixel16Z_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel16Z_0(const void* pmem, int x, int y, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16Z_0(x, y, bw)];
}
__forceinline u32 readPixel16SZ_0(const void* pmem, int x, int y, u32 bw) {
static __forceinline u32 readPixel16SZ_0(const void* pmem, int x, int y, u32 bw) {
return ((const u16*)pmem)[getPixelAddress16SZ_0(x, y, bw)];
}

View File

@ -78,7 +78,7 @@ u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
void __fastcall GIFPackedRegHandlerNull(u32* data)
{
#ifdef _DEBUG
printf("Unexpected packed reg handler %8.8lx_%8.8lx %x\n", data[0], data[1], data[2]);
DEBUG_LOG("Unexpected packed reg handler %8.8lx_%8.8lx %x\n", data[0], data[1], data[2]);
#endif
}
@ -373,16 +373,14 @@ void __fastcall GIFRegHandlerNull(u32* data)
// 0x7f happens on a lot of games
if( data[2] != 0x7f && (data[0] || data[1]) ) {
printf("Unexpected reg handler %x %x %x\n", data[0], data[1], data[2]);
DEBUG_LOG("Unexpected reg handler %x %x %x\n", data[0], data[1], data[2]);
}
#endif
}
void __fastcall GIFRegHandlerPRIM(u32 *data) {
if (data[0] & ~0x3ff) {
#ifdef WARN_LOG
//WARN_LOG("warning: unknown bits in prim %8.8lx_%8.8lx\n", data[1], data[0]);
#endif
}
gs.nTriFanVert = gs.primIndex;

View File

@ -338,13 +338,13 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
#ifdef STATS
st_out_bit_counts[st_current_index] += n;
#endif
// printf("put_bits=%d %x\n", n, value);
// DEBUG_LOG("put_bits=%d %x\n", n, value);
assert(n == 32 || value < (1U << n));
bit_buf = s->bit_buf;
bit_left = s->bit_left;
// printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
// DEBUG_LOG("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
/* XXX: optimize */
if (n < bit_left) {
bit_buf = (bit_buf<<n) | value;
@ -361,7 +361,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
} else
#endif
*(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
//printf("bitbuf = %08x\n", bit_buf);
//DEBUG_LOG("bitbuf = %08x\n", bit_buf);
s->buf_ptr+=4;
bit_left+=32 - n;
bit_buf = value;
@ -403,7 +403,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
ptr[0] |= be2me_32(value>>(index&31));
ptr[1] = be2me_32(value<<(32-(index&31)));
//if(n>24) printf("%d %d\n", n, value);
//if(n>24) DEBUG_LOG("%d %d\n", n, value);
index+= n;
s->index= index;
# endif
@ -431,7 +431,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
ptr[0] |= be2me_32(value<<(32-n-(index&7) ));
ptr[1] = 0;
//if(n>24) printf("%d %d\n", n, value);
//if(n>24) DEBUG_LOG("%d %d\n", n, value);
index+= n;
s->index= index;
# endif
@ -885,17 +885,17 @@ static inline void print_bin(int bits, int n){
int i;
for(i=n-1; i>=0; i--){
printf("%d", (bits>>i)&1);
DEBUG_LOG("%d", (bits>>i)&1);
}
for(i=n; i<24; i++)
printf(" ");
DEBUG_LOG(" ");
}
static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){
int r= get_bits(s, n);
print_bin(r, n);
printf("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
DEBUG_LOG("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
return r;
}
static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, char *func, int line){
@ -907,7 +907,7 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits
print_bin(bits2, len);
printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
DEBUG_LOG("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
return r;
}
static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){
@ -915,7 +915,7 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *fun
int r= get_xbits(s, n);
print_bin(show, n);
printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
DEBUG_LOG("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
return r;
}

View File

@ -386,12 +386,12 @@ void ZeroGS::CRenderTarget::Update(int context, ZeroGS::CRenderTarget* pdepth)
if( ittarg == s_DepthRTs.mapTargets.end() )
nUpdateTarg = 0;
else if( ittarg->second == this ) {
printf("zerogs: updating self");
DEBUG_LOG("zerogs: updating self");
nUpdateTarg = 0;
}
}
else if( ittarg->second == this ) {
printf("zerogs: updating self");
DEBUG_LOG("zerogs: updating self");
nUpdateTarg = 0;
}
}
@ -500,7 +500,7 @@ void ZeroGS::CRenderTarget::ConvertTo32()
V(pd3dDevice->CreateTexture(fbw<<s_AAx, (fbh<<s_AAy)/2, 1, D3DUSAGE_RENDERTARGET, g_RenderFormat, D3DPOOL_DEFAULT, &ptexConv, NULL));
if( FAILED(hr) ) {
printf("Failed to create feedback\n");
DEBUG_LOG("Failed to create feedback\n");
return;
}
@ -696,7 +696,7 @@ void ZeroGS::CRenderTarget::ConvertTo16()
V(pd3dDevice->CreateTexture(fbw<<s_AAx, (fbh<<s_AAy)*2, 1, D3DUSAGE_RENDERTARGET, g_RenderFormat, D3DPOOL_DEFAULT, &ptexConv, NULL));
if( FAILED(hr) ) {
printf("Failed to create feedback\n");
DEBUG_LOG("Failed to create feedback\n");
return;
}
@ -901,7 +901,7 @@ void ZeroGS::CRenderTarget::_CreateFeedback()
V(pd3dDevice->CreateTexture(fbw<<s_AAx, fbh<<s_AAy, 1, D3DUSAGE_RENDERTARGET, g_RenderFormat, D3DPOOL_DEFAULT, &ptexFeedback, NULL));
if( FAILED(hr) ) {
printf("Failed to create feedback\n");
DEBUG_LOG("Failed to create feedback\n");
return;
}
@ -1069,7 +1069,7 @@ void ZeroGS::CDepthTarget::Update(int context, ZeroGS::CRenderTarget* prndr)
if( nUpdateTarg ) {
CRenderTargetMngr::MAPTARGETS::iterator ittarg = s_DepthRTs.mapTargets.find(nUpdateTarg);
if( ittarg == s_DepthRTs.mapTargets.end() || ittarg->second == this) {
printf("zerogs: updating self");
DEBUG_LOG("zerogs: updating self");
nUpdateTarg = 0;
}
else pusetarg = ittarg->second;
@ -2082,7 +2082,7 @@ ZeroGS::CMemoryTarget* ZeroGS::CMemoryTargetMngr::GetMemoryTarget(const tex0Info
listClearedTargets.pop_front();
else {
if( listTargets.size() == 0 ) {
printf("Failed to create %dx%x texture\n", GPU_TEXWIDTH*channels*widthmult, (targ->realheight+widthmult-1)/widthmult);
DEBUG_LOG("Failed to create %dx%x texture\n", GPU_TEXWIDTH*channels*widthmult, (targ->realheight+widthmult-1)/widthmult);
channels = 1;
}
DestroyOldest();
@ -2776,7 +2776,7 @@ void TransferHostLocal(const void* pbyMem, u32 nQWordSize)
if( (ptarg->status & CRenderTarget::TS_Virtual) )
continue;
//printf("zerogs: resolving to alpha channel\n");
//DEBUG_LOG("zerogs: resolving to alpha channel\n");
ptarg->Resolve();
}
}
@ -2839,7 +2839,7 @@ void TransferHostLocal(const void* pbyMem, u32 nQWordSize)
// const T* pbuf = (const T*)pbyMem; \
// u32 nSize = nQWordSize*(4/sizeof(T)); \
// assert( (nSize%widthlimit) == 0 && widthlimit <= 4 ); \
// if( ((gs.imageEndX-gs.trxpos.dx)%widthlimit) ) printf("Bad Transmission! %d %d, psm: %d\n", gs.trxpos.dx, gs.imageEndX, DSTPSM); \
// if( ((gs.imageEndX-gs.trxpos.dx)%widthlimit) ) DEBUG_LOG("Bad Transmission! %d %d, psm: %d\n", gs.trxpos.dx, gs.imageEndX, DSTPSM); \
// for(; i < gs.imageEndY; ++i) { \
// for(; j < gs.imageEndX && nSize > 0; j += widthlimit, nSize -= widthlimit, pbuf += widthlimit) { \
// /* write as many pixel at one time as possible */ \
@ -2907,7 +2907,7 @@ void TransferHostLocal(const void* pbyMem, u32 nQWordSize)
//// // hack
//// if( abs((int)nQWordSize*8 - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx)) <= 8 ) {
//// // don't transfer
//// printf("bad texture 4: %d %d %d\n", gs.trxpos.dx, gs.imageEndX, nQWordSize);
//// DEBUG_LOG("bad texture 4: %d %d %d\n", gs.trxpos.dx, gs.imageEndX, nQWordSize);
//// gs.imageEndX = gs.trxpos.dx + (gs.imageEndX-gs.trxpos.dx)&~7;
//// //i = gs.imageEndY;
//// //goto End;

View File

@ -125,7 +125,7 @@ extern int s_frameskipping;
// static const char* pnames[4] = {NULL};
//
// if( ptargs[index] == psurf && psurf != NULL )
// printf("duplicate targets\n");
// DEBUG_LOG("duplicate targets\n");
// pd3dDevice->SetRenderTarget(index, psurf);
// ptargs[index] = psurf;
// counters[index] = counter;
@ -475,7 +475,7 @@ void ZeroGS::VB::CheckFrame(int tbp)
maxpos = min(gsfb.fbh, maxpos);
maxpos = min(maxmin, maxpos);
//? alteir aris crashes without it
//? atelier iris crashes without it
if( maxpos > 256 )
maxpos &= ~0x1f;
}
@ -505,8 +505,7 @@ void ZeroGS::VB::CheckFrame(int tbp)
}
frame = gsfb;
if( frame.fbw > 1024 )
frame.fbw = 1024;
if (frame.fbw > 1024) frame.fbw = 1024;
// if( fbh > 256 && (fbh % m_Blocks[gsfb.psm].height) <= 2 ) {
// // dragon ball z
@ -600,7 +599,7 @@ void ZeroGS::VB::CheckFrame(int tbp)
//CRenderTargetMngr::MAPTARGETS::iterator it = s_RTs.mapTargets.find(key);
// if( it != s_RTs.mapTargets.end() ) {
//#ifdef _DEBUG
// printf("zbuf resolve\n");
// DEBUG_LOG("zbuf resolve\n");
//#endif
// if( it->second->status & CRenderTarget::TS_Resolved )
// it->second->Resolve();
@ -868,7 +867,7 @@ HRESULT ZeroGS::Create(LONG _width, LONG _height)
D3DADAPTER_IDENTIFIER9 id;
HRESULT hr = pD3D->GetAdapterIdentifier(i, 0, &id);
if( strcmp(id.Description, "NVIDIA NVPerfHUD") == 0 ) {
printf("Using %s adapter\n", id.Description);
DEBUG_LOG("Using %s adapter\n", id.Description);
adapter = i;
devtype = D3DDEVTYPE_REF;
break;
@ -1177,7 +1176,7 @@ void ZeroGS::ChangeDeviceSize(int nNewWidth, int nNewHeight)
int oldwidth = width, oldheight = height;
if( FAILED(Create(nNewWidth&~7, nNewHeight&~7)) ) {
printf("Failed to recreate, changing to old\n");
DEBUG_LOG("Failed to recreate, changing to old\n");
if( FAILED(Create(oldwidth, oldheight)) ) {
MessageBox(NULL, "failed to create dev, exiting...\n", "Error", MB_OK);
exit(0);
@ -1246,7 +1245,7 @@ void ZeroGS::SetAA(int mode)
assert( (header) != NULL && (header)->index == (Index) ); \
hr = pd3dDevice->CreateVertexShader((DWORD*)(s_lpShaderResources + (header)->offset), &(ptr)); \
if( FAILED(hr) || ptr == NULL ) { \
printf("errors 0x%x for %d, failed.. try updating your drivers or dx\n", hr, Index); \
DEBUG_LOG("errors 0x%x for %d, failed.. try updating your drivers or dx\n", hr, Index); \
return E_FAIL; \
} \
} \
@ -1256,7 +1255,7 @@ void ZeroGS::SetAA(int mode)
header = mapShaderResources[index]; \
hr = pd3dDevice->CreatePixelShader((DWORD*)(s_lpShaderResources + (header)->offset), &(ptr)); \
if( FAILED(hr) || ptr == NULL ) { \
printf("errors 0x%x for %s, failed.. try updating your drivers or dx\n", hr, index); \
DEBUG_LOG("errors 0x%x for %s, failed.. try updating your drivers or dx\n", hr, index); \
return E_FAIL; \
} \
} \
@ -1357,7 +1356,7 @@ LPD3DPS ZeroGS::LoadShadeEffect(int type, int texfilter, int fog, int testaem, i
index += NUM_SHADERS*g_nPixelShaderVer;
assert( mapShaderResources.find(index) != mapShaderResources.end() );
SHADERHEADER* header = mapShaderResources[index];
if( header == NULL ) printf("%d %d\n", index%NUM_SHADERS, g_nPixelShaderVer);
if( header == NULL ) DEBUG_LOG("%d %d\n", index%NUM_SHADERS, g_nPixelShaderVer);
assert( header != NULL );
HRESULT hr = pd3dDevice->CreatePixelShader((DWORD*)(s_lpShaderResources + header->offset), pps);
@ -1425,7 +1424,7 @@ public:
V(D3DXCompileShaderFromFile(EFFECT_NAME"ps2hw.fx", pmacros, pInclude, name, shaderver, ShaderFlagsVS, &pShader, &pError, NULL)); \
if( FAILED(hr) ) \
{ \
printf("Failed to load vs %s: \n%s\n", name, pError->GetBufferPointer()); \
DEBUG_LOG("Failed to load vs %s: \n%s\n", name, pError->GetBufferPointer()); \
SAFE_RELEASE(pShader); \
SAFE_RELEASE(pError); \
return hr; \
@ -1441,7 +1440,7 @@ public:
V(D3DXCompileShaderFromFile(EFFECT_NAME"ps2hw.fx", pmacros, pInclude, name, shmodel, ShaderFlagsPS, &pShader, &pError, NULL)); \
if( FAILED(hr) ) \
{ \
printf("Failed to load ps %s: \n%s\n", name, pError->GetBufferPointer()); \
DEBUG_LOG("Failed to load ps %s: \n%s\n", name, pError->GetBufferPointer()); \
SAFE_RELEASE(pShader); \
SAFE_RELEASE(pError); \
return hr; \
@ -1450,7 +1449,7 @@ public:
SAFE_RELEASE(pShader); \
SAFE_RELEASE(pError); \
if( FAILED(hr) || ptr == NULL ) { \
printf("errors 0x%x for %s, failed.. try updating your drivers or dx\n", hr, name); \
DEBUG_LOG("errors 0x%x for %s, failed.. try updating your drivers or dx\n", hr, name); \
return E_FAIL; \
} \
} \
@ -1566,7 +1565,7 @@ LPD3DPS ZeroGS::LoadShadeEffect(int type, int texfilter, int fog, int testaem, i
if( SUCCEEDED(hr) )
return *pps;
printf("Failed to create shader %d,%d,%d,%d\n", type, fog, texfilter, 4*clamp.wms+clamp.wmt);
DEBUG_LOG("Failed to create shader %d,%d,%d,%d\n", type, fog, texfilter, 4*clamp.wms+clamp.wmt);
return NULL;
}
@ -1606,7 +1605,7 @@ HRESULT ZeroGS::InitDeviceObjects()
if( blockfmt == D3DFMT_R32F ) {
if( FAILED(hr = pd3dDevice->CreateTexture(BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 1, 0, D3DFMT_A32B32G32R32F, D3DPOOL_MANAGED, &ptexBilinearBlocks, NULL)) ) {
printf("Failed to create bilinear block texture, fmt = D3DFMT_A32B32G32R32F\n");
DEBUG_LOG("Failed to create bilinear block texture, fmt = D3DFMT_A32B32G32R32F\n");
}
}
else ptexBilinearBlocks = NULL;
@ -1716,7 +1715,7 @@ void ZeroGS::DeleteDeviceObjects()
if( s_aviinit ) {
StopCapture();
STOP_AVI();
printf("zerogs.avi stopped");
DEBUG_LOG("zerogs.avi stopped");
s_aviinit = 0;
}
@ -1926,7 +1925,7 @@ void ZeroGS::Flush(int context)
// kh2 hack
// if( curvb.dwCount == 2 && curvb.curprim.tme == 0 && curvb.curprim.abe == 0 && (curvb.tex0.tbp0 == 0x2a00 || curvb.tex0.tbp0==0x1d00) ) {
// // skip
// printf("skipping\n");
// DEBUG_LOG("skipping\n");
// g_SaveFrameNum++;
// curvb.dwCount = 0;
// return;
@ -3378,7 +3377,7 @@ void ZeroGS::RenderCRTC(int interlace)
pd3dDevice->EndScene();
if( pd3dDevice->Present(NULL, NULL, NULL, NULL) == D3DERR_DEVICELOST ) {
// device is lost, need to recreate
printf("device lost\n");
DEBUG_LOG("device lost\n");
g_bIsLost = TRUE;
Reset();
return;
@ -3462,7 +3461,7 @@ void ZeroGS::RenderCRTC(int interlace)
if( total / ARRAYSIZE(s_nResolveCounts) > 3 ) {
if( s_nLastResolveReset > (int)(fFPS * 8) ) {
// reset
printf("ZeroGS: video mem reset\n");
DEBUG_LOG("ZeroGS: video mem reset\n");
s_nLastResolveReset = 0;
memset(s_nResolveCounts, 0, sizeof(s_nResolveCounts));
@ -3495,52 +3494,63 @@ void ZeroGS::RenderCRTC(int interlace)
// Internal Definitions //
//////////////////////////
#define MOVZ(p, gsz) p.z = curvb.zprimmask==0xffff?min(0xffff, gsz):gsz;
#define MOVFOG(p, gsf) p.f = ((s16)(gsf).f<<7)|0x7f;
__forceinline void MOVZ(VertexGPU *p, u32 gsz, const VB& curvb)
{
p->z = curvb.zprimmask==0xffff?min((u32)0xffff, gsz):gsz;
}
#define SET_VERTEX(p, Index) { \
int index = Index; \
p.x = (((int)gs.gsvertex[index].x - curvb.offset.x)>>1)&0xffff; \
p.y = (((int)gs.gsvertex[index].y - curvb.offset.y)>>1)&0xffff; \
/*x = ((int)gs.gsvertex[index].x - curvb.offset.x); \
y = ((int)gs.gsvertex[index].y - curvb.offset.y); \
p.x = (x&0x7fff) | (x < 0 ? 0x8000 : 0); \
p.y = (y&0x7fff) | (y < 0 ? 0x8000 : 0);*/ \
p.f = ((s16)gs.gsvertex[index].f<<7)|0x7f; \
MOVZ(p, gs.gsvertex[index].z); \
p.rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba; \
if( (g_GameSettings & GAME_TEXAHACK) && !(p.rgba&0xffffff) ) \
p.rgba = 0; \
if( prim->tme ) { \
if( prim->fst ) { \
p.s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt]; \
p.t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt]; \
p.q = 1; \
} \
else { \
p.s = gs.gsvertex[index].s; \
p.t = gs.gsvertex[index].t; \
p.q = gs.gsvertex[index].q; \
} \
} \
} \
__forceinline void MOVFOG(VertexGPU *p, Vertex gsf)
{
p->f = ((s16)(gsf).f<<7)|0x7f;
}
__forceinline void SET_VERTEX(VertexGPU *p, int Index, const VB& curvb)
{
int index = Index;
p->x = (((int)gs.gsvertex[index].x - curvb.offset.x)>>1)&0xffff;
p->y = (((int)gs.gsvertex[index].y - curvb.offset.y)>>1)&0xffff;
/*x = ((int)gs.gsvertex[index].x - curvb.offset.x);
y = ((int)gs.gsvertex[index].y - curvb.offset.y);
p.x = (x&0x7fff) | (x < 0 ? 0x8000 : 0);
p.y = (y&0x7fff) | (y < 0 ? 0x8000 : 0);*/
p->f = ((s16)gs.gsvertex[index].f<<7)|0x7f;
MOVZ(p, gs.gsvertex[index].z, curvb);
p->rgba = prim->iip ? gs.gsvertex[index].rgba : gs.rgba;
if ((g_GameSettings & GAME_TEXAHACK) && !(p->rgba&0xffffff))
p->rgba = 0;
if (prim->tme )
{
if( prim->fst )
{
p->s = (float)gs.gsvertex[index].u * fiTexWidth[prim->ctxt];
p->t = (float)gs.gsvertex[index].v * fiTexHeight[prim->ctxt];
p->q = 1;
}
else
{
p->s = gs.gsvertex[index].s;
p->t = gs.gsvertex[index].t;
p->q = gs.gsvertex[index].q;
}
}
}
#define OUTPUT_VERT(fn, vert, id) { \
fn("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d), rgba=0x%8.8x, stq = (%2.5f,%2.5f,%2.5f)\n", id==0?'*':' ', id, prim->prim, vert.x/8, vert.y/8, vert.z, vert.f/128, \
vert.rgba, Clamp(vert.s, -10, 10), Clamp(vert.t, -10, 10), Clamp(vert.q, -10, 10)); \
} \
//#define OUTPUT_VERT(fn, vert, id) { \
// fn("%c%d(%d): xyzf=(%4d,%4d,0x%x,%3d)\n", id==0?'*':' ', id, prim->prim, vert.x/8, vert.y/8, vert.z, vert.f/128); \
//} \
void ZeroGS::KickPoint()
{
assert( gs.primC >= 1 );
VB& curvb = vb[prim->ctxt];
if( curvb.bNeedTexCheck )
curvb.FlushTexData();
if (curvb.bNeedTexCheck) curvb.FlushTexData();
if( !(g_GameSettings&GAME_DOPARALLELCTX) && vb[!prim->ctxt].dwCount > 0 && vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp )
{
@ -3555,7 +3565,7 @@ void ZeroGS::KickPoint()
int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex);
VertexGPU* p = curvb.pbuf+curvb.dwCount;
SET_VERTEX(p[0], last);
SET_VERTEX(&p[0], last, curvb);
curvb.dwCount++;
#ifdef PRIM_LOG
@ -3584,8 +3594,8 @@ void ZeroGS::KickLine()
int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex);
VertexGPU* p = curvb.pbuf+curvb.dwCount*2;
SET_VERTEX(p[0], next);
SET_VERTEX(p[1], last);
SET_VERTEX(&p[0], next, curvb);
SET_VERTEX(&p[1], last, curvb);
curvb.dwCount++;
@ -3599,8 +3609,7 @@ void ZeroGS::KickTriangle()
{
assert( gs.primC >= 3 );
VB& curvb = vb[prim->ctxt];
if( curvb.bNeedTexCheck )
curvb.FlushTexData();
if (curvb.bNeedTexCheck) curvb.FlushTexData();
if( !(g_GameSettings&GAME_DOPARALLELCTX) && vb[!prim->ctxt].dwCount > 0 && vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp )
{
@ -3613,9 +3622,9 @@ void ZeroGS::KickTriangle()
curvb.Lock();
VertexGPU* p = curvb.pbuf+curvb.dwCount*3;
SET_VERTEX(p[0], 0);
SET_VERTEX(p[1], 1);
SET_VERTEX(p[2], 2);
SET_VERTEX(&p[0], 0, curvb);
SET_VERTEX(&p[1], 1, curvb);
SET_VERTEX(&p[2], 2, curvb);
curvb.dwCount++;
@ -3630,8 +3639,7 @@ void ZeroGS::KickTriangleFan()
{
assert( gs.primC >= 3 );
VB& curvb = vb[prim->ctxt];
if( curvb.bNeedTexCheck )
curvb.FlushTexData();
if (curvb.bNeedTexCheck) curvb.FlushTexData();
if( !(g_GameSettings&GAME_DOPARALLELCTX) && vb[!prim->ctxt].dwCount > 0 && vb[prim->ctxt].gsfb.fbp == vb[!prim->ctxt].gsfb.fbp )
{
@ -3644,9 +3652,9 @@ void ZeroGS::KickTriangleFan()
curvb.Lock();
VertexGPU* p = curvb.pbuf+curvb.dwCount*3;
SET_VERTEX(p[0], 0);
SET_VERTEX(p[1], 1);
SET_VERTEX(p[2], 2);
SET_VERTEX(&p[0], 0, curvb);
SET_VERTEX(&p[1], 1, curvb);
SET_VERTEX(&p[2], 2, curvb);
curvb.dwCount++;
@ -3661,6 +3669,13 @@ void ZeroGS::KickTriangleFan()
#endif
}
__forceinline void SetKickVertex(VertexGPU *p, Vertex v, int next, const VB& curvb)
{
SET_VERTEX(p, next, curvb);
MOVZ(p, v.z, curvb);
MOVFOG(p, v);
}
void ZeroGS::KickSprite()
{
assert( gs.primC >= 2 );
@ -3674,18 +3689,17 @@ void ZeroGS::KickSprite()
Flush(!prim->ctxt);
}
if( curvb.dwCount >= POINT_BUFFERFLUSH/3 )
Flush(prim->ctxt);
if (curvb.dwCount >= POINT_BUFFERFLUSH/3) Flush(prim->ctxt);
curvb.Lock();
int next = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
int last = (gs.primIndex+2)%ARRAYSIZE(gs.gsvertex);
// sprite is too small and AA shows lines (tek4)
if( s_AAx ) {
if( s_AAx )
{
gs.gsvertex[last].x += 4;
if( s_AAy )
gs.gsvertex[last].y += 4;
if (s_AAy) gs.gsvertex[last].y += 4;
}
// might be bad sprite (KH dialog text)
@ -3693,23 +3707,20 @@ void ZeroGS::KickSprite()
// return;
VertexGPU* p = curvb.pbuf+curvb.dwCount*3;
SET_VERTEX(p[0], next); MOVZ(p[0], gs.gsvertex[last].z); MOVFOG(p[0], gs.gsvertex[last]);
SET_VERTEX(p[3], next); MOVZ(p[3], gs.gsvertex[last].z); MOVFOG(p[3], gs.gsvertex[last]);
SET_VERTEX(p[1], last); MOVZ(p[1], gs.gsvertex[last].z); MOVFOG(p[1], gs.gsvertex[last]);
SET_VERTEX(p[4], last); MOVZ(p[4], gs.gsvertex[last].z); MOVFOG(p[4], gs.gsvertex[last]);
SetKickVertex(&p[0], gs.gsvertex[last], next, curvb);
SetKickVertex(&p[3], gs.gsvertex[last], next, curvb);
SetKickVertex(&p[1], gs.gsvertex[last], last, curvb);
SetKickVertex(&p[4], gs.gsvertex[last], last, curvb);
if( g_MaxRenderedHeight < p[0].y )
g_MaxRenderedHeight = p[0].y;
if( g_MaxRenderedHeight < p[1].y )
g_MaxRenderedHeight = p[1].y;
if (g_MaxRenderedHeight < p[0].y) g_MaxRenderedHeight = p[0].y;
if (g_MaxRenderedHeight < p[1].y) g_MaxRenderedHeight = p[1].y;
SET_VERTEX(p[2], next); MOVZ(p[2], gs.gsvertex[last].z); MOVFOG(p[2], gs.gsvertex[last]);
SetKickVertex(&p[2], gs.gsvertex[last], next, curvb);
p[2].s = p[1].s;
p[2].x = p[1].x;
SET_VERTEX(p[5], last); MOVZ(p[5], gs.gsvertex[last].z); MOVFOG(p[5], gs.gsvertex[last]);
SetKickVertex(&p[5], gs.gsvertex[last], last, curvb);
p[5].s = p[0].s;
p[5].x = p[0].x;
@ -4397,7 +4408,7 @@ void ZeroGS::SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0,
//if( a.fix <= 0x80 ) { \
// dwTemp = (a.fix*2)>255?255:(a.fix*2); \
// dwTemp = dwTemp|(dwTemp<<8)|(dwTemp<<16)|0x80000000; \
// printf("bfactor: %8.8x\n", dwTemp); \
// DEBUG_LOG("bfactor: %8.8x\n", dwTemp); \
// SETRS(D3DRS_BLENDFACTOR, dwTemp); \
// } \
// else { \
@ -4664,12 +4675,13 @@ bool ZeroGS::CheckChangeInClut(u32 highdword, u32 psm)
// processing the CLUT after tex0/2 are written
switch(cld) {
case 0: return false;
case 1: break; // Seems to rarely not be 1.
// note sure about changing cbp[0,1]
case 4: return gs.cbp[0] != cbp;
case 5: return gs.cbp[1] != cbp;
// default: load
default: break;
}
int cpsm = (highdword >> 19) & 0xe;
@ -4775,9 +4787,10 @@ void ZeroGS::texClutWrite(int ctx)
// processing the CLUT after tex0/2 are written
switch(tex0.cld) {
case 0: return;
case 1: break; // tex0.cld is usually 1.
case 2: gs.cbp[0] = tex0.cbp; break;
case 3: gs.cbp[1] = tex0.cbp; break;
// note sure about changing cbp[0,1]
// not sure about changing cbp[0,1]
case 4:
if( gs.cbp[0] == tex0.cbp )
return;
@ -4788,75 +4801,97 @@ void ZeroGS::texClutWrite(int ctx)
return;
gs.cbp[1] = tex0.cbp;
break;
default: //DEBUG_LOG("cld isn't 0-5!");
break;
}
Flush(!ctx);
int entries = (tex0.psm&3)==3 ? 256 : 16;
if (tex0.csm)
{
switch (tex0.cpsm)
{
// 16bit psm
// eggomania uses non16bit textures for csm2
case PSMCT16:
{
u16* src = (u16*)g_pbyGSMemory + tex0.cbp*128;
u16 *dst = (u16*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0));
if( tex0.csm ) {
// 16bit psm
// eggomania uses non16bit textures for csm2
if( tex0.cpsm == PSMCT16 ) {
u16* src = (u16*)g_pbyGSMemory + tex0.cbp*128;
u16 *dst = (u16*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0));
for(int i = 0; i < entries; ++i) {
*dst = src[getPixelAddress16_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if( ((u32)dst & 0x3ff) == 0 )
dst = (u16*)(g_pbyGSClut+2);
}
}
else if( tex0.cpsm == PSMCT16S ) {
u16* src = (u16*)g_pbyGSMemory + tex0.cbp*128;
u16 *dst = (u16*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0));
for(int i = 0; i < entries; ++i) {
*dst = src[getPixelAddress16S_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if( ((u32)dst & 0x3ff) == 0 )
dst = (u16*)(g_pbyGSClut+2);
}
}
else if( tex0.cpsm == PSMCT32 || tex0.cpsm == PSMCT24 ) {
u32* src = (u32*)g_pbyGSMemory + tex0.cbp*64;
u32 *dst = (u32*)(g_pbyGSClut+64*tex0.csa);
// check if address exceeds src
if( src+getPixelAddress32_0(gs.clut.cou+entries-1, gs.clut.cov, gs.clut.cbw) >= (u32*)g_pbyGSMemory + 0x00100000 ) {
ERROR_LOG("texClutWrite out of bounds\n");
}
else {
for(int i = 0; i < entries; ++i) {
*dst++ = src[getPixelAddress32_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
for (int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress16_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if (((u32)dst & 0x3ff) == 0) dst = (u16*)(g_pbyGSClut+2);
}
break;
}
}
else {
case PSMCT16S:
{
u16* src = (u16*)g_pbyGSMemory + tex0.cbp*128;
u16 *dst = (u16*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0));
for (int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress16S_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst += 2;
// check for wrapping
if (((u32)dst & 0x3ff) == 0) dst = (u16*)(g_pbyGSClut+2);
}
break;
}
case PSMCT32:
case PSMCT24:
{
u32* src = (u32*)g_pbyGSMemory + tex0.cbp*64;
u32 *dst = (u32*)(g_pbyGSClut+64*tex0.csa);
// check if address exceeds src
if( src+getPixelAddress32_0(gs.clut.cou+entries-1, gs.clut.cov, gs.clut.cbw) >= (u32*)g_pbyGSMemory + 0x00100000 )
ERROR_LOG("texClutWrite out of bounds\n");
else
for(int i = 0; i < entries; ++i)
{
*dst = src[getPixelAddress32_0(gs.clut.cou+i, gs.clut.cov, gs.clut.cbw)];
dst++;
}
}
break;
default:
{
#ifndef RELEASE_TO_PUBLIC
//printf("unknown cpsm: %x (%x)\n", tex0.cpsm, tex0.psm);
//DEBUG_LOG("unknown cpsm: %x (%x)\n", tex0.cpsm, tex0.psm);
#endif
break;
}
}
}
else {
if( tex0.cpsm <= 1 ) {
if( entries == 16 )
WriteCLUT_T32_I4_CSM1((u32*)(g_pbyGSMemory + tex0.cbp*256), (u32*)(g_pbyGSClut+64*tex0.csa));
else
WriteCLUT_T32_I8_CSM1((u32*)(g_pbyGSMemory + tex0.cbp*256), (u32*)(g_pbyGSClut+64*tex0.csa));
}
else {
if( entries == 16 )
WriteCLUT_T16_I4_CSM1((u32*)(g_pbyGSMemory + 256 * tex0.cbp), (u32*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0)));
else if(entries == 256) {
// sse2 for 256 is more complicated, so use regular
WriteCLUT_T16_I8_CSM1_c((u32*)(g_pbyGSMemory + 256 * tex0.cbp), (u32*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0)));
}
else
{
switch (tex0.cpsm)
{
case PSMCT24:
case PSMCT32:
if( entries == 16 )
WriteCLUT_T32_I4_CSM1((u32*)(g_pbyGSMemory + tex0.cbp*256), (u32*)(g_pbyGSClut+64*tex0.csa));
else
WriteCLUT_T32_I8_CSM1((u32*)(g_pbyGSMemory + tex0.cbp*256), (u32*)(g_pbyGSClut+64*tex0.csa));
break;
default:
if( entries == 16 )
WriteCLUT_T16_I4_CSM1((u32*)(g_pbyGSMemory + 256 * tex0.cbp), (u32*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0)));
else // sse2 for 256 is more complicated, so use regular
WriteCLUT_T16_I8_CSM1_c((u32*)(g_pbyGSMemory + 256 * tex0.cbp), (u32*)(g_pbyGSClut+32*(tex0.csa&15)+(tex0.csa>=16?2:0)));
break;
}
}
}
@ -4870,12 +4905,15 @@ void ZeroGS::SetTexFlush()
// if( PSMT_ISCLUT(vb[1].tex0.psm) )
// texClutWrite(1);
if( !s_bForceTexFlush ) {
if( s_ptexCurSet[0] != s_ptexNextSet[0] ) {
if( !s_bForceTexFlush )
{
if( s_ptexCurSet[0] != s_ptexNextSet[0] )
{
s_ptexCurSet[0] = s_ptexNextSet[0];
pd3dDevice->SetTexture(SAMP_MEMORY0, s_ptexNextSet[0]);
}
if( s_ptexCurSet[1] != s_ptexNextSet[1] ) {
if( s_ptexCurSet[1] != s_ptexNextSet[1] )
{
s_ptexCurSet[1] = s_ptexNextSet[1];
pd3dDevice->SetTexture(SAMP_MEMORY1, s_ptexNextSet[1]);
}
@ -5019,7 +5057,7 @@ bool ZeroGS::StartCapture()
s_aviinit = 1;
}
else {
printf("ZeroGS: Continuing from previous capture");
DEBUG_LOG("ZeroGS: Continuing from previous capture");
}
s_avicapturing = 1;

View File

@ -142,7 +142,8 @@ struct Vector_16F
/////////////////////
// define when releasing
#define ZEROGS_CACHEDCLEAR // much better performance
// The only code that uses it is commented out!
//#define ZEROGS_CACHEDCLEAR // much better performance
//#define RELEASE_TO_PUBLIC
#if !defined(_RELEASE)
@ -151,6 +152,9 @@ struct Vector_16F
#define GS_LOG 0&&
#endif
#define ERROR_LOG __LogToConsole
#define DEBUG_LOG printf
#ifdef RELEASE_TO_PUBLIC
#define WARN_LOG 0&&
#define PRIM_LOG 0&&
@ -693,8 +697,8 @@ extern GSinternal gs;
extern FILE *gsLog;
void __Log(char *fmt, ...);
void ERROR_LOG(char *fmt, ...);
void __Log(const char *fmt, ...);
void __LogToConsole(const char *fmt, ...);
void LoadConfig();
void SaveConfig();
@ -803,7 +807,7 @@ inline float Clamp(float fx, float fmin, float fmax)
return fx > fmax ? fmax : fx;
}
// IMPORTANT: For every Reigster there must be an End
// IMPORTANT: For every Register there must be an End
void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
void DVProfEnd(u32 dwUserData);
void DVProfWrite(char* pfilename, u32 frames = 0);

View File

@ -128,8 +128,7 @@ bool THR_bShift = false;
#endif
#ifdef GS_LOG
void __Log(char *fmt, ...) {
void __Log(const char *fmt, ...) {
va_list list;
if (!conf.log) return;
@ -138,9 +137,8 @@ void __Log(char *fmt, ...) {
vfprintf(gsLog, fmt, list);
va_end(list);
}
#endif
void ERROR_LOG(char *fmt, ...) {
void __LogToConsole(const char *fmt, ...) {
va_list list;
va_start(list, fmt);
@ -167,9 +165,7 @@ void CALLBACK GSsetGameCRC(int crc, int options)
g_GameSettings = conf.gamesettings|options;
conf.mrtdepth = 0;//!(conf.gamesettings&GAME_DISABLEMRTDEPTH);
if( !conf.mrtdepth ) {
ERROR_LOG("Disabling MRT depth writing\n");
}
if( !conf.mrtdepth ) ERROR_LOG("Disabling MRT depth writing\n");
g_GameSettings |= GAME_PATH3HACK;
g_LastCRC = crc;
@ -287,11 +283,7 @@ s32 CALLBACK GSinit()
#endif
GSreset();
#ifdef GS_LOG
GS_LOG("GSinit ok\n");
#endif
return 0;
}
@ -396,7 +388,7 @@ LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
case WM_ACTIVATE:
if( wParam != WA_INACTIVE ) {
//printf("restoring device\n");
//DEBUG_LOG("restoring device\n");
ZeroGS::Restore();
}
@ -440,9 +432,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
g_GSMultiThreaded = multithread;
#ifdef GS_LOG
GS_LOG("GSopen\n");
#endif
#ifdef _DEBUG
g_hCurrentThread = GetCurrentThread();
@ -478,7 +468,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
if( pDsp != NULL )
*(HWND*)pDsp = GShwnd;
ERROR_LOG("creating\n");
ERROR_LOG("creating zerogs\n");
//if (conf.record) recOpen();
if( !ZeroGS::Create(conf.width, conf.height) )
return -1;
@ -486,10 +476,10 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
ERROR_LOG("initialization successful\n");
if( conf.bilinear == 2 ) {
ZeroGS::AddMessage("bilinear filtering - forced", 1000);
ZeroGS::AddMessage("forced bilinear filtering - on", 1000);
}
else if( conf.bilinear == 1 ) {
ZeroGS::AddMessage("bilinear filtering - normal", 1000);
ZeroGS::AddMessage("normal bilinear filtering - on", 1000);
}
if( conf.aa ) {
char strtitle[64];
@ -502,15 +492,12 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
ShowWindow( GShwnd, SW_SHOWDEFAULT );
UpdateWindow( GShwnd );
//SetForegroundWindow(GShwnd);
SetFocus(GShwnd);
conf.winstyle = GetWindowLong( GShwnd, GWL_STYLE );
conf.winstyle &= ~WS_MAXIMIZE & ~WS_MINIMIZE; // remove minimize/maximize style
#ifdef GS_LOG
GS_LOG("GSopen ok\n");
#endif
LARGE_INTEGER temp;
QueryPerformanceFrequency(&temp);
@ -598,9 +585,7 @@ void ProcessMessages()
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
{
#ifdef GS_LOG
GS_LOG("GSopen\n");
#endif
assert( GSirq != NULL );
LoadConfig();
@ -613,7 +598,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
if( pDsp != NULL )
*(Display**)pDsp = GLWin.dpy;
ERROR_LOG("creating\n");
ERROR_LOG("creating zerogs\n");
//if (conf.record) recOpen();
if( !ZeroGS::Create(conf.width, conf.height) )
return -1;
@ -632,9 +617,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread)
ZeroGS::AddMessage(strtitle);
}
#ifdef GS_LOG
GS_LOG("GSopen ok\n");
#endif
gs.path1.mode = 0;
gs.path2.mode = 0;
@ -758,9 +741,7 @@ float fFPS = 0;
void CALLBACK GSvsync(int interlace)
{
#ifdef GS_LOG
GS_LOG("\nGSvsync\n\n");
#endif
static u32 dwTime = timeGetTime();
static int nToNextUpdate = 1;
@ -771,10 +752,6 @@ void CALLBACK GSvsync(int interlace)
g_nRealFrame++;
ZeroGS::RenderCRTC(!interlace);
#ifndef _WIN32
//XLockDisplay(GLWin.dpy);
#endif
ProcessMessages();
@ -805,7 +782,7 @@ void CALLBACK GSvsync(int interlace)
#endif
// if( g_nFrame > 100 && fFPS > 60.0f ) {
// printf("set profile\n");
// DEBUG_LOG("set profile\n");
// g_bWriteProfile = 1;
// }
@ -844,29 +821,24 @@ void CALLBACK GSvsync(int interlace)
}
#endif
GL_REPORT_ERRORD();
#ifndef _WIN32
//XUnlockDisplay(GLWin.dpy);
#endif
}
void GIFtag(pathInfo *path, u32 *data) {
path->tag.nloop = data[0] & 0x7fff;
path->tag.eop = (data[0] >> 15) & 0x1;
u32 tagpre = (data[1] >> 14) & 0x1;
u32 tagprim = (data[1] >> 15) & 0x7ff;
u32 tagflg = (data[1] >> 26) & 0x3;
path->tag.nloop = data[0] & 0x7fff;
path->tag.eop = (data[0] >> 15) & 0x1;
u32 tagpre = (data[1] >> 14) & 0x1;
u32 tagprim = (data[1] >> 15) & 0x7ff;
u32 tagflg = (data[1] >> 26) & 0x3;
path->tag.nreg = (data[1] >> 28)<<2;
if (path->tag.nreg == 0) path->tag.nreg = 64;
gs.q = 1;
#ifdef GS_LOG
// 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],
// path->tag.eop, path->tag.nloop, tagflg, path->tag.nreg, tagpre);
#endif
path->mode = tagflg+1;
@ -915,9 +887,6 @@ static int nPath3Hack = 0;
void CALLBACK GSgetLastTag(u64* ptag)
{
// int mode = s_pLastPath->mode > 0 ? s_pLastPath->mode-1 : 0;
// *(u32*)ptag = s_pLastPath->tag.nloop|(s_pLastPath->tag.eop<<15);
// *((u32*)ptag+1) = (mode<<26)|(s_pLastPath->regn<<28);
*(u32*)ptag = nPath3Hack;
nPath3Hack = 0;
}
@ -931,47 +900,36 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
#ifdef _DEBUG
if( conf.log & 0x20 ) {
static int nSaveIndex=0;
__Log("%d: p:%d %x\n", nSaveIndex++, (path==&gs.path3)?3:(path==&gs.path2?2:1), size);
GS_LOG("%d: p:%d %x\n", nSaveIndex++, (path==&gs.path3)?3:(path==&gs.path2?2:1), size);
int vals[4] = {0};
for(int i = 0; i < size; i++) {
for(int j = 0; j < 4; ++j )
vals[j] ^= pMem[4*i+j];
}
__Log("%x %x %x %x\n", vals[0], vals[1], vals[2], vals[3]);
}
#endif
//s_pLastPath = path;
#ifdef _DEBUG
if( conf.log & 0x20 ) {
static int nSaveIndex=0;
__Log("%d: p:%d %x\n", nSaveIndex++, (path==&gs.path3)?3:(path==&gs.path2?2:1), size);
int vals[4] = {0};
for(int i = 0; i < size; ++i) {
for(int j = 0; j < 4; ++j )
vals[j] ^= pMem[4*i+j];
}
__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]);
}
#endif
while(size > 0)
{
//LOG(_T("Transfer(%08x, %d) START\n"), pMem, size);
if(path->tag.nloop == 0) {
if (path->tag.nloop == 0)
{
GIFtag(path, pMem);
pMem+= 4;
size--;
if( (g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop )
if ((g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop)
nPath3Hack = 1;
if( path == &gs.path1 ) {
if (path == &gs.path1)
{
// if too much data, just ignore
if( path->tag.nloop * (path->tag.nreg / 4) > (int)size * (path->mode==2?2:1)) {
if (path->tag.nloop * (path->tag.nreg / 4) > (int)size * (path->mode==2?2:1))
{
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
if( timeGetTime() - lasttime > 5000 )
{
ERROR_LOG("VU1 too much data, ignore if gfx are fine\n");
lasttime = timeGetTime();
}
@ -979,13 +937,16 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
return;
}
if( path->mode == 1 ) {
if (path->mode == 1)
{
// check if 0xb is in any reg, if yes, exit (kh2)
for(int i = 0; i < path->tag.nreg; i += 4) {
if( ((path->regs >> i)&0xf) == 11 ) {
for(int i = 0; i < path->tag.nreg; i += 4)
{
if (((path->regs >> i)&0xf) == 11)
{
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
if( timeGetTime() - lasttime > 5000 )
{
ERROR_LOG("Invalid unpack type\n");
lasttime = timeGetTime();
}
@ -996,11 +957,13 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
}
if(path->tag.nloop == 0 ) {
if( path == &gs.path1 ) {
if(path->tag.nloop == 0 )
{
if( path == &gs.path1 )
{
// ffx hack
if( g_GameSettings & GAME_FFXHACK ) {
if( g_GameSettings & GAME_FFXHACK )
{
if( path->tag.eop )
return;
continue;
@ -1009,8 +972,9 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
return;
}
if( !path->tag.eop ) {
//printf("contuing from eop\n");
if( !path->tag.eop )
{
//DEBUG_LOG("continuing from eop\n");
continue;
}
@ -1025,12 +989,15 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
for(; size > 0; size--, pMem += 4)
{
int reg = (int)((path->regs >> path->regn) & 0xf);
g_GIFPackedRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn) {
if (path->tag.nreg == path->regn)
{
path->regn = 0;
if( path->tag.nloop-- <= 1 ) {
if( path->tag.nloop-- <= 1 )
{
size--;
pMem += 4;
break;
@ -1041,7 +1008,7 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
case 2: // REGLIST
{
//__Log("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
//GS_LOG("%8.8x%8.8x %d L\n", ((u32*)&gs.regs)[1], *(u32*)&gs.regs, path->tag.nreg/4);
assert( path->tag.nloop > 0 );
size *= 2;
for(; size > 0; pMem+= 2, size--)
@ -1049,9 +1016,11 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
int reg = (int)((path->regs >> path->regn) & 0xf);
g_GIFRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn) {
if (path->tag.nreg == path->regn)
{
path->regn = 0;
if( path->tag.nloop-- <= 1 ) {
if( path->tag.nloop-- <= 1 )
{
size--;
pMem += 2;
break;
@ -1070,9 +1039,12 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
{
int process = min((int)size, path->tag.nloop);
if( process > 0 ) {
if( gs.imageTransfer ) ZeroGS::TransferLocalHost(pMem, process);
else ZeroGS::TransferHostLocal(pMem, process*4);
if( process > 0 )
{
if ( gs.imageTransfer )
ZeroGS::TransferLocalHost(pMem, process);
else
ZeroGS::TransferHostLocal(pMem, process*4);
path->tag.nloop -= process;
pMem += process*4; size -= process;
@ -1081,7 +1053,8 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
}
break;
}
else {
else
{
// simulate
int process = min((int)size, path->tag.nloop);
path->tag.nloop -= process;
@ -1093,9 +1066,6 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
default: // GIF_IMAGE
GS_LOG("*** WARNING **** Unexpected GIFTag flag\n");
assert(0);
// ZeroGS::TransferLocalHost(pMem, size);
// pMem+= size*4; path->tag.nloop-= size;
// size = 0; path->mode = 0;
path->tag.nloop = 0;
break;
}
@ -1107,47 +1077,31 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size)
{
#ifdef GS_LOG
//GS_LOG("GSgifTransfer2 size = %lx (mode %d, gs.path2.tag.nloop = %d)\n", size, gs.path2.mode, gs.path2.tag.nloop);
#endif
// if(!g_GSMultiThreaded)
// CSR->FINISH = 0;
//DVProfileFunc _pf("Transf2");
//assert( ((u32)pMem & 0xf) == 0 );
_GSgifTransfer(&gs.path2, pMem, size);
}
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
{
#ifdef GS_LOG
//GS_LOG("GSgifTransfer3 size = %lx (mode %d, gs.path3.tag.nloop = %d)\n", size, gs.path3.mode, gs.path3.tag.nloop);
#endif
nPath3Hack = 0;
_GSgifTransfer(&gs.path3, pMem, size);
}
static int s_trcount = 0;
static int count = 0;
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
{
pathInfo *path = &gs.path1;
#ifdef GS_LOG
//GS_LOG("GSgifTransfer1 0x%x (mode %d)\n", addr, path->mode);
#endif
addr &= 0x3fff;
#ifdef _DEBUG
PRIM_LOG("count :%d\n", s_trcount);
s_trcount++;
// for(int i = addr; i < 0x4000; i += 16 ) {
// u32* mem = (u32*)((u8*)pMem+i);
// PRIM_LOG("%x: %x %x %x %x\n", i, mem[0], mem[1], mem[2], mem[3]);
// }
PRIM_LOG("count: %d\n", count);
count++;
#endif
gs.path1.tag.nloop = 0;
@ -1158,25 +1112,20 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
assert( (addr&0xf) == 0 ); //BUG
gs.path1.tag.nloop = 0;
ERROR_LOG("Transfer1 - 2\n");
//_GSgifTransfer(&gs.path1, (u32*)((u8*)pMem+0x4000-addr), addr/16);
return;
}
}
void CALLBACK GSreadFIFO(u64 *pMem)
{
#ifdef GS_LOG
//GS_LOG("GSreadFIFO\n");
#endif
ZeroGS::TransferLocalHost((u32*)pMem, 1);
}
void CALLBACK GSreadFIFO2(u64 *pMem, int qwc)
{
#ifdef GS_LOG
//GS_LOG("GSreadFIFO2\n");
#endif
ZeroGS::TransferLocalHost((u32*)pMem, qwc);
}
@ -1188,14 +1137,14 @@ int CALLBACK GSsetupRecording(int start, void* pData)
return 1;
ZeroGS::StartCapture();
conf.options |= GSOPTION_CAPTUREAVI;
printf("ZeroGS: started recording at zerogs.avi\n");
WARN_LOG("ZeroGS: started recording at zerogs.avi\n");
}
else {
if( !(conf.options & GSOPTION_CAPTUREAVI) )
return 1;
conf.options &= ~GSOPTION_CAPTUREAVI;
ZeroGS::StopCapture();
printf("ZeroGS: stopped recording\n");
WARN_LOG("ZeroGS: stopped recording\n");
}
return 1;
@ -1227,7 +1176,7 @@ using namespace std;
#ifdef _WIN32
inline u64 GET_PROFILE_TIME()
__forceinline u64 GET_PROFILE_TIME()
{
LARGE_INTEGER lu;
QueryPerformanceCounter(&lu);

View File

@ -38,7 +38,7 @@ static int prevbilinearfilter;
//static map<string, int> mapConfOpts;
struct confOptsStruct{
int value;
char *desc;
const char *desc;
}confOpts;
static map<string, confOptsStruct> mapConfOpts;

View File

@ -530,7 +530,7 @@ int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
int testwidth = (int)nSize - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx); \
if( testwidth <= widthlimit && testwidth >= -widthlimit ) { \
/* don't transfer */ \
/*printf("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/ \
/*DEBUG_LOG("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/ \
gs.imageTransfer = -1; \
} \
bCanAlign = false; \
@ -638,7 +638,7 @@ DEFINE_TRANSFERLOCAL(4HH, u8, 8, 32, 8, 8, _4, SwizzleBlock4HH);
// /* hack */
// if( abs((int)nSize - (gs.imageEndY-i)*(gs.imageEndX-gs.trxpos.dx)+(j-gs.trxpos.dx)) <= widthlimit ) {
// /* don't transfer */
// /*printf("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/
// /*DEBUG_LOG("bad texture %s: %d %d %d\n", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/
// gs.imageTransfer = -1;
// }
// bCanAlign = false;

View File

@ -75,9 +75,7 @@ u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
void __fastcall GIFPackedRegHandlerNull(u32* data)
{
#ifdef _DEBUG
printf("Unexpected packed reg handler %8.8lx_%8.8lx %x\n", data[0], data[1], data[2]);
#endif
DEBUG_LOG("Unexpected packed reg handler %8.8lx_%8.8lx %x\n", data[0], data[1], data[2]);
}
void __fastcall GIFPackedRegHandlerRGBA(u32* data)
@ -122,7 +120,7 @@ void __forceinline KICK_VERTEX3()
{
/* tri fans need special processing */
if (gs.nTriFanVert == gs.primIndex)
gs.primIndex = (gs.primIndex+1)%ARRAY_SIZE(gs.gsvertex);
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
}
}
}
@ -134,7 +132,7 @@ void __fastcall GIFPackedRegHandlerXYZF2(u32* data)
gs.vertexregs.z = (data[2] >> 4) & 0xffffff;
gs.vertexregs.f = (data[3] >> 4) & 0xff;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAY_SIZE(gs.gsvertex);
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
if( data[3] & 0x8000 ) {
KICK_VERTEX3();
@ -150,7 +148,7 @@ void __fastcall GIFPackedRegHandlerXYZ2(u32* data)
gs.vertexregs.y = (data[1] >> 0) & 0xffff;
gs.vertexregs.z = data[2];
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAY_SIZE(gs.gsvertex);
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
if( data[3] & 0x8000 ) {
KICK_VERTEX3();
@ -371,7 +369,7 @@ void __fastcall GIFRegHandlerNull(u32* data)
// 0x7f happens on a lot of games
if( data[2] != 0x7f && (data[0] || data[1]) ) {
printf("Unexpected reg handler %x %x %x\n", data[0], data[1], data[2]);
DEBUG_LOG("Unexpected reg handler %x %x %x\n", data[0], data[1], data[2]);
}
#endif
}
@ -379,9 +377,7 @@ void __fastcall GIFRegHandlerNull(u32* data)
void __fastcall GIFRegHandlerPRIM(u32 *data)
{
if (data[0] & ~0x3ff) {
#ifdef WARN_LOG
//WARN_LOG("warning: unknown bits in prim %8.8lx_%8.8lx\n", data[1], data[0]);
#endif
}
gs.nTriFanVert = gs.primIndex;

View File

@ -338,13 +338,13 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
#ifdef STATS
st_out_bit_counts[st_current_index] += n;
#endif
// printf("put_bits=%d %x\n", n, value);
// DEBUG_LOG("put_bits=%d %x\n", n, value);
assert(n == 32 || value < (1U << n));
bit_buf = s->bit_buf;
bit_left = s->bit_left;
// printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
// DEBUG_LOG("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
/* XXX: optimize */
if (n < bit_left) {
bit_buf = (bit_buf<<n) | value;
@ -361,7 +361,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
} else
#endif
*(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
//printf("bitbuf = %08x\n", bit_buf);
//DEBUG_LOG("bitbuf = %08x\n", bit_buf);
s->buf_ptr+=4;
bit_left+=32 - n;
bit_buf = value;
@ -403,7 +403,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
ptr[0] |= be2me_32(value>>(index&31));
ptr[1] = be2me_32(value<<(32-(index&31)));
//if(n>24) printf("%d %d\n", n, value);
//if(n>24) DEBUG_LOG("%d %d\n", n, value);
index+= n;
s->index= index;
# endif
@ -431,7 +431,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
ptr[0] |= be2me_32(value<<(32-n-(index&7) ));
ptr[1] = 0;
//if(n>24) printf("%d %d\n", n, value);
//if(n>24) DEBUG_LOG("%d %d\n", n, value);
index+= n;
s->index= index;
# endif
@ -885,17 +885,17 @@ static inline void print_bin(int bits, int n){
int i;
for(i=n-1; i>=0; i--){
printf("%d", (bits>>i)&1);
DEBUG_LOG("%d", (bits>>i)&1);
}
for(i=n; i<24; i++)
printf(" ");
DEBUG_LOG(" ");
}
static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){
int r= get_bits(s, n);
print_bin(r, n);
printf("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
DEBUG_LOG("%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
return r;
}
static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, char *func, int line){
@ -907,7 +907,7 @@ static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits
print_bin(bits2, len);
printf("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
DEBUG_LOG("%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
return r;
}
static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *func, int line){
@ -915,7 +915,7 @@ static inline int get_xbits_trace(GetBitContext *s, int n, char *file, char *fun
int r= get_xbits(s, n);
print_bin(show, n);
printf("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
DEBUG_LOG("%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
return r;
}

File diff suppressed because it is too large Load Diff