summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-05-16 16:17:19 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-05-16 16:17:19 +0100
commita64d62be4b433fcad3804d3bb616bdf4f13504f4 (patch)
treea149e7e9795065735e4e3966b3b0078b60caeb9b
parent1e37eec079558337768c4487fcd0fdd80ea8b005 (diff)
downloadpcsxr-a64d62be4b433fcad3804d3bb616bdf4f13504f4.tar.gz
Add PGXP configuration dialog
- Allows independent toggling of PGXP, vertex caching and texture correction
-rw-r--r--libpcsxcore/pgxp_gte.c10
-rwxr-xr-xlibpcsxcore/psxcommon.h4
-rw-r--r--plugins/peopsxgl/pgxp_gpu.c38
-rwxr-xr-xwin32/gui/ConfigurePlugins.c9
-rwxr-xr-xwin32/gui/Win32.h1
-rwxr-xr-xwin32/gui/WndMain.c53
-rwxr-xr-xwin32/pcsxr.rc27
-rwxr-xr-xwin32/resource.h10
8 files changed, 131 insertions, 21 deletions
diff --git a/libpcsxcore/pgxp_gte.c b/libpcsxcore/pgxp_gte.c
index 4334c38d..c130d32c 100644
--- a/libpcsxcore/pgxp_gte.c
+++ b/libpcsxcore/pgxp_gte.c
@@ -26,6 +26,7 @@
***************************************************************************/
#include "pgxp_gte.h"
+#include "psxcommon.h"
#include "psxmem.h"
#include "r3000a.h"
@@ -72,7 +73,7 @@ void PGXP_Init()
char* PGXP_GetMem()
{
- return (char*)(Mem);
+ return Config.PGXP_GTE ? (char*)(Mem) : NULL;
}
/* Playstation Memory Map (from Playstation doc by Joshua Walker)
@@ -266,14 +267,17 @@ void PGXP_pushSXYZ2f(float _x, float _y, float _z, unsigned int _v)
SXY2.x = _x;
SXY2.y = _y;
- SXY2.z = _z;
+ SXY2.z = Config.PGXP_Texture ? _z : 1.f;
SXY2.value = _v;
SXY2.valid = 1;
SXY2.count = uCount++;
// cache value in GPU plugin
temp.word = _v;
- GPU_pgxpCacheVertex(temp.x, temp.y, &SXY2);
+ if(Config.PGXP_Cache)
+ GPU_pgxpCacheVertex(temp.x, temp.y, &SXY2);
+ else
+ GPU_pgxpCacheVertex(0, 0, NULL);
#ifdef GTE_LOG
GTE_LOG("PGPR_PUSH (%f, %f) %u %u|", SXY2.x, SXY2.y, SXY2.valid, SXY2.count);
diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h
index 13e6c1ab..894b1a31 100755
--- a/libpcsxcore/psxcommon.h
+++ b/libpcsxcore/psxcommon.h
@@ -167,6 +167,10 @@ typedef struct {
u8 MemHack;
boolean OverClock; // enable overclocking
u8 PsxClock;
+ // PGXP variables
+ boolean PGXP_GTE;
+ boolean PGXP_Cache;
+ boolean PGXP_Texture;
#ifdef _WIN32
char Lang[256];
#endif
diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c
index 5cb5d5b3..091b161b 100644
--- a/plugins/peopsxgl/pgxp_gpu.c
+++ b/plugins/peopsxgl/pgxp_gpu.c
@@ -47,6 +47,7 @@ typedef struct
const unsigned int mode_init = 0;
const unsigned int mode_write = 1;
const unsigned int mode_read = 2;
+const unsigned int mode_fail = 3;
PGXP_vertex vertexCache[0x800 * 2][0x800 * 2];
@@ -77,7 +78,10 @@ void CALLBACK GPUpgxpCacheVertex(short sx, short sy, const unsigned char* _pVert
PGXP_vertex* pOldVertex = NULL;
if (!pNewVertex)
+ {
+ cacheMode = mode_fail;
return;
+ }
//if (bGteAccuracy)
{
@@ -124,6 +128,9 @@ PGXP_vertex* PGXP_GetCachedVertex(short sx, short sy)
{
if (cacheMode != mode_read)
{
+ if (cacheMode == mode_fail)
+ return NULL;
+
// Initialise cache on first use
if (cacheMode == mode_init)
memset(vertexCache, 0x00, sizeof(vertexCache));
@@ -160,8 +167,7 @@ unsigned int vertexIdx = 0;
// Set current DMA address and pointer to parallel memory
void CALLBACK GPUpgxpMemory(unsigned int addr, unsigned char* pVRAM)
{
- if (pVRAM)
- PGXP_Mem = (PGXP_vertex*)(pVRAM);
+ PGXP_Mem = (PGXP_vertex*)(pVRAM);
currentAddr = addr;
}
@@ -245,30 +251,32 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
PGXP_vertex* primStart = NULL; // pointer to first vertex
char invalidVert = 0; // Number of vertices without valid PGXP values
- short* pPrimData = (short*)addr; // primitive data for cache lookups
+ short* pPrimData = ((short*)addr) + 2; // primitive data for cache lookups
PGXP_vertex* pCacheVert = NULL;
- if (PGXP_Mem == NULL)
- return 0;
-
// Reset vertex count
numVertices = count;
vertexIdx = 0;
- // Offset to start of primitive
- primStart = &PGXP_Mem[currentAddr + 1];
- pPrimData += 2;
-
- // Find any invalid vertices
- for (unsigned i = 0; i < count; ++i)
+ // if PGXP is enabled
+ if (PGXP_Mem != NULL)
{
- if(!primStart[stride * i].valid)
- invalidVert++;
+ // Offset to start of primitive
+ primStart = &PGXP_Mem[currentAddr + 1];
+
+ // Find any invalid vertices
+ for (unsigned i = 0; i < count; ++i)
+ {
+ if (!primStart[stride * i].valid)
+ invalidVert++;
+ }
}
+ else
+ invalidVert = count;
for (unsigned i = 0; i < count; ++i)
{
- if (primStart[stride * i].valid)
+ if (primStart && primStart[stride * i].valid)
{
pVertex[i].x = (primStart[stride * i].x + xOffs);
pVertex[i].y = (primStart[stride * i].y + yOffs);
diff --git a/win32/gui/ConfigurePlugins.c b/win32/gui/ConfigurePlugins.c
index 7abe6119..84c7f93e 100755
--- a/win32/gui/ConfigurePlugins.c
+++ b/win32/gui/ConfigurePlugins.c
@@ -96,6 +96,10 @@ int LoadConfig() {
QueryKeyV("PsxType", Conf->PsxType);
QueryKeyV("PsxClock", Conf->PsxClock);
+ QueryKeyV("PGXP_GTE", Conf->PGXP_GTE);
+ QueryKeyV("PGXP_Cache", Conf->PGXP_Cache);
+ QueryKeyV("PGXP_Texture", Conf->PGXP_Texture);
+
if (Config.Cpu == CPU_DYNAREC) {
Config.Debug = 0; // don't enable debugger if using dynarec core
}
@@ -158,6 +162,11 @@ void SaveConfig() {
SetKeyV("PsxType", Conf->PsxType);
SetKeyV("PsxClock", Conf->PsxClock);
+ SetKeyV("PGXP_GTE", Conf->PGXP_GTE);
+ SetKeyV("PGXP_Cache", Conf->PGXP_Cache);
+ SetKeyV("PGXP_Texture", Conf->PGXP_Texture);
+
+
RegCloseKey(myKey);
}
diff --git a/win32/gui/Win32.h b/win32/gui/Win32.h
index b03a1a09..b5950c81 100755
--- a/win32/gui/Win32.h
+++ b/win32/gui/Win32.h
@@ -42,6 +42,7 @@ void strcatz(char *dst, char *src);
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK ConfigureNetPlayDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT WINAPI CheatDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/win32/gui/WndMain.c b/win32/gui/WndMain.c
index b1ff02d3..0e7a7d38 100755
--- a/win32/gui/WndMain.c
+++ b/win32/gui/WndMain.c
@@ -703,6 +703,10 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_CPUCONF), hWnd, (DLGPROC)ConfigureCpuDlgProc);
return TRUE;
+ case ID_CONFIGURATION_PGXP:
+ DialogBox(gApp.hInstance, MAKEINTRESOURCE(IDD_PGXPCONF), hWnd, (DLGPROC)ConfigurePGXPDlgProc);
+ return TRUE;
+
case ID_CONFIGURATION:
ConfigurePlugins(hWnd);
return TRUE;
@@ -1328,6 +1332,53 @@ BOOL CALLBACK ConfigureMcdsDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lPa
return FALSE;
}
+
+BOOL CALLBACK ConfigurePGXPDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ long tmp;
+ RECT rect;
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ SetWindowText(hW, _("PGXP Config"));
+
+ Button_SetCheck(GetDlgItem(hW, IDC_PGXP_GTE), Config.PGXP_GTE);
+ Button_SetCheck(GetDlgItem(hW, IDC_PGXP_CACHE), Config.PGXP_Cache);
+ Button_SetCheck(GetDlgItem(hW, IDC_PGXP_PERSP), Config.PGXP_Texture);
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDCANCEL:
+ EndDialog(hW, FALSE);
+ return TRUE;
+ case IDOK:
+ Config.PGXP_GTE = Button_GetCheck(GetDlgItem(hW, IDC_PGXP_GTE));
+ Config.PGXP_Cache = Button_GetCheck(GetDlgItem(hW, IDC_PGXP_CACHE));
+ Config.PGXP_Texture = Button_GetCheck(GetDlgItem(hW, IDC_PGXP_PERSP));
+
+ if (Config.SaveWindowPos)
+ {
+ GetWindowRect(gApp.hWnd, &rect);
+ Config.WindowPos[0] = rect.left;
+ Config.WindowPos[1] = rect.top;
+ }
+
+ SaveConfig();
+
+ EndDialog(hW, TRUE);
+
+ if (Config.PsxOut) OpenConsole();
+ else CloseConsole();
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
BOOL CALLBACK ConfigureCpuDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
long tmp;
RECT rect;
@@ -1763,6 +1814,8 @@ void CreateMainMenu() {
ADDMENUITEM(0, _("&Memory cards..."), ID_CONFIGURATION_MEMORYCARDMANAGER);
ADDMENUITEM(0, _("C&PU..."), ID_CONFIGURATION_CPU);
ADDSEPARATOR(0);
+ ADDMENUITEM(0, _("&PGXP..."), ID_CONFIGURATION_PGXP);
+ ADDSEPARATOR(0);
ADDMENUITEM(0, _("&NetPlay..."), ID_CONFIGURATION_NETPLAY);
ADDSEPARATOR(0);
ADDMENUITEM(0, _("&Link cable..."), ID_CONFIGURATION_LINKCABLE);
diff --git a/win32/pcsxr.rc b/win32/pcsxr.rc
index afdf6899..caba4fc6 100755
--- a/win32/pcsxr.rc
+++ b/win32/pcsxr.rc
@@ -270,6 +270,20 @@ BEGIN
EDITTEXT IDC_VALUE,41,22,113,12,ES_AUTOHSCROLL
END
+IDD_PGXPCONF DIALOGEX 0, 0, 241, 101
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "PGXP Config"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,55,80,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,127,80,50,14
+ GROUPBOX "Options",IDC_MISCOPT,6,7,229,87
+ CONTROL "Enable PGXP GTE",IDC_PGXP_GTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,24,76,10
+ CONTROL "Enable Vertex Caching",IDC_PGXP_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,39,88,10
+ CONTROL "Enable Perspective Correct Texturing",IDC_PGXP_PERSP,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,55,133,10
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -341,6 +355,14 @@ BEGIN
IDD_CHEATVALEDIT, DIALOG
BEGIN
END
+
+ IDD_PGXPCONF, DIALOG
+ BEGIN
+ LEFTMARGIN, 6
+ RIGHTMARGIN, 235
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 94
+ END
END
#endif // APSTUDIO_INVOKED
@@ -383,6 +405,11 @@ BEGIN
0
END
+IDD_PGXPCONF AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/win32/resource.h b/win32/resource.h
index 43a2c90c..dc174418 100755
--- a/win32/resource.h
+++ b/win32/resource.h
@@ -35,6 +35,7 @@
#define IDD_COP2C 117
#define MAIN_LOGO 118
#define IDD_CONFIG 120
+#define IDD_PGXPCONF 121
#define IDD_MEMVIEW 136
#define IDC_EDIT2 1001
#define IDC_CODE 1001
@@ -115,7 +116,6 @@
#define IDC_CP021 1034
#define IDC_ASMCHECK20 1034
#define IDC_FIRSTCONTROLLER 1034
-#define IDC_SELPSX2 1034
#define IDC_SELPSXCLOCK 1034
#define IDC_CP022 1035
#define IDC_ASMCHECK21 1035
@@ -158,10 +158,13 @@
#define IDC_LISTCDR 1054
#define IDC_GPR8 1055
#define IDC_LISTBIOS 1055
+#define IDC_PGXP_GTE 1055
#define IDC_GPR9 1056
#define IDC_CONFIGGPU 1056
+#define IDC_PGXP_CACHE 1056
#define IDC_GPR10 1057
#define IDC_TESTGPU 1057
+#define IDC_PGXP_PERSP 1057
#define IDC_ABOUTGPU 1058
#define IDC_CONFIGSPU 1059
#define IDC_TESTSPU 1060
@@ -332,6 +335,7 @@
#define ID_CONFIGURATION_CONTROLLERS 40017
#define ID_CONFIGURATION 40018
#define ID_CONFIGURATION_LINKCABLE 40019
+#define ID_CONFIGURATION_PGXP 40021
#define ID_FILE_RUNBIOS 40026
#define ID_CONFIGURATION_NETPLAY 40043
#define ID_EMULATOR_SWITCH_ISO 40044
@@ -365,7 +369,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 117
#define _APS_NEXT_COMMAND_VALUE 40047
-#define _APS_NEXT_CONTROL_VALUE 1054
-#define _APS_NEXT_SYMED_VALUE 102
+#define _APS_NEXT_CONTROL_VALUE 1056
+#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif