Linux: Reorganized the files to a somewhat familiar file structure. Adjusted some Linux code to be closer to the Windows version.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@443 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-02-07 06:15:22 +00:00
parent 081d533bc8
commit 57c8281242
17 changed files with 2229 additions and 1792 deletions

62
pcsx2/Linux/AboutDlg.cpp Normal file
View File

@ -0,0 +1,62 @@
/* 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 "Linux.h"
GtkWidget *AboutDlg, *about_version , *about_authors, *about_greets;
void OnHelp_Help()
{
}
void OnHelpAbout_Ok(GtkButton *button, gpointer user_data)
{
gtk_widget_destroy(AboutDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data)
{
char str[g_MaxPath];
GtkWidget *Label;
AboutDlg = create_AboutDlg();
gtk_window_set_title(GTK_WINDOW(AboutDlg), _("About"));
Label = lookup_widget(AboutDlg, "GtkAbout_LabelVersion");
// Include the SVN revision
if (SVN_REV != 0)
sprintf(str, _("PCSX2 For Linux\nVersion %s %s\n"), PCSX2_VERSION, SVN_REV);
else
//Use this instead for a non-svn version
sprintf(str, _("PCSX2 For Linux\nVersion %s\n"), PCSX2_VERSION);
gtk_label_set_text(GTK_LABEL(Label), str);
Label = lookup_widget(AboutDlg, "GtkAbout_LabelAuthors");
gtk_label_set_text(GTK_LABEL(Label), _(LabelAuthors));
Label = lookup_widget(AboutDlg, "GtkAbout_LabelGreets");
gtk_label_set_text(GTK_LABEL(Label), _(LabelGreets));
gtk_widget_show_all(AboutDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}

160
pcsx2/Linux/AdvancedDlg.cpp Normal file
View File

@ -0,0 +1,160 @@
/* 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 "Linux.h"
GtkWidget *AdvDlg;
void setAdvancedOptions()
{
if (!cpucaps.hasStreamingSIMD2Extensions)
{
// SSE1 cpus do not support Denormals Are Zero flag.
Config.sseMXCSR &= ~FLAG_DENORMAL_ZERO;
Config.sseVUMXCSR &= ~FLAG_DENORMAL_ZERO;
}
switch ((Config.sseMXCSR & 0x6000) >> 13)
{
case 0:
set_checked(AdvDlg, "radio_EE_Round_Near", TRUE);
break;
case 1:
set_checked(AdvDlg, "radio_EE_Round_Negative", TRUE);
break;
case 2:
set_checked(AdvDlg, "radio_EE_Round_Positive", TRUE);
break;
case 3:
set_checked(AdvDlg, "radio_EE_Round_Zero", TRUE);
break;
}
switch ((Config.sseVUMXCSR & 0x6000) >> 13)
{
case 0:
set_checked(AdvDlg, "radio_VU_Round_Near", TRUE);
break;
case 1:
set_checked(AdvDlg, "radio_VU_Round_Negative", TRUE);
break;
case 2:
set_checked(AdvDlg, "radio_VU_Round_Positive", TRUE);
break;
case 3:
set_checked(AdvDlg, "radio_VU_Round_Zero", TRUE);
break;
}
switch (Config.eeOptions)
{
case FLAG_EE_CLAMP_NONE:
set_checked(AdvDlg, "radio_EE_Clamp_None", TRUE);
break;
case FLAG_EE_CLAMP_NORMAL:
set_checked(AdvDlg, "radio_EE_Clamp_Normal", TRUE);
break;
case FLAG_EE_CLAMP_EXTRA_PRESERVE:
set_checked(AdvDlg, "radio_EE_Clamp_Extra_Preserve", TRUE);
break;
}
switch (Config.vuOptions)
{
case FLAG_VU_CLAMP_NONE:
set_checked(AdvDlg, "radio_VU_Clamp_None", TRUE);
break;
case FLAG_VU_CLAMP_NORMAL:
set_checked(AdvDlg, "radio_VU_Clamp_Normal", TRUE);
break;
case FLAG_VU_CLAMP_EXTRA:
set_checked(AdvDlg, "radio_VU_Clamp_Extra", TRUE);
break;
case FLAG_VU_CLAMP_EXTRA_PRESERVE:
set_checked(AdvDlg, "radio_VU_Clamp_Extra_Preserve", TRUE);
break;
}
set_checked(AdvDlg, "check_EE_Flush_Zero", (Config.sseMXCSR & FLAG_FLUSH_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_EE_Denormal_Zero", (Config.sseMXCSR & FLAG_DENORMAL_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_VU_Flush_Zero", (Config.sseVUMXCSR & FLAG_FLUSH_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_VU_Denormal_Zero", (Config.sseVUMXCSR & FLAG_DENORMAL_ZERO) ? TRUE : FALSE);
}
void on_Advanced(GtkMenuItem *menuitem, gpointer user_data)
{
AdvDlg = create_AdvDlg();
setAdvancedOptions();
gtk_widget_show_all(AdvDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Advanced_Defaults(GtkButton *button, gpointer user_data)
{
Config.sseMXCSR = DEFAULT_sseMXCSR;
Config.sseVUMXCSR = DEFAULT_sseVUMXCSR;
Config.eeOptions = DEFAULT_eeOptions;
Config.vuOptions = DEFAULT_vuOptions;
setAdvancedOptions();
}
void on_Advanced_OK(GtkButton *button, gpointer user_data)
{
Config.sseMXCSR &= 0x1fbf;
Config.sseVUMXCSR &= 0x1fbf;
Config.eeOptions = 0;
Config.vuOptions = 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Near") ? FLAG_ROUND_NEAR : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Zero") ? FLAG_ROUND_ZERO : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Near") ? FLAG_ROUND_NEAR : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Zero") ? FLAG_ROUND_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_None") ? FLAG_EE_CLAMP_NONE : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Normal") ? FLAG_EE_CLAMP_NORMAL : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Extra_Preserve") ? FLAG_EE_CLAMP_EXTRA_PRESERVE : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_None") ? FLAG_VU_CLAMP_NONE : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Normal") ? FLAG_VU_CLAMP_NORMAL : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra") ? FLAG_VU_CLAMP_EXTRA : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra_Preserve") ? FLAG_VU_CLAMP_EXTRA_PRESERVE : 0;
SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR);
SaveConfig();
gtk_widget_destroy(AdvDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}

View File

@ -5,12 +5,12 @@
* 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
@ -23,23 +23,25 @@ using namespace R5900;
static void FindComboText(GtkWidget *combo, char plist[255][255], GList *list, char *conf)
{
if (strlen(conf) > 0) SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf);
if (strlen(conf) > 0) SetActiveComboItem(GTK_COMBO_BOX(combo), plist, list, conf);
}
static bool GetComboText(GtkWidget *combo, char plist[255][255], char *conf)
{
int i;
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
int i;
char *tmp = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
if (tmp == NULL) return FALSE;
for (i=2;i<255;i+=2) {
if (!strcmp(tmp, plist[i-1])) {
strcpy(conf, plist[i-2]);
break;
}
}
for (i = 2;i < 255;i += 2)
{
if (!strcmp(tmp, plist[i-1]))
{
strcpy(conf, plist[i-2]);
break;
}
}
return TRUE;
}
@ -48,23 +50,23 @@ static void ConfPlugin(PluginConf confs, char* plugin, const char* name)
void *drv;
void (*conf)();
char file[g_MaxPath];
GetComboText(confs.Combo, confs.plist, plugin);
strcpy(file, Config.PluginsDir);
strcat(file, plugin);
GetComboText(confs.Combo, confs.plist, plugin);
strcpy(file, Config.PluginsDir);
strcat(file, plugin);
drv = SysLoadLibrary(file);
#ifndef LOCAL_PLUGIN_INIS
getcwd(file, ARRAYSIZE(file)); /* store current dir */
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
#endif
#ifndef LOCAL_PLUGIN_INIS
getcwd(file, ARRAYSIZE(file)); /* store current dir */
chdir(Config.PluginsDir); /* change dirs so that plugins can find their config file*/
#endif
if (drv == NULL) return;
conf = (void (*)()) SysLoadSym(drv, name);
if (SysLibError() == NULL) conf();
#ifndef LOCAL_PLUGIN_INIS
chdir(file); /* change back*/
#endif
if (SysLibError() == NULL) conf();
#ifndef LOCAL_PLUGIN_INIS
chdir(file); /* change back*/
#endif
SysCloseLibrary(drv);
}
@ -72,22 +74,22 @@ static void ConfPlugin(PluginConf confs, char* plugin, const char* name)
static void TestPlugin(PluginConf confs, char* plugin, const char* name)
{
void *drv;
s32 (* (*conf)())();
s32(* (*conf)())();
char file[g_MaxPath];
int ret = 0;
GetComboText(confs.Combo, confs.plist, plugin);
strcpy(file, Config.PluginsDir);
strcat(file, plugin);
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*/
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 = (s32 (* (*)())()) SysLoadSym(drv, name);
conf = (s32(* (*)())()) SysLoadSym(drv, name);
if (SysLibError() == NULL) ret = (s32) conf();
chdir(file); /* change back*/
chdir(file); /* change back*/
SysCloseLibrary(drv);
if (ret == 0)
@ -99,7 +101,7 @@ static void TestPlugin(PluginConf confs, char* plugin, const char* name)
void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -108,9 +110,10 @@ void OnConf_Gs(GtkMenuItem *menuitem, gpointer user_data)
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -120,9 +123,10 @@ void OnConf_Pads(GtkMenuItem *menuitem, gpointer user_data) {
gtk_widget_set_sensitive(MainWindow, TRUE);
}
void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -131,20 +135,22 @@ void OnConf_Spu2(GtkMenuItem *menuitem, gpointer user_data) {
chdir(file);
}
void OnConf_Cdvd(GtkMenuItem *menuitem, gpointer user_data) {
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);
chdir(file);
}
void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -153,9 +159,10 @@ void OnConf_Dev9(GtkMenuItem *menuitem, gpointer user_data) {
chdir(file);
}
void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -164,9 +171,10 @@ void OnConf_Usb(GtkMenuItem *menuitem, gpointer user_data) {
chdir(file);
}
void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data)
{
char file[255];
getcwd(file, ARRAYSIZE(file));
chdir(Config.PluginsDir);
gtk_widget_set_sensitive(MainWindow, FALSE);
@ -175,39 +183,43 @@ void OnConf_Fw(GtkMenuItem *menuitem, gpointer user_data) {
chdir(file);
}
void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, char *conf)
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])) {
if (strlen(conf) > 0)
{
for (i = 2;i < 255;i += 2)
{
if (!strcmp(conf, plist[i-2]))
{
pindex = i - 1;
break;
}
}
break;
}
}
}
i = 0;
temp = list;
while (temp)
{
if (!strcmp(plist[pindex],(char*)temp->data))
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) {
void OnConfConf_Ok(GtkButton *button, gpointer user_data)
{
applychanges = TRUE;
if (!GetComboText(GSConfS.Combo, GSConfS.plist, Config.GS))
applychanges = FALSE;
if (!GetComboText(PAD1ConfS.Combo, PAD1ConfS.plist, Config.PAD1))
@ -229,7 +241,8 @@ void OnConfConf_Ok(GtkButton *button, gpointer user_data) {
SaveConfig();
if (configuringplug == FALSE) {
if (configuringplug == FALSE)
{
ReleasePlugins();
LoadPlugins();
}
@ -239,146 +252,171 @@ void OnConfConf_Ok(GtkButton *button, gpointer user_data) {
gtk_main_quit();
}
void OnConfConf_GsConf(GtkButton *button, gpointer user_data) {
void OnConfConf_GsConf(GtkButton *button, gpointer user_data)
{
ConfPlugin(GSConfS, Config.GS, "GSconfigure");
}
void OnConfConf_GsTest(GtkButton *button, gpointer user_data) {
void OnConfConf_GsTest(GtkButton *button, gpointer user_data)
{
TestPlugin(GSConfS, Config.GS, "GStest");
}
void OnConfConf_GsAbout(GtkButton *button, gpointer user_data) {
void OnConfConf_GsAbout(GtkButton *button, gpointer user_data)
{
ConfPlugin(GSConfS, Config.GS, "GSabout");
}
void OnConfConf_Pad1Conf(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad1Conf(GtkButton *button, gpointer user_data)
{
ConfPlugin(PAD1ConfS, Config.PAD1, "PADconfigure");
}
void OnConfConf_Pad1Test(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad1Test(GtkButton *button, gpointer user_data)
{
TestPlugin(PAD1ConfS, Config.PAD1, "PADtest");
}
void OnConfConf_Pad1About(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad1About(GtkButton *button, gpointer user_data)
{
ConfPlugin(PAD1ConfS, Config.PAD1, "PADabout");
}
void OnConfConf_Pad2Conf(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad2Conf(GtkButton *button, gpointer user_data)
{
ConfPlugin(PAD2ConfS, Config.PAD2, "PADconfigure");
}
void OnConfConf_Pad2Test(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad2Test(GtkButton *button, gpointer user_data)
{
TestPlugin(PAD2ConfS, Config.PAD2, "PADtest");
}
void OnConfConf_Pad2About(GtkButton *button, gpointer user_data) {
void OnConfConf_Pad2About(GtkButton *button, gpointer user_data)
{
ConfPlugin(PAD2ConfS, Config.PAD2, "PADabout");
}
void OnConfConf_Spu2Conf(GtkButton *button, gpointer user_data) {
void OnConfConf_Spu2Conf(GtkButton *button, gpointer user_data)
{
ConfPlugin(SPU2ConfS, Config.SPU2, "SPU2configure");
}
void OnConfConf_Spu2Test(GtkButton *button, gpointer user_data) {
void OnConfConf_Spu2Test(GtkButton *button, gpointer user_data)
{
TestPlugin(SPU2ConfS, Config.SPU2, "SPU2test");
}
void OnConfConf_Spu2About(GtkButton *button, gpointer user_data) {
void OnConfConf_Spu2About(GtkButton *button, gpointer user_data)
{
ConfPlugin(SPU2ConfS, Config.SPU2, "SPU2about");
}
void OnConfConf_CdvdConf(GtkButton *button, gpointer user_data) {
void OnConfConf_CdvdConf(GtkButton *button, gpointer user_data)
{
ConfPlugin(CDVDConfS, Config.CDVD, "CDVDconfigure");
}
void OnConfConf_CdvdTest(GtkButton *button, gpointer user_data) {
void OnConfConf_CdvdTest(GtkButton *button, gpointer user_data)
{
TestPlugin(CDVDConfS, Config.CDVD, "CDVDtest");
}
void OnConfConf_CdvdAbout(GtkButton *button, gpointer user_data) {
void OnConfConf_CdvdAbout(GtkButton *button, gpointer user_data)
{
ConfPlugin(CDVDConfS, Config.CDVD, "CDVDabout");
}
void OnConfConf_Dev9Conf(GtkButton *button, gpointer user_data) {
ConfPlugin( DEV9ConfS, Config.DEV9, "DEV9configure");
void OnConfConf_Dev9Conf(GtkButton *button, gpointer user_data)
{
ConfPlugin(DEV9ConfS, Config.DEV9, "DEV9configure");
}
void OnConfConf_Dev9Test(GtkButton *button, gpointer user_data) {
void OnConfConf_Dev9Test(GtkButton *button, gpointer user_data)
{
TestPlugin(DEV9ConfS, Config.DEV9, "DEV9test");
}
void OnConfConf_Dev9About(GtkButton *button, gpointer user_data) {
ConfPlugin( DEV9ConfS, Config.DEV9, "DEV9about");
void OnConfConf_Dev9About(GtkButton *button, gpointer user_data)
{
ConfPlugin(DEV9ConfS, Config.DEV9, "DEV9about");
}
void OnConfConf_UsbConf(GtkButton *button, gpointer user_data) {
void OnConfConf_UsbConf(GtkButton *button, gpointer user_data)
{
ConfPlugin(USBConfS, Config.USB, "USBconfigure");
}
void OnConfConf_UsbTest(GtkButton *button, gpointer user_data) {
void OnConfConf_UsbTest(GtkButton *button, gpointer user_data)
{
TestPlugin(USBConfS, Config.USB, "USBtest");
}
void OnConfConf_UsbAbout(GtkButton *button, gpointer user_data) {
void OnConfConf_UsbAbout(GtkButton *button, gpointer user_data)
{
ConfPlugin(USBConfS, Config.USB, "USBabout");
}
void OnConfConf_FWConf(GtkButton *button, gpointer user_data) {
ConfPlugin( FWConfS, Config.FW, "FWconfigure");
void OnConfConf_FWConf(GtkButton *button, gpointer user_data)
{
ConfPlugin(FWConfS, Config.FW, "FWconfigure");
}
void OnConfConf_FWTest(GtkButton *button, gpointer user_data) {
void OnConfConf_FWTest(GtkButton *button, gpointer user_data)
{
TestPlugin(FWConfS, Config.FW, "FWtest");
}
void OnConfConf_FWAbout(GtkButton *button, gpointer user_data) {
ConfPlugin( FWConfS, Config.FW, "FWabout");
void OnConfConf_FWAbout(GtkButton *button, gpointer user_data)
{
ConfPlugin(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);
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);
}
static void ConfCreatePConf(const char *name, PluginConf *confs, char *config)
{
char tmp[50];
sprintf (tmp, "GtkCombo_%s", name);
confs->Combo = lookup_widget(ConfDlg, tmp);
SetComboToGList(GTK_COMBO_BOX(confs->Combo), confs->PluginNameList);
FindComboText(confs->Combo, confs->plist, confs->PluginNameList, config);
sprintf(tmp, "GtkCombo_%s", name);
confs->Combo = lookup_widget(ConfDlg, tmp);
SetComboToGList(GTK_COMBO_BOX(confs->Combo), confs->PluginNameList);
FindComboText(confs->Combo, confs->plist, confs->PluginNameList, config);
}
void UpdateConfDlg() {
FindPlugins();
void UpdateConfDlg()
{
FindPlugins();
ConfCreatePConf("Gs", &GSConfS, Config.GS);
ConfCreatePConf("Pad1", &PAD1ConfS, Config.PAD1);
ConfCreatePConf("Pad2", &PAD2ConfS, Config.PAD2);
ConfCreatePConf("Spu2", &SPU2ConfS, Config.SPU2);
ConfCreatePConf("Cdvd", &CDVDConfS, Config.CDVD);
ConfCreatePConf("Dev9", &DEV9ConfS, Config.DEV9);
ConfCreatePConf("Usb", &USBConfS, Config.USB);
ConfCreatePConf("FW", &FWConfS, Config.FW);
ConfCreatePConf("Bios", &BiosConfS, Config.Bios);
ConfCreatePConf("Gs", &GSConfS, Config.GS);
ConfCreatePConf("Pad1", &PAD1ConfS, Config.PAD1);
ConfCreatePConf("Pad2", &PAD2ConfS, Config.PAD2);
ConfCreatePConf("Spu2", &SPU2ConfS, Config.SPU2);
ConfCreatePConf("Cdvd", &CDVDConfS, Config.CDVD);
ConfCreatePConf("Dev9", &DEV9ConfS, Config.DEV9);
ConfCreatePConf("Usb", &USBConfS, Config.USB);
ConfCreatePConf("FW", &FWConfS, Config.FW);
ConfCreatePConf("Bios", &BiosConfS, Config.Bios);
}
void GetDirectory(GtkWidget *topWindow, const char *message, char *reply)
@ -386,45 +424,46 @@ void GetDirectory(GtkWidget *topWindow, const char *message, char *reply)
gchar *File;
GtkWidget *dialog;
gint result;
dialog = gtk_file_chooser_dialog_new (message, GTK_WINDOW (topWindow), 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));
dialog = gtk_file_chooser_dialog_new(message, GTK_WINDOW(topWindow), 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));
case(GTK_RESPONSE_OK):
File = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
strcpy(reply, File);
if (reply[strlen(reply)-1] != '/')
strcat(reply, "/");
strcpy(reply, File);
if (reply[strlen(reply)-1] != '/')
strcat(reply, "/");
default:
gtk_widget_destroy (dialog);
gtk_widget_destroy(dialog);
}
}
void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data)
void OnConfConf_PluginsPath(GtkButton *button, gpointer user_data)
{
char reply[g_MaxPath];
GetDirectory(ConfDlg,"Choose the Plugin Directory:", reply);
GetDirectory(ConfDlg, "Choose the Plugin Directory:", reply);
strcpy(Config.PluginsDir, reply);
UpdateConfDlg();
}
void OnConfConf_BiosPath(GtkButton *button, gpointer user_data)
void OnConfConf_BiosPath(GtkButton *button, gpointer user_data)
{
char reply[g_MaxPath];
GetDirectory(ConfDlg,"Choose the Bios Directory:", reply);
GetDirectory(ConfDlg, "Choose the Bios Directory:", reply);
strcpy(Config.BiosDir, reply);
UpdateConfDlg();
}
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data) {
void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data)
{
FindPlugins();
ConfDlg = create_ConfDlg();
@ -437,50 +476,54 @@ void OnConf_Conf(GtkMenuItem *menuitem, gpointer user_data) {
gtk_main();
}
static void ComboAddPlugin(char name[g_MaxPath], PluginConf *confs, u32 version, struct dirent *ent) {
sprintf (name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version>>8)&0xff ,version&0xff, (version>>24)&0xff);
confs->plugins+=2;
strcpy(confs->plist[confs->plugins-1], name);
strcpy(confs->plist[confs->plugins-2], ent->d_name);
confs->PluginNameList = g_list_append(confs->PluginNameList, confs->plist[confs->plugins-1]);
static void ComboAddPlugin(char name[g_MaxPath], PluginConf *confs, u32 version, struct dirent *ent)
{
sprintf(name, "%s %ld.%ld.%ld", PS2EgetLibName(), (version >> 8)&0xff , version&0xff, (version >> 24)&0xff);
confs->plugins += 2;
strcpy(confs->plist[confs->plugins-1], name);
strcpy(confs->plist[confs->plugins-2], ent->d_name);
confs->PluginNameList = g_list_append(confs->PluginNameList, confs->plist[confs->plugins-1]);
}
void FindPlugins() {
void FindPlugins()
{
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[g_MaxPath],name[g_MaxPath];
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;
char plugin[g_MaxPath], name[g_MaxPath];
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;
USBConfS.PluginNameList = NULL; FWConfS.PluginNameList = NULL; BiosConfS.PluginNameList = NULL;
dir = opendir(Config.PluginsDir);
if (dir == NULL) {
if (dir == NULL)
{
Msgbox::Alert("Could not open '%s' directory", params Config.PluginsDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
while ((ent = readdir(dir)) != NULL)
{
u32 version;
u32 type;
sprintf (plugin, "%s%s", Config.PluginsDir, ent->d_name);
sprintf(plugin, "%s%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL) continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL)
if (Handle == NULL)
{
Console::Error("Can't open %s: %s\n", params ent->d_name, dlerror());
Console::Error("Can't open %s: %s\n", params ent->d_name, dlerror());
continue;
}
PS2EgetLibType = (_PS2EgetLibType) dlsym(Handle, "PS2EgetLibType");
PS2EgetLibName = (_PS2EgetLibName) dlsym(Handle, "PS2EgetLibName");
PS2EgetLibVersion2 = (_PS2EgetLibVersion2) dlsym(Handle, "PS2EgetLibVersion2");
if (PS2EgetLibType == NULL)
{
Console::Error("PS2EgetLibType==NULL for %s", params ent->d_name);
@ -496,100 +539,101 @@ void FindPlugins() {
Console::Error("PS2EgetLibVersion2==NULL for %s", params ent->d_name);
continue;
}
type = PS2EgetLibType();
if (type & PS2E_LT_GS)
if (type & PS2E_LT_GS)
{
version = PS2EgetLibVersion2(PS2E_LT_GS);
if (((version >> 16)&0xff) == PS2E_GS_VERSION)
if (((version >> 16)&0xff) == PS2E_GS_VERSION)
ComboAddPlugin(name, &GSConfS, version, ent);
else
Console::Notice("Plugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_GS_VERSION);
}
if (type & PS2E_LT_PAD)
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(name, &PAD1ConfS, version, ent);
if (query() & 0x2) ComboAddPlugin(name, &PAD2ConfS, version, ent);
}
else
else
Console::Notice("Plugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_PAD_VERSION);
}
if (type & PS2E_LT_SPU2)
if (type & PS2E_LT_SPU2)
{
version = PS2EgetLibVersion2(PS2E_LT_SPU2);
if (((version >> 16)&0xff) == PS2E_SPU2_VERSION)
if (((version >> 16)&0xff) == PS2E_SPU2_VERSION)
ComboAddPlugin(name, &SPU2ConfS, version, ent);
else
else
Console::Notice("Plugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_SPU2_VERSION);
}
if (type & PS2E_LT_CDVD)
if (type & PS2E_LT_CDVD)
{
version = PS2EgetLibVersion2(PS2E_LT_CDVD);
if (((version >> 16)&0xff) == PS2E_CDVD_VERSION)
if (((version >> 16)&0xff) == PS2E_CDVD_VERSION)
ComboAddPlugin(name, &CDVDConfS, version, ent);
else
else
Console::Notice("Plugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_CDVD_VERSION);
}
if (type & PS2E_LT_DEV9)
if (type & PS2E_LT_DEV9)
{
version = PS2EgetLibVersion2(PS2E_LT_DEV9);
if (((version >> 16)&0xff) == PS2E_DEV9_VERSION)
if (((version >> 16)&0xff) == PS2E_DEV9_VERSION)
ComboAddPlugin(name, &DEV9ConfS, version, ent);
else
Console::Notice("DEV9Plugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_DEV9_VERSION);
}
if (type & PS2E_LT_USB)
if (type & PS2E_LT_USB)
{
version = PS2EgetLibVersion2(PS2E_LT_USB);
if (((version >> 16)&0xff) == PS2E_USB_VERSION)
if (((version >> 16)&0xff) == PS2E_USB_VERSION)
ComboAddPlugin(name, &USBConfS, version, ent);
else
else
Console::Notice("USBPlugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_USB_VERSION);
}
if (type & PS2E_LT_FW)
if (type & PS2E_LT_FW)
{
version = PS2EgetLibVersion2(PS2E_LT_FW);
if (((version >> 16)&0xff) == PS2E_FW_VERSION)
if (((version >> 16)&0xff) == PS2E_FW_VERSION)
ComboAddPlugin(name, &FWConfS, version, ent);
else
else
Console::Notice("FWPlugin %s: Version %x != %x", params plugin, (version >> 16)&0xff, PS2E_FW_VERSION);
}
}
closedir(dir);
dir = opendir(Config.BiosDir);
if (dir == NULL)
if (dir == NULL)
{
Msgbox::Alert("Could not open '%s' directory", params Config.BiosDir);
return;
}
while ((ent = readdir(dir)) != NULL) {
while ((ent = readdir(dir)) != NULL)
{
struct stat buf;
char description[50]; //2002-09-28 (Florin)
sprintf (plugin, "%s%s", Config.BiosDir, ent->d_name);
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;
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)));
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]);

View File

@ -15,25 +15,26 @@
* 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__
#ifndef __CONFIGDLG_H__
#define __CONFIGDLG_H__
#include "Linux.h"
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#ifdef __cplusplus
}
#endif
#include "R3000A.h"
#include "IopMem.h"
// Helper Functions
void FindPlugins();
@ -41,7 +42,8 @@ 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 {
typedef struct
{
GtkWidget *Combo;
GList *PluginNameList;
char plist[255][255];
@ -64,7 +66,7 @@ _PS2EgetLibType PS2EgetLibType = NULL;
_PS2EgetLibVersion2 PS2EgetLibVersion2 = NULL;
_PS2EgetLibName PS2EgetLibName = NULL;
void SetActiveComboItem(GtkComboBox *widget,char plist[255][255], GList *list, char *conf);
void SetActiveComboItem(GtkComboBox *widget, char plist[255][255], GList *list, char *conf);
void SetComboToGList(GtkComboBox *widget, GList *list);
static void ConfPlugin(PluginConf confs, char* plugin, const char* name);
static void TestPlugin(PluginConf confs, char* plugin, const char* name);

113
pcsx2/Linux/CpuDlg.cpp Normal file
View File

@ -0,0 +1,113 @@
/* 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 "Linux.h"
void OnCpu_Ok(GtkButton *button, gpointer user_data)
{
u32 newopts = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_EERec"))))
newopts |= PCSX2_EEREC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU0rec"))))
newopts |= PCSX2_VU0REC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU1rec"))))
newopts |= PCSX2_VU1REC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_MTGS"))))
newopts |= PCSX2_GSMULTITHREAD;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitNormal"))))
newopts |= PCSX2_FRAMELIMIT_NORMAL;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitLimit"))))
newopts |= PCSX2_FRAMELIMIT_LIMIT;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS"))))
newopts |= PCSX2_FRAMELIMIT_SKIP;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip"))))
newopts |= PCSX2_FRAMELIMIT_VUSKIP;
Config.CustomFps = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "CustomFPSLimit")));
Config.CustomFrameSkip = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FrameThreshold")));
Config.CustomConsecutiveFrames = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesBeforeSkipping")));
Config.CustomConsecutiveSkip = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesToSkip")));
if (Config.Options != newopts)
{
SysRestorableReset();
if ((Config.Options&PCSX2_GSMULTITHREAD) ^(newopts&PCSX2_GSMULTITHREAD))
{
// Need the MTGS setting to take effect, so close out the plugins:
PluginsResetGS();
if (CHECK_MULTIGS)
Console::Notice("MTGS mode disabled.\n\tEnjoy the fruits of single-threaded simpicity.");
else
Console::Notice("MTGS mode enabled.\n\tWelcome to multi-threaded awesomeness. And random crashes.");
}
Config.Options = newopts;
}
else
UpdateVSyncRate();
SaveConfig();
gtk_widget_destroy(CpuDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data)
{
char str[512];
CpuDlg = create_CpuDlg();
gtk_window_set_title(GTK_WINDOW(CpuDlg), _("Configuration"));
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_EERec")), !!CHECK_EEREC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU0rec")), !!CHECK_VU0REC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU1rec")), !!CHECK_VU1REC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_MTGS")), !!CHECK_MULTIGS);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitNormal")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_NORMAL);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitLimit")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_LIMIT);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_SKIP);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip")), CHECK_FRAMELIMIT == PCSX2_FRAMELIMIT_VUSKIP);
sprintf(str, "Cpu Vendor: %s", cpuinfo.x86ID);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_CpuVendor")), str);
sprintf(str, "Familly: %s", cpuinfo.x86Fam);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_Family")), str);
sprintf(str, "Cpu Speed: %d MHZ", cpuinfo.cpuspeed);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_CpuSpeed")), str);
strcpy(str, "Features: ");
if (cpucaps.hasMultimediaExtensions) strcat(str, "MMX");
if (cpucaps.hasStreamingSIMDExtensions) strcat(str, ",SSE");
if (cpucaps.hasStreamingSIMD2Extensions) strcat(str, ",SSE2");
if (cpucaps.hasStreamingSIMD3Extensions) strcat(str, ",SSE3");
if (cpucaps.hasAMD64BitArchitecture) strcat(str, ",x86-64");
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_Features")), str);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "CustomFPSLimit")), (gdouble)Config.CustomFps);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FrameThreshold")), (gdouble)Config.CustomFrameSkip);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesBeforeSkipping")), (gdouble)Config.CustomConsecutiveFrames);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesToSkip")), (gdouble)Config.CustomConsecutiveSkip);
gtk_widget_show_all(CpuDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}

View File

@ -5,12 +5,12 @@
* 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
@ -19,35 +19,39 @@
#include "DebugDlg.h"
using namespace R5900;
void UpdateDebugger() {
void UpdateDebugger()
{
char *str;
int i;
std::string output;
DebugAdj->value = (gfloat)dPC/4;
DebugAdj->value = (gfloat)dPC / 4;
gtk_list_store_clear(ListDVModel);
for (i=0; i<23; i++) {
for (i = 0; i < 23; i++)
{
GtkTreeIter iter;
u32 *mem;
u32 pc = dPC + i*4;
if (DebugMode) {
u32 pc = dPC + i * 4;
if (DebugMode)
{
mem = (u32*)PSXM(pc);
}
}
else
mem = (u32*)PSM(pc);
if (mem == NULL) {
mem = (u32*)PSM(pc);
if (mem == NULL)
{
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", pc);
str = nullAddr;
}
else
str = nullAddr;
}
else
{
std::string output;
disR5900Fasm(output, *mem, pc);
output.copy( str, 256 );
output.copy(str, 256);
}
gtk_list_store_append(ListDVModel, &iter);
gtk_list_store_set(ListDVModel, &iter, 0, str, -1);
@ -55,25 +59,28 @@ void UpdateDebugger() {
}
}
void OnDebug_Close(GtkButton *button, gpointer user_data) {
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;
void OnDebug_ScrollChange(GtkAdjustment *adj)
{
dPC = (u32)adj->value * 4;
dPC &= ~0x3;
UpdateDebugger();
}
void OnSetPC_Ok(GtkButton *button, gpointer user_data) {
void OnSetPC_Ok(GtkButton *button, gpointer user_data)
{
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetPCEntry));
sscanf(str, "%lx", &dPC);
dPC&= ~0x3;
dPC &= ~0x3;
gtk_widget_destroy(SetPCDlg);
gtk_main_quit();
@ -81,27 +88,30 @@ void OnSetPC_Ok(GtkButton *button, gpointer user_data) {
UpdateDebugger();
}
void OnSetPC_Cancel(GtkButton *button, gpointer user_data) {
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) {
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) {
void OnSetBPA_Ok(GtkButton *button, gpointer user_data)
{
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPAEntry));
sscanf(str, "%lx", &dBPA);
dBPA&= ~0x3;
dBPA &= ~0x3;
gtk_widget_destroy(SetBPADlg);
gtk_main_quit();
@ -109,23 +119,26 @@ void OnSetBPA_Ok(GtkButton *button, gpointer user_data) {
UpdateDebugger();
}
void OnSetBPA_Cancel(GtkButton *button, gpointer user_data) {
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) {
void OnDebug_SetBPA(GtkButton *button, gpointer user_data)
{
SetBPADlg = create_SetBPADlg();
SetBPAEntry = lookup_widget(SetBPADlg, "GtkEntry_BPA");
gtk_widget_show_all(SetBPADlg);
gtk_widget_show_all(SetBPADlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnSetBPC_Ok(GtkButton *button, gpointer user_data) {
void OnSetBPC_Ok(GtkButton *button, gpointer user_data)
{
char *str = (char*)gtk_entry_get_text(GTK_ENTRY(SetBPCEntry));
sscanf(str, "%lx", &dBPC);
@ -136,63 +149,73 @@ void OnSetBPC_Ok(GtkButton *button, gpointer user_data) {
UpdateDebugger();
}
void OnSetBPC_Cancel(GtkButton *button, gpointer user_data) {
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) {
void OnDebug_SetBPC(GtkButton *button, gpointer user_data)
{
SetBPCDlg = create_SetBPCDlg();
SetBPCEntry = lookup_widget(SetBPCDlg, "GtkEntry_BPC");
gtk_widget_show_all(SetBPCDlg);
gtk_widget_show_all(SetBPCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_ClearBPs(GtkButton *button, gpointer user_data) {
void OnDebug_ClearBPs(GtkButton *button, gpointer user_data)
{
dBPA = -1;
dBPC = -1;
}
void OnDumpC_Ok(GtkButton *button, gpointer user_data) {
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;
sscanf(str, "%lx", &addrf);
addrf &= ~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpCTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
sscanf(str, "%lx", &addrt);
addrt &= ~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
while (addrf != addrt)
{
u32 *mem;
if (DebugMode) {
if (DebugMode)
{
mem = (u32*)PSXM(addrf);
}
else {
}
else
{
mem = (u32*)PSM(addrf);
}
if (mem == NULL) {
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", addrf);
str = nullAddr;
if (mem == NULL)
{
sprintf(nullAddr, "%8.8lX:\tNULL MEMORY", addrf);
str = nullAddr;
}
else
else
{
std::string output;
disR5900Fasm(output, *mem, addrf);
output.copy( str, 256 );
output.copy(str, 256);
}
fprintf(f, "%s\n", str);
addrf+= 4;
addrf += 4;
}
fclose(f);
@ -201,49 +224,58 @@ void OnDumpC_Ok(GtkButton *button, gpointer user_data) {
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpC_Cancel(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(DumpCDlg);
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) {
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_show_all(DumpCDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDumpR_Ok(GtkButton *button, gpointer user_data) {
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;
sscanf(str, "%lx", &addrf);
addrf &= ~0x3;
str = (char*)gtk_entry_get_text(GTK_ENTRY(DumpRTEntry));
sscanf(str, "%lx", &addrt); addrt&=~0x3;
sscanf(str, "%lx", &addrt);
addrt &= ~0x3;
f = fopen("dump.txt", "w");
if (f == NULL) return;
while (addrf != addrt) {
while (addrf != addrt)
{
u32 *mem;
u32 out;
if (DebugMode) {
if (DebugMode)
{
mem = (u32*)PSXM(addrf);
} else {
}
else
{
mem = (u32*)PSM(addrf);
}
if (mem == NULL) out = 0;
else out = *mem;
fwrite(&out, 4, 1, f);
addrf+= 4;
addrf += 4;
}
fclose(f);
@ -252,49 +284,59 @@ void OnDumpR_Ok(GtkButton *button, gpointer user_data) {
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnDumpR_Cancel(GtkButton *button, gpointer user_data) {
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) {
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_show_all(DumpRDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
}
void OnDebug_Step(GtkButton *button, gpointer user_data) {
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;
void OnDebug_Skip(GtkButton *button, gpointer user_data)
{
cpuRegs.pc += 4;
dPC = cpuRegs.pc;
UpdateDebugger();
}
int HasBreakPoint(u32 pc) {
int HasBreakPoint(u32 pc)
{
if (pc == dBPA) return 1;
if (DebugMode == 0) {
if (DebugMode == 0)
{
if ((cpuRegs.cycle - 10) <= dBPC &&
(cpuRegs.cycle + 10) >= dBPC) return 1;
} else {
(cpuRegs.cycle + 10) >= dBPC) return 1;
}
else
{
if ((psxRegs.cycle - 100) <= dBPC &&
(psxRegs.cycle + 100) >= dBPC) return 1;
(psxRegs.cycle + 100) >= dBPC) return 1;
}
return 0;
}
void OnDebug_Go(GtkButton *button, gpointer user_data) {
for (;;) {
void OnDebug_Go(GtkButton *button, gpointer user_data)
{
for (;;)
{
if (HasBreakPoint(cpuRegs.pc)) break;
Cpu->Step();
}
@ -302,25 +344,29 @@ void OnDebug_Go(GtkButton *button, gpointer user_data) {
UpdateDebugger();
}
void OnDebug_Log(GtkButton *button, gpointer user_data) {
void OnDebug_Log(GtkButton *button, gpointer user_data)
{
#ifdef PCSX2_DEVBUILD
//Log = 1 - Log;
#endif
}
void OnDebug_EEMode(GtkToggleButton *togglebutton, gpointer user_data) {
void OnDebug_EEMode(GtkToggleButton *togglebutton, gpointer user_data)
{
DebugMode = 0;
dPC = cpuRegs.pc;
UpdateDebugger();
}
void OnDebug_IOPMode(GtkToggleButton *togglebutton, gpointer user_data) {
void OnDebug_IOPMode(GtkToggleButton *togglebutton, gpointer user_data)
{
DebugMode = 1;
dPC = psxRegs.pc;
UpdateDebugger();
}
void OnMemWrite32_Ok(GtkButton *button, gpointer user_data) {
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));
@ -331,26 +377,29 @@ void OnMemWrite32_Ok(GtkButton *button, gpointer user_data) {
gtk_widget_set_sensitive(DebugWnd, TRUE);
}
void OnMemWrite32_Cancel(GtkButton *button, gpointer user_data) {
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) {
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_show_all(MemWriteDlg);
gtk_widget_set_sensitive(DebugWnd, FALSE);
gtk_main();
UpdateDebugger();
}
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data) {
void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *scroll;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
@ -364,29 +413,29 @@ void OnDebug_Debugger(GtkMenuItem *menuitem, gpointer user_data) {
efile=0;*/
dPC = cpuRegs.pc;
DebugWnd = create_DebugWnd();
ListDVModel = gtk_list_store_new (1, G_TYPE_STRING);
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);
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->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);
NULL);
UpdateDebugger();

View File

@ -15,25 +15,26 @@
* 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__
#ifndef __DEBUGDLG_H__
#define __DEBUGDLG_H__
#include "Linux.h"
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#ifdef __cplusplus
}
#endif
#include "R3000A.h"
#include "IopMem.h"
GtkWidget *ListDV;
GtkListStore *ListDVModel;

View File

@ -1,993 +0,0 @@
/* 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 "GtkGui.h"
using namespace R5900;
void On_Dialog_Cancelled(GtkButton* button, gpointer user_data) {
gtk_widget_destroy((GtkWidget*)gtk_widget_get_toplevel ((GtkWidget*)button));
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void StartGui() {
GtkWidget *Menu;
GtkWidget *Item;
u32 i;
add_pixmap_directory(".pixmaps");
MainWindow = create_MainWindow();
if (SVN_REV != 0)
gtk_window_set_title(GTK_WINDOW(MainWindow), "PCSX2 "PCSX2_VERSION" "SVN_REV);
else
gtk_window_set_title(GTK_WINDOW(MainWindow), "PCSX2 "PCSX2_VERSION);
// status bar
pStatusBar = gtk_statusbar_new ();
gtk_box_pack_start (GTK_BOX(lookup_widget(MainWindow, "status_box")), pStatusBar, TRUE, TRUE, 0);
gtk_widget_show (pStatusBar);
gtk_statusbar_push(GTK_STATUSBAR(pStatusBar),0,
"F1 - save, F2 - next state, Shift+F2 - prev state, F3 - load, F8 - snapshot");
// add all the languages
Item = lookup_widget(MainWindow, "GtkMenuItem_Language");
Menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(Item), Menu);
for (i=0; i < langsMax; i++) {
Item = gtk_check_menu_item_new_with_label(ParseLang(langs[i].lang));
gtk_widget_show(Item);
gtk_container_add(GTK_CONTAINER(Menu), Item);
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(Item), TRUE);
if (!strcmp(Config.Lang, langs[i].lang))
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(Item), TRUE);
gtk_signal_connect(GTK_OBJECT(Item), "activate",
GTK_SIGNAL_FUNC(OnLanguage),
(gpointer)(uptr)i);
}
// check the appropriate menu items
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(MainWindow, "enable_console1")), Config.PsxOut);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(MainWindow, "enable_patches1")), Config.Patch);
// disable anything not implemented or not working properly.
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_browser1")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_finder2")), FALSE);
#ifndef PCSX2_DEVBUILD
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_Logging")), FALSE);
#endif
gtk_widget_show_all(MainWindow);
gtk_window_activate_focus(GTK_WINDOW(MainWindow));
gtk_main();
}
void RunGui() {
StartGui();
}
void FixCPUState(void)
{
//Config.sseMXCSR = LinuxsseMXCSR;
//Config.sseVUMXCSR = LinuxsseVUMXCSR;
SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR);
}
void OnDestroy(GtkObject *object, gpointer user_data) {}
gboolean OnDelete(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
pcsx2_exit();
return (FALSE);
}
int Pcsx2Configure() {
if (!UseGui) return 0;
configuringplug = TRUE;
MainWindow = NULL;
OnConf_Conf(NULL, 0);
configuringplug = FALSE;
return applychanges;
}
void OnLanguage(GtkMenuItem *menuitem, gpointer user_data) {
ChangeLanguage(langs[(int)(uptr)user_data].lang);
gtk_widget_destroy(MainWindow);
gtk_main_quit();
while (gtk_events_pending()) gtk_main_iteration();
StartGui();
}
void SignalExit(int sig) {
ClosePlugins();
pcsx2_exit();
}
void ExecuteCpu()
{
// Make sure any left-over recovery states are cleaned up.
safe_delete( g_RecoveryState );
// Destroy the window. Ugly thing.
gtk_widget_destroy(MainWindow);
gtk_main_quit();
while (gtk_events_pending()) gtk_main_iteration();
g_GameInProgress = true;
m_ReturnToGame = false;
signal(SIGINT, SignalExit);
signal(SIGPIPE, SignalExit);
// Make sure any left-over recovery states are cleaned up.
safe_delete( g_RecoveryState );
// Just in case they weren't initialized earlier (no harm in calling this multiple times)
if (OpenPlugins(NULL) == -1) return;
// this needs to be called for every new game! (note: sometimes launching games through bios will give a crc of 0)
if( GSsetGameCRC != NULL ) GSsetGameCRC(ElfCRC, g_ZeroGSOptions);
// Optimization: We hardcode two versions of the EE here -- one for recs and one for ints.
// This is because recs are performance critical, and being able to inline them into the
// function here helps a small bit (not much but every small bit counts!).
g_EmulationInProgress = true;
g_ReturnToGui = false;
PCSX2_MEM_PROTECT_BEGIN();
if( CHECK_EEREC )
{
while( !g_ReturnToGui )
{
recExecute();
SysUpdate();
}
}
else
{
while( !g_ReturnToGui )
{
Cpu->Execute();
SysUpdate();
}
}
PCSX2_MEM_PROTECT_END();
}
void RunExecute( const char* elf_file, bool use_bios )
{
// (air notes:)
// If you want to use the new to-memory savestate feature, take a look at the new
// RunExecute in WinMain.c, and secondly the CpuDlg.c or AdvancedDlg.cpp. The
// objects used are MemoryAlloc, memLoadingState, and memSavingState.
// It's important to make sure to reset the CPU and the plugins correctly, which is
// where the new RunExecute comes into play. It can be kind of tricky knowing
// when to call cpuExecuteBios and loadElfFile, and with what parameters.
// (or, as an alternative maybe we should switch to wxWidgets and have a unified
// cross platform gui?) - Air
try
{
cpuReset();
}
catch( std::exception& ex )
{
Msgbox::Alert( ex.what() );
return;
}
if (OpenPlugins(NULL) == -1)
{
RunGui();
return;
}
if (elf_file == NULL )
{
if (g_RecoveryState != NULL)
{
try
{
memLoadingState( *g_RecoveryState ).FreezeAll();
}
catch( std::runtime_error& ex )
{
Msgbox::Alert(
"Gamestate recovery failed. Your game progress will be lost (sorry!)\n"
"\nError: %s\n", params ex.what() );
// Take the user back to the GUI...
safe_delete( g_RecoveryState );
ClosePlugins();
return;
}
safe_delete( g_RecoveryState );
}
else
{
// Not recovering a state, so need to execute the bios and load the ELF information.
// if the elf_file is null we use the CDVD elf file.
// But if the elf_file is an empty string then we boot the bios instead.
char ename[g_MaxPath];
ename[0] = 0;
if( !use_bios )
GetPS2ElfName( ename );
loadElfFile( ename );
}
}
else
{
// Custom ELF specified (not using CDVD).
// Run the BIOS and load the ELF.
loadElfFile( elf_file );
}
FixCPUState();
ExecuteCpu();
}
void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data) {
safe_free( g_RecoveryState );
ResetPlugins();
RunExecute( NULL );
}
void OnRunElf_Ok(GtkButton* button, gpointer user_data) {
gchar *File;
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(elfname, File);
gtk_widget_destroy(FileSel);
RunExecute(elfname);
}
void OnRunElf_Cancel(GtkButton* button, gpointer user_data) {
gtk_widget_destroy(FileSel);
}
void OnFile_LoadElf(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Ok,*Cancel;
FileSel = gtk_file_selection_new("Select Psx Elf File");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnRunElf_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect (GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnRunElf_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
void pcsx2_exit()
{
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[g_MaxPath];
// with this the problem with plugins that are linked with the pthread
// library is solved
dir = opendir(Config.PluginsDir);
if (dir != NULL) {
while ((ent = readdir(dir)) != NULL) {
sprintf (plugin, "%s%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL) continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL) continue;
}
}
printf("PCSX2 Quitting\n");
if (UseGui)
{
gtk_main_quit();
SysClose();
gtk_exit(0);
}
else
{
SysClose();
exit(0);
}
}
void OnFile_Exit(GtkMenuItem *menuitem, gpointer user_data)
{
pcsx2_exit();
}
void OnEmu_Run(GtkMenuItem *menuitem, gpointer user_data)
{
if( g_EmulationInProgress )
ExecuteCpu();
else
RunExecute( NULL, true ); // boots bios if no savestate is to be recovered
}
void OnEmu_Reset(GtkMenuItem *menuitem, gpointer user_data)
{
SysReset();
}
void ResetMenuSlots(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Item;
char str[g_MaxPath];
int i;
for (i=0; i<5; i++) {
sprintf(str, "GtkMenuItem_LoadSlot%d", i+1);
Item = lookup_widget(MainWindow, str);
if (Slots[i] == -1)
gtk_widget_set_sensitive(Item, FALSE);
else
gtk_widget_set_sensitive(Item, TRUE);
}
}
/*void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) {
char str[g_MaxPath];
int i = 0;
for (i=0; i<5; i++) {
sprintf(str, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, i);
Slots[i] = CheckState(str);
}
}*/
void States_Load(string file, int num = -1 )
{
efile = 2;
try
{
// when we init joe it'll throw an UnsupportedStateVersion.
// So reset the cpu afterward so that trying to load a bum save
// doesn't fry the current emulation state.
gzLoadingState joe( file );
// Make sure the cpu and plugins are ready to be state-ified!
cpuReset();
OpenPlugins( NULL );
joe.FreezeAll();
}
catch( Exception::UnsupportedStateVersion& )
{
if( num != -1 )
Msgbox::Alert("Savestate slot %d is an unsupported version." , params num);
else
Msgbox::Alert( "%s : This is an unsupported savestate version." , params file.c_str());
// At this point the cpu hasn't been reset, so we can return
// control to the user safely...
return;
}
catch( std::exception& ex )
{
if (num != -1)
Console::Error("Error occured while trying to load savestate slot %d", params num);
else
Console::Error("Error occured while trying to load savestate file: %d", params file.c_str());
Console::Error( "%s", params ex.what() );
// The emulation state is ruined. Might as well give them a popup and start the gui.
Msgbox::Alert(
"An error occured while trying to load the savestate data.\n"
"Pcsx2 emulation state has been reset."
);
cpuShutdown();
return;
}
ExecuteCpu();
}
void States_Load(int num) {
string Text;
SaveState::GetFilename( Text, num );
struct stat buf;
if( stat(Text.c_str(), &buf ) == -1 )
{
Console::Notice( "Saveslot %d is empty.", params num );
return;
}
States_Load( Text, num );
}
void States_Save( string file, int num = -1 )
{
try
{
gzSavingState(file).FreezeAll();
if( num != -1 )
Console::Notice("State saved to slot %d", params num );
else
Console::Notice( "State saved to file: %s", params file.c_str() );
}
catch( std::exception& ex )
{
if( num != -1 )
Msgbox::Alert("An error occurred while trying to save to slot %d", params num );
else
Msgbox::Alert("An error occurred while trying to save to file: %s", params file.c_str() );
Console::Error("Save state request failed with the following error:" );
Console::Error( "%s", params ex.what() );
}
}
void States_Save(int num) {
string Text;
SaveState::GetFilename( Text, num );
States_Save( Text, num );
}
void OnStates_Load1(GtkMenuItem *menuitem, gpointer user_data) { States_Load(0); }
void OnStates_Load2(GtkMenuItem *menuitem, gpointer user_data) { States_Load(1); }
void OnStates_Load3(GtkMenuItem *menuitem, gpointer user_data) { States_Load(2); }
void OnStates_Load4(GtkMenuItem *menuitem, gpointer user_data) { States_Load(3); }
void OnStates_Load5(GtkMenuItem *menuitem, gpointer user_data) { States_Load(4); }
void OnLoadOther_Ok(GtkButton* button, gpointer user_data) {
gchar *File;
char str[g_MaxPath];
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(str, File);
gtk_widget_destroy(FileSel);
States_Load( str );
}
void OnLoadOther_Cancel(GtkButton* button, gpointer user_data) {
gtk_widget_destroy(FileSel);
}
void OnStates_LoadOther(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Ok,*Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnLoadOther_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect (GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnLoadOther_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
void OnStates_Save1(GtkMenuItem *menuitem, gpointer user_data) { States_Save(0); }
void OnStates_Save2(GtkMenuItem *menuitem, gpointer user_data) { States_Save(1); }
void OnStates_Save3(GtkMenuItem *menuitem, gpointer user_data) { States_Save(2); }
void OnStates_Save4(GtkMenuItem *menuitem, gpointer user_data) { States_Save(3); }
void OnStates_Save5(GtkMenuItem *menuitem, gpointer user_data) { States_Save(4); }
void OnSaveOther_Ok(GtkButton* button, gpointer user_data) {
gchar *File;
char str[g_MaxPath];
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(str, File);
gtk_widget_destroy(FileSel);
States_Save( str );
}
void OnSaveOther_Cancel(GtkButton* button, gpointer user_data) {
gtk_widget_destroy(FileSel);
}
void OnStates_SaveOther(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Ok,*Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnSaveOther_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect (GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnSaveOther_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
//2002-09-28 (Florin)
void OnArguments_Ok(GtkButton *button, gpointer user_data) {
char *str;
str = (char*)gtk_entry_get_text(GTK_ENTRY(widgetCmdLine));
memcpy(args, str, g_MaxPath);
gtk_widget_destroy(CmdLine);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnEmu_Arguments(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *widgetCmdLine;
CmdLine = create_CmdLine();
gtk_window_set_title(GTK_WINDOW(CmdLine), _("Program arguments"));
widgetCmdLine = lookup_widget(CmdLine, "GtkEntry_dCMDLINE");
gtk_entry_set_text(GTK_ENTRY(widgetCmdLine), args);
gtk_widget_show_all(CmdLine);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnCpu_Ok(GtkButton *button, gpointer user_data) {
u32 newopts = 0;
//Cpu->Shutdown();
//vu0Shutdown();
//vu1Shutdown();
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_EERec"))))
newopts |= PCSX2_EEREC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU0rec"))))
newopts |= PCSX2_VU0REC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU1rec"))))
newopts |= PCSX2_VU1REC;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_MTGS"))))
newopts |= PCSX2_GSMULTITHREAD;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitNormal"))))
newopts |= PCSX2_FRAMELIMIT_NORMAL;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitLimit"))))
newopts |= PCSX2_FRAMELIMIT_LIMIT;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS"))))
newopts |= PCSX2_FRAMELIMIT_SKIP;
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip"))))
newopts |= PCSX2_FRAMELIMIT_VUSKIP;
Config.CustomFps = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "CustomFPSLimit")));
Config.CustomFrameSkip = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FrameThreshold")));
Config.CustomConsecutiveFrames = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesBeforeSkipping")));
Config.CustomConsecutiveSkip = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesToSkip")));
if (Config.Options != newopts)
{
SysRestorableReset();
if ((Config.Options&PCSX2_GSMULTITHREAD) ^ (newopts&PCSX2_GSMULTITHREAD))
{
// Need the MTGS setting to take effect, so close out the plugins:
PluginsResetGS();
if (CHECK_MULTIGS)
Console::Notice( "MTGS mode disabled.\n\tEnjoy the fruits of single-threaded simpicity." );
else
Console::Notice( "MTGS mode enabled.\n\tWelcome to multi-threaded awesomeness. And random crashes." );
}
Config.Options = newopts;
}
else
UpdateVSyncRate();
SaveConfig();
gtk_widget_destroy(CpuDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnConf_Cpu(GtkMenuItem *menuitem, gpointer user_data)
{
char str[512];
CpuDlg = create_CpuDlg();
gtk_window_set_title(GTK_WINDOW(CpuDlg), _("Configuration"));
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_EERec")), !!CHECK_EEREC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU0rec")), !!CHECK_VU0REC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_VU1rec")), !!CHECK_VU1REC);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkCheckButton_MTGS")), !!CHECK_MULTIGS);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitNormal")), CHECK_FRAMELIMIT==PCSX2_FRAMELIMIT_NORMAL);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitLimit")), CHECK_FRAMELIMIT==PCSX2_FRAMELIMIT_LIMIT);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_LimitFS")), CHECK_FRAMELIMIT==PCSX2_FRAMELIMIT_SKIP);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(CpuDlg, "GtkRadioButton_VUSkip")), CHECK_FRAMELIMIT==PCSX2_FRAMELIMIT_VUSKIP);
sprintf(str, "Cpu Vendor: %s", cpuinfo.x86ID);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_CpuVendor")), str);
sprintf(str, "Familly: %s", cpuinfo.x86Fam);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_Family")), str);
sprintf(str, "Cpu Speed: %d MHZ", cpuinfo.cpuspeed);
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_CpuSpeed")), str);
strcpy(str,"Features: ");
if(cpucaps.hasMultimediaExtensions) strcat(str,"MMX");
if(cpucaps.hasStreamingSIMDExtensions) strcat(str,",SSE");
if(cpucaps.hasStreamingSIMD2Extensions) strcat(str,",SSE2");
if(cpucaps.hasStreamingSIMD3Extensions) strcat(str,",SSE3");
if(cpucaps.hasAMD64BitArchitecture) strcat(str,",x86-64");
gtk_label_set_text(GTK_LABEL(lookup_widget(CpuDlg, "GtkLabel_Features")), str);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "CustomFPSLimit")), (gdouble)Config.CustomFps);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FrameThreshold")), (gdouble)Config.CustomFrameSkip);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesBeforeSkipping")), (gdouble)Config.CustomConsecutiveFrames);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(CpuDlg, "FramesToSkip")), (gdouble)Config.CustomConsecutiveSkip);
gtk_widget_show_all(CpuDlg);
if (MainWindow) gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnLogging_Ok(GtkButton *button, gpointer user_data) {
#ifdef PCSX2_DEVBUILD
GtkWidget *Btn;
char str[32];
int i, ret;
for (i=0; i<32; i++) {
if (((i > 16) && (i < 20)) || (i == 29))
continue;
sprintf(str, "Log%d", i);
Btn = lookup_widget(LogDlg, str);
ret = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
if (ret) varLog|= 1<<i;
else varLog&=~(1<<i);
}
SaveConfig();
#endif
gtk_widget_destroy(LogDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnDebug_Logging(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Btn;
char str[32];
int i;
LogDlg = create_Logging();
for (i=0; i<32; i++) {
if (((i > 16) && (i < 20)) || (i == 29))
continue;
sprintf(str, "Log%d", i);
Btn = lookup_widget(LogDlg, str);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), varLog & (1<<i));
}
gtk_widget_show_all(LogDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnHelp_Help() {
}
void OnHelpAbout_Ok(GtkButton *button, gpointer user_data) {
gtk_widget_destroy(AboutDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data) {
char str[g_MaxPath];
GtkWidget *Label;
AboutDlg = create_AboutDlg();
gtk_window_set_title(GTK_WINDOW(AboutDlg), _("About"));
Label = lookup_widget(AboutDlg, "GtkAbout_LabelVersion");
// Include the SVN revision
if (SVN_REV !=0)
sprintf(str, _("PCSX2 For Linux\nVersion %s %s\n"), PCSX2_VERSION, SVN_REV);
else
//Use this instead for a non-svn version
sprintf(str, _("PCSX2 For Linux\nVersion %s\n"), PCSX2_VERSION);
gtk_label_set_text(GTK_LABEL(Label), str);
Label = lookup_widget(AboutDlg, "GtkAbout_LabelAuthors");
gtk_label_set_text(GTK_LABEL(Label), _(LabelAuthors));
Label = lookup_widget(AboutDlg, "GtkAbout_LabelGreets");
gtk_label_set_text(GTK_LABEL(Label), _(LabelGreets));
gtk_widget_show_all(AboutDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_patch_browser1_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_patch_finder2_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_enable_console1_activate (GtkMenuItem *menuitem, gpointer user_data)
{
Config.PsxOut=(int)gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
SaveConfig();
}
void on_enable_patches1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
Config.Patch=(int)gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
SaveConfig();
}
void on_Game_Fixes(GtkMenuItem *menuitem, gpointer user_data)
{
GameFixDlg = create_GameFixDlg();
set_checked(GameFixDlg, "check_VU_Add_Sub", (Config.GameFixes & FLAG_VU_ADD_SUB));
set_checked(GameFixDlg, "check_FPU_Clamp", (Config.GameFixes & FLAG_FPU_CLAMP));
set_checked(GameFixDlg, "check_VU_Branch", (Config.GameFixes & FLAG_VU_BRANCH));
gtk_widget_show_all(GameFixDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Game_Fix_OK(GtkButton *button, gpointer user_data)
{
Config.GameFixes = 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_VU_Add_Sub") ? FLAG_VU_ADD_SUB : 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_FPU_Clamp") ? FLAG_FPU_CLAMP : 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_VU_Branch") ? FLAG_VU_BRANCH : 0;
SaveConfig();
gtk_widget_destroy(GameFixDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void on_Speed_Hacks(GtkMenuItem *menuitem, gpointer user_data)
{
SpeedHacksDlg = create_SpeedHacksDlg();
switch (CHECK_EE_CYCLERATE)
{
case 0:
set_checked(SpeedHacksDlg, "check_default_cycle_rate", true);
break;
case 1:
set_checked(SpeedHacksDlg, "check_1_5_cycle_rate", true);
break;
case 2:
set_checked(SpeedHacksDlg, "check_2_cycle_rate", true);
break;
case 3:
set_checked(SpeedHacksDlg, "check_3_cycle_rate", true);
break;
default:
set_checked(SpeedHacksDlg, "check_default_cycle_rate", true);
break;
}
set_checked(SpeedHacksDlg, "check_iop_cycle_rate", CHECK_IOP_CYCLERATE);
set_checked(SpeedHacksDlg, "check_wait_cycles_sync_hack", CHECK_WAITCYCLE_HACK);
set_checked(SpeedHacksDlg, "check_ESC_hack",CHECK_ESCAPE_HACK);
gtk_widget_show_all(SpeedHacksDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Speed_Hack_OK(GtkButton *button, gpointer user_data)
{
Config.Hacks = 0;
if is_checked(SpeedHacksDlg, "check_default_cycle_rate")
Config.Hacks = 0;
else if is_checked(SpeedHacksDlg, "check_1_5_cycle_rate")
Config.Hacks = 1;
else if is_checked(SpeedHacksDlg, "check_2_cycle_rate")
Config.Hacks = 2;
else if is_checked(SpeedHacksDlg, "check_3_cycle_rate")
Config.Hacks = 3;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_iop_cycle_rate") << 3;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_wait_cycles_sync_hack") << 4;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_ESC_hack") << 10;
SaveConfig();
gtk_widget_destroy(SpeedHacksDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void setAdvancedOptions()
{
if( !cpucaps.hasStreamingSIMD2Extensions )
{
// SSE1 cpus do not support Denormals Are Zero flag.
Config.sseMXCSR &= ~FLAG_DENORMAL_ZERO;
Config.sseVUMXCSR &= ~FLAG_DENORMAL_ZERO;
}
switch((Config.sseMXCSR & 0x6000) >> 13)
{
case 0:
set_checked(AdvDlg, "radio_EE_Round_Near", TRUE);
break;
case 1:
set_checked(AdvDlg, "radio_EE_Round_Negative",TRUE);
break;
case 2:
set_checked(AdvDlg, "radio_EE_Round_Positive", TRUE);
break;
case 3:
set_checked(AdvDlg, "radio_EE_Round_Zero", TRUE);
break;
}
switch((Config.sseVUMXCSR & 0x6000) >> 13)
{
case 0:
set_checked(AdvDlg, "radio_VU_Round_Near", TRUE);
break;
case 1:
set_checked(AdvDlg, "radio_VU_Round_Negative",TRUE);
break;
case 2:
set_checked(AdvDlg, "radio_VU_Round_Positive", TRUE);
break;
case 3:
set_checked(AdvDlg, "radio_VU_Round_Zero", TRUE);
break;
}
switch(Config.eeOptions)
{
case FLAG_EE_CLAMP_NONE:
set_checked(AdvDlg, "radio_EE_Clamp_None", TRUE);
break;
case FLAG_EE_CLAMP_NORMAL:
set_checked(AdvDlg, "radio_EE_Clamp_Normal",TRUE);
break;
case FLAG_EE_CLAMP_EXTRA_PRESERVE:
set_checked(AdvDlg, "radio_EE_Clamp_Extra_Preserve", TRUE);
break;
}
switch(Config.vuOptions)
{
case FLAG_VU_CLAMP_NONE:
set_checked(AdvDlg, "radio_VU_Clamp_None", TRUE);
break;
case FLAG_VU_CLAMP_NORMAL:
set_checked(AdvDlg, "radio_VU_Clamp_Normal",TRUE);
break;
case FLAG_VU_CLAMP_EXTRA:
set_checked(AdvDlg, "radio_VU_Clamp_Extra", TRUE);
break;
case FLAG_VU_CLAMP_EXTRA_PRESERVE:
set_checked(AdvDlg, "radio_VU_Clamp_Extra_Preserve", TRUE);
break;
}
set_checked(AdvDlg, "check_EE_Flush_Zero", (Config.sseMXCSR & FLAG_FLUSH_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_EE_Denormal_Zero", (Config.sseMXCSR & FLAG_DENORMAL_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_VU_Flush_Zero", (Config.sseVUMXCSR & FLAG_FLUSH_ZERO) ? TRUE : FALSE);
set_checked(AdvDlg, "check_VU_Denormal_Zero", (Config.sseVUMXCSR & FLAG_DENORMAL_ZERO) ? TRUE : FALSE);
}
void on_Advanced(GtkMenuItem *menuitem, gpointer user_data)
{
AdvDlg = create_AdvDlg();
setAdvancedOptions();
gtk_widget_show_all(AdvDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Advanced_Defaults(GtkButton *button, gpointer user_data)
{
Config.sseMXCSR = DEFAULT_sseMXCSR;
Config.sseVUMXCSR = DEFAULT_sseVUMXCSR;
Config.eeOptions = DEFAULT_eeOptions;
Config.vuOptions = DEFAULT_vuOptions;
setAdvancedOptions();
}
void on_Advanced_OK(GtkButton *button, gpointer user_data)
{
Config.sseMXCSR &= 0x1fbf;
Config.sseVUMXCSR &= 0x1fbf;
Config.eeOptions = 0;
Config.vuOptions = 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Near") ? FLAG_ROUND_NEAR : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Zero") ? FLAG_ROUND_ZERO : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Near") ? FLAG_ROUND_NEAR : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Zero") ? FLAG_ROUND_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_None") ? FLAG_EE_CLAMP_NONE : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Normal") ? FLAG_EE_CLAMP_NORMAL : 0;
Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Extra_Preserve") ? FLAG_EE_CLAMP_EXTRA_PRESERVE : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_None") ? FLAG_VU_CLAMP_NONE : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Normal") ? FLAG_VU_CLAMP_NORMAL : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra") ? FLAG_VU_CLAMP_EXTRA : 0;
Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra_Preserve") ? FLAG_VU_CLAMP_EXTRA_PRESERVE : 0;
SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR);
SaveConfig();
gtk_widget_destroy(AdvDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}

View File

@ -1,83 +0,0 @@
/* 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 __GTKGUI_H__
#define __GTKGUI_H__
#include "PrecompiledHeader.h"
#include "Linux.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#ifdef __cplusplus
}
#endif
bool applychanges = FALSE;
bool configuringplug = FALSE;
bool UseGui = TRUE;
MemoryAlloc<u8>* g_RecoveryState = NULL;
bool g_GameInProgress = false; // Set TRUE if a game is actively running.
//static bool AccBreak = false;
static bool m_ReturnToGame = false; // set to exit the RunGui message pump
int efile = 0;
char elfname[g_MaxPath];
int Slots[5] = { -1, -1, -1, -1, -1 };
GtkWidget *CpuDlg;
// 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 OnLanguage(GtkMenuItem *menuitem, gpointer user_data);
void OnHelp_Help();
void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data);
void ExecuteCpu();
void StartGui();
void pcsx2_exit();
GtkWidget *MainWindow;
GtkWidget *pStatusBar = NULL, *Status_Box;
GtkWidget *CmdLine; //2002-09-28 (Florin)
GtkWidget *widgetCmdLine;
GtkWidget *LogDlg;
GtkWidget *FileSel;
GtkWidget *AboutDlg, *about_version , *about_authors, *about_greets;
void init_widgets();
GtkAccelGroup *AccelGroup;
GtkWidget *GameFixDlg, *SpeedHacksDlg, *AdvDlg;
#endif

104
pcsx2/Linux/HacksDlg.cpp Normal file
View File

@ -0,0 +1,104 @@
/* 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 "Linux.h"
GtkWidget *GameFixDlg, *SpeedHacksDlg;
void on_Game_Fixes(GtkMenuItem *menuitem, gpointer user_data)
{
GameFixDlg = create_GameFixDlg();
set_checked(GameFixDlg, "check_VU_Add_Sub", (Config.GameFixes & FLAG_VU_ADD_SUB));
set_checked(GameFixDlg, "check_FPU_Clamp", (Config.GameFixes & FLAG_FPU_CLAMP));
set_checked(GameFixDlg, "check_VU_Branch", (Config.GameFixes & FLAG_VU_BRANCH));
gtk_widget_show_all(GameFixDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Game_Fix_OK(GtkButton *button, gpointer user_data)
{
Config.GameFixes = 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_VU_Add_Sub") ? FLAG_VU_ADD_SUB : 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_FPU_Clamp") ? FLAG_FPU_CLAMP : 0;
Config.GameFixes |= is_checked(GameFixDlg, "check_VU_Branch") ? FLAG_VU_BRANCH : 0;
SaveConfig();
gtk_widget_destroy(GameFixDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void on_Speed_Hacks(GtkMenuItem *menuitem, gpointer user_data)
{
SpeedHacksDlg = create_SpeedHacksDlg();
switch (CHECK_EE_CYCLERATE)
{
case 0:
set_checked(SpeedHacksDlg, "check_default_cycle_rate", true);
break;
case 1:
set_checked(SpeedHacksDlg, "check_1_5_cycle_rate", true);
break;
case 2:
set_checked(SpeedHacksDlg, "check_2_cycle_rate", true);
break;
case 3:
set_checked(SpeedHacksDlg, "check_3_cycle_rate", true);
break;
default:
set_checked(SpeedHacksDlg, "check_default_cycle_rate", true);
break;
}
set_checked(SpeedHacksDlg, "check_iop_cycle_rate", CHECK_IOP_CYCLERATE);
set_checked(SpeedHacksDlg, "check_wait_cycles_sync_hack", CHECK_WAITCYCLE_HACK);
set_checked(SpeedHacksDlg, "check_ESC_hack", CHECK_ESCAPE_HACK);
gtk_widget_show_all(SpeedHacksDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_Speed_Hack_OK(GtkButton *button, gpointer user_data)
{
Config.Hacks = 0;
if is_checked(SpeedHacksDlg, "check_default_cycle_rate")
Config.Hacks = 0;
else if is_checked(SpeedHacksDlg, "check_1_5_cycle_rate")
Config.Hacks = 1;
else if is_checked(SpeedHacksDlg, "check_2_cycle_rate")
Config.Hacks = 2;
else if is_checked(SpeedHacksDlg, "check_3_cycle_rate")
Config.Hacks = 3;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_iop_cycle_rate") << 3;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_wait_cycles_sync_hack") << 4;
Config.Hacks |= is_checked(SpeedHacksDlg, "check_ESC_hack") << 10;
SaveConfig();
gtk_widget_destroy(SpeedHacksDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}

View File

@ -19,7 +19,7 @@
#ifndef __LINUX_H__
#define __LINUX_H__
#include <stdio.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdbool.h>
@ -35,7 +35,7 @@
#include <sys/time.h>
#include <pthread.h>
#include <pthread.h>
#include <X11/keysym.h>
#include <gtk/gtk.h>
@ -54,19 +54,31 @@
#include "x86/ix86/ix86.h"
#include "x86/iR5900.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "support.h"
#include "callbacks.h"
#include "interface.h"
#ifdef __cplusplus
}
#endif
/* Misc.c */
extern void vu0Shutdown();
extern void vu1Shutdown();
extern void SaveConfig();
extern bool UseGui;
extern int efile;
extern int g_SaveGSStream;
extern int g_ZeroGSOptions;
extern void FixCPUState(void);
/* LnxMain */
extern void InitLanguages();
extern char *GetLanguageNext();
extern void CloseLanguages();
@ -75,24 +87,23 @@ extern void StartGui();
extern void RunGui();
extern int Pcsx2Configure();
extern GtkWidget *CpuDlg;
extern void SysMessage(const char *fmt, ...);
/* Config.c */
extern int LoadConfig();
extern void SaveConfig();
/* GtkGui */
extern void init_widgets();
extern MemoryAlloc<u8>* g_RecoveryState;
extern void SysRestorableReset();
extern void SysDetect();
extern void RunExecute( const char* elf_file, bool use_bios = false);
void SignalExit(int sig);
extern void RunExecute(const char* elf_file, bool use_bios = false);
extern void ExecuteCpu();
extern bool g_ReturnToGui; // set to exit the execution of the emulator and return control to the GUI
extern bool g_EmulationInProgress; // Set TRUE if a game is actively running (set to false on reset)
typedef struct {
typedef struct
{
char lang[g_MaxPath];
} _langs;
@ -127,7 +138,7 @@ char cfgfile[g_MaxPath];
int Config_hacks_backup;
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
#define set_flag(v, flag, value) if (value == TRUE) v |= flag; else v &= flag;
@ -136,22 +147,23 @@ int Config_hacks_backup;
/*static __forceinline void print_flags(char *name, u32 num, char *flag_names[16])
{
int i;
DevCon::WriteLn("%s:", name);
if (flag_names != NULL)
{
for(i=0; i<=15; i++)
DevCon::WriteLn("%s %x: %x", params flag_names[i], (1<<i), get_flag(num, i));
}
else
else
{
for(i=0; i<=15; i++)
DevCon::WriteLn("%x: %x", params (1<<i), get_flag(num, i));
}
} */
char ee_log_names[17][32] = {
char ee_log_names[17][32] =
{
"Cpu Log",
"Mem Log",
"HW Log",
@ -168,9 +180,11 @@ char ee_log_names[17][32] = {
"Sif Log",
"IPU Log",
"VU Micro Log",
"RPC Log" };
char iop_log_names[9][32] = {
"RPC Log"
};
char iop_log_names[9][32] =
{
"IOP Log",
"Mem Log",
"HW Log",
@ -179,8 +193,9 @@ char iop_log_names[9][32] = {
"Pad Log",
"Gte Log",
"Cdr Log",
"GPU Log" };
"GPU Log"
};
#define FLAG_VU_ADD_SUB 0x1
#define FLAG_VU_CLIP 0x2
#define FLAG_FPU_CLAMP 0x4
@ -189,10 +204,10 @@ char iop_log_names[9][32] = {
#define FLAG_VU_NO_OVERFLOW 0x2
#define FLAG_VU_EXTRA_OVERFLOW 0x40
#define FLAG_FPU_NO_OVERFLOW 0x800
#define FLAG_FPU_EXTRA_OVERFLOW 0x1000
#define FLAG_EE_2_SYNC 0x1
#define FLAG_IOP_2_SYNC 0x10
#define FLAG_TRIPLE_SYNC 0x20

View File

@ -23,14 +23,14 @@
// Linux Note : The Linux Console is pretty simple. It just dumps to the stdio!
// (no console open/close/title stuff tho, so those functions are dummies)
// Fixme - A lot of extra \ns are being added in here somewhere. I think it's
// Fixme - A lot of extra \ns are being added in here somewhere. I think it's
// partially in SetColor/ClearColor, as colored lines have more extra \ns then the other
// lines.
namespace Console
{
static const char* tbl_color_codes[] =
{
"\033[30m" // black
static const char* tbl_color_codes[] =
{
"\033[30m" // black
, "\033[31m" // red
, "\033[32m" // green
, "\033[33m" // yellow
@ -38,108 +38,108 @@ namespace Console
, "\033[35m" // magenta
, "\033[36m" // cyan
, "\033[37m" // white!
};
};
void SetTitle( const string& title )
void SetTitle(const string& title)
{
}
void Open()
{
}
void Close()
{
}
__forceinline bool __fastcall Newline()
{
if (Config.PsxOut)
puts("\n");
if (emuLog != NULL)
{
fputs("\n", emuLog);
fflush(emuLog);
}
void Open()
{
}
return false;
}
void Close()
{
}
__forceinline bool __fastcall Write(const char* fmt)
{
if (Config.PsxOut)
puts(fmt);
__forceinline bool __fastcall Newline()
{
if (Config.PsxOut)
puts( "\n" );
if (emuLog != NULL)
fputs(fmt, emuLog);
if (emuLog != NULL)
{
fputs("\n", emuLog);
fflush( emuLog );
}
return false;
}
return false;
}
void __fastcall SetColor(Colors color)
{
Write(tbl_color_codes[color]);
}
__forceinline bool __fastcall Write( const char* fmt )
{
if (Config.PsxOut)
puts( fmt );
if (emuLog != NULL)
fputs(fmt, emuLog);
return false;
}
void __fastcall SetColor( Colors color )
{
Write( tbl_color_codes[color] );
}
void ClearColor()
{
Write( COLOR_RESET );
}
void ClearColor()
{
Write(COLOR_RESET);
}
}
namespace Msgbox
{
bool Alert (const char* fmt)
{
bool Alert(const char* fmt)
{
GtkWidget *dialog;
if (!UseGui)
{
GtkWidget *dialog;
if (!UseGui)
{
Console::Error( fmt );
return false;
}
dialog = gtk_message_dialog_new (GTK_WINDOW(MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, fmt);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return false;
Console::Error(fmt);
return false;
}
bool Alert(const char* fmt, VARG_PARAM dummy, ...)
{
GtkWidget *dialog;
string msg;
va_list list;
va_start(list, dummy);
vssprintf(msg, fmt, list);
va_end(list);
// fixme: using NULL terminators on std::string might work, but are technically "incorrect."
// This should use one of the std::string trimming functions instead.
if (msg[msg.length()-1] == '\n')
msg[msg.length()-1] = 0;
dialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, fmt);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (!UseGui)
{
Console::Error( msg.c_str() );
return false;
}
dialog = gtk_message_dialog_new (GTK_WINDOW(MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, msg.c_str());
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return false;
}
return false;
}
bool Alert(const char* fmt, VARG_PARAM dummy, ...)
{
GtkWidget *dialog;
string msg;
va_list list;
va_start(list, dummy);
vssprintf(msg, fmt, list);
va_end(list);
// fixme: using NULL terminators on std::string might work, but are technically "incorrect."
// This should use one of the std::string trimming functions instead.
if (msg[msg.length()-1] == '\n')
msg[msg.length()-1] = 0;
if (!UseGui)
{
Console::Error(msg.c_str());
return false;
}
dialog = gtk_message_dialog_new(GTK_WINDOW(MainWindow),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, msg.c_str());
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return false;
}
}

View File

@ -5,25 +5,23 @@
* 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 <sys/mman.h>
#include <sys/stat.h>
#include "LnxMain.h"
using namespace R5900;
DIR *dir;
GtkWidget *FileSel;
#ifdef PCSX2_DEVBUILD
TESTRUNARGS g_TestRun;
@ -31,14 +29,8 @@ TESTRUNARGS g_TestRun;
GtkWidget *MsgDlg;
static int sinit=0;
// These two status vars replace the old g_GameInProgress status var.
bool g_ReturnToGui = false; // set to exit the execution of the emulator and return control to the GUI
bool g_EmulationInProgress = false; // Set TRUE if a game is actively running (set to false on reset)
int main(int argc, char *argv[]) {
int main(int argc, char *argv[])
{
char *file = NULL;
char elfname[g_MaxPath];
int i = 1;
@ -59,79 +51,101 @@ int main(int argc, char *argv[]) {
memset(&g_TestRun, 0, sizeof(g_TestRun));
#endif
while(i < argc) {
while (i < argc)
{
char* token = argv[i++];
if( stricmp(token, "-help") == 0 || stricmp(token, "--help") == 0 || stricmp(token, "-h") == 0 ) {
if (stricmp(token, "-help") == 0 || stricmp(token, "--help") == 0 || stricmp(token, "-h") == 0)
{
//Msgbox::Alert( phelpmsg );
return 0;
}
else if( stricmp(token, "-efile") == 0 ) {
else if (stricmp(token, "-efile") == 0)
{
token = argv[i++];
if( token != NULL ) {
if (token != NULL)
{
efile = atoi(token);
}
}
else if( stricmp(token, "-nogui") == 0 ) {
else if (stricmp(token, "-nogui") == 0)
{
UseGui = FALSE;
}
else if( stricmp(token, "-loadgs") == 0 ) {
else if (stricmp(token, "-loadgs") == 0)
{
g_pRunGSState = argv[i++];
}
#ifdef PCSX2_DEVBUILD
else if( stricmp(token, "-image") == 0 ) {
else if (stricmp(token, "-image") == 0)
{
g_TestRun.pimagename = argv[i++];
}
else if( stricmp(token, "-log") == 0 ) {
else if (stricmp(token, "-log") == 0)
{
g_TestRun.plogname = argv[i++];
}
else if( stricmp(token, "-logopt") == 0 ) {
else if (stricmp(token, "-logopt") == 0)
{
token = argv[i++];
if( token != NULL ) {
if( token[0] == '0' && token[1] == 'x' ) token += 2;
if (token != NULL)
{
if (token[0] == '0' && token[1] == 'x') token += 2;
sscanf(token, "%x", &varLog);
}
}
else if( stricmp(token, "-frame") == 0 ) {
else if (stricmp(token, "-frame") == 0)
{
token = argv[i++];
if( token != NULL ) {
if (token != NULL)
{
g_TestRun.frame = atoi(token);
}
}
else if( stricmp(token, "-numimages") == 0 ) {
else if (stricmp(token, "-numimages") == 0)
{
token = argv[i++];
if( token != NULL ) {
if (token != NULL)
{
g_TestRun.numimages = atoi(token);
}
}
else if( stricmp(token, "-jpg") == 0 ) {
else if (stricmp(token, "-jpg") == 0)
{
g_TestRun.jpgcapture = 1;
}
else if( stricmp(token, "-gs") == 0 ) {
else if (stricmp(token, "-gs") == 0)
{
token = argv[i++];
g_TestRun.pgsdll = token;
}
else if( stricmp(token, "-cdvd") == 0 ) {
else if (stricmp(token, "-cdvd") == 0)
{
token = argv[i++];
g_TestRun.pcdvddll = token;
}
else if( stricmp(token, "-spu") == 0 ) {
else if (stricmp(token, "-spu") == 0)
{
token = argv[i++];
g_TestRun.pspudll = token;
}
else if( stricmp(token, "-test") == 0 ) {
else if (stricmp(token, "-test") == 0)
{
g_TestRun.enabled = 1;
}
#endif
else if( stricmp(token, "-pad") == 0 ) {
else if (stricmp(token, "-pad") == 0)
{
token = argv[i++];
printf("-pad ignored\n");
}
else if( stricmp(token, "-loadgs") == 0 ) {
else if (stricmp(token, "-loadgs") == 0)
{
token = argv[i++];
g_pRunGSState = token;
}
else {
else
{
file = token;
printf("opening file %s\n", file);
}
@ -143,16 +157,19 @@ int main(int argc, char *argv[]) {
#endif
// make gtk thread safe if using MTGS
if( CHECK_MULTIGS ) {
if (CHECK_MULTIGS)
{
g_thread_init(NULL);
gdk_threads_init();
}
if (UseGui) {
if (UseGui)
{
gtk_init(NULL, NULL);
}
if (LoadConfig() == -1) {
if (LoadConfig() == -1)
{
memset(&Config, 0, sizeof(Config));
strcpy(Config.BiosDir, DEFAULT_BIOS_DIR "/");
@ -168,9 +185,10 @@ int main(int argc, char *argv[]) {
return 0;
}
InitLanguages();
if( Config.PsxOut ) {
InitLanguages();
if (Config.PsxOut)
{
// output the help commands
Console::WriteLn("\tF1 - save state");
Console::WriteLn("\t(Shift +) F2 - cycle states");
@ -186,14 +204,16 @@ int main(int argc, char *argv[]) {
if (!SysInit()) return 1;
#ifdef PCSX2_DEVBUILD
if( g_pRunGSState ) {
if (g_pRunGSState)
{
LoadGSState(g_pRunGSState);
SysClose();
return 0;
}
#endif
if (UseGui && (file == NULL)) {
if (UseGui && (file == NULL))
{
StartGui();
return 0;
}
@ -205,7 +225,7 @@ int main(int argc, char *argv[]) {
FixCPUState();
cpuExecuteBios();
if (file) strcpy(elfname, file);
if (!efile) efile=GetPS2ElfName(elfname);
if (!efile) efile = GetPS2ElfName(elfname);
loadElfFile(elfname);
ExecuteCpu();
@ -213,33 +233,38 @@ int main(int argc, char *argv[]) {
return 0;
}
void InitLanguages() {
void InitLanguages()
{
char *lang;
int i = 1;
if (Config.Lang[0] == 0) {
if (Config.Lang[0] == 0)
{
strcpy(Config.Lang, "en");
}
langs = (_langs*)malloc(sizeof(_langs));
strcpy(langs[0].lang, "en");
dir = opendir(LANGS_DIR);
while ((lang = GetLanguageNext()) != NULL) {
langs = (_langs*)realloc(langs, sizeof(_langs)*(i+1));
while ((lang = GetLanguageNext()) != NULL)
{
langs = (_langs*)realloc(langs, sizeof(_langs) * (i + 1));
strcpy(langs[i].lang, lang);
i++;
}
CloseLanguages();
langsMax = i;
}
char *GetLanguageNext() {
char *GetLanguageNext()
{
struct dirent *ent;
if (dir == NULL) return NULL;
for (;;) {
for (;;)
{
ent = readdir(dir);
if (ent == NULL) return NULL;
@ -251,251 +276,354 @@ char *GetLanguageNext() {
return ent->d_name;
}
void CloseLanguages() {
void CloseLanguages()
{
if (dir) closedir(dir);
}
void ChangeLanguage(char *lang) {
strcpy(Config.Lang, lang);
void ChangeLanguage(char *lang)
{
strcpy(Config.Lang, lang);
SaveConfig();
}
/* Quick macros for checking shift, control, alt, and caps lock. */
#define SHIFT_EVT(evt) ((evt == XK_Shift_L) || (evt == XK_Shift_R))
#define CTRL_EVT(evt) ((evt == XK_Control_L) || (evt == XK_Control_L))
#define ALT_EVT(evt) ((evt == XK_Alt_L) || (evt == XK_Alt_R))
#define CAPS_LOCK_EVT(evt) (evt == XK_Caps_Lock)
void KeyEvent(keyEvent* ev) {
static int shift = 0;
if (ev == NULL) return;
if( GSkeyEvent != NULL ) GSkeyEvent(ev);
if (ev->evt == KEYPRESS)
{
if (SHIFT_EVT(ev->key))
shift = 1;
if (CAPS_LOCK_EVT(ev->key))
{
//Set up anything we want to happen while caps lock is down.
//Config_hacks_backup = Config.Hacks;
}
switch (ev->key)
{
case XK_F1: case XK_F2: case XK_F3: case XK_F4:
case XK_F5: case XK_F6: case XK_F7: case XK_F8:
case XK_F9: case XK_F10: case XK_F11: case XK_F12:
try
{
ProcessFKeys(ev->key-XK_F1 + 1, shift);
}
catch( Exception::CpuStateShutdown& )
{
// Woops! Something was unrecoverable. Bummer.
// Let's give the user a RunGui!
g_EmulationInProgress = false;
g_ReturnToGui = true;
}
break;
case XK_Escape:
signal(SIGINT, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
#ifdef PCSX2_DEVBUILD
if( g_SaveGSStream >= 3 ) {
g_SaveGSStream = 4;// gs state
break;
}
#endif
ClosePlugins();
if (!UseGui) exit(0);
// fixme: The GUI is now capable of recieving control back from the
// emulator. Which means that when I set g_ReturnToGui here, the emulation
// loop in ExecuteCpu() will exit. You should be able to set it up so
// that it returns control to the existing GTK event loop, instead of
// always starting a new one via RunGui(). (but could take some trial and
// error) -- (air)
g_ReturnToGui = true;
RunGui();
break;
default:
GSkeyEvent(ev);
break;
}
}
else if (ev->evt == KEYRELEASE)
{
if (SHIFT_EVT(ev->key))
shift = 0;
if (CAPS_LOCK_EVT(ev->key))
{
//Release caps lock
//Config_hacks_backup = Config.Hacks;
}
}
return;
}
void OnMsg_Ok() {
void OnMsg_Ok()
{
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
}
void SysMessage(const char *fmt, ...) {
va_list list;
char msg[512];
va_start(list,fmt);
vsnprintf(msg,511,fmt,list);
msg[511] = '\0';
va_end(list);
Msgbox::Alert(msg);
void On_Dialog_Cancelled(GtkButton* button, gpointer user_data)
{
gtk_widget_destroy((GtkWidget*)gtk_widget_get_toplevel((GtkWidget*)button));
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
bool SysInit()
void StartGui()
{
if( sinit ) return true;
sinit = true;
mkdir(SSTATES_DIR, 0755);
mkdir(MEMCARDS_DIR, 0755);
GtkWidget *Menu;
GtkWidget *Item;
mkdir(LOGS_DIR, 0755);
u32 i;
#ifdef PCSX2_DEVBUILD
if( g_TestRun.plogname != NULL )
emuLog = fopen(g_TestRun.plogname, "w");
if( emuLog == NULL )
emuLog = fopen(LOGS_DIR "/emuLog.txt","wb");
add_pixmap_directory(".pixmaps");
MainWindow = create_MainWindow();
if (SVN_REV != 0)
gtk_window_set_title(GTK_WINDOW(MainWindow), "PCSX2 "PCSX2_VERSION" "SVN_REV);
else
gtk_window_set_title(GTK_WINDOW(MainWindow), "PCSX2 "PCSX2_VERSION);
// status bar
pStatusBar = gtk_statusbar_new();
gtk_box_pack_start(GTK_BOX(lookup_widget(MainWindow, "status_box")), pStatusBar, TRUE, TRUE, 0);
gtk_widget_show(pStatusBar);
gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), 0,
"F1 - save, F2 - next state, Shift+F2 - prev state, F3 - load, F8 - snapshot");
// add all the languages
Item = lookup_widget(MainWindow, "GtkMenuItem_Language");
Menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(Item), Menu);
for (i = 0; i < langsMax; i++)
{
Item = gtk_check_menu_item_new_with_label(ParseLang(langs[i].lang));
gtk_widget_show(Item);
gtk_container_add(GTK_CONTAINER(Menu), Item);
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(Item), TRUE);
if (!strcmp(Config.Lang, langs[i].lang))
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(Item), TRUE);
gtk_signal_connect(GTK_OBJECT(Item), "activate",
GTK_SIGNAL_FUNC(OnLanguage),
(gpointer)(uptr)i);
}
// check the appropriate menu items
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(MainWindow, "enable_console1")), Config.PsxOut);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(MainWindow, "enable_patches1")), Config.Patch);
// disable anything not implemented or not working properly.
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_browser1")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "patch_finder2")), FALSE);
#ifndef PCSX2_DEVBUILD
gtk_widget_set_sensitive(GTK_WIDGET(lookup_widget(MainWindow, "GtkMenuItem_Logging")), FALSE);
#endif
if( emuLog != NULL )
setvbuf(emuLog, NULL, _IONBF, 0);
gtk_widget_show_all(MainWindow);
gtk_window_activate_focus(GTK_WINDOW(MainWindow));
gtk_main();
}
PCSX2_MEM_PROTECT_BEGIN();
SysDetect();
if( !SysAllocateMem() )
return false; // critical memory allocation failure;
void RunGui()
{
StartGui();
}
SysAllocateDynarecs();
PCSX2_MEM_PROTECT_END();
void FixCPUState(void)
{
//Config.sseMXCSR = LinuxsseMXCSR;
//Config.sseVUMXCSR = LinuxsseVUMXCSR;
SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR);
}
while (LoadPlugins() == -1) {
if (Pcsx2Configure() == FALSE)
void OnDestroy(GtkObject *object, gpointer user_data) {}
gboolean OnDelete(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
pcsx2_exit();
return (FALSE);
}
int Pcsx2Configure()
{
if (!UseGui) return 0;
configuringplug = TRUE;
MainWindow = NULL;
OnConf_Conf(NULL, 0);
configuringplug = FALSE;
return applychanges;
}
void OnLanguage(GtkMenuItem *menuitem, gpointer user_data)
{
ChangeLanguage(langs[(int)(uptr)user_data].lang);
gtk_widget_destroy(MainWindow);
gtk_main_quit();
while (gtk_events_pending()) gtk_main_iteration();
StartGui();
}
void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data)
{
safe_free(g_RecoveryState);
ResetPlugins();
RunExecute(NULL);
}
void OnRunElf_Ok(GtkButton* button, gpointer user_data)
{
gchar *File;
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(elfname, File);
gtk_widget_destroy(FileSel);
RunExecute(elfname);
}
void OnRunElf_Cancel(GtkButton* button, gpointer user_data)
{
gtk_widget_destroy(FileSel);
}
void OnFile_LoadElf(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *Ok, *Cancel;
FileSel = gtk_file_selection_new("Select Psx Elf File");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnRunElf_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnRunElf_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
void pcsx2_exit()
{
DIR *dir;
struct dirent *ent;
void *Handle;
char plugin[g_MaxPath];
// with this the problem with plugins that are linked with the pthread
// library is solved
dir = opendir(Config.PluginsDir);
if (dir != NULL)
{
while ((ent = readdir(dir)) != NULL)
{
Msgbox::Alert("Configuration failed. Exiting.");
exit(1);
sprintf(plugin, "%s%s", Config.PluginsDir, ent->d_name);
if (strstr(plugin, ".so") == NULL) continue;
Handle = dlopen(plugin, RTLD_NOW);
if (Handle == NULL) continue;
}
}
return true;
}
void SysRestorableReset()
{
// already reset? and saved?
if( !g_EmulationInProgress ) return;
if( g_RecoveryState != NULL ) return;
printf("PCSX2 Quitting\n");
try
if (UseGui)
{
g_RecoveryState = new MemoryAlloc<u8>( "Memory Savestate Recovery" );
memSavingState( *g_RecoveryState ).FreezeAll();
cpuShutdown();
g_EmulationInProgress = false;
gtk_main_quit();
SysClose();
gtk_exit(0);
}
catch( Exception::RuntimeError& ex )
else
{
Msgbox::Alert(
"Pcsx2 gamestate recovery failed. Some options may have been reverted to protect your game's state.\n"
"Error: %s", params ex.cMessage() );
safe_delete( g_RecoveryState );
SysClose();
exit(0);
}
}
void SysReset()
void SignalExit(int sig)
{
if (!sinit) return;
g_EmulationInProgress = false;
safe_free( g_RecoveryState );
ResetPlugins();
ElfCRC = 0;
}
void SysClose() {
if (sinit == 0) return;
cpuShutdown();
ClosePlugins();
ReleasePlugins();
pcsx2_exit();
}
if (emuLog != NULL)
void OnFile_Exit(GtkMenuItem *menuitem, gpointer user_data)
{
pcsx2_exit();
}
void OnEmu_Run(GtkMenuItem *menuitem, gpointer user_data)
{
if (g_EmulationInProgress)
ExecuteCpu();
else
RunExecute(NULL, true); // boots bios if no savestate is to be recovered
}
void OnEmu_Reset(GtkMenuItem *menuitem, gpointer user_data)
{
SysReset();
}
void ResetMenuSlots(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *Item;
char str[g_MaxPath];
int i;
for (i = 0; i < 5; i++)
{
fclose(emuLog);
emuLog = NULL;
sprintf(str, "GtkMenuItem_LoadSlot%d", i + 1);
Item = lookup_widget(MainWindow, str);
if (Slots[i] == -1)
gtk_widget_set_sensitive(Item, FALSE);
else
gtk_widget_set_sensitive(Item, TRUE);
}
sinit=0;
}
void SysPrintf(const char *fmt, ...) {
va_list list;
char msg[512];
/*void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) {
char str[g_MaxPath];
int i = 0;
va_start(list,fmt);
vsnprintf(msg,511,fmt,list);
msg[511] = '\0';
va_end(list);
for (i=0; i<5; i++) {
sprintf(str, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, i);
Slots[i] = CheckState(str);
}
}*/
Console::Write( msg );
}
void *SysLoadLibrary(const char *lib) {
return dlopen(lib, RTLD_NOW);
}
void *SysLoadSym(void *lib, const char *sym) {
return dlsym(lib, sym);
}
const char *SysLibError() {
return dlerror();
}
void SysCloseLibrary(void *lib) {
dlclose(lib);
}
void SysUpdate() {
KeyEvent(PAD1keyEvent());
KeyEvent(PAD2keyEvent());
}
void SysRunGui() {
RunGui();
}
void *SysMmap(uptr base, u32 size)
//2002-09-28 (Florin)
void OnArguments_Ok(GtkButton *button, gpointer user_data)
{
u8 *Mem;
Mem = mmap((uptr*)base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (Mem == MAP_FAILED) Console::Notice("Mmap Failed!");
return Mem;
char *str;
str = (char*)gtk_entry_get_text(GTK_ENTRY(widgetCmdLine));
memcpy(args, str, g_MaxPath);
gtk_widget_destroy(CmdLine);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void SysMunmap(uptr base, u32 size)
void OnEmu_Arguments(GtkMenuItem *menuitem, gpointer user_data)
{
munmap((uptr*)base, size);
GtkWidget *widgetCmdLine;
CmdLine = create_CmdLine();
gtk_window_set_title(GTK_WINDOW(CmdLine), _("Program arguments"));
widgetCmdLine = lookup_widget(CmdLine, "GtkEntry_dCMDLINE");
gtk_entry_set_text(GTK_ENTRY(widgetCmdLine), args);
gtk_widget_show_all(CmdLine);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void OnLogging_Ok(GtkButton *button, gpointer user_data)
{
#ifdef PCSX2_DEVBUILD
GtkWidget *Btn;
char str[32];
int i, ret;
for (i = 0; i < 32; i++)
{
if (((i > 16) && (i < 20)) || (i == 29))
continue;
sprintf(str, "Log%d", i);
Btn = lookup_widget(LogDlg, str);
ret = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Btn));
if (ret) varLog |= 1 << i;
else varLog &= ~(1 << i);
}
SaveConfig();
#endif
gtk_widget_destroy(LogDlg);
gtk_widget_set_sensitive(MainWindow, TRUE);
gtk_main_quit();
}
void OnDebug_Logging(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *Btn;
char str[32];
int i;
LogDlg = create_Logging();
for (i = 0; i < 32; i++)
{
if (((i > 16) && (i < 20)) || (i == 29))
continue;
sprintf(str, "Log%d", i);
Btn = lookup_widget(LogDlg, str);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(Btn), varLog & (1 << i));
}
gtk_widget_show_all(LogDlg);
gtk_widget_set_sensitive(MainWindow, FALSE);
gtk_main();
}
void on_patch_browser1_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_patch_finder2_activate(GtkMenuItem *menuitem, gpointer user_data) {}
void on_enable_console1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
Config.PsxOut = (int)gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
SaveConfig();
}
void on_enable_patches1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
Config.Patch = (int)gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
SaveConfig();
}

View File

@ -15,39 +15,76 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __LNXMAIN_H__
#define __LNXMAIN_H__
#include "Linux.h"
char* g_pRunGSState = NULL;
extern char* g_pRunGSState;
const char* phelpmsg =
"\tpcsx2 [options] [file]\n\n"
"-cfg [file] {configuration file}\n"
"-efile [efile] {0 - reset, 1 - runcd (default), 2 - loadelf}\n"
"-help {display this help file}\n"
"-nogui {Don't use gui when launching}\n"
"-loadgs [file} {Loads a gsstate}\n"
"\n"
void SignalExit(int sig);
bool applychanges = FALSE;
bool configuringplug = FALSE;
extern bool UseGui;
extern MemoryAlloc<u8>* g_RecoveryState;
extern bool g_ReturnToGui; // set to exit the execution of the emulator and return control to the GUI
extern bool g_EmulationInProgress; // Set TRUE if a game is actively running (set to false on reset)
int efile = 0;
char elfname[g_MaxPath];
int Slots[5] = { -1, -1, -1, -1, -1 };
GtkWidget *CpuDlg;
// 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 OnLanguage(GtkMenuItem *menuitem, gpointer user_data);
void OnHelp_Help();
void OnHelp_About(GtkMenuItem *menuitem, gpointer user_data);
void ExecuteCpu();
void StartGui();
void pcsx2_exit();
GtkWidget *MainWindow;
GtkWidget *pStatusBar = NULL, *Status_Box;
GtkWidget *CmdLine; //2002-09-28 (Florin)
GtkWidget *widgetCmdLine;
GtkWidget *LogDlg;
void init_widgets();
GtkAccelGroup *AccelGroup;
const char* phelpmsg =
"\tpcsx2 [options] [file]\n\n"
"-cfg [file] {configuration file}\n"
"-efile [efile] {0 - reset, 1 - runcd (default), 2 - loadelf}\n"
"-help {display this help file}\n"
"-nogui {Don't use gui when launching}\n"
"-loadgs [file} {Loads a gsstate}\n"
"\n"
#ifdef PCSX2_DEVBUILD
"Testing Options: \n"
"\t-frame [frame] {game will run up to this frame before exiting}\n"
"\t-image [name] {path and base name of image (do not include the .ext)}\n"
"\t-jpg {save images to jpg format}\n"
"\t-log [name] {log path to save log file in}\n"
"\t-logopt [hex] {log options in hex (see debug.h) }\n"
"\t-numimages [num] {after hitting frame, this many images will be captures every 20 frames}\n"
"\t-test {Triggers testing mode (only for dev builds)}\n"
"\n"
"Testing Options: \n"
"\t-frame [frame] {game will run up to this frame before exiting}\n"
"\t-image [name] {path and base name of image (do not include the .ext)}\n"
"\t-jpg {save images to jpg format}\n"
"\t-log [name] {log path to save log file in}\n"
"\t-logopt [hex] {log options in hex (see debug.h) }\n"
"\t-numimages [num] {after hitting frame, this many images will be captures every 20 frames}\n"
"\t-test {Triggers testing mode (only for dev builds)}\n"
"\n"
#endif
"Load Plugins:\n"
"\t-cdvd [libpath] {specify the library load path of the CDVD plugin}\n"
"\t-gs [libpath] {specify the library load path of the GS plugin}\n"
"-pad [tsxcal] {specify to hold down on the triangle, square, circle, x, start, select buttons}\n"
"\t-spu [libpath] {specify the library load path of the SPU2 plugin}\n"
"\n";
#endif
"Load Plugins:\n"
"\t-cdvd [libpath] {specify the library load path of the CDVD plugin}\n"
"\t-gs [libpath] {specify the library load path of the GS plugin}\n"
"-pad [tsxcal] {specify to hold down on the triangle, square, circle, x, start, select buttons}\n"
"\t-spu [libpath] {specify the library load path of the SPU2 plugin}\n"
"\n";
#endif

792
pcsx2/Linux/LnxSysExec.cpp Normal file
View File

@ -0,0 +1,792 @@
/* 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 "Linux.h"
#include <sys/mman.h>
#include <sys/stat.h>
bool UseGui = true;
MemoryAlloc<u8>* g_RecoveryState = NULL;
MemoryAlloc<u8>* g_gsRecoveryState = NULL;
const char* g_pRunGSState = NULL;
bool g_ReturnToGui = false; // set to exit the execution of the emulator and return control to the GUI
bool g_EmulationInProgress = false; // Set TRUE if a game is actively running (set to false on reset)
static bool sinit = false;
GtkWidget *FileSel;
void SysPrintf(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsnprintf(msg, 511, fmt, list);
msg[511] = '\0';
va_end(list);
Console::Write(msg);
}
static void KeyEvent(keyEvent* ev);
void SysUpdate()
{
KeyEvent(PAD1keyEvent());
KeyEvent(PAD2keyEvent());
}
static void TryRecoverFromGsState()
{
if( g_gsRecoveryState != NULL )
{
s32 dummylen;
memLoadingState eddie( *g_gsRecoveryState );
eddie.FreezePlugin( "GS", gsSafeFreeze );
eddie.Freeze( dummylen ); // reads the length value recorded earlier.
eddie.gsFreeze();
}
}
void ExecuteCpu()
{
// Make sure any left-over recovery states are cleaned up.
safe_delete( g_RecoveryState );
// Just in case they weren't initialized earlier (no harm in calling this multiple times)
if (OpenPlugins(NULL) == -1) return;
// this needs to be called for every new game!
// (note: sometimes launching games through bios will give a crc of 0)
if( GSsetGameCRC != NULL ) GSsetGameCRC(ElfCRC, g_ZeroGSOptions);
TryRecoverFromGsState();
safe_delete( g_gsRecoveryState );
// Destroy the window. Ugly thing.
gtk_widget_destroy(MainWindow);
gtk_main_quit();
while (gtk_events_pending()) gtk_main_iteration();
g_EmulationInProgress = true;
g_ReturnToGui = false;
signal(SIGINT, SignalExit);
signal(SIGPIPE, SignalExit);
// Optimization: We hardcode two versions of the EE here -- one for recs and one for ints.
// This is because recs are performance critical, and being able to inline them into the
// function here helps a small bit (not much but every small bit counts!).
if (CHECK_EEREC)
{
while (!g_ReturnToGui)
{
recExecute();
SysUpdate();
}
}
else
{
while (!g_ReturnToGui)
{
Cpu->Execute();
SysUpdate();
}
}
}
// Runs an ELF image directly (ISO or ELF program or BIN)
// Used by Run::FromCD and such
void RunExecute(const char* elf_file, bool use_bios)
{
// (air notes:)
// If you want to use the new to-memory savestate feature, take a look at the new
// RunExecute in WinMain.c, and secondly the CpuDlg.c or AdvancedDlg.cpp. The
// objects used are MemoryAlloc, memLoadingState, and memSavingState.
// It's important to make sure to reset the CPU and the plugins correctly, which is
// where the new RunExecute comes into play. It can be kind of tricky knowing
// when to call cpuExecuteBios and loadElfFile, and with what parameters.
// (or, as an alternative maybe we should switch to wxWidgets and have a unified
// cross platform gui?) - Air
// Sounds like a good idea, at this point.
try
{
cpuReset();
}
catch( Exception::BaseException& ex )
{
Msgbox::Alert( ex.cMessage() );
return;
}
if (OpenPlugins(NULL) == -1)
{
RunGui();
return;
}
if (elf_file == NULL)
{
if (g_RecoveryState != NULL)
{
try
{
memLoadingState(*g_RecoveryState).FreezeAll();
}
catch (std::runtime_error& ex)
{
Msgbox::Alert(
"Gamestate recovery failed. Your game progress will be lost (sorry!)\n"
"\nError: %s\n", params ex.what());
// Take the user back to the GUI...
safe_delete(g_RecoveryState);
ClosePlugins();
return;
}
safe_delete(g_RecoveryState);
}
else if( g_gsRecoveryState == NULL )
{
// Not recovering a state, so need to execute the bios and load the ELF information.
// if the elf_file is null we use the CDVD elf file.
// But if the elf_file is an empty string then we boot the bios instead.
char ename[g_MaxPath];
ename[0] = 0;
if (!use_bios) GetPS2ElfName(ename);
loadElfFile(ename);
}
}
else
{
// Custom ELF specified (not using CDVD).
// Run the BIOS and load the ELF.
loadElfFile(elf_file);
}
//FixCPUState();
ExecuteCpu();
}
class RecoveryMemSavingState : public memSavingState, Sealed
{
public:
virtual ~RecoveryMemSavingState() { }
RecoveryMemSavingState() : memSavingState( *g_RecoveryState )
{
}
void gsFreeze()
{
if (g_gsRecoveryState != NULL)
{
// just copy the data from src to dst.
// the normal savestate doesn't expect a length prefix for internal structures,
// so don't copy that part.
const u32 pluginlen = *((u32*)g_gsRecoveryState->GetPtr());
const u32 gslen = *((u32*)g_gsRecoveryState->GetPtr(pluginlen+4));
memcpy( m_memory.GetPtr(m_idx), g_gsRecoveryState->GetPtr(pluginlen+8), gslen );
m_idx += gslen;
}
else
memSavingState::gsFreeze();
}
void FreezePlugin( const char* name, s32 (CALLBACK* freezer)(int mode, freezeData *data) )
{
if ((freezer == gsSafeFreeze) && (g_gsRecoveryState != NULL))
{
// Gs data is already in memory, so just copy from src to dest:
// length of the GS data is stored as the first u32, so use that to run the copy:
const u32 len = *((u32*)g_gsRecoveryState->GetPtr());
memcpy( m_memory.GetPtr(m_idx), g_gsRecoveryState->GetPtr(), len+4 );
m_idx += len+4;
}
else
memSavingState::FreezePlugin( name, freezer );
}
};
class RecoveryZipSavingState : public gzSavingState, Sealed
{
public:
virtual ~RecoveryZipSavingState() { }
RecoveryZipSavingState( const string& filename ) : gzSavingState( filename )
{
}
void gsFreeze()
{
if (g_gsRecoveryState != NULL)
{
// read data from the gsRecoveryState allocation instead of the GS, since the gs
// info was invalidated when the plugin was shut down.
// the normal savestate doesn't expect a length prefix for internal structures,
// so don't copy that part.
u32& pluginlen = *((u32*)g_gsRecoveryState->GetPtr(0));
u32& gslen = *((u32*)g_gsRecoveryState->GetPtr(pluginlen+4));
gzwrite( m_file, g_gsRecoveryState->GetPtr(pluginlen+4), gslen );
}
else
gzSavingState::gsFreeze();
}
void FreezePlugin( const char* name, s32 (CALLBACK* freezer)(int mode, freezeData *data) )
{
if ((freezer == gsSafeFreeze) && (g_gsRecoveryState != NULL))
{
// Gs data is already in memory, so just copy from there into the gzip file.
// length of the GS data is stored as the first u32, so use that to run the copy:
u32& len = *((u32*)g_gsRecoveryState->GetPtr());
gzwrite( m_file, g_gsRecoveryState->GetPtr(), len+4 );
}
else
gzSavingState::FreezePlugin( name, freezer );
}
};
void States_Load(const string& file, int num = -1)
{
if( !Path::isFile( file ) )
{
Console::Notice( "Saveslot %d is empty.", params num );
return;
}
try
{
char Text[g_MaxPath];
gzLoadingState joe( file ); // this'll throw an StateLoadError_Recoverable.
// Make sure the cpu and plugins are ready to be state-ified!
cpuReset();
OpenPlugins( NULL );
joe.FreezeAll();
if( num != -1 )
sprintf (Text, _("*PCSX2*: Loaded State %d"), num);
else
sprintf (Text, _("*PCSX2*: Loaded State %s"), file.c_str());
//StatusBar_Notice( Text );
Console::Notice(Text);
if( GSsetGameCRC != NULL ) GSsetGameCRC(ElfCRC, g_ZeroGSOptions);
}
catch( Exception::StateLoadError_Recoverable& ex)
{
if( num != -1 )
Console::Notice( "Could not load savestate from slot %d.\n\n%s", params num, ex.cMessage() );
else
Console::Notice( "Could not load savestate file: %s.\n\n%s", params file.c_str(), ex.cMessage() );
// At this point the cpu hasn't been reset, so we can return
// control to the user safely... (that's why we use a console notice instead of a popup)
return;
}
catch( Exception::BaseException& ex )
{
// The emulation state is ruined. Might as well give them a popup and start the gui.
string message;
if( num != -1 )
ssprintf( message,
"Encountered an error while loading savestate from slot %d.\n", num );
else
ssprintf( message,
"Encountered an error while loading savestate from file: %s.\n", file.c_str() );
if( g_EmulationInProgress )
message += "Since the savestate load was incomplete, the emulator has been reset.\n";
message += "\nError: " + ex.Message();
Msgbox::Alert( message.c_str() );
SysClose();
return;
}
// Start emulating!
ExecuteCpu();
}
void States_Load(int num)
{
States_Load( SaveState::GetFilename( num ), num );
}
void States_Save( const string& file, int num = -1 )
{
try
{
string text;
RecoveryZipSavingState( file ).FreezeAll();
if( num != -1 )
ssprintf( text, _( "State saved to slot %d" ), num );
else
ssprintf( text, _( "State saved to file: %s" ), file.c_str() );
Console::Notice(text.c_str());
}
catch( Exception::BaseException& ex )
{
string message;
if( num != -1 )
ssprintf( message, "An error occurred while trying to save to slot %d\n", num );
else
ssprintf( message, "An error occurred while trying to save to file: %s\n", file.c_str() );
message += "Your emulation state has not been saved!\n\nError: " + ex.Message();
Console::Error( message.c_str() );
}
}
void States_Save(int num)
{
if( g_RecoveryState != NULL )
{
// State is already saved into memory, and the emulator (and in-progress flag)
// have likely been cleared out. So save from the Recovery buffer instead of
// doing a "standard" save:
string text;
SaveState::GetFilename( text, num );
gzFile fileptr = gzopen( text.c_str(), "wb" );
if( fileptr == NULL )
{
Msgbox::Alert( _("File permissions error while trying to save to slot %d"), params num );
return;
}
gzwrite( fileptr, &g_SaveVersion, sizeof( u32 ) );
gzwrite( fileptr, g_RecoveryState->GetPtr(), g_RecoveryState->GetSizeInBytes() );
gzclose( fileptr );
return;
}
if( !g_EmulationInProgress )
{
Msgbox::Alert( "You need to start a game first before you can save it's state." );
return;
}
States_Save( SaveState::GetFilename( num ), num );
}
class JustGsSavingState : public memSavingState, Sealed
{
public:
virtual ~JustGsSavingState() { }
JustGsSavingState() : memSavingState( *g_gsRecoveryState )
{
}
// This special override saves the gs info to m_idx+4, and then goes back and
// writes in the length of data saved.
void gsFreeze()
{
int oldmidx = m_idx;
m_idx += 4;
memSavingState::gsFreeze();
if( IsSaving() )
{
s32& len = *((s32*)m_memory.GetPtr( oldmidx ));
len = (m_idx - oldmidx)-4;
}
}
};
void OnStates_Load1(GtkMenuItem *menuitem, gpointer user_data)
{
States_Load(0);
}
void OnStates_Load2(GtkMenuItem *menuitem, gpointer user_data)
{
States_Load(1);
}
void OnStates_Load3(GtkMenuItem *menuitem, gpointer user_data)
{
States_Load(2);
}
void OnStates_Load4(GtkMenuItem *menuitem, gpointer user_data)
{
States_Load(3);
}
void OnStates_Load5(GtkMenuItem *menuitem, gpointer user_data)
{
States_Load(4);
}
void OnLoadOther_Ok(GtkButton* button, gpointer user_data)
{
gchar *File;
char str[g_MaxPath];
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(str, File);
gtk_widget_destroy(FileSel);
States_Load(str);
}
void OnLoadOther_Cancel(GtkButton* button, gpointer user_data)
{
gtk_widget_destroy(FileSel);
}
void OnStates_LoadOther(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *Ok, *Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnLoadOther_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnLoadOther_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
void OnStates_Save1(GtkMenuItem *menuitem, gpointer user_data)
{
States_Save(0);
}
void OnStates_Save2(GtkMenuItem *menuitem, gpointer user_data)
{
States_Save(1);
}
void OnStates_Save3(GtkMenuItem *menuitem, gpointer user_data)
{
States_Save(2);
}
void OnStates_Save4(GtkMenuItem *menuitem, gpointer user_data)
{
States_Save(3);
}
void OnStates_Save5(GtkMenuItem *menuitem, gpointer user_data)
{
States_Save(4);
}
void OnSaveOther_Ok(GtkButton* button, gpointer user_data)
{
gchar *File;
char str[g_MaxPath];
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
strcpy(str, File);
gtk_widget_destroy(FileSel);
States_Save(str);
}
void OnSaveOther_Cancel(GtkButton* button, gpointer user_data)
{
gtk_widget_destroy(FileSel);
}
void OnStates_SaveOther(GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *Ok, *Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnSaveOther_Ok), NULL);
gtk_widget_show(Ok);
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnSaveOther_Cancel), NULL);
gtk_widget_show(Cancel);
gtk_widget_show(FileSel);
gdk_window_raise(FileSel->window);
}
/* Quick macros for checking shift, control, alt, and caps lock. */
#define SHIFT_EVT(evt) ((evt == XK_Shift_L) || (evt == XK_Shift_R))
#define CTRL_EVT(evt) ((evt == XK_Control_L) || (evt == XK_Control_L))
#define ALT_EVT(evt) ((evt == XK_Alt_L) || (evt == XK_Alt_R))
#define CAPS_LOCK_EVT(evt) (evt == XK_Caps_Lock)
void KeyEvent(keyEvent* ev)
{
static int shift = 0;
if (ev == NULL) return;
if (GSkeyEvent != NULL) GSkeyEvent(ev);
if (ev->evt == KEYPRESS)
{
if (SHIFT_EVT(ev->key))
shift = 1;
if (CAPS_LOCK_EVT(ev->key))
{
//Set up anything we want to happen while caps lock is down.
//Config_hacks_backup = Config.Hacks;
}
switch (ev->key)
{
case XK_F1:
case XK_F2:
case XK_F3:
case XK_F4:
case XK_F5:
case XK_F6:
case XK_F7:
case XK_F8:
case XK_F9:
case XK_F10:
case XK_F11:
case XK_F12:
try
{
ProcessFKeys(ev->key - XK_F1 + 1, shift);
}
catch (Exception::CpuStateShutdown&)
{
// Woops! Something was unrecoverable. Bummer.
// Let's give the user a RunGui!
g_EmulationInProgress = false;
g_ReturnToGui = true;
}
break;
case XK_Escape:
signal(SIGINT, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
#ifdef PCSX2_DEVBUILD
if (g_SaveGSStream >= 3)
{
g_SaveGSStream = 4;// gs state
break;
}
#endif
if( Config.closeGSonEsc )
{
safe_delete( g_gsRecoveryState );
safe_delete( g_RecoveryState );
g_gsRecoveryState = new MemoryAlloc<u8>();
JustGsSavingState eddie;
eddie.FreezePlugin( "GS", gsSafeFreeze ) ;
eddie.gsFreeze();
PluginsResetGS();
}
ClosePlugins();
if (!UseGui) exit(0);
// fixme: The GUI is now capable of recieving control back from the
// emulator. Which means that when I set g_ReturnToGui here, the emulation
// loop in ExecuteCpu() will exit. You should be able to set it up so
// that it returns control to the existing GTK event loop, instead of
// always starting a new one via RunGui(). (but could take some trial and
// error) -- (air)
// Easier said then done; running gtk in two threads at the same time can't be
// done, and working around that is pretty fiddly.
g_ReturnToGui = true;
RunGui();
break;
default:
GSkeyEvent(ev);
break;
}
}
else if (ev->evt == KEYRELEASE)
{
if (SHIFT_EVT(ev->key))
shift = 0;
if (CAPS_LOCK_EVT(ev->key))
{
//Release caps lock
//Config_hacks_backup = Config.Hacks;
}
}
return;
}
void SysRestorableReset()
{
// already reset? and saved?
if( !g_EmulationInProgress ) return;
if( g_RecoveryState != NULL ) return;
try
{
g_RecoveryState = new MemoryAlloc<u8>( "Memory Savestate Recovery" );
RecoveryMemSavingState().FreezeAll();
safe_delete( g_gsRecoveryState );
g_EmulationInProgress = false;
}
catch( Exception::RuntimeError& ex )
{
Msgbox::Alert(
"Pcsx2 gamestate recovery failed. Some options may have been reverted to protect your game's state.\n"
"Error: %s", params ex.cMessage() );
safe_delete( g_RecoveryState );
}
}
void SysReset()
{
if (!sinit) return;
g_EmulationInProgress = false;
safe_delete( g_RecoveryState );
safe_delete( g_gsRecoveryState );
ResetPlugins();
ElfCRC = 0;
// Note : No need to call cpuReset() here. It gets called automatically before the
// emulator resumes execution.
}
bool SysInit()
{
if (sinit) return true;
sinit = true;
mkdir(SSTATES_DIR, 0755);
mkdir(MEMCARDS_DIR, 0755);
mkdir(LOGS_DIR, 0755);
#ifdef PCSX2_DEVBUILD
if (g_TestRun.plogname != NULL)
emuLog = fopen(g_TestRun.plogname, "w");
if (emuLog == NULL)
emuLog = fopen(LOGS_DIR "/emuLog.txt", "wb");
#endif
if (emuLog != NULL)
setvbuf(emuLog, NULL, _IONBF, 0);
PCSX2_MEM_PROTECT_BEGIN();
SysDetect();
if (!SysAllocateMem()) return false; // critical memory allocation failure;
SysAllocateDynarecs();
PCSX2_MEM_PROTECT_END();
while (LoadPlugins() == -1)
{
if (Pcsx2Configure() == FALSE)
{
Msgbox::Alert("Configuration failed. Exiting.");
exit(1);
}
}
return true;
}
void SysClose()
{
if (sinit == 0) return;
cpuShutdown();
ClosePlugins();
ReleasePlugins();
if (emuLog != NULL)
{
fclose(emuLog);
emuLog = NULL;
}
sinit = 0;
}
void *SysLoadLibrary(const char *lib)
{
return dlopen(lib, RTLD_NOW);
}
void *SysLoadSym(void *lib, const char *sym)
{
return dlsym(lib, sym);
}
const char *SysLibError()
{
return dlerror();
}
void SysCloseLibrary(void *lib)
{
dlclose(lib);
}
void SysRunGui()
{
RunGui();
}
void *SysMmap(uptr base, u32 size)
{
u8 *Mem;
Mem = mmap((uptr*)base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (Mem == MAP_FAILED) Console::Notice("Mmap Failed!");
return Mem;
}
void SysMunmap(uptr base, u32 size)
{
munmap((uptr*)base, size);
}

View File

@ -4,7 +4,10 @@ INCLUDES = $(shell pkg-config --cflags gtk+-2.0) -I@srcdir@/../ -I@srcdir@/../
bin_PROGRAMS = pcsx2
# the application source, library search path, and link libraries
pcsx2_SOURCES = Pref.cpp interface.c ConfigDlg.cpp DebugDlg.cpp GtkGui.cpp LnxMain.cpp LnxConsole.cpp LnxThreads.cpp support.c
pcsx2_SOURCES = \
interface.c support.c LnxMain.cpp LnxThreads.cpp LnxConsole.cpp LnxSysExec.cpp \
AboutDlg.cpp ConfigDlg.cpp DebugDlg.cpp AdvancedDlg.cpp CpuDlg.cpp HacksDlg.cpp Pref.cpp \
GtkGui.h Linux.h LnxMain.h ConfigDlg.h DebugDlg.h interface.h callbacks.h memzero.h support.h
pcsx2_LDFLAGS =

View File

@ -5,12 +5,12 @@
* 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
@ -21,14 +21,14 @@
FILE *pref_file;
char *data;
static void SetValue( const char *name, char *var)
static void SetValue(const char *name, char *var)
{
fprintf (pref_file,"%s = %s\n", name, var);
fprintf(pref_file, "%s = %s\n", name, var);
}
static void SetValuel( const char *name, s32 var)
static void SetValuel(const char *name, s32 var)
{
fprintf (pref_file,"%s = %x\n", name, var);
fprintf(pref_file, "%s = %x\n", name, var);
}
#define GetValue(name, var) {\
@ -50,15 +50,16 @@ static void SetValuel( const char *name, s32 var)
if (*tmp != '\n') sscanf(tmp, "%x", &var); \
} \
}
int LoadConfig() {
int LoadConfig()
{
struct stat buf;
int size;
if (stat(cfgfile, &buf) == -1) return -1;
size = buf.st_size;
pref_file = fopen(cfgfile,"r");
pref_file = fopen(cfgfile, "r");
if (pref_file == NULL) return -1;
data = (char*)malloc(size);
@ -85,7 +86,7 @@ int LoadConfig() {
GetValue("DEV9", Config.DEV9);
GetValue("USB", Config.USB);
GetValue("FW", Config.FW);
GetValuel("Patch", Config.Patch);
#ifdef PCSX2_DEVBUILD
GetValuel("varLog", varLog);
@ -93,7 +94,7 @@ int LoadConfig() {
GetValuel("Options", Config.Options);
GetValuel("Hacks", Config.Hacks);
GetValuel("Fixes", Config.GameFixes);
GetValuel("CustomFps", Config.CustomFps);
GetValuel("CustomFrameskip", Config.CustomFrameSkip);
GetValuel("CustomConsecutiveFrames", Config.CustomConsecutiveFrames);
@ -104,11 +105,12 @@ int LoadConfig() {
GetValuel("sseVUMXCSR", Config.sseVUMXCSR);
GetValuel("eeOptions", Config.eeOptions);
GetValuel("vuOptions", Config.vuOptions);
free(data);
#ifdef ENABLE_NLS
if (Config.Lang[0]) {
if (Config.Lang[0])
{
extern int _nl_msg_cat_cntr;
setenv("LANGUAGE", Config.Lang, 1);
@ -121,9 +123,10 @@ int LoadConfig() {
/////////////////////////////////////////////////////////
void SaveConfig() {
void SaveConfig()
{
pref_file = fopen(cfgfile,"w");
pref_file = fopen(cfgfile, "w");
if (pref_file == NULL) return;
SetValue("Bios", Config.Bios);
@ -143,12 +146,12 @@ void SaveConfig() {
SetValue("DEV9", Config.DEV9);
SetValue("USB", Config.USB);
SetValue("FW", Config.FW);
SetValuel("Options", Config.Options);
// Remove Fast Branches hack for now:
Config.Hacks &= ~0x80;
SetValuel("Hacks", Config.Hacks);
SetValuel("Fixes", Config.GameFixes);
@ -163,7 +166,7 @@ void SaveConfig() {
SetValuel("sseVUMXCSR", Config.sseVUMXCSR);
SetValuel("eeOptions", Config.eeOptions);
SetValuel("vuOptions", Config.vuOptions);
#ifdef PCSX2_DEVBUILD
SetValuel("varLog", varLog);
#endif