Adjust indentation in zerogs to be consistant between dx and opengl, making it easier to compare the two.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@530 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2009-01-01 04:07:10 +00:00 committed by Gregory Hainaut
parent efa4602765
commit bee1d26824
34 changed files with 12986 additions and 12986 deletions

View File

@ -46,8 +46,8 @@ extern HWND GShwnd;
typedef int BOOL;
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
@ -64,7 +64,7 @@ typedef int BOOL;
struct Vector_16F
{
u16 x, y, z, w;
u16 x, y, z, w;
};
@ -370,7 +370,7 @@ typedef struct {
u8 aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x
u8 bilinear; // set to enable bilinear support
u32 options;
u32 gamesettings; // default game settings
u32 gamesettings; // default game settings
int width, height;
int winstyle; // window style before full screen
#ifdef GS_LOG
@ -716,7 +716,7 @@ __forceinline u16 Float16ToALPHA(u16 f) {
#ifndef COLOR_ARGB
#define COLOR_ARGB(a,r,g,b) \
((u32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
((u32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#endif
// assumes that positive in [1,2] (then extracts fraction by just looking at the specified bits)

View File

@ -70,21 +70,21 @@ u32 g_nGenVars = 0, g_nTexVars = 0, g_nAlphaVars = 0, g_nResolve = 0;
#define VER 97
const unsigned char version = PS2E_GS_VERSION;
unsigned char revision = 0; // revision and build gives plugin version
unsigned char build = VER;
unsigned char build = VER;
unsigned char minor = 1;
#ifdef _DEBUG
char *libraryName = "ZeroGS (Debug) ";
char *libraryName = "ZeroGS (Debug) ";
#elif defined(RELEASE_TO_PUBLIC)
#ifdef ZEROGS_SSE2
char *libraryName = "ZeroGS KOSMOS";
char *libraryName = "ZeroGS KOSMOS";
#else
char *libraryName = "ZeroGS KOSMOS (no SSE2)";
char *libraryName = "ZeroGS KOSMOS (no SSE2)";
#endif
#else
char *libraryName = "ZeroGS (Dev) ";
char *libraryName = "ZeroGS (Dev) ";
#endif
static const char* s_aa[5] = { "AA none |", "AA 2x |", "AA 4x |", "AA 8x", "AA 16x" };
@ -142,7 +142,7 @@ void __Log(char *fmt, ...) {
void ERROR_LOG(char *fmt, ...) {
va_list list;
printf("ZeroGS: ");
printf("ZeroGS: ");
va_start(list, fmt);
vfprintf(gsLog, fmt, list);
@ -161,16 +161,16 @@ void CALLBACK GSsetGameCRC(int crc, int options)
{
VALIDATE_THRESH = 8;
g_GameSettings = conf.gamesettings|options;
conf.mrtdepth = !(conf.gamesettings&GAME_DISABLEMRTDEPTH);
conf.mrtdepth = !(conf.gamesettings&GAME_DISABLEMRTDEPTH);
g_GameSettings |= GAME_PATH3HACK;
g_LastCRC = crc;
g_GameSettings |= GAME_PATH3HACK;
g_LastCRC = crc;
//g_GameSettings |= GAME_PARTIALDEPTH;
//g_GameSettings |= GAME_PARTIALDEPTH;
// g_GameSettings |= GAME_DOPARALLELCTX|GAME_XENOSPECHACK;
// VALIDATE_THRESH = 64;
// TEXDESTROY_THRESH = 32;
// g_GameSettings |= GAME_DOPARALLELCTX|GAME_XENOSPECHACK;
// VALIDATE_THRESH = 64;
// TEXDESTROY_THRESH = 32;
switch(crc) {
case 0x54A548B4: // crash n burn
@ -180,12 +180,12 @@ void CALLBACK GSsetGameCRC(int crc, int options)
}
break;
case 0xA3D63039: // xenosaga(j)
case 0x0E7807B2: // xenosaga(u)
g_GameSettings |= GAME_DOPARALLELCTX;
VALIDATE_THRESH = 64;
TEXDESTROY_THRESH = 32;
break;
case 0xA3D63039: // xenosaga(j)
case 0x0E7807B2: // xenosaga(u)
g_GameSettings |= GAME_DOPARALLELCTX;
VALIDATE_THRESH = 64;
TEXDESTROY_THRESH = 32;
break;
case 0x7D2FE035: // espgaluda (j)
VALIDATE_THRESH = 24;
@ -193,12 +193,12 @@ void CALLBACK GSsetGameCRC(int crc, int options)
break;
}
printf("ZeroGS: Set game options: 0x%8.8x\n", g_GameSettings);
printf("ZeroGS: Set game options: 0x%8.8x\n", g_GameSettings);
}
void CALLBACK GSsetFrameSkip(int frameskip)
{
s_frameskipping |= frameskip;
s_frameskipping |= frameskip;
if( frameskip && g_nFrameRender > 1 ) {
for(int i = 0; i < 16; ++i) {
@ -302,10 +302,10 @@ LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static int nWindowWidth = 0, nWindowHeight = 0;
switch( msg ) {
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
switch( msg ) {
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_KEYDOWN:
// switch(wParam) {
@ -341,9 +341,9 @@ LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
case WM_SETCURSOR:
SetCursor(NULL);
break;
}
}
return DefWindowProc( hWnd, msg, wParam, lParam );
return DefWindowProc( hWnd, msg, wParam, lParam );
}
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
@ -360,7 +360,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
assert( GSirq != NULL );
LoadConfig();
g_GameSettings = 0;
g_GameSettings = 0;
strcpy(GStitle, Title);
@ -399,7 +399,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
if( FAILED(ZeroGS::InitDeviceObjects()) )
return -1;
if( conf.bilinear == 2 ) {
if( conf.bilinear == 2 ) {
ZeroGS::AddMessage("forced bilinear filtering - on", 1000);
}
else if( conf.bilinear == 1 ) {
@ -410,13 +410,13 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread) {
sprintf(strtitle, "anti-aliasing - %s", s_aa[conf.aa], 1000);
ZeroGS::AddMessage(strtitle);
}
if( conf.options & GSOPTION_WIDESCREEN ) {
ZeroGS::AddMessage("16:9 widescreen - on", 1000);
}
if( conf.options & GSOPTION_WIDESCREEN ) {
ZeroGS::AddMessage("16:9 widescreen - on", 1000);
}
// set just in case
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)MsgProc);
SetWindowLongPtr(GShwnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)MsgProc);
ShowWindow( GShwnd, SW_SHOWDEFAULT );
UpdateWindow( GShwnd );
SetFocus(GShwnd);
@ -470,7 +470,7 @@ void CALLBACK GSchangeSaveState(int newstate, const char* filename)
void CALLBACK GSmakeSnapshot(char *path)
{
FILE *bmpfile;
char filename[256];
char filename[256];
u32 snapshotnr = 0;
// increment snapshot value & try to get filename
@ -535,7 +535,7 @@ void CALLBACK GSvsync(int interlace)
}
else {
conf.bilinear = (conf.bilinear+1)%3;
sprintf(strtitle, "bilinear filtering - %s", pbilinear[conf.bilinear]);
sprintf(strtitle, "bilinear filtering - %s", pbilinear[conf.bilinear]);
}
}
else {
@ -573,7 +573,7 @@ void CALLBACK GSvsync(int interlace)
g_bDisplayFPS ^= 1;
}
else {
conf.options ^= GSOPTION_WIREFRAME;
conf.options ^= GSOPTION_WIREFRAME;
SETRS(D3DRS_FILLMODE, (conf.options&GSOPTION_WIREFRAME)?D3DFILL_WIREFRAME:D3DFILL_SOLID);
sprintf(strtitle, "wireframe rendering - %s", (conf.options&GSOPTION_WIREFRAME)?"on":"off");
// conf.options ^= GSOPTION_CAPTUREAVI;
@ -587,15 +587,15 @@ void CALLBACK GSvsync(int interlace)
}
else if( msg.wParam == VK_F9 ) {
if( (GetKeyState(VK_SHIFT)&0x8000) ) {
conf.options ^= GSOPTION_WIDESCREEN;
sprintf(strtitle, "16:9 widescreen - %s", (conf.options&GSOPTION_WIDESCREEN)?"on":"off");
}
else {
g_GameSettings ^= GAME_PATH3HACK;
sprintf(strtitle, "path3 hack - %s", (g_GameSettings&GAME_PATH3HACK) ? "on" : "off");
}
ZeroGS::AddMessage(strtitle);
if( (GetKeyState(VK_SHIFT)&0x8000) ) {
conf.options ^= GSOPTION_WIDESCREEN;
sprintf(strtitle, "16:9 widescreen - %s", (conf.options&GSOPTION_WIDESCREEN)?"on":"off");
}
else {
g_GameSettings ^= GAME_PATH3HACK;
sprintf(strtitle, "path3 hack - %s", (g_GameSettings&GAME_PATH3HACK) ? "on" : "off");
}
ZeroGS::AddMessage(strtitle);
}
else if( msg.wParam == VK_ESCAPE ) {
@ -660,7 +660,7 @@ void CALLBACK GSvsync(int interlace)
_snprintf(strtitle, 512, "%s 0.%d.%d %.1f fps | %s%s%s%s %s (%.1f)", libraryName, build, minor, fFPS,
(conf.interlace < 2) ? "interlace | " : "",
conf.bilinear ? (conf.bilinear==2?"forced bilinear | ":"bilinear | ") : "",
conf.bilinear ? (conf.bilinear==2?"forced bilinear | ":"bilinear | ") : "",
conf.aa ? s_aa[conf.aa] : "",
(g_GameSettings&GAME_FFXHACK) ? "ffxhack | " : "",
g_pShaders[g_nPixelShaderVer], (ppf&0xfffff)/(float)UPDATE_FRAMES);
@ -707,11 +707,11 @@ void GIFtag(pathInfo *path, u32 *data) {
#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],
// data[3], data[2], data[1], data[0],
// path->tag.eop, path->tag.nloop, tagflg, path->tag.nreg, tagpre);
#endif
path->mode = tagflg+1;
path->mode = tagflg+1;
switch (tagflg) {
case 0x0:
@ -759,11 +759,11 @@ 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;
// 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;
}
void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
@ -772,15 +772,15 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
assert( g_hCurrentThread == GetCurrentThread() );
#endif
//s_pLastPath = path;
//s_pLastPath = path;
//BOOL bAfter0Tag = 0;
// if( conf.log & 0x20 ) {
// __Log("%d: %x:%x\n", (path==&gs.path3)?3:(path==&gs.path2?2:1), pMem, size);
// for(int i = 0; i < size; i++) {
// __Log("%x %x %x %x\n", pMem[4*i+0], pMem[4*i+1], pMem[4*i+2], pMem[4*i+3]);
// }
// }
// if( conf.log & 0x20 ) {
// __Log("%d: %x:%x\n", (path==&gs.path3)?3:(path==&gs.path2?2:1), pMem, size);
// for(int i = 0; i < size; i++) {
// __Log("%x %x %x %x\n", pMem[4*i+0], pMem[4*i+1], pMem[4*i+2], pMem[4*i+3]);
// }
// }
while(size > 0)
{
@ -790,38 +790,38 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
pMem+= 4;
size--;
if( (g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop )
nPath3Hack = 1;
if( path == &gs.path1 ) {
if( (g_GameSettings & GAME_PATH3HACK) && path == &gs.path3 && gs.path3.tag.eop )
nPath3Hack = 1;
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)) {
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
ERROR_LOG("VU1 too much data, ignore if gfx are fine\n");
lasttime = timeGetTime();
}
path->tag.nloop = 0;
return;
}
// if too much data, just ignore
if( path->tag.nloop * (path->tag.nreg / 4) > (int)size * (path->mode==2?2:1)) {
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
ERROR_LOG("VU1 too much data, ignore if gfx are fine\n");
lasttime = timeGetTime();
}
path->tag.nloop = 0;
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 ) {
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
ERROR_LOG("Invalid unpack type\n");
lasttime = timeGetTime();
}
path->tag.nloop = 0;
return;
}
}
}
}
// 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 ) {
static int lasttime = 0;
if( timeGetTime() - lasttime > 5000 ) {
ERROR_LOG("Invalid unpack type\n");
lasttime = timeGetTime();
}
path->tag.nloop = 0;
return;
}
}
}
}
if(path->tag.nloop == 0 ) {
//bAfter0Tag = 1;
@ -867,7 +867,7 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
{
int reg = (int)((path->regs >> path->regn) & 0xf);
g_GIFPackedRegHandlers[reg](pMem);
g_GIFPackedRegHandlers[reg](pMem);
path->regn += 4;
if (path->tag.nreg == path->regn) {
@ -906,7 +906,7 @@ void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size)
break;
}
case 3: // GIF_IMAGE (FROM_VFRAM)
case 4:
case 4:
{
if(gs.imageTransfer >= 0 && gs.imageTransfer <= 1)
{
@ -973,7 +973,7 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size)
//DVProfileFunc _pf("Transf3");
//assert( ((u32)pMem & 0xf) == 0 );
nPath3Hack = 0;
nPath3Hack = 0;
_GSgifTransfer(&gs.path3, pMem, size);
}
@ -990,7 +990,7 @@ void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr)
#ifdef _DEBUG
PRIM_LOG("count: %d\n", count);
count++;
count++;
// for(int i = addr; i < 0x4000; i += 16 ) {
// u32* mem = (u32*)((u8*)pMem+i);
@ -1031,23 +1031,23 @@ void CALLBACK GSreadFIFO2(u64 *pMem, int qwc)
int CALLBACK GSsetupRecording(int start, void* pData)
{
if( start ) {
if( conf.options & GSOPTION_CAPTUREAVI )
return 1;
if( !ZeroGS::StartCapture() )
return 0;
conf.options |= GSOPTION_CAPTUREAVI;
printf("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");
}
if( start ) {
if( conf.options & GSOPTION_CAPTUREAVI )
return 1;
if( !ZeroGS::StartCapture() )
return 0;
conf.options |= GSOPTION_CAPTUREAVI;
printf("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");
}
return 1;
return 1;
}
s32 CALLBACK GSfreeze(int mode, freezeData *data) {
@ -1068,10 +1068,10 @@ s32 CALLBACK GSfreeze(int mode, freezeData *data) {
extern HINSTANCE hInst;
void CALLBACK GSconfigure() {
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
DialogBox(hInst,
MAKEINTRESOURCE(IDD_CONFIG),
GetActiveWindow(),
(DLGPROC)ConfigureDlgProc);
if( g_nPixelShaderVer == SHADER_20 )
conf.bilinear = 0;

View File

@ -113,9 +113,9 @@ u32 g_columnTable32[8][8] = {
u32 g_columnTable16[8][16] = {
{ 0, 2, 8, 10, 16, 18, 24, 26,
1, 3, 9, 11, 17, 19, 25, 27 },
1, 3, 9, 11, 17, 19, 25, 27 },
{ 4, 6, 12, 14, 20, 22, 28, 30,
5, 7, 13, 15, 21, 23, 29, 31 },
5, 7, 13, 15, 21, 23, 29, 31 },
{ 32, 34, 40, 42, 48, 50, 56, 58,
33, 35, 41, 43, 49, 51, 57, 59 },
{ 36, 38, 44, 46, 52, 54, 60, 62,
@ -132,7 +132,7 @@ u32 g_columnTable16[8][16] = {
u32 g_columnTable8[16][16] = {
{ 0, 4, 16, 20, 32, 36, 48, 52, // column 0
2, 6, 18, 22, 34, 38, 50, 54 },
2, 6, 18, 22, 34, 38, 50, 54 },
{ 8, 12, 24, 28, 40, 44, 56, 60,
10, 14, 26, 30, 42, 46, 58, 62 },
{ 33, 37, 49, 53, 1, 5, 17, 21,
@ -167,9 +167,9 @@ u32 g_columnTable8[16][16] = {
u32 g_columnTable4[16][32] = {
{ 0, 8, 32, 40, 64, 72, 96, 104, // column 0
2, 10, 34, 42, 66, 74, 98, 106,
4, 12, 36, 44, 68, 76, 100, 108,
6, 14, 38, 46, 70, 78, 102, 110 },
2, 10, 34, 42, 66, 74, 98, 106,
4, 12, 36, 44, 68, 76, 100, 108,
6, 14, 38, 46, 70, 78, 102, 110 },
{ 16, 24, 48, 56, 80, 88, 112, 120,
18, 26, 50, 58, 82, 90, 114, 122,
20, 28, 52, 60, 84, 92, 116, 124,
@ -283,9 +283,9 @@ End: \
} \
} \
for(; i < endY; ++i) { \
for(; j < gs.imageEndX && nSize > 0; j += widthlimit, nSize -= widthlimit, pbuf += widthlimit) { \
for(; j < gs.imageEndX && nSize > 0; j += widthlimit, nSize -= widthlimit, pbuf += widthlimit) { \
/* write as many pixel at one time as possible */ \
if( nSize < widthlimit ) goto End; \
if( nSize < widthlimit ) goto End; \
writePixel##psm##_0(pstart, j%2048, i%2048, pbuf[0], gs.dstbuf.bw); \
\
if( widthlimit > 1 ) { \
@ -332,8 +332,8 @@ End: \
else { \
assert( /*(nSize%widthlimit) == 0 &&*/ widthlimit == 8 ); \
for(; i < endY; ++i) { \
for(; j < gs.imageEndX && nSize > 0; j += widthlimit, nSize -= widthlimit, pbuf += 3*widthlimit) { \
if( nSize < widthlimit ) goto End; \
for(; j < gs.imageEndX && nSize > 0; j += widthlimit, nSize -= widthlimit, pbuf += 3*widthlimit) { \
if( nSize < widthlimit ) goto End; \
/* write as many pixel at one time as possible */ \
writePixel##psm##_0(pstart, j%2048, i%2048, *(u32*)(pbuf+0), gs.dstbuf.bw); \
writePixel##psm##_0(pstart, (j+1)%2048, i%2048, *(u32*)(pbuf+3), gs.dstbuf.bw); \
@ -422,20 +422,20 @@ End: \
#define SwizzleBlock24(dst, src, pitch) { \
u8* pnewsrc = src; \
u32* pblock = tempblock; \
\
\
for(int by = 0; by < 7; ++by, pblock += 8, pnewsrc += pitch-24) { \
for(int bx = 0; bx < 8; ++bx, pnewsrc += 3) { \
pblock[bx] = *(u32*)pnewsrc; \
pblock[bx] = *(u32*)pnewsrc; \
} \
} \
for(int bx = 0; bx < 7; ++bx, pnewsrc += 3) { \
/* might be 1 byte out of bounds of GS memory */ \
pblock[bx] = *(u32*)pnewsrc; \
} \
/* do 3 bytes for the last copy */ \
*((u8*)pblock+28) = pnewsrc[0]; \
*((u8*)pblock+29) = pnewsrc[1]; \
*((u8*)pblock+30) = pnewsrc[2]; \
for(int bx = 0; bx < 7; ++bx, pnewsrc += 3) { \
/* might be 1 byte out of bounds of GS memory */ \
pblock[bx] = *(u32*)pnewsrc; \
} \
/* do 3 bytes for the last copy */ \
*((u8*)pblock+28) = pnewsrc[0]; \
*((u8*)pblock+29) = pnewsrc[1]; \
*((u8*)pblock+30) = pnewsrc[2]; \
SwizzleBlock32((u8*)dst, (u8*)tempblock, 32, 0x00ffffff); \
} \
@ -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) \
@ -517,7 +517,7 @@ int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
START_HOSTLOCAL(); \
\
const T* pbuf = (const T*)pbyMem; \
int nLeftOver = (nQWordSize*4*2)%(TRANSMIT_PITCH##TransSfx(2, T)); \
int nLeftOver = (nQWordSize*4*2)%(TRANSMIT_PITCH##TransSfx(2, T)); \
int nSize = nQWordSize*4*2/TRANSMIT_PITCH##TransSfx(2, T); \
nSize = min(nSize, gs.imageWnew * gs.imageHnew); \
\
@ -598,7 +598,7 @@ int TransferHostLocal##psm(const void* pbyMem, u32 nQWordSize) \
} \
\
END_HOSTLOCAL(); \
return (nSize * TRANSMIT_PITCH##TransSfx(2, T) + nLeftOver)/2; \
return (nSize * TRANSMIT_PITCH##TransSfx(2, T) + nLeftOver)/2; \
} \
DEFINE_TRANSFERLOCAL(32, u32, 2, 32, 8, 8, _, SwizzleBlock32);

View File

@ -315,7 +315,7 @@ __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)
return pix >> 4;
return pix >> 4;
else return pix & 0xf;
}
@ -451,7 +451,7 @@ __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)
return pix >> 4;
return pix >> 4;
else return pix & 0xf;
}

View File

@ -107,8 +107,8 @@ void __fastcall GIFPackedRegHandlerUV(u32* data)
#define KICK_VERTEX2() { \
if( ++gs.primC >= (int)g_primmult[prim->prim]) { \
if( !(g_GameSettings&GAME_XENOSPECHACK) || !ZeroGS::vb[prim->ctxt].zbuf.zmsk ) \
(*ZeroGS::drawfn[prim->prim])(); \
if( !(g_GameSettings&GAME_XENOSPECHACK) || !ZeroGS::vb[prim->ctxt].zbuf.zmsk ) \
(*ZeroGS::drawfn[prim->prim])(); \
gs.primC -= g_primsub[prim->prim]; \
} \
} \
@ -284,7 +284,7 @@ __forceinline void frameWrite(int i, u32 *data)
{
frameInfo& gsfb = ZeroGS::vb[i].gsfb;
if( (gsfb.fbp == ((data[0] ) & 0x1ff) * 32) &&
if( (gsfb.fbp == ((data[0] ) & 0x1ff) * 32) &&
(gsfb.fbw == ((data[0] >> 16) & 0x3f) * 64) &&
gsfb.psm == ((data[0] >> 24) & 0x3f) &&
(gsfb.fbm == data[1]) ) {
@ -294,7 +294,7 @@ __forceinline void frameWrite(int i, u32 *data)
ZeroGS::Flush(0);
ZeroGS::Flush(1);
gsfb.fbp = ((data[0] ) & 0x1ff) * 32;
gsfb.fbp = ((data[0] ) & 0x1ff) * 32;
gsfb.fbw = ((data[0] >> 16) & 0x3f) * 64;
gsfb.psm = (data[0] >> 24) & 0x3f;
gsfb.fbm = data[1];
@ -327,7 +327,7 @@ __forceinline void testWrite(int i, u32 *data)
ZeroGS::Flush(i);
*(u32*)test = data[0];
// test.ate = (data[0] ) & 0x1;
// test.ate = (data[0] ) & 0x1;
// test.atst = (data[0] >> 1) & 0x7;
// test.aref = (data[0] >> 4) & 0xff;
// test.afail = (data[0] >> 12) & 0x3;
@ -349,7 +349,7 @@ __forceinline void clampWrite(int i, u32 *data)
ZeroGS::Flush(i);
s_uClampData[i] = data[0];
clamp.wms = (data[0] ) & 0x3;
clamp.wms = (data[0] ) & 0x3;
clamp.wmt = (data[0] >> 2) & 0x3;
clamp.minu = (data[0] >> 4) & 0x3ff;
clamp.maxu = (data[0] >> 14) & 0x3ff;
@ -363,8 +363,8 @@ __forceinline void clampWrite(int i, u32 *data)
void __fastcall GIFRegHandlerNull(u32* data)
{
#ifdef _DEBUG
if( (((uptr)&data[2])&0xffff) == 0 )
return;
if( (((uptr)&data[2])&0xffff) == 0 )
return;
// 0x7f happens on a lot of games
if( data[2] != 0x7f && (data[0] || data[1]) ) {
@ -435,33 +435,33 @@ void __fastcall GIFRegHandlerXYZ2(u32* data)
void __fastcall GIFRegHandlerTEX0_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
tex0Write(0, data);
}
void __fastcall GIFRegHandlerTEX0_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
tex0Write(1, data);
}
void __fastcall GIFRegHandlerCLAMP_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
clampWrite(0, data);
}
void __fastcall GIFRegHandlerCLAMP_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
clampWrite(1, data);
}
@ -500,36 +500,36 @@ void __fastcall GIFRegHandlerNOP(u32* data)
void tex1Write(int i, u32* data)
{
tex1Info& tex1 = ZeroGS::vb[i].tex1;
tex1Info& tex1 = ZeroGS::vb[i].tex1;
if( conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7)) ) {
ZeroGS::Flush(i);
ZeroGS::vb[i].bVarsTexSync = FALSE;
}
tex1.lcm = (data[0] ) & 0x1;
tex1.lcm = (data[0] ) & 0x1;
tex1.mxl = (data[0] >> 2) & 0x7;
tex1.mmag = (data[0] >> 5) & 0x1;
tex1.mmin = (data[0] >> 6) & 0x7;
tex1.mtba = (data[0] >> 9) & 0x1;
tex1.l = (data[0] >> 19) & 0x3;
tex1.k = (data[1] >> 4) & 0xff;
tex1.l = (data[0] >> 19) & 0x3;
tex1.k = (data[1] >> 4) & 0xff;
}
void __fastcall GIFRegHandlerTEX1_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
tex1Write(0, data);
}
void __fastcall GIFRegHandlerTEX1_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk )
return;
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk )
return;
tex1Write(1, data);
tex1Write(1, data);
}
void __fastcall GIFRegHandlerTEX2_1(u32* data)
@ -587,7 +587,7 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data)
ZeroGS::vb[0].FlushTexData();
if( ZeroGS::vb[1].bNeedTexCheck )
ZeroGS::vb[1].FlushTexData();
gs.clut.cbw = ((data[0] ) & 0x3f) * 64;
gs.clut.cbw = ((data[0] ) & 0x3f) * 64;
gs.clut.cou = ((data[0] >> 6) & 0x3f) * 16;
gs.clut.cov = (data[0] >> 12) & 0x3ff;
}
@ -605,7 +605,7 @@ void __fastcall GIFRegHandlerSCANMSK(u32* data)
void __fastcall GIFRegHandlerMIPTBP1_1(u32* data)
{
miptbpInfo& miptbp0 = ZeroGS::vb[0].miptbp0;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp0.tbw[1] = (data[1] >> 2) & 0x3f;
@ -616,7 +616,7 @@ void __fastcall GIFRegHandlerMIPTBP1_1(u32* data)
void __fastcall GIFRegHandlerMIPTBP1_2(u32* data)
{
miptbpInfo& miptbp0 = ZeroGS::vb[1].miptbp0;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp0.tbw[1] = (data[1] >> 2) & 0x3f;
@ -627,7 +627,7 @@ void __fastcall GIFRegHandlerMIPTBP1_2(u32* data)
void __fastcall GIFRegHandlerMIPTBP2_1(u32* data)
{
miptbpInfo& miptbp1 = ZeroGS::vb[0].miptbp1;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp1.tbw[1] = (data[1] >> 2) & 0x3f;
@ -638,7 +638,7 @@ void __fastcall GIFRegHandlerMIPTBP2_1(u32* data)
void __fastcall GIFRegHandlerMIPTBP2_2(u32* data)
{
miptbpInfo& miptbp1 = ZeroGS::vb[1].miptbp1;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp1.tbw[1] = (data[1] >> 2) & 0x3f;
@ -681,9 +681,9 @@ void __fastcall GIFRegHandlerSCISSOR_1(u32* data)
Rect2 newscissor;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x1 = ((data[0] >> 16) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y1 = ((data[1] >> 16) & 0x7ff) << 3;
if( newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
@ -702,9 +702,9 @@ void __fastcall GIFRegHandlerSCISSOR_2(u32* data)
Rect2 newscissor;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x1 = ((data[0] >> 16) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y1 = ((data[1] >> 16) & 0x7ff) << 3;
if( newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
@ -727,10 +727,10 @@ void __fastcall GIFRegHandlerALPHA_1(u32* data)
if( *(WORD*)&newalpha != *(WORD*)&ZeroGS::vb[0].alpha ) {
ZeroGS::Flush(0);
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
*(WORD*)&ZeroGS::vb[0].alpha = *(WORD*)&newalpha;
}
@ -745,10 +745,10 @@ void __fastcall GIFRegHandlerALPHA_2(u32* data)
if( *(WORD*)&newalpha != *(WORD*)&ZeroGS::vb[1].alpha ) {
ZeroGS::Flush(1);
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
*(WORD*)&ZeroGS::vb[1].alpha = *(WORD*)&newalpha;
}
@ -816,16 +816,16 @@ void __fastcall GIFRegHandlerZBUF_1(u32* data)
{
zbufInfo& zbuf = ZeroGS::vb[0].zbuf;
int psm = (0x30|((data[0] >> 24) & 0xf));
int psm = (0x30|((data[0] >> 24) & 0xf));
if( zbuf.zbp == (data[0] & 0x1ff) * 32 &&
zbuf.psm == psm &&
zbuf.zmsk == (data[1] & 0x1) ) {
return;
}
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
ZeroGS::Flush(0);
ZeroGS::Flush(1);
@ -844,16 +844,16 @@ void __fastcall GIFRegHandlerZBUF_2(u32* data)
{
zbufInfo& zbuf = ZeroGS::vb[1].zbuf;
int psm = (0x30|((data[0] >> 24) & 0xf));
int psm = (0x30|((data[0] >> 24) & 0xf));
if( zbuf.zbp == (data[0] & 0x1ff) * 32 &&
zbuf.psm == psm &&
zbuf.zmsk == (data[1] & 0x1) ) {
return;
}
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
ZeroGS::Flush(0);
ZeroGS::Flush(1);
@ -870,10 +870,10 @@ void __fastcall GIFRegHandlerZBUF_2(u32* data)
void __fastcall GIFRegHandlerBITBLTBUF(u32* data)
{
gs.srcbufnew.bp = ((data[0] ) & 0x3fff);// * 64;
gs.srcbufnew.bp = ((data[0] ) & 0x3fff);// * 64;
gs.srcbufnew.bw = ((data[0] >> 16) & 0x3f) * 64;
gs.srcbufnew.psm = (data[0] >> 24) & 0x3f;
gs.dstbufnew.bp = ((data[1] ) & 0x3fff);// * 64;
gs.dstbufnew.bp = ((data[1] ) & 0x3fff);// * 64;
gs.dstbufnew.bw = ((data[1] >> 16) & 0x3f) * 64;
gs.dstbufnew.psm = (data[1] >> 24) & 0x3f;
@ -882,9 +882,9 @@ void __fastcall GIFRegHandlerBITBLTBUF(u32* data)
void __fastcall GIFRegHandlerTRXPOS(u32* data)
{
gs.trxposnew.sx = (data[0] ) & 0x7ff;
gs.trxposnew.sx = (data[0] ) & 0x7ff;
gs.trxposnew.sy = (data[0] >> 16) & 0x7ff;
gs.trxposnew.dx = (data[1] ) & 0x7ff;
gs.trxposnew.dx = (data[1] ) & 0x7ff;
gs.trxposnew.dy = (data[1] >> 16) & 0x7ff;
gs.trxposnew.dir = (data[1] >> 27) & 0x3;
}
@ -1013,101 +1013,101 @@ void __fastcall GIFRegHandlerLABEL(u32* data)
//
//ExecuteBufferXeno::ExecuteBufferXeno()
//{
// clampdata[0] = clampdata[1] = 0;
// tex0data[0] = tex0data[1] = 0;
// tex1data[0] = tex1data[1] = 0;
// bCanExecute = true;
// curprim._val = 0;
// clampdata[0] = clampdata[1] = 0;
// tex0data[0] = tex0data[1] = 0;
// tex1data[0] = tex1data[1] = 0;
// bCanExecute = true;
// curprim._val = 0;
//}
//
//void ExecuteBufferXeno::Execute()
//{
// if( vertices.size() == 0 || !bCanExecute)
// return;
// if( vertices.size() == 0 || !bCanExecute)
// return;
//
// bCanExecute = false;
// ZeroGS::Flush(0);
// ZeroGS::Flush(1);
// bCanExecute = false;
// ZeroGS::Flush(0);
// ZeroGS::Flush(1);
//
// int oldC = gs.primC;
// int ctx = curprim.ctxt;
// int oldC = gs.primC;
// int ctx = curprim.ctxt;
//
// Vertex oldverts[3];
// oldverts[0] = gs.gsvertex[0];
// oldverts[1] = gs.gsvertex[1];
// oldverts[2] = gs.gsvertex[2];
// Vertex oldverts[3];
// oldverts[0] = gs.gsvertex[0];
// oldverts[1] = gs.gsvertex[1];
// oldverts[2] = gs.gsvertex[2];
//
// u32 oldtex0[2];
// tex1Info oldtex1 = ZeroGS::vb[ctx].tex1;
// clampInfo oldclamp = ZeroGS::vb[ctx].clamp;
// oldtex0[0] = ZeroGS::vb[ctx].uNextTex0Data[0];
// oldtex0[1] = ZeroGS::vb[ctx].uNextTex0Data[1];
// u32 oldtex0[2];
// tex1Info oldtex1 = ZeroGS::vb[ctx].tex1;
// clampInfo oldclamp = ZeroGS::vb[ctx].clamp;
// oldtex0[0] = ZeroGS::vb[ctx].uNextTex0Data[0];
// oldtex0[1] = ZeroGS::vb[ctx].uNextTex0Data[1];
//
// int oldmask = ZeroGS::vb[ctx].zbuf.zmsk;
// ZeroGS::vb[ctx].zbuf.zmsk = 1;
// tex0Write(0, tex0data);
// tex1Write(0, tex1data);
// clampWrite(0, clampdata);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// gs.primC = 3;
// u32 oldprim = prim->_val;
// prim->_val = curprim._val;
// for(int i = 0; i < (int)vertices.size(); i += 3) {
// gs.gsvertex[0] = vertices[i];
// gs.gsvertex[1] = vertices[i+1];
// gs.gsvertex[2] = vertices[i+2];
// (*ZeroGS::drawfn[4])(); // draw a triangle
// }
// vertices.resize(0);
// int oldmask = ZeroGS::vb[ctx].zbuf.zmsk;
// ZeroGS::vb[ctx].zbuf.zmsk = 1;
// tex0Write(0, tex0data);
// tex1Write(0, tex1data);
// clampWrite(0, clampdata);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// gs.primC = 3;
// u32 oldprim = prim->_val;
// prim->_val = curprim._val;
// for(int i = 0; i < (int)vertices.size(); i += 3) {
// gs.gsvertex[0] = vertices[i];
// gs.gsvertex[1] = vertices[i+1];
// gs.gsvertex[2] = vertices[i+2];
// (*ZeroGS::drawfn[4])(); // draw a triangle
// }
// vertices.resize(0);
//
// ZeroGS::Flush(ctx);
// ZeroGS::Flush(ctx);
//
// ZeroGS::vb[ctx].zbuf.zmsk = oldmask;
// gs.primC = oldC;
// gs.gsvertex[0] = oldverts[0];
// gs.gsvertex[1] = oldverts[1];
// gs.gsvertex[2] = oldverts[2];
// ZeroGS::vb[ctx].clamp = oldclamp;
// ZeroGS::vb[ctx].tex1 = oldtex1;
// tex0Write(0, oldtex0);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// prim->_val = oldprim;
// bCanExecute = true;
// ZeroGS::vb[ctx].zbuf.zmsk = oldmask;
// gs.primC = oldC;
// gs.gsvertex[0] = oldverts[0];
// gs.gsvertex[1] = oldverts[1];
// gs.gsvertex[2] = oldverts[2];
// ZeroGS::vb[ctx].clamp = oldclamp;
// ZeroGS::vb[ctx].tex1 = oldtex1;
// tex0Write(0, oldtex0);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// prim->_val = oldprim;
// bCanExecute = true;
//}
//
//void ExecuteBufferXeno::SetTex0(u32* data)
//{
// if( data[0] != tex0data[0] || (data[1]&0x1fffffff) != (tex0data[1]&0x1fffffff) )
// Execute();
// if( data[0] != tex0data[0] || (data[1]&0x1fffffff) != (tex0data[1]&0x1fffffff) )
// Execute();
//
// tex0data[0] = data[0];
// tex0data[1] = data[1];
// tex0data[0] = data[0];
// tex0data[1] = data[1];
//}
//
//void ExecuteBufferXeno::SetTex1(u32* data)
//{
// if( data[0] != tex1data[0] )
// Execute();
// if( data[0] != tex1data[0] )
// Execute();
//
// tex1data[0] = data[0];
// tex1data[1] = data[1];
// tex1data[0] = data[0];
// tex1data[1] = data[1];
//}
//
//void ExecuteBufferXeno::SetClamp(u32* data)
//{
// if( data[0] != clampdata[0] || (data[1]&0xfff) != clampdata[1] )
// Execute();
// if( data[0] != clampdata[0] || (data[1]&0xfff) != clampdata[1] )
// Execute();
//
// clampdata[0] = data[0];
// clampdata[1] = data[1]&0xfff;
// clampdata[0] = data[0];
// clampdata[1] = data[1]&0xfff;
//}
//
//void ExecuteBufferXeno::SetTri()
//{
// if( prim->_val != curprim._val )
// Execute();
// curprim._val = prim->_val;
// vertices.push_back(gs.gsvertex[0]);
// vertices.push_back(gs.gsvertex[1]);
// vertices.push_back(gs.gsvertex[2]);
// if( prim->_val != curprim._val )
// Execute();
// curprim._val = prim->_val;
// vertices.push_back(gs.gsvertex[0]);
// vertices.push_back(gs.gsvertex[1]);
// vertices.push_back(gs.gsvertex[2]);
//}

View File

@ -94,27 +94,27 @@ void __fastcall GIFRegHandlerLABEL(u32* data);
//class ExecuteBuffer
//{
//public:
// virtual void Execute()=0;
// virtual void Execute()=0;
//};
//
//class ExecuteBufferXeno : public ExecuteBuffer
//{
//public:
// ExecuteBufferXeno();
// virtual void Execute();
// ExecuteBufferXeno();
// virtual void Execute();
//
// void SetTex0(u32* data);
// void SetTex1(u32* data);
// void SetClamp(u32* data);
// void SetTri();
// void SetTex0(u32* data);
// void SetTex1(u32* data);
// void SetClamp(u32* data);
// void SetTri();
//
// u32 clampdata[2];
// u32 tex0data[2];
// u32 tex1data[2];
// primInfo curprim;
//
// std::vector<Vertex> vertices;
// bool bCanExecute;
// u32 clampdata[2];
// u32 tex0data[2];
// u32 tex1data[2];
// primInfo curprim;
//
// std::vector<Vertex> vertices;
// bool bCanExecute;
//};
//
//extern ExecuteBufferXeno g_ebXeno;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ namespace ZeroGS
// gets all targets with a range
void GetTargs(int start, int end, list<ZeroGS::CRenderTarget*>& listTargets) const;
virtual void DestroyChildren(CRenderTarget* ptarg);
virtual void DestroyChildren(CRenderTarget* ptarg);
// resolves all targets within a range
__forceinline void Resolve(int start, int end);
@ -44,7 +44,7 @@ namespace ZeroGS
if( ptarg == vb[i].pdepth ) { vb[i].pdepth = NULL; vb[i].bNeedZCheck = 1; }
}
DestroyChildren(ptarg);
DestroyChildren(ptarg);
delete ptarg;
}
@ -86,13 +86,13 @@ namespace ZeroGS
u32 dummykey = (it->second->fbw<<16)|it->second->fbh;
if( it->second->pmimicparent != NULL && mapDummyTargs.find(dummykey) == mapDummyTargs.end() ) {
DestroyChildren(it->second);
DestroyChildren(it->second);
mapDummyTargs[dummykey] = it->second;
}
else {
DestroyChildren(it->second);
else {
DestroyChildren(it->second);
delete it->second;
}
}
it = mapTargets.erase(it);
}
else ++it;
@ -117,13 +117,13 @@ namespace ZeroGS
u32 dummykey = (it->second->fbw<<16)|it->second->fbh;
if( it->second->pmimicparent != NULL && mapDummyTargs.find(dummykey) == mapDummyTargs.end() ) {
DestroyChildren(it->second);
DestroyChildren(it->second);
mapDummyTargs[dummykey] = it->second;
}
else {
DestroyChildren(it->second);
else {
DestroyChildren(it->second);
delete it->second;
}
}
it = mapTargets.erase(it);
}
@ -152,10 +152,10 @@ namespace ZeroGS
else
mapTargets[key] = ptarg;
if( g_GameSettings & GAME_RESOLVEPROMOTED )
ptarg->status = CRenderTarget::TS_Resolved;
else
ptarg->status = CRenderTarget::TS_NeedUpdate;
if( g_GameSettings & GAME_RESOLVEPROMOTED )
ptarg->status = CRenderTarget::TS_Resolved;
else
ptarg->status = CRenderTarget::TS_NeedUpdate;
return ptarg;
}

View File

@ -34,195 +34,195 @@
void FASTCALL(SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask))
{
u32* d = &g_columnTable32[0][0];
u32* d = &g_columnTable32[0][0];
if(WriteMask == 0xffffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
if(WriteMask == 0xffffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
}
void FASTCALL(SwizzleBlock16_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable16[0][0];
u32* d = &g_columnTable16[0][0];
for(int j = 0; j < 8; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
((u16*)dst)[d[i]] = ((u16*)src)[i];
for(int j = 0; j < 8; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
((u16*)dst)[d[i]] = ((u16*)src)[i];
}
void FASTCALL(SwizzleBlock8_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable8[0][0];
u32* d = &g_columnTable8[0][0];
for(int j = 0; j < 16; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
dst[d[i]] = src[i];
for(int j = 0; j < 16; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
dst[d[i]] = src[i];
}
void FASTCALL(SwizzleBlock4_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable4[0][0];
u32* d = &g_columnTable4[0][0];
for(int j = 0; j < 16; j++, d += 32, src += srcpitch)
{
for(int i = 0; i < 32; i++)
{
u32 addr = d[i];
u8 c = (src[i>>1] >> ((i&1) << 2)) & 0x0f;
u32 shift = (addr&1) << 2;
dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift);
}
}
for(int j = 0; j < 16; j++, d += 32, src += srcpitch)
{
for(int i = 0; i < 32; i++)
{
u32 addr = d[i];
u8 c = (src[i>>1] >> ((i&1) << 2)) & 0x0f;
u32 shift = (addr&1) << 2;
dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift);
}
}
}
#define _FrameSwizzleBlock(type, transfer, transfer16, incsrc) \
/* FrameSwizzleBlock32 */ \
void FASTCALL(FrameSwizzleBlock32##type##c(u32* dst, u32* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = (transfer); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = ((transfer)&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = (transfer); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = ((transfer)&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* FrameSwizzleBlock16 */ \
void FASTCALL(FrameSwizzleBlock16##type##c(u16* dst, u32* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
if( WriteMask == 0xffff ) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
dst[d[j]] = RGBA32to16(temp); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
u32 dsrc = RGBA32to16(temp); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable16[0][0]; \
\
if( WriteMask == 0xffff ) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
dst[d[j]] = RGBA32to16(temp); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
u32 dsrc = RGBA32to16(temp); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock32 */ \
void FASTCALL(Frame16SwizzleBlock32##type##c(u32* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock32Z */ \
void FASTCALL(Frame16SwizzleBlock32Z##type##c(u32* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
if( WriteMask == 0xffffffff ) { /* breaks KH text if not checked */ \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB_Z(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable32[0][0]; \
if( WriteMask == 0xffffffff ) { /* breaks KH text if not checked */ \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB_Z(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock16 */ \
void FASTCALL(Frame16SwizzleBlock16##type##c(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
if( (WriteMask&0xfff8f8f8) == 0xfff8f8f8) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB16(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable16[0][0]; \
\
if( (WriteMask&0xfff8f8f8) == 0xfff8f8f8) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB16(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock16Z */ \
void FASTCALL(Frame16SwizzleBlock16Z##type##c(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
u32* d = &g_columnTable16[0][0]; \
\
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
_FrameSwizzleBlock(_, src[j], src[j], 0);
@ -234,63 +234,63 @@ _FrameSwizzleBlock(A4_, (src[2*j]+src[2*j+1]+src[2*j+srcpitch]+src[2*j+srcpitch+
//void FASTCALL(WriteCLUT_T16_I8_CSM1_sse2(u32* vm, u32* clut)
//{
// __asm {
// mov eax, vm
// mov ecx, clut
// mov edx, 8
// mov eax, vm
// mov ecx, clut
// mov edx, 8
// }
//
//Extract32x2:
// __asm {
// movdqa xmm0, qword ptr [eax]
// movdqa xmm1, qword ptr [eax+16]
// movdqa xmm2, qword ptr [eax+32]
// movdqa xmm3, qword ptr [eax+48]
// movdqa xmm0, qword ptr [eax]
// movdqa xmm1, qword ptr [eax+16]
// movdqa xmm2, qword ptr [eax+32]
// movdqa xmm3, qword ptr [eax+48]
//
// // rearrange
// pshuflw xmm0, xmm0, 0xd8
// pshufhw xmm0, xmm0, 0xd8
// pshuflw xmm1, xmm1, 0xd8
// pshufhw xmm1, xmm1, 0xd8
// pshuflw xmm2, xmm2, 0xd8
// pshufhw xmm2, xmm2, 0xd8
// pshuflw xmm3, xmm3, 0xd8
// pshufhw xmm3, xmm3, 0xd8
// // rearrange
// pshuflw xmm0, xmm0, 0xd8
// pshufhw xmm0, xmm0, 0xd8
// pshuflw xmm1, xmm1, 0xd8
// pshufhw xmm1, xmm1, 0xd8
// pshuflw xmm2, xmm2, 0xd8
// pshufhw xmm2, xmm2, 0xd8
// pshuflw xmm3, xmm3, 0xd8
// pshufhw xmm3, xmm3, 0xd8
//
// movdqa xmm4, xmm0
// movdqa xmm6, xmm2
// movdqa xmm4, xmm0
// movdqa xmm6, xmm2
//
// shufps xmm0, xmm1, 0x88
// shufps xmm2, xmm3, 0x88
// shufps xmm0, xmm1, 0x88
// shufps xmm2, xmm3, 0x88
//
// shufps xmm4, xmm1, 0xdd
// shufps xmm6, xmm3, 0xdd
// shufps xmm4, xmm1, 0xdd
// shufps xmm6, xmm3, 0xdd
//
// pshufd xmm0, xmm0, 0xd8
// pshufd xmm2, xmm2, 0xd8
// pshufd xmm4, xmm4, 0xd8
// pshufd xmm6, xmm6, 0xd8
// pshufd xmm0, xmm0, 0xd8
// pshufd xmm2, xmm2, 0xd8
// pshufd xmm4, xmm4, 0xd8
// pshufd xmm6, xmm6, 0xd8
//
// // left column
// movhlps xmm1, xmm0
// movlhps xmm0, xmm2
// //movdqa xmm7, [ecx]
// // left column
// movhlps xmm1, xmm0
// movlhps xmm0, xmm2
// //movdqa xmm7, [ecx]
//
// movdqa [ecx], xmm0
// shufps xmm1, xmm2, 0xe4
// movdqa [ecx+16], xmm1
// movdqa [ecx], xmm0
// shufps xmm1, xmm2, 0xe4
// movdqa [ecx+16], xmm1
//
// // right column
// movhlps xmm3, xmm4
// movlhps xmm4, xmm6
// movdqa [ecx+32], xmm4
// shufps xmm3, xmm6, 0xe4
// movdqa [ecx+48], xmm3
// // right column
// movhlps xmm3, xmm4
// movlhps xmm4, xmm6
// movdqa [ecx+32], xmm4
// shufps xmm3, xmm6, 0xe4
// movdqa [ecx+48], xmm3
//
// add eax, 16*4
// add ecx, 16*8
// sub edx, 1
// cmp edx, 0
// jne Extract32x2
// add eax, 16*4
// add ecx, 16*8
// sub edx, 1
// cmp edx, 0
// jne Extract32x2
// }
//}
@ -298,50 +298,50 @@ _FrameSwizzleBlock(A4_, (src[2*j]+src[2*j+1]+src[2*j+srcpitch]+src[2*j+srcpitch+
extern "C" void FASTCALL(WriteCLUT_T32_I8_CSM1_sse2(u32* vm, u32* clut))
{
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
for(int j = 0; j < 64; j += 32, src += 32, dst += 32)
{
for(int i = 0; i < 16; i += 4)
{
__m128i r0 = _mm_load_si128(&src[i+0]);
__m128i r1 = _mm_load_si128(&src[i+1]);
__m128i r2 = _mm_load_si128(&src[i+2]);
__m128i r3 = _mm_load_si128(&src[i+3]);
for(int j = 0; j < 64; j += 32, src += 32, dst += 32)
{
for(int i = 0; i < 16; i += 4)
{
__m128i r0 = _mm_load_si128(&src[i+0]);
__m128i r1 = _mm_load_si128(&src[i+1]);
__m128i r2 = _mm_load_si128(&src[i+2]);
__m128i r3 = _mm_load_si128(&src[i+3]);
_mm_store_si128(&dst[i*2+0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[i*2+1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[i*2+2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[i*2+3], _mm_unpackhi_epi64(r2, r3));
_mm_store_si128(&dst[i*2+0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[i*2+1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[i*2+2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[i*2+3], _mm_unpackhi_epi64(r2, r3));
__m128i r4 = _mm_load_si128(&src[i+0+16]);
__m128i r5 = _mm_load_si128(&src[i+1+16]);
__m128i r6 = _mm_load_si128(&src[i+2+16]);
__m128i r7 = _mm_load_si128(&src[i+3+16]);
__m128i r4 = _mm_load_si128(&src[i+0+16]);
__m128i r5 = _mm_load_si128(&src[i+1+16]);
__m128i r6 = _mm_load_si128(&src[i+2+16]);
__m128i r7 = _mm_load_si128(&src[i+3+16]);
_mm_store_si128(&dst[i*2+4], _mm_unpacklo_epi64(r4, r5));
_mm_store_si128(&dst[i*2+5], _mm_unpacklo_epi64(r6, r7));
_mm_store_si128(&dst[i*2+6], _mm_unpackhi_epi64(r4, r5));
_mm_store_si128(&dst[i*2+7], _mm_unpackhi_epi64(r6, r7));
}
}
_mm_store_si128(&dst[i*2+4], _mm_unpacklo_epi64(r4, r5));
_mm_store_si128(&dst[i*2+5], _mm_unpacklo_epi64(r6, r7));
_mm_store_si128(&dst[i*2+6], _mm_unpackhi_epi64(r4, r5));
_mm_store_si128(&dst[i*2+7], _mm_unpackhi_epi64(r6, r7));
}
}
}
extern "C" void FASTCALL(WriteCLUT_T32_I4_CSM1_sse2(u32* vm, u32* clut))
{
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i r0 = _mm_load_si128(&src[0]);
__m128i r1 = _mm_load_si128(&src[1]);
__m128i r2 = _mm_load_si128(&src[2]);
__m128i r3 = _mm_load_si128(&src[3]);
__m128i r0 = _mm_load_si128(&src[0]);
__m128i r1 = _mm_load_si128(&src[1]);
__m128i r2 = _mm_load_si128(&src[2]);
__m128i r3 = _mm_load_si128(&src[3]);
_mm_store_si128(&dst[0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[3], _mm_unpackhi_epi64(r2, r3));
_mm_store_si128(&dst[0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[3], _mm_unpackhi_epi64(r2, r3));
}
#endif
@ -350,124 +350,124 @@ extern "C" void FASTCALL(WriteCLUT_T32_I4_CSM1_sse2(u32* vm, u32* clut))
extern "C" {
PCSX2_ALIGNED16(int s_clut16mask2[4]) = { 0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff };
PCSX2_ALIGNED16(int s_clut16mask[8]) = { 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff};
0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff};
}
#if !defined(__x86_64__)
extern "C" void FASTCALL(WriteCLUT_T16_I4_CSM1_sse2(u32* vm, u32* clut))
{
__asm {
mov eax, vm
mov ecx, clut
movdqa xmm0, qword ptr [eax]
movdqa xmm1, qword ptr [eax+16]
movdqa xmm2, qword ptr [eax+32]
movdqa xmm3, qword ptr [eax+48]
__asm {
mov eax, vm
mov ecx, clut
movdqa xmm0, qword ptr [eax]
movdqa xmm1, qword ptr [eax+16]
movdqa xmm2, qword ptr [eax+32]
movdqa xmm3, qword ptr [eax+48]
// rearrange
pshuflw xmm0, xmm0, 0x88
pshufhw xmm0, xmm0, 0x88
pshuflw xmm1, xmm1, 0x88
pshufhw xmm1, xmm1, 0x88
pshuflw xmm2, xmm2, 0x88
pshufhw xmm2, xmm2, 0x88
pshuflw xmm3, xmm3, 0x88
pshufhw xmm3, xmm3, 0x88
// rearrange
pshuflw xmm0, xmm0, 0x88
pshufhw xmm0, xmm0, 0x88
pshuflw xmm1, xmm1, 0x88
pshufhw xmm1, xmm1, 0x88
pshuflw xmm2, xmm2, 0x88
pshufhw xmm2, xmm2, 0x88
pshuflw xmm3, xmm3, 0x88
pshufhw xmm3, xmm3, 0x88
shufps xmm0, xmm1, 0x88
shufps xmm2, xmm3, 0x88
shufps xmm0, xmm1, 0x88
shufps xmm2, xmm3, 0x88
pshufd xmm0, xmm0, 0xd8
pshufd xmm2, xmm2, 0xd8
pshufd xmm0, xmm0, 0xd8
pshufd xmm2, xmm2, 0xd8
pxor xmm6, xmm6
pxor xmm6, xmm6
test ecx, 15
jnz WriteUnaligned
test ecx, 15
jnz WriteUnaligned
movdqa xmm7, s_clut16mask // saves upper 16 bits
movdqa xmm7, s_clut16mask // saves upper 16 bits
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
pand xmm4, xmm7
pand xmm5, xmm7
pand xmm4, xmm7
pand xmm5, xmm7
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
por xmm0, xmm4
por xmm1, xmm5
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
por xmm0, xmm4
por xmm1, xmm5
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
por xmm2, xmm7
por xmm3, xmm5
por xmm2, xmm7
por xmm3, xmm5
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
jmp End
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
jmp End
WriteUnaligned:
// ecx is offset by 2
sub ecx, 2
// ecx is offset by 2
sub ecx, 2
movdqa xmm7, s_clut16mask2 // saves lower 16 bits
movdqa xmm7, s_clut16mask2 // saves lower 16 bits
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
pand xmm4, xmm7
pand xmm5, xmm7
pand xmm4, xmm7
pand xmm5, xmm7
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
pslld xmm0, 16
pslld xmm1, 16
por xmm0, xmm4
por xmm1, xmm5
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
pslld xmm0, 16
pslld xmm1, 16
por xmm0, xmm4
por xmm1, xmm5
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
pslld xmm2, 16
pslld xmm3, 16
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
pslld xmm2, 16
pslld xmm3, 16
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
por xmm2, xmm7
por xmm3, xmm5
por xmm2, xmm7
por xmm3, xmm5
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
End:
}
}
}
#endif // __x86_64__
#endif // _MSC_VER
@ -476,98 +476,98 @@ End:
void FASTCALL(WriteCLUT_T16_I8_CSM1_c(u32* _vm, u32* _clut))
{
const static u32 map[] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30,
1, 3, 9, 11, 17, 19, 25, 27,
5, 7, 13, 15, 21, 23, 29, 31
};
const static u32 map[] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30,
1, 3, 9, 11, 17, 19, 25, 27,
5, 7, 13, 15, 21, 23, 29, 31
};
u16* vm = (u16*)_vm;
u16* clut = (u16*)_clut;
u16* vm = (u16*)_vm;
u16* clut = (u16*)_clut;
int left = ((u32)(uptr)clut&2) ? 512 : 512-(((u32)(uptr)clut)&0x3ff)/2;
int left = ((u32)(uptr)clut&2) ? 512 : 512-(((u32)(uptr)clut)&0x3ff)/2;
for(int j = 0; j < 8; j++, vm += 32, clut += 64, left -= 32)
{
if(left == 32) {
assert( left == 32 );
for(int i = 0; i < 16; i++)
clut[2*i] = vm[map[i]];
for(int j = 0; j < 8; j++, vm += 32, clut += 64, left -= 32)
{
if(left == 32) {
assert( left == 32 );
for(int i = 0; i < 16; i++)
clut[2*i] = vm[map[i]];
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
for(int i = 16; i < 32; i++)
clut[2*i] = vm[map[i]];
}
else {
if( left == 0 ) {
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
left = -1;
}
for(int i = 16; i < 32; i++)
clut[2*i] = vm[map[i]];
}
else {
if( left == 0 ) {
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
left = -1;
}
for(int i = 0; i < 32; i++)
clut[2*i] = vm[map[i]];
}
}
for(int i = 0; i < 32; i++)
clut[2*i] = vm[map[i]];
}
}
}
void FASTCALL(WriteCLUT_T32_I8_CSM1_c(u32* vm, u32* clut))
{
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
for(int j = 0; j < 2; j++, src += 32) {
for(int i = 0; i < 4; i++, dst+=16, src+=8)
{
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
for(int j = 0; j < 2; j++, src += 32) {
for(int i = 0; i < 4; i++, dst+=16, src+=8)
{
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
dst[8] = src[32];
dst[9] = src[32+2];
dst[10] = src[32+4];
dst[11] = src[32+6];
dst[12] = src[32+1];
dst[13] = src[32+3];
dst[14] = src[32+5];
dst[15] = src[32+7];
}
}
dst[8] = src[32];
dst[9] = src[32+2];
dst[10] = src[32+4];
dst[11] = src[32+6];
dst[12] = src[32+1];
dst[13] = src[32+3];
dst[14] = src[32+5];
dst[15] = src[32+7];
}
}
}
void FASTCALL(WriteCLUT_T16_I4_CSM1_c(u32* _vm, u32* _clut))
{
u16* dst = (u16*)_clut;
u16* src = (u16*)_vm;
u16* dst = (u16*)_clut;
u16* src = (u16*)_vm;
dst[0] = src[0]; dst[2] = src[2];
dst[4] = src[8]; dst[6] = src[10];
dst[8] = src[16]; dst[10] = src[18];
dst[12] = src[24]; dst[14] = src[26];
dst[16] = src[4]; dst[18] = src[6];
dst[20] = src[12]; dst[22] = src[14];
dst[24] = src[20]; dst[26] = src[22];
dst[28] = src[28]; dst[30] = src[30];
dst[0] = src[0]; dst[2] = src[2];
dst[4] = src[8]; dst[6] = src[10];
dst[8] = src[16]; dst[10] = src[18];
dst[12] = src[24]; dst[14] = src[26];
dst[16] = src[4]; dst[18] = src[6];
dst[20] = src[12]; dst[22] = src[14];
dst[24] = src[20]; dst[26] = src[22];
dst[28] = src[28]; dst[30] = src[30];
}
void FASTCALL(WriteCLUT_T32_I4_CSM1_c(u32* vm, u32* clut))
{
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
}

File diff suppressed because it is too large Load Diff

View File

@ -134,8 +134,8 @@ extern float g_fiGPU_TEXWIDTH;
#define GAME_QUICKRESOLVE1 0x0400
#define GAME_NOQUICKRESOLVE 0x0800
#define GAME_NOTARGETCLUT 0x1000 // full 16 bit resolution
#define GAME_NOSTENCIL 0x2000
#define GAME_VSSHACKOFF 0x4000 // vertical stripe syndrome
#define GAME_NOSTENCIL 0x2000
#define GAME_VSSHACKOFF 0x4000 // vertical stripe syndrome
#define GAME_NODEPTHRESOLVE 0x8000
#define GAME_FULL16BITRES 0x00010000
#define GAME_RESOLVEPROMOTED 0x00020000
@ -145,12 +145,12 @@ extern float g_fiGPU_TEXWIDTH;
#define GAME_32BITTARGS 0x00200000
#define GAME_PATH3HACK 0x00400000
#define GAME_DOPARALLELCTX 0x00800000 // tries to parallelize both contexts so that render calls are reduced (xenosaga)
// makes the game faster, but can be buggy
// makes the game faster, but can be buggy
#define GAME_XENOSPECHACK 0x01000000 // xenosaga specularity hack (ignore any zmask=1 draws)
#define GAME_PARTIALPOINTERS 0x02000000 // whenver the texture or render target are small, tries to look for bigger ones to read from
#define GAME_PARTIALDEPTH 0x04000000 // tries to save depth targets as much as possible across height changes
#define GAME_RELAXEDDEPTH 0x08000000 // tries to save depth targets as much as possible across height changes
#define USEALPHABLENDING 1//(!(g_GameSettings&GAME_NOALPHABLEND))
#define USEALPHATESTING (!(g_GameSettings&GAME_NOALPHATEST))
@ -176,7 +176,7 @@ namespace ZeroGS
{
public:
CRenderTarget();
CRenderTarget(const frameInfo& frame, CRenderTarget& r); // virtualized a target
CRenderTarget(const frameInfo& frame, CRenderTarget& r); // virtualized a target
virtual ~CRenderTarget();
virtual BOOL Create(const frameInfo& frame);
@ -195,17 +195,17 @@ namespace ZeroGS
virtual void Resolve();
virtual void Resolve(int startrange, int endrange); // resolves only in the allowed range
virtual void Update(int context, CRenderTarget* pdepth);
virtual void ConvertTo32(); // converts a psm==2 target, to a psm==0
virtual void ConvertTo16(); // converts a psm==0 target, to a psm==2
virtual void ConvertTo32(); // converts a psm==2 target, to a psm==0
virtual void ConvertTo16(); // converts a psm==0 target, to a psm==2
virtual bool IsDepth() { return false; }
LPD3DSURF psurf, psys;
LPD3DTEX ptex;
int targoffx, targoffy; // the offset from the target that the real fbp starts at (in pixels)
int targheight; // height of ptex
CRenderTarget* pmimicparent; // if not NULL, this target is a subtarget of pmimicparent
int targoffx, targoffy; // the offset from the target that the real fbp starts at (in pixels)
int targheight; // height of ptex
CRenderTarget* pmimicparent; // if not NULL, this target is a subtarget of pmimicparent
int fbp, fbw, fbh; // if fbp is negative, virtual target (not mapped to any real addr)
int start, end; // in bytes
@ -230,8 +230,8 @@ namespace ZeroGS
TS_NeedUpdate = 2,
TS_Virtual = 4, // currently not mapped to memory
TS_FeedbackReady = 8, // feedback effect is ready and doesn't need to be updated
TS_NeedConvert32 = 16,
TS_NeedConvert16 = 32,
TS_NeedConvert32 = 16,
TS_NeedConvert16 = 32,
};
private:

View File

@ -59,7 +59,7 @@ extern bool THR_bShift;
// declare linux equivalents
extern __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
{
assert( align < 0x10000 );
assert( align < 0x10000 );
char* p = (char*)malloc(size+align);
int off = 2+align - ((int)(uptr)(p+2) % align);
@ -71,10 +71,10 @@ extern __forceinline void* pcsx2_aligned_malloc(size_t size, size_t align)
extern __forceinline void pcsx2_aligned_free(void* pmem)
{
if( pmem != NULL ) {
char* p = (char*)pmem;
free(p - (int)*(u16*)(p-2));
}
if( pmem != NULL ) {
char* p = (char*)pmem;
free(p - (int)*(u16*)(p-2));
}
}
#define _aligned_malloc pcsx2_aligned_malloc
@ -82,42 +82,42 @@ extern __forceinline void pcsx2_aligned_free(void* pmem)
#endif
#include <sys/timeb.h> // ftime(), struct timeb
#include <sys/timeb.h> // ftime(), struct timeb
inline unsigned long timeGetTime()
{
#ifdef _WIN32
_timeb t;
_ftime(&t);
_timeb t;
_ftime(&t);
#else
timeb t;
ftime(&t);
timeb t;
ftime(&t);
#endif
return (unsigned long)(t.time*1000+t.millitm);
return (unsigned long)(t.time*1000+t.millitm);
}
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
struct RECT
{
int left, top;
int right, bottom;
int left, top;
int right, bottom;
};
typedef struct {
Display *dpy;
int screen;
Window win;
GLXContext ctx;
XSetWindowAttributes attr;
Bool fs;
Bool doubleBuffered;
XF86VidModeModeInfo deskMode;
int x, y;
unsigned int width, height;
unsigned int depth;
Display *dpy;
int screen;
Window win;
GLXContext ctx;
XSetWindowAttributes attr;
Bool fs;
Bool doubleBuffered;
XF86VidModeModeInfo deskMode;
int x, y;
unsigned int width, height;
unsigned int depth;
} GLWindow;
extern GLWindow GLWin;
@ -147,7 +147,7 @@ using namespace std;
struct Vector_16F
{
u16 x, y, z, w;
u16 x, y, z, w;
};
/////////////////////
@ -448,10 +448,10 @@ typedef struct {
int aa; // antialiasing 0 - off, 1 - 2x, 2 - 4x
int bilinear; // set to enable bilinear support
u32 options;
u32 gamesettings; // default game settings
u32 gamesettings; // default game settings
int width, height;
int winstyle; // window style before full screen
int mrtdepth; // write color in render target
int mrtdepth; // write color in render target
#ifdef GS_LOG
u32 log;
#endif
@ -468,9 +468,9 @@ struct VertexGPU
struct Vertex
{
u16 x, y, f, resv0; // note: xy is 12d3
u32 rgba;
u32 z;
float s, t, q;
u32 rgba;
u32 z;
float s, t, q;
u16 u, v;
};
@ -787,7 +787,7 @@ __forceinline u16 Float16ToALPHA(u16 f) {
#ifndef COLOR_ARGB
#define COLOR_ARGB(a,r,g,b) \
((u32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
((u32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#endif
// assumes that positive in [1,2] (then extracts fraction by just looking at the specified bits)

File diff suppressed because it is too large Load Diff

View File

@ -27,51 +27,51 @@
extern string s_strIniPath;
void SaveConfig() {
FILE *f;
char cfg[255];
FILE *f;
char cfg[255];
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg,"w");
if (f == NULL) {
printf("failed to open %s\n", s_strIniPath.c_str());
return;
}
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg,"w");
if (f == NULL) {
printf("failed to open %s\n", s_strIniPath.c_str());
return;
}
fprintf(f, "interlace = %x\n", conf.interlace);
fprintf(f, "aliasing = %x\n", conf.aa);
fprintf(f, "bilinear = %x\n", conf.bilinear);
fprintf(f, "options = %x\n", conf.options);
fprintf(f, "gamesettings = %x\n", conf.gamesettings);
fclose(f);
fprintf(f, "gamesettings = %x\n", conf.gamesettings);
fclose(f);
}
void LoadConfig() {
FILE *f;
char cfg[255];
FILE *f;
char cfg[255];
memset(&conf, 0, sizeof(conf));
memset(&conf, 0, sizeof(conf));
conf.interlace = 0; // on, mode 1
conf.mrtdepth = 1;
conf.options = 0;
conf.options = 0;
conf.bilinear = 1;
conf.width = 640;
conf.height = 480;
conf.width = 640;
conf.height = 480;
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "r");
if (f == NULL) {
printf("failed to open %s\n", s_strIniPath.c_str());
SaveConfig();//save and return
return;
}
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "r");
if (f == NULL) {
printf("failed to open %s\n", s_strIniPath.c_str());
SaveConfig();//save and return
return;
}
fscanf(f, "interlace = %x\n", &conf.interlace);
fscanf(f, "aliasing = %x\n", &conf.aa);
fscanf(f, "bilinear = %x\n", &conf.bilinear);
fscanf(f, "options = %x\n", &conf.options);
fscanf(f, "gamesettings = %x\n", &conf.gamesettings);
fclose(f);
fscanf(f, "gamesettings = %x\n", &conf.gamesettings);
fclose(f);
// filter bad files
if( conf.aa < 0 || conf.aa > 2 ) conf.aa = 0;
// filter bad files
if( conf.aa < 0 || conf.aa > 2 ) conf.aa = 0;
switch(conf.options&GSOPTION_WINDIMS) {
case GSOPTION_WIN640:

View File

@ -51,7 +51,7 @@ void CALLBACK GSkeyEvent(keyEvent *ev)
{
//static bool bShift = false;
static bool bAlt = false;
switch(ev->event) {
case KEYPRESS:
switch(ev->key) {
@ -97,7 +97,7 @@ GList *cachesizel;
GList *codecl;
GList *filtersl;
void OnConf_Ok(GtkButton *button, gpointer user_data)
void OnConf_Ok(GtkButton *button, gpointer user_data)
{
GtkWidget *Btn;
GtkWidget *treeview;
@ -114,16 +114,16 @@ void OnConf_Ok(GtkButton *button, gpointer user_data)
else if( !newinterlace ) conf.interlace = 2; // off
conf.bilinear = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkBilinear")));
// restore
if( conf.bilinear && prevbilinearfilter )
conf.bilinear = prevbilinearfilter;
// restore
if( conf.bilinear && prevbilinearfilter )
conf.bilinear = prevbilinearfilter;
//conf.mrtdepth = 1;//IsDlgButtonChecked(hW, IDC_CONFIG_DEPTHWRITE);
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAANone"))) ) {
conf.aa = 0;
}
else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA2X"))) ) {
else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA2X"))) ) {
conf.aa = 1;
}
else conf.aa = 2;
@ -153,22 +153,22 @@ void OnConf_Ok(GtkButton *button, gpointer user_data)
GSsetGameCRC(0, conf.gamesettings);
//---------- done getting advanced options ---------//
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize640"))) )
conf.options |= GSOPTION_WIN640;
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize640"))) )
conf.options |= GSOPTION_WIN640;
else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize800"))) )
conf.options |= GSOPTION_WIN800;
conf.options |= GSOPTION_WIN800;
else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1024"))) )
conf.options |= GSOPTION_WIN1024;
conf.options |= GSOPTION_WIN1024;
else if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1280"))) )
conf.options |= GSOPTION_WIN1280;
conf.options |= GSOPTION_WIN1280;
SaveConfig();
SaveConfig();
gtk_widget_destroy(Conf);
gtk_main_quit();
}
void OnConf_Cancel(GtkButton *button, gpointer user_data) {
void OnConf_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(Conf);
gtk_main_quit();
}
@ -185,27 +185,27 @@ void CALLBACK GSconfigure()
GtkTreeIter treeiter;
GtkTreeViewColumn *treecol;
if( !(conf.options & GSOPTION_LOADED) )
if( !(conf.options & GSOPTION_LOADED) )
LoadConfig();
Conf = create_Config();
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkBilinear")), !!conf.bilinear);
//gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton6")), conf.mrtdepth);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAANone")), conf.aa==0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA2X")), conf.aa==1);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA4X")), conf.aa==2);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkWireframe")), (conf.options&GSOPTION_WIREFRAME)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkAVI")), (conf.options&GSOPTION_CAPTUREAVI)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton6")), (conf.options&GSOPTION_FULLSCREEN)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkTGA")), (conf.options&GSOPTION_TGASNAP)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkBilinear")), !!conf.bilinear);
//gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton6")), conf.mrtdepth);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAANone")), conf.aa==0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA2X")), conf.aa==1);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioAA4X")), conf.aa==2);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkWireframe")), (conf.options&GSOPTION_WIREFRAME)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkAVI")), (conf.options&GSOPTION_CAPTUREAVI)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton6")), (conf.options&GSOPTION_FULLSCREEN)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkTGA")), (conf.options&GSOPTION_TGASNAP)?1:0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize640")), ((conf.options&GSOPTION_WINDIMS)>>4)==0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize800")), ((conf.options&GSOPTION_WINDIMS)>>4)==1);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1024")), ((conf.options&GSOPTION_WINDIMS)>>4)==2);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1280")), ((conf.options&GSOPTION_WINDIMS)>>4)==3);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize640")), ((conf.options&GSOPTION_WINDIMS)>>4)==0);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize800")), ((conf.options&GSOPTION_WINDIMS)>>4)==1);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1024")), ((conf.options&GSOPTION_WINDIMS)>>4)==2);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "radioSize1280")), ((conf.options&GSOPTION_WINDIMS)>>4)==3);
prevbilinearfilter = conf.bilinear;
prevbilinearfilter = conf.bilinear;
//--------- Let's build a treeview for our advanced options! --------//
treeview = lookup_widget(Conf,"treeview1");
@ -337,7 +337,7 @@ void OnToggle_advopts(GtkCellRendererToggle *cell, gchar *path, gpointer user_da
GtkWidget *About;
void OnAbout_Ok(GtkButton *button, gpointer user_data) {
void OnAbout_Ok(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(About);
gtk_main_quit();
}

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,7 @@ struct BLOCK
void (*TransferLocalHost)(void* pbyMem, u32 nQWordSize);
// texture must be of dims BLOCK_TEXWIDTH and BLOCK_TEXHEIGHT
static void FillBlocks(std::vector<char>& vBlockData, std::vector<char>& vBilinearData, int floatfmt);
static void FillBlocks(std::vector<char>& vBlockData, std::vector<char>& vBilinearData, int floatfmt);
};
extern BLOCK m_Blocks[];
@ -316,7 +316,7 @@ __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)
return pix >> 4;
return pix >> 4;
else return pix & 0xf;
}
@ -452,7 +452,7 @@ __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)
return pix >> 4;
return pix >> 4;
else return pix & 0xf;
}

File diff suppressed because it is too large Load Diff

View File

@ -8,93 +8,93 @@ extern HINSTANCE hInst;
void SaveConfig() {
char *szTemp;
char szIniFile[256], szValue[256];
char *szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\zerogs.ini");
if(!szTemp) return;
strcpy(szTemp, "\\inis\\zerogs.ini");
sprintf(szValue,"%u",conf.interlace);
WritePrivateProfileString("Settings", "Interlace",szValue,szIniFile);
sprintf(szValue,"%u",conf.aa);
WritePrivateProfileString("Settings", "Antialiasing",szValue,szIniFile);
sprintf(szValue,"%u",conf.bilinear);
WritePrivateProfileString("Settings", "Bilinear",szValue,szIniFile);
sprintf(szValue,"%u",conf.options);
WritePrivateProfileString("Settings", "Options",szValue,szIniFile);
sprintf(szValue,"%u",conf.gamesettings);
WritePrivateProfileString("Settings", "AdvancedOptions",szValue,szIniFile);
sprintf(szValue,"%u",conf.interlace);
WritePrivateProfileString("Settings", "Interlace",szValue,szIniFile);
sprintf(szValue,"%u",conf.aa);
WritePrivateProfileString("Settings", "Antialiasing",szValue,szIniFile);
sprintf(szValue,"%u",conf.bilinear);
WritePrivateProfileString("Settings", "Bilinear",szValue,szIniFile);
sprintf(szValue,"%u",conf.options);
WritePrivateProfileString("Settings", "Options",szValue,szIniFile);
sprintf(szValue,"%u",conf.gamesettings);
WritePrivateProfileString("Settings", "AdvancedOptions",szValue,szIniFile);
}
void LoadConfig() {
FILE *fp;
char *szTemp;
char szIniFile[256], szValue[256];
FILE *fp;
char *szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
memset(&conf, 0, sizeof(conf));
conf.interlace = 0; // on, mode 1
conf.mrtdepth = 1;
conf.options = 0;
conf.bilinear = 1;
conf.width = 640;
conf.height = 480;
memset(&conf, 0, sizeof(conf));
conf.interlace = 0; // on, mode 1
conf.mrtdepth = 1;
conf.options = 0;
conf.bilinear = 1;
conf.width = 640;
conf.height = 480;
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\zerogs.ini");
fp=fopen("inis\\zerogs.ini","rt");
if (!fp)
{
CreateDirectory("inis",NULL);
SaveConfig();//save and return
return ;
}
fclose(fp);
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\zerogs.ini");
fp=fopen("inis\\zerogs.ini","rt");
if (!fp)
{
CreateDirectory("inis",NULL);
SaveConfig();//save and return
return ;
}
fclose(fp);
GetPrivateProfileString("Settings", "Interlace", NULL, szValue, 20, szIniFile);
conf.interlace = (u8)strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Antialiasing", NULL, szValue, 20, szIniFile);
conf.aa = (u8)strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Options", NULL, szValue, 20, szIniFile);
conf.options = strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "AdvancedOptions", NULL, szValue, 20, szIniFile);
conf.gamesettings = strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, szIniFile);
conf.bilinear = strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Interlace", NULL, szValue, 20, szIniFile);
conf.interlace = (u8)strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Antialiasing", NULL, szValue, 20, szIniFile);
conf.aa = (u8)strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Options", NULL, szValue, 20, szIniFile);
conf.options = strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "AdvancedOptions", NULL, szValue, 20, szIniFile);
conf.gamesettings = strtoul(szValue, NULL, 10);
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, szIniFile);
conf.bilinear = strtoul(szValue, NULL, 10);
if( conf.aa < 0 || conf.aa > 2 ) conf.aa = 0;
if( conf.aa < 0 || conf.aa > 2 ) conf.aa = 0;
switch(conf.options&GSOPTION_WINDIMS) {
case GSOPTION_WIN640:
conf.width = 640;
conf.height = 480;
break;
case GSOPTION_WIN800:
conf.width = 800;
conf.height = 600;
break;
case GSOPTION_WIN1024:
conf.width = 1024;
conf.height = 768;
break;
case GSOPTION_WIN1280:
conf.width = 1280;
conf.height = 960;
break;
}
// turn off all hacks by defaultof
conf.options &= ~(GSOPTION_FULLSCREEN|GSOPTION_WIREFRAME|GSOPTION_CAPTUREAVI);
conf.options |= GSOPTION_LOADED;
switch(conf.options&GSOPTION_WINDIMS) {
case GSOPTION_WIN640:
conf.width = 640;
conf.height = 480;
break;
case GSOPTION_WIN800:
conf.width = 800;
conf.height = 600;
break;
case GSOPTION_WIN1024:
conf.width = 1024;
conf.height = 768;
break;
case GSOPTION_WIN1280:
conf.width = 1280;
conf.height = 960;
break;
}
// turn off all hacks by defaultof
conf.options &= ~(GSOPTION_FULLSCREEN|GSOPTION_WIREFRAME|GSOPTION_CAPTUREAVI);
conf.options |= GSOPTION_LOADED;
if( conf.width <= 0 || conf.height <= 0 ) {
conf.width = 640;
conf.height = 480;
}
if( conf.width <= 0 || conf.height <= 0 ) {
conf.width = 640;
conf.height = 480;
}
}

View File

@ -16,46 +16,46 @@ HINSTANCE hInst=NULL;
void CALLBACK GSkeyEvent(keyEvent *ev) {
// switch (ev->event) {
// case KEYPRESS:
// switch (ev->key) {
// case VK_PRIOR:
// if (conf.fps) fpspos++; break;
// case VK_NEXT:
// if (conf.fps) fpspos--; break;
// case VK_END:
// if (conf.fps) fpspress = 1; break;
// case VK_DELETE:
// conf.fps = 1 - conf.fps;
// break;
// }
// break;
// case KEYPRESS:
// switch (ev->key) {
// case VK_PRIOR:
// if (conf.fps) fpspos++; break;
// case VK_NEXT:
// if (conf.fps) fpspos--; break;
// case VK_END:
// if (conf.fps) fpspress = 1; break;
// case VK_DELETE:
// conf.fps = 1 - conf.fps;
// break;
// }
// break;
// }
}
#include "Win32/resource.h"
BOOL CALLBACK LoggingDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
if (conf.log) CheckDlgButton(hW, IDC_LOG, TRUE);
return TRUE;
switch(uMsg) {
case WM_INITDIALOG:
if (conf.log) CheckDlgButton(hW, IDC_LOG, TRUE);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, FALSE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOG))
conf.log = 1;
else conf.log = 0;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, FALSE);
return TRUE;
case IDOK:
if (IsDlgButtonChecked(hW, IDC_LOG))
conf.log = 1;
else conf.log = 0;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
SaveConfig();
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
map<int, int> mapConfOpts;
@ -63,184 +63,184 @@ map<int, int> mapConfOpts;
void OnInitDialog(HWND hW)
{
if( !(conf.options & GSOPTION_LOADED) )
LoadConfig();
if( !(conf.options & GSOPTION_LOADED) )
LoadConfig();
CheckDlgButton(hW, IDC_CONFIG_INTERLACE, conf.interlace);
CheckDlgButton(hW, IDC_CONFIG_BILINEAR, conf.bilinear);
CheckDlgButton(hW, IDC_CONFIG_DEPTHWRITE, conf.mrtdepth);
CheckRadioButton(hW,IDC_CONFIG_AANONE,IDC_CONFIG_AA4, IDC_CONFIG_AANONE+conf.aa);
CheckDlgButton(hW, IDC_CONFIG_WIREFRAME, (conf.options&GSOPTION_WIREFRAME)?1:0);
CheckDlgButton(hW, IDC_CONFIG_CAPTUREAVI, (conf.options&GSOPTION_CAPTUREAVI)?1:0);
//CheckDlgButton(hW, IDC_CONFIG_CACHEFBP, (conf.options&GSOPTION_ALPHACLAMP)?1:0);
CheckDlgButton(hW, IDC_CONFIG_FULLSCREEN, (conf.options&GSOPTION_FULLSCREEN)?1:0);
//CheckDlgButton(hW, IDC_CONFIG_FFX, (conf.options&GSOPTION_FFXHACK)?1:0);
CheckDlgButton(hW, IDC_CONFIG_BMPSS, (conf.options&GSOPTION_TGASNAP)?1:0);
CheckRadioButton(hW,IDC_CONF_WIN640, IDC_CONF_WIN1280, IDC_CONF_WIN640+((conf.options&GSOPTION_WINDIMS)>>4));
CheckDlgButton(hW, IDC_CONFIG_INTERLACE, conf.interlace);
CheckDlgButton(hW, IDC_CONFIG_BILINEAR, conf.bilinear);
CheckDlgButton(hW, IDC_CONFIG_DEPTHWRITE, conf.mrtdepth);
CheckRadioButton(hW,IDC_CONFIG_AANONE,IDC_CONFIG_AA4, IDC_CONFIG_AANONE+conf.aa);
CheckDlgButton(hW, IDC_CONFIG_WIREFRAME, (conf.options&GSOPTION_WIREFRAME)?1:0);
CheckDlgButton(hW, IDC_CONFIG_CAPTUREAVI, (conf.options&GSOPTION_CAPTUREAVI)?1:0);
//CheckDlgButton(hW, IDC_CONFIG_CACHEFBP, (conf.options&GSOPTION_ALPHACLAMP)?1:0);
CheckDlgButton(hW, IDC_CONFIG_FULLSCREEN, (conf.options&GSOPTION_FULLSCREEN)?1:0);
//CheckDlgButton(hW, IDC_CONFIG_FFX, (conf.options&GSOPTION_FFXHACK)?1:0);
CheckDlgButton(hW, IDC_CONFIG_BMPSS, (conf.options&GSOPTION_TGASNAP)?1:0);
CheckRadioButton(hW,IDC_CONF_WIN640, IDC_CONF_WIN1280, IDC_CONF_WIN640+((conf.options&GSOPTION_WINDIMS)>>4));
prevbilinearfilter = conf.bilinear;
prevbilinearfilter = conf.bilinear;
mapConfOpts.clear();
PUT_CONF(00000001);
PUT_CONF(00000002);
PUT_CONF(00000004);
PUT_CONF(00000008);
PUT_CONF(00000010);
PUT_CONF(00000020);
PUT_CONF(00000040);
PUT_CONF(00000080);
PUT_CONF(00000200);
PUT_CONF(00000400);
PUT_CONF(00000800);
PUT_CONF(00001000);
PUT_CONF(00002000);
PUT_CONF(00004000);
PUT_CONF(00008000);
PUT_CONF(00010000);
PUT_CONF(00020000);
PUT_CONF(00040000);
PUT_CONF(00080000);
PUT_CONF(00100000);
PUT_CONF(00200000);
PUT_CONF(00800000);
PUT_CONF(01000000);
PUT_CONF(02000000);
PUT_CONF(04000000);
mapConfOpts.clear();
PUT_CONF(00000001);
PUT_CONF(00000002);
PUT_CONF(00000004);
PUT_CONF(00000008);
PUT_CONF(00000010);
PUT_CONF(00000020);
PUT_CONF(00000040);
PUT_CONF(00000080);
PUT_CONF(00000200);
PUT_CONF(00000400);
PUT_CONF(00000800);
PUT_CONF(00001000);
PUT_CONF(00002000);
PUT_CONF(00004000);
PUT_CONF(00008000);
PUT_CONF(00010000);
PUT_CONF(00020000);
PUT_CONF(00040000);
PUT_CONF(00080000);
PUT_CONF(00100000);
PUT_CONF(00200000);
PUT_CONF(00800000);
PUT_CONF(01000000);
PUT_CONF(02000000);
PUT_CONF(04000000);
for(map<int, int>::iterator it = mapConfOpts.begin(); it != mapConfOpts.end(); ++it) {
CheckDlgButton(hW, it->first, (conf.gamesettings&it->second)?1:0);
}
for(map<int, int>::iterator it = mapConfOpts.begin(); it != mapConfOpts.end(); ++it) {
CheckDlgButton(hW, it->first, (conf.gamesettings&it->second)?1:0);
}
}
void OnOK(HWND hW) {
u32 newinterlace = IsDlgButtonChecked(hW, IDC_CONFIG_INTERLACE);
u32 newinterlace = IsDlgButtonChecked(hW, IDC_CONFIG_INTERLACE);
if( !conf.interlace ) conf.interlace = newinterlace;
else if( !newinterlace ) conf.interlace = 2; // off
if( !conf.interlace ) conf.interlace = newinterlace;
else if( !newinterlace ) conf.interlace = 2; // off
conf.bilinear = IsDlgButtonChecked(hW, IDC_CONFIG_BILINEAR);
// restore
if( conf.bilinear && prevbilinearfilter )
conf.bilinear = prevbilinearfilter;
conf.bilinear = IsDlgButtonChecked(hW, IDC_CONFIG_BILINEAR);
// restore
if( conf.bilinear && prevbilinearfilter )
conf.bilinear = prevbilinearfilter;
//conf.mrtdepth = 1;//IsDlgButtonChecked(hW, IDC_CONFIG_DEPTHWRITE);
//conf.mrtdepth = 1;//IsDlgButtonChecked(hW, IDC_CONFIG_DEPTHWRITE);
if( SendDlgItemMessage(hW,IDC_CONFIG_AANONE,BM_GETCHECK,0,0) ) {
conf.aa = 0;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA2,BM_GETCHECK,0,0) ) {
conf.aa = 1;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA4,BM_GETCHECK,0,0) ) {
conf.aa = 2;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA8,BM_GETCHECK,0,0) ) {
conf.aa = 3;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA16,BM_GETCHECK,0,0) ) {
conf.aa = 4;
}
else conf.aa = 0;
if( SendDlgItemMessage(hW,IDC_CONFIG_AANONE,BM_GETCHECK,0,0) ) {
conf.aa = 0;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA2,BM_GETCHECK,0,0) ) {
conf.aa = 1;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA4,BM_GETCHECK,0,0) ) {
conf.aa = 2;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA8,BM_GETCHECK,0,0) ) {
conf.aa = 3;
}
else if( SendDlgItemMessage(hW,IDC_CONFIG_AA16,BM_GETCHECK,0,0) ) {
conf.aa = 4;
}
else conf.aa = 0;
conf.options = 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_CAPTUREAVI) ? GSOPTION_CAPTUREAVI : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_WIREFRAME) ? GSOPTION_WIREFRAME : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_FULLSCREEN) ? GSOPTION_FULLSCREEN : 0;
//conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_FFX) ? GSOPTION_FFXHACK : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_BMPSS) ? GSOPTION_TGASNAP : 0;
conf.options = 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_CAPTUREAVI) ? GSOPTION_CAPTUREAVI : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_WIREFRAME) ? GSOPTION_WIREFRAME : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_FULLSCREEN) ? GSOPTION_FULLSCREEN : 0;
//conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_FFX) ? GSOPTION_FFXHACK : 0;
conf.options |= IsDlgButtonChecked(hW, IDC_CONFIG_BMPSS) ? GSOPTION_TGASNAP : 0;
conf.gamesettings = 0;
for(map<int, int>::iterator it = mapConfOpts.begin(); it != mapConfOpts.end(); ++it) {
if( IsDlgButtonChecked(hW, it->first) )
conf.gamesettings |= it->second;
}
GSsetGameCRC(g_LastCRC, conf.gamesettings);
conf.gamesettings = 0;
for(map<int, int>::iterator it = mapConfOpts.begin(); it != mapConfOpts.end(); ++it) {
if( IsDlgButtonChecked(hW, it->first) )
conf.gamesettings |= it->second;
}
GSsetGameCRC(g_LastCRC, conf.gamesettings);
if( SendDlgItemMessage(hW,IDC_CONF_WIN640,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN640;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN800,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN800;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN1024,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN1024;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN1280,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN1280;
if( SendDlgItemMessage(hW,IDC_CONF_WIN640,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN640;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN800,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN800;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN1024,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN1024;
else if( SendDlgItemMessage(hW,IDC_CONF_WIN1280,BM_GETCHECK,0,0) ) conf.options |= GSOPTION_WIN1280;
SaveConfig();
EndDialog(hW, FALSE);
SaveConfig();
EndDialog(hW, FALSE);
}
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
OnInitDialog(hW);
return TRUE;
switch(uMsg) {
case WM_INITDIALOG:
OnInitDialog(hW);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
OnOK(hW);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDCANCEL:
EndDialog(hW, TRUE);
return TRUE;
case IDOK:
OnOK(hW);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_INITDIALOG:
switch(uMsg) {
case WM_INITDIALOG:
//ZeroGS uses floating point render targets because A8R8G8B8 format is not sufficient for ps2 blending and this requires alpha blending on floating point render targets
//There might be a problem with pixel shader precision with older geforce models (textures will look blocky).
//ZeroGS uses floating point render targets because A8R8G8B8 format is not sufficient for ps2 blending and this requires alpha blending on floating point render targets
//There might be a problem with pixel shader precision with older geforce models (textures will look blocky).
return TRUE;
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
EndDialog(hW, FALSE);
return TRUE;
}
}
return FALSE;
}
s32 CALLBACK GStest() {
return 0;
return 0;
}
void CALLBACK GSabout() {
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(),
(DLGPROC)AboutDlgProc);
}
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
DWORD dwReason,
LPVOID lpReserved) {
hInst = (HINSTANCE)hModule;
return TRUE; // very quick :)
}
static char *err = "Error Loading Symbol";
static int errval;
void *SysLoadLibrary(char *lib) {
return LoadLibrary(lib);
return LoadLibrary(lib);
}
void *SysLoadSym(void *lib, char *sym) {
void *tmp = GetProcAddress((HINSTANCE)lib, sym);
if (tmp == NULL) errval = 1;
else errval = 0;
return tmp;
void *tmp = GetProcAddress((HINSTANCE)lib, sym);
if (tmp == NULL) errval = 1;
else errval = 0;
return tmp;
}
char *SysLibError() {
if (errval) { errval = 0; return err; }
return NULL;
if (errval) { errval = 0; return err; }
return NULL;
}
void SysCloseLibrary(void *lib) {
FreeLibrary((HINSTANCE)lib);
FreeLibrary((HINSTANCE)lib);
}

View File

@ -9,31 +9,31 @@ using namespace std;
BOOL AVI_Init()
{
/* first let's make sure we are running on 1.1 */
WORD wVer = HIWORD(VideoForWindowsVersion());
if (wVer < 0x010a){
/* oops, we are too old, blow out of here */
//MessageBeep(MB_ICONHAND);
MessageBox(NULL, "Cant't init AVI File - Video for Windows version is to old", "Error", MB_OK|MB_ICONSTOP);
return FALSE;
}
/* first let's make sure we are running on 1.1 */
WORD wVer = HIWORD(VideoForWindowsVersion());
if (wVer < 0x010a){
/* oops, we are too old, blow out of here */
//MessageBeep(MB_ICONHAND);
MessageBox(NULL, "Cant't init AVI File - Video for Windows version is to old", "Error", MB_OK|MB_ICONSTOP);
return FALSE;
}
AVIFileInit();
AVIFileInit();
return TRUE;
return TRUE;
}
BOOL AVI_FileOpenWrite(PAVIFILE * pfile, const char *filename)
{
HRESULT hr = AVIFileOpen(pfile, // returned file pointer
filename, // file name
OF_WRITE | OF_CREATE, // mode to open file with
NULL); // use handler determined
// from file extension....
if (hr != AVIERR_OK)
return FALSE;
HRESULT hr = AVIFileOpen(pfile, // returned file pointer
filename, // file name
OF_WRITE | OF_CREATE, // mode to open file with
NULL); // use handler determined
// from file extension....
if (hr != AVIERR_OK)
return FALSE;
return TRUE;
return TRUE;
}
DWORD getFOURCC(const char* value)
@ -58,47 +58,47 @@ DWORD getFOURCC(const char* value)
// Fill in the header for the video stream....
// The video stream will run in rate ths of a second....
BOOL AVI_CreateStream(PAVIFILE pfile, PAVISTREAM * ps, int rate, // sample/second
unsigned long buffersize, int rectwidth, int rectheight,
unsigned long buffersize, int rectwidth, int rectheight,
const char* _compressor)
{
AVISTREAMINFO strhdr;
memset(&strhdr, 0, sizeof(strhdr));
strhdr.fccType = streamtypeVIDEO;// stream type
strhdr.fccHandler = getFOURCC(_compressor);
//strhdr.fccHandler = 0; // no compression!
//strhdr.fccHandler = mmioFOURCC('D','I','B',' '); // Uncompressed
//strhdr.fccHandler = mmioFOURCC('C','V','I','D'); // Cinpak
//strhdr.fccHandler = mmioFOURCC('I','V','3','2'); // Intel video 3.2
//strhdr.fccHandler = mmioFOURCC('M','S','V','C'); // Microsoft video 1
//strhdr.fccHandler = mmioFOURCC('I','V','5','0'); // Intel video 5.0
//strhdr.dwFlags = AVISTREAMINFO_DISABLED;
//strhdr.dwCaps =
//strhdr.wPriority =
//strhdr.wLanguage =
strhdr.dwScale = 1;
strhdr.dwRate = rate; // rate fps
//strhdr.dwStart =
//strhdr.dwLength =
//strhdr.dwInitialFrames =
strhdr.dwSuggestedBufferSize = buffersize;
strhdr.dwQuality = -1; // use the default
//strhdr.dwSampleSize =
SetRect(&strhdr.rcFrame, 0, 0, // rectangle for stream
(int) rectwidth,
(int) rectheight);
//strhdr.dwEditCount =
strhdr.fccType = streamtypeVIDEO;// stream type
strhdr.fccHandler = getFOURCC(_compressor);
//strhdr.fccHandler = 0; // no compression!
//strhdr.fccHandler = mmioFOURCC('D','I','B',' '); // Uncompressed
//strhdr.fccHandler = mmioFOURCC('C','V','I','D'); // Cinpak
//strhdr.fccHandler = mmioFOURCC('I','V','3','2'); // Intel video 3.2
//strhdr.fccHandler = mmioFOURCC('M','S','V','C'); // Microsoft video 1
//strhdr.fccHandler = mmioFOURCC('I','V','5','0'); // Intel video 5.0
//strhdr.dwFlags = AVISTREAMINFO_DISABLED;
//strhdr.dwCaps =
//strhdr.wPriority =
//strhdr.wLanguage =
strhdr.dwScale = 1;
strhdr.dwRate = rate; // rate fps
//strhdr.dwStart =
//strhdr.dwLength =
//strhdr.dwInitialFrames =
strhdr.dwSuggestedBufferSize = buffersize;
strhdr.dwQuality = -1; // use the default
//strhdr.dwSampleSize =
SetRect(&strhdr.rcFrame, 0, 0, // rectangle for stream
(int) rectwidth,
(int) rectheight);
//strhdr.dwEditCount =
//strhdr.dwFormatChangeCount =
//strcpy(strhdr.szName, "Full Frames (Uncompressed)");
// And create the stream;
HRESULT hr = AVIFileCreateStream(pfile, // file pointer
ps, // returned stream pointer
&strhdr); // stream header
if (hr != AVIERR_OK) {
return FALSE;
}
// And create the stream;
HRESULT hr = AVIFileCreateStream(pfile, // file pointer
ps, // returned stream pointer
&strhdr); // stream header
if (hr != AVIERR_OK) {
return FALSE;
}
return TRUE;
return TRUE;
}
string getFOURCCVAsString(DWORD value)
@ -164,23 +164,23 @@ string dumpAVICOMPRESSOPTIONS(AVICOMPRESSOPTIONS opts)
BOOL AVI_SetOptions(PAVISTREAM * ps, PAVISTREAM * psCompressed, LPBITMAPINFOHEADER lpbi,
const char* _compressor)
{
AVICOMPRESSOPTIONS opts;
AVICOMPRESSOPTIONS FAR * aopts[1] = {&opts};
AVICOMPRESSOPTIONS opts;
AVICOMPRESSOPTIONS FAR * aopts[1] = {&opts};
memset(&opts, 0, sizeof(opts));
opts.fccType = streamtypeVIDEO;
opts.fccHandler = getFOURCC(_compressor);
opts.fccHandler = getFOURCC(_compressor);
//opts.fccHandler = 0;
//opts.fccHandler = mmioFOURCC('D','I','B',' '); // Uncompressed
//opts.fccHandler = mmioFOURCC('C','V','I','D'); // Cinpak
//opts.fccHandler = mmioFOURCC('I','V','3','2'); // Intel video 3.2
//opts.fccHandler = mmioFOURCC('M','S','V','C'); // Microsoft video 1
//opts.fccHandler = mmioFOURCC('I','V','5','0'); // Intel video 5.0
//opts.fccHandler = mmioFOURCC('D','I','B',' '); // Uncompressed
//opts.fccHandler = mmioFOURCC('C','V','I','D'); // Cinpak
//opts.fccHandler = mmioFOURCC('I','V','3','2'); // Intel video 3.2
//opts.fccHandler = mmioFOURCC('M','S','V','C'); // Microsoft video 1
//opts.fccHandler = mmioFOURCC('I','V','5','0'); // Intel video 5.0
//opts.dwKeyFrameEvery = 5;
//opts.dwQuality
//opts.dwBytesPerSecond
//opts.dwFlags = AVICOMPRESSF_KEYFRAMES;
//opts.dwFlags = AVICOMPRESSF_KEYFRAMES;
//opts.lpFormat
//opts.cbFormat
//opts.lpParms
@ -199,52 +199,52 @@ BOOL AVI_SetOptions(PAVISTREAM * ps, PAVISTREAM * psCompressed, LPBITMAPINFOHEAD
//MessageBox(NULL, dumpAVICOMPRESSOPTIONS(opts).c_str(), "AVICOMPRESSOPTIONS", MB_OK);
}
HRESULT hr = AVIMakeCompressedStream(psCompressed, *ps, &opts, NULL);
if (hr != AVIERR_OK) {
return FALSE;
}
HRESULT hr = AVIMakeCompressedStream(psCompressed, *ps, &opts, NULL);
if (hr != AVIERR_OK) {
return FALSE;
}
hr = AVIStreamSetFormat(*psCompressed, 0,
lpbi, // stream format
lpbi->biSize // format size
+ lpbi->biClrUsed * sizeof(RGBQUAD)
);
if (hr != AVIERR_OK) {
return FALSE;
}
hr = AVIStreamSetFormat(*psCompressed, 0,
lpbi, // stream format
lpbi->biSize // format size
+ lpbi->biClrUsed * sizeof(RGBQUAD)
);
if (hr != AVIERR_OK) {
return FALSE;
}
return TRUE;
return TRUE;
}
BOOL AVI_SetText(PAVIFILE pfile, PAVISTREAM psText, char *szText, int width, int height, int TextHeight)
{
// Fill in the stream header for the text stream....
AVISTREAMINFO strhdr;
DWORD dwTextFormat;
// The text stream is in 60ths of a second....
// Fill in the stream header for the text stream....
AVISTREAMINFO strhdr;
DWORD dwTextFormat;
// The text stream is in 60ths of a second....
memset(&strhdr, 0, sizeof(strhdr));
strhdr.fccType = streamtypeTEXT;
strhdr.fccHandler = mmioFOURCC('D', 'R', 'A', 'W');
strhdr.dwScale = 1;
strhdr.dwRate = 60;
strhdr.dwSuggestedBufferSize = sizeof(szText);
SetRect(&strhdr.rcFrame, 0, (int) height,
(int) width, (int) height + TextHeight); // #define TEXT_HEIGHT 20
strhdr.fccType = streamtypeTEXT;
strhdr.fccHandler = mmioFOURCC('D', 'R', 'A', 'W');
strhdr.dwScale = 1;
strhdr.dwRate = 60;
strhdr.dwSuggestedBufferSize = sizeof(szText);
SetRect(&strhdr.rcFrame, 0, (int) height,
(int) width, (int) height + TextHeight); // #define TEXT_HEIGHT 20
// ....and create the stream.
HRESULT hr = AVIFileCreateStream(pfile, &psText, &strhdr);
if (hr != AVIERR_OK) {
return FALSE;
}
// ....and create the stream.
HRESULT hr = AVIFileCreateStream(pfile, &psText, &strhdr);
if (hr != AVIERR_OK) {
return FALSE;
}
dwTextFormat = sizeof(dwTextFormat);
hr = AVIStreamSetFormat(psText, 0, &dwTextFormat, sizeof(dwTextFormat));
if (hr != AVIERR_OK) {
return FALSE;
}
dwTextFormat = sizeof(dwTextFormat);
hr = AVIStreamSetFormat(psText, 0, &dwTextFormat, sizeof(dwTextFormat));
if (hr != AVIERR_OK) {
return FALSE;
}
return TRUE;
return TRUE;
}
BOOL AVI_AddFrame(PAVISTREAM psCompressed, int time, LPBITMAPINFOHEADER lpbi)
@ -280,51 +280,51 @@ BOOL AVI_AddFrame(PAVISTREAM psCompressed, int time, LPBITMAPINFOHEADER lpbi)
BOOL AVI_AddText(PAVISTREAM psText, int time, char *szText)
{
int iLen = (int)strlen(szText);
int iLen = (int)strlen(szText);
HRESULT hr = AVIStreamWrite(psText,
time,
1,
szText,
iLen + 1,
AVIIF_KEYFRAME,
NULL,
NULL);
if (hr != AVIERR_OK)
return FALSE;
HRESULT hr = AVIStreamWrite(psText,
time,
1,
szText,
iLen + 1,
AVIIF_KEYFRAME,
NULL,
NULL);
if (hr != AVIERR_OK)
return FALSE;
return TRUE;
return TRUE;
}
BOOL AVI_CloseStream(PAVISTREAM ps, PAVISTREAM psCompressed, PAVISTREAM psText)
{
if (ps)
AVIStreamClose(ps);
if (ps)
AVIStreamClose(ps);
if (psCompressed)
AVIStreamClose(psCompressed);
if (psCompressed)
AVIStreamClose(psCompressed);
if (psText)
AVIStreamClose(psText);
if (psText)
AVIStreamClose(psText);
return TRUE;
return TRUE;
}
BOOL AVI_CloseFile(PAVIFILE pfile)
{
if (pfile)
AVIFileClose(pfile);
return TRUE;
if (pfile)
AVIFileClose(pfile);
return TRUE;
}
BOOL AVI_Exit()
{
AVIFileExit();
AVIFileExit();
return TRUE;
return TRUE;
}

View File

@ -29,8 +29,8 @@ char* dstfilename = "ps2hw.dat";
struct SHADERINFO
{
int type;
vector<char> buf;
int type;
vector<char> buf;
};
map<int, SHADERINFO> mapShaders;
@ -38,300 +38,300 @@ CGcontext g_cgcontext;
void LoadShader(int index, const char* pshader, CGprofile prof, vector<const char*>& vargs, int context)
{
vector<const char*> realargs;
realargs.reserve(16);
realargs.resize(vargs.size());
if( vargs.size() > 0 )
memcpy(&realargs[0], &vargs[0], realargs.size() * sizeof(realargs[0]));
realargs.push_back(context ? "-Ictx1" : "-Ictx0");
realargs.push_back(NULL);
vector<const char*> realargs;
realargs.reserve(16);
realargs.resize(vargs.size());
if( vargs.size() > 0 )
memcpy(&realargs[0], &vargs[0], realargs.size() * sizeof(realargs[0]));
realargs.push_back(context ? "-Ictx1" : "-Ictx0");
realargs.push_back(NULL);
CGprogram prog = cgCreateProgramFromFile(g_cgcontext, CG_SOURCE, srcfilename, prof, pshader, &realargs[0]);
if( !cgIsProgram(prog) ) {
printf("Failed to load shader %s: \n%s\n", pshader, cgGetLastListing(g_cgcontext));
return;
}
CGprogram prog = cgCreateProgramFromFile(g_cgcontext, CG_SOURCE, srcfilename, prof, pshader, &realargs[0]);
if( !cgIsProgram(prog) ) {
printf("Failed to load shader %s: \n%s\n", pshader, cgGetLastListing(g_cgcontext));
return;
}
if( mapShaders.find(index) != mapShaders.end() ) {
printf("error: two shaders share the same index %d\n", index);
exit(0);
}
if( mapShaders.find(index) != mapShaders.end() ) {
printf("error: two shaders share the same index %d\n", index);
exit(0);
}
if( !cgIsProgramCompiled(prog) )
cgCompileProgram(prog);
const char* pstr = cgGetProgramString(prog, CG_COMPILED_PROGRAM);
if( !cgIsProgramCompiled(prog) )
cgCompileProgram(prog);
const char* pstr = cgGetProgramString(prog, CG_COMPILED_PROGRAM);
const char* pprog = strstr(pstr, "#program");
if( pprog == NULL ) {
printf("program field not found!\n");
return;
}
pprog += 9;
const char* progend = strchr(pprog, '\r');
if( progend == NULL ) progend = strchr(pprog, '\n');
const char* pprog = strstr(pstr, "#program");
if( pprog == NULL ) {
printf("program field not found!\n");
return;
}
pprog += 9;
const char* progend = strchr(pprog, '\r');
if( progend == NULL ) progend = strchr(pprog, '\n');
if( progend == NULL ) {
printf("prog end not found!\n");
return;
}
if( progend == NULL ) {
printf("prog end not found!\n");
return;
}
const char* defname = "main";
const char* defname = "main";
SHADERINFO info;
info.type = 0;
info.buf.resize(strlen(pstr)+1);
// change the program name to main
memset(&info.buf[0], 0, info.buf.size());
memcpy(&info.buf[0], pstr, pprog-pstr);
memcpy(&info.buf[pprog-pstr], defname, 4);
memcpy(&info.buf[pprog-pstr+4], progend, strlen(pstr)-(progend-pstr));
SHADERINFO info;
info.type = 0;
info.buf.resize(strlen(pstr)+1);
// change the program name to main
memset(&info.buf[0], 0, info.buf.size());
memcpy(&info.buf[0], pstr, pprog-pstr);
memcpy(&info.buf[pprog-pstr], defname, 4);
memcpy(&info.buf[pprog-pstr+4], progend, strlen(pstr)-(progend-pstr));
if( mapShaders.find(index) != mapShaders.end() )
printf("same shader\n");
assert( mapShaders.find(index) == mapShaders.end() );
mapShaders[index] = info;
if( mapShaders.find(index) != mapShaders.end() )
printf("same shader\n");
assert( mapShaders.find(index) == mapShaders.end() );
mapShaders[index] = info;
cgDestroyProgram(prog);
cgDestroyProgram(prog);
}
int main(int argc, char** argv)
{
printf("usage: [src] [dst] [opts]\n");
printf("usage: [src] [dst] [opts]\n");
if( argc >= 2 ) srcfilename = argv[1];
if( argc >= 3 ) dstfilename = argv[2];
if( argc >= 2 ) srcfilename = argv[1];
if( argc >= 3 ) dstfilename = argv[2];
FILE* fsrc = fopen(srcfilename, "r");
if( fsrc == NULL ) {
printf("cannot open %s\n", srcfilename);
return 0;
}
fclose(fsrc);
g_cgcontext = cgCreateContext();
if( !cgIsContext(g_cgcontext) ) {
printf("failed to create cg context\n");
return -1;
}
FILE* fsrc = fopen(srcfilename, "r");
if( fsrc == NULL ) {
printf("cannot open %s\n", srcfilename);
return 0;
}
fclose(fsrc);
g_cgcontext = cgCreateContext();
if( !cgIsContext(g_cgcontext) ) {
printf("failed to create cg context\n");
return -1;
}
CGprofile cgvProf = CG_PROFILE_ARBVP1;
CGprofile cgfProf = CG_PROFILE_ARBFP1;
if( !cgGLIsProfileSupported(cgvProf) != CG_TRUE ) {
printf("arbvp1 not supported\n");
return 0;
}
if( !cgGLIsProfileSupported(cgfProf) != CG_TRUE ) {
printf("arbfp1 not supported\n");
return 0;
}
CGprofile cgvProf = CG_PROFILE_ARBVP1;
CGprofile cgfProf = CG_PROFILE_ARBFP1;
if( !cgGLIsProfileSupported(cgvProf) != CG_TRUE ) {
printf("arbvp1 not supported\n");
return 0;
}
if( !cgGLIsProfileSupported(cgfProf) != CG_TRUE ) {
printf("arbfp1 not supported\n");
return 0;
}
cgGLEnableProfile(cgvProf);
cgGLEnableProfile(cgfProf);
cgGLSetOptimalOptions(cgvProf);
cgGLSetOptimalOptions(cgfProf);
cgGLEnableProfile(cgvProf);
cgGLEnableProfile(cgfProf);
cgGLSetOptimalOptions(cgvProf);
cgGLSetOptimalOptions(cgfProf);
vector<const char*> vmacros;
vector<const char*> vmacros;
LoadShader(SH_BITBLTVS, "BitBltVS", cgvProf, vmacros, 0);
LoadShader(SH_BITBLTPS, "BitBltPS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTDEPTHPS, "BitBltDepthPS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTDEPTHMRTPS, "BitBltDepthMRTPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCTARGPS, "CRTCTargPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCPS, "CRTCPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTC_NEARESTPS, "CRTCPS_Nearest", cgfProf, vmacros, 0);
LoadShader(SH_CRTC24PS, "CRTC24PS", cgfProf, vmacros, 0);
LoadShader(SH_ZEROPS, "ZeroPS", cgfProf, vmacros, 0);
LoadShader(SH_BASETEXTUREPS, "BaseTexturePS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTAAPS, "BitBltPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCTARGINTERPS, "CRTCTargInterPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCINTERPS, "CRTCInterPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCINTER_NEARESTPS, "CRTCInterPS_Nearest", cgfProf, vmacros, 0);
LoadShader(SH_CRTC24INTERPS, "CRTC24InterPS", cgfProf, vmacros, 0);
LoadShader(SH_CONVERT16TO32PS, "Convert16to32PS", cgfProf, vmacros, 0);
LoadShader(SH_CONVERT32TO16PS, "Convert32to16PS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTVS, "BitBltVS", cgvProf, vmacros, 0);
LoadShader(SH_BITBLTPS, "BitBltPS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTDEPTHPS, "BitBltDepthPS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTDEPTHMRTPS, "BitBltDepthMRTPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCTARGPS, "CRTCTargPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCPS, "CRTCPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTC_NEARESTPS, "CRTCPS_Nearest", cgfProf, vmacros, 0);
LoadShader(SH_CRTC24PS, "CRTC24PS", cgfProf, vmacros, 0);
LoadShader(SH_ZEROPS, "ZeroPS", cgfProf, vmacros, 0);
LoadShader(SH_BASETEXTUREPS, "BaseTexturePS", cgfProf, vmacros, 0);
LoadShader(SH_BITBLTAAPS, "BitBltPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCTARGINTERPS, "CRTCTargInterPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCINTERPS, "CRTCInterPS", cgfProf, vmacros, 0);
LoadShader(SH_CRTCINTER_NEARESTPS, "CRTCInterPS_Nearest", cgfProf, vmacros, 0);
LoadShader(SH_CRTC24INTERPS, "CRTC24InterPS", cgfProf, vmacros, 0);
LoadShader(SH_CONVERT16TO32PS, "Convert16to32PS", cgfProf, vmacros, 0);
LoadShader(SH_CONVERT32TO16PS, "Convert32to16PS", cgfProf, vmacros, 0);
const int vsshaders[4] = { SH_REGULARVS, SH_TEXTUREVS, SH_REGULARFOGVS, SH_TEXTUREFOGVS };
const char* pvsshaders[4] = { "RegularVS", "TextureVS", "RegularFogVS", "TextureFogVS" };
const int vsshaders[4] = { SH_REGULARVS, SH_TEXTUREVS, SH_REGULARFOGVS, SH_TEXTUREFOGVS };
const char* pvsshaders[4] = { "RegularVS", "TextureVS", "RegularFogVS", "TextureFogVS" };
// load the texture shaders
char str[255], strdir[255];
// load the texture shaders
char str[255], strdir[255];
strcpy(strdir, srcfilename);
int i = (int)strlen(strdir);
while(i > 0) {
if( strdir[i-1] == '/' || strdir[i-1] == '\\' )
break;
--i;
}
strcpy(strdir, srcfilename);
int i = (int)strlen(strdir);
while(i > 0) {
if( strdir[i-1] == '/' || strdir[i-1] == '\\' )
break;
--i;
}
strdir[i] = 0;
strdir[i] = 0;
for(i = 0; i < ARRAYSIZE(vsshaders); ++i) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
for(i = 0; i < ARRAYSIZE(vsshaders); ++i) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
if( writedepth ) vmacros.push_back("-DWRITE_DEPTH");
LoadShader(vsshaders[i]|(writedepth?SH_WRITEDEPTH:0), pvsshaders[i], cgvProf, vmacros, 0);
LoadShader(vsshaders[i]|(writedepth?SH_WRITEDEPTH:0)|SH_CONTEXT1, pvsshaders[i], cgvProf, vmacros, 1);
if( writedepth ) vmacros.pop_back();
}
}
if( writedepth ) vmacros.push_back("-DWRITE_DEPTH");
LoadShader(vsshaders[i]|(writedepth?SH_WRITEDEPTH:0), pvsshaders[i], cgvProf, vmacros, 0);
LoadShader(vsshaders[i]|(writedepth?SH_WRITEDEPTH:0)|SH_CONTEXT1, pvsshaders[i], cgvProf, vmacros, 1);
if( writedepth ) vmacros.pop_back();
}
}
const int psshaders[2] = { SH_REGULARPS, SH_REGULARFOGPS };
const char* ppsshaders[2] = { "RegularPS", "RegularFogPS" };
const int psshaders[2] = { SH_REGULARPS, SH_REGULARFOGPS };
const char* ppsshaders[2] = { "RegularPS", "RegularFogPS" };
for(i = 0; i < ARRAYSIZE(psshaders); ++i) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
if( writedepth ) vmacros.push_back("-DWRITE_DEPTH");
LoadShader(psshaders[i]|(writedepth?SH_WRITEDEPTH:0), ppsshaders[i], cgfProf, vmacros, 0);
if( writedepth ) vmacros.pop_back();
}
}
for(i = 0; i < ARRAYSIZE(psshaders); ++i) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
if( writedepth ) vmacros.push_back("-DWRITE_DEPTH");
LoadShader(psshaders[i]|(writedepth?SH_WRITEDEPTH:0), ppsshaders[i], cgfProf, vmacros, 0);
if( writedepth ) vmacros.pop_back();
}
}
printf("creating shaders, note that ctx0/ps2hw_ctx.fx, and ctx1/ps2hw_ctx.fx are required\n");
vmacros.resize(0);
for(int texwrap = 0; texwrap < NUM_TEXWRAPS; ++texwrap ) {
printf("creating shaders, note that ctx0/ps2hw_ctx.fx, and ctx1/ps2hw_ctx.fx are required\n");
vmacros.resize(0);
for(int texwrap = 0; texwrap < NUM_TEXWRAPS; ++texwrap ) {
if( g_pPsTexWrap[texwrap] != NULL )
vmacros.push_back(g_pPsTexWrap[texwrap]);
if( g_pPsTexWrap[texwrap] != NULL )
vmacros.push_back(g_pPsTexWrap[texwrap]);
for(int context = 0; context < 2; ++context) {
for(int texfilter = 0; texfilter < NUM_FILTERS; ++texfilter) {
for(int fog = 0; fog < 2; ++fog ) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
for(int context = 0; context < 2; ++context) {
for(int texfilter = 0; texfilter < NUM_FILTERS; ++texfilter) {
for(int fog = 0; fog < 2; ++fog ) {
for(int writedepth = 0; writedepth < 2; ++writedepth ) {
if( writedepth )
vmacros.push_back("-DWRITE_DEPTH");
if( writedepth )
vmacros.push_back("-DWRITE_DEPTH");
for(int testaem = 0; testaem < 2; ++testaem ) {
for(int testaem = 0; testaem < 2; ++testaem ) {
if( testaem )
vmacros.push_back("-DTEST_AEM");
if( testaem )
vmacros.push_back("-DTEST_AEM");
for(int exactcolor = 0; exactcolor < 2; ++exactcolor ) {
if( exactcolor )
vmacros.push_back("-DEXACT_COLOR");
for(int exactcolor = 0; exactcolor < 2; ++exactcolor ) {
if( exactcolor )
vmacros.push_back("-DEXACT_COLOR");
// 32
sprintf(str, "Texture%s%d_32PS", fog?"Fog":"", texfilter);
// 32
sprintf(str, "Texture%s%d_32PS", fog?"Fog":"", texfilter);
vmacros.push_back("-DACCURATE_DECOMPRESSION");
LoadShader(GET_SHADER_INDEX(0, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
vmacros.pop_back();
vmacros.push_back("-DACCURATE_DECOMPRESSION");
LoadShader(GET_SHADER_INDEX(0, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
vmacros.pop_back();
LoadShader(GET_SHADER_INDEX(0, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
LoadShader(GET_SHADER_INDEX(0, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
if( texfilter == 0 ) {
// tex32
sprintf(str, "Texture%s%d_tex32PS", fog?"Fog":"", texfilter);
if( texfilter == 0 ) {
// tex32
sprintf(str, "Texture%s%d_tex32PS", fog?"Fog":"", texfilter);
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(1, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(1, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
LoadShader(GET_SHADER_INDEX(1, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
LoadShader(GET_SHADER_INDEX(1, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
// clut32
sprintf(str, "Texture%s%d_clut32PS", fog?"Fog":"", texfilter);
// clut32
sprintf(str, "Texture%s%d_clut32PS", fog?"Fog":"", texfilter);
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(2, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(2, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
LoadShader(GET_SHADER_INDEX(2, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
LoadShader(GET_SHADER_INDEX(2, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
// tex32to16
sprintf(str, "Texture%s%d_tex32to16PS", fog?"Fog":"", texfilter);
// tex32to16
sprintf(str, "Texture%s%d_tex32to16PS", fog?"Fog":"", texfilter);
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(3, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(3, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
LoadShader(GET_SHADER_INDEX(3, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
LoadShader(GET_SHADER_INDEX(3, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
// tex16to8h
sprintf(str, "Texture%s%d_tex16to8hPS", fog?"Fog":"", texfilter);
// tex16to8h
sprintf(str, "Texture%s%d_tex16to8hPS", fog?"Fog":"", texfilter);
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(4, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
// vmacros.push_back("-DACCURATE_DECOMPRESSION");
// LoadShader(GET_SHADER_INDEX(4, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, SHADER_ACCURATE), str, cgfProf, vmacros, context);
// vmacros.pop_back();
LoadShader(GET_SHADER_INDEX(4, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
}
LoadShader(GET_SHADER_INDEX(4, texfilter, texwrap, fog, writedepth, testaem, exactcolor, context, 0), str, cgfProf, vmacros, context);
}
if( exactcolor )
vmacros.pop_back();
}
if( exactcolor )
vmacros.pop_back();
}
if( testaem )
vmacros.pop_back();
}
if( testaem )
vmacros.pop_back();
}
if( writedepth )
vmacros.pop_back();
}
}
}
}
if( writedepth )
vmacros.pop_back();
}
}
}
}
if( g_pPsTexWrap[texwrap] != NULL )
vmacros.pop_back();
}
if( g_pPsTexWrap[texwrap] != NULL )
vmacros.pop_back();
}
if( vmacros.size() != 0 )
printf("error with macros!\n");
if( vmacros.size() != 0 )
printf("error with macros!\n");
// create the database
// create the database
int num = (int)mapShaders.size();
// first compress
vector<char> buffer;
buffer.reserve(10000000); // 10mb
buffer.resize(sizeof(SHADERHEADER)*num);
int num = (int)mapShaders.size();
// first compress
vector<char> buffer;
buffer.reserve(10000000); // 10mb
buffer.resize(sizeof(SHADERHEADER)*num);
i = 0;
for(map<int, SHADERINFO>::iterator it = mapShaders.begin(); it != mapShaders.end(); ++it, ++i) {
SHADERHEADER h;
h.index = it->first | it->second.type;
h.offset = (int)buffer.size();
h.size = (int)it->second.buf.size();
i = 0;
for(map<int, SHADERINFO>::iterator it = mapShaders.begin(); it != mapShaders.end(); ++it, ++i) {
SHADERHEADER h;
h.index = it->first | it->second.type;
h.offset = (int)buffer.size();
h.size = (int)it->second.buf.size();
memcpy(&buffer[0] + i*sizeof(SHADERHEADER), &h, sizeof(SHADERHEADER));
memcpy(&buffer[0] + i*sizeof(SHADERHEADER), &h, sizeof(SHADERHEADER));
size_t cur = buffer.size();
buffer.resize(cur + it->second.buf.size());
memcpy(&buffer[cur], &it->second.buf[0], it->second.buf.size());
}
size_t cur = buffer.size();
buffer.resize(cur + it->second.buf.size());
memcpy(&buffer[cur], &it->second.buf[0], it->second.buf.size());
}
int compressed_size;
int real_size = (int)buffer.size();
vector<char> dst;
dst.resize(buffer.size());
def(&buffer[0], &dst[0], (int)buffer.size(), &compressed_size);
int compressed_size;
int real_size = (int)buffer.size();
vector<char> dst;
dst.resize(buffer.size());
def(&buffer[0], &dst[0], (int)buffer.size(), &compressed_size);
// write to file
// fmt: num shaders, size of compressed, compressed data
FILE* fdst = fopen(dstfilename, "wb");
if( fdst == NULL ) {
printf("failed to open %s\n", dstfilename);
return 0;
}
// write to file
// fmt: num shaders, size of compressed, compressed data
FILE* fdst = fopen(dstfilename, "wb");
if( fdst == NULL ) {
printf("failed to open %s\n", dstfilename);
return 0;
}
fwrite(&num, 4, 1, fdst);
fwrite(&compressed_size, 4, 1, fdst);
fwrite(&real_size, 4, 1, fdst);
fwrite(&dst[0], compressed_size, 1, fdst);
fwrite(&num, 4, 1, fdst);
fwrite(&compressed_size, 4, 1, fdst);
fwrite(&real_size, 4, 1, fdst);
fwrite(&dst[0], compressed_size, 1, fdst);
fclose(fdst);
fclose(fdst);
printf("wrote %s\n", dstfilename);
printf("wrote %s\n", dstfilename);
cgDestroyContext(g_cgcontext);
cgDestroyContext(g_cgcontext);
return 0;
return 0;
}

View File

@ -5,7 +5,7 @@
#define NUM_TYPES 5 // types of texture read modes
#define NUM_TEXWRAPS 4 // texture wrapping
#define SHADER_REDUCED 1 // equivalent to ps2.0
#define SHADER_REDUCED 1 // equivalent to ps2.0
#define SHADER_ACCURATE 2 // for older cards with less accurate math (ps2.x+)
#define NUM_SHADERS (NUM_FILTERS*NUM_TYPES*NUM_TEXWRAPS*32) // # shaders for a given ps
@ -33,23 +33,23 @@ static CGprogram LoadShaderFromType(const char* srcdir, const char* srcfile, int
char str[255], strctx[255];
sprintf(str, "Texture%s%d_%sPS", fog?"Fog":"", texfilter, g_pTexTypes[type]);
sprintf(strctx, "-I%s%s", srcdir, context?"ctx1":"ctx0");
sprintf(strctx, "-I%s%s", srcdir, context?"ctx1":"ctx0");
vector<const char*> macros;
macros.push_back(strctx);
macros.push_back(strctx);
#ifdef _DEBUG
macros.push_back("-bestprecision");
macros.push_back("-bestprecision");
#endif
if( g_pPsTexWrap[texwrap] != NULL ) macros.push_back(g_pPsTexWrap[texwrap]);
if( g_pPsTexWrap[texwrap] != NULL ) macros.push_back(g_pPsTexWrap[texwrap]);
if( writedepth ) macros.push_back("-DWRITE_DEPTH");
if( testaem ) macros.push_back("-DTEST_AEM");
if( exactcolor ) macros.push_back("-DEXACT_COLOR");
if( ps & SHADER_ACCURATE ) macros.push_back("-DACCURATE_DECOMPRESSION");
if( ps & SHADER_ACCURATE ) macros.push_back("-DACCURATE_DECOMPRESSION");
macros.push_back(NULL);
CGprogram prog = cgCreateProgramFromFile(g_cgcontext, CG_SOURCE, srcfile, CG_PROFILE_ARBFP1, str, &macros[0]);
CGprogram prog = cgCreateProgramFromFile(g_cgcontext, CG_SOURCE, srcfile, CG_PROFILE_ARBFP1, str, &macros[0]);
if( !cgIsProgram(prog) ) {
printf("Failed to load shader %s: \n%s\n", str, cgGetLastListing(g_cgcontext));
printf("Failed to load shader %s: \n%s\n", str, cgGetLastListing(g_cgcontext));
return NULL;
}

View File

@ -15,101 +15,101 @@ int inf(char *src, char *dst, int bytes_to_decompress, int maximum_after_decompr
int def(char *src, char *dst, int bytes_to_compress, int *bytes_after_compressed)
{
z_stream strm;
z_stream strm;
int ret;//, flush;
unsigned have;
int ret;//, flush;
unsigned have;
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION) ;
if (ret != Z_OK)
return ret;
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION) ;
if (ret != Z_OK)
return ret;
/* compress */
strm.avail_in = bytes_to_compress ;
strm.avail_out = bytes_to_compress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
/* compress */
strm.avail_in = bytes_to_compress ;
strm.avail_out = bytes_to_compress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
ret = deflate(&strm, Z_FINISH) ;
have = bytes_to_compress - strm.avail_out ;
*bytes_after_compressed = have ;
assert(ret == Z_STREAM_END); /* stream will be complete */
ret = deflate(&strm, Z_FINISH) ;
have = bytes_to_compress - strm.avail_out ;
*bytes_after_compressed = have ;
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
}
int inf(char *src, char *dst, int bytes_to_decompress, int maximum_after_decompress, int* outbytes)
{
z_stream strm;
z_stream strm;
int ret;
//unsigned have;
int ret;
//unsigned have;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress */
strm.avail_in = bytes_to_decompress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
/* decompress */
strm.avail_in = bytes_to_decompress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
strm.avail_out = maximum_after_decompress ;
ret = inflate(&strm, Z_NO_FLUSH) ;
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
assert(strm.avail_in == 0); /* all input will be used */
ret = inflate(&strm, Z_NO_FLUSH) ;
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
assert(strm.avail_in == 0); /* all input will be used */
if( outbytes != NULL )
*outbytes = strm.total_out;
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
/* report a zlib or i/o error */
void zerr(int ret)
{
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -10,138 +10,138 @@
// globals
GLubyte rasters[][13] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
{0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xff, 0x66, 0x66, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f, 0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18},
{0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30, 0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70},
{0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70, 0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e},
{0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c},
{0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30},
{0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c, 0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x38, 0x18},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e},
{0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x03, 0x03, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03, 0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06},
{0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60},
{0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e},
{0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3, 0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18},
{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e},
{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3},
{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff},
{0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c},
{0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x30, 0x30, 0x60, 0x60},
{0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18},
{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x70},
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x03, 0x03, 0x03, 0x03, 0x03},
{0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e},
{0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00},
{0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00},
{0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78},
{0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00},
{0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x00},
{0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38, 0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f},
{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c, 0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00}
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
{0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xff, 0x66, 0x66, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f, 0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18},
{0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30, 0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70},
{0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70, 0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e},
{0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c},
{0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30},
{0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c, 0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03},
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x38, 0x18},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e},
{0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x03, 0x03, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03, 0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06},
{0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60},
{0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e},
{0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3, 0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18},
{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e},
{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3},
{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c},
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff},
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff},
{0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c},
{0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x30, 0x30, 0x60, 0x60},
{0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18},
{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x70},
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x03, 0x03, 0x03, 0x03, 0x03},
{0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e},
{0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00},
{0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00},
{0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0},
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78},
{0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00},
{0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x00},
{0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38, 0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f},
{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
{0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c, 0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00}
};
RasterFont::RasterFont()
{
// set GL modes
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// create the raster font
fontOffset = glGenLists (128);
for (int i = 32; i < 127; i++) {
glNewList(i+fontOffset, GL_COMPILE);
glBitmap(8, 13, 0.0f, 2.0f, 10.0f, 0.0f, rasters[i-32]);
glEndList();
}
// set GL modes
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// create the raster font
fontOffset = glGenLists (128);
for (int i = 32; i < 127; i++) {
glNewList(i+fontOffset, GL_COMPILE);
glBitmap(8, 13, 0.0f, 2.0f, 10.0f, 0.0f, rasters[i-32]);
glEndList();
}
}
RasterFont::~RasterFont()
{
glDeleteLists(fontOffset, 128);
glDeleteLists(fontOffset, 128);
}
void RasterFont::printString(const char *s, double x, double y, double z)
{
// go to the right spot
glRasterPos3d(x, y, z);
glPushAttrib (GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
// go to the right spot
glRasterPos3d(x, y, z);
glPushAttrib (GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
}
void RasterFont::printCenteredString(const char *s, double y, int screen_width, double z)
{
int length = strlen(s);
int x = int(screen_width/2.0 - (length/2.0)*char_width);
printString(s, x, y, z);
int length = strlen(s);
int x = int(screen_width/2.0 - (length/2.0)*char_width);
printString(s, x, y, z);
}

View File

@ -3,20 +3,20 @@
class RasterFont {
protected:
int fontOffset;
int fontOffset;
public:
RasterFont();
~RasterFont(void);
static int debug;
// some useful constants
enum {char_width = 10};
enum {char_height = 15};
// and the happy helper functions
void printString(const char *s, double x, double y, double z=0.0);
void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
RasterFont();
~RasterFont(void);
static int debug;
// some useful constants
enum {char_width = 10};
enum {char_height = 15};
// and the happy helper functions
void printString(const char *s, double x, double y, double z=0.0);
void printCenteredString(const char *s, double y, int screen_width, double z=0.0);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -32,195 +32,195 @@
void FASTCALL(SwizzleBlock32_c(u8* dst, u8* src, int srcpitch, u32 WriteMask))
{
u32* d = &g_columnTable32[0][0];
u32* d = &g_columnTable32[0][0];
if(WriteMask == 0xffffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
if(WriteMask == 0xffffffff)
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = ((u32*)src)[i];
}
else
{
for(int j = 0; j < 8; j++, d += 8, src += srcpitch)
for(int i = 0; i < 8; i++)
((u32*)dst)[d[i]] = (((u32*)dst)[d[i]] & ~WriteMask) | (((u32*)src)[i] & WriteMask);
}
}
void FASTCALL(SwizzleBlock16_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable16[0][0];
u32* d = &g_columnTable16[0][0];
for(int j = 0; j < 8; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
((u16*)dst)[d[i]] = ((u16*)src)[i];
for(int j = 0; j < 8; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
((u16*)dst)[d[i]] = ((u16*)src)[i];
}
void FASTCALL(SwizzleBlock8_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable8[0][0];
u32* d = &g_columnTable8[0][0];
for(int j = 0; j < 16; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
dst[d[i]] = src[i];
for(int j = 0; j < 16; j++, d += 16, src += srcpitch)
for(int i = 0; i < 16; i++)
dst[d[i]] = src[i];
}
void FASTCALL(SwizzleBlock4_c(u8* dst, u8* src, int srcpitch))
{
u32* d = &g_columnTable4[0][0];
u32* d = &g_columnTable4[0][0];
for(int j = 0; j < 16; j++, d += 32, src += srcpitch)
{
for(int i = 0; i < 32; i++)
{
u32 addr = d[i];
u8 c = (src[i>>1] >> ((i&1) << 2)) & 0x0f;
u32 shift = (addr&1) << 2;
dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift);
}
}
for(int j = 0; j < 16; j++, d += 32, src += srcpitch)
{
for(int i = 0; i < 32; i++)
{
u32 addr = d[i];
u8 c = (src[i>>1] >> ((i&1) << 2)) & 0x0f;
u32 shift = (addr&1) << 2;
dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift);
}
}
}
#define _FrameSwizzleBlock(type, transfer, transfer16, incsrc) \
/* FrameSwizzleBlock32 */ \
void FASTCALL(FrameSwizzleBlock32##type##c(u32* dst, u32* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = (transfer); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = ((transfer)&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = (transfer); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
dst[d[j]] = ((transfer)&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* FrameSwizzleBlock16 */ \
void FASTCALL(FrameSwizzleBlock16##type##c(u16* dst, u32* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
if( WriteMask == 0xffff ) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
dst[d[j]] = RGBA32to16(temp); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
u32 dsrc = RGBA32to16(temp); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable16[0][0]; \
\
if( WriteMask == 0xffff ) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
dst[d[j]] = RGBA32to16(temp); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
u32 temp = (transfer); \
u32 dsrc = RGBA32to16(temp); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock32 */ \
void FASTCALL(Frame16SwizzleBlock32##type##c(u32* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
u32* d = &g_columnTable32[0][0]; \
\
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
if( WriteMask == 0xffffffff ) { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock32Z */ \
void FASTCALL(Frame16SwizzleBlock32Z##type##c(u32* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable32[0][0]; \
if( WriteMask == 0xffffffff ) { /* breaks KH text if not checked */ \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB_Z(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable32[0][0]; \
if( WriteMask == 0xffffffff ) { /* breaks KH text if not checked */ \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 8) { \
for(int j = 0; j < 8; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB_Z(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock16 */ \
void FASTCALL(Frame16SwizzleBlock16##type##c(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
if( (WriteMask&0xfff8f8f8) == 0xfff8f8f8) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB16(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
u32* d = &g_columnTable16[0][0]; \
\
if( (WriteMask&0xfff8f8f8) == 0xfff8f8f8) { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
else { \
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
u32 dsrc = Float16ToARGB16(dsrc16); \
dst[d[j]] = (dsrc&WriteMask)|(dst[d[j]]&~WriteMask); \
} \
src += srcpitch << incsrc; \
} \
} \
} \
\
/* Frame16SwizzleBlock16Z */ \
void FASTCALL(Frame16SwizzleBlock16Z##type##c(u16* dst, Vector_16F* src, int srcpitch, u32 WriteMask)) \
{ \
u32* d = &g_columnTable16[0][0]; \
\
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
u32* d = &g_columnTable16[0][0]; \
\
for(int i = 0; i < 8; ++i, d += 16) { \
for(int j = 0; j < 16; ++j) { \
Vector_16F dsrc16 = (transfer16); \
dst[d[j]] = Float16ToARGB16_Z(dsrc16); \
} \
src += srcpitch << incsrc; \
} \
} \
_FrameSwizzleBlock(_, src[j], src[j], 0);
@ -232,63 +232,63 @@ _FrameSwizzleBlock(A4_, (src[2*j]+src[2*j+1]+src[2*j+srcpitch]+src[2*j+srcpitch+
//void FASTCALL(WriteCLUT_T16_I8_CSM1_sse2(u32* vm, u32* clut)
//{
// __asm {
// mov eax, vm
// mov ecx, clut
// mov edx, 8
// mov eax, vm
// mov ecx, clut
// mov edx, 8
// }
//
//Extract32x2:
// __asm {
// movdqa xmm0, qword ptr [eax]
// movdqa xmm1, qword ptr [eax+16]
// movdqa xmm2, qword ptr [eax+32]
// movdqa xmm3, qword ptr [eax+48]
// movdqa xmm0, qword ptr [eax]
// movdqa xmm1, qword ptr [eax+16]
// movdqa xmm2, qword ptr [eax+32]
// movdqa xmm3, qword ptr [eax+48]
//
// // rearrange
// pshuflw xmm0, xmm0, 0xd8
// pshufhw xmm0, xmm0, 0xd8
// pshuflw xmm1, xmm1, 0xd8
// pshufhw xmm1, xmm1, 0xd8
// pshuflw xmm2, xmm2, 0xd8
// pshufhw xmm2, xmm2, 0xd8
// pshuflw xmm3, xmm3, 0xd8
// pshufhw xmm3, xmm3, 0xd8
// // rearrange
// pshuflw xmm0, xmm0, 0xd8
// pshufhw xmm0, xmm0, 0xd8
// pshuflw xmm1, xmm1, 0xd8
// pshufhw xmm1, xmm1, 0xd8
// pshuflw xmm2, xmm2, 0xd8
// pshufhw xmm2, xmm2, 0xd8
// pshuflw xmm3, xmm3, 0xd8
// pshufhw xmm3, xmm3, 0xd8
//
// movdqa xmm4, xmm0
// movdqa xmm6, xmm2
// movdqa xmm4, xmm0
// movdqa xmm6, xmm2
//
// shufps xmm0, xmm1, 0x88
// shufps xmm2, xmm3, 0x88
// shufps xmm0, xmm1, 0x88
// shufps xmm2, xmm3, 0x88
//
// shufps xmm4, xmm1, 0xdd
// shufps xmm6, xmm3, 0xdd
// shufps xmm4, xmm1, 0xdd
// shufps xmm6, xmm3, 0xdd
//
// pshufd xmm0, xmm0, 0xd8
// pshufd xmm2, xmm2, 0xd8
// pshufd xmm4, xmm4, 0xd8
// pshufd xmm6, xmm6, 0xd8
// pshufd xmm0, xmm0, 0xd8
// pshufd xmm2, xmm2, 0xd8
// pshufd xmm4, xmm4, 0xd8
// pshufd xmm6, xmm6, 0xd8
//
// // left column
// movhlps xmm1, xmm0
// movlhps xmm0, xmm2
// //movdqa xmm7, [ecx]
// // left column
// movhlps xmm1, xmm0
// movlhps xmm0, xmm2
// //movdqa xmm7, [ecx]
//
// movdqa [ecx], xmm0
// shufps xmm1, xmm2, 0xe4
// movdqa [ecx+16], xmm1
// movdqa [ecx], xmm0
// shufps xmm1, xmm2, 0xe4
// movdqa [ecx+16], xmm1
//
// // right column
// movhlps xmm3, xmm4
// movlhps xmm4, xmm6
// movdqa [ecx+32], xmm4
// shufps xmm3, xmm6, 0xe4
// movdqa [ecx+48], xmm3
// // right column
// movhlps xmm3, xmm4
// movlhps xmm4, xmm6
// movdqa [ecx+32], xmm4
// shufps xmm3, xmm6, 0xe4
// movdqa [ecx+48], xmm3
//
// add eax, 16*4
// add ecx, 16*8
// sub edx, 1
// cmp edx, 0
// jne Extract32x2
// add eax, 16*4
// add ecx, 16*8
// sub edx, 1
// cmp edx, 0
// jne Extract32x2
// }
//}
@ -296,50 +296,50 @@ _FrameSwizzleBlock(A4_, (src[2*j]+src[2*j+1]+src[2*j+srcpitch]+src[2*j+srcpitch+
extern "C" void FASTCALL(WriteCLUT_T32_I8_CSM1_sse2(u32* vm, u32* clut))
{
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
for(int j = 0; j < 64; j += 32, src += 32, dst += 32)
{
for(int i = 0; i < 16; i += 4)
{
__m128i r0 = _mm_load_si128(&src[i+0]);
__m128i r1 = _mm_load_si128(&src[i+1]);
__m128i r2 = _mm_load_si128(&src[i+2]);
__m128i r3 = _mm_load_si128(&src[i+3]);
for(int j = 0; j < 64; j += 32, src += 32, dst += 32)
{
for(int i = 0; i < 16; i += 4)
{
__m128i r0 = _mm_load_si128(&src[i+0]);
__m128i r1 = _mm_load_si128(&src[i+1]);
__m128i r2 = _mm_load_si128(&src[i+2]);
__m128i r3 = _mm_load_si128(&src[i+3]);
_mm_store_si128(&dst[i*2+0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[i*2+1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[i*2+2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[i*2+3], _mm_unpackhi_epi64(r2, r3));
_mm_store_si128(&dst[i*2+0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[i*2+1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[i*2+2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[i*2+3], _mm_unpackhi_epi64(r2, r3));
__m128i r4 = _mm_load_si128(&src[i+0+16]);
__m128i r5 = _mm_load_si128(&src[i+1+16]);
__m128i r6 = _mm_load_si128(&src[i+2+16]);
__m128i r7 = _mm_load_si128(&src[i+3+16]);
__m128i r4 = _mm_load_si128(&src[i+0+16]);
__m128i r5 = _mm_load_si128(&src[i+1+16]);
__m128i r6 = _mm_load_si128(&src[i+2+16]);
__m128i r7 = _mm_load_si128(&src[i+3+16]);
_mm_store_si128(&dst[i*2+4], _mm_unpacklo_epi64(r4, r5));
_mm_store_si128(&dst[i*2+5], _mm_unpacklo_epi64(r6, r7));
_mm_store_si128(&dst[i*2+6], _mm_unpackhi_epi64(r4, r5));
_mm_store_si128(&dst[i*2+7], _mm_unpackhi_epi64(r6, r7));
}
}
_mm_store_si128(&dst[i*2+4], _mm_unpacklo_epi64(r4, r5));
_mm_store_si128(&dst[i*2+5], _mm_unpacklo_epi64(r6, r7));
_mm_store_si128(&dst[i*2+6], _mm_unpackhi_epi64(r4, r5));
_mm_store_si128(&dst[i*2+7], _mm_unpackhi_epi64(r6, r7));
}
}
}
extern "C" void FASTCALL(WriteCLUT_T32_I4_CSM1_sse2(u32* vm, u32* clut))
{
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i* src = (__m128i*)vm;
__m128i* dst = (__m128i*)clut;
__m128i r0 = _mm_load_si128(&src[0]);
__m128i r1 = _mm_load_si128(&src[1]);
__m128i r2 = _mm_load_si128(&src[2]);
__m128i r3 = _mm_load_si128(&src[3]);
__m128i r0 = _mm_load_si128(&src[0]);
__m128i r1 = _mm_load_si128(&src[1]);
__m128i r2 = _mm_load_si128(&src[2]);
__m128i r3 = _mm_load_si128(&src[3]);
_mm_store_si128(&dst[0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[3], _mm_unpackhi_epi64(r2, r3));
_mm_store_si128(&dst[0], _mm_unpacklo_epi64(r0, r1));
_mm_store_si128(&dst[1], _mm_unpacklo_epi64(r2, r3));
_mm_store_si128(&dst[2], _mm_unpackhi_epi64(r0, r1));
_mm_store_si128(&dst[3], _mm_unpackhi_epi64(r2, r3));
}
#endif
@ -348,124 +348,124 @@ extern "C" void FASTCALL(WriteCLUT_T32_I4_CSM1_sse2(u32* vm, u32* clut))
extern "C" {
PCSX2_ALIGNED16(int s_clut16mask2[4]) = { 0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff };
PCSX2_ALIGNED16(int s_clut16mask[8]) = { 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff};
0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff};
}
#if !defined(__x86_64__)
extern "C" void FASTCALL(WriteCLUT_T16_I4_CSM1_sse2(u32* vm, u32* clut))
{
__asm {
mov eax, vm
mov ecx, clut
movdqa xmm0, qword ptr [eax]
movdqa xmm1, qword ptr [eax+16]
movdqa xmm2, qword ptr [eax+32]
movdqa xmm3, qword ptr [eax+48]
__asm {
mov eax, vm
mov ecx, clut
movdqa xmm0, qword ptr [eax]
movdqa xmm1, qword ptr [eax+16]
movdqa xmm2, qword ptr [eax+32]
movdqa xmm3, qword ptr [eax+48]
// rearrange
pshuflw xmm0, xmm0, 0x88
pshufhw xmm0, xmm0, 0x88
pshuflw xmm1, xmm1, 0x88
pshufhw xmm1, xmm1, 0x88
pshuflw xmm2, xmm2, 0x88
pshufhw xmm2, xmm2, 0x88
pshuflw xmm3, xmm3, 0x88
pshufhw xmm3, xmm3, 0x88
// rearrange
pshuflw xmm0, xmm0, 0x88
pshufhw xmm0, xmm0, 0x88
pshuflw xmm1, xmm1, 0x88
pshufhw xmm1, xmm1, 0x88
pshuflw xmm2, xmm2, 0x88
pshufhw xmm2, xmm2, 0x88
pshuflw xmm3, xmm3, 0x88
pshufhw xmm3, xmm3, 0x88
shufps xmm0, xmm1, 0x88
shufps xmm2, xmm3, 0x88
shufps xmm0, xmm1, 0x88
shufps xmm2, xmm3, 0x88
pshufd xmm0, xmm0, 0xd8
pshufd xmm2, xmm2, 0xd8
pshufd xmm0, xmm0, 0xd8
pshufd xmm2, xmm2, 0xd8
pxor xmm6, xmm6
pxor xmm6, xmm6
test ecx, 15
jnz WriteUnaligned
test ecx, 15
jnz WriteUnaligned
movdqa xmm7, s_clut16mask // saves upper 16 bits
movdqa xmm7, s_clut16mask // saves upper 16 bits
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
pand xmm4, xmm7
pand xmm5, xmm7
pand xmm4, xmm7
pand xmm5, xmm7
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
por xmm0, xmm4
por xmm1, xmm5
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
por xmm0, xmm4
por xmm1, xmm5
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
por xmm2, xmm7
por xmm3, xmm5
por xmm2, xmm7
por xmm3, xmm5
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
jmp End
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
jmp End
WriteUnaligned:
// ecx is offset by 2
sub ecx, 2
// ecx is offset by 2
sub ecx, 2
movdqa xmm7, s_clut16mask2 // saves lower 16 bits
movdqa xmm7, s_clut16mask2 // saves lower 16 bits
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
// have to save interlaced with the old data
movdqa xmm4, [ecx]
movdqa xmm5, [ecx+32]
movhlps xmm1, xmm0
movlhps xmm0, xmm2 // lower 8 colors
pand xmm4, xmm7
pand xmm5, xmm7
pand xmm4, xmm7
pand xmm5, xmm7
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
shufps xmm1, xmm2, 0xe4 // upper 8 colors
movdqa xmm2, xmm0
movdqa xmm3, xmm1
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
pslld xmm0, 16
pslld xmm1, 16
por xmm0, xmm4
por xmm1, xmm5
punpcklwd xmm0, xmm6
punpcklwd xmm1, xmm6
pslld xmm0, 16
pslld xmm1, 16
por xmm0, xmm4
por xmm1, xmm5
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
pslld xmm2, 16
pslld xmm3, 16
punpckhwd xmm2, xmm6
punpckhwd xmm3, xmm6
pslld xmm2, 16
pslld xmm3, 16
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa [ecx], xmm0
movdqa [ecx+32], xmm1
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
movdqa xmm5, xmm7
pand xmm7, [ecx+16]
pand xmm5, [ecx+48]
por xmm2, xmm7
por xmm3, xmm5
por xmm2, xmm7
por xmm3, xmm5
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
movdqa [ecx+16], xmm2
movdqa [ecx+48], xmm3
End:
}
}
}
#endif // __x86_64__
#endif // _MSC_VER
@ -474,98 +474,98 @@ End:
void FASTCALL(WriteCLUT_T16_I8_CSM1_c(u32* _vm, u32* _clut))
{
const static u32 map[] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30,
1, 3, 9, 11, 17, 19, 25, 27,
5, 7, 13, 15, 21, 23, 29, 31
};
const static u32 map[] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30,
1, 3, 9, 11, 17, 19, 25, 27,
5, 7, 13, 15, 21, 23, 29, 31
};
u16* vm = (u16*)_vm;
u16* clut = (u16*)_clut;
u16* vm = (u16*)_vm;
u16* clut = (u16*)_clut;
int left = ((u32)(uptr)clut&2) ? 512 : 512-(((u32)(uptr)clut)&0x3ff)/2;
int left = ((u32)(uptr)clut&2) ? 512 : 512-(((u32)(uptr)clut)&0x3ff)/2;
for(int j = 0; j < 8; j++, vm += 32, clut += 64, left -= 32)
{
if(left == 32) {
assert( left == 32 );
for(int i = 0; i < 16; i++)
clut[2*i] = vm[map[i]];
for(int j = 0; j < 8; j++, vm += 32, clut += 64, left -= 32)
{
if(left == 32) {
assert( left == 32 );
for(int i = 0; i < 16; i++)
clut[2*i] = vm[map[i]];
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
for(int i = 16; i < 32; i++)
clut[2*i] = vm[map[i]];
}
else {
if( left == 0 ) {
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
left = -1;
}
for(int i = 16; i < 32; i++)
clut[2*i] = vm[map[i]];
}
else {
if( left == 0 ) {
clut = (u16*)((uptr)clut & ~0x3ff) + 1;
left = -1;
}
for(int i = 0; i < 32; i++)
clut[2*i] = vm[map[i]];
}
}
for(int i = 0; i < 32; i++)
clut[2*i] = vm[map[i]];
}
}
}
void FASTCALL(WriteCLUT_T32_I8_CSM1_c(u32* vm, u32* clut))
{
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
for(int j = 0; j < 2; j++, src += 32) {
for(int i = 0; i < 4; i++, dst+=16, src+=8)
{
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
for(int j = 0; j < 2; j++, src += 32) {
for(int i = 0; i < 4; i++, dst+=16, src+=8)
{
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
dst[8] = src[32];
dst[9] = src[32+2];
dst[10] = src[32+4];
dst[11] = src[32+6];
dst[12] = src[32+1];
dst[13] = src[32+3];
dst[14] = src[32+5];
dst[15] = src[32+7];
}
}
dst[8] = src[32];
dst[9] = src[32+2];
dst[10] = src[32+4];
dst[11] = src[32+6];
dst[12] = src[32+1];
dst[13] = src[32+3];
dst[14] = src[32+5];
dst[15] = src[32+7];
}
}
}
void FASTCALL(WriteCLUT_T16_I4_CSM1_c(u32* _vm, u32* _clut))
{
u16* dst = (u16*)_clut;
u16* src = (u16*)_vm;
u16* dst = (u16*)_clut;
u16* src = (u16*)_vm;
dst[0] = src[0]; dst[2] = src[2];
dst[4] = src[8]; dst[6] = src[10];
dst[8] = src[16]; dst[10] = src[18];
dst[12] = src[24]; dst[14] = src[26];
dst[16] = src[4]; dst[18] = src[6];
dst[20] = src[12]; dst[22] = src[14];
dst[24] = src[20]; dst[26] = src[22];
dst[28] = src[28]; dst[30] = src[30];
dst[0] = src[0]; dst[2] = src[2];
dst[4] = src[8]; dst[6] = src[10];
dst[8] = src[16]; dst[10] = src[18];
dst[12] = src[24]; dst[14] = src[26];
dst[16] = src[4]; dst[18] = src[6];
dst[20] = src[12]; dst[22] = src[14];
dst[24] = src[20]; dst[26] = src[22];
dst[28] = src[28]; dst[30] = src[30];
}
void FASTCALL(WriteCLUT_T32_I4_CSM1_c(u32* vm, u32* clut))
{
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
u64* src = (u64*)vm;
u64* dst = (u64*)clut;
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
dst[0] = src[0];
dst[1] = src[2];
dst[2] = src[4];
dst[3] = src[6];
dst[4] = src[1];
dst[5] = src[3];
dst[6] = src[5];
dst[7] = src[7];
}

File diff suppressed because it is too large Load Diff

View File

@ -91,24 +91,24 @@ using namespace std;
// sets the data stream
#define SET_STREAM() { \
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8); \
glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12); \
glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16); \
glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); \
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8); \
glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12); \
glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16); \
glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); \
}
#define SETVERTEXSHADER(prog) { \
if( (prog) != g_vsprog ) { \
cgGLBindProgram(prog); \
g_vsprog = prog; \
} \
if( (prog) != g_vsprog ) { \
cgGLBindProgram(prog); \
g_vsprog = prog; \
} \
} \
#define SETPIXELSHADER(prog) { \
if( (prog) != g_psprog ) { \
cgGLBindProgram(prog); \
g_psprog = prog; \
} \
if( (prog) != g_psprog ) { \
cgGLBindProgram(prog); \
g_psprog = prog; \
} \
} \
#ifndef ARRAY_SIZE
@ -125,25 +125,25 @@ extern CGprogram g_vsprog, g_psprog;
struct FRAGMENTSHADER
{
FRAGMENTSHADER() : prog(0), sMemory(0), sFinal(0), sBitwiseANDX(0), sBitwiseANDY(0), sInterlace(0), sCLUT(0), sOneColor(0), sBitBltZ(0),
fTexAlpha2(0), fTexOffset(0), fTexDims(0), fTexBlock(0), fClampExts(0), fTexWrapMode(0),
fRealTexDims(0), fTestBlack(0), fPageOffset(0), fTexAlpha(0) {}
CGprogram prog;
CGparameter sMemory, sFinal, sBitwiseANDX, sBitwiseANDY, sCLUT, sInterlace;
CGparameter sOneColor, sBitBltZ, sInvTexDims;
CGparameter fTexAlpha2, fTexOffset, fTexDims, fTexBlock, fClampExts, fTexWrapMode, fRealTexDims, fTestBlack, fPageOffset, fTexAlpha;
FRAGMENTSHADER() : prog(0), sMemory(0), sFinal(0), sBitwiseANDX(0), sBitwiseANDY(0), sInterlace(0), sCLUT(0), sOneColor(0), sBitBltZ(0),
fTexAlpha2(0), fTexOffset(0), fTexDims(0), fTexBlock(0), fClampExts(0), fTexWrapMode(0),
fRealTexDims(0), fTestBlack(0), fPageOffset(0), fTexAlpha(0) {}
CGprogram prog;
CGparameter sMemory, sFinal, sBitwiseANDX, sBitwiseANDY, sCLUT, sInterlace;
CGparameter sOneColor, sBitBltZ, sInvTexDims;
CGparameter fTexAlpha2, fTexOffset, fTexDims, fTexBlock, fClampExts, fTexWrapMode, fRealTexDims, fTestBlack, fPageOffset, fTexAlpha;
#ifdef _DEBUG
string filename;
string filename;
#endif
};
struct VERTEXSHADER
{
VERTEXSHADER() : prog(0), sBitBltPos(0), sBitBltTex(0) {}
CGprogram prog;
CGparameter sBitBltPos, sBitBltTex, fBitBltTrans; // vertex shader constants
VERTEXSHADER() : prog(0), sBitBltPos(0), sBitBltTex(0) {}
CGprogram prog;
CGparameter sBitBltPos, sBitBltTex, fBitBltTrans; // vertex shader constants
};
// don't change these values!
@ -159,8 +159,8 @@ struct VERTEXSHADER
#define GAME_QUICKRESOLVE1 0x0400
#define GAME_NOQUICKRESOLVE 0x0800
#define GAME_NOTARGETCLUT 0x1000 // full 16 bit resolution
#define GAME_NOSTENCIL 0x2000
#define GAME_VSSHACKOFF 0x4000 // vertical stripe syndrome
#define GAME_NOSTENCIL 0x2000
#define GAME_VSSHACKOFF 0x4000 // vertical stripe syndrome
#define GAME_NODEPTHRESOLVE 0x8000
#define GAME_FULL16BITRES 0x00010000
#define GAME_RESOLVEPROMOTED 0x00020000
@ -170,7 +170,7 @@ struct VERTEXSHADER
#define GAME_32BITTARGS 0x00200000
#define GAME_PATH3HACK 0x00400000
#define GAME_DOPARALLELCTX 0x00800000 // tries to parallelize both contexts so that render calls are reduced (xenosaga)
// makes the game faster, but can be buggy
// makes the game faster, but can be buggy
#define GAME_XENOSPECHACK 0x01000000 // xenosaga specularity hack (ignore any zmask=1 draws)
#define GAME_PARTIALPOINTERS 0x02000000 // whenver the texture or render target are small, tries to look for bigger ones to read from
#define GAME_PARTIALDEPTH 0x04000000 // tries to save depth targets as much as possible across height changes
@ -187,8 +187,8 @@ namespace ZeroGS {
enum RenderFormatType
{
RFT_byte8 = 0, // A8R8G8B8
RFT_float16 = 1, // A32R32B32G32
RFT_byte8 = 0, // A8R8G8B8
RFT_float16 = 1, // A32R32B32G32
};
// managers render-to-texture targets
@ -271,9 +271,9 @@ namespace ZeroGS {
void SetDepthStencilSurface();
u32 pdepth; // 24 bit, will contain the stencil buffer if possible
u32 pstencil; // if not 0, contains the stencil buffer
int icount; // internal counter
u32 pdepth; // 24 bit, will contain the stencil buffer if possible
u32 pstencil; // if not 0, contains the stencil buffer
int icount; // internal counter
};
// manages contiguous chunks of memory (width is always 1024)
@ -374,29 +374,29 @@ namespace ZeroGS {
public:
void FlushTexData();
// notify VB that nVerts need to be written to pbuf
inline void NotifyWrite(int nVerts) {
assert( pBufferData != NULL && nCount <= nNumVertices && nVerts > 0 );
// notify VB that nVerts need to be written to pbuf
inline void NotifyWrite(int nVerts) {
assert( pBufferData != NULL && nCount <= nNumVertices && nVerts > 0 );
if( nCount + nVerts > nNumVertices ) {
// recreate except with a bigger count
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU)*nNumVertices*2, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
nNumVertices *= 2;
assert( nCount + nVerts <= nNumVertices );
_aligned_free(pBufferData);
pBufferData = ptemp;
}
}
if( nCount + nVerts > nNumVertices ) {
// recreate except with a bigger count
VertexGPU* ptemp = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU)*nNumVertices*2, 256);
memcpy_amd(ptemp, pBufferData, sizeof(VertexGPU) * nCount);
nNumVertices *= 2;
assert( nCount + nVerts <= nNumVertices );
_aligned_free(pBufferData);
pBufferData = ptemp;
}
}
void Init(int nVerts) {
if( pBufferData == NULL && nVerts > 0 ) {
pBufferData = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU)*nVerts, 256);
nNumVertices = nVerts;
}
void Init(int nVerts) {
if( pBufferData == NULL && nVerts > 0 ) {
pBufferData = (VertexGPU*)_aligned_malloc(sizeof(VertexGPU)*nVerts, 256);
nNumVertices = nVerts;
}
nCount = 0;
}
nCount = 0;
}
u8 bNeedFrameCheck;
u8 bNeedZCheck;
@ -416,7 +416,7 @@ namespace ZeroGS {
int ictx;
VertexGPU* pBufferData; // current allocated data
int nNumVertices; // size of pBufferData in terms of VertexGPU objects
int nNumVertices; // size of pBufferData in terms of VertexGPU objects
int nCount;
primInfo curprim; // the previous prim the current buffers are set to
@ -432,9 +432,9 @@ namespace ZeroGS {
int nNextFrameHeight;
CMemoryTarget* pmemtarg; // the current mem target set
CRenderTarget* prndr;
CRenderTarget* prndr;
CDepthTarget* pdepth;
};
};
// visible members
extern DrawFn drawfn[8];
@ -442,7 +442,7 @@ namespace ZeroGS {
extern float fiTexWidth[2], fiTexHeight[2]; // current tex width and height
void AddMessage(const char* pstr, u32 ms = 5000);
void DrawText(const char* pstr, int left, int top, u32 color);
void DrawText(const char* pstr, int left, int top, u32 color);
void ChangeWindowSize(int nNewWidth, int nNewHeight);
void SetChangeDeviceSize(int nNewWidth, int nNewHeight);
void ChangeDeviceSize(int nNewWidth, int nNewHeight);
@ -452,7 +452,7 @@ namespace ZeroGS {
void ReloadEffects();
// Methods //
bool IsGLExt( const char* szTargetExtension ); ///< returns true if the the opengl extension is supported
bool IsGLExt( const char* szTargetExtension ); ///< returns true if the the opengl extension is supported
bool Create(int width, int height);
void Destroy(BOOL bD3D);
@ -460,7 +460,7 @@ namespace ZeroGS {
void Reset(); // call to destroy video resources
void GSStateReset();
void HandleGLError();
void HandleGLError();
// called on a primitive switch
void Prim();
@ -493,23 +493,23 @@ namespace ZeroGS {
// switches the render target to the real target, flushes the current render targets and renders the real image
void RenderCRTC(int interlace);
void ResetRenderTarget(int index);
void ResetRenderTarget(int index);
bool CheckChangeInClut(u32 highdword, u32 psm); // returns true if clut will change after this tex0 op
// call to load CLUT data (depending on CLD)
void texClutWrite(int ctx);
RenderFormatType GetRenderFormat();
GLenum GetRenderTargetFormat();
RenderFormatType GetRenderFormat();
GLenum GetRenderTargetFormat();
int Save(char* pbydata);
bool Load(char* pbydata);
void SaveSnapshot(const char* filename);
bool SaveRenderTarget(const char* filename, int width, int height, int jpeg);
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height);
bool SaveJPEG(const char* filename, int width, int height, const void* pdata, int quality);
bool SaveTGA(const char* filename, int width, int height, void* pdata);
bool SaveRenderTarget(const char* filename, int width, int height, int jpeg);
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height);
bool SaveJPEG(const char* filename, int width, int height, const void* pdata, int quality);
bool SaveTGA(const char* filename, int width, int height, void* pdata);
// private methods
void FlushSysMem(const RECT* prc);

View File

@ -37,89 +37,89 @@ inline dReal* inv4(const dReal* pf, dReal* pfres);
class Vector
{
public:
dReal x, y, z, w;
dReal x, y, z, w;
Vector() : x(0), y(0), z(0), w(0) {}
Vector(dReal x, dReal y, dReal z) : x(x), y(y), z(z), w(0) {}
Vector(dReal x, dReal y, dReal z, dReal w) : x(x), y(y), z(z), w(w) {}
Vector(const Vector &vec) : x(vec.x), y(vec.y), z(vec.z), w(vec.w) {}
Vector(const dReal* pf) { assert(pf != NULL); x = pf[0]; y = pf[1]; z = pf[2]; w = 0; }
Vector() : x(0), y(0), z(0), w(0) {}
Vector(dReal x, dReal y, dReal z) : x(x), y(y), z(z), w(0) {}
Vector(dReal x, dReal y, dReal z, dReal w) : x(x), y(y), z(z), w(w) {}
Vector(const Vector &vec) : x(vec.x), y(vec.y), z(vec.z), w(vec.w) {}
Vector(const dReal* pf) { assert(pf != NULL); x = pf[0]; y = pf[1]; z = pf[2]; w = 0; }
dReal operator[](int i) const { return (&x)[i]; }
dReal& operator[](int i) { return (&x)[i]; }
dReal operator[](int i) const { return (&x)[i]; }
dReal& operator[](int i) { return (&x)[i]; }
// casting operators
operator dReal* () { return &x; }
operator const dReal* () const { return (const dReal*)&x; }
// casting operators
operator dReal* () { return &x; }
operator const dReal* () const { return (const dReal*)&x; }
// SCALAR FUNCTIONS
inline dReal dot(const Vector &v) const { return x*v.x + y*v.y + z*v.z + w*v.w; }
inline void normalize() { normalize4(&x, &x); }
// SCALAR FUNCTIONS
inline dReal dot(const Vector &v) const { return x*v.x + y*v.y + z*v.z + w*v.w; }
inline void normalize() { normalize4(&x, &x); }
inline void Set3(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; }
inline void Set4(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; w = pvals[3]; }
inline void Set3(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; }
inline void Set4(const float* pvals) { x = pvals[0]; y = pvals[1]; z = pvals[2]; w = pvals[3]; }
// 3 dim cross product, w is not touched
/// this = this x v
inline void Cross(const Vector &v) { cross3(&x, &x, v); }
// 3 dim cross product, w is not touched
/// this = this x v
inline void Cross(const Vector &v) { cross3(&x, &x, v); }
/// this = u x v
inline void Cross(const Vector &u, const Vector &v) { cross3(&x, u, v); }
/// this = u x v
inline void Cross(const Vector &u, const Vector &v) { cross3(&x, u, v); }
inline Vector operator-() const { Vector v; v.x = -x; v.y = -y; v.z = -z; v.w = -w; return v; }
inline Vector operator+(const Vector &r) const { Vector v; v.x = x+r.x; v.y = y+r.y; v.z = z+r.z; v.w = w+r.w; return v; }
inline Vector operator-(const Vector &r) const { Vector v; v.x = x-r.x; v.y = y-r.y; v.z = z-r.z; v.w = w-r.w; return v; }
inline Vector operator*(const Vector &r) const { Vector v; v.x = r.x*x; v.y = r.y*y; v.z = r.z*z; v.w = r.w*w; return v; }
inline Vector operator*(dReal k) const { Vector v; v.x = k*x; v.y = k*y; v.z = k*z; v.w = k*w; return v; }
inline Vector operator-() const { Vector v; v.x = -x; v.y = -y; v.z = -z; v.w = -w; return v; }
inline Vector operator+(const Vector &r) const { Vector v; v.x = x+r.x; v.y = y+r.y; v.z = z+r.z; v.w = w+r.w; return v; }
inline Vector operator-(const Vector &r) const { Vector v; v.x = x-r.x; v.y = y-r.y; v.z = z-r.z; v.w = w-r.w; return v; }
inline Vector operator*(const Vector &r) const { Vector v; v.x = r.x*x; v.y = r.y*y; v.z = r.z*z; v.w = r.w*w; return v; }
inline Vector operator*(dReal k) const { Vector v; v.x = k*x; v.y = k*y; v.z = k*z; v.w = k*w; return v; }
inline Vector& operator += (const Vector& r) { x += r.x; y += r.y; z += r.z; w += r.w; return *this; }
inline Vector& operator -= (const Vector& r) { x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; }
inline Vector& operator *= (const Vector& r) { x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; }
inline Vector& operator *= (const dReal k) { x *= k; y *= k; z *= k; w *= k; return *this; }
inline Vector& operator /= (const dReal _k) { dReal k=1/_k; x *= k; y *= k; z *= k; w *= k; return *this; }
inline Vector& operator += (const Vector& r) { x += r.x; y += r.y; z += r.z; w += r.w; return *this; }
inline Vector& operator -= (const Vector& r) { x -= r.x; y -= r.y; z -= r.z; w -= r.w; return *this; }
inline Vector& operator *= (const Vector& r) { x *= r.x; y *= r.y; z *= r.z; w *= r.w; return *this; }
inline Vector& operator *= (const dReal k) { x *= k; y *= k; z *= k; w *= k; return *this; }
inline Vector& operator /= (const dReal _k) { dReal k=1/_k; x *= k; y *= k; z *= k; w *= k; return *this; }
friend Vector operator* (float f, const Vector& v);
//friend ostream& operator<<(ostream& O, const Vector& v);
//friend istream& operator>>(istream& I, Vector& v);
friend Vector operator* (float f, const Vector& v);
//friend ostream& operator<<(ostream& O, const Vector& v);
//friend istream& operator>>(istream& I, Vector& v);
};
inline Vector operator* (float f, const Vector& left)
{
Vector v;
v.x = f * left.x;
v.y = f * left.y;
v.z = f * left.z;
return v;
Vector v;
v.x = f * left.x;
v.y = f * left.y;
v.z = f * left.z;
return v;
}
struct AABB
{
Vector pos, extents;
Vector pos, extents;
};
struct OBB
{
Vector right, up, dir, pos, extents;
Vector right, up, dir, pos, extents;
};
struct TRIANGLE
{
TRIANGLE() {}
TRIANGLE(const Vector& v1, const Vector& v2, const Vector& v3) : v1(v1), v2(v2), v3(v3) {}
~TRIANGLE() {}
TRIANGLE() {}
TRIANGLE(const Vector& v1, const Vector& v2, const Vector& v3) : v1(v1), v2(v2), v3(v3) {}
~TRIANGLE() {}
Vector v1, v2, v3; //!< the vertices of the triangle
Vector v1, v2, v3; //!< the vertices of the triangle
const Vector& operator[](int i) const { return (&v1)[i]; }
Vector& operator[](int i) { return (&v1)[i]; }
const Vector& operator[](int i) const { return (&v1)[i]; }
Vector& operator[](int i) { return (&v1)[i]; }
/// assumes CCW ordering of vertices
inline Vector ComputeNormal() {
Vector normal;
cross3(normal, v2-v1, v3-v1);
return normal;
}
/// assumes CCW ordering of vertices
inline Vector ComputeNormal() {
Vector normal;
cross3(normal, v2-v1, v3-v1);
return normal;
}
};
// Routines made for 3D graphics that deal with 3 or 4 dim algebra structures
@ -624,13 +624,13 @@ inline dReal* cross3(dReal* pfout, const dReal* pf1, const dReal* pf2)
{
assert( pfout != NULL && pf1 != NULL && pf2 != NULL );
dReal temp[3];
dReal temp[3];
temp[0] = pf1[1] * pf2[2] - pf1[2] * pf2[1];
temp[1] = pf1[2] * pf2[0] - pf1[0] * pf2[2];
temp[2] = pf1[0] * pf2[1] - pf1[1] * pf2[0];
pfout[0] = temp[0]; pfout[1] = temp[1]; pfout[2] = temp[2];
return pfout;
return pfout;
}
template <class T> inline void mult(T* pf, T fa, int r)
@ -724,7 +724,7 @@ inline T* multtrans_to2(T* pf1, R* pf2, int r1, int c1, int r2, S* pfres, bool b
}
pf1 += c1;
pfres += r2;
pfres += r2;
}
return pfres;

View File

@ -15,101 +15,101 @@ int inf(char *src, char *dst, int bytes_to_decompress, int maximum_after_decompr
int def(char *src, char *dst, int bytes_to_compress, int *bytes_after_compressed)
{
z_stream strm;
z_stream strm;
int ret;//, flush;
unsigned have;
int ret;//, flush;
unsigned have;
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION) ;
if (ret != Z_OK)
return ret;
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION) ;
if (ret != Z_OK)
return ret;
/* compress */
strm.avail_in = bytes_to_compress ;
strm.avail_out = bytes_to_compress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
/* compress */
strm.avail_in = bytes_to_compress ;
strm.avail_out = bytes_to_compress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
ret = deflate(&strm, Z_FINISH) ;
have = bytes_to_compress - strm.avail_out ;
*bytes_after_compressed = have ;
assert(ret == Z_STREAM_END); /* stream will be complete */
ret = deflate(&strm, Z_FINISH) ;
have = bytes_to_compress - strm.avail_out ;
*bytes_after_compressed = have ;
assert(ret == Z_STREAM_END); /* stream will be complete */
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
/* clean up and return */
(void)deflateEnd(&strm);
return Z_OK;
}
int inf(char *src, char *dst, int bytes_to_decompress, int maximum_after_decompress, int* outbytes)
{
z_stream strm;
z_stream strm;
int ret;
//unsigned have;
int ret;
//unsigned have;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* allocate inflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = 0;
strm.next_in = Z_NULL;
ret = inflateInit(&strm);
if (ret != Z_OK)
return ret;
/* decompress */
strm.avail_in = bytes_to_decompress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
/* decompress */
strm.avail_in = bytes_to_decompress ;
strm.next_in = (Bytef *)src ;
strm.next_out = (Bytef *)dst ;
strm.avail_out = maximum_after_decompress ;
ret = inflate(&strm, Z_NO_FLUSH) ;
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
assert(strm.avail_in == 0); /* all input will be used */
ret = inflate(&strm, Z_NO_FLUSH) ;
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
switch (ret) {
case Z_NEED_DICT:
ret = Z_DATA_ERROR; /* and fall through */
case Z_DATA_ERROR:
case Z_MEM_ERROR:
(void)inflateEnd(&strm);
return ret;
}
assert(strm.avail_in == 0); /* all input will be used */
if( outbytes != NULL )
*outbytes = strm.total_out;
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
/* clean up and return */
(void)inflateEnd(&strm);
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
/* report a zlib or i/o error */
void zerr(int ret)
{
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
fputs("zpipe: ", stderr);
switch (ret) {
case Z_ERRNO:
if (ferror(stdin))
fputs("error reading stdin\n", stderr);
if (ferror(stdout))
fputs("error writing stdout\n", stderr);
break;
case Z_STREAM_ERROR:
fputs("invalid compression level\n", stderr);
break;
case Z_DATA_ERROR:
fputs("invalid or incomplete deflate data\n", stderr);
break;
case Z_MEM_ERROR:
fputs("out of memory\n", stderr);
break;
case Z_VERSION_ERROR:
fputs("zlib version mismatch!\n", stderr);
}
}