Break up the file structure of the Linux port a bit, to make it easier to make large changes.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@272 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2008-11-02 11:24:10 +00:00 committed by Gregory Hainaut
parent 91f11550c0
commit b5a6e33845
10 changed files with 1106 additions and 983 deletions

469
pcsx2/Linux/ConfigDlg.cpp Normal file
View File

@ -0,0 +1,469 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ConfigDlg.h"
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
GSconfigure();
chdir(file);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
PAD1configure();
if (strcmp(Config.PAD1, Config.PAD2)) PAD2configure();
chdir(file);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
SPU2configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Cdvd(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
CDVDconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
DEV9configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
USBconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
FWconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, char *conf)
{
GList *temp;
int i = 0, pindex = 0, item = -1;
if (strlen(conf) > 0) {
for (i=2;i<255;i+=2) {
if (!strcmp(conf, plist[i-2])) {
pindex = i - 1;
break;
}
}
}
i = 0;
temp = list;
while (temp)
{
if (!strcmp(plist[pindex],(char*)temp->data))
item = i;
temp = temp->next;
i++;
}
if (item <= 0) item = 0;
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), item);
}
void OnConfConf_Ok(GtkButton *button, gpointer user_data) {
GetComboText(GSConfS.Combo, GSConfS.plist, Config.GS)
GetComboText(PAD1ConfS.Combo, PAD1ConfS.plist, Config.PAD1);
GetComboText(PAD2ConfS.Combo, PAD2ConfS.plist, Config.PAD2);
GetComboText(SPU2ConfS.Combo, SPU2ConfS.plist, Config.SPU2);
GetComboText(CDVDConfS.Combo, CDVDConfS.plist, Config.CDVD);
GetComboText(DEV9ConfS.Combo, DEV9ConfS.plist, Config.DEV9);
GetComboText(USBConfS.Combo, USBConfS.plist, Config.USB);
GetComboText(FWConfS.Combo, FWConfS.plist, Config.FW);
GetComboText(BiosConfS.Combo, BiosConfS.plist, Config.Bios);
SaveConfig();
if (configuringplug == FALSE) {
ReleasePlugins();
LoadPlugins();
}
needReset = TRUE;
gtk_widget_destroy(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
applychanges = TRUE;
}
void OnConfConf_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
applychanges = FALSE;
}
void OnConfConf_GsConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_GSconfigure, GSConfS, Config.GS, "GSconfigure");
}
void OnConfConf_GsTest(GtkButton *button, gpointer user_data) {
TestPlugin(_GStest, GSConfS, Config.GS, "GStest");
}
void OnConfConf_GsAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_GSabout, GSConfS, Config.GS, "GSabout");
}
void OnConfConf_Pad1Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADconfigure, PAD1ConfS, Config.PAD1, "PADconfigure");
}
void OnConfConf_Pad1Test(GtkButton *button, gpointer user_data) {
TestPlugin(_PADtest, PAD1ConfS, Config.PAD1, "PADtest");
}
void OnConfConf_Pad1About(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADabout, PAD1ConfS, Config.PAD1, "PADabout");
}
void OnConfConf_Pad2Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADconfigure, PAD2ConfS, Config.PAD2, "PADconfigure");
}
void OnConfConf_Pad2Test(GtkButton *button, gpointer user_data) {
TestPlugin(_PADtest, PAD2ConfS, Config.PAD2, "PADtest");
}
void OnConfConf_Pad2About(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADabout, PAD2ConfS, Config.PAD2, "PADabout");
}
void OnConfConf_Spu2Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_SPU2configure, SPU2ConfS, Config.SPU2, "SPU2configure");
}
void OnConfConf_Spu2Test(GtkButton *button, gpointer user_data) {
TestPlugin(_SPU2test, SPU2ConfS, Config.SPU2, "SPU2test");
}
void OnConfConf_Spu2About(GtkButton *button, gpointer user_data) {
ConfPlugin(_SPU2about, SPU2ConfS, Config.SPU2, "SPU2about");
}
void OnConfConf_CdvdConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_CDVDconfigure, CDVDConfS, Config.CDVD, "CDVDconfigure");
}
void OnConfConf_CdvdTest(GtkButton *button, gpointer user_data) {
TestPlugin(_CDVDtest, CDVDConfS, Config.CDVD, "CDVDtest");
}
void OnConfConf_CdvdAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_CDVDabout, CDVDConfS, Config.CDVD, "CDVDabout");
}
void OnConfConf_Dev9Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_DEV9configure, DEV9ConfS, Config.DEV9, "DEV9configure");
}
void OnConfConf_Dev9Test(GtkButton *button, gpointer user_data) {
TestPlugin(_DEV9test, DEV9ConfS, Config.DEV9, "DEV9test");
}
void OnConfConf_Dev9About(GtkButton *button, gpointer user_data) {
ConfPlugin(_DEV9about, DEV9ConfS, Config.DEV9, "DEV9about");
}
void OnConfConf_UsbConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_USBconfigure, USBConfS, Config.USB, "USBconfigure");
}
void OnConfConf_UsbTest(GtkButton *button, gpointer user_data) {
TestPlugin(_USBtest, USBConfS, Config.USB, "USBtest");
}
void OnConfConf_UsbAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_USBabout, USBConfS, Config.USB, "USBabout");
}
void OnConfConf_FWConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_FWconfigure, FWConfS, Config.FW, "FWconfigure");
}
void OnConfConf_FWTest(GtkButton *button, gpointer user_data) {
TestPlugin(_FWtest, FWConfS, Config.FW, "FWtest");
}
void OnConfConf_FWAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_FWabout, FWConfS, Config.FW, "FWabout");
}
void SetComboToGList(GtkComboBox *widget, GList *list)
{
GList *temp;
while (gtk_combo_box_get_active_text(widget) != NULL)
{
gtk_combo_box_remove_text(GTK_COMBO_BOX(widget), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
}
temp = list;
while (temp != NULL)
{
gtk_combo_box_append_text(GTK_COMBO_BOX (widget), (char*)temp->data);
temp = temp->next;
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
}
void UpdateConfDlg() {
FindPlugins();
ConfCreatePConf("Gs", GS);
ConfCreatePConf("Pad1", PAD1);
ConfCreatePConf("Pad2", PAD2);
ConfCreatePConf("Spu2", SPU2);
ConfCreatePConf("Cdvd", CDVD);
ConfCreatePConf("Dev9", DEV9);
ConfCreatePConf("Usb", USB);
ConfCreatePConf("FW", FW);
ConfCreatePConf("Bios", Bios);
}
void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data) {
gchar *File;
GtkWidget *dialog;
gint result;
dialog = gtk_file_chooser_dialog_new ("Choose the Plugin Directory:", GTK_WINDOW (ConfDlg), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result)
{
case (GTK_RESPONSE_OK):
File = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
strcpy(Config.PluginsDir, File);
if (Config.PluginsDir[strlen(Config.PluginsDir)-1] != '/')
strcat(Config.PluginsDir, "/");
default:
gtk_widget_destroy (dialog);
}
UpdateConfDlg();
}
void OnConfConf_BiosPath(GtkButton *button, gpointer user_data) {
gchar *File;
GtkWidget *dialog;
gint result;
dialog = gtk_file_chooser_dialog_new ("Choose the Bios Directory:", GTK_WINDOW (ConfDlg), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result)
{
case (GTK_RESPONSE_OK):
File = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
strcpy(Config.BiosDir, File);
if (Config.PluginsDir[strlen(Config.BiosDir)-1] != '/')
strcat(Config.BiosDir, "/");
default:
gtk_widget_destroy (dialog);
}
UpdateConfDlg();
}
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data) {
FindPlugins();
ConfDlg = create_ConfDlg();
gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configuration"));
UpdateConfDlg();
gtk_widget_show_all(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void FindPlugins() {
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[256],name[256];
GSConfS.plugins = 0; CDVDConfS.plugins = 0; DEV9ConfS.plugins = 0;
PAD1ConfS.plugins = 0; PAD2ConfS.plugins = 0; SPU2ConfS.plugins = 0;
USBConfS.plugins = 0; FWConfS.plugins = 0; BiosConfS.plugins = 0;
GSConfS.PluginNameList = NULL; CDVDConfS.PluginNameList = NULL; DEV9ConfS.PluginNameList = NULL;
PAD1ConfS.PluginNameList = NULL; PAD2ConfS.PluginNameList = NULL; SPU2ConfS.PluginNameList = NULL;
USBConfS.PluginNameList = NULL; FWConfS.PluginNameList = NULL; BiosConfS.PluginNameList = NULL;
dir = opendir(Config.PluginsDir);
if (dir == NULL) {
SysMessage(_("Could not open '%s' directory"), Config.PluginsDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
u32 version;
u32 type;
sprintf (plugin, "%s%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL) continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL) {
printf("%s\n", dlerror()); continue;
}
PS2EgetLibType = (_PS2EgetLibType) dlsym(Handle, "PS2EgetLibType");
PS2EgetLibName = (_PS2EgetLibName) dlsym(Handle, "PS2EgetLibName");
PS2EgetLibVersion2 = (_PS2EgetLibVersion2) dlsym(Handle, "PS2EgetLibVersion2");
if (PS2EgetLibType == NULL || PS2EgetLibName == NULL || PS2EgetLibVersion2 == NULL)
continue;
type = PS2EgetLibType();
if (type & PS2E_LT_GS) {
version = PS2EgetLibVersion2(PS2E_LT_GS);
if (((version >> 16)&0xff) == PS2E_GS_VERSION) {
ComboAddPlugin(GS);
}
else
SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_GS_VERSION);
}
if (type & PS2E_LT_PAD) {
_PADquery query;
query = (_PADquery)dlsym(Handle, "PADquery");
version = PS2EgetLibVersion2(PS2E_LT_PAD);
if (((version >> 16)&0xff) == PS2E_PAD_VERSION && query) {
if (query() & 0x1)
ComboAddPlugin(PAD1);
if (query() & 0x2)
ComboAddPlugin(PAD2);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_PAD_VERSION);
}
if (type & PS2E_LT_SPU2) {
version = PS2EgetLibVersion2(PS2E_LT_SPU2);
if (((version >> 16)&0xff) == PS2E_SPU2_VERSION) {
ComboAddPlugin(SPU2);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_SPU2_VERSION);
}
if (type & PS2E_LT_CDVD) {
version = PS2EgetLibVersion2(PS2E_LT_CDVD);
if (((version >> 16)&0xff) == PS2E_CDVD_VERSION) {
ComboAddPlugin(CDVD);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_CDVD_VERSION);
}
if (type & PS2E_LT_DEV9) {
version = PS2EgetLibVersion2(PS2E_LT_DEV9);
if (((version >> 16)&0xff) == PS2E_DEV9_VERSION) {
ComboAddPlugin(DEV9);
} else SysPrintf("DEV9Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_DEV9_VERSION);
}
if (type & PS2E_LT_USB) {
version = PS2EgetLibVersion2(PS2E_LT_USB);
if (((version >> 16)&0xff) == PS2E_USB_VERSION) {
ComboAddPlugin(USB);
} else SysPrintf("USBPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_USB_VERSION);
}
if (type & PS2E_LT_FW) {
version = PS2EgetLibVersion2(PS2E_LT_FW);
if (((version >> 16)&0xff) == PS2E_FW_VERSION) {
ComboAddPlugin(FW);
} else SysPrintf("FWPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_FW_VERSION);
}
}
closedir(dir);
dir = opendir(Config.BiosDir);
if (dir == NULL) {
SysMessage(_("Could not open '%s' directory"), Config.BiosDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
struct stat buf;
char description[50]; //2002-09-28 (Florin)
sprintf (plugin, "%s%s", Config.BiosDir, ent->d_name);
if (stat(plugin, &buf) == -1) continue;
if (buf.st_size > (1024*4096)) continue; //2002-09-28 (Florin)
if (!IsBIOS(ent->d_name, description)) continue;//2002-09-28 (Florin)
BiosConfS.plugins+=2;
snprintf(BiosConfS.plist[BiosConfS.plugins-1], sizeof(BiosConfS.plist[0]), "%s (", description);
strncat(BiosConfS.plist[BiosConfS.plugins-1], ent->d_name, min(sizeof(BiosConfS.plist[0]-2), strlen(ent->d_name)));
strcat(BiosConfS.plist[BiosConfS.plugins-1], ")");
strcpy(BiosConfS.plist[BiosConfS.plugins-2], ent->d_name);
BiosConfS.PluginNameList = g_list_append(BiosConfS.PluginNameList, BiosConfS.plist[BiosConfS.plugins-1]);
}
closedir(dir);
}

133
pcsx2/Linux/ConfigDlg.h Normal file
View File

@ -0,0 +1,133 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __CONFIGDLG_H__
#define __CONFIGDLG_H__
#include "Linux.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#include "R3000A.h"
#include "PsxMem.h"
#ifdef __cplusplus
}
#endif
// Evil Macros - Destroy when possible
#define FindComboText(combo,plist, list, conf) \
if (strlen(conf) > 0) { \
SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf); \
}
#define GetComboText(combo,list,conf) \
{ \
int i; \
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); \
for (i=2;i<255;i+=2) { \
if (!strcmp(tmp, list[i-1])) { \
strcpy(conf, list[i-2]); \
break; \
} \
} \
}
#define ConfPlugin(src, confs, plugin, name) \
void *drv; \
src conf; \
char file[256]; \
GetComboText(confs.Combo, confs.plist, plugin); \
strcpy(file, Config.PluginsDir); \
strcat(file, plugin); \
drv = SysLoadLibrary(file); \
getcwd(file, ARRAYSIZE(file)); /* store current dir */ \
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/ \
if (drv == NULL) return; \
conf = (src) SysLoadSym(drv, (char*)name); \
if (SysLibError() == NULL) conf(); \
chdir(file); /* change back*/ \
SysCloseLibrary(drv);
#define TestPlugin(src, confs, plugin, name) \
void *drv; \
src conf; \
int ret = 0; \
char file[256]; \
GetComboText(confs.Combo, confs.plist, plugin); \
strcpy(file, Config.PluginsDir); \
strcat(file, plugin); \
drv = SysLoadLibrary(file); \
if (drv == NULL) return; \
conf = (src) SysLoadSym(drv, (char*)name); \
if (SysLibError() == NULL) { \
ret = conf(); \
if (ret == 0) \
SysMessage(_("This plugin reports that should work correctly")); \
else SysMessage(_("This plugin reports that should not work correctly")); \
} \
SysCloseLibrary(drv);
#define ConfCreatePConf(name, type) \
type##ConfS.Combo = lookup_widget(ConfDlg, "GtkCombo_" name); \
SetComboToGList(GTK_COMBO_BOX(type##ConfS.Combo), type##ConfS.PluginNameList); \
FindComboText(type##ConfS.Combo, type##ConfS.plist, type##ConfS.PluginNameList, Config.type);
#define ComboAddPlugin(type) { \
sprintf (name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version>>8)&0xff ,version&0xff, (version>>24)&0xff); \
type##ConfS.plugins+=2; \
strcpy(type##ConfS.plist[type##ConfS.plugins-1], name); \
strcpy(type##ConfS.plist[type##ConfS.plugins-2], ent->d_name); \
type##ConfS.PluginNameList = g_list_append(type##ConfS.PluginNameList, type##ConfS.plist[type##ConfS.plugins-1]); \
}
// Helper Functions
void FindPlugins();
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data);
typedef struct {
GtkWidget *Combo;
GList *PluginNameList;
char plist[255][255];
int plugins;
} PluginConf;
PluginConf GSConfS;
PluginConf PAD1ConfS;
PluginConf PAD2ConfS;
PluginConf SPU2ConfS;
PluginConf CDVDConfS;
PluginConf DEV9ConfS;
PluginConf USBConfS;
PluginConf FWConfS;
PluginConf BiosConfS;
GtkWidget *ConfDlg;
_PS2EgetLibType PS2EgetLibType = NULL;
_PS2EgetLibVersion2 PS2EgetLibVersion2 = NULL;
_PS2EgetLibName PS2EgetLibName = NULL;
#endif // __CONFIGDLG_H__

387
pcsx2/Linux/DebugDlg.cpp Normal file
View File

@ -0,0 +1,387 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "DebugDlg.h"
void UpdateDebugger() {
char *str;
int i;
DebugAdj->value = (gfloat)dPC/4;
gtk_list_store_clear(ListDVModel);
for (i=0; i<23; i++) {
GtkTreeIter iter;
u32 *mem;
u32 pc = dPC + i*4;
if (DebugMode) {
mem = (u32*)PSXM(pc);
}
else
mem = (u32*)PSM(pc);
if (mem == NULL) {
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", pc);
str = nullAddr;
}
else
str = disR5900Fasm(*mem, pc);
gtk_list_store_append(ListDVModel, &iter);
gtk_list_store_set(ListDVModel, &iter, 0, str, -1);
}
}
void OnDebug_Close(GtkButton *button, gpointer user_data) {
ClosePlugins();
gtk_widget_destroy(DebugWnd);
gtk_main_quit();
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnDebug_ScrollChange(GtkAdjustment *adj) {
dPC = (u32)adj->value*4;
dPC&= ~0x3;
UpdateDebugger();
}
void OnSetPC_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetPCEntry));
sscanf(str, "%lx", &dPC);
dPC&= ~0x3;
gtk_widget_destroy(SetPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetPC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetPC(GtkButton *button, gpointer user_data) {
SetPCDlg = create_SetPCDlg();
SetPCEntry = lookup_widget(SetPCDlg, "GtkEntry_dPC");
gtk_widget_show_all(SetPCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnSetBPA_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPAEntry));
sscanf(str, "%lx", &dBPA);
dBPA&= ~0x3;
gtk_widget_destroy(SetBPADlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetBPA_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetBPADlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetBPA(GtkButton *button, gpointer user_data) {
SetBPADlg = create_SetBPADlg();
SetBPAEntry = lookup_widget(SetBPADlg, "GtkEntry_BPA");
gtk_widget_show_all(SetBPADlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnSetBPC_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPCEntry));
sscanf(str, "%lx", &dBPC);
gtk_widget_destroy(SetBPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetBPC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetBPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetBPC(GtkButton *button, gpointer user_data) {
SetBPCDlg = create_SetBPCDlg();
SetBPCEntry = lookup_widget(SetBPCDlg, "GtkEntry_BPC");
gtk_widget_show_all(SetBPCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_ClearBPs(GtkButton *button, gpointer user_data) {
dBPA = -1;
dBPC = -1;
}
void OnDumpC_Ok(GtkButton *button, gpointer user_data) {
FILE *f;
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpCFEntry));
u32 addrf, addrt;
sscanf(str, "%lx", &addrf); addrf&=~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpCTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
u32 *mem;
if (DebugMode) {
mem = (u32*)PSXM(addrf);
}
else {
mem = (u32*)PSM(addrf);
}
if (mem == NULL) {
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", addrf);
str = nullAddr;
}
else
str = disR5900Fasm(*mem, addrf);
fprintf(f, "%s\n", str);
addrf+= 4;
}
fclose(f);
gtk_widget_destroy(DumpCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(DumpCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_DumpCode(GtkButton *button, gpointer user_data) {
DumpCDlg = create_DumpCDlg();
DumpCFEntry = lookup_widget(DumpCDlg, "GtkEntry_DumpCF");
DumpCTEntry = lookup_widget(DumpCDlg, "GtkEntry_DumpCT");
gtk_widget_show_all(DumpCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDumpR_Ok(GtkButton *button, gpointer user_data) {
FILE *f;
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpRFEntry));
u32 addrf, addrt;
sscanf(str, "%lx", &addrf); addrf&=~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpRTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
u32 *mem;
u32 out;
if (DebugMode) {
mem = (u32*)PSXM(addrf);
} else {
mem = (u32*)PSM(addrf);
}
if (mem == NULL) out = 0;
else out = *mem;
fwrite(&out, 4, 1, f);
addrf+= 4;
}
fclose(f);
gtk_widget_destroy(DumpRDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpR_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(DumpRDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_RawDump(GtkButton *button, gpointer user_data) {
DumpRDlg = create_DumpRDlg();
DumpRFEntry = lookup_widget(DumpRDlg, "GtkEntry_DumpRF");
DumpRTEntry = lookup_widget(DumpRDlg, "GtkEntry_DumpRT");
gtk_widget_show_all(DumpRDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_Step(GtkButton *button, gpointer user_data) {
Cpu->Step();
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_Skip(GtkButton *button, gpointer user_data) {
cpuRegs.pc+= 4;
dPC = cpuRegs.pc;
UpdateDebugger();
}
int HasBreakPoint(u32 pc) {
if (pc == dBPA) return 1;
if (DebugMode == 0) {
if ((cpuRegs.cycle - 10) <= dBPC &&
(cpuRegs.cycle + 10) >= dBPC) return 1;
} else {
if ((psxRegs.cycle - 100) <= dBPC &&
(psxRegs.cycle + 100) >= dBPC) return 1;
}
return 0;
}
void OnDebug_Go(GtkButton *button, gpointer user_data) {
for (;;) {
if (HasBreakPoint(cpuRegs.pc)) break;
Cpu->Step();
}
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_Log(GtkButton *button, gpointer user_data) {
#ifdef PCSX2_DEVBUILD
Log = 1 - Log;
#endif
}
void OnDebug_EEMode(GtkToggleButton *togglebutton, gpointer user_data) {
DebugMode = 0;
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_IOPMode(GtkToggleButton *togglebutton, gpointer user_data) {
DebugMode = 1;
dPC = psxRegs.pc;
UpdateDebugger();
}
void OnMemWrite32_Ok(GtkButton *button, gpointer user_data) {
char *mem = (char*)gtk_entry_get_text(GTK_ENTRY(MemEntry));
char *data = (char*)gtk_entry_get_text(GTK_ENTRY(DataEntry));
printf("memWrite32: %s, %s\n", mem, data);
memWrite32(strtol(mem, (char**)NULL, 0), strtol(data, (char**)NULL, 0));
gtk_widget_destroy(MemWriteDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnMemWrite32_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(MemWriteDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_memWrite32(GtkButton *button, gpointer user_data) {
MemWriteDlg = create_MemWrite32();
MemEntry = lookup_widget(MemWriteDlg, "GtkEntry_Mem");
DataEntry = lookup_widget(MemWriteDlg, "GtkEntry_Data");
gtk_widget_show_all(MemWriteDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
UpdateDebugger();
}
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *scroll;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
if (OpenPlugins(NULL) == -1) return;
if (needReset) {
SysReset();
needReset = FALSE;
}
if (!efile)
efile=GetPS2ElfName(elfname);
if (efile)
loadElfFile(elfname);
efile=0;
dPC = cpuRegs.pc;
DebugWnd = create_DebugWnd();
ListDVModel = gtk_list_store_new (1, G_TYPE_STRING);
ListDV = lookup_widget(DebugWnd, "GtkList_DisView");
gtk_tree_view_set_model(GTK_TREE_VIEW(ListDV), GTK_TREE_MODEL(ListDVModel));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("heading", renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (ListDV), column);
scroll = lookup_widget(DebugWnd, "GtkVScrollbar_VList");
DebugAdj = GTK_RANGE(scroll)->adjustment;
DebugAdj->lower = (gfloat)0x00000000/4;
DebugAdj->upper = (gfloat)0xffffffff/4;
DebugAdj->step_increment = (gfloat)1;
DebugAdj->page_increment = (gfloat)20;
DebugAdj->page_size = (gfloat)23;
gtk_signal_connect(GTK_OBJECT(DebugAdj),
"value_changed", GTK_SIGNAL_FUNC(OnDebug_ScrollChange),
NULL);
UpdateDebugger();
gtk_widget_show_all(DebugWnd);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}

57
pcsx2/Linux/DebugDlg.h Normal file
View File

@ -0,0 +1,57 @@
/* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __DEBUGDLG_H__
#define __DEBUGDLG_H__
#include "Linux.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#include "R3000A.h"
#include "PsxMem.h"
#ifdef __cplusplus
}
#endif
GtkWidget *ListDV;
GtkListStore *ListDVModel;
GtkWidget *SetPCDlg, *SetPCEntry;
GtkWidget *SetBPADlg, *SetBPAEntry;
GtkWidget *SetBPCDlg, *SetBPCEntry;
GtkWidget *DumpCDlg, *DumpCTEntry, *DumpCFEntry;
GtkWidget *DumpRDlg, *DumpRTEntry, *DumpRFEntry;
GtkWidget *MemWriteDlg, *MemEntry, *DataEntry;
GtkAdjustment *DebugAdj;
extern int efile;
extern char elfname[256];
int DebugMode; // 0 - EE | 1 - IOP
static u32 dPC, dBPA = -1, dBPC = -1;
static char nullAddr[256];
GtkWidget *DebugWnd;
#endif // __DEBUGDLG_H__

View File

@ -407,86 +407,6 @@ void OnEmu_Arguments(GtkMenuItem *menuitem, gpointer user_data) {
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
//-------------------
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
GSconfigure();
chdir(file);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
PAD1configure();
if (strcmp(Config.PAD1, Config.PAD2)) PAD2configure();
chdir(file);
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
SPU2configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Cdvd(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
CDVDconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
DEV9configure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
USBconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data) {
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
FWconfigure();
gtk_widget_set_sensitive(MainWindow, TRUE);
chdir(file);
}
void OnCpu_Ok(GtkButton *button, gpointer user_data) {
u32 newopts = 0;
@ -541,7 +461,6 @@ void OnCpu_Cancel(GtkButton *button, gpointer user_data) {
gtk_main_quit();
}
void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data)
{
char str[512];
@ -586,686 +505,6 @@ void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data)
gtk_main();
}
void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, char *conf)
{
GList *temp;
int i = 0, pindex = 0, item = -1;
if (strlen(conf) > 0) {
for (i=2;i<255;i+=2) {
if (!strcmp(conf, plist[i-2])) {
pindex = i - 1;
break;
}
}
}
i = 0;
temp = list;
while (temp)
{
if (!strcmp(plist[pindex],(char*)temp->data))
item = i;
temp = temp->next;
i++;
}
if (item <= 0) item = 0;
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), item);
}
#define FindComboText(combo,plist, list, conf) \
if (strlen(conf) > 0) { \
SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf); \
}
#define GetComboText(combo,list,conf) \
{ \
int i; \
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); \
for (i=2;i<255;i+=2) { \
if (!strcmp(tmp, list[i-1])) { \
strcpy(conf, list[i-2]); \
break; \
} \
} \
}
void OnConfConf_Ok(GtkButton *button, gpointer user_data) {
GetComboText(GSConfS.Combo, GSConfS.plist, Config.GS)
GetComboText(PAD1ConfS.Combo, PAD1ConfS.plist, Config.PAD1);
GetComboText(PAD2ConfS.Combo, PAD2ConfS.plist, Config.PAD2);
GetComboText(SPU2ConfS.Combo, SPU2ConfS.plist, Config.SPU2);
GetComboText(CDVDConfS.Combo, CDVDConfS.plist, Config.CDVD);
GetComboText(DEV9ConfS.Combo, DEV9ConfS.plist, Config.DEV9);
GetComboText(USBConfS.Combo, USBConfS.plist, Config.USB);
GetComboText(FWConfS.Combo, FWConfS.plist, Config.FW);
GetComboText(BiosConfS.Combo, BiosConfS.plist, Config.Bios);
SaveConfig();
if (configuringplug == FALSE) {
ReleasePlugins();
LoadPlugins();
}
needReset = TRUE;
gtk_widget_destroy(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
applychanges = TRUE;
}
void OnConfConf_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
applychanges = FALSE;
}
#define ConfPlugin(src, confs, plugin, name) \
void *drv; \
src conf; \
char file[256]; \
GetComboText(confs.Combo, confs.plist, plugin); \
strcpy(file, Config.PluginsDir); \
strcat(file, plugin); \
drv = SysLoadLibrary(file); \
getcwd(file, ARRAYSIZE(file)); /* store current dir */ \
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/ \
if (drv == NULL) return; \
conf = (src) SysLoadSym(drv, (char*)name); \
if (SysLibError() == NULL) conf(); \
chdir(file); /* change back*/ \
SysCloseLibrary(drv);
#define TestPlugin(src, confs, plugin, name) \
void *drv; \
src conf; \
int ret = 0; \
char file[256]; \
GetComboText(confs.Combo, confs.plist, plugin); \
strcpy(file, Config.PluginsDir); \
strcat(file, plugin); \
drv = SysLoadLibrary(file); \
if (drv == NULL) return; \
conf = (src) SysLoadSym(drv, (char*)name); \
if (SysLibError() == NULL) { \
ret = conf(); \
if (ret == 0) \
SysMessage(_("This plugin reports that should work correctly")); \
else SysMessage(_("This plugin reports that should not work correctly")); \
} \
SysCloseLibrary(drv);
void OnConfConf_GsConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_GSconfigure, GSConfS, Config.GS, "GSconfigure");
}
void OnConfConf_GsTest(GtkButton *button, gpointer user_data) {
TestPlugin(_GStest, GSConfS, Config.GS, "GStest");
}
void OnConfConf_GsAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_GSabout, GSConfS, Config.GS, "GSabout");
}
void OnConfConf_Pad1Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADconfigure, PAD1ConfS, Config.PAD1, "PADconfigure");
}
void OnConfConf_Pad1Test(GtkButton *button, gpointer user_data) {
TestPlugin(_PADtest, PAD1ConfS, Config.PAD1, "PADtest");
}
void OnConfConf_Pad1About(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADabout, PAD1ConfS, Config.PAD1, "PADabout");
}
void OnConfConf_Pad2Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADconfigure, PAD2ConfS, Config.PAD2, "PADconfigure");
}
void OnConfConf_Pad2Test(GtkButton *button, gpointer user_data) {
TestPlugin(_PADtest, PAD2ConfS, Config.PAD2, "PADtest");
}
void OnConfConf_Pad2About(GtkButton *button, gpointer user_data) {
ConfPlugin(_PADabout, PAD2ConfS, Config.PAD2, "PADabout");
}
void OnConfConf_Spu2Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_SPU2configure, SPU2ConfS, Config.SPU2, "SPU2configure");
}
void OnConfConf_Spu2Test(GtkButton *button, gpointer user_data) {
TestPlugin(_SPU2test, SPU2ConfS, Config.SPU2, "SPU2test");
}
void OnConfConf_Spu2About(GtkButton *button, gpointer user_data) {
ConfPlugin(_SPU2about, SPU2ConfS, Config.SPU2, "SPU2about");
}
void OnConfConf_CdvdConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_CDVDconfigure, CDVDConfS, Config.CDVD, "CDVDconfigure");
}
void OnConfConf_CdvdTest(GtkButton *button, gpointer user_data) {
TestPlugin(_CDVDtest, CDVDConfS, Config.CDVD, "CDVDtest");
}
void OnConfConf_CdvdAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_CDVDabout, CDVDConfS, Config.CDVD, "CDVDabout");
}
void OnConfConf_Dev9Conf(GtkButton *button, gpointer user_data) {
ConfPlugin(_DEV9configure, DEV9ConfS, Config.DEV9, "DEV9configure");
}
void OnConfConf_Dev9Test(GtkButton *button, gpointer user_data) {
TestPlugin(_DEV9test, DEV9ConfS, Config.DEV9, "DEV9test");
}
void OnConfConf_Dev9About(GtkButton *button, gpointer user_data) {
ConfPlugin(_DEV9about, DEV9ConfS, Config.DEV9, "DEV9about");
}
void OnConfConf_UsbConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_USBconfigure, USBConfS, Config.USB, "USBconfigure");
}
void OnConfConf_UsbTest(GtkButton *button, gpointer user_data) {
TestPlugin(_USBtest, USBConfS, Config.USB, "USBtest");
}
void OnConfConf_UsbAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_USBabout, USBConfS, Config.USB, "USBabout");
}
void OnConfConf_FWConf(GtkButton *button, gpointer user_data) {
ConfPlugin(_FWconfigure, FWConfS, Config.FW, "FWconfigure");
}
void OnConfConf_FWTest(GtkButton *button, gpointer user_data) {
TestPlugin(_FWtest, FWConfS, Config.FW, "FWtest");
}
void OnConfConf_FWAbout(GtkButton *button, gpointer user_data) {
ConfPlugin(_FWabout, FWConfS, Config.FW, "FWabout");
}
void SetComboToGList(GtkComboBox *widget, GList *list)
{
GList *temp;
while (gtk_combo_box_get_active_text(widget) != NULL)
{
gtk_combo_box_remove_text(GTK_COMBO_BOX(widget), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
}
temp = list;
while (temp != NULL)
{
gtk_combo_box_append_text(GTK_COMBO_BOX (widget), (char*)temp->data);
temp = temp->next;
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
}
#define ConfCreatePConf(name, type) \
type##ConfS.Combo = lookup_widget(ConfDlg, "GtkCombo_" name); \
SetComboToGList(GTK_COMBO_BOX(type##ConfS.Combo), type##ConfS.PluginNameList); \
FindComboText(type##ConfS.Combo, type##ConfS.plist, type##ConfS.PluginNameList, Config.type);
void UpdateConfDlg() {
FindPlugins();
ConfCreatePConf("Gs", GS);
ConfCreatePConf("Pad1", PAD1);
ConfCreatePConf("Pad2", PAD2);
ConfCreatePConf("Spu2", SPU2);
ConfCreatePConf("Cdvd", CDVD);
ConfCreatePConf("Dev9", DEV9);
ConfCreatePConf("Usb", USB);
ConfCreatePConf("FW", FW);
ConfCreatePConf("Bios", Bios);
}
void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data) {
gchar *File;
GtkWidget *dialog;
gint result;
dialog = gtk_file_chooser_dialog_new ("Choose the Plugin Directory:", GTK_WINDOW (ConfDlg), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result)
{
case (GTK_RESPONSE_OK):
File = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
strcpy(Config.PluginsDir, File);
if (Config.PluginsDir[strlen(Config.PluginsDir)-1] != '/')
strcat(Config.PluginsDir, "/");
default:
gtk_widget_destroy (dialog);
}
UpdateConfDlg();
}
void OnConfConf_BiosPath(GtkButton *button, gpointer user_data) {
gchar *File;
GtkWidget *dialog;
gint result;
dialog = gtk_file_chooser_dialog_new ("Choose the Bios Directory:", GTK_WINDOW (ConfDlg), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
result = gtk_dialog_run (GTK_DIALOG (dialog));
switch (result)
{
case (GTK_RESPONSE_OK):
File = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog));
strcpy(Config.BiosDir, File);
if (Config.PluginsDir[strlen(Config.BiosDir)-1] != '/')
strcat(Config.BiosDir, "/");
default:
gtk_widget_destroy (dialog);
}
UpdateConfDlg();
}
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data) {
FindPlugins();
ConfDlg = create_ConfDlg();
gtk_window_set_title(GTK_WINDOW(ConfDlg), _("Configuration"));
UpdateConfDlg();
gtk_widget_show_all(ConfDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void UpdateDebugger() {
char *str;
int i;
DebugAdj->value = (gfloat)dPC/4;
gtk_list_store_clear(ListDVModel);
for (i=0; i<23; i++) {
GtkTreeIter iter;
u32 *mem;
u32 pc = dPC + i*4;
if (DebugMode) {
mem = (u32*)PSXM(pc);
}
else
mem = (u32*)PSM(pc);
if (mem == NULL) {
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", pc);
str = nullAddr;
}
else
str = disR5900Fasm(*mem, pc);
gtk_list_store_append(ListDVModel, &iter);
gtk_list_store_set(ListDVModel, &iter, 0, str, -1);
}
}
void OnDebug_Close(GtkButton *button, gpointer user_data) {
ClosePlugins();
gtk_widget_destroy(DebugWnd);
gtk_main_quit();
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnDebug_ScrollChange(GtkAdjustment *adj) {
dPC = (u32)adj->value*4;
dPC&= ~0x3;
UpdateDebugger();
}
void OnSetPC_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetPCEntry));
sscanf(str, "%lx", &dPC);
dPC&= ~0x3;
gtk_widget_destroy(SetPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetPC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetPC(GtkButton *button, gpointer user_data) {
SetPCDlg = create_SetPCDlg();
SetPCEntry = lookup_widget(SetPCDlg, "GtkEntry_dPC");
gtk_widget_show_all(SetPCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnSetBPA_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPAEntry));
sscanf(str, "%lx", &dBPA);
dBPA&= ~0x3;
gtk_widget_destroy(SetBPADlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetBPA_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetBPADlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetBPA(GtkButton *button, gpointer user_data) {
SetBPADlg = create_SetBPADlg();
SetBPAEntry = lookup_widget(SetBPADlg, "GtkEntry_BPA");
gtk_widget_show_all(SetBPADlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnSetBPC_Ok(GtkButton *button, gpointer user_data) {
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPCEntry));
sscanf(str, "%lx", &dBPC);
gtk_widget_destroy(SetBPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
UpdateDebugger();
}
void OnSetBPC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(SetBPCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_SetBPC(GtkButton *button, gpointer user_data) {
SetBPCDlg = create_SetBPCDlg();
SetBPCEntry = lookup_widget(SetBPCDlg, "GtkEntry_BPC");
gtk_widget_show_all(SetBPCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_ClearBPs(GtkButton *button, gpointer user_data) {
dBPA = -1;
dBPC = -1;
}
void OnDumpC_Ok(GtkButton *button, gpointer user_data) {
FILE *f;
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpCFEntry));
u32 addrf, addrt;
sscanf(str, "%lx", &addrf); addrf&=~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpCTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
u32 *mem;
if (DebugMode) {
mem = (u32*)PSXM(addrf);
}
else {
mem = (u32*)PSM(addrf);
}
if (mem == NULL) {
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", addrf);
str = nullAddr;
}
else
str = disR5900Fasm(*mem, addrf);
fprintf(f, "%s\n", str);
addrf+= 4;
}
fclose(f);
gtk_widget_destroy(DumpCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(DumpCDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_DumpCode(GtkButton *button, gpointer user_data) {
DumpCDlg = create_DumpCDlg();
DumpCFEntry = lookup_widget(DumpCDlg, "GtkEntry_DumpCF");
DumpCTEntry = lookup_widget(DumpCDlg, "GtkEntry_DumpCT");
gtk_widget_show_all(DumpCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDumpR_Ok(GtkButton *button, gpointer user_data) {
FILE *f;
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpRFEntry));
u32 addrf, addrt;
sscanf(str, "%lx", &addrf); addrf&=~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpRTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
u32 *mem;
u32 out;
if (DebugMode) {
mem = (u32*)PSXM(addrf);
} else {
mem = (u32*)PSM(addrf);
}
if (mem == NULL) out = 0;
else out = *mem;
fwrite(&out, 4, 1, f);
addrf+= 4;
}
fclose(f);
gtk_widget_destroy(DumpRDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpR_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(DumpRDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_RawDump(GtkButton *button, gpointer user_data) {
DumpRDlg = create_DumpRDlg();
DumpRFEntry = lookup_widget(DumpRDlg, "GtkEntry_DumpRF");
DumpRTEntry = lookup_widget(DumpRDlg, "GtkEntry_DumpRT");
gtk_widget_show_all(DumpRDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_Step(GtkButton *button, gpointer user_data) {
Cpu->Step();
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_Skip(GtkButton *button, gpointer user_data) {
cpuRegs.pc+= 4;
dPC = cpuRegs.pc;
UpdateDebugger();
}
int HasBreakPoint(u32 pc) {
if (pc == dBPA) return 1;
if (DebugMode == 0) {
if ((cpuRegs.cycle - 10) <= dBPC &&
(cpuRegs.cycle + 10) >= dBPC) return 1;
} else {
if ((psxRegs.cycle - 100) <= dBPC &&
(psxRegs.cycle + 100) >= dBPC) return 1;
}
return 0;
}
void OnDebug_Go(GtkButton *button, gpointer user_data) {
for (;;) {
if (HasBreakPoint(cpuRegs.pc)) break;
Cpu->Step();
}
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_Log(GtkButton *button, gpointer user_data) {
#ifdef PCSX2_DEVBUILD
Log = 1 - Log;
#endif
}
void OnDebug_EEMode(GtkToggleButton *togglebutton, gpointer user_data) {
DebugMode = 0;
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_IOPMode(GtkToggleButton *togglebutton, gpointer user_data) {
DebugMode = 1;
dPC = psxRegs.pc;
UpdateDebugger();
}
void OnMemWrite32_Ok(GtkButton *button, gpointer user_data) {
char *mem = (char*)gtk_entry_get_text(GTK_ENTRY(MemEntry));
char *data = (char*)gtk_entry_get_text(GTK_ENTRY(DataEntry));
printf("memWrite32: %s, %s\n", mem, data);
memWrite32(strtol(mem, (char**)NULL, 0), strtol(data, (char**)NULL, 0));
gtk_widget_destroy(MemWriteDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnMemWrite32_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(MemWriteDlg);
gtk_main_quit();
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDebug_memWrite32(GtkButton *button, gpointer user_data) {
MemWriteDlg = create_MemWrite32();
MemEntry = lookup_widget(MemWriteDlg, "GtkEntry_Mem");
DataEntry = lookup_widget(MemWriteDlg, "GtkEntry_Data");
gtk_widget_show_all(MemWriteDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
UpdateDebugger();
}
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *scroll;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
if (OpenPlugins(NULL) == -1) return;
if (needReset) {
SysReset();
needReset = FALSE;
}
if (!efile)
efile=GetPS2ElfName(elfname);
if (efile)
loadElfFile(elfname);
efile=0;
dPC = cpuRegs.pc;
DebugWnd = create_DebugWnd();
ListDVModel = gtk_list_store_new (1, G_TYPE_STRING);
ListDV = lookup_widget(DebugWnd, "GtkList_DisView");
gtk_tree_view_set_model(GTK_TREE_VIEW(ListDV), GTK_TREE_MODEL(ListDVModel));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("heading", renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (ListDV), column);
scroll = lookup_widget(DebugWnd, "GtkVScrollbar_VList");
DebugAdj = GTK_RANGE(scroll)->adjustment;
DebugAdj->lower = (gfloat)0x00000000/4;
DebugAdj->upper = (gfloat)0xffffffff/4;
DebugAdj->step_increment = (gfloat)1;
DebugAdj->page_increment = (gfloat)20;
DebugAdj->page_size = (gfloat)23;
gtk_signal_connect(GTK_OBJECT(DebugAdj),
"value_changed", GTK_SIGNAL_FUNC(OnDebug_ScrollChange),
NULL);
UpdateDebugger();
gtk_widget_show_all(DebugWnd);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnLogging_Ok(GtkButton *button, gpointer user_data) {
#ifdef PCSX2_DEVBUILD
GtkWidget *Btn;
@ -1376,184 +615,6 @@ void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data) {
gtk_main();
}
#define ComboAddPlugin(type) { \
sprintf (name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version>>8)&0xff ,version&0xff, (version>>24)&0xff); \
type##ConfS.plugins+=2; \
strcpy(type##ConfS.plist[type##ConfS.plugins-1], name); \
strcpy(type##ConfS.plist[type##ConfS.plugins-2], ent->d_name); \
type##ConfS.PluginNameList = g_list_append(type##ConfS.PluginNameList, type##ConfS.plist[type##ConfS.plugins-1]); \
}
void FindPlugins() {
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[256],name[256];
GSConfS.plugins = 0; CDVDConfS.plugins = 0; DEV9ConfS.plugins = 0;
PAD1ConfS.plugins = 0; PAD2ConfS.plugins = 0; SPU2ConfS.plugins = 0;
USBConfS.plugins = 0; FWConfS.plugins = 0; BiosConfS.plugins = 0;
GSConfS.PluginNameList = NULL; CDVDConfS.PluginNameList = NULL; DEV9ConfS.PluginNameList = NULL;
PAD1ConfS.PluginNameList = NULL; PAD2ConfS.PluginNameList = NULL; SPU2ConfS.PluginNameList = NULL;
USBConfS.PluginNameList = NULL; FWConfS.PluginNameList = NULL; BiosConfS.PluginNameList = NULL;
dir = opendir(Config.PluginsDir);
if (dir == NULL) {
SysMessage(_("Could not open '%s' directory"), Config.PluginsDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
u32 version;
u32 type;
sprintf (plugin, "%s%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL) continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL) {
printf("%s\n", dlerror()); continue;
}
PS2EgetLibType = (_PS2EgetLibType) dlsym(Handle, "PS2EgetLibType");
PS2EgetLibName = (_PS2EgetLibName) dlsym(Handle, "PS2EgetLibName");
PS2EgetLibVersion2 = (_PS2EgetLibVersion2) dlsym(Handle, "PS2EgetLibVersion2");
if (PS2EgetLibType == NULL || PS2EgetLibName == NULL || PS2EgetLibVersion2 == NULL)
continue;
type = PS2EgetLibType();
if (type & PS2E_LT_GS) {
version = PS2EgetLibVersion2(PS2E_LT_GS);
if (((version >> 16)&0xff) == PS2E_GS_VERSION) {
ComboAddPlugin(GS);
}
else
SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_GS_VERSION);
}
if (type & PS2E_LT_PAD) {
_PADquery query;
query = (_PADquery)dlsym(Handle, "PADquery");
version = PS2EgetLibVersion2(PS2E_LT_PAD);
if (((version >> 16)&0xff) == PS2E_PAD_VERSION && query) {
if (query() & 0x1)
ComboAddPlugin(PAD1);
if (query() & 0x2)
ComboAddPlugin(PAD2);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_PAD_VERSION);
}
if (type & PS2E_LT_SPU2) {
version = PS2EgetLibVersion2(PS2E_LT_SPU2);
if (((version >> 16)&0xff) == PS2E_SPU2_VERSION) {
ComboAddPlugin(SPU2);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_SPU2_VERSION);
}
if (type & PS2E_LT_CDVD) {
version = PS2EgetLibVersion2(PS2E_LT_CDVD);
if (((version >> 16)&0xff) == PS2E_CDVD_VERSION) {
ComboAddPlugin(CDVD);
} else SysPrintf("Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_CDVD_VERSION);
}
if (type & PS2E_LT_DEV9) {
version = PS2EgetLibVersion2(PS2E_LT_DEV9);
if (((version >> 16)&0xff) == PS2E_DEV9_VERSION) {
ComboAddPlugin(DEV9);
} else SysPrintf("DEV9Plugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_DEV9_VERSION);
}
if (type & PS2E_LT_USB) {
version = PS2EgetLibVersion2(PS2E_LT_USB);
if (((version >> 16)&0xff) == PS2E_USB_VERSION) {
ComboAddPlugin(USB);
} else SysPrintf("USBPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_USB_VERSION);
}
if (type & PS2E_LT_FW) {
version = PS2EgetLibVersion2(PS2E_LT_FW);
if (((version >> 16)&0xff) == PS2E_FW_VERSION) {
ComboAddPlugin(FW);
} else SysPrintf("FWPlugin %s: Version %x != %x\n", plugin, (version >> 16)&0xff, PS2E_FW_VERSION);
}
}
closedir(dir);
dir = opendir(Config.BiosDir);
if (dir == NULL) {
SysMessage(_("Could not open '%s' directory"), Config.BiosDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
struct stat buf;
char description[50]; //2002-09-28 (Florin)
sprintf (plugin, "%s%s", Config.BiosDir, ent->d_name);
if (stat(plugin, &buf) == -1) continue;
if (buf.st_size > (1024*4096)) continue; //2002-09-28 (Florin)
if (!IsBIOS(ent->d_name, description)) continue;//2002-09-28 (Florin)
BiosConfS.plugins+=2;
snprintf(BiosConfS.plist[BiosConfS.plugins-1], sizeof(BiosConfS.plist[0]), "%s (", description);
strncat(BiosConfS.plist[BiosConfS.plugins-1], ent->d_name, min(sizeof(BiosConfS.plist[0]-2), strlen(ent->d_name)));
strcat(BiosConfS.plist[BiosConfS.plugins-1], ")");
strcpy(BiosConfS.plist[BiosConfS.plugins-2], ent->d_name);
BiosConfS.PluginNameList = g_list_append(BiosConfS.PluginNameList, BiosConfS.plist[BiosConfS.plugins-1]);
}
closedir(dir);
}
GtkWidget *MsgDlg;
void OnMsg_Ok() {
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
}
void SysMessage(const char *fmt, ...) {
GtkWidget *Ok,*Txt;
GtkWidget *Box,*Box1;
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n')
msg[strlen(msg)-1] = 0;
if (!UseGui) {
printf("%s\n",msg);
return;
}
MsgDlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), _("PCSX2 Msg"));
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5);
Box = gtk_vbox_new(5, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Txt = gtk_label_new(msg);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Ok = gtk_button_new_with_label(_("Ok"));
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_grab_focus(Ok);
gtk_widget_show(MsgDlg);
gtk_main();
}
void on_patch_browser1_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_patch_finder2_activate(GtkMenuItem *menuitem, gpointer user_data) {}

View File

@ -41,10 +41,6 @@ bool destroy = FALSE;
bool UseGui = TRUE;
bool needReset = TRUE;
bool RunExe = FALSE;
int DebugMode; // 0 - EE | 1 - IOP
static u32 dPC, dBPA = -1, dBPC = -1;
static char nullAddr[256];
int efile = 0;
char elfname[256];
@ -52,23 +48,12 @@ int Slots[5] = { -1, -1, -1, -1, -1 };
GtkWidget *CpuDlg;
_PS2EgetLibType PS2EgetLibType = NULL;
_PS2EgetLibVersion2 PS2EgetLibVersion2 = NULL;
_PS2EgetLibName PS2EgetLibName = NULL;
// Helper Functions
void FindPlugins();
// Functions Callbacks
void OnFile_LoadElf(GtkMenuItem *menuitem, gpointer user_data);
void OnFile_Exit(GtkMenuItem *menuitem, gpointer user_data);
void OnEmu_Run(GtkMenuItem *menuitem, gpointer user_data);
void OnEmu_Reset(GtkMenuItem *menuitem, gpointer user_data);
void OnEmu_Arguments(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data);
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data);
void OnLanguage(GtkMenuItem *menuitem, gpointer user_data);
void OnHelp_Help();
void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data);
@ -77,8 +62,6 @@ GtkWidget *MainWindow;
GtkWidget *pStatusBar = NULL, *Status_Box;
GtkWidget *CmdLine; //2002-09-28 (Florin)
GtkWidget *widgetCmdLine;
GtkWidget *ConfDlg;
GtkWidget *DebugWnd;
GtkWidget *LogDlg;
GtkWidget *FileSel;
GtkWidget *AboutDlg, *about_version , *about_authors, *about_greets;
@ -87,32 +70,6 @@ void init_widgets();
GtkAccelGroup *AccelGroup;
typedef struct {
GtkWidget *Combo;
GList *PluginNameList;
char plist[255][255];
int plugins;
} PluginConf;
PluginConf GSConfS;
PluginConf PAD1ConfS;
PluginConf PAD2ConfS;
PluginConf SPU2ConfS;
PluginConf CDVDConfS;
PluginConf DEV9ConfS;
PluginConf USBConfS;
PluginConf FWConfS;
PluginConf BiosConfS;
GtkWidget *ListDV;
GtkListStore *ListDVModel;
GtkWidget *SetPCDlg, *SetPCEntry;
GtkWidget *SetBPADlg, *SetBPAEntry;
GtkWidget *SetBPCDlg, *SetBPCEntry;
GtkWidget *DumpCDlg, *DumpCTEntry, *DumpCFEntry;
GtkWidget *DumpRDlg, *DumpRTEntry, *DumpRFEntry;
GtkWidget *MemWriteDlg, *MemEntry, *DataEntry;
GtkAdjustment *DebugAdj;
GtkWidget *GameFixDlg, *SpeedHacksDlg, *AdvDlg;
#endif

View File

@ -102,6 +102,10 @@ typedef enum
BIOS
} plugin_types;
extern GtkWidget *MainWindow;
extern bool applychanges;
extern bool configuringplug;
GtkWidget *check_eerec, *check_vu0rec, *check_vu1rec;
GtkWidget *check_mtgs , *check_cpu_dc;
GtkWidget *check_console , *check_patches;

View File

@ -35,6 +35,8 @@ static int s_nPageSize = 0;
static int s_nShmCounter = 0;
#endif
GtkWidget *MsgDlg;
int main(int argc, char *argv[]) {
char *file = NULL;
char elfname[256];
@ -342,6 +344,59 @@ void KeyEvent(keyEvent* ev) {
return;
}
void OnMsg_Ok() {
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
}
void SysMessage(const char *fmt, ...) {
GtkWidget *Ok,*Txt;
GtkWidget *Box,*Box1;
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n')
msg[strlen(msg)-1] = 0;
if (!UseGui) {
printf("%s\n",msg);
return;
}
MsgDlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), _("PCSX2 Msg"));
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5);
Box = gtk_vbox_new(5, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Txt = gtk_label_new(msg);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Ok = gtk_button_new_with_label(_("Ok"));
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_grab_focus(Ok);
gtk_widget_show(MsgDlg);
gtk_main();
}
int SysInit() {
mkdir(SSTATES_DIR, 0755);
mkdir(MEMCARDS_DIR, 0755);

View File

@ -3,7 +3,7 @@ INCLUDES = $(shell pkg-config --cflags gtk+-2.0) -I@srcdir@/../
bin_PROGRAMS = pcsx2
# the application source, library search path, and link libraries
pcsx2_SOURCES = Config.cpp interface.c GtkGui.cpp LnxMain.c support.c
pcsx2_SOURCES = Pref.cpp interface.c ConfigDlg.cpp DebugDlg.cpp GtkGui.cpp LnxMain.c support.c
pcsx2_LDFLAGS =