GregMiscellaneous: Sync from trunk. Before there are too many conflict

git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3679 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut@gmail.com 2010-08-22 10:48:23 +00:00
commit ec44d0f8cf
31 changed files with 283 additions and 241 deletions

View File

@ -3686,7 +3686,7 @@ Compat = 5
Serial = SLUS-20482
Name = Sphinx and the Cursed Mummy
Region = NTSC-U
Compat = 1
Compat = 5
---------------------------------------------
Serial = SLUS-20483
Name = WWE Smackdown - Shut Your Mouth
@ -15611,17 +15611,6 @@ Serial = SLPM-65038
Name = Devil May Cry
Region = NTSC-J
Compat = 3
[patches = 96B2F56D]
comment=Skips Movies
//skip Movie_Set
patch=0,EE,001cdea0,word,03e00008
patch=0,EE,001cdea4,word,03e00008
//skip MovieEndCheck
patch=0,EE,001ce44c,word,70001428
[/patches]
---------------------------------------------
Serial = SLPM-65039
Name = Densha de Go! Shinkansen
@ -34046,23 +34035,6 @@ Serial = SLES-52336
Name = Max Payne 2 - The Fall of Max Payne
Region = PAL-Unk
Compat = 4
[patches = D03BEF2A]
comment=patches by Nachbrenner
//Skip Videos
patch=0,EE,002c8650,word,03e00008
patch=0,EE,002c8654,word,00000000
//fix obscure inf. loop
patch=0,EE,001aa610,word,03e00008
patch=0,EE,001aa614,word,24020000
//Language Modifier (sceScfGetLanguage)
patch=0,EE,00445ce4,word,24020001 // english
//patch=0,EE,00445ce4,word,24020004 // deutsch
//fix "SleepThread vs. RTFSSIOP.IRX"
patch=0,EE,001b3208,word,00000000
[/patches]
---------------------------------------------
Serial = SLES-52337
Name = Max Payne 2 - The Fall of Max Payne

View File

@ -81,6 +81,11 @@ else(BZIP2_FOUND)
message(STATUS "${msg_dep_cdvdiso}")
endif(BZIP2_FOUND)
#---------------------------------------
# CDVDlinuz
#---------------------------------------
set(CDVDlinuz TRUE)
#---------------------------------------
# dev9null
#---------------------------------------
@ -219,7 +224,6 @@ set(USBnull TRUE)
# [TODO] Write CMakeLists.txt for these plugins.
set(cdvdGigaherz FALSE)
set(CDVDisoEFP FALSE)
set(CDVDlinuz FALSE)
set(CDVDolio FALSE)
set(CDVDpeops FALSE)
set(GSdx FALSE)

View File

@ -64,7 +64,10 @@ struct PluginLog
void Close()
{
if (LogFile) fclose(LogFile);
if (LogFile) {
fclose(LogFile);
LogFile = NULL;
}
}
void Write(const char *fmt, ...)
@ -132,7 +135,10 @@ struct PluginConf
void Close()
{
fclose(ConfFile);
if (ConfFile) {
fclose(ConfFile);
ConfFile = NULL;
}
}
int ReadInt(const std::string& item, int defval)

View File

@ -173,10 +173,9 @@ static __ri void format_that_ascii_mess( SafeArray<char>& buffer, uint writepos,
static __ri void format_that_unicode_mess( SafeArray<char>& buffer, uint writepos, const wxChar* fmt, va_list argptr)
{
const int WX_CHAR_SIZE = sizeof(wxChar);
while( true )
{
int size = buffer.GetLength()/WX_CHAR_SIZE;
int size = buffer.GetLength() / sizeof(wxChar);
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos), size-writepos, fmt, argptr);
@ -196,7 +195,7 @@ static __ri void format_that_unicode_mess( SafeArray<char>& buffer, uint writepo
len += writepos;
if (len < size) break;
buffer.ExactAlloc( (len + 31) * WX_CHAR_SIZE );
buffer.ExactAlloc( (len + 31) * sizeof(wxChar) );
};
// performing an assertion or log of a truncated string is unsafe, so let's not; even
@ -235,11 +234,10 @@ FastFormatUnicode::~FastFormatUnicode() throw()
FastFormatUnicode& FastFormatUnicode::WriteV( const char* fmt, va_list argptr )
{
const int WX_CHAR_SIZE = sizeof(wxChar);
wxString converted( fromUTF8(FastFormatAscii().WriteV( fmt, argptr )) );
uint inspos = wxStrlen((wxChar*)m_dest->GetPtr());
m_dest->MakeRoomFor((inspos + converted.Length() + 31)*WX_CHAR_SIZE);
m_dest->MakeRoomFor((inspos + converted.Length() + 31)*sizeof(wxChar));
wxStrcpy( &((wxChar*)m_dest->GetPtr())[inspos], converted );
return *this;

View File

@ -422,6 +422,9 @@ void SysClearExecutionCache()
Cpu->Reset();
psxCpu->Reset();
// mVU's VU0 needs to be properly initialised for macro mode even if it's not used for micro mode!
if (CHECK_EEREC)
((BaseVUmicroCPU*)GetCpuProviders().CpuProviders->microVU0)->Reset();
CpuVU0->Reset();
CpuVU1->Reset();

View File

@ -43,12 +43,12 @@ protected:
class SysCpuProviderPack
{
protected:
ScopedPtr<CpuInitializerSet> CpuProviders;
ScopedPtr<BaseException> m_RecExceptionEE;
ScopedPtr<BaseException> m_RecExceptionIOP;
public:
ScopedPtr<CpuInitializerSet> CpuProviders;
SysCpuProviderPack();
virtual ~SysCpuProviderPack() throw();

View File

@ -63,7 +63,7 @@ static vtlbHandler UnmappedPhyHandler1;
template< typename DataType >
DataType __fastcall vtlb_memRead(u32 addr)
{
static const uint DataSize = sizeof(DataType);
static const uint DataSize = sizeof(DataType) * 8;
u32 vmv=vtlbdata.vmap[addr>>VTLB_PAGE_BITS];
s32 ppf=addr+vmv;
@ -134,7 +134,7 @@ void __fastcall vtlb_memRead128(u32 mem, u64 (&out)[2])
template< typename DataType >
void __fastcall vtlb_memWrite(u32 addr, DataType data)
{
static const uint DataSize = sizeof(DataType);
static const uint DataSize = sizeof(DataType) * 8;
u32 vmv=vtlbdata.vmap[addr>>VTLB_PAGE_BITS];
s32 ppf=addr+vmv;

View File

@ -5,7 +5,6 @@ set(Output CDVDlinuz)
set(CommonFlags
-Wall
-fPIC
-D_LARGEFILE64_SOURCE
)
@ -48,8 +47,8 @@ set(CDVDlinuzHeaders
PS2Edefs.h
PS2Etypes.h
# ERROR It takes /usr/include/alsa/version.h
# Either fix include dir. Or rename the file. Or mv stuff into in another include file.
version.h
# The content was move to Linux/CDVDlinuz.h
# version.h
)
# CDVDlinuz Linux sources

View File

@ -47,8 +47,6 @@
#include "DVD.h" // InitDVDInfo()
#include "device.h"
#include "../version.h"
// Globals

View File

@ -38,7 +38,14 @@
#define __CDVDLINUZ_H__
#define CDVDdefs
#include "PS2Edefs.h"
extern char *libname;
extern const unsigned char version;
extern const unsigned char revision;
extern const unsigned char build;
@ -50,13 +57,7 @@
#define VERBOSE_DISC_TYPE
#define READ_AHEAD_BUFFERS 32
#endif /* __CDVDLINUZ_H__ */

View File

@ -62,7 +62,7 @@
#include "version.h"
#include "CDVDlinuz.h"
#include "aboutbox.h"

View File

@ -112,6 +112,7 @@ CRC::Game CRC::m_games[] =
{0x565B6170, WildArms5, JP, 0},
{0xBBC3EFFA, WildArms4, US, 0},
{0xBBC396EC, WildArms4, US, 0}, //hmm such a small diff in the CRC..
{0x7B2DE9CC, WildArms4, EU, 0},
{0x8B029334, Manhunt2, Unknown, 0},
{0x09F49E37, CrashBandicootWoC, Unknown, 0},
{0x013E349D, ResidentEvil4, US, 0},

View File

@ -136,7 +136,10 @@ EXPORT_C_(void) GSsetLogDir(const char* dir)
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
OpenLog();
}
@ -156,7 +159,10 @@ EXPORT_C_(void) GSshutdown()
GSCloseWindow();
#ifdef GS_LOG
if (gsLog) fclose(gsLog);
if (gsLog) {
fclose(gsLog);
gsLog = NULL;
}
#endif
}

View File

@ -141,7 +141,10 @@ EXPORT_C_(void) SPU2setLogDir(const char* dir)
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (spu2Log) fclose(spu2Log);
if(spu2Log) {
fclose(spu2Log);
spu2Log = NULL;
}
OpenLog();
}
@ -209,7 +212,10 @@ EXPORT_C_(void) SPU2shutdown()
free(spu2mem);
spu2mem = NULL;
#ifdef SPU2_LOG
if (spu2Log) fclose(spu2Log);
if(spu2Log) {
fclose(spu2Log);
spu2Log = NULL;
}
#endif
}

View File

@ -44,14 +44,6 @@ LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// }
break;
case WM_ACTIVATE:
if (wParam != WA_INACTIVE)
{
//ZZLog::Debug_Log("Restoring device.");
ZeroGS::Restore();
}
break;
case WM_SIZE:
nWindowWidth = lParam & 0xffff;
nWindowHeight = lParam >> 16;

View File

@ -72,6 +72,29 @@ class GLWindow
extern GLWindow GLWin;
extern u8* g_pbyGSMemory;
class GSMemory
{
public:
void init();
void destroy();
u8* get();
u8* get(u32 addr);
u8* get_raw(u32 addr);
};
extern u8* g_pbyGSClut; // the temporary clut buffer
class GSClut
{
public:
void init();
void destroy();
u8* get();
u8* get(u32 addr);
u8* get_raw(u32 addr);
};
struct Vector_16F
{
u16 x, y, z, w;
@ -316,6 +339,12 @@ inline int PSMT_BITMODE(int psm) {return (psm & 0x7);}
inline int PSMT_BITS_NUM(int psm)
{
// Treat these as 32 bit.
if ((psm == PSMT8H) || (psm == PSMT4HL) || (psm == PSMT4HH))
{
return 4;
}
switch (PSMT_BITMODE(psm))
{
case 4:
@ -676,6 +705,9 @@ typedef struct
pathInfo path[4];
GIFRegDIMX dimx;
GSMemory mem;
GSClut clut_buffer;
void setRGBA(u32 r, u32 g, u32 b, u32 a)
{
rgba = (r & 0xff) |

View File

@ -27,7 +27,49 @@
#include "zerogs.h"
#include "targets.h"
extern _getPixelAddress getPixelFun[64];
u8* g_pbyGSMemory = NULL; // 4Mb GS system mem
void GSMemory::init()
{
const u32 mem_size = MEMORY_END + 0x10000; // leave some room for out of range accesses (saves on the checks)
// clear
g_pbyGSMemory = (u8*)_aligned_malloc(mem_size, 1024);
memset(g_pbyGSMemory, 0, mem_size);
}
void GSMemory::destroy()
{
_aligned_free(g_pbyGSMemory);
g_pbyGSMemory = NULL;
}
u8* GSMemory::get() { return g_pbyGSMemory; }
u8* GSMemory::get(u32 addr) { return &g_pbyGSMemory[addr*8]; }
u8* GSMemory::get_raw(u32 addr) { return &g_pbyGSMemory[addr]; }
u8* g_pbyGSClut = NULL; // ZZ
void GSClut::init()
{
g_pbyGSClut = (u8*)_aligned_malloc(256 * 8, 1024); // need 512 alignment!
memset(g_pbyGSClut, 0, 256*8);
}
void GSClut::destroy()
{
_aligned_free(g_pbyGSClut);
g_pbyGSClut = NULL;
}
u8* GSClut::get() { return g_pbyGSClut; }
u8* GSClut::get(u32 addr) { return &g_pbyGSClut[addr*8]; }
u8* GSClut::get_raw(u32 addr) { return &g_pbyGSClut[addr]; }
extern _getPixelAddress getPixelFun[64];
namespace ZeroGS
{
@ -63,16 +105,7 @@ extern _getPixelAddress getPixelFun[64];
return;
}
// For some reason, we have to treat these as 32 bit.
if ((psm == PSMT8H) || (psm == PSMT4HL) || (psm == PSMT4HH))
{
bits = 4;
}
else
{
bits = PSMT_BITS_NUM(psm);
}
bits = PSMT_BITS_NUM(psm);
start = getPixelFun[psm](x, y, bp, bw);
end = getPixelFun[psm](x + w - 1, y + h - 1, bp, bw) + 1;
@ -100,8 +133,6 @@ extern _getPixelAddress getPixelFun[64];
{
FUNCLOG
//if (g_bIsLost) return;
#if defined(ZEROGS_DEVBUILD)
if (gs.trxpos.dx + gs.imageWnew > gs.dstbuf.bw)
ZZLog::Warn_Log("Transfer error, width exceeded.");
@ -145,8 +176,6 @@ extern _getPixelAddress getPixelFun[64];
{
FUNCLOG
// if (g_bIsLost) return;
int start, end;
GetRectMemAddress(start, end, gs.dstbuf.psm, gs.imageX, gs.imageY, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw);
@ -473,7 +502,7 @@ __forceinline void _TransferLocalLocal_4()
{
_TransferLocalLocal_4();
}
g_MemTargs.ClearRange(dststart, dstend);
#ifdef ZEROGS_DEVBUILD

View File

@ -302,18 +302,6 @@ _getPixelAddress_0 getPixelFun_0[64] =
NULL, NULL, getPixelAddress16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_getPixelAddress getPixelFun[64] =
{
getPixelAddress32, getPixelAddress24, getPixelAddress16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8, getPixelAddress4, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HH, NULL, NULL, NULL,
getPixelAddress32Z, getPixelAddress24Z, getPixelAddress16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16SZ, NULL, NULL, NULL, NULL, NULL
};
_writePixel_0 writePixelFun_0[64] =
{
writePixel32_0, writePixel24_0, writePixel16_0, NULL, NULL, NULL, NULL, NULL,
@ -338,6 +326,18 @@ _readPixel_0 readPixelFun_0[64] =
NULL, NULL, readPixel16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_getPixelAddress getPixelFun[64] =
{
getPixelAddress32, getPixelAddress24, getPixelAddress16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8, getPixelAddress4, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HH, NULL, NULL, NULL,
getPixelAddress32Z, getPixelAddress24Z, getPixelAddress16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16SZ, NULL, NULL, NULL, NULL, NULL
};
_writePixel writePixelFun[64] =
{
writePixel32, writePixel24, writePixel16, NULL, NULL, NULL, NULL, NULL,

View File

@ -44,25 +44,27 @@ GIFRegHandler g_GIFTempRegHandlers[16] = {0};
u32 s_uTex1Data[2][2] = {{0, }};
u32 s_uClampData[2] = {0, };
u32 results[65535] = {0, };
//u32 results[65535] = {0, };
// return true if triangle SHOULD be painted.
// My brain hurts. --arcum42
// return true if triangle SHOULD be painted.
inline bool NoHighlights(int i)
{
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
int resultA = prim->iip + ((prim->tme) << 1) + ((prim->fge) << 2) + ((prim->abe) << 3) + ((prim->aa1) << 4) + ((prim->fst) << 5) + ((prim->ctxt) << 6) + ((prim->fix) << 7) +
((ZeroGS::vb[i].zbuf.psm) << 8);
int dummy = 0;
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
const pixTest curtest = ZeroGS::vb[i].test;
int result = curtest.ate + ((curtest.atst) << 1) + ((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst) << 9);
if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
// Old code
//Old code
return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ;
}

View File

@ -42,47 +42,41 @@ GIFRegHandler g_GIFTempRegHandlers[16] = {0};
u32 s_uTex1Data[2][2] = {{0, }};
u32 s_uClampData[2] = {0, };
u32 results[65535] = {0, };
//u32 results[65535] = {0, };
// return true if triangle SHOULD be painted.
inline bool NoHighlights(int i)
{
// This is hack-code, I still in search of correct reason, why some triangles should not be drawn.
// I'd have thought we could just test prim->_val and ZeroGS::vb[i].zbuf.psm directly...
int resultA = prim->iip + ((prim->tme) << 1) + ((prim->fge) << 2) + ((prim->abe) << 3) + ((prim->aa1) << 4) + ((prim->fst) << 5) + ((prim->ctxt) << 6) + ((prim->fix) << 7) +
((ZeroGS::vb[i].zbuf.psm) << 8);
int dummy = 0;
u32 resultA = prim->iip + (2 * (prim->tme)) + (4 * (prim->fge)) + (8 * (prim->abe)) + (16 * (prim->aa1)) + (32 * (prim->fst)) + (64 * (prim->ctxt)) + (128 * (prim->fix));
// if ( results[resultA] == 0 ) {
// results[resultA] = 1;
// ZZLog::Error_Log("%x = %d %d %d %d %d %d %d %d psm: %x", resultA, prim->iip, (prim->tme), (prim->fge), (prim->abe) , (prim->aa1) ,(prim->fst), (prim->ctxt), (prim->fix), ZeroGS::vb[i].zbuf.psm) ;
// ZZLog::ERROR_LOG("%x = %d %d %d %d %d %d %d %d \n", resultA, prim->iip, (prim->tme), (prim->fge), (prim->abe) , (prim->aa1) ,(prim->fst), (prim->ctxt), (prim->fix)) ;
// }
// if (resultA == 0xb && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
const pixTest curtest = ZeroGS::vb[i].test;
// Again, couldn't we just test curtest._val?
int result = curtest.ate + ((curtest.atst) << 1) + ((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst) << 9);
u32 result = curtest.ate + ((curtest.atst) << 1) +((curtest.afail) << 4) + ((curtest.date) << 6) + ((curtest.datm) << 7) + ((curtest.zte) << 8) + ((curtest.ztst)<< 9);
// if (resultA == 0xb)
// if ( results[result] == 0) {
// results[result] = 1;
// ZZLog::Error_Log("0x%x = %d %d %d %d %d %d %d %d ", result, curtest.ate, curtest.atst, curtest.aref, curtest.afail, curtest.date, curtest.datm, curtest.zte, curtest.ztst);
// }
// 0, -50b, -500, !-300, -30a, -50a, -5cb, +100 (zte==1), -50d
// if (result == 0x50b && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
// if psm is 16S or 24, tme, abe, & fst are true, the rest are false, result is 0x302 or 0x700, and there is a mask.
//if (result == 0x50b && ZeroGS::vb[i].zbuf.zmsk ) return false; //ATF
//if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
//if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
if ((resultA == 0x3a2a || resultA == 0x312a) && (result == 0x302 || result == 0x700) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Silent Hill:SM and Front Mission 5, result != 0x300
// if psm is 24, abe is true, tme doesn't matter, the rest are false, result is 0x54c or 0x50c and there is a mask.
if (((resultA == 0x3100) || (resultA == 0x3108)) && ((result == 0x54c) || (result == 0x50c)) && (ZeroGS::vb[i].zbuf.zmsk)) return false; // Okage
// if psm is 24, abe & tme are true, the rest are false, and no result.
if ((resultA == 0x310a) && (result == 0x0)) return false; // Radiata Stories
// if psm is 16S, tme, abe, fst, and ctxt are true, the rest are false, result is 0x330 or 0x500, and there is a mask.
if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
//if (resultA == 0x3a6a && (result == 0x300 || result == 0x500) && ZeroGS::vb[i].zbuf.zmsk) return false; // Okami, result != 0x30d
// if ((resultA == 0x300b) && (result == 0x300) && ZeroGS::vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
//if ((resultA == 0x300b) && (result == 0x300) && ZeroGS::vb[i].zbuf.zmsk) return false; // ATF, but no Melty Blood
// Old code
return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ;

View File

@ -53,7 +53,10 @@ bool Open()
void Close()
{
if (gsLog != NULL) fclose(gsLog);
if (gsLog != NULL) {
fclose(gsLog);
gsLog = NULL;
}
}
void SetDir(const char* dir)
@ -62,7 +65,7 @@ void SetDir(const char* dir)
s_strLogPath = (dir==NULL) ? "logs/" : dir;
// Reload the log file after updated the path
if (gsLog != NULL) fclose(gsLog);
Close();
Open();
}

View File

@ -742,7 +742,7 @@ inline void AfterRendererUnimportantJob()
AfterRenderCountStatistics();
if (s_nNewWidth >= 0 && s_nNewHeight >= 0/* && !g_bIsLost*/)
if (s_nNewWidth >= 0 && s_nNewHeight >= 0)
AfterRendererResizeWindow();
maxmin = 608;
@ -830,7 +830,7 @@ int count = 0;
// The main renderer function
void ZeroGS::RenderCRTC(int interlace)
{
if (/*g_bIsLost || */FrameSkippingHelper()) return;
if (FrameSkippingHelper()) return;
u32 bInterlace = SMODE2->INT && SMODE2->FFMD && (conf.interlace < 2);
@ -847,7 +847,15 @@ void ZeroGS::RenderCRTC(int interlace)
tex0Info& texframe = dispinfo[i];
if (texframe.th <= 1) continue;
if (SMODE2->INT && SMODE2->FFMD) texframe.th >>= 1;
if (SMODE2->INT && SMODE2->FFMD)
{
texframe.th >>= 1;
// Final Fantasy X-2 issue here.
if (conf.interlace == 2 && texframe.th >= 512)
texframe.th >>= 1;
}
if (i == 0) RenderSetupBlending();
if (bUsingStencil) RenderSetupStencil(i);

View File

@ -32,8 +32,6 @@ extern HDC hDC; // Private GDI Device Context
extern HGLRC hRC; // Permanent Rendering Context
#endif
//extern bool g_bIsLost;
extern int s_frameskipping;
extern float fFPS;
extern unsigned char zgsrevision, zgsbuild, zgsminor;

View File

@ -497,6 +497,10 @@ bool ZeroGS::Create(int _width, int _height)
// check the max texture width and height
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &g_MaxTexWidth);
// Limit the texture size supported to 8192. We do not need bigger texture.
// Besides the following assertion is false when texture are too big.
// ZZoglFlush.cpp:2349: assert(fblockstride >= 1.0f)
g_MaxTexWidth = min(8192, g_MaxTexWidth);
g_MaxTexHeight = g_MaxTexWidth / 4;
GPU_TEXWIDTH = g_MaxTexWidth / 8;
@ -616,65 +620,86 @@ bool ZeroGS::Create(int _width, int _height)
// create the blocks texture
g_fBlockMult = 1;
bool do_not_use_billinear = false;
vector<char> vBlockData, vBilinearData;
BLOCK::FillBlocks(vBlockData, vBilinearData, 1);
glGenTextures(1, &ptexBlocks);
glBindTexture(GL_TEXTURE_2D, ptexBlocks);
g_internalFloatFmt = GL_ALPHA_FLOAT32_ATI;
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
Texture2D(g_internalFloatFmt, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
g_internalFloatFmt = GL_RGBA32F; // This is OpenGL 3.0 standard format, so it should be implemented in new cards.
g_internalRGBAFloatFmt = GL_RGBA32F;
g_internalRGBAFloat16Fmt = GL_RGBA16F;
if (glGetError() != GL_NO_ERROR)
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
// try different internal format
g_internalFloatFmt = GL_FLOAT_R32_NV;
Texture2D(g_internalFloatFmt, GL_RED, GL_FLOAT, &vBlockData[0]);
g_internalFloatFmt = GL_ALPHA_FLOAT32_ATI;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_FLOAT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
// This case is bad. But for really old cards it could be nice.
g_fBlockMult = 65535.0f*(float)g_fiGPU_TEXWIDTH ;
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
g_internalFloatFmt = GL_ALPHA16 ;
// We store block data on u16 rather float numbers. It's not as precise, but ALPHA16 is OpenGL 2.0 standard
// and uses only 16 bit. Old zerogs use red channel, but it does not work.
glTexImage2D(GL_TEXTURE_2D, 0, g_internalFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_ALPHA, GL_UNSIGNED_SHORT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Could not fill blocks.");
return false;
}
do_not_use_billinear = true;
ZZLog::Debug_Log("Using non-bilinear fill, quallity is outdated!");
}
else
ZZLog::Debug_Log("Use ATI_texture_float for blockdata.");
}
else
ZZLog::Debug_Log("Use GL_RGBA32F for blockdata.");
setTex2DFilters(GL_NEAREST);
setTex2DWrap(GL_REPEAT);
if (glGetError() != GL_NO_ERROR)
if (!do_not_use_billinear)
{
// error, resort to 16bit
g_fBlockMult = 65535.0f * (float)g_fiGPU_TEXWIDTH / 32.0f;
BLOCK::FillBlocks(vBlockData, vBilinearData, 0);
Texture2D(2, GL_R, GL_UNSIGNED_SHORT, &vBlockData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Could not fill blocks.");
return false;
}
ZZLog::GS_Log("Using non-bilinear fill.");
}
else
{
// fill in the bilinear blocks
// fill in the bilinear blocks (main variant).
glGenTextures(1, &ptexBilinearBlocks);
glBindTexture(GL_TEXTURE_2D, ptexBilinearBlocks);
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
if (glGetError() != GL_NO_ERROR)
{
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
g_internalRGBAFloat16Fmt = GL_FLOAT_RGBA16_NV;
Texture2D(g_internalRGBAFloatFmt, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
ZZLog::Debug_Log("ZZogl Fill bilinear blocks. ");
B_G(glGetError() == GL_NO_ERROR, return false);
g_internalRGBAFloatFmt = GL_RGBA_FLOAT32_ATI;
g_internalRGBAFloat16Fmt = GL_RGBA_FLOAT16_ATI;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
{
g_internalRGBAFloatFmt = GL_FLOAT_RGBA32_NV;
g_internalRGBAFloat16Fmt = GL_FLOAT_RGBA16_NV;
glTexImage2D(GL_TEXTURE_2D, 0, g_internalRGBAFloatFmt, BLOCK_TEXWIDTH, BLOCK_TEXHEIGHT, 0, GL_RGBA, GL_FLOAT, &vBilinearData[0]);
if (glGetError() != GL_NO_ERROR)
{
ZZLog::Error_Log("Fill bilinear blocks failed!");
return false;
}
else
ZZLog::Debug_Log("Fill bilinear blocks with NVidia_float.");
}
else
ZZLog::Debug_Log("Fill bilinear blocks with ATI_texture_float.");
}
else
{
// No, they failed on the first clause of the if statement, not the second.
//ZZLog::Error_Log("Fill bilinear blocks failed!");
}
ZZLog::Debug_Log("Fill bilinear blocks OK.!");
setTex2DFilters(GL_NEAREST);
setTex2DWrap(GL_REPEAT);

View File

@ -118,7 +118,6 @@ void Draw(const VB& curvb)
//------------------ variables
//extern bool g_bIsLost;
extern int g_nDepthBias;
extern float g_fBlockMult;
bool g_bUpdateStencil = 1;
@ -377,7 +376,7 @@ inline void FlushUpdateEffect()
// Check, maybe we cold skip flush
inline bool IsFlushNoNeed(VB& curvb, const pixTest& curtest)
{
if (curvb.nCount == 0 || (curtest.zte && curtest.ztst == 0) /*|| g_bIsLost*/ || IsBadFrame(curvb))
if (curvb.nCount == 0 || (curtest.zte && curtest.ztst == 0) || IsBadFrame(curvb))
{
curvb.nCount = 0;
return true;
@ -2033,7 +2032,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment)
case 3: // region rep x
v.x = 0.9999f;
v.z = fw;
v.z = (float)fw;
v2.x = (float)GPU_TEXMASKWIDTH / fw;
v2.z = pclamp->maxu / fw;
int correctMinu = pclamp->minu & (~pclamp->maxu); // (A && B) || C == (A && (B && !C)) + C
@ -2068,7 +2067,7 @@ void ZeroGS::SetTexClamping(int context, FRAGMENTSHADER* pfragment)
case 3: // region rep y
v.y = 0.9999f;
v.w = fh;
v.w = (float)fh;
v2.y = (float)GPU_TEXMASKWIDTH / fh;
v2.w = pclamp->maxv / fh;
int correctMinv = pclamp->minv & (~pclamp->maxv); // (A && B) || C == (A && (B && !C)) + C

Binary file not shown.

View File

@ -1,19 +1,4 @@
// Cg Shaders for PS2 GS emulation
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Cg Shaders for PS2 GS emulation
// divides by z for every pixel, instead of in vertex shader
// fixes kh textures
@ -92,7 +77,6 @@ float2 ps2memcoord(float2 realtex)
float2 fblock = frac(realtex.xy);
off.xy = realtex.xy-fblock.xy;
//#if 0
#ifdef ACCURATE_DECOMPRESSION
off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar;
off.x = dot(off.xy, g_fTexOffset.xy);
@ -216,9 +200,9 @@ float2 ps2addr(float2 coord)
float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zz).x * g_fClampExts.x + g_fClampExts.z;
final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zx).x * g_fClampExts.x + g_fClampExts.z;
if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.ww).x * g_fClampExts.y + g_fClampExts.w;
final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.wy).x * g_fClampExts.y + g_fClampExts.w;
return final;
}
@ -337,7 +321,7 @@ decl_ps2shade_##num(_tex16to32h) \
// nearest
#define decl_ps2shade_0(bit) \
half4 ps2shade0##bit( TEX_DECL tex) \
float4 ps2shade0##bit( TEX_DECL tex) \
{ \
return tex2DPS##bit( ps2addr(TEX_XY)); \
} \
@ -745,7 +729,7 @@ half4 BilinearFloat16(float2 tex0)
half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
{
float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
half4 c = BilinearFloat16(tex0);
float4 c = BilinearFloat16(tex0);
c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter;
return c;
}

View File

@ -33,7 +33,6 @@
using namespace ZeroGS;
extern int g_TransferredToGPU;
//extern bool g_bIsLost;
extern bool g_bUpdateStencil;
#if !defined(ZEROGS_DEVBUILD)
@ -2543,24 +2542,25 @@ u32 ZeroGS::CBitwiseTextureMngr::GetTexInt(u32 bitvalue, u32 ptexDoNotDelete)
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on generation of bitmask texture.");
vector<u16> data(GPU_TEXMASKWIDTH + 1);
vector<u16> data(GPU_TEXMASKWIDTH);
for (u32 i = 0; i < GPU_TEXMASKWIDTH; ++i)
{
data[i] = (((i << MASKDIVISOR) & bitvalue) << 6); // add the 1/2 offset so that
}
// data[GPU_TEXMASKWIDTH] = 0; // I remove GPU_TEXMASKWIDTH+1 element of this texture, because it was a reason of FFC crush
// Probably, some sort of PoT incompability in drivers.
data[GPU_TEXMASKWIDTH] = 0;
glBindTexture(GL_TEXTURE_RECTANGLE_NV, ptex);
glBindTexture(GL_TEXTURE_RECTANGLE, ptex);
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on binding bitmask texture.");
TextureRect(GL_LUMINANCE16, GPU_TEXMASKWIDTH + 1, 1, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]);
TextureRect2(GL_LUMINANCE16, GPU_TEXMASKWIDTH, 1, GL_LUMINANCE, GL_UNSIGNED_SHORT, &data[0]);
if (glGetError() != GL_NO_ERROR) ZZLog::Error_Log("Error on applying bitmask texture.");
// Removing clamping, as it seems lead to numerous troubles at some drivers
// Need to observe, may be clamping is not really needed.
/* setTexRectWrap(GL_REPEAT);
/* setRectWrap2(GL_REPEAT);
GLint Error = glGetError();
if( Error != GL_NO_ERROR ) {

View File

@ -23,6 +23,10 @@
#define TARGET_VIRTUAL_KEY 0x80000000
#include "PS2Edefs.h"
#ifndef GL_TEXTURE_RECTANGLE
#define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV
#endif
inline Vector DefaultOneColor(FRAGMENTSHADER ptr)
{
Vector v = Vector(1, 1, 1, 1);
@ -345,6 +349,11 @@ static __forceinline void TextureRect(GLint iFormat, GLint width, GLint height,
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, iFormat, width, height, 0, format, type, pixels);
}
static __forceinline void TextureRect2(GLint iFormat, GLint width, GLint height, GLenum format, GLenum type, const GLvoid* pixels)
{
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, iFormat, width, height, 0, format, type, pixels);
}
static __forceinline void TextureRect(GLenum attach, GLuint id = 0)
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attach, GL_RENDERBUFFER_EXT, id);
@ -386,5 +395,11 @@ static __forceinline void setRectWrap(GLint type)
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, type);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, type);
}
static __forceinline void setRectWrap2(GLint type)
{
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, type);
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, type);
}
#endif

View File

@ -48,10 +48,6 @@ extern int g_nFrame, g_nRealFrame;
//extern int s_nFullscreen;
//-------------------------- Variables
// Context is lost -- could not draw.
// Setting this variable to true is also lost. Fixme.
//bool g_bIsLost = false;
primInfo *prim;
CGprogram g_vsprog = 0, g_psprog = 0; // 2 -- ZZ
@ -92,10 +88,7 @@ int s_nResolveCounts[30] = {0}; // resolve counts for last 30 frames
////////////////////
// State parameters
int nBackbufferWidth, nBackbufferHeight;
u8* g_pbyGSMemory = NULL; // 4Mb GS system mem
u8* g_pbyGSClut = NULL; // ZZ
int nBackbufferWidth, nBackbufferHeight; // ZZ
namespace ZeroGS
{
@ -487,8 +480,6 @@ void ZeroGS::Prim()
{
FUNCLOG
// if (g_bIsLost) return;
VB& curvb = vb[prim->ctxt];
if (curvb.CheckPrim()) Flush(prim->ctxt);
@ -582,21 +573,6 @@ void ZeroGS::RenderCustom(float fAlpha)
GL_REPORT_ERROR();
}
void ZeroGS::Restore()
{
FUNCLOG
return;
/*if (!g_bIsLost) return;
//if( SUCCEEDED(pd3dDevice->Reset(&d3dpp)) ) {
g_bIsLost = false;
// handle lost states
ZeroGS::ChangeDeviceSize(nBackbufferWidth, nBackbufferHeight);*/
//}
}
//////////////////////////
// Internal Definitions //
//////////////////////////
@ -851,18 +827,15 @@ void ZeroGS::SetFogColor(u32 fog)
ZeroGS::FlushBoth();
//if (!g_bIsLost)
//{
SetShaderCaller("SetFogColor");
Vector v;
SetShaderCaller("SetFogColor");
Vector v;
// set it immediately
// v.x = (gs.fogcol & 0xff) / 255.0f;
// v.y = ((gs.fogcol >> 8) & 0xff) / 255.0f;
// v.z = ((gs.fogcol >> 16) & 0xff) / 255.0f;
v.SetColor(gs.fogcol);
ZZcgSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
//}
// set it immediately
// v.x = (gs.fogcol & 0xff) / 255.0f;
// v.y = ((gs.fogcol >> 8) & 0xff) / 255.0f;
// v.z = ((gs.fogcol >> 16) & 0xff) / 255.0f;
v.SetColor(gs.fogcol);
ZZcgSetParameter4fv(g_fparamFogColor, v, "g_fParamFogColor");
// }
}
@ -1119,8 +1092,6 @@ void ZeroGS::texClutWrite(int ctx)
FUNCLOG
s_bTexFlush = false;
//if (g_bIsLost) return;
tex0Info& tex0 = vb[ctx].tex0;
assert(PSMT_ISCLUT(tex0.psm));

View File

@ -112,9 +112,6 @@ extern u32 ptexLogo;
extern int nLogoWidth, nLogoHeight;
extern int nBackbufferWidth, nBackbufferHeight;
extern u8* g_pbyGSMemory;
extern u8* g_pbyGSClut; // the temporary clut buffer
namespace ZeroGS
{
@ -474,7 +471,6 @@ inline bool Create_Window(int _width, int _height);
bool Create(int width, int height);
void Destroy(bool bD3D);
void Restore(); // call to restore device
void Reset(); // call to destroy video resources
void GSStateReset();
void GSReset();