GSnull: Update the GifTransfer code. Start to add keyboard code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1234 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-21 22:19:54 +00:00
parent 7922f33f4f
commit b1fd826954
7 changed files with 177 additions and 53 deletions

View File

@ -27,6 +27,7 @@
using namespace std;
#include "GS.h"
#include "null/GSnull.h"
#ifdef __LINUX__
Display *display;
@ -43,6 +44,9 @@ const unsigned char build = 1; // increase that with each version
static char *libraryName = "GSnull Driver";
FILE *gsLog;
Config conf;
u32 GSKeyEvent = 0;
bool GSShift = false, GSAlt = false;
string s_strIniPath="inis/GSnull.ini";
void (*GSirq)();
@ -168,9 +172,37 @@ EXPORT_C_(s32) GStest()
return 0;
}
void ProcessMessages()
{
#ifdef __LINUX__
if ( GSKeyEvent )
{
int myKeyEvent = GSKeyEvent;
bool myShift = GSShift;
GSKeyEvent = 0;
switch ( myKeyEvent )
{
case XK_F5:
OnKeyboardF5(myShift);
break;
case XK_F6:
OnKeyboardF6(myShift);
break;
case XK_F7:
OnKeyboardF7(myShift);
break;
case XK_F9:
OnKeyboardF9(myShift);
break;
}
}
#endif
}
EXPORT_C_(void) GSvsync(int field)
{
ProcessMessages();
}
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr)
@ -211,7 +243,41 @@ EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc)
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
EXPORT_C_(void) GSkeyEvent(keyEvent *ev)
{
//SysPrintf("There is a key event.\n");
switch(ev->evt) {
case KEYPRESS:
switch(ev->key) {
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F9:
GSKeyEvent = ev->key ;
break;
case XK_Escape:
break;
case XK_Shift_L:
case XK_Shift_R:
//bShift = true;
GSShift = true;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = true;
break;
}
break;
case KEYRELEASE:
switch(ev->key) {
case XK_Shift_L:
case XK_Shift_R:
//bShift = false;
GSShift = false;
break;
case XK_Alt_L:
case XK_Alt_R:
GSAlt = false;
break;
}
}
}
EXPORT_C_(void) GSchangeSaveState(int, const char* filename)

View File

@ -103,14 +103,24 @@ u32 GIFPath::GetReg()
return regs[curreg];
}
__forceinline u32 _gifTransfer( GIF_PATH pathidx, const u8* pMem, u32 size )
__forceinline bool GIFPath::StepReg()
{
GIFPath& path = m_path[pathidx];
if ((++curreg & 0xf) == tag.nreg)
{
curreg = 0;
if(--tag.nloop == 0)
{
return false;
}
}
}
__forceinline u32 _gifTransfer( GIF_PATH pathidx, const u8* pMem, u32 size )
{ GIFPath& path = m_path[pathidx];
while(size > 0)
{
bool eop = false;
if(path.tag.nloop == 0)
{
path.SetTag( pMem );
@ -119,14 +129,16 @@ __forceinline u32 _gifTransfer( GIF_PATH pathidx, const u8* pMem, u32 size )
--size;
if(pathidx == 2 && path.tag.eop)
{
Path3transfer = FALSE;
}
if( pathidx == 0 )
{
// hack: if too much data for VU1, just ignore.
// The GIF is evil : if nreg is 0, it's really 16. Otherwise it's the value in nreg.
const int numregs = ((path.tag.nreg - 1) & 15) + 1;
const int numregs = ((path.tag.nreg-1)&15)+1;
if((path.tag.nloop * numregs) > (size * ((path.tag.flg == 1) ? 2 : 1)))
{
@ -134,74 +146,48 @@ __forceinline u32 _gifTransfer( GIF_PATH pathidx, const u8* pMem, u32 size )
return ++size;
}
}
if(path.tag.eop)
{
eop = true;
}
else if(path.tag.nloop == 0)
else
{
if(pathidx == 0)
continue;
// NOTE: size > 0 => do {} while(size > 0); should be faster than while(size > 0) {}
eop = true;
}
}
if(path.tag.nloop > 0)
{
switch(path.tag.flg)
{
case GIF_FLG_PACKED:
while(size > 0)
do
{
if( path.GetReg() == 0xe )
{
const int handler = pMem[8];
if(handler >= 0x60 && handler < 0x63)
s_GSHandlers[handler & 0x3]((const u32*)pMem);
s_GSHandlers[handler&0x3]((const u32*)pMem);
}
size--;
pMem += 16; // 128 bits! //sizeof(GIFPackedReg);
if((++path.curreg & 0xf) == path.tag.nreg)
{
path.curreg = 0;
path.tag.nloop--;
if(path.tag.nloop == 0)
break;
}
}
while(path.StepReg() && size > 0);
break;
case GIF_FLG_REGLIST:
size *= 2;
while(size > 0)
do
{
const int handler = path.GetReg();
if (handler >= 0x60 && handler < 0x63)
if(handler >= 0x60 && handler < 0x63)
s_GSHandlers[handler&0x3]((const u32*)pMem);
size--;
pMem += 8; //sizeof(GIFReg); -- 64 bits!
if((++path.curreg & 0xf) == path.tag.nreg)
{
path.curreg = 0;
path.tag.nloop--;
if(path.tag.nloop == 0)
{
break;
}
}
}
while(path.StepReg() && size > 0);
if(size & 1) pMem += 8; //sizeof(GIFReg);
if (size & 1) pMem += 8; //sizeof(GIFReg);
size /= 2;
break;
@ -227,23 +213,27 @@ __forceinline u32 _gifTransfer( GIF_PATH pathidx, const u8* pMem, u32 size )
}
}
if (eop && ((int)size <= 0 || pathidx == 0))
if(pathidx == 0)
{
if(path.tag.eop && path.tag.nloop == 0)
{
break;
}
}
}
if(pathidx == 0)
{
if (!path.tag.eop && path.tag.nloop > 0)
if(size == 0 && path.tag.nloop > 0)
{
path.tag.nloop = 0;
SysPrintf( "path1 hack! " );
SysPrintf( "path1 hack! \n" );
// This means that the giftag data got screwly somewhere
// along the way (often means curreg was in a bad state or something)
}
}
return size;
}

View File

@ -85,6 +85,7 @@ struct GIFPath
__forceinline void PrepRegs();
void SetTag(const void* mem);
u32 GetReg();
__forceinline bool StepReg();
};
extern GIFPath m_path[3];

View File

@ -29,7 +29,5 @@ libGSnull_a_SOURCES += \
Linux/interface.h Linux/support.c \
Linux/interface.c Linux/support.h \
Linux/callbacks.h \
GifTransfer.cpp GifTransfer.h
#Linux/callbacks.c
#SUBDIRS = Linux
GifTransfer.cpp GifTransfer.h \
null/GSnull.cpp null/GSnull.h

View File

@ -164,6 +164,10 @@
RelativePath="..\GS.cpp"
>
</File>
<File
RelativePath="..\null\GSnull.cpp"
>
</File>
<File
RelativePath="..\GifTransfer.cpp"
>
@ -185,6 +189,10 @@
RelativePath="..\GifTransfer.h"
>
</File>
<File
RelativePath="..\null\GSnull.h"
>
</File>
<File
RelativePath=".\resource.h"
>

View File

@ -0,0 +1,39 @@
/* GSnull
* Copyright (C) 2004-2009 PCSX2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "GS.h"
void OnKeyboardF5(int myShift)
{
SysPrintf("F5 pressed!\n");
}
void OnKeyboardF6(int myShift)
{
SysPrintf("F6 pressed!\n");
}
void OnKeyboardF7(int myShift)
{
SysPrintf("F7 pressed!\n");
}
void OnKeyboardF9(int myShift)
{
SysPrintf("F9 pressed!\n");
}

View File

@ -0,0 +1,22 @@
/* GSnull
* Copyright (C) 2004-2009 PCSX2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
extern void OnKeyboardF5(int myShift);
extern void OnKeyboardF6(int myShift);
extern void OnKeyboardF7(int myShift);
extern void OnKeyboardF9(int myShift);